Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Contains the SQL data types, type errors, and a few supporting functions.
- data Type
- = ScalarType Text
- | DomainType Text
- | EnumType Text
- | UnknownType
- | ArrayType Type
- | NamedCompositeType Text
- | CompositeType [(Text, TypeExtra)]
- | TrefType [((Text, Text), TypeExtra)]
- | AnonymousCompositeType [Type]
- | Pseudo PseudoType
- data TypeExtra = TypeExtra {
- teType :: Type
- tePrecision :: Maybe Int
- teScale :: Maybe Int
- teNullable :: Bool
- data PseudoType
- data TypeError
- = NoMatchingOperator Text [Type]
- | AmbiguousOperator Text [Type]
- | TypelessEmptyArray
- | IncompatibleTypeSet [Type]
- | IncompatibleTypes Type Type
- | WrongNumberOfColumns
- | WrongTypes Type [Type]
- | IncompatibleUnionTypes Type Type
- | TypeAlreadyExists Type
- | SchemaAlreadyExists Text
- | BadCatalogUpdate Text
- | UnrecognisedRelation (Text, Text)
- | DomainDefNotFound Type
- | TypeNotKnown Type
- | UnknownTypeName Text
- | UnrecognisedIdentifier Text
- | UnrecognisedCorrelationName Text
- | SchemadColumnName Text
- | DbSchemadColumnName Text
- | BadStarExpand
- | InternalError String
- | AmbiguousIdentifier Text
- | OdbcFuncBadContent
- | DuplicateColumnName Text
- | TooManyColumnsInInsert
SQL types
Standard types of things. This covers all the usual postgres types plus some extra ones added for use by the hssqlppp typechecker
ScalarType Text | basic type of a scalar value. These are either built in types in postgres, or implemented in C or similar |
DomainType Text | a domain type is used for a constraint on a table column which would used on multiple columns on a table or in multiple tables, using a domain type is a way of just writing the constraint once |
EnumType Text | enum type, not really supported in hssqlppp yet |
UnknownType | String literals in postgres have an unknown type. The effective type is determined using what seems to amount to some simple ad hoc rules based on the context of the string literal. Hssqlppp also treats ? placeholders and nulls the same way, so they have UnknownType, not sure how closely this matches postgres |
ArrayType Type | postgres automatically creates an array type for every scalar type (plus some other types?) If there is no array type for a type in the catalog, then you can't work with arrays of that type |
NamedCompositeType Text | refer to composite type in catalog by name. not sure if this needs to exist along with CompositeType |
CompositeType [(Text, TypeExtra)] | refer to composite type by structure |
TrefType [((Text, Text), TypeExtra)] | CompositeTypeExtra [(Text,TypeExtra)] | hack to support the environment for a tref |
AnonymousCompositeType [Type] | the fields are anonymous as well as the type itself |
Pseudo PseudoType | The pseudo type is used for types which only appear as argument or return types in function definitions and/or are used only in plpgsql and not regular sql. hssqlppp also follows this usage for the types used in hssqlppp which don't have an exact counterpart in postgres |
Quick fix to add precision and nullable information to the annotation types. This approach should be revisited, maybe this information should be in the Type type?
data PseudoType Source #
Pseudo types: mainly used for the argument and return types of functions. The weird undocumented types are just used to represent functions with those types which are in the postgres default catalog
SetOfType Type | setof is used for set returning functions |
AnyElement | used to represent polymorphic functions, all the AnyElement parameters and the return type if AnyElement must be the same type for a given function call invocation. |
AnyArray | like AnyElement, but the type must be an array type |
AnyEnum | like AnyElement, but the type must be an enum type |
AnyNonArray | like AnyElement, but the type must be a non array type |
AnyRange | |
Any | Any drops the restriction that all the Any types must be the same type |
Record (Maybe Type) | record types are used in plpgsql for a sort of dynamic typing or rough polymorphism substitute. They can refer to values of named composite type, composite type or anonymous composite type, not sure if non composite types as well. |
Void | presumably used for the types of OLD and NEW in a trigger function. Hssqlppp will probably use the Record type above for these. | TriggerRecord | Trigger | cstring - a C string | Cstring | represents the return type of a function which doesn't return anything. Not sure if it is used anywhere else |