|
Database.HsSqlPpp.Ast.Environment |
|
|
|
|
Description |
This module contains the environment data types and a helper functions.
You almost certainly will never have to do anything with Environments apart
from read them from a database to supply to the annotation function. If you
only need to type check against the default template1 catalog, then you
don't even need to do this - is you use the annotation function with
no Environment parameter, it uses the default template1 catalog.
The environment data type serves the following purposes:
- Contains all the catalog information needed to type check against
an existing database.
- A copy of the catalog information from a default template1
database is included - defaultTemplate1Environment, at some
point this might be used to allow typechecking sql code against
this catalog without having an available PostGreSQL install.
- It is used internally to keep track of updates to the catalog
whilst running an annotation process (e.g. so that a select can
type check against a create table given in the same source). It
is also used to track other identifier types, such as attribute
references in select expressions, and argument and variable
types inside create function statements.
You can see what kind of stuff is contained in the Environment type
by looking at the EnvironmentUpdate type.
|
|
Synopsis |
|
|
|
|
Data types
|
|
|
The main datatype, this holds the catalog and context
information to type check against.
|
|
|
Updates
|
|
|
Constructors | EnvCreateScalar Type String Bool | add a new scalar type with the name given, also creates
an array type automatically
| EnvCreateDomain Type Type | | EnvCreateComposite String [(String, Type)] | | EnvCreateCast Type Type CastContext | | EnvCreateTable String [(String, Type)] [(String, Type)] | | EnvCreateView String [(String, Type)] | | EnvCreateFunction FunFlav String [Type] Type | | EnvStackIDs [QualifiedIDs] | to allow an unqualified identifier reference to work you need to
supply an extra entry with "" as the alias, and all the fields,
in the case of joins, these unaliased fields need to have the
duplicates removed and the types resolved
| EnvSetStarExpansion [QualifiedIDs] | to allow an unqualified star to work you need to
supply an extra entry with "" as the alias, and all the fields
|
| Instances | |
|
|
bits and pieces
|
|
|
Represents the types of the ids available, currently used for
resolving identifiers inside select expressions. Will probably
change as this is fixed to support more general contexts. The
components represent the qualifying name (empty string for no
qualifying name), the list of identifier names with their types,
and the list of system column identifier names with their types.
|
|
|
Use to note what the flavour of a cast is, i.e. if/when it can
be used implicitly.
| Constructors | ImplicitCastContext | | AssignmentCastContext | | ExplicitCastContext | |
| Instances | |
|
|
|
Used to distinguish between standalone composite types, and
automatically generated ones, generated from a table or view
respectively.
| Constructors | Composite | | TableComposite | | ViewComposite | |
| Instances | |
|
|
|
Provides the definition of a composite type. The components are
composite (or table or view) name, the flavour of the composite,
the types of the composite attributes, and the types of the
system columns iff the composite represents a table type (the
third and fourth components are always UnnamedCompositeTypes).
|
|
|
The components are: function (or operator) name, argument
types, and return type.
|
|
|
The components are domain type, base type (todo: add check
constraint).
|
|
|
Constructors | FunPrefix | | FunPostfix | | FunBinary | | FunName | | FunAgg | |
| Instances | |
|
|
Environment values
|
|
|
Represents an empty environment. This doesn't contain things
like the 'and' operator, and so if you try to use it it will
almost certainly not work.
|
|
|
Represents what you probably want to use as a starting point if
you are building an environment from scratch. It contains
information on built in function like things that aren't in the
PostGreSQL catalog, such as greatest, coalesce, keyword operators
like 'and', etc..
|
|
|
|
Functions
|
|
readEnvironmentFromDatabase | Source |
|
:: String | name of the database to read
| -> IO [EnvironmentUpdate] | | Creates an EnvironmentUpdate list by reading the database given.
To create an Environment value from this, use
env <- readEnvironmentFromDatabase something
let newEnv = updateEnvironment defaultEnvironment env
|
|
|
|
Applies a list of EnvironmentUpdates to an Environment value
to produce a new Environment value.
|
|
operator utils
|
|
|
Constructors | BinaryOp | | PrefixOp | | PostfixOp | |
| Instances | |
|
|
|
|
|
|
Produced by Haddock version 2.6.0 |