This module contains the database catalog data types and helper functions.
The catalog 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 -
- 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 Catalog type
by looking at the
- data Catalog
- data CatalogUpdate
- = CatCreateScalar Type String Bool
- | CatCreateDomain Type Type
- | CatCreateComposite String [(String, Type)]
- | CatCreateCast Type Type CastContext
- | CatCreateTable String [(String, Type)] [(String, Type)]
- | CatCreateView String [(String, Type)]
- | CatCreateFunction FunFlav String [Type] Type Bool
- | CatDropFunction Bool String [Type]
- ppCatUpdate :: CatalogUpdate -> String
- data CastContext
- data CompositeFlavour
- type CompositeDef = (String, CompositeFlavour, Type, Type)
- type FunctionPrototype = (String, [Type], Type, Bool)
- type DomainDefinition = (Type, Type)
- data FunFlav
- emptyCatalog :: Catalog
- defaultCatalog :: Catalog
- defaultTemplate1Catalog :: Catalog
- data CatalogDiff = CatalogDiff [CatalogUpdate] [CatalogUpdate]
- compareCatalogs :: Catalog -> Catalog -> Catalog -> CatalogDiff
- ppCatDiff :: CatalogDiff -> String
- updateCatalog :: Catalog -> [CatalogUpdate] -> Either [TypeError] Catalog
- deconstructCatalog :: Catalog -> [CatalogUpdate]
- data OperatorType
- getOperatorType :: Catalog -> String -> Either [TypeError] OperatorType
- isOperatorName :: String -> Bool
The main datatype, this holds the catalog and context information to type check against.
|CatCreateScalar Type String Bool|
add a new scalar type with the name given, also creates an array type automatically
|CatCreateDomain Type Type|
add a new domain to the catalog
|CatCreateComposite String [(String, Type)]|
add a new composite type to the catalog
|CatCreateCast Type Type CastContext|
add a new cast to the catalog
|CatCreateTable String [(String, Type)] [(String, Type)]|
add a new table to the catalog with the given public and private columns also creates the composite type to go with this table
|CatCreateView String [(String, Type)]|
add the view to the catalog, using the column names and types supplied
|CatCreateFunction FunFlav String [Type] Type Bool|
add a new function to the catalog
|CatDropFunction Bool String [Type]|
drop a function from the catalog
attempt to show a readable representation of a
bits and pieces
Use to note what the flavour of a cast is, i.e. if/when it can be used implicitly.
Used to distinguish between standalone composite types, and automatically generated ones, generated from a table or view respectively.
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
The components are: function (or operator) name, argument types, return type and is variadic.
The components are domain type, base type (todo: add check constraint).
Represents an empty catalog. This doesn't contain things
like the 'and' operator,
defaultCatalog contains these.
Represents what you probably want to use as a starting point if you are building an catalog 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..
items in first catalog and not second, items in second and not first.
find differences between two catalogs