Contains the data types and functions for annotating an ast and working with annotated trees, including the representations of SQL data types.
- are attached to most of the ast node data types, but not quite all of them;
- types annotations are attached to most nodes during type checking;
- type errors are attached to the lowest down node that the type error is detected at;
- nodes who fail the type check or whose type depends on a node with
a type error are given the type
- each statement has an additional
StatementInfoannotation attached to it;
- the parser fills in the source position annotation in every annotatable ast node.
- typeCheckStatements :: Catalog -> [Statement] -> (Catalog, [Statement])
- typeCheckParameterizedStatement :: Catalog -> Statement -> Either String Statement
- typeCheckQueryExpr :: Catalog -> QueryExpr -> QueryExpr
- typeCheckScalarExpr :: Catalog -> ScalarExpr -> ScalarExpr
- fixUpIdentifiers :: Catalog -> [Statement] -> [Statement]
- fixUpIdentifiersQE :: Catalog -> QueryExpr -> QueryExpr
- fixUpIdentifiersSE :: Catalog -> ScalarExpr -> ScalarExpr
- addExplicitCasts :: Data a => a -> a
- canonicalizeTypeNames :: Data a => a -> a
- getStatementAnnotations :: Data a => a -> [Annotation]
typechecking/ annotation functions
Takes an ast, checks against catalog passed, and adds annotations, including types, type errors, and statement info. Returns the updated catalog as well as the annotated ast.
Unfinished version of type check which can type check an individual statement with ? or positional arg placeholders in it. Will error if the statement isn't select, update, insert or delete. For use in type checking embedded parameterized statements. Does all typechecking and annotation that the regular typecheck does.
Testing utility, mainly used to check an expression for type errors or to get its type.
transform the tree by converting * to explicit lists of columns and adding qualifiers to all column references
Run through a typechecked tree and add in explicit casts where implicit casts are used to typecheck. Does function and operator calls, case result expressions, and string, integer and float literals at the moment, todo: union, array, greatest, least
Convert all the typenames in the ast to canonical form e.g. int -> int4