diff --git a/Database/HsSqlPpp/Ast/Annotation.lhs b/Database/HsSqlPpp/Ast/Annotation.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Ast/Annotation.lhs
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This is the public module to the annotation data types and support
-functions (not including those that depend on the ast data types).
-
-> {- | Contains the annotation data types and a few auxiliary functions.
-> -}
-
-> module Database.HsSqlPpp.Ast.Annotation
->     (
->      -- * Annotation data types
->      Annotation
->     ,AnnotationElement(..)
->     ,StatementType(..)
->     ,stripAnnotations
->     ,updateAnnotation
->     ,getAnnotation
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.AstAnnotation
diff --git a/Database/HsSqlPpp/Ast/Ast.lhs b/Database/HsSqlPpp/Ast/Ast.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Ast/Ast.lhs
+++ /dev/null
@@ -1,95 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This is the public module for the ast nodes.
-
-> {- | This module contains the ast node data types. They are very
->      permissive, in that they allow a lot of invalid SQL to be
->      represented. The type checking process should catch all invalid
->      trees, but doesn't quite manage at the moment.  Sorry about all
->      the seemingly pointless type synonyms below, they are an
->      artefact of using UUAGC. You can see labels for the fields by
->      looking at the ag source here:
->      <http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head:/Database/HsSqlPpp/AstInternals/AstInternal.ag>
->      -}
-
-> module Database.HsSqlPpp.Ast.Ast
->     (
->      -- * Main nodes
->      StatementList
->     ,Statement (..)
->     ,Expression (..)
->     ,SelectExpression (..)
->      -- * Components
->      -- ** Selects
->     ,SelectList (..)
->     ,SelectItem (..)
->     ,TableRef (..)
->     ,TableAlias(..)
->     ,JoinExpression (..)
->     ,JoinType (..)
->     ,Natural (..)
->     ,CombineType (..)
->     ,Direction (..)
->     ,Distinct (..)
->     ,InList (..)
->     ,LiftFlavour (..)
->     ,FrameClause(..)
->      -- ** dml
->     ,SetClause (..)
->     ,CopySource (..)
->     ,RestartIdentity (..)
->      -- ** ddl
->     ,AttributeDef (..)
->     ,RowConstraint (..)
->     ,Constraint (..)
->     ,AlterTableAction(..)
->     ,TypeAttributeDef (..)
->     ,TypeName (..)
->     ,DropType (..)
->     ,IfExists (..)
->     ,Cascade (..)
->     ,TriggerWhen(..)
->     ,TriggerEvent(..)
->     ,TriggerFire(..)
->      -- ** functions
->     ,FnBody (..)
->     ,ParamDef (..)
->     ,VarDef (..)
->     ,RaiseType (..)
->     ,Volatility (..)
->     ,Language (..)
->      -- ** misc
->      ,SetValue(..)
->      -- ** typedefs
->     ,ExpressionListStatementListPairList
->     ,ExpressionListStatementListPair
->     ,ExpressionList
->     ,MaybeSelectList
->     ,StringList
->     ,ParamDefList
->     ,AttributeDefList
->     ,ConstraintList
->     ,TypeAttributeDefList
->     ,TypeNameList
->     ,StringTypeNameListPair
->     ,StringTypeNameListPairList
->     ,ExpressionStatementListPairList
->     ,SetClauseList
->     ,CaseExpressionListExpressionPairList
->     ,MaybeExpression
->     ,MaybeBoolExpression
->     ,TableRefList
->     ,ExpressionListList
->     ,SelectItemList
->     ,OnExpr
->     ,RowConstraintList
->     ,VarDefList
->     ,ExpressionStatementListPair
->     ,CaseExpressionListExpressionPair
->     ,CaseExpressionList
->     ,ExpressionDirectionPair
->     ,ExpressionDirectionPairList
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.AstInternal
-
diff --git a/Database/HsSqlPpp/Ast/Catalog.lhs b/Database/HsSqlPpp/Ast/Catalog.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Ast/Catalog.lhs
+++ /dev/null
@@ -1,63 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This is the public api to the catalog data type, it just forwards
-the public part of CatalogInternal, which is the module used by
-the type checking code.
-
-> {- | 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 - 'defaultTemplate1Catalog'.
->
->  * 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 'CatalogUpdate' type.
->
-> -}
-
-> module Database.HsSqlPpp.Ast.Catalog
->     (
->      -- * Data types
->      Catalog
->      -- ** Updates
->     ,CatalogUpdate(..)
->     ,ppCatUpdate
->      -- ** bits and pieces
->     ,CastContext(..)
->     ,CompositeFlavour(..)
->     ,CompositeDef
->     ,FunctionPrototype
->     ,DomainDefinition
->     ,FunFlav(..)
->      -- * 'Catalog' values
->     ,emptyCatalog
->     ,defaultCatalog
->     ,defaultTemplate1Catalog
->      -- * 'Catalog' comparison
->     ,CatalogDiff(..)
->     ,compareCatalogs
->     ,ppCatDiff
->      -- * Functions
->     ,readCatalogFromDatabase
->     ,updateCatalog
->     ,deconstructCatalog
->      -- * operator utils
->     ,OperatorType(..)
->     ,getOperatorType
->     ,isOperatorName
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogReader
-> import Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
diff --git a/Database/HsSqlPpp/Ast/SqlTypes.lhs b/Database/HsSqlPpp/Ast/SqlTypes.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Ast/SqlTypes.lhs
+++ /dev/null
@@ -1,26 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This is the public module to the SQL data types, mainly from TypeType.
-
-
-> {- | Contains the SQL data types, type errors, and a few supporting
->      functions.
-> -}
-
-> module Database.HsSqlPpp.Ast.SqlTypes
->     (
->      -- * SQL types
->      Type (..)
->     ,PseudoType (..)
->      -- * type aliases
->      -- | aliases for all the sql types with multiple names
->      -- these give you the canonical names
->     ,typeSmallInt,typeBigInt,typeInt,typeNumeric,typeFloat4
->     ,typeFloat8,typeVarChar,typeChar,typeBool
->     ,canonicalizeTypeName
->     ,canonicalizeTypes
->      -- * Type errors
->     ,TypeError (..)
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.TypeType
diff --git a/Database/HsSqlPpp/Ast/TypeChecker.lhs b/Database/HsSqlPpp/Ast/TypeChecker.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Ast/TypeChecker.lhs
+++ /dev/null
@@ -1,42 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This is the public module for the type checking functionality.
-
-> {- | Contains the data types and functions for annotating
->  an ast and working with annotated trees, including the
->  representations of SQL data types.
->
-> Annotations:
->
-> * 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 'TypeCheckFailed';
->
-> * each statement has an additional 'StatementInfo' annotation attached to it;
->
-> * the parser fills in the source position annotation in every annotatable ast node.
->
-> -}
-> module Database.HsSqlPpp.Ast.TypeChecker
->     (
->      -- * typechecking/ annotation functions
->       typeCheck
->      ,typeCheckPS
->      ,typeCheckExpression
->      -- * Annotated tree utils
->     ,getTopLevelTypes
->     ,getTopLevelInfos
->     ,getTopLevelCatUpdates
->     ,getTypeErrors
->     ,getStatementAnnotations
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.AstInternal
-> import Database.HsSqlPpp.AstInternals.AstAnnotation
-> import Database.HsSqlPpp.AstInternals.AnnotationUtils
-
diff --git a/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs b/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs
+++ /dev/null
@@ -1,27 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This module contains some utilities and generic code for working with
-asts and annotations which depend on the ast types.
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.AstInternals.AnnotationUtils
->     (
->      getStatementAnnotations
->     ) where
-
-> import Data.Generics
-
-> import Database.HsSqlPpp.AstInternals.AstInternal
-> import Database.HsSqlPpp.AstInternals.AstAnnotation
-
-> -- | Run through the ast and return all the annotations attached to
-> --   a Statement node.
-> getStatementAnnotations :: Data a => a -> [Annotation]
-> getStatementAnnotations st =
->     everything (++) (mkQ [] ga) st
->     where
->       ga :: Statement -> [Annotation]
->       ga s = [getAnnotation s]
-
-
diff --git a/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs b/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs
+++ /dev/null
@@ -1,218 +0,0 @@
-Copyright 2009 Jake Wheat
-
-The annotation data types and utilities for working with them.
-
-Annotations are used to store source positions, types, errors,
-warnings, catalog deltas, information, and other stuff a client might
-want to use when looking at an ast. Internal annotations which are
-used in the type-checking/ annotation process use the attribute
-grammar code and aren't exposed.
-
-> {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable,ScopedTypeVariables,
->   RankNTypes,FlexibleContexts #-}
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.AstInternals.AstAnnotation
->     (
->      Annotation
->     ,AnnotationElement(..)
->     --,stripAnnotations
->     ,getTopLevelTypes
->     ,getTopLevelInfos
->     ,getTopLevelCatUpdates
->     ,getTypeAnnotation
->     ,getTypeErrors
->     ,stripAnnotations
->     ,filterAnnotations
->     ,updateAnnotation
->     ,getAnnotation
->     ,getAnnotations
->     --,getTypeErrors
->     --,pack
->     ,StatementType(..)
->     ,getSIAnnotation
->     ) where
-
-> import Data.Generics
-> import Control.Arrow
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-
-> -- | Annotation type - one of these is attached to most of the
-> -- data types used in the ast.
-> type Annotation = [AnnotationElement]
-
-> -- | the elements of an annotation. Source positions are generated by
-> -- the parser, the rest come from the separate ast annotation process.
-> data AnnotationElement = SourcePos String Int Int
->                        | TypeAnnotation Type
->                        | TypeErrorA TypeError
->                        | StatementTypeA StatementType
->                        | CatUpdates [CatalogUpdate]
->                        | FunctionPrototypeA FunctionPrototype
->                        | InferredType Type
->                          deriving (Eq, Show,Typeable,Data)
-
-Use syb to pull annotation values from an ast.
-
-I like to cut and paste code from the internet which I don't
-understand, then keep changing it till it compiles and passes the tests.
-
-
-> -- | run through the ast, and pull the type annotation from each
-> -- of the top level items.
-> getTopLevelTypes :: Data a => [a] -> [Type]
-> getTopLevelTypes st =
->     getTopLevelXs typeAnnot st
->     where
->       typeAnnot :: Annotation -> [Type]
->       typeAnnot (x:xs) = case x of
->                                 TypeAnnotation t -> [t]
->                                 _ -> typeAnnot xs
->       typeAnnot [] = [TypeCheckFailed] -- error "couldn't find type annotation"
-
-> getTopLevelXs :: forall a b a1.
->                  (Data a1, Typeable b) =>
->                 (b -> [a]) -> a1 -> [a]
-> getTopLevelXs st = everythingOne (++) $ mkQ [] st
-
-
-> getTypeAnnotation :: Data a => a -> Type
-> getTypeAnnotation st =
->     case getTopLevelX typeAnnot st of
->       x:_ -> x
->       [] -> TypeCheckFailed
->     where
->       typeAnnot :: Annotation -> [Type]
->       typeAnnot (x:xs) = case x of
->                                 TypeAnnotation t -> [t]
->                                 _ -> typeAnnot xs
->       typeAnnot [] = [TypeCheckFailed]
-
-> getTopLevelX :: forall a b a1.
->                 (Data a1, Typeable b) =>
->                (b -> [a]) -> a1 -> [a]
-> getTopLevelX p = everythingOne (++) (mkQ [] p)
-
-
- > everythingTwo :: (r -> r -> r) -> GenericQ r -> GenericQ r
- > everythingTwo k f x
- >  = foldl k (f x) (gmapQ (everythingOne k f) x)
-
-> everythingZero :: (r -> r -> r) -> GenericQ r -> GenericQ r
-> everythingZero k f x
->  = foldl k (f x) (gmapQ f x)
-
-> everythingOne :: (r -> r -> r) -> GenericQ r -> GenericQ r
-> everythingOne k f x
->  = foldl k (f x) (gmapQ (everythingZero k f) x)
-
-> getSIAnnotation :: Annotation -> [Maybe StatementType]
-> getSIAnnotation (x:xs) = case x of
->                                 StatementTypeA t -> [Just t]
->                                 _ -> getSIAnnotation xs
-> getSIAnnotation []  = [Nothing]
-
-> getEuAnnotation :: Annotation -> [[CatalogUpdate]]
-> getEuAnnotation (x:xs) = case x of
->                                 CatUpdates t -> t:getEuAnnotation xs
->                                 _ -> getEuAnnotation xs
-> getEuAnnotation [] = []
-
-
-> -- | Run through the ast given and return a list of statementtypes
-> -- from the top level items.
-> getTopLevelInfos :: Data a => [a] -> [Maybe StatementType]
-> getTopLevelInfos = getTopLevelXs getSIAnnotation
-
-> getTopLevelCatUpdates ::  Data a => [a] -> [[CatalogUpdate]]
-> getTopLevelCatUpdates = getTopLevelXs getEuAnnotation
-
-> data StatementType = StatementType [Type] [(String,Type)]
->                      deriving (Eq,Show,Typeable,Data)
-
-
-question:
-if a node has no source position e.g. the all in select all or select
-   distinct may correspond to a token or may be synthesized as the
-   default if neither all or distinct is present. Should this have the
-   source position of where the token would have appeared, should it
-   inherit it from its parent, should there be a separate ctor to
-   represent a fake node with no source position?
-
-
-hack job, often not interested in the source positions when testing
-the asts produced, so this function will reset all the source
-positions to empty ("", 0, 0) so we can compare them for equality, etc.
-without having to get the positions correct.
-
-> -- | strip all the annotations from a tree. E.g. can be used to compare
-> -- two asts are the same, ignoring any source position annotation differences.
-> stripAnnotations :: (Data a) => a -> a
-> stripAnnotations = filterAnnotations (const False)
-
- >>                    everywhere (mkT stripAn)
- >                    where
- >                      stripAn :: [AnnotationElement] -> [AnnotationElement]
- >                      stripAn _ = []
-
-
-> filterAnnotations :: (Data a) => (AnnotationElement -> Bool) -> a -> a
-> filterAnnotations f =
->     everywhere (mkT filterAnn)
->     where
->       filterAnn :: [AnnotationElement] -> [AnnotationElement]
->       filterAnn = filter f
-
-
-> -- | runs through the ast given and returns a list of all the type errors
-> -- in the ast. Recurses into all ast nodes to find type errors.
-> -- This is the function to use to see if an ast has passed the type checking process.
-> -- Returns a Maybe SourcePos and the list of type errors for each node which has one or
-> -- more type errors.
-> getTypeErrors :: (Data a) => a -> [(Maybe AnnotationElement,[TypeError])]
-> getTypeErrors sts =
->     filter (\(_,te) -> not $ null te) $ map (gtsp &&& gte) $ getAnnotations sts
->     where
->       gte (a:as) = case a of
->                     TypeErrorA e -> e:gte as
->                     _ -> gte as
->       gte _ = []
-
->       gtsp (a:as) = case a of
->                     s@(SourcePos _ _ _) -> Just s
->                     _ -> gtsp as
->       gtsp _ = Nothing
-
-
-
-> -- | Update all the annotations in a tree using the function supplied
-> updateAnnotation :: forall a.(Data a) =>
->                   (Annotation -> Annotation) -> a -> a
-> updateAnnotation f = oneLevel (mkT f)
-
-> oneLevel :: (forall a.Data a => a -> a)
->          -> (forall a.Data a => a -> a)
-> oneLevel f = gmapT f
-
-> -- | get the annotation for the root of the tree passed
-> getAnnotation :: forall a.(Data a) => a -> Annotation
-> getAnnotation a =
->   case oneLevelQ (mkQ [] f) a of
->     an:_ -> an
->     [] -> []
->   where
->     f :: Annotation -> Annotation
->     f = id
-
-> oneLevelQ :: forall a.Data a => forall u. (forall d. (Data d) => d -> u) -> a -> [u]
-> oneLevelQ = gmapQ
-
-
-> getAnnotations :: forall a.(Data a) =>
->                   a -> [Annotation]
-> getAnnotations = listifyWholeLists (\(_::Annotation) -> True)
-
-> listifyWholeLists :: Typeable b => ([b] -> Bool) -> GenericQ [[b]]
-> listifyWholeLists blp = flip (synthesize id (.) (mkQ id (\bl _ -> if blp bl then (bl:) else id))) []
diff --git a/Database/HsSqlPpp/AstInternals/AstInternal.ag b/Database/HsSqlPpp/AstInternals/AstInternal.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/AstInternal.ag
+++ /dev/null
@@ -1,783 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the ast nodes, and the api functions to pass an ast
-and get back type information.
-
-It uses the Utrecht University Attribute Grammar system:
-
-http://www.cs.uu.nl/wiki/bin/view/HUT/AttributeGrammarSystem
-http://www.haskell.org/haskellwiki/The_Monad.Reader/Issue4/Why_Attribute_Grammars_Matter
-
-The attr and sem definitions are in TypeChecking.ag, which is included
-into this file.
-
-These ast nodes are both used as the result of successful parsing, and
-as the input to the type checker (and the output from the type
-checker), and the pretty printer.
-
-= compiling
-
-use
-
-uuagc  -dcfwsp --cycle --genlinepragmas AstInternal.ag
-
-to generate a new AstInternal.hs from this file (cycle will check for
-cycles - it's bad if you get any of these, and genlinepragmas mean
-that you'll be able to view the original source ag positions when
-there are errors or warnings compiling the generated hs file, which
-you want much more often than not).
-
-(install uuagc with
-cabal install uuagc
-)
-
--}
-MODULE {Database.HsSqlPpp.AstInternals.AstInternal}
-{
-    -- {-# LANGUAGE DeriveDataTypeable,RankNTypes,ScopedTypeVariables #-}
-    -- {-# OPTIONS_HADDOCK hide  #-}
-    --from the ag files:
-    --ast nodes
-    Statement (..)
-   ,SelectExpression (..)
-   ,FnBody (..)
-   ,SetClause (..)
-   ,TableRef (..)
-   ,TableAlias(..)
-   ,JoinExpression (..)
-   ,JoinType (..)
-   ,SelectList (..)
-   ,SelectItem (..)
-   ,CopySource (..)
-   ,AttributeDef (..)
-   ,RowConstraint (..)
-   ,AlterTableAction(..)
-   ,Constraint (..)
-   ,TypeAttributeDef (..)
-   ,ParamDef (..)
-   ,VarDef (..)
-   ,RaiseType (..)
-   ,CombineType (..)
-   ,Volatility (..)
-   ,Language (..)
-   ,TypeName (..)
-   ,DropType (..)
-   ,Cascade (..)
-   ,Direction (..)
-   ,Distinct (..)
-   ,Natural (..)
-   ,IfExists (..)
-   ,RestartIdentity (..)
-   ,Expression (..)
-   ,FrameClause(..)
-   ,InList (..)
-   ,LiftFlavour(..)
-   ,TriggerWhen(..)
-   ,TriggerEvent(..)
-   ,TriggerFire(..)
-   ,StatementList
-   ,ExpressionListStatementListPairList
-   ,ExpressionListStatementListPair
-   ,ExpressionList
-   ,StringList
-   ,ParamDefList
-   ,AttributeDefList
-   ,ConstraintList
-   ,TypeAttributeDefList
-   ,TypeNameList
-   ,StringTypeNameListPair
-   ,StringTypeNameListPairList
-   ,ExpressionStatementListPairList
-   ,SetClauseList
-   ,CaseExpressionListExpressionPairList
-   ,MaybeExpression
-   ,TableRefList
-   ,ExpressionListList
-   ,SelectItemList
-   ,OnExpr
-   ,RowConstraintList
-   ,VarDefList
-   ,ExpressionStatementListPair
-   ,CaseExpressionListExpressionPair
-   ,CaseExpressionList
-   ,ExpressionDirectionPair
-   ,ExpressionDirectionPairList
-   ,MaybeBoolExpression
-   ,MaybeSelectList
-   ,SetValue(..)
-   -- typechecking
-   ,typeCheck
-   ,typeCheckPS
-   ,typeCheckExpression
-}
-
-{
-import Data.Maybe
-import Data.List
-import Debug.Trace
---import Control.Monad.Error
-import Data.Either
-import Control.Applicative
-import Data.Generics
-import Data.Char
-import Control.Monad.State
-
-import Database.HsSqlPpp.AstInternals.TypeType
-import Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
-import Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
-import Database.HsSqlPpp.AstInternals.AstAnnotation
-import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-import Database.HsSqlPpp.AstInternals.TypeChecking.LocalIdentifierBindings
---import Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
-import Database.HsSqlPpp.Utils
-import Data.Generics.PlateData
-
-}
-
-{-
-================================================================================
-
-SQL top level statements
-
-everything is chucked in here: dml, ddl, plpgsql statements
-
--}
-
-DATA Statement
-
---queries
-
-    | SelectStatement ann:Annotation ex:SelectExpression
-
--- dml
-
-    --table targetcolumns insertdata(values or select statement) returning
-    | Insert ann:Annotation
-             table : String
-             targetCols : StringList
-             insData : SelectExpression
-             returning : MaybeSelectList
-    --tablename setitems where returning
-    | Update ann:Annotation
-             table : String
-             assigns : SetClauseList
-             whr : MaybeBoolExpression
-             returning : MaybeSelectList
-    --tablename, where, returning
-    | Delete ann:Annotation
-             table : String
-             whr : MaybeBoolExpression
-             returning : MaybeSelectList
-    --tablename column names, from
-    | Copy ann:Annotation
-           table : String
-           targetCols : StringList
-           source : CopySource
-    --represents inline data for copy statement
-    | CopyData ann:Annotation insData : String
-    | Truncate ann:Annotation
-               tables: StringList
-               restartIdentity : RestartIdentity
-               cascade : Cascade
-
--- ddl
-
-    | CreateTable ann:Annotation
-                  name : String
-                  atts : AttributeDefList
-                  cons : ConstraintList
-    | AlterTable ann:Annotation
-                 name : String
-                 actions : {[AlterTableAction]}
-    | CreateSequence ann:Annotation
-                     name:String
-                     incr:Integer
-                     min:Integer
-                     max:Integer
-                     start:Integer
-                     cache:Integer
-    | AlterSequence ann:Annotation
-                    name:String
-                    ownedBy: String
-    | CreateTableAs ann:Annotation
-                    name : String
-                    expr : SelectExpression
-    | CreateView ann:Annotation
-                 name : String
-                 expr : SelectExpression
-    | CreateType ann:Annotation
-                 name : String
-                 atts : TypeAttributeDefList
-    -- language name args rettype bodyquoteused body vol
-    | CreateFunction ann:Annotation
-                     name : String
-                     params : ParamDefList
-                     rettype : TypeName
-                     lang : Language
-                     bodyQuote : String
-                     body : FnBody
-                     vol : Volatility
-    -- name type checkexpression
-    | CreateDomain ann:Annotation
-                   name : String
-                   typ : TypeName
-                   checkName: String
-                   check : MaybeBoolExpression
-    | CreateLanguage ann:Annotation
-                     name:String
-    | CreateTrigger ann:Annotation
-                    name:String
-                    wh : TriggerWhen
-                    events: {[TriggerEvent]}
-                    tbl : String
-                    firing : TriggerFire
-                    fnName : String
-                    fnArgs : {[Expression]}
-    -- ifexists (name,argtypes)* cascadeorrestrict
-    | DropFunction ann:Annotation
-                   ifE : IfExists
-                   sigs : StringTypeNameListPairList
-                   cascade : Cascade
-    -- ifexists names cascadeorrestrict
-    | DropSomething ann:Annotation
-                    dropType : DropType
-                    ifE : IfExists
-                    names : StringList
-                    cascade : Cascade
-    | Assignment ann:Annotation
-                 target : String
-                 value : Expression
-    | Return ann:Annotation
-             value : (MaybeExpression)
-    | ReturnNext ann:Annotation
-                 expr : Expression
-    | ReturnQuery ann:Annotation
-                  sel : SelectExpression
-    | Raise ann:Annotation
-            level : RaiseType
-            message : String
-            args : ExpressionList
-    | NullStatement ann:Annotation
-    | Perform ann:Annotation
-              expr : Expression
-    | Execute ann:Annotation
-              expr : Expression
-    | ExecuteInto ann:Annotation
-                  expr : Expression
-                  targets : StringList
-    | ForSelectStatement ann:Annotation
-                         var : String
-                         sel : SelectExpression
-                         sts : StatementList
-    | ForIntegerStatement ann:Annotation
-                          var : String
-                          from : Expression
-                          to : Expression
-                          sts : StatementList
-    | WhileStatement ann:Annotation
-                     expr : Expression
-                     sts : StatementList
-    | ContinueStatement ann:Annotation
-    --variable, list of when parts, else part
-    | CaseStatement ann:Annotation
-                    val : Expression
-                    cases : ExpressionListStatementListPairList
-                    els : StatementList
-    --list is
-    --first if (condition, statements):elseifs(condition, statements)
-    --last bit is else statements
-    | If ann:Annotation
-         cases : ExpressionStatementListPairList
-         els : StatementList
-
---misc
-
-    | Set ann:Annotation name:String values:{[SetValue]}
-    | Notify ann:Annotation name:String
-
--- =============================================================================
-
---Statement components
-
--- maybe this should be called relation valued expression?
-DATA SelectExpression
-    | Select ann:Annotation
-             selDistinct : Distinct
-             selSelectList : SelectList
-             selTref : TableRefList
-             selWhere : MaybeBoolExpression
-             selGroupBy : ExpressionList
-             selHaving : MaybeBoolExpression
-             selOrderBy : ExpressionDirectionPairList
-             selLimit : MaybeExpression
-             selOffset : MaybeExpression
-    | CombineSelect ann:Annotation
-                    ctype : CombineType
-                    sel1 : SelectExpression
-                    sel2 : SelectExpression
-    | Values ann:Annotation
-             vll:ExpressionListList
-
-TYPE TableRefList = [TableRef]
-TYPE MaybeExpression = MAYBE Expression
-TYPE MaybeBoolExpression = MAYBE Expression
-
-DATA FnBody | SqlFnBody ann:Annotation sts : StatementList
-            | PlpgsqlFnBody ann:Annotation vars:VarDefList sts : StatementList
-
-DATA SetClause | SetClause ann:Annotation att:String val:Expression
-               | RowSetClause ann:Annotation atts:StringList vals:ExpressionList
-
-DATA TableRef | Tref ann:Annotation
-                     tbl:String
-                     alias : TableAlias
-              | JoinedTref ann:Annotation
-                           tbl : TableRef
-                           nat : Natural
-                           joinType : JoinType
-                           tbl1 : TableRef
-                           onExpr : OnExpr
-                           alias : TableAlias
-              | SubTref ann:Annotation
-                        sel : SelectExpression
-                        alias : TableAlias
-              | TrefFun ann:Annotation
-                        fn:Expression
-                        alias : TableAlias
-
-DATA TableAlias | NoAlias
-                | TableAlias alias:String
-                | FullAlias alias:String cols:{[String]}
-
-TYPE OnExpr = MAYBE JoinExpression
-
-DATA JoinExpression | JoinOn ann:Annotation Expression
-                    | JoinUsing ann:Annotation StringList
-
-DATA JoinType | Inner | LeftOuter| RightOuter | FullOuter | Cross
-
--- select columns, into columns
-
-DATA SelectList | SelectList ann:Annotation items:SelectItemList into:StringList
-
-
-TYPE MaybeSelectList = MAYBE SelectList
-
-DATA SelectItem | SelExp ann:Annotation ex:Expression
-                | SelectItem ann:Annotation ex:Expression name:String
-
-DATA CopySource | CopyFilename String
-                | Stdin
-
---name type default null constraint
-
-DATA AttributeDef | AttributeDef ann:Annotation
-                                 name : String
-                                 typ : TypeName
-                                 def: MaybeExpression
-                                 cons : RowConstraintList
-
---Constraints which appear attached to an individual field
-
-DATA RowConstraint | NullConstraint ann:Annotation name:String
-                   | NotNullConstraint ann:Annotation name:String
-                   | RowCheckConstraint ann:Annotation name:String Expression
-                   | RowUniqueConstraint ann:Annotation name:String
-                   | RowPrimaryKeyConstraint ann:Annotation name:String
-                   | RowReferenceConstraint ann:Annotation name:String
-                                            table : String
-                                            att : (Maybe String)
-                                            onUpdate : Cascade
-                                            onDelete : Cascade
-
---constraints which appear on a separate row in the create table
-
-DATA Constraint | UniqueConstraint ann:Annotation name:String StringList
-                | PrimaryKeyConstraint ann:Annotation name:String StringList
-                | CheckConstraint ann:Annotation name:String Expression
-                  -- sourcecols targettable targetcols ondelete onupdate
-                | ReferenceConstraint ann:Annotation
-                                      name:String
-                                      atts : StringList
-                                      table : String
-                                      tableAtts : StringList
-                                      onUpdate : Cascade
-                                      onDelete : Cascade
-
-DATA TypeAttributeDef | TypeAttDef ann:Annotation
-                                   name : String
-                                   typ : TypeName
-
-DATA AlterTableAction | AlterColumnDefault ann:Annotation
-                                           nm : String
-                                           def : Expression
-                      | AddConstraint ann:Annotation
-                                      con: Constraint
-DATA SetValue
-    | SetStr ann:Annotation String
-    | SetId ann:Annotation String
-    | SetNum ann:Annotation Double
-
-DATA TriggerWhen | TriggerBefore | TriggerAfter
-DATA TriggerEvent | TInsert| TUpdate | TDelete
-DATA TriggerFire | EachRow | EachStatement
-
-DATA ParamDef | ParamDef ann:Annotation name:String typ:TypeName
-              | ParamDefTp ann:Annotation typ:TypeName
-
-DATA VarDef | VarDef ann:Annotation
-                     name : String
-                     typ : TypeName
-                     value : (Maybe Expression)
-
-DATA RaiseType | RNotice | RException | RError
-
-DATA CombineType | Except | Union | Intersect | UnionAll
-
-DATA Volatility | Volatile | Stable | Immutable
-
-DATA Language | Sql | Plpgsql
-
-DATA TypeName | SimpleTypeName ann:Annotation tn:String
-              | PrecTypeName ann:Annotation tn:String prec:Integer
-              | ArrayTypeName ann:Annotation typ:TypeName
-              | SetOfTypeName ann:Annotation typ:TypeName
-
-DATA DropType | Table
-              | Domain
-              | View
-              | Type
-
-DATA Cascade | Cascade | Restrict
-
-DATA Direction | Asc | Desc
-
-DATA Distinct | Distinct | Dupes
-
-DATA Natural | Natural | Unnatural
-
-DATA IfExists | Require | IfExists
-
-DATA RestartIdentity | RestartIdentity | ContinueIdentity
-
-{-
-================================================================================
-
-Expressions
-
-Similarly to the statement type, all expressions are chucked into one
-even though there are many restrictions on which expressions can
-appear in different places.  Maybe this should be called scalar
-expression?
-
--}
-DATA Expression | IntegerLit ann:Annotation i:Integer
-                | FloatLit ann:Annotation d:Double
-                | StringLit ann:Annotation
-                            quote : String
-                            value : String
-                | NullLit ann:Annotation
-                | BooleanLit ann:Annotation b:Bool
-                | PositionalArg ann:Annotation p:Integer
-                | Placeholder ann:Annotation -- represents a '?'
-                | Cast ann:Annotation
-                       expr:Expression
-                       tn:TypeName
-                | Identifier ann:Annotation
-                             i:String
-                | Case ann:Annotation
-                       cases : CaseExpressionListExpressionPairList
-                       els : MaybeExpression
-                | CaseSimple ann:Annotation
-                             value : Expression
-                             cases : CaseExpressionListExpressionPairList
-                             els : MaybeExpression
-                | Exists ann:Annotation
-                         sel : SelectExpression
-                | FunCall ann:Annotation
-                          funName:String
-                          args:ExpressionList
-                | InPredicate ann:Annotation
-                              expr:Expression
-                              i:Bool
-                              list:InList
-                | WindowFn ann:Annotation
-                           fn : Expression
-                           partitionBy : ExpressionList
-                           orderBy : ExpressionList
-                           dir : Direction
-                           frm : FrameClause
-                | ScalarSubQuery ann:Annotation
-                                 sel : SelectExpression
-                | LiftOperator ann:Annotation
-                               oper:String
-                               flav:LiftFlavour
-                               args:ExpressionList
-
-DATA LiftFlavour | LiftAny | LiftAll
-
---todo: use liftoperator to implement inlist?
-DATA InList | InList ann:Annotation exprs : ExpressionList
-            | InSelect ann:Annotation sel : SelectExpression
-
-
-DATA FrameClause | FrameUnboundedPreceding
-                 | FrameUnboundedFull
-                 | FrameRowsUnboundedPreceding
-{-
-
-list of expression flavours from postgresql with the equivalents in this ast
-pg                                here
---                                ----
-constant/literal                  integerlit, floatlit, unknownstringlit, nulllit, boollit
-column reference                  identifier
-positional parameter reference    positionalarg
-subscripted expression            funcall
-field selection expression        identifier
-operator invocation               funcall
-function call                     funcall
-aggregate expression              funcall
-window function call              windowfn
-type cast                         cast
-scalar subquery                   scalarsubquery
-array constructor                 funcall
-row constructor                   funall
-
-Anything that is represented in the ast as some sort of name plus a
-list of expressions as arguments is treated as the same type of node:
-FunCall.
-
-This includes
-symbol operators
-regular function calls
-keyword operators e.g. and, like (ones which can be parsed as normal
-  syntactic operators)
-unusual syntax operators, e.g. between
-unusual syntax function calls e.g. substring(x from 5 for 3)
-arrayctors e.g. array[3,5,6]
-rowctors e.g. ROW (2,4,6)
-array subscripting
-
-list of keyword operators (regular prefix, infix and postfix):
-and, or, not
-is null, is not null, isnull, notnull
-is distinct from, is not distinct from
-is true, is not true,is false, is not false, is unknown, is not unknown
-like, not like, ilike, not ilike
-similar to, not similar to
-in, not in (don't include these here since the argument isn't always an expr)
-
-unusual syntax operators and fn calls
-between, not between, between symmetric
-overlay, substring, trim
-any, some, all
-
-Most of unusual syntax forms and keywords operators are not yet
-supported, so this is mainly a todo list.
-
-Keyword operators are encoded with the function name as a ! followed
-by a string
-e.g.
-operator 'and' -> FunCall "!and" ...
-see keywordOperatorTypes value in AstUtils.lhs for the list of
-currently supported keyword operators.
-
--}
-
--- some list nodes, not sure if all of these are needed as separately
--- named node types
-
-TYPE ExpressionList = [Expression]
-TYPE ExpressionListList = [ExpressionList]
-TYPE StringList = [String]
-TYPE SetClauseList = [SetClause]
-TYPE AttributeDefList = [AttributeDef]
-TYPE ConstraintList = [Constraint]
-TYPE TypeAttributeDefList = [TypeAttributeDef]
-TYPE ParamDefList = [ParamDef]
-TYPE TypeNameList = [TypeName]
-TYPE StringTypeNameListPair = (String, TypeNameList)
-TYPE StringTypeNameListPairList = [StringTypeNameListPair]
-TYPE ExpressionListStatementListPair = (ExpressionList,StatementList)
-TYPE ExpressionListStatementListPairList = [ExpressionListStatementListPair]
-TYPE ExpressionStatementListPair = (Expression, StatementList)
-TYPE ExpressionStatementListPairList = [ExpressionStatementListPair]
-TYPE VarDefList = [VarDef]
-TYPE SelectItemList = [SelectItem]
-TYPE RowConstraintList = [RowConstraint]
-TYPE CaseExpressionListExpressionPair = (CaseExpressionList,Expression)
-TYPE CaseExpressionList = [Expression]
-TYPE CaseExpressionListExpressionPairList = [CaseExpressionListExpressionPair]
-TYPE StatementList = [Statement]
-TYPE ExpressionDirectionPair = (Expression,Direction)
-TYPE ExpressionDirectionPairList = [ExpressionDirectionPair]
-
--- Add a root data type so we can put initial values for inherited
--- attributes in the section which defines and uses those attributes
--- rather than in the sem_ calls
-
-DATA Root | Root statements:StatementList
-DERIVING Root: Show
-
--- use an expression root also to support type checking,
--- etc., individual expressions
-
-DATA ExpressionRoot | ExpressionRoot expr:Expression
-DERIVING ExpressionRoot: Show
-
-{-
-================================================================================
-
-=some basic bookkeeping
-
-attributes which every node has
--}
-
-SET AllNodes = Statement SelectExpression FnBody SetClause TableRef
-               JoinExpression JoinType
-               SelectList SelectItem CopySource AttributeDef RowConstraint
-               Constraint TypeAttributeDef ParamDef VarDef RaiseType
-               CombineType Volatility Language TypeName DropType Cascade
-               Direction Distinct Natural IfExists RestartIdentity
-               Expression InList MaybeExpression MaybeBoolExpression
-               ExpressionList ExpressionListList StringList SetClauseList
-               AttributeDefList ConstraintList TypeAttributeDefList
-               ParamDefList TypeNameList StringTypeNameListPair
-               StringTypeNameListPairList
-               StatementList ExpressionListStatementListPair
-               ExpressionListStatementListPairList ExpressionStatementListPair
-               ExpressionStatementListPairList VarDefList SelectItemList
-               RowConstraintList CaseExpressionListExpressionPair
-               CaseExpressionListExpressionPairList CaseExpressionList
-               TableRefList TableRef OnExpr LiftFlavour MaybeSelectList
-               SetValue TableAlias FrameClause AlterTableAction
-               TriggerWhen TriggerEvent TriggerFire ExpressionDirectionPair
-               ExpressionDirectionPairList
-
-
-DERIVING AllNodes: Show,Eq,Typeable,Data
-
-
-INCLUDE "TypeChecking/TypeChecking.ag"
-
-{-
-
-================================================================================
-
-used to use record syntax to try to insulate code from field changes,
-and not have to write out loads of nothings and [] for simple selects,
-but don't know how to create haskell named records from uuagc DATA
-things
-
-makeSelect :: Statement
-makeSelect = Select Dupes (SelectList [SelExp (Identifier "*")] [])
-                   Nothing Nothing [] Nothing [] Asc Nothing Nothing
-
-
-================================================================================
-
-= annotation functions
-
--}
-{
-{-
--- | Type check multiple asts, allowing type checking references in
---   later files to definitions in earlier files. This is probably
---   more straightforward if you parse the files then concatenate the
---   statementlists together before type checking rather than using
---   this function
-typeCheckMany :: Catalog -> [StatementList] -> [StatementList]
-typeCheckMany cat sts =
-    annInt cat sts []
-    where
-      annInt e (s:ss) ress =
-          let (e1,res) = typeCheck e s
-          in annInt e1 ss (res:ress)
-      annInt _ [] ress = reverse ress
--}
-
--- | 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.
-typeCheck :: Catalog -> StatementList -> (Catalog,StatementList)
-typeCheck cat sts =
-    let t = sem_Root (Root (fixupImplicitJoins sts))
-        ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
-                                  ,lib_Inh_Root = emptyBindings}
-        tl = annotatedTree_Syn_Root ta
-        cat1 = producedCat_Syn_Root ta
-   in case tl of
-         Root r -> (cat1,r)
-
--- | 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.
-typeCheckPS :: Catalog -> Statement -> Either String Statement
-typeCheckPS cat st =
-    case st of
-      SelectStatement _ _ -> tc
-      Insert _ _ _ _ _ -> tc
-      Update _ _ _ _ _ -> tc
-      Delete _ _ _ _ -> tc
-      _ -> Left "requires select, update, insert or delete statement"
-    where
-      tc = let t = sem_Root (Root (fixupImplicitJoins [st]))
-               ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
-                                         ,lib_Inh_Root = emptyBindings}
-               tl = annotatedTree_Syn_Root ta
-               cat1 = producedCat_Syn_Root ta
-           in case tl of
-                Root [st1] -> Right st1
-                _ -> error "impossible happened in typeCheckPS!"
-
-
--- | Testing utility, mainly used to check an expression for type errors
--- or to get its type.
-typeCheckExpression :: Catalog -> Expression -> Expression
-typeCheckExpression cat ex =
-    let t = sem_ExpressionRoot (ExpressionRoot (fixupImplicitJoins ex))
-        rt = (annotatedTree_Syn_ExpressionRoot
-              (wrap_ExpressionRoot t Inh_ExpressionRoot {cat_Inh_ExpressionRoot = cat
-                                                        ,lib_Inh_ExpressionRoot = emptyBindings}))
-    in case rt of
-         ExpressionRoot e -> e
-
-{-
-bit of a hack, to avoid rewriting the tableref type checking to be
-able to do implicit joins, we just convert them in to the equivalent
-explicit join
--}
-
-fixupImplicitJoins :: Data a => a -> a
-fixupImplicitJoins =
-    transformBi $ \x ->
-            case x of
-              -- alter asts to change implicit joins into explicit joins
-              Select an dis sl trs@(_:_:_) whr grp hav ord lim off
-                  -> Select an dis sl [convTrefs trs] whr grp hav ord lim off
-              x1 -> x1
-    where
-      convTrefs (tr:tr1:trs) = JoinedTref [] tr Unnatural Cross (convTrefs (tr1:trs)) Nothing NoAlias
-      convTrefs (tr:[]) = tr
-      convTrefs _ = error "failed doing implicit join fixup hack"
-
-}
-
-{-
-
-Future plans:
-
-Investigate how much mileage can get out of making these nodes the
-parse tree nodes, and using a separate ast. Hinges on how much extra
-value can get from making the types more restrictive for the ast nodes
-compared to the parse tree. Starting to think this won't be worth it.
-
-Would like to turn this back into regular Haskell file, maybe could
-use AspectAG instead of uuagc to make this happen?
-
-
--}
diff --git a/Database/HsSqlPpp/AstInternals/AstInternal.hs b/Database/HsSqlPpp/AstInternals/AstInternal.hs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/AstInternal.hs
+++ /dev/null
@@ -1,16222 +0,0 @@
-
-
--- UUAGC 0.9.13 (AstInternal.ag)
-module Database.HsSqlPpp.AstInternals.AstInternal(
-    -- {-# LANGUAGE DeriveDataTypeable,RankNTypes,ScopedTypeVariables #-}
-    -- {-# OPTIONS_HADDOCK hide  #-}
-    --from the ag files:
-    --ast nodes
-    Statement (..)
-   ,SelectExpression (..)
-   ,FnBody (..)
-   ,SetClause (..)
-   ,TableRef (..)
-   ,TableAlias(..)
-   ,JoinExpression (..)
-   ,JoinType (..)
-   ,SelectList (..)
-   ,SelectItem (..)
-   ,CopySource (..)
-   ,AttributeDef (..)
-   ,RowConstraint (..)
-   ,AlterTableAction(..)
-   ,Constraint (..)
-   ,TypeAttributeDef (..)
-   ,ParamDef (..)
-   ,VarDef (..)
-   ,RaiseType (..)
-   ,CombineType (..)
-   ,Volatility (..)
-   ,Language (..)
-   ,TypeName (..)
-   ,DropType (..)
-   ,Cascade (..)
-   ,Direction (..)
-   ,Distinct (..)
-   ,Natural (..)
-   ,IfExists (..)
-   ,RestartIdentity (..)
-   ,Expression (..)
-   ,FrameClause(..)
-   ,InList (..)
-   ,LiftFlavour(..)
-   ,TriggerWhen(..)
-   ,TriggerEvent(..)
-   ,TriggerFire(..)
-   ,StatementList
-   ,ExpressionListStatementListPairList
-   ,ExpressionListStatementListPair
-   ,ExpressionList
-   ,StringList
-   ,ParamDefList
-   ,AttributeDefList
-   ,ConstraintList
-   ,TypeAttributeDefList
-   ,TypeNameList
-   ,StringTypeNameListPair
-   ,StringTypeNameListPairList
-   ,ExpressionStatementListPairList
-   ,SetClauseList
-   ,CaseExpressionListExpressionPairList
-   ,MaybeExpression
-   ,TableRefList
-   ,ExpressionListList
-   ,SelectItemList
-   ,OnExpr
-   ,RowConstraintList
-   ,VarDefList
-   ,ExpressionStatementListPair
-   ,CaseExpressionListExpressionPair
-   ,CaseExpressionList
-   ,ExpressionDirectionPair
-   ,ExpressionDirectionPairList
-   ,MaybeBoolExpression
-   ,MaybeSelectList
-   ,SetValue(..)
-   -- typechecking
-   ,typeCheck
-   ,typeCheckPS
-   ,typeCheckExpression
-) where
-
-import Data.Maybe
-import Data.List
-import Debug.Trace
---import Control.Monad.Error
-import Data.Either
-import Control.Applicative
-import Data.Generics
-import Data.Char
-import Control.Monad.State
-
-import Database.HsSqlPpp.AstInternals.TypeType
-import Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
-import Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
-import Database.HsSqlPpp.AstInternals.AstAnnotation
-import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-import Database.HsSqlPpp.AstInternals.TypeChecking.LocalIdentifierBindings
---import Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
-import Database.HsSqlPpp.Utils
-import Data.Generics.PlateData
-
-
-{-# LINE 683 "AstInternal.ag" #-}
-
-{-
--- | Type check multiple asts, allowing type checking references in
---   later files to definitions in earlier files. This is probably
---   more straightforward if you parse the files then concatenate the
---   statementlists together before type checking rather than using
---   this function
-typeCheckMany :: Catalog -> [StatementList] -> [StatementList]
-typeCheckMany cat sts =
-    annInt cat sts []
-    where
-      annInt e (s:ss) ress =
-          let (e1,res) = typeCheck e s
-          in annInt e1 ss (res:ress)
-      annInt _ [] ress = reverse ress
--}
-
--- | 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.
-typeCheck :: Catalog -> StatementList -> (Catalog,StatementList)
-typeCheck cat sts =
-    let t = sem_Root (Root (fixupImplicitJoins sts))
-        ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
-                                  ,lib_Inh_Root = emptyBindings}
-        tl = annotatedTree_Syn_Root ta
-        cat1 = producedCat_Syn_Root ta
-   in case tl of
-         Root r -> (cat1,r)
-
--- | 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.
-typeCheckPS :: Catalog -> Statement -> Either String Statement
-typeCheckPS cat st =
-    case st of
-      SelectStatement _ _ -> tc
-      Insert _ _ _ _ _ -> tc
-      Update _ _ _ _ _ -> tc
-      Delete _ _ _ _ -> tc
-      _ -> Left "requires select, update, insert or delete statement"
-    where
-      tc = let t = sem_Root (Root (fixupImplicitJoins [st]))
-               ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
-                                         ,lib_Inh_Root = emptyBindings}
-               tl = annotatedTree_Syn_Root ta
-               cat1 = producedCat_Syn_Root ta
-           in case tl of
-                Root [st1] -> Right st1
-                _ -> error "impossible happened in typeCheckPS!"
-
-
--- | Testing utility, mainly used to check an expression for type errors
--- or to get its type.
-typeCheckExpression :: Catalog -> Expression -> Expression
-typeCheckExpression cat ex =
-    let t = sem_ExpressionRoot (ExpressionRoot (fixupImplicitJoins ex))
-        rt = (annotatedTree_Syn_ExpressionRoot
-              (wrap_ExpressionRoot t Inh_ExpressionRoot {cat_Inh_ExpressionRoot = cat
-                                                        ,lib_Inh_ExpressionRoot = emptyBindings}))
-    in case rt of
-         ExpressionRoot e -> e
-
-{-
-bit of a hack, to avoid rewriting the tableref type checking to be
-able to do implicit joins, we just convert them in to the equivalent
-explicit join
--}
-
-fixupImplicitJoins :: Data a => a -> a
-fixupImplicitJoins =
-    transformBi $ \x ->
-            case x of
-              -- alter asts to change implicit joins into explicit joins
-              Select an dis sl trs@(_:_:_) whr grp hav ord lim off
-                  -> Select an dis sl [convTrefs trs] whr grp hav ord lim off
-              x1 -> x1
-    where
-      convTrefs (tr:tr1:trs) = JoinedTref [] tr Unnatural Cross (convTrefs (tr1:trs)) Nothing NoAlias
-      convTrefs (tr:[]) = tr
-      convTrefs _ = error "failed doing implicit join fixup hack"
-
-{-# LINE 190 "AstInternal.hs" #-}
-
-{-# LINE 81 "./TypeChecking/Misc.ag" #-}
-
-{-
-================================================================================
-
-= couple of small utils
-
-I think this should be alright, an identifier referenced in an
-expression can only have zero or one dot in it.
--}
-
-splitIdentifier :: String -> (String,String)
-splitIdentifier s = let (a,b) = span (/= '.') s
-                    in if b == ""
-                         then ("", a)
-                         else (a,tail b)
-
-{-
-helper to make adding annotations a bit easier
--}
-
-annTypesAndErrors :: Data a => a -> Type -> [TypeError]
-                  -> Maybe [AnnotationElement] -> a
-annTypesAndErrors item nt errs add =
-    updateAnnotation modifier item
-    where
-      modifier = (([TypeAnnotation nt] ++ fromMaybe [] add ++
-       map TypeErrorA errs) ++)
-
-{-
-================================================================================
-
-proper dodgy:
-1st pass is to add inferred types to the tree. This is done only for
-expressions in a funcall argument list atm. Then we pull out the
-placeholders after they've had this information added. Only the
-placeholders in funcall argument lists will have their type inferred
-in this way, to be expanded. Insert also does this currently, but in Dml.ag
-
-This should probably be done during the typechecking phase instead,
-but probably needs a proper type inferencing algorithm to be used, is
-done like this for development expediency.
-
--}
-getPlaceholders :: Data a => a -> [Expression]
-getPlaceholders st =
-    filter isPlaceholder $ everything (++) (mkQ [] ga) (setInferredTypes st)
-    where
-      ga :: Expression -> [Expression]
-      ga s = [s]
-      isPlaceholder e = case e of
-                          PositionalArg _ _ -> True
-                          Placeholder _ -> True
-                          _ -> False
-
-getPlaceholderTypes :: Data a => a -> [Type]
-getPlaceholderTypes ex =
-    map (getInferredType . getAnnotation) $ getPlaceholders ex
-    where
-      getInferredType (InferredType t:_) = t
-      getInferredType (_:as) = getInferredType as
-      getInferredType [] = TypeCheckFailed
-
-
-setInferredTypes :: Data a => a -> a
-setInferredTypes =
-      doExprs {-. doSts-}
-     where
-       doExprs =
-         transformBi (\x ->
-           case x of
-             FunCall an op exprs
-                 -> FunCall an op (addInferredTypes an exprs)
-             x1 -> x1)
-       {-doSts =
-         transformBi (\x ->
-           case x of
-             Insert ann table targetCols insData returning
-                 -> Insert ann table targetCols insData returning
-             x1 -> x1)-}
-       addInferredTypes an exprs =
-           let args1 = fmap (\(_,a,_,_) -> a) $ fp an
-               args = fromMaybe [] args1
-               fargs = args ++ repeat TypeCheckFailed
-           in flip map (zip exprs fargs)
-                  (\(ex, ty) -> updateAnnotation (++ [InferredType ty]) ex)
-           where
-             fp (FunctionPrototypeA f:_) = Just f
-             fp (_:ls) = fp ls
-             fp [] = Nothing
-
-{-# LINE 283 "AstInternal.hs" #-}
-
-{-# LINE 94 "./TypeChecking/Expressions.ag" #-}
-
-{-
-
-small shim in front of findCallMatch in the type conversion code, to
-handle some special cases.
-
-Some of the special cases will no longer be needed when variadic
-support is added.
-
-between, greatest and least are treated as syntactic sugar so we
-delegate the function lookups to the <=/>= operators.
-
-the row comparison should be more general than this, since it supports
-any operator satisfying some properties
-
-
-TODO: move all of this into find call match. Don't know why it's separate
--}
-typeCheckFunCall :: Catalog -> String -> [Type] -> Either [TypeError] FunctionPrototype
-typeCheckFunCall cat fnName' argsType =
-    {-trace ("typecheckfncall " ++ fnName' ++ show argsType) $-}
-    --dependsOnRTpe argsType $
-      case fnName of
-              "count" -> -- not quite sure how this is suppose to work,
-                         -- the counts in the pg catalog accept either
-                         -- no args, or one arg of type any, but you can call
-                         -- count with multiple arguments?
-                         return ("count", argsType, typeBigInt, False)
-              "!between" -> do
-                    f1 <- lookupReturnType ">=" [argsType !! 0, argsType !! 1]
-                    f2 <- lookupReturnType "<=" [argsType !! 0, argsType !! 2]
-                    lookupFn "!and" [f1,f2]
-              "greatest" -> do
-                    fp@(_,_,t,_) <- lookupFn fnName argsType
-                    lookupFn ">=" [t,t]
-                    return fp
-              "least" -> do
-                    fp@(_,_,t,_) <- lookupFn fnName argsType
-                    lookupFn "<=" [t,t]
-                    return fp
-              "!rowctor" -> return $ ("!rowCtor", argsType, AnonymousRecordType argsType, False)
-                    -- special case the row comparison ops
-                    -- this needs to be fixed: we want to match
-                    -- any implicit casts to functions on composite types
-                    -- first, then we can use the anonymous record type on
-                    -- any composite
-              _ | fnName `elem` ["=", "<>", "<=", ">=", "<", ">"]
-                         && length argsType == 2
-                         && all isCompositeOrSetOfCompositeType argsType
-                         && compositesCompatible cat (head argsType) (head $ tail argsType) -> return (fnName, argsType, typeBool, False)
-              --checked for all special cases, so run general case now
-              s -> lookupFn s argsType
-    where
-      lookupReturnType :: String -> [Type] -> Either [TypeError] Type
-      lookupReturnType s1 args = fmap (\(_,_,r,_) -> r) $ lookupFn s1 args
-      lookupFn :: String -> [Type] -> Either [TypeError] FunctionPrototype
-      lookupFn s1 args = findCallMatch cat
-                             (if s1 == "u-" then "-" else s1) args
-      fnName = map toLower fnName'
-{-# LINE 345 "AstInternal.hs" #-}
-
-{-# LINE 138 "./TypeChecking/SelectStatement.ag" #-}
-
-
-typeCheckValuesExpr :: Catalog -> [[Type]] -> Either [TypeError] Type
-typeCheckValuesExpr cat rowsTs =
-        let colNames = zipWith (++)
-                           (repeat "column")
-                           (map show [1..length $ head rowsTs])
-        in unionRelTypes cat rowsTs colNames
-
-
-typeCheckCombineSelect :: Catalog -> Type -> Type -> Either [TypeError] Type
-typeCheckCombineSelect cat v1 v2 = do
-    u1 <- unwrapSetOfComposite v1
-    let colNames = map fst u1
-    u2 <- unwrapSetOfComposite v2
-    let colTypes1 = map snd u1
-    let colTypes2 = map snd u2
-    unionRelTypes cat [colTypes1,colTypes2] colNames
-
-unionRelTypes :: Catalog -> [[Type]] -> [String] -> Either [TypeError] Type
-unionRelTypes cat rowsTs colNames =
-  let lengths = map length rowsTs
-  in case () of
-             _ | null rowsTs ->
-                   Left [NoRowsGivenForValues]
-               | not (all (==head lengths) lengths) ->
-                   Left [ValuesListsMustBeSameLength]
-               | otherwise ->
-                   --i don't think this propagates all the errors, just the first set
-                   mapM (resolveResultSetType cat) (transpose rowsTs) >>=
-                     (return . SetOfType . CompositeType . zip colNames)
-
-{-# LINE 380 "AstInternal.hs" #-}
-
-{-# LINE 200 "./TypeChecking/TableRefs.ag" #-}
-
-{-
-convert a function call into a [String,[(string,type)]] list for use
-in a tableref context
-first consideration is the alias: if there is an alias in the select,
-e.g. select * from generate_series(1,2) x;  (alias is x)
-we use that, otherwise we use the name of the function
-second consideration is the attributes coming out, roughly speaking
-we have to convert an arbitrary type to a relation type
-if we have a relation valued function, we don't need to do anything
-if we have a setof non composite, we lift the single type to an
-attribute, using the function name for the attribute name
-if we have a non setof, we lift the single type to an attribute and
-then relation, using the function name for the attribute name
-need to check to see what should happen with arrayof
-
--}
-funIdens :: Catalog -> String -> Expression -> Either [TypeError] (String,[(String,Type)])
-funIdens cat alias fnVal = do
-   errorWhen (case fnVal of
-                FunCall _ _ _ -> False
-                _ -> True)
-             [ContextError "FunCall"]
-   let (FunCall _ fnName _) = fnVal
-       correlationName = if alias /= ""
-                           then alias
-                           else fnName
-   attrs <- do
-     case getTypeAnnotation fnVal of
-       SetOfType (NamedCompositeType t) -> catCompositePublicAttrs cat [] t
-       SetOfType x -> return [(correlationName,x)]
-       y -> return [(correlationName,y)]
-   return (correlationName, attrs)
-
-getAlias :: String -> TableAlias -> String
-getAlias def alias =
-  case alias of
-    NoAlias -> def
-    TableAlias t -> t
-    FullAlias t _ -> t
-
-{-# LINE 424 "AstInternal.hs" #-}
-
-{-# LINE 92 "./TypeChecking/SelectLists.ag" #-}
-
-expandStar :: LocalIdentifierBindings
-           -> String
-           -> Type
-           -> [(String,Type)]
-           -> [(String,Type)]
-expandStar cat colName colType types =
-    fromRight types $ do
-    let (correlationName,iden) = splitIdentifier colName
-    newCols <- if iden == "*"
-                 then libExpandStar cat correlationName
-                 else return [(iden, colType)]
-    return $ newCols ++ types
-
-fixStar :: Expression -> Expression
-fixStar =
-    everywhere (mkT fixStar')
-    where
-      fixStar' :: Annotation -> Annotation
-      fixStar' a =
-          if TypeAnnotation TypeCheckFailed `elem` a
-              && any (\an ->
-                       case an of
-                         TypeErrorA (UnrecognisedIdentifier x) |
-                           let (_,iden) = splitIdentifier x
-                           in iden == "*" -> True
-                         _ -> False) a
-             then filter (\an -> case an of
-                                   TypeAnnotation TypeCheckFailed -> False
-                                   TypeErrorA (UnrecognisedIdentifier _) -> False
-                                   _ -> True) a
-             else a
-{-# LINE 459 "AstInternal.hs" #-}
-
-{-# LINE 96 "./TypeChecking/Dml.ag" #-}
-
-
-setInferredTypesG :: Data a => [Type] -> a -> a
-setInferredTypesG tys x =
-  evalState (transformBiM f x) tys
-  where
-    f (p@(Placeholder _)) = do
-         y:ys <- get
-         put ys
-         return $ updateAnnotation (++ [InferredType y]) p
-    f z = return z
-{-# LINE 473 "AstInternal.hs" #-}
-
-{-# LINE 163 "./TypeChecking/Dml.ag" #-}
-
-getRowTypes :: [Type] -> [Type]
-getRowTypes [AnonymousRecordType ts] = ts
-getRowTypes ts = ts
-{-# LINE 480 "AstInternal.hs" #-}
-
-{-# LINE 202 "./TypeChecking/Dml.ag" #-}
-
-
---small shortcut to help produce better errors?
-checkRelationExists :: Catalog -> String -> Either [TypeError] ()
-checkRelationExists cat tbl =
-    catCompositeDef cat relationComposites tbl >>
-    return ()
-
---used by both insert and update
-checkColumnConsistency :: Catalog ->  String -> [String] -> [(String,Type)]
-                       -> Either [TypeError] [(String,Type)]
-checkColumnConsistency cat tbl cols' insNameTypePairs = do
-  ttcols <- lowerize <$> catCompositePublicAttrs cat [] tbl
-  let cols = if null cols'
-               then map fst ttcols
-               else map (map toLower) cols'
-  errorWhen (length insNameTypePairs /= length cols) [WrongNumberOfColumns]
-  let nonMatchingColumns = cols \\ map fst ttcols
-  errorWhen (not $ null nonMatchingColumns) $
-       map UnrecognisedIdentifier nonMatchingColumns
-  let targetNameTypePairs = map (\l -> (l,fromJust $ lookup l ttcols)) cols
-        --check the types of the insdata match the column targets
-        --name datatype columntype
-      typeTriples = map (\((a,b),c) -> (a,b,c)) $
-                    zip targetNameTypePairs $
-                    map snd insNameTypePairs
-      errs :: [TypeError]
-      errs = concat $ lefts $
-             map (\(_,b,c) -> checkAssignmentValid cat c b) typeTriples
-  liftErrors errs
-  return targetNameTypePairs
-  where
-    lowerize = map (\(a,b) -> (map toLower a,b))
-
-{-# LINE 517 "AstInternal.hs" #-}
-
-{-# LINE 40 "./TypeChecking/CreateTable.ag" #-}
-
-defaultSystemColumns :: [(String,Type)]
-defaultSystemColumns = [("tableoid", ScalarType "oid")
-                       ,("cmax", ScalarType "cid")
-                       ,("xmax", ScalarType "xid")
-                       ,("cmin", ScalarType "cid")
-                       ,("xmin", ScalarType "xid")
-                       ,("ctid", ScalarType "tid")]
-{-# LINE 528 "AstInternal.hs" #-}
--- AlterTableAction --------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative AddConstraint:
-         child ann            : {Annotation}
-         child con            : Constraint 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative AlterColumnDefault:
-         child ann            : {Annotation}
-         child nm             : {String}
-         child def            : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data AlterTableAction  = AddConstraint (Annotation) (Constraint) 
-                       | AlterColumnDefault (Annotation) (String) (Expression) 
-                       deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_AlterTableAction :: AlterTableAction  ->
-                        T_AlterTableAction 
-sem_AlterTableAction (AddConstraint _ann _con )  =
-    (sem_AlterTableAction_AddConstraint _ann (sem_Constraint _con ) )
-sem_AlterTableAction (AlterColumnDefault _ann _nm _def )  =
-    (sem_AlterTableAction_AlterColumnDefault _ann _nm (sem_Expression _def ) )
--- semantic domain
-type T_AlterTableAction  = Catalog ->
-                           LocalIdentifierBindings ->
-                           ( AlterTableAction,AlterTableAction)
-data Inh_AlterTableAction  = Inh_AlterTableAction {cat_Inh_AlterTableAction :: Catalog,lib_Inh_AlterTableAction :: LocalIdentifierBindings}
-data Syn_AlterTableAction  = Syn_AlterTableAction {annotatedTree_Syn_AlterTableAction :: AlterTableAction,originalTree_Syn_AlterTableAction :: AlterTableAction}
-wrap_AlterTableAction :: T_AlterTableAction  ->
-                         Inh_AlterTableAction  ->
-                         Syn_AlterTableAction 
-wrap_AlterTableAction sem (Inh_AlterTableAction _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_AlterTableAction _lhsOannotatedTree _lhsOoriginalTree ))
-sem_AlterTableAction_AddConstraint :: Annotation ->
-                                      T_Constraint  ->
-                                      T_AlterTableAction 
-sem_AlterTableAction_AddConstraint ann_ con_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: AlterTableAction
-              _lhsOoriginalTree :: AlterTableAction
-              _conOcat :: Catalog
-              _conOlib :: LocalIdentifierBindings
-              _conIannotatedTree :: Constraint
-              _conIoriginalTree :: Constraint
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  AddConstraint ann_ _conIannotatedTree
-                  {-# LINE 592 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  AddConstraint ann_ _conIoriginalTree
-                  {-# LINE 597 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 602 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 607 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _conOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 612 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _conOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 617 "AstInternal.hs" #-}
-              ( _conIannotatedTree,_conIoriginalTree) =
-                  (con_ _conOcat _conOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_AlterTableAction_AlterColumnDefault :: Annotation ->
-                                           String ->
-                                           T_Expression  ->
-                                           T_AlterTableAction 
-sem_AlterTableAction_AlterColumnDefault ann_ nm_ def_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: AlterTableAction
-              _lhsOoriginalTree :: AlterTableAction
-              _defOcat :: Catalog
-              _defOlib :: LocalIdentifierBindings
-              _defIannotatedTree :: Expression
-              _defIliftedColumnName :: String
-              _defIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterColumnDefault ann_ nm_ _defIannotatedTree
-                  {-# LINE 639 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterColumnDefault ann_ nm_ _defIoriginalTree
-                  {-# LINE 644 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 649 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 654 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _defOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 659 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _defOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 664 "AstInternal.hs" #-}
-              ( _defIannotatedTree,_defIliftedColumnName,_defIoriginalTree) =
-                  (def_ _defOcat _defOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- AttributeDef ------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         attrName             : String
-         namedType            : Type
-         originalTree         : SELF 
-   alternatives:
-      alternative AttributeDef:
-         child ann            : {Annotation}
-         child name           : {String}
-         child typ            : TypeName 
-         child def            : MaybeExpression 
-         child cons           : RowConstraintList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data AttributeDef  = AttributeDef (Annotation) (String) (TypeName) (MaybeExpression) (RowConstraintList) 
-                   deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_AttributeDef :: AttributeDef  ->
-                    T_AttributeDef 
-sem_AttributeDef (AttributeDef _ann _name _typ _def _cons )  =
-    (sem_AttributeDef_AttributeDef _ann _name (sem_TypeName _typ ) (sem_MaybeExpression _def ) (sem_RowConstraintList _cons ) )
--- semantic domain
-type T_AttributeDef  = Catalog ->
-                       LocalIdentifierBindings ->
-                       ( AttributeDef,String,Type,AttributeDef)
-data Inh_AttributeDef  = Inh_AttributeDef {cat_Inh_AttributeDef :: Catalog,lib_Inh_AttributeDef :: LocalIdentifierBindings}
-data Syn_AttributeDef  = Syn_AttributeDef {annotatedTree_Syn_AttributeDef :: AttributeDef,attrName_Syn_AttributeDef :: String,namedType_Syn_AttributeDef :: Type,originalTree_Syn_AttributeDef :: AttributeDef}
-wrap_AttributeDef :: T_AttributeDef  ->
-                     Inh_AttributeDef  ->
-                     Syn_AttributeDef 
-wrap_AttributeDef sem (Inh_AttributeDef _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOattrName,_lhsOnamedType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_AttributeDef _lhsOannotatedTree _lhsOattrName _lhsOnamedType _lhsOoriginalTree ))
-sem_AttributeDef_AttributeDef :: Annotation ->
-                                 String ->
-                                 T_TypeName  ->
-                                 T_MaybeExpression  ->
-                                 T_RowConstraintList  ->
-                                 T_AttributeDef 
-sem_AttributeDef_AttributeDef ann_ name_ typ_ def_ cons_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrName :: String
-              _lhsOnamedType :: Type
-              _consOlib :: LocalIdentifierBindings
-              _lhsOannotatedTree :: AttributeDef
-              _lhsOoriginalTree :: AttributeDef
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _defOcat :: Catalog
-              _defOlib :: LocalIdentifierBindings
-              _consOcat :: Catalog
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              _defIannotatedTree :: MaybeExpression
-              _defIoriginalTree :: MaybeExpression
-              _consIannotatedTree :: RowConstraintList
-              _consIoriginalTree :: RowConstraintList
-              -- "./TypeChecking/CreateTable.ag"(line 79, column 9)
-              _lhsOattrName =
-                  {-# LINE 79 "./TypeChecking/CreateTable.ag" #-}
-                  map toLower name_
-                  {-# LINE 740 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 80, column 9)
-              _lhsOnamedType =
-                  {-# LINE 80 "./TypeChecking/CreateTable.ag" #-}
-                  _typInamedType
-                  {-# LINE 745 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 95, column 9)
-              _consOlib =
-                  {-# LINE 95 "./TypeChecking/CreateTable.ag" #-}
-                  case updateBindings _lhsIlib _lhsIcat
-                           [LibStackIDs [("", [(name_, _typInamedType)])]] of
-                    Left x -> error $ show x
-                    Right e -> e
-                  {-# LINE 753 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  AttributeDef ann_ name_ _typIannotatedTree _defIannotatedTree _consIannotatedTree
-                  {-# LINE 758 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  AttributeDef ann_ name_ _typIoriginalTree _defIoriginalTree _consIoriginalTree
-                  {-# LINE 763 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 768 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 773 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 778 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 783 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _defOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 788 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _defOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 793 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _consOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 798 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-              ( _defIannotatedTree,_defIoriginalTree) =
-                  (def_ _defOcat _defOlib )
-              ( _consIannotatedTree,_consIoriginalTree) =
-                  (cons_ _consOcat _consOlib )
-          in  ( _lhsOannotatedTree,_lhsOattrName,_lhsOnamedType,_lhsOoriginalTree)))
--- AttributeDefList --------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         attrs                : [(String, Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : AttributeDef 
-         child tl             : AttributeDefList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type AttributeDefList  = [(AttributeDef)]
--- cata
-sem_AttributeDefList :: AttributeDefList  ->
-                        T_AttributeDefList 
-sem_AttributeDefList list  =
-    (Prelude.foldr sem_AttributeDefList_Cons sem_AttributeDefList_Nil (Prelude.map sem_AttributeDef list) )
--- semantic domain
-type T_AttributeDefList  = Catalog ->
-                           LocalIdentifierBindings ->
-                           ( AttributeDefList,([(String, Type)]),AttributeDefList)
-data Inh_AttributeDefList  = Inh_AttributeDefList {cat_Inh_AttributeDefList :: Catalog,lib_Inh_AttributeDefList :: LocalIdentifierBindings}
-data Syn_AttributeDefList  = Syn_AttributeDefList {annotatedTree_Syn_AttributeDefList :: AttributeDefList,attrs_Syn_AttributeDefList :: [(String, Type)],originalTree_Syn_AttributeDefList :: AttributeDefList}
-wrap_AttributeDefList :: T_AttributeDefList  ->
-                         Inh_AttributeDefList  ->
-                         Syn_AttributeDefList 
-wrap_AttributeDefList sem (Inh_AttributeDefList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_AttributeDefList _lhsOannotatedTree _lhsOattrs _lhsOoriginalTree ))
-sem_AttributeDefList_Cons :: T_AttributeDef  ->
-                             T_AttributeDefList  ->
-                             T_AttributeDefList 
-sem_AttributeDefList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrs :: ([(String, Type)])
-              _lhsOannotatedTree :: AttributeDefList
-              _lhsOoriginalTree :: AttributeDefList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: AttributeDef
-              _hdIattrName :: String
-              _hdInamedType :: Type
-              _hdIoriginalTree :: AttributeDef
-              _tlIannotatedTree :: AttributeDefList
-              _tlIattrs :: ([(String, Type)])
-              _tlIoriginalTree :: AttributeDefList
-              -- "./TypeChecking/CreateTable.ag"(line 85, column 12)
-              _lhsOattrs =
-                  {-# LINE 85 "./TypeChecking/CreateTable.ag" #-}
-                  (_hdIattrName, _hdInamedType) : _tlIattrs
-                  {-# LINE 871 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 876 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 881 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 886 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 891 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 896 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 901 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 906 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 911 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIattrName,_hdInamedType,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIattrs,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree)))
-sem_AttributeDefList_Nil :: T_AttributeDefList 
-sem_AttributeDefList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrs :: ([(String, Type)])
-              _lhsOannotatedTree :: AttributeDefList
-              _lhsOoriginalTree :: AttributeDefList
-              -- "./TypeChecking/CreateTable.ag"(line 86, column 11)
-              _lhsOattrs =
-                  {-# LINE 86 "./TypeChecking/CreateTable.ag" #-}
-                  []
-                  {-# LINE 928 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 933 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 938 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 943 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 948 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree)))
--- Cascade -----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cascade:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Restrict:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Cascade  = Cascade 
-              | Restrict 
-              deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Cascade :: Cascade  ->
-               T_Cascade 
-sem_Cascade (Cascade )  =
-    (sem_Cascade_Cascade )
-sem_Cascade (Restrict )  =
-    (sem_Cascade_Restrict )
--- semantic domain
-type T_Cascade  = Catalog ->
-                  LocalIdentifierBindings ->
-                  ( Cascade,Cascade)
-data Inh_Cascade  = Inh_Cascade {cat_Inh_Cascade :: Catalog,lib_Inh_Cascade :: LocalIdentifierBindings}
-data Syn_Cascade  = Syn_Cascade {annotatedTree_Syn_Cascade :: Cascade,originalTree_Syn_Cascade :: Cascade}
-wrap_Cascade :: T_Cascade  ->
-                Inh_Cascade  ->
-                Syn_Cascade 
-wrap_Cascade sem (Inh_Cascade _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Cascade _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Cascade_Cascade :: T_Cascade 
-sem_Cascade_Cascade  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Cascade
-              _lhsOoriginalTree :: Cascade
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Cascade
-                  {-# LINE 1002 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Cascade
-                  {-# LINE 1007 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1012 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1017 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Cascade_Restrict :: T_Cascade 
-sem_Cascade_Restrict  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Cascade
-              _lhsOoriginalTree :: Cascade
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Restrict
-                  {-# LINE 1029 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Restrict
-                  {-# LINE 1034 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1039 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1044 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- CaseExpressionList ------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : Expression 
-         child tl             : CaseExpressionList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type CaseExpressionList  = [(Expression)]
--- cata
-sem_CaseExpressionList :: CaseExpressionList  ->
-                          T_CaseExpressionList 
-sem_CaseExpressionList list  =
-    (Prelude.foldr sem_CaseExpressionList_Cons sem_CaseExpressionList_Nil (Prelude.map sem_Expression list) )
--- semantic domain
-type T_CaseExpressionList  = Catalog ->
-                             LocalIdentifierBindings ->
-                             ( CaseExpressionList,CaseExpressionList)
-data Inh_CaseExpressionList  = Inh_CaseExpressionList {cat_Inh_CaseExpressionList :: Catalog,lib_Inh_CaseExpressionList :: LocalIdentifierBindings}
-data Syn_CaseExpressionList  = Syn_CaseExpressionList {annotatedTree_Syn_CaseExpressionList :: CaseExpressionList,originalTree_Syn_CaseExpressionList :: CaseExpressionList}
-wrap_CaseExpressionList :: T_CaseExpressionList  ->
-                           Inh_CaseExpressionList  ->
-                           Syn_CaseExpressionList 
-wrap_CaseExpressionList sem (Inh_CaseExpressionList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_CaseExpressionList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_CaseExpressionList_Cons :: T_Expression  ->
-                               T_CaseExpressionList  ->
-                               T_CaseExpressionList 
-sem_CaseExpressionList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CaseExpressionList
-              _lhsOoriginalTree :: CaseExpressionList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: Expression
-              _hdIliftedColumnName :: String
-              _hdIoriginalTree :: Expression
-              _tlIannotatedTree :: CaseExpressionList
-              _tlIoriginalTree :: CaseExpressionList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 1107 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 1112 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1117 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1122 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1127 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1132 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1137 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1142 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIliftedColumnName,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CaseExpressionList_Nil :: T_CaseExpressionList 
-sem_CaseExpressionList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CaseExpressionList
-              _lhsOoriginalTree :: CaseExpressionList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1158 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1163 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1168 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1173 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- CaseExpressionListExpressionPair ----------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Tuple:
-         child x1             : CaseExpressionList 
-         child x2             : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type CaseExpressionListExpressionPair  = ( (CaseExpressionList),(Expression))
--- cata
-sem_CaseExpressionListExpressionPair :: CaseExpressionListExpressionPair  ->
-                                        T_CaseExpressionListExpressionPair 
-sem_CaseExpressionListExpressionPair ( x1,x2)  =
-    (sem_CaseExpressionListExpressionPair_Tuple (sem_CaseExpressionList x1 ) (sem_Expression x2 ) )
--- semantic domain
-type T_CaseExpressionListExpressionPair  = Catalog ->
-                                           LocalIdentifierBindings ->
-                                           ( CaseExpressionListExpressionPair,CaseExpressionListExpressionPair)
-data Inh_CaseExpressionListExpressionPair  = Inh_CaseExpressionListExpressionPair {cat_Inh_CaseExpressionListExpressionPair :: Catalog,lib_Inh_CaseExpressionListExpressionPair :: LocalIdentifierBindings}
-data Syn_CaseExpressionListExpressionPair  = Syn_CaseExpressionListExpressionPair {annotatedTree_Syn_CaseExpressionListExpressionPair :: CaseExpressionListExpressionPair,originalTree_Syn_CaseExpressionListExpressionPair :: CaseExpressionListExpressionPair}
-wrap_CaseExpressionListExpressionPair :: T_CaseExpressionListExpressionPair  ->
-                                         Inh_CaseExpressionListExpressionPair  ->
-                                         Syn_CaseExpressionListExpressionPair 
-wrap_CaseExpressionListExpressionPair sem (Inh_CaseExpressionListExpressionPair _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_CaseExpressionListExpressionPair _lhsOannotatedTree _lhsOoriginalTree ))
-sem_CaseExpressionListExpressionPair_Tuple :: T_CaseExpressionList  ->
-                                              T_Expression  ->
-                                              T_CaseExpressionListExpressionPair 
-sem_CaseExpressionListExpressionPair_Tuple x1_ x2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CaseExpressionListExpressionPair
-              _lhsOoriginalTree :: CaseExpressionListExpressionPair
-              _x1Ocat :: Catalog
-              _x1Olib :: LocalIdentifierBindings
-              _x2Ocat :: Catalog
-              _x2Olib :: LocalIdentifierBindings
-              _x1IannotatedTree :: CaseExpressionList
-              _x1IoriginalTree :: CaseExpressionList
-              _x2IannotatedTree :: Expression
-              _x2IliftedColumnName :: String
-              _x2IoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IannotatedTree,_x2IannotatedTree)
-                  {-# LINE 1232 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IoriginalTree,_x2IoriginalTree)
-                  {-# LINE 1237 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1242 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1247 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1252 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1257 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1262 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1267 "AstInternal.hs" #-}
-              ( _x1IannotatedTree,_x1IoriginalTree) =
-                  (x1_ _x1Ocat _x1Olib )
-              ( _x2IannotatedTree,_x2IliftedColumnName,_x2IoriginalTree) =
-                  (x2_ _x2Ocat _x2Olib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- CaseExpressionListExpressionPairList ------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : CaseExpressionListExpressionPair 
-         child tl             : CaseExpressionListExpressionPairList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type CaseExpressionListExpressionPairList  = [(CaseExpressionListExpressionPair)]
--- cata
-sem_CaseExpressionListExpressionPairList :: CaseExpressionListExpressionPairList  ->
-                                            T_CaseExpressionListExpressionPairList 
-sem_CaseExpressionListExpressionPairList list  =
-    (Prelude.foldr sem_CaseExpressionListExpressionPairList_Cons sem_CaseExpressionListExpressionPairList_Nil (Prelude.map sem_CaseExpressionListExpressionPair list) )
--- semantic domain
-type T_CaseExpressionListExpressionPairList  = Catalog ->
-                                               LocalIdentifierBindings ->
-                                               ( CaseExpressionListExpressionPairList,CaseExpressionListExpressionPairList)
-data Inh_CaseExpressionListExpressionPairList  = Inh_CaseExpressionListExpressionPairList {cat_Inh_CaseExpressionListExpressionPairList :: Catalog,lib_Inh_CaseExpressionListExpressionPairList :: LocalIdentifierBindings}
-data Syn_CaseExpressionListExpressionPairList  = Syn_CaseExpressionListExpressionPairList {annotatedTree_Syn_CaseExpressionListExpressionPairList :: CaseExpressionListExpressionPairList,originalTree_Syn_CaseExpressionListExpressionPairList :: CaseExpressionListExpressionPairList}
-wrap_CaseExpressionListExpressionPairList :: T_CaseExpressionListExpressionPairList  ->
-                                             Inh_CaseExpressionListExpressionPairList  ->
-                                             Syn_CaseExpressionListExpressionPairList 
-wrap_CaseExpressionListExpressionPairList sem (Inh_CaseExpressionListExpressionPairList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_CaseExpressionListExpressionPairList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_CaseExpressionListExpressionPairList_Cons :: T_CaseExpressionListExpressionPair  ->
-                                                 T_CaseExpressionListExpressionPairList  ->
-                                                 T_CaseExpressionListExpressionPairList 
-sem_CaseExpressionListExpressionPairList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CaseExpressionListExpressionPairList
-              _lhsOoriginalTree :: CaseExpressionListExpressionPairList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: CaseExpressionListExpressionPair
-              _hdIoriginalTree :: CaseExpressionListExpressionPair
-              _tlIannotatedTree :: CaseExpressionListExpressionPairList
-              _tlIoriginalTree :: CaseExpressionListExpressionPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 1333 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 1338 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1343 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1348 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1353 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1358 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1363 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1368 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CaseExpressionListExpressionPairList_Nil :: T_CaseExpressionListExpressionPairList 
-sem_CaseExpressionListExpressionPairList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CaseExpressionListExpressionPairList
-              _lhsOoriginalTree :: CaseExpressionListExpressionPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1384 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1389 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1394 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1399 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- CombineType -------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Except:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Intersect:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Union:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative UnionAll:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data CombineType  = Except 
-                  | Intersect 
-                  | Union 
-                  | UnionAll 
-                  deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_CombineType :: CombineType  ->
-                   T_CombineType 
-sem_CombineType (Except )  =
-    (sem_CombineType_Except )
-sem_CombineType (Intersect )  =
-    (sem_CombineType_Intersect )
-sem_CombineType (Union )  =
-    (sem_CombineType_Union )
-sem_CombineType (UnionAll )  =
-    (sem_CombineType_UnionAll )
--- semantic domain
-type T_CombineType  = Catalog ->
-                      LocalIdentifierBindings ->
-                      ( CombineType,CombineType)
-data Inh_CombineType  = Inh_CombineType {cat_Inh_CombineType :: Catalog,lib_Inh_CombineType :: LocalIdentifierBindings}
-data Syn_CombineType  = Syn_CombineType {annotatedTree_Syn_CombineType :: CombineType,originalTree_Syn_CombineType :: CombineType}
-wrap_CombineType :: T_CombineType  ->
-                    Inh_CombineType  ->
-                    Syn_CombineType 
-wrap_CombineType sem (Inh_CombineType _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_CombineType _lhsOannotatedTree _lhsOoriginalTree ))
-sem_CombineType_Except :: T_CombineType 
-sem_CombineType_Except  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CombineType
-              _lhsOoriginalTree :: CombineType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Except
-                  {-# LINE 1467 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Except
-                  {-# LINE 1472 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1477 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1482 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CombineType_Intersect :: T_CombineType 
-sem_CombineType_Intersect  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CombineType
-              _lhsOoriginalTree :: CombineType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Intersect
-                  {-# LINE 1494 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Intersect
-                  {-# LINE 1499 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1504 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1509 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CombineType_Union :: T_CombineType 
-sem_CombineType_Union  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CombineType
-              _lhsOoriginalTree :: CombineType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Union
-                  {-# LINE 1521 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Union
-                  {-# LINE 1526 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1531 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1536 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CombineType_UnionAll :: T_CombineType 
-sem_CombineType_UnionAll  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CombineType
-              _lhsOoriginalTree :: CombineType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  UnionAll
-                  {-# LINE 1548 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  UnionAll
-                  {-# LINE 1553 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1558 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1563 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Constraint --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative CheckConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child expression     : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative PrimaryKeyConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child stringList     : StringList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ReferenceConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child atts           : StringList 
-         child table          : {String}
-         child tableAtts      : StringList 
-         child onUpdate       : Cascade 
-         child onDelete       : Cascade 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative UniqueConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child stringList     : StringList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Constraint  = CheckConstraint (Annotation) (String) (Expression) 
-                 | PrimaryKeyConstraint (Annotation) (String) (StringList) 
-                 | ReferenceConstraint (Annotation) (String) (StringList) (String) (StringList) (Cascade) (Cascade) 
-                 | UniqueConstraint (Annotation) (String) (StringList) 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Constraint :: Constraint  ->
-                  T_Constraint 
-sem_Constraint (CheckConstraint _ann _name _expression )  =
-    (sem_Constraint_CheckConstraint _ann _name (sem_Expression _expression ) )
-sem_Constraint (PrimaryKeyConstraint _ann _name _stringList )  =
-    (sem_Constraint_PrimaryKeyConstraint _ann _name (sem_StringList _stringList ) )
-sem_Constraint (ReferenceConstraint _ann _name _atts _table _tableAtts _onUpdate _onDelete )  =
-    (sem_Constraint_ReferenceConstraint _ann _name (sem_StringList _atts ) _table (sem_StringList _tableAtts ) (sem_Cascade _onUpdate ) (sem_Cascade _onDelete ) )
-sem_Constraint (UniqueConstraint _ann _name _stringList )  =
-    (sem_Constraint_UniqueConstraint _ann _name (sem_StringList _stringList ) )
--- semantic domain
-type T_Constraint  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( Constraint,Constraint)
-data Inh_Constraint  = Inh_Constraint {cat_Inh_Constraint :: Catalog,lib_Inh_Constraint :: LocalIdentifierBindings}
-data Syn_Constraint  = Syn_Constraint {annotatedTree_Syn_Constraint :: Constraint,originalTree_Syn_Constraint :: Constraint}
-wrap_Constraint :: T_Constraint  ->
-                   Inh_Constraint  ->
-                   Syn_Constraint 
-wrap_Constraint sem (Inh_Constraint _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Constraint _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Constraint_CheckConstraint :: Annotation ->
-                                  String ->
-                                  T_Expression  ->
-                                  T_Constraint 
-sem_Constraint_CheckConstraint ann_ name_ expression_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Constraint
-              _lhsOoriginalTree :: Constraint
-              _expressionOcat :: Catalog
-              _expressionOlib :: LocalIdentifierBindings
-              _expressionIannotatedTree :: Expression
-              _expressionIliftedColumnName :: String
-              _expressionIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CheckConstraint ann_ name_ _expressionIannotatedTree
-                  {-# LINE 1655 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CheckConstraint ann_ name_ _expressionIoriginalTree
-                  {-# LINE 1660 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1665 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1670 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1675 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1680 "AstInternal.hs" #-}
-              ( _expressionIannotatedTree,_expressionIliftedColumnName,_expressionIoriginalTree) =
-                  (expression_ _expressionOcat _expressionOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Constraint_PrimaryKeyConstraint :: Annotation ->
-                                       String ->
-                                       T_StringList  ->
-                                       T_Constraint 
-sem_Constraint_PrimaryKeyConstraint ann_ name_ stringList_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Constraint
-              _lhsOoriginalTree :: Constraint
-              _stringListOcat :: Catalog
-              _stringListOlib :: LocalIdentifierBindings
-              _stringListIannotatedTree :: StringList
-              _stringListIoriginalTree :: StringList
-              _stringListIstrings :: ([String])
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  PrimaryKeyConstraint ann_ name_ _stringListIannotatedTree
-                  {-# LINE 1702 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  PrimaryKeyConstraint ann_ name_ _stringListIoriginalTree
-                  {-# LINE 1707 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1712 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1717 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1722 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1727 "AstInternal.hs" #-}
-              ( _stringListIannotatedTree,_stringListIoriginalTree,_stringListIstrings) =
-                  (stringList_ _stringListOcat _stringListOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Constraint_ReferenceConstraint :: Annotation ->
-                                      String ->
-                                      T_StringList  ->
-                                      String ->
-                                      T_StringList  ->
-                                      T_Cascade  ->
-                                      T_Cascade  ->
-                                      T_Constraint 
-sem_Constraint_ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Constraint
-              _lhsOoriginalTree :: Constraint
-              _attsOcat :: Catalog
-              _attsOlib :: LocalIdentifierBindings
-              _tableAttsOcat :: Catalog
-              _tableAttsOlib :: LocalIdentifierBindings
-              _onUpdateOcat :: Catalog
-              _onUpdateOlib :: LocalIdentifierBindings
-              _onDeleteOcat :: Catalog
-              _onDeleteOlib :: LocalIdentifierBindings
-              _attsIannotatedTree :: StringList
-              _attsIoriginalTree :: StringList
-              _attsIstrings :: ([String])
-              _tableAttsIannotatedTree :: StringList
-              _tableAttsIoriginalTree :: StringList
-              _tableAttsIstrings :: ([String])
-              _onUpdateIannotatedTree :: Cascade
-              _onUpdateIoriginalTree :: Cascade
-              _onDeleteIannotatedTree :: Cascade
-              _onDeleteIoriginalTree :: Cascade
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ReferenceConstraint ann_ name_ _attsIannotatedTree table_ _tableAttsIannotatedTree _onUpdateIannotatedTree _onDeleteIannotatedTree
-                  {-# LINE 1766 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ReferenceConstraint ann_ name_ _attsIoriginalTree table_ _tableAttsIoriginalTree _onUpdateIoriginalTree _onDeleteIoriginalTree
-                  {-# LINE 1771 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1776 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1781 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1786 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1791 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tableAttsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1796 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tableAttsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1801 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onUpdateOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1806 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onUpdateOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1811 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onDeleteOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1816 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onDeleteOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1821 "AstInternal.hs" #-}
-              ( _attsIannotatedTree,_attsIoriginalTree,_attsIstrings) =
-                  (atts_ _attsOcat _attsOlib )
-              ( _tableAttsIannotatedTree,_tableAttsIoriginalTree,_tableAttsIstrings) =
-                  (tableAtts_ _tableAttsOcat _tableAttsOlib )
-              ( _onUpdateIannotatedTree,_onUpdateIoriginalTree) =
-                  (onUpdate_ _onUpdateOcat _onUpdateOlib )
-              ( _onDeleteIannotatedTree,_onDeleteIoriginalTree) =
-                  (onDelete_ _onDeleteOcat _onDeleteOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Constraint_UniqueConstraint :: Annotation ->
-                                   String ->
-                                   T_StringList  ->
-                                   T_Constraint 
-sem_Constraint_UniqueConstraint ann_ name_ stringList_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Constraint
-              _lhsOoriginalTree :: Constraint
-              _stringListOcat :: Catalog
-              _stringListOlib :: LocalIdentifierBindings
-              _stringListIannotatedTree :: StringList
-              _stringListIoriginalTree :: StringList
-              _stringListIstrings :: ([String])
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  UniqueConstraint ann_ name_ _stringListIannotatedTree
-                  {-# LINE 1849 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  UniqueConstraint ann_ name_ _stringListIoriginalTree
-                  {-# LINE 1854 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1859 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1864 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1869 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1874 "AstInternal.hs" #-}
-              ( _stringListIannotatedTree,_stringListIoriginalTree,_stringListIstrings) =
-                  (stringList_ _stringListOcat _stringListOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ConstraintList ----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : Constraint 
-         child tl             : ConstraintList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ConstraintList  = [(Constraint)]
--- cata
-sem_ConstraintList :: ConstraintList  ->
-                      T_ConstraintList 
-sem_ConstraintList list  =
-    (Prelude.foldr sem_ConstraintList_Cons sem_ConstraintList_Nil (Prelude.map sem_Constraint list) )
--- semantic domain
-type T_ConstraintList  = Catalog ->
-                         LocalIdentifierBindings ->
-                         ( ConstraintList,ConstraintList)
-data Inh_ConstraintList  = Inh_ConstraintList {cat_Inh_ConstraintList :: Catalog,lib_Inh_ConstraintList :: LocalIdentifierBindings}
-data Syn_ConstraintList  = Syn_ConstraintList {annotatedTree_Syn_ConstraintList :: ConstraintList,originalTree_Syn_ConstraintList :: ConstraintList}
-wrap_ConstraintList :: T_ConstraintList  ->
-                       Inh_ConstraintList  ->
-                       Syn_ConstraintList 
-wrap_ConstraintList sem (Inh_ConstraintList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ConstraintList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ConstraintList_Cons :: T_Constraint  ->
-                           T_ConstraintList  ->
-                           T_ConstraintList 
-sem_ConstraintList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ConstraintList
-              _lhsOoriginalTree :: ConstraintList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: Constraint
-              _hdIoriginalTree :: Constraint
-              _tlIannotatedTree :: ConstraintList
-              _tlIoriginalTree :: ConstraintList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 1938 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 1943 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1948 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 1953 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1958 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1963 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 1968 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 1973 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_ConstraintList_Nil :: T_ConstraintList 
-sem_ConstraintList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ConstraintList
-              _lhsOoriginalTree :: ConstraintList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1989 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 1994 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 1999 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2004 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- CopySource --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative CopyFilename:
-         child string         : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Stdin:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data CopySource  = CopyFilename (String) 
-                 | Stdin 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_CopySource :: CopySource  ->
-                  T_CopySource 
-sem_CopySource (CopyFilename _string )  =
-    (sem_CopySource_CopyFilename _string )
-sem_CopySource (Stdin )  =
-    (sem_CopySource_Stdin )
--- semantic domain
-type T_CopySource  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( CopySource,CopySource)
-data Inh_CopySource  = Inh_CopySource {cat_Inh_CopySource :: Catalog,lib_Inh_CopySource :: LocalIdentifierBindings}
-data Syn_CopySource  = Syn_CopySource {annotatedTree_Syn_CopySource :: CopySource,originalTree_Syn_CopySource :: CopySource}
-wrap_CopySource :: T_CopySource  ->
-                   Inh_CopySource  ->
-                   Syn_CopySource 
-wrap_CopySource sem (Inh_CopySource _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_CopySource _lhsOannotatedTree _lhsOoriginalTree ))
-sem_CopySource_CopyFilename :: String ->
-                               T_CopySource 
-sem_CopySource_CopyFilename string_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CopySource
-              _lhsOoriginalTree :: CopySource
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CopyFilename string_
-                  {-# LINE 2060 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CopyFilename string_
-                  {-# LINE 2065 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2070 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2075 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_CopySource_Stdin :: T_CopySource 
-sem_CopySource_Stdin  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: CopySource
-              _lhsOoriginalTree :: CopySource
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Stdin
-                  {-# LINE 2087 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Stdin
-                  {-# LINE 2092 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2097 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2102 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Direction ---------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Asc:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Desc:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Direction  = Asc 
-                | Desc 
-                deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Direction :: Direction  ->
-                 T_Direction 
-sem_Direction (Asc )  =
-    (sem_Direction_Asc )
-sem_Direction (Desc )  =
-    (sem_Direction_Desc )
--- semantic domain
-type T_Direction  = Catalog ->
-                    LocalIdentifierBindings ->
-                    ( Direction,Direction)
-data Inh_Direction  = Inh_Direction {cat_Inh_Direction :: Catalog,lib_Inh_Direction :: LocalIdentifierBindings}
-data Syn_Direction  = Syn_Direction {annotatedTree_Syn_Direction :: Direction,originalTree_Syn_Direction :: Direction}
-wrap_Direction :: T_Direction  ->
-                  Inh_Direction  ->
-                  Syn_Direction 
-wrap_Direction sem (Inh_Direction _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Direction _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Direction_Asc :: T_Direction 
-sem_Direction_Asc  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Direction
-              _lhsOoriginalTree :: Direction
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Asc
-                  {-# LINE 2156 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Asc
-                  {-# LINE 2161 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2166 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2171 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Direction_Desc :: T_Direction 
-sem_Direction_Desc  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Direction
-              _lhsOoriginalTree :: Direction
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Desc
-                  {-# LINE 2183 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Desc
-                  {-# LINE 2188 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2193 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2198 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Distinct ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Distinct:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Dupes:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Distinct  = Distinct 
-               | Dupes 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Distinct :: Distinct  ->
-                T_Distinct 
-sem_Distinct (Distinct )  =
-    (sem_Distinct_Distinct )
-sem_Distinct (Dupes )  =
-    (sem_Distinct_Dupes )
--- semantic domain
-type T_Distinct  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( Distinct,Distinct)
-data Inh_Distinct  = Inh_Distinct {cat_Inh_Distinct :: Catalog,lib_Inh_Distinct :: LocalIdentifierBindings}
-data Syn_Distinct  = Syn_Distinct {annotatedTree_Syn_Distinct :: Distinct,originalTree_Syn_Distinct :: Distinct}
-wrap_Distinct :: T_Distinct  ->
-                 Inh_Distinct  ->
-                 Syn_Distinct 
-wrap_Distinct sem (Inh_Distinct _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Distinct _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Distinct_Distinct :: T_Distinct 
-sem_Distinct_Distinct  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Distinct
-              _lhsOoriginalTree :: Distinct
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Distinct
-                  {-# LINE 2252 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Distinct
-                  {-# LINE 2257 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2262 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2267 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Distinct_Dupes :: T_Distinct 
-sem_Distinct_Dupes  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Distinct
-              _lhsOoriginalTree :: Distinct
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Dupes
-                  {-# LINE 2279 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Dupes
-                  {-# LINE 2284 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2289 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2294 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- DropType ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Domain:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Table:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Type:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative View:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data DropType  = Domain 
-               | Table 
-               | Type 
-               | View 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_DropType :: DropType  ->
-                T_DropType 
-sem_DropType (Domain )  =
-    (sem_DropType_Domain )
-sem_DropType (Table )  =
-    (sem_DropType_Table )
-sem_DropType (Type )  =
-    (sem_DropType_Type )
-sem_DropType (View )  =
-    (sem_DropType_View )
--- semantic domain
-type T_DropType  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( DropType,DropType)
-data Inh_DropType  = Inh_DropType {cat_Inh_DropType :: Catalog,lib_Inh_DropType :: LocalIdentifierBindings}
-data Syn_DropType  = Syn_DropType {annotatedTree_Syn_DropType :: DropType,originalTree_Syn_DropType :: DropType}
-wrap_DropType :: T_DropType  ->
-                 Inh_DropType  ->
-                 Syn_DropType 
-wrap_DropType sem (Inh_DropType _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_DropType _lhsOannotatedTree _lhsOoriginalTree ))
-sem_DropType_Domain :: T_DropType 
-sem_DropType_Domain  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: DropType
-              _lhsOoriginalTree :: DropType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Domain
-                  {-# LINE 2362 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Domain
-                  {-# LINE 2367 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2372 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2377 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_DropType_Table :: T_DropType 
-sem_DropType_Table  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: DropType
-              _lhsOoriginalTree :: DropType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Table
-                  {-# LINE 2389 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Table
-                  {-# LINE 2394 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2399 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2404 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_DropType_Type :: T_DropType 
-sem_DropType_Type  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: DropType
-              _lhsOoriginalTree :: DropType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Type
-                  {-# LINE 2416 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Type
-                  {-# LINE 2421 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2426 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2431 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_DropType_View :: T_DropType 
-sem_DropType_View  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: DropType
-              _lhsOoriginalTree :: DropType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  View
-                  {-# LINE 2443 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  View
-                  {-# LINE 2448 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 2453 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2458 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Expression --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         liftedColumnName     : String
-         originalTree         : SELF 
-   alternatives:
-      alternative BooleanLit:
-         child ann            : {Annotation}
-         child b              : {Bool}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Case:
-         child ann            : {Annotation}
-         child cases          : CaseExpressionListExpressionPairList 
-         child els            : MaybeExpression 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local whenTypes   : _
-            local thenTypes   : _
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CaseSimple:
-         child ann            : {Annotation}
-         child value          : Expression 
-         child cases          : CaseExpressionListExpressionPairList 
-         child els            : MaybeExpression 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local whenTypes   : _
-            local thenTypes   : _
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Cast:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         child tn             : TypeName 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Exists:
-         child ann            : {Annotation}
-         child sel            : SelectExpression 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative FloatLit:
-         child ann            : {Annotation}
-         child d              : {Double}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative FunCall:
-         child ann            : {Annotation}
-         child funName        : {String}
-         child args           : ExpressionList 
-         visit 0:
-            local _tup1       : _
-            local tpe         : _
-            local prototype   : {Maybe FunctionPrototype}
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Identifier:
-         child ann            : {Annotation}
-         child i              : {String}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative InPredicate:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         child i              : {Bool}
-         child list           : InList 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative IntegerLit:
-         child ann            : {Annotation}
-         child i              : {Integer}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative LiftOperator:
-         child ann            : {Annotation}
-         child oper           : {String}
-         child flav           : LiftFlavour 
-         child args           : ExpressionList 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative NullLit:
-         child ann            : {Annotation}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Placeholder:
-         child ann            : {Annotation}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative PositionalArg:
-         child ann            : {Annotation}
-         child p              : {Integer}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative ScalarSubQuery:
-         child ann            : {Annotation}
-         child sel            : SelectExpression 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative StringLit:
-         child ann            : {Annotation}
-         child quote          : {String}
-         child value          : {String}
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative WindowFn:
-         child ann            : {Annotation}
-         child fn             : Expression 
-         child partitionBy    : ExpressionList 
-         child orderBy        : ExpressionList 
-         child dir            : Direction 
-         child frm            : FrameClause 
-         visit 0:
-            local prototype   : {Maybe FunctionPrototype}
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
--}
-data Expression  = BooleanLit (Annotation) (Bool) 
-                 | Case (Annotation) (CaseExpressionListExpressionPairList) (MaybeExpression) 
-                 | CaseSimple (Annotation) (Expression) (CaseExpressionListExpressionPairList) (MaybeExpression) 
-                 | Cast (Annotation) (Expression) (TypeName) 
-                 | Exists (Annotation) (SelectExpression) 
-                 | FloatLit (Annotation) (Double) 
-                 | FunCall (Annotation) (String) (ExpressionList) 
-                 | Identifier (Annotation) (String) 
-                 | InPredicate (Annotation) (Expression) (Bool) (InList) 
-                 | IntegerLit (Annotation) (Integer) 
-                 | LiftOperator (Annotation) (String) (LiftFlavour) (ExpressionList) 
-                 | NullLit (Annotation) 
-                 | Placeholder (Annotation) 
-                 | PositionalArg (Annotation) (Integer) 
-                 | ScalarSubQuery (Annotation) (SelectExpression) 
-                 | StringLit (Annotation) (String) (String) 
-                 | WindowFn (Annotation) (Expression) (ExpressionList) (ExpressionList) (Direction) (FrameClause) 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Expression :: Expression  ->
-                  T_Expression 
-sem_Expression (BooleanLit _ann _b )  =
-    (sem_Expression_BooleanLit _ann _b )
-sem_Expression (Case _ann _cases _els )  =
-    (sem_Expression_Case _ann (sem_CaseExpressionListExpressionPairList _cases ) (sem_MaybeExpression _els ) )
-sem_Expression (CaseSimple _ann _value _cases _els )  =
-    (sem_Expression_CaseSimple _ann (sem_Expression _value ) (sem_CaseExpressionListExpressionPairList _cases ) (sem_MaybeExpression _els ) )
-sem_Expression (Cast _ann _expr _tn )  =
-    (sem_Expression_Cast _ann (sem_Expression _expr ) (sem_TypeName _tn ) )
-sem_Expression (Exists _ann _sel )  =
-    (sem_Expression_Exists _ann (sem_SelectExpression _sel ) )
-sem_Expression (FloatLit _ann _d )  =
-    (sem_Expression_FloatLit _ann _d )
-sem_Expression (FunCall _ann _funName _args )  =
-    (sem_Expression_FunCall _ann _funName (sem_ExpressionList _args ) )
-sem_Expression (Identifier _ann _i )  =
-    (sem_Expression_Identifier _ann _i )
-sem_Expression (InPredicate _ann _expr _i _list )  =
-    (sem_Expression_InPredicate _ann (sem_Expression _expr ) _i (sem_InList _list ) )
-sem_Expression (IntegerLit _ann _i )  =
-    (sem_Expression_IntegerLit _ann _i )
-sem_Expression (LiftOperator _ann _oper _flav _args )  =
-    (sem_Expression_LiftOperator _ann _oper (sem_LiftFlavour _flav ) (sem_ExpressionList _args ) )
-sem_Expression (NullLit _ann )  =
-    (sem_Expression_NullLit _ann )
-sem_Expression (Placeholder _ann )  =
-    (sem_Expression_Placeholder _ann )
-sem_Expression (PositionalArg _ann _p )  =
-    (sem_Expression_PositionalArg _ann _p )
-sem_Expression (ScalarSubQuery _ann _sel )  =
-    (sem_Expression_ScalarSubQuery _ann (sem_SelectExpression _sel ) )
-sem_Expression (StringLit _ann _quote _value )  =
-    (sem_Expression_StringLit _ann _quote _value )
-sem_Expression (WindowFn _ann _fn _partitionBy _orderBy _dir _frm )  =
-    (sem_Expression_WindowFn _ann (sem_Expression _fn ) (sem_ExpressionList _partitionBy ) (sem_ExpressionList _orderBy ) (sem_Direction _dir ) (sem_FrameClause _frm ) )
--- semantic domain
-type T_Expression  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( Expression,String,Expression)
-data Inh_Expression  = Inh_Expression {cat_Inh_Expression :: Catalog,lib_Inh_Expression :: LocalIdentifierBindings}
-data Syn_Expression  = Syn_Expression {annotatedTree_Syn_Expression :: Expression,liftedColumnName_Syn_Expression :: String,originalTree_Syn_Expression :: Expression}
-wrap_Expression :: T_Expression  ->
-                   Inh_Expression  ->
-                   Syn_Expression 
-wrap_Expression sem (Inh_Expression _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Expression _lhsOannotatedTree _lhsOliftedColumnName _lhsOoriginalTree ))
-sem_Expression_BooleanLit :: Annotation ->
-                             Bool ->
-                             T_Expression 
-sem_Expression_BooleanLit ann_ b_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 2727 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 2732 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 41, column 19)
-              _tpe =
-                  {-# LINE 41 "./TypeChecking/Expressions.ag" #-}
-                  Right typeBool
-                  {-# LINE 2737 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 53, column 9)
-              _backTree =
-                  {-# LINE 53 "./TypeChecking/Expressions.ag" #-}
-                  BooleanLit ann_ b_
-                  {-# LINE 2742 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 2747 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  BooleanLit ann_ b_
-                  {-# LINE 2752 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  BooleanLit ann_ b_
-                  {-# LINE 2757 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2762 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_Case :: Annotation ->
-                       T_CaseExpressionListExpressionPairList  ->
-                       T_MaybeExpression  ->
-                       T_Expression 
-sem_Expression_Case ann_ cases_ els_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _casesOcat :: Catalog
-              _casesOlib :: LocalIdentifierBindings
-              _elsOcat :: Catalog
-              _elsOlib :: LocalIdentifierBindings
-              _casesIannotatedTree :: CaseExpressionListExpressionPairList
-              _casesIoriginalTree :: CaseExpressionListExpressionPairList
-              _elsIannotatedTree :: MaybeExpression
-              _elsIoriginalTree :: MaybeExpression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 2790 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 2795 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 202, column 9)
-              _whenTypes =
-                  {-# LINE 202 "./TypeChecking/Expressions.ag" #-}
-                  map getTypeAnnotation $ concatMap fst $
-                  _casesIannotatedTree
-                  {-# LINE 2801 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 204, column 9)
-              _thenTypes =
-                  {-# LINE 204 "./TypeChecking/Expressions.ag" #-}
-                  map getTypeAnnotation $
-                      (map snd $ _casesIannotatedTree) ++
-                        maybeToList _elsIannotatedTree
-                  {-# LINE 2808 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 210, column 9)
-              _tpe =
-                  {-# LINE 210 "./TypeChecking/Expressions.ag" #-}
-                  dependsOnRTpe _whenTypes     $ do
-                  errorWhen (any (/= typeBool) _whenTypes    ) $
-                            [WrongTypes typeBool _whenTypes    ]
-                  dependsOnRTpe _thenTypes     $
-                    resolveResultSetType _lhsIcat _thenTypes
-                  {-# LINE 2817 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 216, column 9)
-              _backTree =
-                  {-# LINE 216 "./TypeChecking/Expressions.ag" #-}
-                  Case ann_ _casesIannotatedTree _elsIannotatedTree
-                  {-# LINE 2822 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 2827 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Case ann_ _casesIannotatedTree _elsIannotatedTree
-                  {-# LINE 2832 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Case ann_ _casesIoriginalTree _elsIoriginalTree
-                  {-# LINE 2837 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2842 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 2847 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 2852 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 2857 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 2862 "AstInternal.hs" #-}
-              ( _casesIannotatedTree,_casesIoriginalTree) =
-                  (cases_ _casesOcat _casesOlib )
-              ( _elsIannotatedTree,_elsIoriginalTree) =
-                  (els_ _elsOcat _elsOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_CaseSimple :: Annotation ->
-                             T_Expression  ->
-                             T_CaseExpressionListExpressionPairList  ->
-                             T_MaybeExpression  ->
-                             T_Expression 
-sem_Expression_CaseSimple ann_ value_ cases_ els_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOoriginalTree :: Expression
-              _lhsOliftedColumnName :: String
-              _valueOcat :: Catalog
-              _valueOlib :: LocalIdentifierBindings
-              _casesOcat :: Catalog
-              _casesOlib :: LocalIdentifierBindings
-              _elsOcat :: Catalog
-              _elsOlib :: LocalIdentifierBindings
-              _valueIannotatedTree :: Expression
-              _valueIliftedColumnName :: String
-              _valueIoriginalTree :: Expression
-              _casesIannotatedTree :: CaseExpressionListExpressionPairList
-              _casesIoriginalTree :: CaseExpressionListExpressionPairList
-              _elsIannotatedTree :: MaybeExpression
-              _elsIoriginalTree :: MaybeExpression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 2900 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 2905 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 202, column 9)
-              _whenTypes =
-                  {-# LINE 202 "./TypeChecking/Expressions.ag" #-}
-                  map getTypeAnnotation $ concatMap fst $
-                  _casesIannotatedTree
-                  {-# LINE 2911 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 204, column 9)
-              _thenTypes =
-                  {-# LINE 204 "./TypeChecking/Expressions.ag" #-}
-                  map getTypeAnnotation $
-                      (map snd $ _casesIannotatedTree) ++
-                        maybeToList _elsIannotatedTree
-                  {-# LINE 2918 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 221, column 9)
-              _tpe =
-                  {-# LINE 221 "./TypeChecking/Expressions.ag" #-}
-                  dependsOnRTpe _whenTypes     $ do
-                  let valueType = getTypeAnnotation _valueIannotatedTree
-                  checkWhenTypes <-
-                      resolveResultSetType _lhsIcat (valueType : _whenTypes    )
-                  dependsOnRTpe _thenTypes     $
-                    resolveResultSetType _lhsIcat _thenTypes
-                  {-# LINE 2928 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 228, column 9)
-              _backTree =
-                  {-# LINE 228 "./TypeChecking/Expressions.ag" #-}
-                  CaseSimple ann_
-                             _valueIannotatedTree
-                             _casesIannotatedTree
-                             _elsIannotatedTree
-                  {-# LINE 2936 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CaseSimple ann_ _valueIannotatedTree _casesIannotatedTree _elsIannotatedTree
-                  {-# LINE 2941 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CaseSimple ann_ _valueIoriginalTree _casesIoriginalTree _elsIoriginalTree
-                  {-# LINE 2946 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 2951 "AstInternal.hs" #-}
-              -- copy rule (up)
-              _lhsOliftedColumnName =
-                  {-# LINE 161 "./TypeChecking/SelectLists.ag" #-}
-                  _valueIliftedColumnName
-                  {-# LINE 2956 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 2961 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 2966 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 2971 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 2976 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 2981 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 2986 "AstInternal.hs" #-}
-              ( _valueIannotatedTree,_valueIliftedColumnName,_valueIoriginalTree) =
-                  (value_ _valueOcat _valueOlib )
-              ( _casesIannotatedTree,_casesIoriginalTree) =
-                  (cases_ _casesOcat _casesOlib )
-              ( _elsIannotatedTree,_elsIoriginalTree) =
-                  (els_ _elsOcat _elsOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_Cast :: Annotation ->
-                       T_Expression  ->
-                       T_TypeName  ->
-                       T_Expression 
-sem_Expression_Cast ann_ expr_ tn_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _tnOcat :: Catalog
-              _tnOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              _tnIannotatedTree :: TypeName
-              _tnInamedType :: Type
-              _tnIoriginalTree :: TypeName
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3022 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3027 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 66, column 12)
-              _tpe =
-                  {-# LINE 66 "./TypeChecking/Expressions.ag" #-}
-                  Right $ _tnInamedType
-                  {-# LINE 3032 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 67, column 12)
-              _backTree =
-                  {-# LINE 67 "./TypeChecking/Expressions.ag" #-}
-                  Cast ann_ _exprIannotatedTree _tnIannotatedTree
-                  {-# LINE 3037 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 169, column 10)
-              _lhsOliftedColumnName =
-                  {-# LINE 169 "./TypeChecking/SelectLists.ag" #-}
-                  case _tnIannotatedTree of
-                    SimpleTypeName _ tn -> tn
-                    _ -> ""
-                  {-# LINE 3044 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Cast ann_ _exprIannotatedTree _tnIannotatedTree
-                  {-# LINE 3049 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Cast ann_ _exprIoriginalTree _tnIoriginalTree
-                  {-# LINE 3054 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3059 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3064 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3069 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tnOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3074 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tnOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3079 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-              ( _tnIannotatedTree,_tnInamedType,_tnIoriginalTree) =
-                  (tn_ _tnOcat _tnOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_Exists :: Annotation ->
-                         T_SelectExpression  ->
-                         T_Expression 
-sem_Expression_Exists ann_ sel_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3107 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3112 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 259, column 9)
-              _tpe =
-                  {-# LINE 259 "./TypeChecking/Expressions.ag" #-}
-                  Right typeBool
-                  {-# LINE 3117 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 260, column 9)
-              _backTree =
-                  {-# LINE 260 "./TypeChecking/Expressions.ag" #-}
-                  Exists ann_ _selIannotatedTree
-                  {-# LINE 3122 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3127 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Exists ann_ _selIannotatedTree
-                  {-# LINE 3132 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Exists ann_ _selIoriginalTree
-                  {-# LINE 3137 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3142 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3147 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3152 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_FloatLit :: Annotation ->
-                           Double ->
-                           T_Expression 
-sem_Expression_FloatLit ann_ d_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3173 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3178 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 40, column 17)
-              _tpe =
-                  {-# LINE 40 "./TypeChecking/Expressions.ag" #-}
-                  Right typeNumeric
-                  {-# LINE 3183 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 51, column 9)
-              _backTree =
-                  {-# LINE 51 "./TypeChecking/Expressions.ag" #-}
-                  FloatLit ann_ d_
-                  {-# LINE 3188 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3193 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FloatLit ann_ d_
-                  {-# LINE 3198 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FloatLit ann_ d_
-                  {-# LINE 3203 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3208 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_FunCall :: Annotation ->
-                          String ->
-                          T_ExpressionList  ->
-                          T_Expression 
-sem_Expression_FunCall ann_ funName_ args_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _argsOcat :: Catalog
-              _argsOlib :: LocalIdentifierBindings
-              _argsIannotatedTree :: ExpressionList
-              _argsIoriginalTree :: ExpressionList
-              _argsItypeList :: ([Type])
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3233 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 74, column 9)
-              __tup1 =
-                  {-# LINE 74 "./TypeChecking/Expressions.ag" #-}
-                  if any (==TypeCheckFailed) _argsItypeList
-                  then (Right TypeCheckFailed, Nothing)
-                  else
-                    let fe = typeCheckFunCall
-                             _lhsIcat
-                             funName_
-                             _argsItypeList
-                    in (dependsOnRTpe _argsItypeList $ fmap (\(_,_,r,_) -> r) fe
-                       ,eitherToMaybe fe)
-                  {-# LINE 3246 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 74, column 9)
-              (_tpe,_) =
-                  {-# LINE 74 "./TypeChecking/Expressions.ag" #-}
-                  __tup1
-                  {-# LINE 3251 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 74, column 9)
-              (_,_prototype) =
-                  {-# LINE 74 "./TypeChecking/Expressions.ag" #-}
-                  __tup1
-                  {-# LINE 3256 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 83, column 9)
-              _backTree =
-                  {-# LINE 83 "./TypeChecking/Expressions.ag" #-}
-                  FunCall ann_ funName_ _argsIannotatedTree
-                  {-# LINE 3261 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 165, column 13)
-              _lhsOliftedColumnName =
-                  {-# LINE 165 "./TypeChecking/SelectLists.ag" #-}
-                  if isOperatorName funName_
-                     then ""
-                     else funName_
-                  {-# LINE 3268 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FunCall ann_ funName_ _argsIannotatedTree
-                  {-# LINE 3273 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FunCall ann_ funName_ _argsIoriginalTree
-                  {-# LINE 3278 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3283 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3288 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3293 "AstInternal.hs" #-}
-              ( _argsIannotatedTree,_argsIoriginalTree,_argsItypeList) =
-                  (args_ _argsOcat _argsOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_Identifier :: Annotation ->
-                             String ->
-                             T_Expression 
-sem_Expression_Identifier ann_ i_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3314 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3319 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 241, column 9)
-              _tpe =
-                  {-# LINE 241 "./TypeChecking/Expressions.ag" #-}
-                  libLookupID _lhsIlib i_
-                  {-# LINE 3324 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 242, column 9)
-              _backTree =
-                  {-# LINE 242 "./TypeChecking/Expressions.ag" #-}
-                  Identifier ann_ i_
-                  {-# LINE 3329 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 164, column 16)
-              _lhsOliftedColumnName =
-                  {-# LINE 164 "./TypeChecking/SelectLists.ag" #-}
-                  i_
-                  {-# LINE 3334 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Identifier ann_ i_
-                  {-# LINE 3339 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Identifier ann_ i_
-                  {-# LINE 3344 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3349 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_InPredicate :: Annotation ->
-                              T_Expression  ->
-                              Bool ->
-                              T_InList  ->
-                              T_Expression 
-sem_Expression_InPredicate ann_ expr_ i_ list_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOoriginalTree :: Expression
-              _lhsOliftedColumnName :: String
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _listOcat :: Catalog
-              _listOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              _listIannotatedTree :: InList
-              _listIlistType :: (Either [TypeError] Type)
-              _listIoriginalTree :: InList
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3380 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3385 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 289, column 9)
-              _tpe =
-                  {-# LINE 289 "./TypeChecking/Expressions.ag" #-}
-                  do
-                  lt <- _listIlistType
-                  ty <- resolveResultSetType
-                            _lhsIcat
-                            [getTypeAnnotation _exprIannotatedTree, lt]
-                  return typeBool
-                  {-# LINE 3395 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 295, column 9)
-              _backTree =
-                  {-# LINE 295 "./TypeChecking/Expressions.ag" #-}
-                  InPredicate ann_
-                              _exprIannotatedTree
-                              i_
-                              _listIannotatedTree
-                  {-# LINE 3403 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  InPredicate ann_ _exprIannotatedTree i_ _listIannotatedTree
-                  {-# LINE 3408 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  InPredicate ann_ _exprIoriginalTree i_ _listIoriginalTree
-                  {-# LINE 3413 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3418 "AstInternal.hs" #-}
-              -- copy rule (up)
-              _lhsOliftedColumnName =
-                  {-# LINE 161 "./TypeChecking/SelectLists.ag" #-}
-                  _exprIliftedColumnName
-                  {-# LINE 3423 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3428 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3433 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _listOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3438 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _listOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3443 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-              ( _listIannotatedTree,_listIlistType,_listIoriginalTree) =
-                  (list_ _listOcat _listOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_IntegerLit :: Annotation ->
-                             Integer ->
-                             T_Expression 
-sem_Expression_IntegerLit ann_ i_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3466 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3471 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 38, column 19)
-              _tpe =
-                  {-# LINE 38 "./TypeChecking/Expressions.ag" #-}
-                  Right typeInt
-                  {-# LINE 3476 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 47, column 9)
-              _backTree =
-                  {-# LINE 47 "./TypeChecking/Expressions.ag" #-}
-                  IntegerLit ann_ i_
-                  {-# LINE 3481 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3486 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  IntegerLit ann_ i_
-                  {-# LINE 3491 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  IntegerLit ann_ i_
-                  {-# LINE 3496 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3501 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_LiftOperator :: Annotation ->
-                               String ->
-                               T_LiftFlavour  ->
-                               T_ExpressionList  ->
-                               T_Expression 
-sem_Expression_LiftOperator ann_ oper_ flav_ args_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _flavOcat :: Catalog
-              _flavOlib :: LocalIdentifierBindings
-              _argsOcat :: Catalog
-              _argsOlib :: LocalIdentifierBindings
-              _flavIannotatedTree :: LiftFlavour
-              _flavIoriginalTree :: LiftFlavour
-              _argsIannotatedTree :: ExpressionList
-              _argsIoriginalTree :: ExpressionList
-              _argsItypeList :: ([Type])
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3531 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3536 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 167, column 9)
-              _tpe =
-                  {-# LINE 167 "./TypeChecking/Expressions.ag" #-}
-                  dependsOnRTpe _argsItypeList $ do
-                  let args = _argsIannotatedTree
-                  errorWhen (length args /= 2)
-                            [AnyAllError $ "must have two args, got " ++ show args]
-                  let [a,b] = args
-                      aType = getTypeAnnotation a
-                      bType = getTypeAnnotation b
-                  dependsOnRTpe [aType,bType] $ do
-                  errorWhen (not $ isArrayType bType)
-                            [AnyAllError $ "second arg must be array, got " ++ show args]
-                  elemType <- unwrapArray $ bType
-                  resType <- fmap (\(_,_,r,_) -> r) $ typeCheckFunCall
-                                     _lhsIcat
-                                     oper_
-                                     [aType,elemType]
-                  errorWhen (resType /= typeBool)
-                            [AnyAllError $ "operator must have bool return, got " ++ show resType]
-                  return resType
-                  {-# LINE 3558 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 185, column 9)
-              _backTree =
-                  {-# LINE 185 "./TypeChecking/Expressions.ag" #-}
-                  LiftOperator ann_ oper_ _flavIannotatedTree _argsIannotatedTree
-                  {-# LINE 3563 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3568 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftOperator ann_ oper_ _flavIannotatedTree _argsIannotatedTree
-                  {-# LINE 3573 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftOperator ann_ oper_ _flavIoriginalTree _argsIoriginalTree
-                  {-# LINE 3578 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3583 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _flavOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3588 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _flavOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3593 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3598 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3603 "AstInternal.hs" #-}
-              ( _flavIannotatedTree,_flavIoriginalTree) =
-                  (flav_ _flavOcat _flavOlib )
-              ( _argsIannotatedTree,_argsIoriginalTree,_argsItypeList) =
-                  (args_ _argsOcat _argsOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_NullLit :: Annotation ->
-                          T_Expression 
-sem_Expression_NullLit ann_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3625 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3630 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 43, column 16)
-              _tpe =
-                  {-# LINE 43 "./TypeChecking/Expressions.ag" #-}
-                  Right UnknownType
-                  {-# LINE 3635 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 55, column 9)
-              _backTree =
-                  {-# LINE 55 "./TypeChecking/Expressions.ag" #-}
-                  NullLit ann_
-                  {-# LINE 3640 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3645 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  NullLit ann_
-                  {-# LINE 3650 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  NullLit ann_
-                  {-# LINE 3655 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3660 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_Placeholder :: Annotation ->
-                              T_Expression 
-sem_Expression_Placeholder ann_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3678 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3683 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 253, column 9)
-              _tpe =
-                  {-# LINE 253 "./TypeChecking/Expressions.ag" #-}
-                  Right UnknownType
-                  {-# LINE 3688 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 254, column 9)
-              _backTree =
-                  {-# LINE 254 "./TypeChecking/Expressions.ag" #-}
-                  Placeholder ann_
-                  {-# LINE 3693 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3698 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Placeholder ann_
-                  {-# LINE 3703 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Placeholder ann_
-                  {-# LINE 3708 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3713 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_PositionalArg :: Annotation ->
-                                Integer ->
-                                T_Expression 
-sem_Expression_PositionalArg ann_ p_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3732 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3737 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 247, column 9)
-              _tpe =
-                  {-# LINE 247 "./TypeChecking/Expressions.ag" #-}
-                  libLookupID _lhsIlib ('$':show p_)
-                  {-# LINE 3742 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 248, column 9)
-              _backTree =
-                  {-# LINE 248 "./TypeChecking/Expressions.ag" #-}
-                  PositionalArg ann_ p_
-                  {-# LINE 3747 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3752 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  PositionalArg ann_ p_
-                  {-# LINE 3757 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  PositionalArg ann_ p_
-                  {-# LINE 3762 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3767 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_ScalarSubQuery :: Annotation ->
-                                 T_SelectExpression  ->
-                                 T_Expression 
-sem_Expression_ScalarSubQuery ann_ sel_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3791 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3796 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 271, column 9)
-              _tpe =
-                  {-# LINE 271 "./TypeChecking/Expressions.ag" #-}
-                  do
-                  let selType = getTypeAnnotation _selIannotatedTree
-                  dependsOnRTpe [selType] $ do
-                  f <- map snd <$> unwrapSetOfComposite selType
-                  case length f of
-                    0 -> Left [InternalError "no columns in scalar subquery?"]
-                    1 -> Right $ head f
-                    _ -> Right $ AnonymousRecordType f
-                  {-# LINE 3808 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 281, column 9)
-              _backTree =
-                  {-# LINE 281 "./TypeChecking/Expressions.ag" #-}
-                  ScalarSubQuery ann_ _selIannotatedTree
-                  {-# LINE 3813 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3818 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ScalarSubQuery ann_ _selIannotatedTree
-                  {-# LINE 3823 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ScalarSubQuery ann_ _selIoriginalTree
-                  {-# LINE 3828 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3833 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3838 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3843 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_StringLit :: Annotation ->
-                            String ->
-                            String ->
-                            T_Expression 
-sem_Expression_StringLit ann_ quote_ value_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOliftedColumnName :: String
-              _lhsOoriginalTree :: Expression
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3865 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3870 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 39, column 18)
-              _tpe =
-                  {-# LINE 39 "./TypeChecking/Expressions.ag" #-}
-                  Right UnknownType
-                  {-# LINE 3875 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 49, column 9)
-              _backTree =
-                  {-# LINE 49 "./TypeChecking/Expressions.ag" #-}
-                  StringLit ann_ quote_ value_
-                  {-# LINE 3880 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 177, column 7)
-              _lhsOliftedColumnName =
-                  {-# LINE 177 "./TypeChecking/SelectLists.ag" #-}
-                  ""
-                  {-# LINE 3885 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  StringLit ann_ quote_ value_
-                  {-# LINE 3890 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  StringLit ann_ quote_ value_
-                  {-# LINE 3895 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3900 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
-sem_Expression_WindowFn :: Annotation ->
-                           T_Expression  ->
-                           T_ExpressionList  ->
-                           T_ExpressionList  ->
-                           T_Direction  ->
-                           T_FrameClause  ->
-                           T_Expression 
-sem_Expression_WindowFn ann_ fn_ partitionBy_ orderBy_ dir_ frm_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Expression
-              _prototype :: (Maybe FunctionPrototype)
-              _lhsOoriginalTree :: Expression
-              _lhsOliftedColumnName :: String
-              _fnOcat :: Catalog
-              _fnOlib :: LocalIdentifierBindings
-              _partitionByOcat :: Catalog
-              _partitionByOlib :: LocalIdentifierBindings
-              _orderByOcat :: Catalog
-              _orderByOlib :: LocalIdentifierBindings
-              _dirOcat :: Catalog
-              _dirOlib :: LocalIdentifierBindings
-              _frmOcat :: Catalog
-              _frmOlib :: LocalIdentifierBindings
-              _fnIannotatedTree :: Expression
-              _fnIliftedColumnName :: String
-              _fnIoriginalTree :: Expression
-              _partitionByIannotatedTree :: ExpressionList
-              _partitionByIoriginalTree :: ExpressionList
-              _partitionByItypeList :: ([Type])
-              _orderByIannotatedTree :: ExpressionList
-              _orderByIoriginalTree :: ExpressionList
-              _orderByItypeList :: ([Type])
-              _dirIannotatedTree :: Direction
-              _dirIoriginalTree :: Direction
-              _frmIannotatedTree :: FrameClause
-              _frmIoriginalTree :: FrameClause
-              -- "./TypeChecking/Expressions.ag"(line 14, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 14 "./TypeChecking/Expressions.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ fmap ((:[]) . FunctionPrototypeA) _prototype
-                  {-# LINE 3946 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 29, column 9)
-              _prototype =
-                  {-# LINE 29 "./TypeChecking/Expressions.ag" #-}
-                  Nothing
-                  {-# LINE 3951 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 87, column 9)
-              _tpe =
-                  {-# LINE 87 "./TypeChecking/Expressions.ag" #-}
-                  Right (getTypeAnnotation _fnIannotatedTree)
-                  {-# LINE 3956 "AstInternal.hs" #-}
-              -- "./TypeChecking/Expressions.ag"(line 88, column 9)
-              _backTree =
-                  {-# LINE 88 "./TypeChecking/Expressions.ag" #-}
-                  WindowFn ann_
-                           _fnIannotatedTree
-                           _partitionByIannotatedTree
-                           _orderByIannotatedTree
-                           _dirIannotatedTree
-                           _frmIannotatedTree
-                  {-# LINE 3966 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  WindowFn ann_ _fnIannotatedTree _partitionByIannotatedTree _orderByIannotatedTree _dirIannotatedTree _frmIannotatedTree
-                  {-# LINE 3971 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  WindowFn ann_ _fnIoriginalTree _partitionByIoriginalTree _orderByIoriginalTree _dirIoriginalTree _frmIoriginalTree
-                  {-# LINE 3976 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 3981 "AstInternal.hs" #-}
-              -- copy rule (up)
-              _lhsOliftedColumnName =
-                  {-# LINE 161 "./TypeChecking/SelectLists.ag" #-}
-                  _fnIliftedColumnName
-                  {-# LINE 3986 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fnOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 3991 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fnOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 3996 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _partitionByOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4001 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _partitionByOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4006 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _orderByOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4011 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _orderByOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4016 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _dirOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4021 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _dirOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4026 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _frmOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4031 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _frmOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4036 "AstInternal.hs" #-}
-              ( _fnIannotatedTree,_fnIliftedColumnName,_fnIoriginalTree) =
-                  (fn_ _fnOcat _fnOlib )
-              ( _partitionByIannotatedTree,_partitionByIoriginalTree,_partitionByItypeList) =
-                  (partitionBy_ _partitionByOcat _partitionByOlib )
-              ( _orderByIannotatedTree,_orderByIoriginalTree,_orderByItypeList) =
-                  (orderBy_ _orderByOcat _orderByOlib )
-              ( _dirIannotatedTree,_dirIoriginalTree) =
-                  (dir_ _dirOcat _dirOlib )
-              ( _frmIannotatedTree,_frmIoriginalTree) =
-                  (frm_ _frmOcat _frmOlib )
-          in  ( _lhsOannotatedTree,_lhsOliftedColumnName,_lhsOoriginalTree)))
--- ExpressionDirectionPair -------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Tuple:
-         child x1             : Expression 
-         child x2             : Direction 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionDirectionPair  = ( (Expression),(Direction))
--- cata
-sem_ExpressionDirectionPair :: ExpressionDirectionPair  ->
-                               T_ExpressionDirectionPair 
-sem_ExpressionDirectionPair ( x1,x2)  =
-    (sem_ExpressionDirectionPair_Tuple (sem_Expression x1 ) (sem_Direction x2 ) )
--- semantic domain
-type T_ExpressionDirectionPair  = Catalog ->
-                                  LocalIdentifierBindings ->
-                                  ( ExpressionDirectionPair,ExpressionDirectionPair)
-data Inh_ExpressionDirectionPair  = Inh_ExpressionDirectionPair {cat_Inh_ExpressionDirectionPair :: Catalog,lib_Inh_ExpressionDirectionPair :: LocalIdentifierBindings}
-data Syn_ExpressionDirectionPair  = Syn_ExpressionDirectionPair {annotatedTree_Syn_ExpressionDirectionPair :: ExpressionDirectionPair,originalTree_Syn_ExpressionDirectionPair :: ExpressionDirectionPair}
-wrap_ExpressionDirectionPair :: T_ExpressionDirectionPair  ->
-                                Inh_ExpressionDirectionPair  ->
-                                Syn_ExpressionDirectionPair 
-wrap_ExpressionDirectionPair sem (Inh_ExpressionDirectionPair _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionDirectionPair _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionDirectionPair_Tuple :: T_Expression  ->
-                                     T_Direction  ->
-                                     T_ExpressionDirectionPair 
-sem_ExpressionDirectionPair_Tuple x1_ x2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionDirectionPair
-              _lhsOoriginalTree :: ExpressionDirectionPair
-              _x1Ocat :: Catalog
-              _x1Olib :: LocalIdentifierBindings
-              _x2Ocat :: Catalog
-              _x2Olib :: LocalIdentifierBindings
-              _x1IannotatedTree :: Expression
-              _x1IliftedColumnName :: String
-              _x1IoriginalTree :: Expression
-              _x2IannotatedTree :: Direction
-              _x2IoriginalTree :: Direction
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IannotatedTree,_x2IannotatedTree)
-                  {-# LINE 4105 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IoriginalTree,_x2IoriginalTree)
-                  {-# LINE 4110 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4115 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4120 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4125 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4130 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4135 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4140 "AstInternal.hs" #-}
-              ( _x1IannotatedTree,_x1IliftedColumnName,_x1IoriginalTree) =
-                  (x1_ _x1Ocat _x1Olib )
-              ( _x2IannotatedTree,_x2IoriginalTree) =
-                  (x2_ _x2Ocat _x2Olib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionDirectionPairList ---------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : ExpressionDirectionPair 
-         child tl             : ExpressionDirectionPairList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionDirectionPairList  = [(ExpressionDirectionPair)]
--- cata
-sem_ExpressionDirectionPairList :: ExpressionDirectionPairList  ->
-                                   T_ExpressionDirectionPairList 
-sem_ExpressionDirectionPairList list  =
-    (Prelude.foldr sem_ExpressionDirectionPairList_Cons sem_ExpressionDirectionPairList_Nil (Prelude.map sem_ExpressionDirectionPair list) )
--- semantic domain
-type T_ExpressionDirectionPairList  = Catalog ->
-                                      LocalIdentifierBindings ->
-                                      ( ExpressionDirectionPairList,ExpressionDirectionPairList)
-data Inh_ExpressionDirectionPairList  = Inh_ExpressionDirectionPairList {cat_Inh_ExpressionDirectionPairList :: Catalog,lib_Inh_ExpressionDirectionPairList :: LocalIdentifierBindings}
-data Syn_ExpressionDirectionPairList  = Syn_ExpressionDirectionPairList {annotatedTree_Syn_ExpressionDirectionPairList :: ExpressionDirectionPairList,originalTree_Syn_ExpressionDirectionPairList :: ExpressionDirectionPairList}
-wrap_ExpressionDirectionPairList :: T_ExpressionDirectionPairList  ->
-                                    Inh_ExpressionDirectionPairList  ->
-                                    Syn_ExpressionDirectionPairList 
-wrap_ExpressionDirectionPairList sem (Inh_ExpressionDirectionPairList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionDirectionPairList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionDirectionPairList_Cons :: T_ExpressionDirectionPair  ->
-                                        T_ExpressionDirectionPairList  ->
-                                        T_ExpressionDirectionPairList 
-sem_ExpressionDirectionPairList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionDirectionPairList
-              _lhsOoriginalTree :: ExpressionDirectionPairList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: ExpressionDirectionPair
-              _hdIoriginalTree :: ExpressionDirectionPair
-              _tlIannotatedTree :: ExpressionDirectionPairList
-              _tlIoriginalTree :: ExpressionDirectionPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 4206 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 4211 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4216 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4221 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4226 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4231 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4236 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4241 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_ExpressionDirectionPairList_Nil :: T_ExpressionDirectionPairList 
-sem_ExpressionDirectionPairList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionDirectionPairList
-              _lhsOoriginalTree :: ExpressionDirectionPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4257 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4262 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4267 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4272 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionList ----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         typeList             : [Type]
-   alternatives:
-      alternative Cons:
-         child hd             : Expression 
-         child tl             : ExpressionList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionList  = [(Expression)]
--- cata
-sem_ExpressionList :: ExpressionList  ->
-                      T_ExpressionList 
-sem_ExpressionList list  =
-    (Prelude.foldr sem_ExpressionList_Cons sem_ExpressionList_Nil (Prelude.map sem_Expression list) )
--- semantic domain
-type T_ExpressionList  = Catalog ->
-                         LocalIdentifierBindings ->
-                         ( ExpressionList,ExpressionList,([Type]))
-data Inh_ExpressionList  = Inh_ExpressionList {cat_Inh_ExpressionList :: Catalog,lib_Inh_ExpressionList :: LocalIdentifierBindings}
-data Syn_ExpressionList  = Syn_ExpressionList {annotatedTree_Syn_ExpressionList :: ExpressionList,originalTree_Syn_ExpressionList :: ExpressionList,typeList_Syn_ExpressionList :: [Type]}
-wrap_ExpressionList :: T_ExpressionList  ->
-                       Inh_ExpressionList  ->
-                       Syn_ExpressionList 
-wrap_ExpressionList sem (Inh_ExpressionList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeList) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionList _lhsOannotatedTree _lhsOoriginalTree _lhsOtypeList ))
-sem_ExpressionList_Cons :: T_Expression  ->
-                           T_ExpressionList  ->
-                           T_ExpressionList 
-sem_ExpressionList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOtypeList :: ([Type])
-              _lhsOannotatedTree :: ExpressionList
-              _lhsOoriginalTree :: ExpressionList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: Expression
-              _hdIliftedColumnName :: String
-              _hdIoriginalTree :: Expression
-              _tlIannotatedTree :: ExpressionList
-              _tlIoriginalTree :: ExpressionList
-              _tlItypeList :: ([Type])
-              -- "./TypeChecking/Misc.ag"(line 52, column 12)
-              _lhsOtypeList =
-                  {-# LINE 52 "./TypeChecking/Misc.ag" #-}
-                  getTypeAnnotation _hdIannotatedTree : _tlItypeList
-                  {-# LINE 4338 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 4343 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 4348 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4353 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4358 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4363 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4368 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4373 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4378 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIliftedColumnName,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlItypeList) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeList)))
-sem_ExpressionList_Nil :: T_ExpressionList 
-sem_ExpressionList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOtypeList :: ([Type])
-              _lhsOannotatedTree :: ExpressionList
-              _lhsOoriginalTree :: ExpressionList
-              -- "./TypeChecking/Misc.ag"(line 53, column 11)
-              _lhsOtypeList =
-                  {-# LINE 53 "./TypeChecking/Misc.ag" #-}
-                  []
-                  {-# LINE 4395 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4400 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4405 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4410 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4415 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeList)))
--- ExpressionListList ------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         typeListList         : [[Type]]
-   alternatives:
-      alternative Cons:
-         child hd             : ExpressionList 
-         child tl             : ExpressionListList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionListList  = [(ExpressionList)]
--- cata
-sem_ExpressionListList :: ExpressionListList  ->
-                          T_ExpressionListList 
-sem_ExpressionListList list  =
-    (Prelude.foldr sem_ExpressionListList_Cons sem_ExpressionListList_Nil (Prelude.map sem_ExpressionList list) )
--- semantic domain
-type T_ExpressionListList  = Catalog ->
-                             LocalIdentifierBindings ->
-                             ( ExpressionListList,ExpressionListList,([[Type]]))
-data Inh_ExpressionListList  = Inh_ExpressionListList {cat_Inh_ExpressionListList :: Catalog,lib_Inh_ExpressionListList :: LocalIdentifierBindings}
-data Syn_ExpressionListList  = Syn_ExpressionListList {annotatedTree_Syn_ExpressionListList :: ExpressionListList,originalTree_Syn_ExpressionListList :: ExpressionListList,typeListList_Syn_ExpressionListList :: [[Type]]}
-wrap_ExpressionListList :: T_ExpressionListList  ->
-                           Inh_ExpressionListList  ->
-                           Syn_ExpressionListList 
-wrap_ExpressionListList sem (Inh_ExpressionListList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeListList) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionListList _lhsOannotatedTree _lhsOoriginalTree _lhsOtypeListList ))
-sem_ExpressionListList_Cons :: T_ExpressionList  ->
-                               T_ExpressionListList  ->
-                               T_ExpressionListList 
-sem_ExpressionListList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOtypeListList :: ([[Type]])
-              _lhsOannotatedTree :: ExpressionListList
-              _lhsOoriginalTree :: ExpressionListList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: ExpressionList
-              _hdIoriginalTree :: ExpressionList
-              _hdItypeList :: ([Type])
-              _tlIannotatedTree :: ExpressionListList
-              _tlIoriginalTree :: ExpressionListList
-              _tlItypeListList :: ([[Type]])
-              -- "./TypeChecking/Misc.ag"(line 59, column 12)
-              _lhsOtypeListList =
-                  {-# LINE 59 "./TypeChecking/Misc.ag" #-}
-                  _hdItypeList : _tlItypeListList
-                  {-# LINE 4481 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 4486 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 4491 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4496 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4501 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4506 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4511 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4516 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4521 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree,_hdItypeList) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlItypeListList) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeListList)))
-sem_ExpressionListList_Nil :: T_ExpressionListList 
-sem_ExpressionListList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOtypeListList :: ([[Type]])
-              _lhsOannotatedTree :: ExpressionListList
-              _lhsOoriginalTree :: ExpressionListList
-              -- "./TypeChecking/Misc.ag"(line 60, column 11)
-              _lhsOtypeListList =
-                  {-# LINE 60 "./TypeChecking/Misc.ag" #-}
-                  []
-                  {-# LINE 4538 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4543 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4548 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4553 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4558 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOtypeListList)))
--- ExpressionListStatementListPair -----------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Tuple:
-         child x1             : ExpressionList 
-         child x2             : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionListStatementListPair  = ( (ExpressionList),(StatementList))
--- cata
-sem_ExpressionListStatementListPair :: ExpressionListStatementListPair  ->
-                                       T_ExpressionListStatementListPair 
-sem_ExpressionListStatementListPair ( x1,x2)  =
-    (sem_ExpressionListStatementListPair_Tuple (sem_ExpressionList x1 ) (sem_StatementList x2 ) )
--- semantic domain
-type T_ExpressionListStatementListPair  = Catalog ->
-                                          LocalIdentifierBindings ->
-                                          ( ExpressionListStatementListPair,ExpressionListStatementListPair)
-data Inh_ExpressionListStatementListPair  = Inh_ExpressionListStatementListPair {cat_Inh_ExpressionListStatementListPair :: Catalog,lib_Inh_ExpressionListStatementListPair :: LocalIdentifierBindings}
-data Syn_ExpressionListStatementListPair  = Syn_ExpressionListStatementListPair {annotatedTree_Syn_ExpressionListStatementListPair :: ExpressionListStatementListPair,originalTree_Syn_ExpressionListStatementListPair :: ExpressionListStatementListPair}
-wrap_ExpressionListStatementListPair :: T_ExpressionListStatementListPair  ->
-                                        Inh_ExpressionListStatementListPair  ->
-                                        Syn_ExpressionListStatementListPair 
-wrap_ExpressionListStatementListPair sem (Inh_ExpressionListStatementListPair _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionListStatementListPair _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionListStatementListPair_Tuple :: T_ExpressionList  ->
-                                             T_StatementList  ->
-                                             T_ExpressionListStatementListPair 
-sem_ExpressionListStatementListPair_Tuple x1_ x2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _x2OcatUpdates :: ([CatalogUpdate])
-              _x2OlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: ExpressionListStatementListPair
-              _lhsOoriginalTree :: ExpressionListStatementListPair
-              _x1Ocat :: Catalog
-              _x1Olib :: LocalIdentifierBindings
-              _x2Ocat :: Catalog
-              _x2Olib :: LocalIdentifierBindings
-              _x1IannotatedTree :: ExpressionList
-              _x1IoriginalTree :: ExpressionList
-              _x1ItypeList :: ([Type])
-              _x2IannotatedTree :: StatementList
-              _x2IoriginalTree :: StatementList
-              _x2IproducedCat :: Catalog
-              _x2IproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 94, column 9)
-              _x2OcatUpdates =
-                  {-# LINE 94 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 4621 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 95, column 9)
-              _x2OlibUpdates =
-                  {-# LINE 95 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 4626 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IannotatedTree,_x2IannotatedTree)
-                  {-# LINE 4631 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IoriginalTree,_x2IoriginalTree)
-                  {-# LINE 4636 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4641 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4646 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4651 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4656 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4661 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4666 "AstInternal.hs" #-}
-              ( _x1IannotatedTree,_x1IoriginalTree,_x1ItypeList) =
-                  (x1_ _x1Ocat _x1Olib )
-              ( _x2IannotatedTree,_x2IoriginalTree,_x2IproducedCat,_x2IproducedLib) =
-                  (x2_ _x2Ocat _x2OcatUpdates _x2Olib _x2OlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionListStatementListPairList -------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : ExpressionListStatementListPair 
-         child tl             : ExpressionListStatementListPairList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionListStatementListPairList  = [(ExpressionListStatementListPair)]
--- cata
-sem_ExpressionListStatementListPairList :: ExpressionListStatementListPairList  ->
-                                           T_ExpressionListStatementListPairList 
-sem_ExpressionListStatementListPairList list  =
-    (Prelude.foldr sem_ExpressionListStatementListPairList_Cons sem_ExpressionListStatementListPairList_Nil (Prelude.map sem_ExpressionListStatementListPair list) )
--- semantic domain
-type T_ExpressionListStatementListPairList  = Catalog ->
-                                              LocalIdentifierBindings ->
-                                              ( ExpressionListStatementListPairList,ExpressionListStatementListPairList)
-data Inh_ExpressionListStatementListPairList  = Inh_ExpressionListStatementListPairList {cat_Inh_ExpressionListStatementListPairList :: Catalog,lib_Inh_ExpressionListStatementListPairList :: LocalIdentifierBindings}
-data Syn_ExpressionListStatementListPairList  = Syn_ExpressionListStatementListPairList {annotatedTree_Syn_ExpressionListStatementListPairList :: ExpressionListStatementListPairList,originalTree_Syn_ExpressionListStatementListPairList :: ExpressionListStatementListPairList}
-wrap_ExpressionListStatementListPairList :: T_ExpressionListStatementListPairList  ->
-                                            Inh_ExpressionListStatementListPairList  ->
-                                            Syn_ExpressionListStatementListPairList 
-wrap_ExpressionListStatementListPairList sem (Inh_ExpressionListStatementListPairList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionListStatementListPairList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionListStatementListPairList_Cons :: T_ExpressionListStatementListPair  ->
-                                                T_ExpressionListStatementListPairList  ->
-                                                T_ExpressionListStatementListPairList 
-sem_ExpressionListStatementListPairList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionListStatementListPairList
-              _lhsOoriginalTree :: ExpressionListStatementListPairList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: ExpressionListStatementListPair
-              _hdIoriginalTree :: ExpressionListStatementListPair
-              _tlIannotatedTree :: ExpressionListStatementListPairList
-              _tlIoriginalTree :: ExpressionListStatementListPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 4732 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 4737 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4742 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4747 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4752 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4757 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4762 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4767 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_ExpressionListStatementListPairList_Nil :: T_ExpressionListStatementListPairList 
-sem_ExpressionListStatementListPairList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionListStatementListPairList
-              _lhsOoriginalTree :: ExpressionListStatementListPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4783 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 4788 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4793 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4798 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionRoot ----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative ExpressionRoot:
-         child expr           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data ExpressionRoot  = ExpressionRoot (Expression) 
-                     deriving ( Show)
--- cata
-sem_ExpressionRoot :: ExpressionRoot  ->
-                      T_ExpressionRoot 
-sem_ExpressionRoot (ExpressionRoot _expr )  =
-    (sem_ExpressionRoot_ExpressionRoot (sem_Expression _expr ) )
--- semantic domain
-type T_ExpressionRoot  = Catalog ->
-                         LocalIdentifierBindings ->
-                         ( ExpressionRoot,ExpressionRoot)
-data Inh_ExpressionRoot  = Inh_ExpressionRoot {cat_Inh_ExpressionRoot :: Catalog,lib_Inh_ExpressionRoot :: LocalIdentifierBindings}
-data Syn_ExpressionRoot  = Syn_ExpressionRoot {annotatedTree_Syn_ExpressionRoot :: ExpressionRoot,originalTree_Syn_ExpressionRoot :: ExpressionRoot}
-wrap_ExpressionRoot :: T_ExpressionRoot  ->
-                       Inh_ExpressionRoot  ->
-                       Syn_ExpressionRoot 
-wrap_ExpressionRoot sem (Inh_ExpressionRoot _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionRoot _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionRoot_ExpressionRoot :: T_Expression  ->
-                                     T_ExpressionRoot 
-sem_ExpressionRoot_ExpressionRoot expr_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionRoot
-              _lhsOoriginalTree :: ExpressionRoot
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ExpressionRoot _exprIannotatedTree
-                  {-# LINE 4852 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ExpressionRoot _exprIoriginalTree
-                  {-# LINE 4857 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4862 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4867 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4872 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4877 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionStatementListPair ---------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Tuple:
-         child x1             : Expression 
-         child x2             : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionStatementListPair  = ( (Expression),(StatementList))
--- cata
-sem_ExpressionStatementListPair :: ExpressionStatementListPair  ->
-                                   T_ExpressionStatementListPair 
-sem_ExpressionStatementListPair ( x1,x2)  =
-    (sem_ExpressionStatementListPair_Tuple (sem_Expression x1 ) (sem_StatementList x2 ) )
--- semantic domain
-type T_ExpressionStatementListPair  = Catalog ->
-                                      LocalIdentifierBindings ->
-                                      ( ExpressionStatementListPair,ExpressionStatementListPair)
-data Inh_ExpressionStatementListPair  = Inh_ExpressionStatementListPair {cat_Inh_ExpressionStatementListPair :: Catalog,lib_Inh_ExpressionStatementListPair :: LocalIdentifierBindings}
-data Syn_ExpressionStatementListPair  = Syn_ExpressionStatementListPair {annotatedTree_Syn_ExpressionStatementListPair :: ExpressionStatementListPair,originalTree_Syn_ExpressionStatementListPair :: ExpressionStatementListPair}
-wrap_ExpressionStatementListPair :: T_ExpressionStatementListPair  ->
-                                    Inh_ExpressionStatementListPair  ->
-                                    Syn_ExpressionStatementListPair 
-wrap_ExpressionStatementListPair sem (Inh_ExpressionStatementListPair _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionStatementListPair _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionStatementListPair_Tuple :: T_Expression  ->
-                                         T_StatementList  ->
-                                         T_ExpressionStatementListPair 
-sem_ExpressionStatementListPair_Tuple x1_ x2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _x2OcatUpdates :: ([CatalogUpdate])
-              _x2OlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: ExpressionStatementListPair
-              _lhsOoriginalTree :: ExpressionStatementListPair
-              _x1Ocat :: Catalog
-              _x1Olib :: LocalIdentifierBindings
-              _x2Ocat :: Catalog
-              _x2Olib :: LocalIdentifierBindings
-              _x1IannotatedTree :: Expression
-              _x1IliftedColumnName :: String
-              _x1IoriginalTree :: Expression
-              _x2IannotatedTree :: StatementList
-              _x2IoriginalTree :: StatementList
-              _x2IproducedCat :: Catalog
-              _x2IproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 98, column 9)
-              _x2OcatUpdates =
-                  {-# LINE 98 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 4942 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 99, column 9)
-              _x2OlibUpdates =
-                  {-# LINE 99 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 4947 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IannotatedTree,_x2IannotatedTree)
-                  {-# LINE 4952 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (_x1IoriginalTree,_x2IoriginalTree)
-                  {-# LINE 4957 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 4962 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 4967 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4972 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4977 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 4982 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 4987 "AstInternal.hs" #-}
-              ( _x1IannotatedTree,_x1IliftedColumnName,_x1IoriginalTree) =
-                  (x1_ _x1Ocat _x1Olib )
-              ( _x2IannotatedTree,_x2IoriginalTree,_x2IproducedCat,_x2IproducedLib) =
-                  (x2_ _x2Ocat _x2OcatUpdates _x2Olib _x2OlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ExpressionStatementListPairList -----------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : ExpressionStatementListPair 
-         child tl             : ExpressionStatementListPairList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ExpressionStatementListPairList  = [(ExpressionStatementListPair)]
--- cata
-sem_ExpressionStatementListPairList :: ExpressionStatementListPairList  ->
-                                       T_ExpressionStatementListPairList 
-sem_ExpressionStatementListPairList list  =
-    (Prelude.foldr sem_ExpressionStatementListPairList_Cons sem_ExpressionStatementListPairList_Nil (Prelude.map sem_ExpressionStatementListPair list) )
--- semantic domain
-type T_ExpressionStatementListPairList  = Catalog ->
-                                          LocalIdentifierBindings ->
-                                          ( ExpressionStatementListPairList,ExpressionStatementListPairList)
-data Inh_ExpressionStatementListPairList  = Inh_ExpressionStatementListPairList {cat_Inh_ExpressionStatementListPairList :: Catalog,lib_Inh_ExpressionStatementListPairList :: LocalIdentifierBindings}
-data Syn_ExpressionStatementListPairList  = Syn_ExpressionStatementListPairList {annotatedTree_Syn_ExpressionStatementListPairList :: ExpressionStatementListPairList,originalTree_Syn_ExpressionStatementListPairList :: ExpressionStatementListPairList}
-wrap_ExpressionStatementListPairList :: T_ExpressionStatementListPairList  ->
-                                        Inh_ExpressionStatementListPairList  ->
-                                        Syn_ExpressionStatementListPairList 
-wrap_ExpressionStatementListPairList sem (Inh_ExpressionStatementListPairList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ExpressionStatementListPairList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_ExpressionStatementListPairList_Cons :: T_ExpressionStatementListPair  ->
-                                            T_ExpressionStatementListPairList  ->
-                                            T_ExpressionStatementListPairList 
-sem_ExpressionStatementListPairList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionStatementListPairList
-              _lhsOoriginalTree :: ExpressionStatementListPairList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: ExpressionStatementListPair
-              _hdIoriginalTree :: ExpressionStatementListPair
-              _tlIannotatedTree :: ExpressionStatementListPairList
-              _tlIoriginalTree :: ExpressionStatementListPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 5053 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 5058 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5063 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5068 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5073 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5078 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5083 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5088 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_ExpressionStatementListPairList_Nil :: T_ExpressionStatementListPairList 
-sem_ExpressionStatementListPairList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: ExpressionStatementListPairList
-              _lhsOoriginalTree :: ExpressionStatementListPairList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 5104 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 5109 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5114 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5119 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- FnBody ------------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative PlpgsqlFnBody:
-         child ann            : {Annotation}
-         child vars           : VarDefList 
-         child sts            : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative SqlFnBody:
-         child ann            : {Annotation}
-         child sts            : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data FnBody  = PlpgsqlFnBody (Annotation) (VarDefList) (StatementList) 
-             | SqlFnBody (Annotation) (StatementList) 
-             deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_FnBody :: FnBody  ->
-              T_FnBody 
-sem_FnBody (PlpgsqlFnBody _ann _vars _sts )  =
-    (sem_FnBody_PlpgsqlFnBody _ann (sem_VarDefList _vars ) (sem_StatementList _sts ) )
-sem_FnBody (SqlFnBody _ann _sts )  =
-    (sem_FnBody_SqlFnBody _ann (sem_StatementList _sts ) )
--- semantic domain
-type T_FnBody  = Catalog ->
-                 LocalIdentifierBindings ->
-                 ( FnBody,FnBody)
-data Inh_FnBody  = Inh_FnBody {cat_Inh_FnBody :: Catalog,lib_Inh_FnBody :: LocalIdentifierBindings}
-data Syn_FnBody  = Syn_FnBody {annotatedTree_Syn_FnBody :: FnBody,originalTree_Syn_FnBody :: FnBody}
-wrap_FnBody :: T_FnBody  ->
-               Inh_FnBody  ->
-               Syn_FnBody 
-wrap_FnBody sem (Inh_FnBody _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_FnBody _lhsOannotatedTree _lhsOoriginalTree ))
-sem_FnBody_PlpgsqlFnBody :: Annotation ->
-                            T_VarDefList  ->
-                            T_StatementList  ->
-                            T_FnBody 
-sem_FnBody_PlpgsqlFnBody ann_ vars_ sts_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _stsOcatUpdates :: ([CatalogUpdate])
-              _stsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _stsOlib :: LocalIdentifierBindings
-              _lhsOannotatedTree :: FnBody
-              _lhsOoriginalTree :: FnBody
-              _varsOcat :: Catalog
-              _varsOlib :: LocalIdentifierBindings
-              _stsOcat :: Catalog
-              _varsIannotatedTree :: VarDefList
-              _varsIdefs :: ([(String,Type)])
-              _varsIoriginalTree :: VarDefList
-              _stsIannotatedTree :: StatementList
-              _stsIoriginalTree :: StatementList
-              _stsIproducedCat :: Catalog
-              _stsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 102, column 9)
-              _stsOcatUpdates =
-                  {-# LINE 102 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 5194 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 103, column 9)
-              _stsOlibUpdates =
-                  {-# LINE 103 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 5199 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 121, column 9)
-              _stsOlib =
-                  {-# LINE 121 "./TypeChecking/CreateFunction.ag" #-}
-                  fromRight _lhsIlib $
-                  updateBindings _lhsIlib _lhsIcat
-                                 [LibStackIDs [("", _varsIdefs)]]
-                  {-# LINE 5206 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  PlpgsqlFnBody ann_ _varsIannotatedTree _stsIannotatedTree
-                  {-# LINE 5211 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  PlpgsqlFnBody ann_ _varsIoriginalTree _stsIoriginalTree
-                  {-# LINE 5216 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5221 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5226 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _varsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5231 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _varsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5236 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5241 "AstInternal.hs" #-}
-              ( _varsIannotatedTree,_varsIdefs,_varsIoriginalTree) =
-                  (vars_ _varsOcat _varsOlib )
-              ( _stsIannotatedTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
-                  (sts_ _stsOcat _stsOcatUpdates _stsOlib _stsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_FnBody_SqlFnBody :: Annotation ->
-                        T_StatementList  ->
-                        T_FnBody 
-sem_FnBody_SqlFnBody ann_ sts_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _stsOcatUpdates :: ([CatalogUpdate])
-              _stsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: FnBody
-              _lhsOoriginalTree :: FnBody
-              _stsOcat :: Catalog
-              _stsOlib :: LocalIdentifierBindings
-              _stsIannotatedTree :: StatementList
-              _stsIoriginalTree :: StatementList
-              _stsIproducedCat :: Catalog
-              _stsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 102, column 9)
-              _stsOcatUpdates =
-                  {-# LINE 102 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 5267 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 103, column 9)
-              _stsOlibUpdates =
-                  {-# LINE 103 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 5272 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SqlFnBody ann_ _stsIannotatedTree
-                  {-# LINE 5277 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SqlFnBody ann_ _stsIoriginalTree
-                  {-# LINE 5282 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5287 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5292 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5297 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5302 "AstInternal.hs" #-}
-              ( _stsIannotatedTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
-                  (sts_ _stsOcat _stsOcatUpdates _stsOlib _stsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- FrameClause -------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative FrameRowsUnboundedPreceding:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative FrameUnboundedFull:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative FrameUnboundedPreceding:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data FrameClause  = FrameRowsUnboundedPreceding 
-                  | FrameUnboundedFull 
-                  | FrameUnboundedPreceding 
-                  deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_FrameClause :: FrameClause  ->
-                   T_FrameClause 
-sem_FrameClause (FrameRowsUnboundedPreceding )  =
-    (sem_FrameClause_FrameRowsUnboundedPreceding )
-sem_FrameClause (FrameUnboundedFull )  =
-    (sem_FrameClause_FrameUnboundedFull )
-sem_FrameClause (FrameUnboundedPreceding )  =
-    (sem_FrameClause_FrameUnboundedPreceding )
--- semantic domain
-type T_FrameClause  = Catalog ->
-                      LocalIdentifierBindings ->
-                      ( FrameClause,FrameClause)
-data Inh_FrameClause  = Inh_FrameClause {cat_Inh_FrameClause :: Catalog,lib_Inh_FrameClause :: LocalIdentifierBindings}
-data Syn_FrameClause  = Syn_FrameClause {annotatedTree_Syn_FrameClause :: FrameClause,originalTree_Syn_FrameClause :: FrameClause}
-wrap_FrameClause :: T_FrameClause  ->
-                    Inh_FrameClause  ->
-                    Syn_FrameClause 
-wrap_FrameClause sem (Inh_FrameClause _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_FrameClause _lhsOannotatedTree _lhsOoriginalTree ))
-sem_FrameClause_FrameRowsUnboundedPreceding :: T_FrameClause 
-sem_FrameClause_FrameRowsUnboundedPreceding  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: FrameClause
-              _lhsOoriginalTree :: FrameClause
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameRowsUnboundedPreceding
-                  {-# LINE 5365 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameRowsUnboundedPreceding
-                  {-# LINE 5370 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5375 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5380 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_FrameClause_FrameUnboundedFull :: T_FrameClause 
-sem_FrameClause_FrameUnboundedFull  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: FrameClause
-              _lhsOoriginalTree :: FrameClause
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameUnboundedFull
-                  {-# LINE 5392 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameUnboundedFull
-                  {-# LINE 5397 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5402 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5407 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_FrameClause_FrameUnboundedPreceding :: T_FrameClause 
-sem_FrameClause_FrameUnboundedPreceding  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: FrameClause
-              _lhsOoriginalTree :: FrameClause
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameUnboundedPreceding
-                  {-# LINE 5419 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FrameUnboundedPreceding
-                  {-# LINE 5424 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5429 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5434 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- IfExists ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative IfExists:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Require:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data IfExists  = IfExists 
-               | Require 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_IfExists :: IfExists  ->
-                T_IfExists 
-sem_IfExists (IfExists )  =
-    (sem_IfExists_IfExists )
-sem_IfExists (Require )  =
-    (sem_IfExists_Require )
--- semantic domain
-type T_IfExists  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( IfExists,IfExists)
-data Inh_IfExists  = Inh_IfExists {cat_Inh_IfExists :: Catalog,lib_Inh_IfExists :: LocalIdentifierBindings}
-data Syn_IfExists  = Syn_IfExists {annotatedTree_Syn_IfExists :: IfExists,originalTree_Syn_IfExists :: IfExists}
-wrap_IfExists :: T_IfExists  ->
-                 Inh_IfExists  ->
-                 Syn_IfExists 
-wrap_IfExists sem (Inh_IfExists _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_IfExists _lhsOannotatedTree _lhsOoriginalTree ))
-sem_IfExists_IfExists :: T_IfExists 
-sem_IfExists_IfExists  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: IfExists
-              _lhsOoriginalTree :: IfExists
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  IfExists
-                  {-# LINE 5488 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  IfExists
-                  {-# LINE 5493 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5498 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5503 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_IfExists_Require :: T_IfExists 
-sem_IfExists_Require  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: IfExists
-              _lhsOoriginalTree :: IfExists
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Require
-                  {-# LINE 5515 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Require
-                  {-# LINE 5520 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5525 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5530 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- InList ------------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         listType             : Either [TypeError] Type
-         originalTree         : SELF 
-   alternatives:
-      alternative InList:
-         child ann            : {Annotation}
-         child exprs          : ExpressionList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative InSelect:
-         child ann            : {Annotation}
-         child sel            : SelectExpression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data InList  = InList (Annotation) (ExpressionList) 
-             | InSelect (Annotation) (SelectExpression) 
-             deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_InList :: InList  ->
-              T_InList 
-sem_InList (InList _ann _exprs )  =
-    (sem_InList_InList _ann (sem_ExpressionList _exprs ) )
-sem_InList (InSelect _ann _sel )  =
-    (sem_InList_InSelect _ann (sem_SelectExpression _sel ) )
--- semantic domain
-type T_InList  = Catalog ->
-                 LocalIdentifierBindings ->
-                 ( InList,(Either [TypeError] Type),InList)
-data Inh_InList  = Inh_InList {cat_Inh_InList :: Catalog,lib_Inh_InList :: LocalIdentifierBindings}
-data Syn_InList  = Syn_InList {annotatedTree_Syn_InList :: InList,listType_Syn_InList :: Either [TypeError] Type,originalTree_Syn_InList :: InList}
-wrap_InList :: T_InList  ->
-               Inh_InList  ->
-               Syn_InList 
-wrap_InList sem (Inh_InList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_InList _lhsOannotatedTree _lhsOlistType _lhsOoriginalTree ))
-sem_InList_InList :: Annotation ->
-                     T_ExpressionList  ->
-                     T_InList 
-sem_InList_InList ann_ exprs_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: (Either [TypeError] Type)
-              _lhsOannotatedTree :: InList
-              _lhsOoriginalTree :: InList
-              _exprsOcat :: Catalog
-              _exprsOlib :: LocalIdentifierBindings
-              _exprsIannotatedTree :: ExpressionList
-              _exprsIoriginalTree :: ExpressionList
-              _exprsItypeList :: ([Type])
-              -- "./TypeChecking/Expressions.ag"(line 305, column 9)
-              _lhsOlistType =
-                  {-# LINE 305 "./TypeChecking/Expressions.ag" #-}
-                  resolveResultSetType _lhsIcat _exprsItypeList
-                  {-# LINE 5597 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  InList ann_ _exprsIannotatedTree
-                  {-# LINE 5602 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  InList ann_ _exprsIoriginalTree
-                  {-# LINE 5607 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5612 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5617 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5622 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5627 "AstInternal.hs" #-}
-              ( _exprsIannotatedTree,_exprsIoriginalTree,_exprsItypeList) =
-                  (exprs_ _exprsOcat _exprsOlib )
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
-sem_InList_InSelect :: Annotation ->
-                       T_SelectExpression  ->
-                       T_InList 
-sem_InList_InSelect ann_ sel_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: (Either [TypeError] Type)
-              _lhsOannotatedTree :: InList
-              _lhsOoriginalTree :: InList
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Expressions.ag"(line 307, column 9)
-              _lhsOlistType =
-                  {-# LINE 307 "./TypeChecking/Expressions.ag" #-}
-                  do
-                  attrs <- map snd <$> (unwrapSetOfComposite $
-                                        getTypeAnnotation _selIannotatedTree)
-                  typ <- case length attrs of
-                            0 -> Left [InternalError
-                                       "got subquery with no columns? in inselect"]
-                            1 -> Right $ head attrs
-                            _ -> Right $ AnonymousRecordType attrs
-                  dependsOnRTpe attrs $ Right typ
-                  {-# LINE 5657 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  InSelect ann_ _selIannotatedTree
-                  {-# LINE 5662 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  InSelect ann_ _selIoriginalTree
-                  {-# LINE 5667 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5672 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5677 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5682 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5687 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
--- JoinExpression ----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative JoinOn:
-         child ann            : {Annotation}
-         child expression     : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative JoinUsing:
-         child ann            : {Annotation}
-         child stringList     : StringList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data JoinExpression  = JoinOn (Annotation) (Expression) 
-                     | JoinUsing (Annotation) (StringList) 
-                     deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_JoinExpression :: JoinExpression  ->
-                      T_JoinExpression 
-sem_JoinExpression (JoinOn _ann _expression )  =
-    (sem_JoinExpression_JoinOn _ann (sem_Expression _expression ) )
-sem_JoinExpression (JoinUsing _ann _stringList )  =
-    (sem_JoinExpression_JoinUsing _ann (sem_StringList _stringList ) )
--- semantic domain
-type T_JoinExpression  = Catalog ->
-                         LocalIdentifierBindings ->
-                         ( JoinExpression,JoinExpression)
-data Inh_JoinExpression  = Inh_JoinExpression {cat_Inh_JoinExpression :: Catalog,lib_Inh_JoinExpression :: LocalIdentifierBindings}
-data Syn_JoinExpression  = Syn_JoinExpression {annotatedTree_Syn_JoinExpression :: JoinExpression,originalTree_Syn_JoinExpression :: JoinExpression}
-wrap_JoinExpression :: T_JoinExpression  ->
-                       Inh_JoinExpression  ->
-                       Syn_JoinExpression 
-wrap_JoinExpression sem (Inh_JoinExpression _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_JoinExpression _lhsOannotatedTree _lhsOoriginalTree ))
-sem_JoinExpression_JoinOn :: Annotation ->
-                             T_Expression  ->
-                             T_JoinExpression 
-sem_JoinExpression_JoinOn ann_ expression_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinExpression
-              _lhsOoriginalTree :: JoinExpression
-              _expressionOcat :: Catalog
-              _expressionOlib :: LocalIdentifierBindings
-              _expressionIannotatedTree :: Expression
-              _expressionIliftedColumnName :: String
-              _expressionIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinOn ann_ _expressionIannotatedTree
-                  {-# LINE 5754 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinOn ann_ _expressionIoriginalTree
-                  {-# LINE 5759 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5764 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5769 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5774 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5779 "AstInternal.hs" #-}
-              ( _expressionIannotatedTree,_expressionIliftedColumnName,_expressionIoriginalTree) =
-                  (expression_ _expressionOcat _expressionOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_JoinExpression_JoinUsing :: Annotation ->
-                                T_StringList  ->
-                                T_JoinExpression 
-sem_JoinExpression_JoinUsing ann_ stringList_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinExpression
-              _lhsOoriginalTree :: JoinExpression
-              _stringListOcat :: Catalog
-              _stringListOlib :: LocalIdentifierBindings
-              _stringListIannotatedTree :: StringList
-              _stringListIoriginalTree :: StringList
-              _stringListIstrings :: ([String])
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinUsing ann_ _stringListIannotatedTree
-                  {-# LINE 5800 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinUsing ann_ _stringListIoriginalTree
-                  {-# LINE 5805 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5810 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5815 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 5820 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stringListOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 5825 "AstInternal.hs" #-}
-              ( _stringListIannotatedTree,_stringListIoriginalTree,_stringListIstrings) =
-                  (stringList_ _stringListOcat _stringListOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- JoinType ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cross:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative FullOuter:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Inner:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative LeftOuter:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RightOuter:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data JoinType  = Cross 
-               | FullOuter 
-               | Inner 
-               | LeftOuter 
-               | RightOuter 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_JoinType :: JoinType  ->
-                T_JoinType 
-sem_JoinType (Cross )  =
-    (sem_JoinType_Cross )
-sem_JoinType (FullOuter )  =
-    (sem_JoinType_FullOuter )
-sem_JoinType (Inner )  =
-    (sem_JoinType_Inner )
-sem_JoinType (LeftOuter )  =
-    (sem_JoinType_LeftOuter )
-sem_JoinType (RightOuter )  =
-    (sem_JoinType_RightOuter )
--- semantic domain
-type T_JoinType  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( JoinType,JoinType)
-data Inh_JoinType  = Inh_JoinType {cat_Inh_JoinType :: Catalog,lib_Inh_JoinType :: LocalIdentifierBindings}
-data Syn_JoinType  = Syn_JoinType {annotatedTree_Syn_JoinType :: JoinType,originalTree_Syn_JoinType :: JoinType}
-wrap_JoinType :: T_JoinType  ->
-                 Inh_JoinType  ->
-                 Syn_JoinType 
-wrap_JoinType sem (Inh_JoinType _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_JoinType _lhsOannotatedTree _lhsOoriginalTree ))
-sem_JoinType_Cross :: T_JoinType 
-sem_JoinType_Cross  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinType
-              _lhsOoriginalTree :: JoinType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Cross
-                  {-# LINE 5902 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Cross
-                  {-# LINE 5907 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5912 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5917 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_JoinType_FullOuter :: T_JoinType 
-sem_JoinType_FullOuter  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinType
-              _lhsOoriginalTree :: JoinType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FullOuter
-                  {-# LINE 5929 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FullOuter
-                  {-# LINE 5934 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5939 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5944 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_JoinType_Inner :: T_JoinType 
-sem_JoinType_Inner  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinType
-              _lhsOoriginalTree :: JoinType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Inner
-                  {-# LINE 5956 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Inner
-                  {-# LINE 5961 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5966 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5971 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_JoinType_LeftOuter :: T_JoinType 
-sem_JoinType_LeftOuter  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinType
-              _lhsOoriginalTree :: JoinType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  LeftOuter
-                  {-# LINE 5983 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  LeftOuter
-                  {-# LINE 5988 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 5993 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 5998 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_JoinType_RightOuter :: T_JoinType 
-sem_JoinType_RightOuter  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: JoinType
-              _lhsOoriginalTree :: JoinType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RightOuter
-                  {-# LINE 6010 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RightOuter
-                  {-# LINE 6015 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6020 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6025 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Language ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Plpgsql:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Sql:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Language  = Plpgsql 
-               | Sql 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Language :: Language  ->
-                T_Language 
-sem_Language (Plpgsql )  =
-    (sem_Language_Plpgsql )
-sem_Language (Sql )  =
-    (sem_Language_Sql )
--- semantic domain
-type T_Language  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( Language,Language)
-data Inh_Language  = Inh_Language {cat_Inh_Language :: Catalog,lib_Inh_Language :: LocalIdentifierBindings}
-data Syn_Language  = Syn_Language {annotatedTree_Syn_Language :: Language,originalTree_Syn_Language :: Language}
-wrap_Language :: T_Language  ->
-                 Inh_Language  ->
-                 Syn_Language 
-wrap_Language sem (Inh_Language _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Language _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Language_Plpgsql :: T_Language 
-sem_Language_Plpgsql  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Language
-              _lhsOoriginalTree :: Language
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Plpgsql
-                  {-# LINE 6079 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Plpgsql
-                  {-# LINE 6084 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6089 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6094 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Language_Sql :: T_Language 
-sem_Language_Sql  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Language
-              _lhsOoriginalTree :: Language
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Sql
-                  {-# LINE 6106 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Sql
-                  {-# LINE 6111 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6116 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6121 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- LiftFlavour -------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative LiftAll:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative LiftAny:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data LiftFlavour  = LiftAll 
-                  | LiftAny 
-                  deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_LiftFlavour :: LiftFlavour  ->
-                   T_LiftFlavour 
-sem_LiftFlavour (LiftAll )  =
-    (sem_LiftFlavour_LiftAll )
-sem_LiftFlavour (LiftAny )  =
-    (sem_LiftFlavour_LiftAny )
--- semantic domain
-type T_LiftFlavour  = Catalog ->
-                      LocalIdentifierBindings ->
-                      ( LiftFlavour,LiftFlavour)
-data Inh_LiftFlavour  = Inh_LiftFlavour {cat_Inh_LiftFlavour :: Catalog,lib_Inh_LiftFlavour :: LocalIdentifierBindings}
-data Syn_LiftFlavour  = Syn_LiftFlavour {annotatedTree_Syn_LiftFlavour :: LiftFlavour,originalTree_Syn_LiftFlavour :: LiftFlavour}
-wrap_LiftFlavour :: T_LiftFlavour  ->
-                    Inh_LiftFlavour  ->
-                    Syn_LiftFlavour 
-wrap_LiftFlavour sem (Inh_LiftFlavour _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_LiftFlavour _lhsOannotatedTree _lhsOoriginalTree ))
-sem_LiftFlavour_LiftAll :: T_LiftFlavour 
-sem_LiftFlavour_LiftAll  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: LiftFlavour
-              _lhsOoriginalTree :: LiftFlavour
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftAll
-                  {-# LINE 6175 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftAll
-                  {-# LINE 6180 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6185 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6190 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_LiftFlavour_LiftAny :: T_LiftFlavour 
-sem_LiftFlavour_LiftAny  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: LiftFlavour
-              _lhsOoriginalTree :: LiftFlavour
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftAny
-                  {-# LINE 6202 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  LiftAny
-                  {-# LINE 6207 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6212 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6217 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- MaybeBoolExpression -----------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Just:
-         child just           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nothing:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type MaybeBoolExpression  = (Maybe (Expression))
--- cata
-sem_MaybeBoolExpression :: MaybeBoolExpression  ->
-                           T_MaybeBoolExpression 
-sem_MaybeBoolExpression (Prelude.Just x )  =
-    (sem_MaybeBoolExpression_Just (sem_Expression x ) )
-sem_MaybeBoolExpression Prelude.Nothing  =
-    sem_MaybeBoolExpression_Nothing
--- semantic domain
-type T_MaybeBoolExpression  = Catalog ->
-                              LocalIdentifierBindings ->
-                              ( MaybeBoolExpression,MaybeBoolExpression)
-data Inh_MaybeBoolExpression  = Inh_MaybeBoolExpression {cat_Inh_MaybeBoolExpression :: Catalog,lib_Inh_MaybeBoolExpression :: LocalIdentifierBindings}
-data Syn_MaybeBoolExpression  = Syn_MaybeBoolExpression {annotatedTree_Syn_MaybeBoolExpression :: MaybeBoolExpression,originalTree_Syn_MaybeBoolExpression :: MaybeBoolExpression}
-wrap_MaybeBoolExpression :: T_MaybeBoolExpression  ->
-                            Inh_MaybeBoolExpression  ->
-                            Syn_MaybeBoolExpression 
-wrap_MaybeBoolExpression sem (Inh_MaybeBoolExpression _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_MaybeBoolExpression _lhsOannotatedTree _lhsOoriginalTree ))
-sem_MaybeBoolExpression_Just :: T_Expression  ->
-                                T_MaybeBoolExpression 
-sem_MaybeBoolExpression_Just just_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: MaybeBoolExpression
-              _lhsOoriginalTree :: MaybeBoolExpression
-              _justOcat :: Catalog
-              _justOlib :: LocalIdentifierBindings
-              _justIannotatedTree :: Expression
-              _justIliftedColumnName :: String
-              _justIoriginalTree :: Expression
-              -- "./TypeChecking/Misc.ag"(line 74, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 74 "./TypeChecking/Misc.ag" #-}
-                  if getTypeAnnotation _justIannotatedTree `notElem` [typeBool, TypeCheckFailed]
-                    then Just $ updateAnnotation ((TypeErrorA ExpressionMustBeBool) :)
-                                  _justIannotatedTree
-                    else Just $ _justIannotatedTree
-                  {-# LINE 6279 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIannotatedTree
-                  {-# LINE 6284 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIoriginalTree
-                  {-# LINE 6289 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6294 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6299 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6304 "AstInternal.hs" #-}
-              ( _justIannotatedTree,_justIliftedColumnName,_justIoriginalTree) =
-                  (just_ _justOcat _justOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_MaybeBoolExpression_Nothing :: T_MaybeBoolExpression 
-sem_MaybeBoolExpression_Nothing  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: MaybeBoolExpression
-              _lhsOoriginalTree :: MaybeBoolExpression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6318 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6323 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6328 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6333 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- MaybeExpression ---------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Just:
-         child just           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nothing:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type MaybeExpression  = (Maybe (Expression))
--- cata
-sem_MaybeExpression :: MaybeExpression  ->
-                       T_MaybeExpression 
-sem_MaybeExpression (Prelude.Just x )  =
-    (sem_MaybeExpression_Just (sem_Expression x ) )
-sem_MaybeExpression Prelude.Nothing  =
-    sem_MaybeExpression_Nothing
--- semantic domain
-type T_MaybeExpression  = Catalog ->
-                          LocalIdentifierBindings ->
-                          ( MaybeExpression,MaybeExpression)
-data Inh_MaybeExpression  = Inh_MaybeExpression {cat_Inh_MaybeExpression :: Catalog,lib_Inh_MaybeExpression :: LocalIdentifierBindings}
-data Syn_MaybeExpression  = Syn_MaybeExpression {annotatedTree_Syn_MaybeExpression :: MaybeExpression,originalTree_Syn_MaybeExpression :: MaybeExpression}
-wrap_MaybeExpression :: T_MaybeExpression  ->
-                        Inh_MaybeExpression  ->
-                        Syn_MaybeExpression 
-wrap_MaybeExpression sem (Inh_MaybeExpression _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_MaybeExpression _lhsOannotatedTree _lhsOoriginalTree ))
-sem_MaybeExpression_Just :: T_Expression  ->
-                            T_MaybeExpression 
-sem_MaybeExpression_Just just_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: MaybeExpression
-              _lhsOoriginalTree :: MaybeExpression
-              _justOcat :: Catalog
-              _justOlib :: LocalIdentifierBindings
-              _justIannotatedTree :: Expression
-              _justIliftedColumnName :: String
-              _justIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIannotatedTree
-                  {-# LINE 6392 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIoriginalTree
-                  {-# LINE 6397 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6402 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6407 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6412 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6417 "AstInternal.hs" #-}
-              ( _justIannotatedTree,_justIliftedColumnName,_justIoriginalTree) =
-                  (just_ _justOcat _justOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_MaybeExpression_Nothing :: T_MaybeExpression 
-sem_MaybeExpression_Nothing  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: MaybeExpression
-              _lhsOoriginalTree :: MaybeExpression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6431 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6436 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6441 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6446 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- MaybeSelectList ---------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         listType             : Maybe [(String,Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative Just:
-         child just           : SelectList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nothing:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type MaybeSelectList  = (Maybe (SelectList))
--- cata
-sem_MaybeSelectList :: MaybeSelectList  ->
-                       T_MaybeSelectList 
-sem_MaybeSelectList (Prelude.Just x )  =
-    (sem_MaybeSelectList_Just (sem_SelectList x ) )
-sem_MaybeSelectList Prelude.Nothing  =
-    sem_MaybeSelectList_Nothing
--- semantic domain
-type T_MaybeSelectList  = Catalog ->
-                          LocalIdentifierBindings ->
-                          ( MaybeSelectList,(Maybe [(String,Type)]),MaybeSelectList)
-data Inh_MaybeSelectList  = Inh_MaybeSelectList {cat_Inh_MaybeSelectList :: Catalog,lib_Inh_MaybeSelectList :: LocalIdentifierBindings}
-data Syn_MaybeSelectList  = Syn_MaybeSelectList {annotatedTree_Syn_MaybeSelectList :: MaybeSelectList,listType_Syn_MaybeSelectList :: Maybe [(String,Type)],originalTree_Syn_MaybeSelectList :: MaybeSelectList}
-wrap_MaybeSelectList :: T_MaybeSelectList  ->
-                        Inh_MaybeSelectList  ->
-                        Syn_MaybeSelectList 
-wrap_MaybeSelectList sem (Inh_MaybeSelectList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_MaybeSelectList _lhsOannotatedTree _lhsOlistType _lhsOoriginalTree ))
-sem_MaybeSelectList_Just :: T_SelectList  ->
-                            T_MaybeSelectList 
-sem_MaybeSelectList_Just just_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: (Maybe [(String,Type)])
-              _lhsOannotatedTree :: MaybeSelectList
-              _lhsOoriginalTree :: MaybeSelectList
-              _justOcat :: Catalog
-              _justOlib :: LocalIdentifierBindings
-              _justIannotatedTree :: SelectList
-              _justIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _justIlistType :: ([(String,Type)])
-              _justIoriginalTree :: SelectList
-              -- "./TypeChecking/SelectLists.ag"(line 25, column 12)
-              _lhsOlistType =
-                  {-# LINE 25 "./TypeChecking/SelectLists.ag" #-}
-                  Just _justIlistType
-                  {-# LINE 6508 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIannotatedTree
-                  {-# LINE 6513 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIoriginalTree
-                  {-# LINE 6518 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6523 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6528 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6533 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6538 "AstInternal.hs" #-}
-              ( _justIannotatedTree,_justIlibUpdates,_justIlistType,_justIoriginalTree) =
-                  (just_ _justOcat _justOlib )
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
-sem_MaybeSelectList_Nothing :: T_MaybeSelectList 
-sem_MaybeSelectList_Nothing  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: (Maybe [(String,Type)])
-              _lhsOannotatedTree :: MaybeSelectList
-              _lhsOoriginalTree :: MaybeSelectList
-              -- "./TypeChecking/SelectLists.ag"(line 26, column 15)
-              _lhsOlistType =
-                  {-# LINE 26 "./TypeChecking/SelectLists.ag" #-}
-                  Nothing
-                  {-# LINE 6553 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6558 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6563 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6568 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6573 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
--- Natural -----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Natural:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Unnatural:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Natural  = Natural 
-              | Unnatural 
-              deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Natural :: Natural  ->
-               T_Natural 
-sem_Natural (Natural )  =
-    (sem_Natural_Natural )
-sem_Natural (Unnatural )  =
-    (sem_Natural_Unnatural )
--- semantic domain
-type T_Natural  = Catalog ->
-                  LocalIdentifierBindings ->
-                  ( Natural,Natural)
-data Inh_Natural  = Inh_Natural {cat_Inh_Natural :: Catalog,lib_Inh_Natural :: LocalIdentifierBindings}
-data Syn_Natural  = Syn_Natural {annotatedTree_Syn_Natural :: Natural,originalTree_Syn_Natural :: Natural}
-wrap_Natural :: T_Natural  ->
-                Inh_Natural  ->
-                Syn_Natural 
-wrap_Natural sem (Inh_Natural _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Natural _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Natural_Natural :: T_Natural 
-sem_Natural_Natural  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Natural
-              _lhsOoriginalTree :: Natural
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Natural
-                  {-# LINE 6627 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Natural
-                  {-# LINE 6632 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6637 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6642 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Natural_Unnatural :: T_Natural 
-sem_Natural_Unnatural  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Natural
-              _lhsOoriginalTree :: Natural
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Unnatural
-                  {-# LINE 6654 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Unnatural
-                  {-# LINE 6659 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6664 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6669 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- OnExpr ------------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Just:
-         child just           : JoinExpression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nothing:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type OnExpr  = (Maybe (JoinExpression))
--- cata
-sem_OnExpr :: OnExpr  ->
-              T_OnExpr 
-sem_OnExpr (Prelude.Just x )  =
-    (sem_OnExpr_Just (sem_JoinExpression x ) )
-sem_OnExpr Prelude.Nothing  =
-    sem_OnExpr_Nothing
--- semantic domain
-type T_OnExpr  = Catalog ->
-                 LocalIdentifierBindings ->
-                 ( OnExpr,OnExpr)
-data Inh_OnExpr  = Inh_OnExpr {cat_Inh_OnExpr :: Catalog,lib_Inh_OnExpr :: LocalIdentifierBindings}
-data Syn_OnExpr  = Syn_OnExpr {annotatedTree_Syn_OnExpr :: OnExpr,originalTree_Syn_OnExpr :: OnExpr}
-wrap_OnExpr :: T_OnExpr  ->
-               Inh_OnExpr  ->
-               Syn_OnExpr 
-wrap_OnExpr sem (Inh_OnExpr _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_OnExpr _lhsOannotatedTree _lhsOoriginalTree ))
-sem_OnExpr_Just :: T_JoinExpression  ->
-                   T_OnExpr 
-sem_OnExpr_Just just_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: OnExpr
-              _lhsOoriginalTree :: OnExpr
-              _justOcat :: Catalog
-              _justOlib :: LocalIdentifierBindings
-              _justIannotatedTree :: JoinExpression
-              _justIoriginalTree :: JoinExpression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIannotatedTree
-                  {-# LINE 6727 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Just _justIoriginalTree
-                  {-# LINE 6732 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6737 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6742 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6747 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _justOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6752 "AstInternal.hs" #-}
-              ( _justIannotatedTree,_justIoriginalTree) =
-                  (just_ _justOcat _justOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_OnExpr_Nothing :: T_OnExpr 
-sem_OnExpr_Nothing  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: OnExpr
-              _lhsOoriginalTree :: OnExpr
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6766 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Nothing
-                  {-# LINE 6771 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6776 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6781 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- ParamDef ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         namedType            : Type
-         originalTree         : SELF 
-         paramName            : String
-   alternatives:
-      alternative ParamDef:
-         child ann            : {Annotation}
-         child name           : {String}
-         child typ            : TypeName 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ParamDefTp:
-         child ann            : {Annotation}
-         child typ            : TypeName 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data ParamDef  = ParamDef (Annotation) (String) (TypeName) 
-               | ParamDefTp (Annotation) (TypeName) 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_ParamDef :: ParamDef  ->
-                T_ParamDef 
-sem_ParamDef (ParamDef _ann _name _typ )  =
-    (sem_ParamDef_ParamDef _ann _name (sem_TypeName _typ ) )
-sem_ParamDef (ParamDefTp _ann _typ )  =
-    (sem_ParamDef_ParamDefTp _ann (sem_TypeName _typ ) )
--- semantic domain
-type T_ParamDef  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( ParamDef,Type,ParamDef,String)
-data Inh_ParamDef  = Inh_ParamDef {cat_Inh_ParamDef :: Catalog,lib_Inh_ParamDef :: LocalIdentifierBindings}
-data Syn_ParamDef  = Syn_ParamDef {annotatedTree_Syn_ParamDef :: ParamDef,namedType_Syn_ParamDef :: Type,originalTree_Syn_ParamDef :: ParamDef,paramName_Syn_ParamDef :: String}
-wrap_ParamDef :: T_ParamDef  ->
-                 Inh_ParamDef  ->
-                 Syn_ParamDef 
-wrap_ParamDef sem (Inh_ParamDef _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ParamDef _lhsOannotatedTree _lhsOnamedType _lhsOoriginalTree _lhsOparamName ))
-sem_ParamDef_ParamDef :: Annotation ->
-                         String ->
-                         T_TypeName  ->
-                         T_ParamDef 
-sem_ParamDef_ParamDef ann_ name_ typ_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOparamName :: String
-              _lhsOannotatedTree :: ParamDef
-              _lhsOoriginalTree :: ParamDef
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/CreateFunction.ag"(line 56, column 9)
-              _lhsOnamedType =
-                  {-# LINE 56 "./TypeChecking/CreateFunction.ag" #-}
-                  _typInamedType
-                  {-# LINE 6852 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 58, column 9)
-              _lhsOparamName =
-                  {-# LINE 58 "./TypeChecking/CreateFunction.ag" #-}
-                  name_
-                  {-# LINE 6857 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ParamDef ann_ name_ _typIannotatedTree
-                  {-# LINE 6862 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ParamDef ann_ name_ _typIoriginalTree
-                  {-# LINE 6867 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6872 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6877 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6882 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6887 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName)))
-sem_ParamDef_ParamDefTp :: Annotation ->
-                           T_TypeName  ->
-                           T_ParamDef 
-sem_ParamDef_ParamDefTp ann_ typ_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOparamName :: String
-              _lhsOannotatedTree :: ParamDef
-              _lhsOoriginalTree :: ParamDef
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/CreateFunction.ag"(line 56, column 9)
-              _lhsOnamedType =
-                  {-# LINE 56 "./TypeChecking/CreateFunction.ag" #-}
-                  _typInamedType
-                  {-# LINE 6910 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 60, column 9)
-              _lhsOparamName =
-                  {-# LINE 60 "./TypeChecking/CreateFunction.ag" #-}
-                  ""
-                  {-# LINE 6915 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ParamDefTp ann_ _typIannotatedTree
-                  {-# LINE 6920 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ParamDefTp ann_ _typIoriginalTree
-                  {-# LINE 6925 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 6930 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 6935 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 6940 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 6945 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName)))
--- ParamDefList ------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         params               : [(String, Type)]
-   alternatives:
-      alternative Cons:
-         child hd             : ParamDef 
-         child tl             : ParamDefList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type ParamDefList  = [(ParamDef)]
--- cata
-sem_ParamDefList :: ParamDefList  ->
-                    T_ParamDefList 
-sem_ParamDefList list  =
-    (Prelude.foldr sem_ParamDefList_Cons sem_ParamDefList_Nil (Prelude.map sem_ParamDef list) )
--- semantic domain
-type T_ParamDefList  = Catalog ->
-                       LocalIdentifierBindings ->
-                       ( ParamDefList,ParamDefList,([(String, Type)]))
-data Inh_ParamDefList  = Inh_ParamDefList {cat_Inh_ParamDefList :: Catalog,lib_Inh_ParamDefList :: LocalIdentifierBindings}
-data Syn_ParamDefList  = Syn_ParamDefList {annotatedTree_Syn_ParamDefList :: ParamDefList,originalTree_Syn_ParamDefList :: ParamDefList,params_Syn_ParamDefList :: [(String, Type)]}
-wrap_ParamDefList :: T_ParamDefList  ->
-                     Inh_ParamDefList  ->
-                     Syn_ParamDefList 
-wrap_ParamDefList sem (Inh_ParamDefList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOparams) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_ParamDefList _lhsOannotatedTree _lhsOoriginalTree _lhsOparams ))
-sem_ParamDefList_Cons :: T_ParamDef  ->
-                         T_ParamDefList  ->
-                         T_ParamDefList 
-sem_ParamDefList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOparams :: ([(String, Type)])
-              _lhsOannotatedTree :: ParamDefList
-              _lhsOoriginalTree :: ParamDefList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: ParamDef
-              _hdInamedType :: Type
-              _hdIoriginalTree :: ParamDef
-              _hdIparamName :: String
-              _tlIannotatedTree :: ParamDefList
-              _tlIoriginalTree :: ParamDefList
-              _tlIparams :: ([(String, Type)])
-              -- "./TypeChecking/CreateFunction.ag"(line 64, column 13)
-              _lhsOparams =
-                  {-# LINE 64 "./TypeChecking/CreateFunction.ag" #-}
-                  ((_hdIparamName, _hdInamedType) : _tlIparams)
-                  {-# LINE 7014 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 7019 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 7024 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7029 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7034 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7039 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7044 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7049 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7054 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdInamedType,_hdIoriginalTree,_hdIparamName) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlIparams) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOparams)))
-sem_ParamDefList_Nil :: T_ParamDefList 
-sem_ParamDefList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOparams :: ([(String, Type)])
-              _lhsOannotatedTree :: ParamDefList
-              _lhsOoriginalTree :: ParamDefList
-              -- "./TypeChecking/CreateFunction.ag"(line 63, column 12)
-              _lhsOparams =
-                  {-# LINE 63 "./TypeChecking/CreateFunction.ag" #-}
-                  []
-                  {-# LINE 7071 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 7076 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 7081 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7086 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7091 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOparams)))
--- RaiseType ---------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative RError:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RException:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RNotice:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data RaiseType  = RError 
-                | RException 
-                | RNotice 
-                deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_RaiseType :: RaiseType  ->
-                 T_RaiseType 
-sem_RaiseType (RError )  =
-    (sem_RaiseType_RError )
-sem_RaiseType (RException )  =
-    (sem_RaiseType_RException )
-sem_RaiseType (RNotice )  =
-    (sem_RaiseType_RNotice )
--- semantic domain
-type T_RaiseType  = Catalog ->
-                    LocalIdentifierBindings ->
-                    ( RaiseType,RaiseType)
-data Inh_RaiseType  = Inh_RaiseType {cat_Inh_RaiseType :: Catalog,lib_Inh_RaiseType :: LocalIdentifierBindings}
-data Syn_RaiseType  = Syn_RaiseType {annotatedTree_Syn_RaiseType :: RaiseType,originalTree_Syn_RaiseType :: RaiseType}
-wrap_RaiseType :: T_RaiseType  ->
-                  Inh_RaiseType  ->
-                  Syn_RaiseType 
-wrap_RaiseType sem (Inh_RaiseType _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_RaiseType _lhsOannotatedTree _lhsOoriginalTree ))
-sem_RaiseType_RError :: T_RaiseType 
-sem_RaiseType_RError  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RaiseType
-              _lhsOoriginalTree :: RaiseType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RError
-                  {-# LINE 7152 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RError
-                  {-# LINE 7157 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7162 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7167 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RaiseType_RException :: T_RaiseType 
-sem_RaiseType_RException  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RaiseType
-              _lhsOoriginalTree :: RaiseType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RException
-                  {-# LINE 7179 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RException
-                  {-# LINE 7184 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7189 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7194 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RaiseType_RNotice :: T_RaiseType 
-sem_RaiseType_RNotice  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RaiseType
-              _lhsOoriginalTree :: RaiseType
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RNotice
-                  {-# LINE 7206 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RNotice
-                  {-# LINE 7211 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7216 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7221 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- RestartIdentity ---------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative ContinueIdentity:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RestartIdentity:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data RestartIdentity  = ContinueIdentity 
-                      | RestartIdentity 
-                      deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_RestartIdentity :: RestartIdentity  ->
-                       T_RestartIdentity 
-sem_RestartIdentity (ContinueIdentity )  =
-    (sem_RestartIdentity_ContinueIdentity )
-sem_RestartIdentity (RestartIdentity )  =
-    (sem_RestartIdentity_RestartIdentity )
--- semantic domain
-type T_RestartIdentity  = Catalog ->
-                          LocalIdentifierBindings ->
-                          ( RestartIdentity,RestartIdentity)
-data Inh_RestartIdentity  = Inh_RestartIdentity {cat_Inh_RestartIdentity :: Catalog,lib_Inh_RestartIdentity :: LocalIdentifierBindings}
-data Syn_RestartIdentity  = Syn_RestartIdentity {annotatedTree_Syn_RestartIdentity :: RestartIdentity,originalTree_Syn_RestartIdentity :: RestartIdentity}
-wrap_RestartIdentity :: T_RestartIdentity  ->
-                        Inh_RestartIdentity  ->
-                        Syn_RestartIdentity 
-wrap_RestartIdentity sem (Inh_RestartIdentity _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_RestartIdentity _lhsOannotatedTree _lhsOoriginalTree ))
-sem_RestartIdentity_ContinueIdentity :: T_RestartIdentity 
-sem_RestartIdentity_ContinueIdentity  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RestartIdentity
-              _lhsOoriginalTree :: RestartIdentity
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ContinueIdentity
-                  {-# LINE 7275 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ContinueIdentity
-                  {-# LINE 7280 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7285 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7290 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RestartIdentity_RestartIdentity :: T_RestartIdentity 
-sem_RestartIdentity_RestartIdentity  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RestartIdentity
-              _lhsOoriginalTree :: RestartIdentity
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RestartIdentity
-                  {-# LINE 7302 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RestartIdentity
-                  {-# LINE 7307 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7312 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7317 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Root --------------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         producedCat          : Catalog
-         producedLib          : LocalIdentifierBindings
-   alternatives:
-      alternative Root:
-         child statements     : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Root  = Root (StatementList) 
-           deriving ( Show)
--- cata
-sem_Root :: Root  ->
-            T_Root 
-sem_Root (Root _statements )  =
-    (sem_Root_Root (sem_StatementList _statements ) )
--- semantic domain
-type T_Root  = Catalog ->
-               LocalIdentifierBindings ->
-               ( Root,Root,Catalog,LocalIdentifierBindings)
-data Inh_Root  = Inh_Root {cat_Inh_Root :: Catalog,lib_Inh_Root :: LocalIdentifierBindings}
-data Syn_Root  = Syn_Root {annotatedTree_Syn_Root :: Root,originalTree_Syn_Root :: Root,producedCat_Syn_Root :: Catalog,producedLib_Syn_Root :: LocalIdentifierBindings}
-wrap_Root :: T_Root  ->
-             Inh_Root  ->
-             Syn_Root 
-wrap_Root sem (Inh_Root _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Root _lhsOannotatedTree _lhsOoriginalTree _lhsOproducedCat _lhsOproducedLib ))
-sem_Root_Root :: T_StatementList  ->
-                 T_Root 
-sem_Root_Root statements_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _statementsOcatUpdates :: ([CatalogUpdate])
-              _statementsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Root
-              _lhsOoriginalTree :: Root
-              _lhsOproducedCat :: Catalog
-              _lhsOproducedLib :: LocalIdentifierBindings
-              _statementsOcat :: Catalog
-              _statementsOlib :: LocalIdentifierBindings
-              _statementsIannotatedTree :: StatementList
-              _statementsIoriginalTree :: StatementList
-              _statementsIproducedCat :: Catalog
-              _statementsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 80, column 12)
-              _statementsOcatUpdates =
-                  {-# LINE 80 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 7378 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 81, column 12)
-              _statementsOlibUpdates =
-                  {-# LINE 81 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 7383 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Root _statementsIannotatedTree
-                  {-# LINE 7388 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Root _statementsIoriginalTree
-                  {-# LINE 7393 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7398 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7403 "AstInternal.hs" #-}
-              -- copy rule (up)
-              _lhsOproducedCat =
-                  {-# LINE 27 "./TypeChecking/Statements.ag" #-}
-                  _statementsIproducedCat
-                  {-# LINE 7408 "AstInternal.hs" #-}
-              -- copy rule (up)
-              _lhsOproducedLib =
-                  {-# LINE 28 "./TypeChecking/Statements.ag" #-}
-                  _statementsIproducedLib
-                  {-# LINE 7413 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _statementsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7418 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _statementsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7423 "AstInternal.hs" #-}
-              ( _statementsIannotatedTree,_statementsIoriginalTree,_statementsIproducedCat,_statementsIproducedLib) =
-                  (statements_ _statementsOcat _statementsOcatUpdates _statementsOlib _statementsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
--- RowConstraint -----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative NotNullConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative NullConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RowCheckConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child expression     : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RowPrimaryKeyConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RowReferenceConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         child table          : {String}
-         child att            : {Maybe String}
-         child onUpdate       : Cascade 
-         child onDelete       : Cascade 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative RowUniqueConstraint:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data RowConstraint  = NotNullConstraint (Annotation) (String) 
-                    | NullConstraint (Annotation) (String) 
-                    | RowCheckConstraint (Annotation) (String) (Expression) 
-                    | RowPrimaryKeyConstraint (Annotation) (String) 
-                    | RowReferenceConstraint (Annotation) (String) (String) (Maybe String) (Cascade) (Cascade) 
-                    | RowUniqueConstraint (Annotation) (String) 
-                    deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_RowConstraint :: RowConstraint  ->
-                     T_RowConstraint 
-sem_RowConstraint (NotNullConstraint _ann _name )  =
-    (sem_RowConstraint_NotNullConstraint _ann _name )
-sem_RowConstraint (NullConstraint _ann _name )  =
-    (sem_RowConstraint_NullConstraint _ann _name )
-sem_RowConstraint (RowCheckConstraint _ann _name _expression )  =
-    (sem_RowConstraint_RowCheckConstraint _ann _name (sem_Expression _expression ) )
-sem_RowConstraint (RowPrimaryKeyConstraint _ann _name )  =
-    (sem_RowConstraint_RowPrimaryKeyConstraint _ann _name )
-sem_RowConstraint (RowReferenceConstraint _ann _name _table _att _onUpdate _onDelete )  =
-    (sem_RowConstraint_RowReferenceConstraint _ann _name _table _att (sem_Cascade _onUpdate ) (sem_Cascade _onDelete ) )
-sem_RowConstraint (RowUniqueConstraint _ann _name )  =
-    (sem_RowConstraint_RowUniqueConstraint _ann _name )
--- semantic domain
-type T_RowConstraint  = Catalog ->
-                        LocalIdentifierBindings ->
-                        ( RowConstraint,RowConstraint)
-data Inh_RowConstraint  = Inh_RowConstraint {cat_Inh_RowConstraint :: Catalog,lib_Inh_RowConstraint :: LocalIdentifierBindings}
-data Syn_RowConstraint  = Syn_RowConstraint {annotatedTree_Syn_RowConstraint :: RowConstraint,originalTree_Syn_RowConstraint :: RowConstraint}
-wrap_RowConstraint :: T_RowConstraint  ->
-                      Inh_RowConstraint  ->
-                      Syn_RowConstraint 
-wrap_RowConstraint sem (Inh_RowConstraint _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_RowConstraint _lhsOannotatedTree _lhsOoriginalTree ))
-sem_RowConstraint_NotNullConstraint :: Annotation ->
-                                       String ->
-                                       T_RowConstraint 
-sem_RowConstraint_NotNullConstraint ann_ name_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  NotNullConstraint ann_ name_
-                  {-# LINE 7526 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  NotNullConstraint ann_ name_
-                  {-# LINE 7531 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7536 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7541 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraint_NullConstraint :: Annotation ->
-                                    String ->
-                                    T_RowConstraint 
-sem_RowConstraint_NullConstraint ann_ name_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  NullConstraint ann_ name_
-                  {-# LINE 7555 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  NullConstraint ann_ name_
-                  {-# LINE 7560 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7565 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7570 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraint_RowCheckConstraint :: Annotation ->
-                                        String ->
-                                        T_Expression  ->
-                                        T_RowConstraint 
-sem_RowConstraint_RowCheckConstraint ann_ name_ expression_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              _expressionOcat :: Catalog
-              _expressionOlib :: LocalIdentifierBindings
-              _expressionIannotatedTree :: Expression
-              _expressionIliftedColumnName :: String
-              _expressionIoriginalTree :: Expression
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RowCheckConstraint ann_ name_ _expressionIannotatedTree
-                  {-# LINE 7590 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RowCheckConstraint ann_ name_ _expressionIoriginalTree
-                  {-# LINE 7595 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7600 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7605 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7610 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _expressionOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7615 "AstInternal.hs" #-}
-              ( _expressionIannotatedTree,_expressionIliftedColumnName,_expressionIoriginalTree) =
-                  (expression_ _expressionOcat _expressionOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraint_RowPrimaryKeyConstraint :: Annotation ->
-                                             String ->
-                                             T_RowConstraint 
-sem_RowConstraint_RowPrimaryKeyConstraint ann_ name_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RowPrimaryKeyConstraint ann_ name_
-                  {-# LINE 7631 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RowPrimaryKeyConstraint ann_ name_
-                  {-# LINE 7636 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7641 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7646 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraint_RowReferenceConstraint :: Annotation ->
-                                            String ->
-                                            String ->
-                                            (Maybe String) ->
-                                            T_Cascade  ->
-                                            T_Cascade  ->
-                                            T_RowConstraint 
-sem_RowConstraint_RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              _onUpdateOcat :: Catalog
-              _onUpdateOlib :: LocalIdentifierBindings
-              _onDeleteOcat :: Catalog
-              _onDeleteOlib :: LocalIdentifierBindings
-              _onUpdateIannotatedTree :: Cascade
-              _onUpdateIoriginalTree :: Cascade
-              _onDeleteIannotatedTree :: Cascade
-              _onDeleteIoriginalTree :: Cascade
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RowReferenceConstraint ann_ name_ table_ att_ _onUpdateIannotatedTree _onDeleteIannotatedTree
-                  {-# LINE 7672 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RowReferenceConstraint ann_ name_ table_ att_ _onUpdateIoriginalTree _onDeleteIoriginalTree
-                  {-# LINE 7677 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7682 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7687 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onUpdateOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7692 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onUpdateOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7697 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onDeleteOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7702 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onDeleteOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7707 "AstInternal.hs" #-}
-              ( _onUpdateIannotatedTree,_onUpdateIoriginalTree) =
-                  (onUpdate_ _onUpdateOcat _onUpdateOlib )
-              ( _onDeleteIannotatedTree,_onDeleteIoriginalTree) =
-                  (onDelete_ _onDeleteOcat _onDeleteOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraint_RowUniqueConstraint :: Annotation ->
-                                         String ->
-                                         T_RowConstraint 
-sem_RowConstraint_RowUniqueConstraint ann_ name_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraint
-              _lhsOoriginalTree :: RowConstraint
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RowUniqueConstraint ann_ name_
-                  {-# LINE 7725 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RowUniqueConstraint ann_ name_
-                  {-# LINE 7730 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7735 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7740 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- RowConstraintList -------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : RowConstraint 
-         child tl             : RowConstraintList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type RowConstraintList  = [(RowConstraint)]
--- cata
-sem_RowConstraintList :: RowConstraintList  ->
-                         T_RowConstraintList 
-sem_RowConstraintList list  =
-    (Prelude.foldr sem_RowConstraintList_Cons sem_RowConstraintList_Nil (Prelude.map sem_RowConstraint list) )
--- semantic domain
-type T_RowConstraintList  = Catalog ->
-                            LocalIdentifierBindings ->
-                            ( RowConstraintList,RowConstraintList)
-data Inh_RowConstraintList  = Inh_RowConstraintList {cat_Inh_RowConstraintList :: Catalog,lib_Inh_RowConstraintList :: LocalIdentifierBindings}
-data Syn_RowConstraintList  = Syn_RowConstraintList {annotatedTree_Syn_RowConstraintList :: RowConstraintList,originalTree_Syn_RowConstraintList :: RowConstraintList}
-wrap_RowConstraintList :: T_RowConstraintList  ->
-                          Inh_RowConstraintList  ->
-                          Syn_RowConstraintList 
-wrap_RowConstraintList sem (Inh_RowConstraintList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_RowConstraintList _lhsOannotatedTree _lhsOoriginalTree ))
-sem_RowConstraintList_Cons :: T_RowConstraint  ->
-                              T_RowConstraintList  ->
-                              T_RowConstraintList 
-sem_RowConstraintList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraintList
-              _lhsOoriginalTree :: RowConstraintList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: RowConstraint
-              _hdIoriginalTree :: RowConstraint
-              _tlIannotatedTree :: RowConstraintList
-              _tlIoriginalTree :: RowConstraintList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 7802 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 7807 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7812 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7817 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7822 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7827 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 7832 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 7837 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_RowConstraintList_Nil :: T_RowConstraintList 
-sem_RowConstraintList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: RowConstraintList
-              _lhsOoriginalTree :: RowConstraintList
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 7853 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 7858 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 7863 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 7868 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- SelectExpression --------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-         originalTree         : SELF 
-   alternatives:
-      alternative CombineSelect:
-         child ann            : {Annotation}
-         child ctype          : CombineType 
-         child sel1           : SelectExpression 
-         child sel2           : SelectExpression 
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Select:
-         child ann            : {Annotation}
-         child selDistinct    : Distinct 
-         child selSelectList  : SelectList 
-         child selTref        : TableRefList 
-         child selWhere       : MaybeBoolExpression 
-         child selGroupBy     : ExpressionList 
-         child selHaving      : MaybeBoolExpression 
-         child selOrderBy     : ExpressionDirectionPairList 
-         child selLimit       : MaybeExpression 
-         child selOffset      : MaybeExpression 
-         visit 0:
-            local newLib      : _
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Values:
-         child ann            : {Annotation}
-         child vll            : ExpressionListList 
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
--}
-data SelectExpression  = CombineSelect (Annotation) (CombineType) (SelectExpression) (SelectExpression) 
-                       | Select (Annotation) (Distinct) (SelectList) (TableRefList) (MaybeBoolExpression) (ExpressionList) (MaybeBoolExpression) (ExpressionDirectionPairList) (MaybeExpression) (MaybeExpression) 
-                       | Values (Annotation) (ExpressionListList) 
-                       deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_SelectExpression :: SelectExpression  ->
-                        T_SelectExpression 
-sem_SelectExpression (CombineSelect _ann _ctype _sel1 _sel2 )  =
-    (sem_SelectExpression_CombineSelect _ann (sem_CombineType _ctype ) (sem_SelectExpression _sel1 ) (sem_SelectExpression _sel2 ) )
-sem_SelectExpression (Select _ann _selDistinct _selSelectList _selTref _selWhere _selGroupBy _selHaving _selOrderBy _selLimit _selOffset )  =
-    (sem_SelectExpression_Select _ann (sem_Distinct _selDistinct ) (sem_SelectList _selSelectList ) (sem_TableRefList _selTref ) (sem_MaybeBoolExpression _selWhere ) (sem_ExpressionList _selGroupBy ) (sem_MaybeBoolExpression _selHaving ) (sem_ExpressionDirectionPairList _selOrderBy ) (sem_MaybeExpression _selLimit ) (sem_MaybeExpression _selOffset ) )
-sem_SelectExpression (Values _ann _vll )  =
-    (sem_SelectExpression_Values _ann (sem_ExpressionListList _vll ) )
--- semantic domain
-type T_SelectExpression  = Catalog ->
-                           LocalIdentifierBindings ->
-                           ( SelectExpression,([LocalIdentifierBindingsUpdate]),SelectExpression)
-data Inh_SelectExpression  = Inh_SelectExpression {cat_Inh_SelectExpression :: Catalog,lib_Inh_SelectExpression :: LocalIdentifierBindings}
-data Syn_SelectExpression  = Syn_SelectExpression {annotatedTree_Syn_SelectExpression :: SelectExpression,libUpdates_Syn_SelectExpression :: [LocalIdentifierBindingsUpdate],originalTree_Syn_SelectExpression :: SelectExpression}
-wrap_SelectExpression :: T_SelectExpression  ->
-                         Inh_SelectExpression  ->
-                         Syn_SelectExpression 
-wrap_SelectExpression sem (Inh_SelectExpression _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SelectExpression _lhsOannotatedTree _lhsOlibUpdates _lhsOoriginalTree ))
-sem_SelectExpression_CombineSelect :: Annotation ->
-                                      T_CombineType  ->
-                                      T_SelectExpression  ->
-                                      T_SelectExpression  ->
-                                      T_SelectExpression 
-sem_SelectExpression_CombineSelect ann_ ctype_ sel1_ sel2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SelectExpression
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOoriginalTree :: SelectExpression
-              _ctypeOcat :: Catalog
-              _ctypeOlib :: LocalIdentifierBindings
-              _sel1Ocat :: Catalog
-              _sel1Olib :: LocalIdentifierBindings
-              _sel2Ocat :: Catalog
-              _sel2Olib :: LocalIdentifierBindings
-              _ctypeIannotatedTree :: CombineType
-              _ctypeIoriginalTree :: CombineType
-              _sel1IannotatedTree :: SelectExpression
-              _sel1IlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _sel1IoriginalTree :: SelectExpression
-              _sel2IannotatedTree :: SelectExpression
-              _sel2IlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _sel2IoriginalTree :: SelectExpression
-              -- "./TypeChecking/SelectStatement.ag"(line 23, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 23 "./TypeChecking/SelectStatement.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    Nothing
-                  {-# LINE 7975 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 129, column 9)
-              _tpe =
-                  {-# LINE 129 "./TypeChecking/SelectStatement.ag" #-}
-                  let sel1t = getTypeAnnotation _sel1IannotatedTree
-                      sel2t = getTypeAnnotation _sel2IannotatedTree
-                  in dependsOnRTpe [sel1t, sel2t] $
-                        typeCheckCombineSelect _lhsIcat sel1t sel2t
-                  {-# LINE 7983 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 134, column 9)
-              _backTree =
-                  {-# LINE 134 "./TypeChecking/SelectStatement.ag" #-}
-                  CombineSelect ann_ _ctypeIannotatedTree
-                                _sel1IannotatedTree
-                                _sel2IannotatedTree
-                  {-# LINE 7990 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 87, column 11)
-              _lhsOlibUpdates =
-                  {-# LINE 87 "./TypeChecking/SelectLists.ag" #-}
-                  []
-                  {-# LINE 7995 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CombineSelect ann_ _ctypeIannotatedTree _sel1IannotatedTree _sel2IannotatedTree
-                  {-# LINE 8000 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CombineSelect ann_ _ctypeIoriginalTree _sel1IoriginalTree _sel2IoriginalTree
-                  {-# LINE 8005 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8010 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ctypeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8015 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ctypeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8020 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sel1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8025 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sel1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8030 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sel2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8035 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sel2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8040 "AstInternal.hs" #-}
-              ( _ctypeIannotatedTree,_ctypeIoriginalTree) =
-                  (ctype_ _ctypeOcat _ctypeOlib )
-              ( _sel1IannotatedTree,_sel1IlibUpdates,_sel1IoriginalTree) =
-                  (sel1_ _sel1Ocat _sel1Olib )
-              ( _sel2IannotatedTree,_sel2IlibUpdates,_sel2IoriginalTree) =
-                  (sel2_ _sel2Ocat _sel2Olib )
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_SelectExpression_Select :: Annotation ->
-                               T_Distinct  ->
-                               T_SelectList  ->
-                               T_TableRefList  ->
-                               T_MaybeBoolExpression  ->
-                               T_ExpressionList  ->
-                               T_MaybeBoolExpression  ->
-                               T_ExpressionDirectionPairList  ->
-                               T_MaybeExpression  ->
-                               T_MaybeExpression  ->
-                               T_SelectExpression 
-sem_SelectExpression_Select ann_ selDistinct_ selSelectList_ selTref_ selWhere_ selGroupBy_ selHaving_ selOrderBy_ selLimit_ selOffset_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SelectExpression
-              _selSelectListOlib :: LocalIdentifierBindings
-              _selWhereOlib :: LocalIdentifierBindings
-              _selGroupByOlib :: LocalIdentifierBindings
-              _selOrderByOlib :: LocalIdentifierBindings
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOoriginalTree :: SelectExpression
-              _selDistinctOcat :: Catalog
-              _selDistinctOlib :: LocalIdentifierBindings
-              _selSelectListOcat :: Catalog
-              _selTrefOcat :: Catalog
-              _selTrefOlib :: LocalIdentifierBindings
-              _selWhereOcat :: Catalog
-              _selGroupByOcat :: Catalog
-              _selHavingOcat :: Catalog
-              _selHavingOlib :: LocalIdentifierBindings
-              _selOrderByOcat :: Catalog
-              _selLimitOcat :: Catalog
-              _selLimitOlib :: LocalIdentifierBindings
-              _selOffsetOcat :: Catalog
-              _selOffsetOlib :: LocalIdentifierBindings
-              _selDistinctIannotatedTree :: Distinct
-              _selDistinctIoriginalTree :: Distinct
-              _selSelectListIannotatedTree :: SelectList
-              _selSelectListIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selSelectListIlistType :: ([(String,Type)])
-              _selSelectListIoriginalTree :: SelectList
-              _selTrefIannotatedTree :: TableRefList
-              _selTrefIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selTrefIoriginalTree :: TableRefList
-              _selWhereIannotatedTree :: MaybeBoolExpression
-              _selWhereIoriginalTree :: MaybeBoolExpression
-              _selGroupByIannotatedTree :: ExpressionList
-              _selGroupByIoriginalTree :: ExpressionList
-              _selGroupByItypeList :: ([Type])
-              _selHavingIannotatedTree :: MaybeBoolExpression
-              _selHavingIoriginalTree :: MaybeBoolExpression
-              _selOrderByIannotatedTree :: ExpressionDirectionPairList
-              _selOrderByIoriginalTree :: ExpressionDirectionPairList
-              _selLimitIannotatedTree :: MaybeExpression
-              _selLimitIoriginalTree :: MaybeExpression
-              _selOffsetIannotatedTree :: MaybeExpression
-              _selOffsetIoriginalTree :: MaybeExpression
-              -- "./TypeChecking/SelectStatement.ag"(line 23, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 23 "./TypeChecking/SelectStatement.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    Nothing
-                  {-# LINE 8112 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 94, column 10)
-              _newLib =
-                  {-# LINE 94 "./TypeChecking/SelectStatement.ag" #-}
-                  case updateBindings _lhsIlib _lhsIcat _selTrefIlibUpdates of
-                    Left x -> error $ show x
-                    Right e -> e
-                  {-# LINE 8119 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 97, column 10)
-              _selSelectListOlib =
-                  {-# LINE 97 "./TypeChecking/SelectStatement.ag" #-}
-                  _newLib
-                  {-# LINE 8124 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 98, column 10)
-              _selWhereOlib =
-                  {-# LINE 98 "./TypeChecking/SelectStatement.ag" #-}
-                  _newLib
-                  {-# LINE 8129 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 99, column 10)
-              _selGroupByOlib =
-                  {-# LINE 99 "./TypeChecking/SelectStatement.ag" #-}
-                  _newLib
-                  {-# LINE 8134 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 100, column 10)
-              _selOrderByOlib =
-                  {-# LINE 100 "./TypeChecking/SelectStatement.ag" #-}
-                  _newLib
-                  {-# LINE 8139 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 111, column 9)
-              _tpe =
-                  {-# LINE 111 "./TypeChecking/SelectStatement.ag" #-}
-                  do
-                  Right $ case _selSelectListIlistType of
-                            [(_,Pseudo Void)] -> Pseudo Void
-                            _ -> SetOfType $ CompositeType _selSelectListIlistType
-                  {-# LINE 8147 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 118, column 9)
-              _backTree =
-                  {-# LINE 118 "./TypeChecking/SelectStatement.ag" #-}
-                  Select ann_
-                         _selDistinctIannotatedTree
-                         _selSelectListIannotatedTree
-                         _selTrefIannotatedTree
-                         _selWhereIannotatedTree
-                         _selGroupByIannotatedTree
-                         _selHavingIannotatedTree
-                         _selOrderByIannotatedTree
-                         _selLimitIannotatedTree
-                         _selOffsetIannotatedTree
-                  {-# LINE 8161 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 85, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 85 "./TypeChecking/SelectLists.ag" #-}
-                  _selSelectListIlibUpdates
-                  {-# LINE 8166 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Select ann_ _selDistinctIannotatedTree _selSelectListIannotatedTree _selTrefIannotatedTree _selWhereIannotatedTree _selGroupByIannotatedTree _selHavingIannotatedTree _selOrderByIannotatedTree _selLimitIannotatedTree _selOffsetIannotatedTree
-                  {-# LINE 8171 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Select ann_ _selDistinctIoriginalTree _selSelectListIoriginalTree _selTrefIoriginalTree _selWhereIoriginalTree _selGroupByIoriginalTree _selHavingIoriginalTree _selOrderByIoriginalTree _selLimitIoriginalTree _selOffsetIoriginalTree
-                  {-# LINE 8176 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8181 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selDistinctOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8186 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selDistinctOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8191 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selSelectListOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8196 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selTrefOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8201 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selTrefOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8206 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selWhereOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8211 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selGroupByOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8216 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selHavingOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8221 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selHavingOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8226 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOrderByOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8231 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selLimitOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8236 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selLimitOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8241 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOffsetOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8246 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOffsetOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8251 "AstInternal.hs" #-}
-              ( _selDistinctIannotatedTree,_selDistinctIoriginalTree) =
-                  (selDistinct_ _selDistinctOcat _selDistinctOlib )
-              ( _selSelectListIannotatedTree,_selSelectListIlibUpdates,_selSelectListIlistType,_selSelectListIoriginalTree) =
-                  (selSelectList_ _selSelectListOcat _selSelectListOlib )
-              ( _selTrefIannotatedTree,_selTrefIlibUpdates,_selTrefIoriginalTree) =
-                  (selTref_ _selTrefOcat _selTrefOlib )
-              ( _selWhereIannotatedTree,_selWhereIoriginalTree) =
-                  (selWhere_ _selWhereOcat _selWhereOlib )
-              ( _selGroupByIannotatedTree,_selGroupByIoriginalTree,_selGroupByItypeList) =
-                  (selGroupBy_ _selGroupByOcat _selGroupByOlib )
-              ( _selHavingIannotatedTree,_selHavingIoriginalTree) =
-                  (selHaving_ _selHavingOcat _selHavingOlib )
-              ( _selOrderByIannotatedTree,_selOrderByIoriginalTree) =
-                  (selOrderBy_ _selOrderByOcat _selOrderByOlib )
-              ( _selLimitIannotatedTree,_selLimitIoriginalTree) =
-                  (selLimit_ _selLimitOcat _selLimitOlib )
-              ( _selOffsetIannotatedTree,_selOffsetIoriginalTree) =
-                  (selOffset_ _selOffsetOcat _selOffsetOlib )
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_SelectExpression_Values :: Annotation ->
-                               T_ExpressionListList  ->
-                               T_SelectExpression 
-sem_SelectExpression_Values ann_ vll_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SelectExpression
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOoriginalTree :: SelectExpression
-              _vllOcat :: Catalog
-              _vllOlib :: LocalIdentifierBindings
-              _vllIannotatedTree :: ExpressionListList
-              _vllIoriginalTree :: ExpressionListList
-              _vllItypeListList :: ([[Type]])
-              -- "./TypeChecking/SelectStatement.ag"(line 23, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 23 "./TypeChecking/SelectStatement.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    Nothing
-                  {-# LINE 8292 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 106, column 9)
-              _tpe =
-                  {-# LINE 106 "./TypeChecking/SelectStatement.ag" #-}
-                  typeCheckValuesExpr
-                              _lhsIcat
-                              _vllItypeListList
-                  {-# LINE 8299 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 109, column 9)
-              _backTree =
-                  {-# LINE 109 "./TypeChecking/SelectStatement.ag" #-}
-                  Values ann_ _vllIannotatedTree
-                  {-# LINE 8304 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 87, column 11)
-              _lhsOlibUpdates =
-                  {-# LINE 87 "./TypeChecking/SelectLists.ag" #-}
-                  []
-                  {-# LINE 8309 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Values ann_ _vllIannotatedTree
-                  {-# LINE 8314 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Values ann_ _vllIoriginalTree
-                  {-# LINE 8319 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8324 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _vllOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8329 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _vllOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8334 "AstInternal.hs" #-}
-              ( _vllIannotatedTree,_vllIoriginalTree,_vllItypeListList) =
-                  (vll_ _vllOcat _vllOlib )
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree)))
--- SelectItem --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         columnName           : String
-         itemType             : Type
-         originalTree         : SELF 
-   alternatives:
-      alternative SelExp:
-         child ann            : {Annotation}
-         child ex             : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative SelectItem:
-         child ann            : {Annotation}
-         child ex             : Expression 
-         child name           : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data SelectItem  = SelExp (Annotation) (Expression) 
-                 | SelectItem (Annotation) (Expression) (String) 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_SelectItem :: SelectItem  ->
-                  T_SelectItem 
-sem_SelectItem (SelExp _ann _ex )  =
-    (sem_SelectItem_SelExp _ann (sem_Expression _ex ) )
-sem_SelectItem (SelectItem _ann _ex _name )  =
-    (sem_SelectItem_SelectItem _ann (sem_Expression _ex ) _name )
--- semantic domain
-type T_SelectItem  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( SelectItem,String,Type,SelectItem)
-data Inh_SelectItem  = Inh_SelectItem {cat_Inh_SelectItem :: Catalog,lib_Inh_SelectItem :: LocalIdentifierBindings}
-data Syn_SelectItem  = Syn_SelectItem {annotatedTree_Syn_SelectItem :: SelectItem,columnName_Syn_SelectItem :: String,itemType_Syn_SelectItem :: Type,originalTree_Syn_SelectItem :: SelectItem}
-wrap_SelectItem :: T_SelectItem  ->
-                   Inh_SelectItem  ->
-                   Syn_SelectItem 
-wrap_SelectItem sem (Inh_SelectItem _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOcolumnName,_lhsOitemType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SelectItem _lhsOannotatedTree _lhsOcolumnName _lhsOitemType _lhsOoriginalTree ))
-sem_SelectItem_SelExp :: Annotation ->
-                         T_Expression  ->
-                         T_SelectItem 
-sem_SelectItem_SelExp ann_ ex_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOitemType :: Type
-              _lhsOcolumnName :: String
-              _lhsOannotatedTree :: SelectItem
-              _lhsOoriginalTree :: SelectItem
-              _exOcat :: Catalog
-              _exOlib :: LocalIdentifierBindings
-              _exIannotatedTree :: Expression
-              _exIliftedColumnName :: String
-              _exIoriginalTree :: Expression
-              -- "./TypeChecking/SelectLists.ag"(line 13, column 9)
-              _annotatedTree =
-                  {-# LINE 13 "./TypeChecking/SelectLists.ag" #-}
-                  SelExp ann_ $ fixStar _exIannotatedTree
-                  {-# LINE 8406 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 35, column 9)
-              _lhsOitemType =
-                  {-# LINE 35 "./TypeChecking/SelectLists.ag" #-}
-                  getTypeAnnotation _exIannotatedTree
-                  {-# LINE 8411 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 181, column 14)
-              _lhsOcolumnName =
-                  {-# LINE 181 "./TypeChecking/SelectLists.ag" #-}
-                  case _exIliftedColumnName of
-                    "" -> "?column?"
-                    s -> s
-                  {-# LINE 8418 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SelExp ann_ _exIoriginalTree
-                  {-# LINE 8423 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8428 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8433 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8438 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8443 "AstInternal.hs" #-}
-              ( _exIannotatedTree,_exIliftedColumnName,_exIoriginalTree) =
-                  (ex_ _exOcat _exOlib )
-          in  ( _lhsOannotatedTree,_lhsOcolumnName,_lhsOitemType,_lhsOoriginalTree)))
-sem_SelectItem_SelectItem :: Annotation ->
-                             T_Expression  ->
-                             String ->
-                             T_SelectItem 
-sem_SelectItem_SelectItem ann_ ex_ name_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOitemType :: Type
-              _lhsOcolumnName :: String
-              _lhsOannotatedTree :: SelectItem
-              _lhsOoriginalTree :: SelectItem
-              _exOcat :: Catalog
-              _exOlib :: LocalIdentifierBindings
-              _exIannotatedTree :: Expression
-              _exIliftedColumnName :: String
-              _exIoriginalTree :: Expression
-              -- "./TypeChecking/SelectLists.ag"(line 15, column 9)
-              _annotatedTree =
-                  {-# LINE 15 "./TypeChecking/SelectLists.ag" #-}
-                  SelectItem ann_ (fixStar _exIannotatedTree) name_
-                  {-# LINE 8467 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 35, column 9)
-              _lhsOitemType =
-                  {-# LINE 35 "./TypeChecking/SelectLists.ag" #-}
-                  getTypeAnnotation _exIannotatedTree
-                  {-# LINE 8472 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 184, column 18)
-              _lhsOcolumnName =
-                  {-# LINE 184 "./TypeChecking/SelectLists.ag" #-}
-                  name_
-                  {-# LINE 8477 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SelectItem ann_ _exIoriginalTree name_
-                  {-# LINE 8482 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8487 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8492 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8497 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8502 "AstInternal.hs" #-}
-              ( _exIannotatedTree,_exIliftedColumnName,_exIoriginalTree) =
-                  (ex_ _exOcat _exOlib )
-          in  ( _lhsOannotatedTree,_lhsOcolumnName,_lhsOitemType,_lhsOoriginalTree)))
--- SelectItemList ----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         listType             : [(String,Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : SelectItem 
-         child tl             : SelectItemList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type SelectItemList  = [(SelectItem)]
--- cata
-sem_SelectItemList :: SelectItemList  ->
-                      T_SelectItemList 
-sem_SelectItemList list  =
-    (Prelude.foldr sem_SelectItemList_Cons sem_SelectItemList_Nil (Prelude.map sem_SelectItem list) )
--- semantic domain
-type T_SelectItemList  = Catalog ->
-                         LocalIdentifierBindings ->
-                         ( SelectItemList,([(String,Type)]),SelectItemList)
-data Inh_SelectItemList  = Inh_SelectItemList {cat_Inh_SelectItemList :: Catalog,lib_Inh_SelectItemList :: LocalIdentifierBindings}
-data Syn_SelectItemList  = Syn_SelectItemList {annotatedTree_Syn_SelectItemList :: SelectItemList,listType_Syn_SelectItemList :: [(String,Type)],originalTree_Syn_SelectItemList :: SelectItemList}
-wrap_SelectItemList :: T_SelectItemList  ->
-                       Inh_SelectItemList  ->
-                       Syn_SelectItemList 
-wrap_SelectItemList sem (Inh_SelectItemList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SelectItemList _lhsOannotatedTree _lhsOlistType _lhsOoriginalTree ))
-sem_SelectItemList_Cons :: T_SelectItem  ->
-                           T_SelectItemList  ->
-                           T_SelectItemList 
-sem_SelectItemList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: ([(String,Type)])
-              _lhsOannotatedTree :: SelectItemList
-              _lhsOoriginalTree :: SelectItemList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: SelectItem
-              _hdIcolumnName :: String
-              _hdIitemType :: Type
-              _hdIoriginalTree :: SelectItem
-              _tlIannotatedTree :: SelectItemList
-              _tlIlistType :: ([(String,Type)])
-              _tlIoriginalTree :: SelectItemList
-              -- "./TypeChecking/SelectLists.ag"(line 29, column 12)
-              _lhsOlistType =
-                  {-# LINE 29 "./TypeChecking/SelectLists.ag" #-}
-                  expandStar _lhsIlib _hdIcolumnName _hdIitemType _tlIlistType
-                  {-# LINE 8571 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 8576 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 8581 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8586 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8591 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8596 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8601 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8606 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8611 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIcolumnName,_hdIitemType,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIlistType,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
-sem_SelectItemList_Nil :: T_SelectItemList 
-sem_SelectItemList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: ([(String,Type)])
-              _lhsOannotatedTree :: SelectItemList
-              _lhsOoriginalTree :: SelectItemList
-              -- "./TypeChecking/SelectLists.ag"(line 30, column 11)
-              _lhsOlistType =
-                  {-# LINE 30 "./TypeChecking/SelectLists.ag" #-}
-                  []
-                  {-# LINE 8628 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 8633 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 8638 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8643 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8648 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
--- SelectList --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-         listType             : [(String,Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative SelectList:
-         child ann            : {Annotation}
-         child items          : SelectItemList 
-         child into           : StringList 
-         visit 0:
-            local errs        : _
-            local stuff       : _
-            local annotatedTree : _
-            local originalTree : _
--}
-data SelectList  = SelectList (Annotation) (SelectItemList) (StringList) 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_SelectList :: SelectList  ->
-                  T_SelectList 
-sem_SelectList (SelectList _ann _items _into )  =
-    (sem_SelectList_SelectList _ann (sem_SelectItemList _items ) (sem_StringList _into ) )
--- semantic domain
-type T_SelectList  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( SelectList,([LocalIdentifierBindingsUpdate]),([(String,Type)]),SelectList)
-data Inh_SelectList  = Inh_SelectList {cat_Inh_SelectList :: Catalog,lib_Inh_SelectList :: LocalIdentifierBindings}
-data Syn_SelectList  = Syn_SelectList {annotatedTree_Syn_SelectList :: SelectList,libUpdates_Syn_SelectList :: [LocalIdentifierBindingsUpdate],listType_Syn_SelectList :: [(String,Type)],originalTree_Syn_SelectList :: SelectList}
-wrap_SelectList :: T_SelectList  ->
-                   Inh_SelectList  ->
-                   Syn_SelectList 
-wrap_SelectList sem (Inh_SelectList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOlistType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SelectList _lhsOannotatedTree _lhsOlibUpdates _lhsOlistType _lhsOoriginalTree ))
-sem_SelectList_SelectList :: Annotation ->
-                             T_SelectItemList  ->
-                             T_StringList  ->
-                             T_SelectList 
-sem_SelectList_SelectList ann_ items_ into_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlistType :: ([(String,Type)])
-              _lhsOannotatedTree :: SelectList
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOoriginalTree :: SelectList
-              _itemsOcat :: Catalog
-              _itemsOlib :: LocalIdentifierBindings
-              _intoOcat :: Catalog
-              _intoOlib :: LocalIdentifierBindings
-              _itemsIannotatedTree :: SelectItemList
-              _itemsIlistType :: ([(String,Type)])
-              _itemsIoriginalTree :: SelectItemList
-              _intoIannotatedTree :: StringList
-              _intoIoriginalTree :: StringList
-              _intoIstrings :: ([String])
-              -- "./TypeChecking/SelectLists.ag"(line 41, column 9)
-              _lhsOlistType =
-                  {-# LINE 41 "./TypeChecking/SelectLists.ag" #-}
-                  _itemsIlistType
-                  {-# LINE 8717 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 43, column 9)
-              _errs =
-                  {-# LINE 43 "./TypeChecking/SelectLists.ag" #-}
-                  case _stuff     of
-                    (er,_) -> er
-                  {-# LINE 8723 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 45, column 9)
-              _stuff =
-                  {-# LINE 45 "./TypeChecking/SelectLists.ag" #-}
-                  case () of
-                    _ | null sl -> ([],Nothing)
-                      | not (null targetTypeErrs) -> (targetTypeErrs,Nothing)
-                      | (case targetTypes of
-                           [PgRecord _] -> True
-                           _ -> False) -> ([],Just (head sl, CompositeType _itemsIlistType))
-                      | matchingComposite /= Left [] -> (fromLeft [] matchingComposite,Nothing)
-                      | length sl /= length _itemsIlistType -> ([WrongNumberOfColumns],Nothing)
-                      | not (null assignErrs) -> (assignErrs,Nothing)
-                      | otherwise -> ([],Nothing)
-                  where
-                    targetTypeEithers = map (libLookupID _lhsIlib) sl
-                    targetTypeErrs = concat $ lefts $ targetTypeEithers
-                    targetTypes = rights $ targetTypeEithers
-                    typePairs = zip (map snd _itemsIlistType) targetTypes
-                    assignErrs = concat $ lefts $ map (uncurry $ checkAssignmentValid _lhsIcat) typePairs
-                    sl = _intoIstrings
-                    matchingComposite =
-                        case targetTypes of
-                          [t] | isCompositeType t -> checkAssignmentValid _lhsIcat (AnonymousRecordType (map snd _itemsIlistType)) t
-                          _ -> Left []
-                  {-# LINE 8748 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 68, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 68 "./TypeChecking/SelectLists.ag" #-}
-                  SelectList (ann_ ++ map TypeErrorA _errs    )
-                             _itemsIannotatedTree
-                             _intoIannotatedTree
-                  {-# LINE 8755 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 71, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 71 "./TypeChecking/SelectLists.ag" #-}
-                  case _stuff     of
-                    (_,Just r) -> [LibStackIDs [("", [r])]]
-                    _ -> []
-                  {-# LINE 8762 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SelectList ann_ _itemsIannotatedTree _intoIannotatedTree
-                  {-# LINE 8767 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SelectList ann_ _itemsIoriginalTree _intoIoriginalTree
-                  {-# LINE 8772 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8777 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _itemsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8782 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _itemsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8787 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _intoOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8792 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _intoOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8797 "AstInternal.hs" #-}
-              ( _itemsIannotatedTree,_itemsIlistType,_itemsIoriginalTree) =
-                  (items_ _itemsOcat _itemsOlib )
-              ( _intoIannotatedTree,_intoIoriginalTree,_intoIstrings) =
-                  (into_ _intoOcat _intoOlib )
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOlistType,_lhsOoriginalTree)))
--- SetClause ---------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         pairs                : [(String,Type)]
-         rowSetError          : Maybe TypeError
-   alternatives:
-      alternative RowSetClause:
-         child ann            : {Annotation}
-         child atts           : StringList 
-         child vals           : ExpressionList 
-         visit 0:
-            local rowSetError : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative SetClause:
-         child ann            : {Annotation}
-         child att            : {String}
-         child val            : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data SetClause  = RowSetClause (Annotation) (StringList) (ExpressionList) 
-                | SetClause (Annotation) (String) (Expression) 
-                deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_SetClause :: SetClause  ->
-                 T_SetClause 
-sem_SetClause (RowSetClause _ann _atts _vals )  =
-    (sem_SetClause_RowSetClause _ann (sem_StringList _atts ) (sem_ExpressionList _vals ) )
-sem_SetClause (SetClause _ann _att _val )  =
-    (sem_SetClause_SetClause _ann _att (sem_Expression _val ) )
--- semantic domain
-type T_SetClause  = Catalog ->
-                    LocalIdentifierBindings ->
-                    ( SetClause,SetClause,([(String,Type)]),(Maybe TypeError))
-data Inh_SetClause  = Inh_SetClause {cat_Inh_SetClause :: Catalog,lib_Inh_SetClause :: LocalIdentifierBindings}
-data Syn_SetClause  = Syn_SetClause {annotatedTree_Syn_SetClause :: SetClause,originalTree_Syn_SetClause :: SetClause,pairs_Syn_SetClause :: [(String,Type)],rowSetError_Syn_SetClause :: Maybe TypeError}
-wrap_SetClause :: T_SetClause  ->
-                  Inh_SetClause  ->
-                  Syn_SetClause 
-wrap_SetClause sem (Inh_SetClause _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetError) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SetClause _lhsOannotatedTree _lhsOoriginalTree _lhsOpairs _lhsOrowSetError ))
-sem_SetClause_RowSetClause :: Annotation ->
-                              T_StringList  ->
-                              T_ExpressionList  ->
-                              T_SetClause 
-sem_SetClause_RowSetClause ann_ atts_ vals_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOpairs :: ([(String,Type)])
-              _lhsOannotatedTree :: SetClause
-              _lhsOoriginalTree :: SetClause
-              _lhsOrowSetError :: (Maybe TypeError)
-              _attsOcat :: Catalog
-              _attsOlib :: LocalIdentifierBindings
-              _valsOcat :: Catalog
-              _valsOlib :: LocalIdentifierBindings
-              _attsIannotatedTree :: StringList
-              _attsIoriginalTree :: StringList
-              _attsIstrings :: ([String])
-              _valsIannotatedTree :: ExpressionList
-              _valsIoriginalTree :: ExpressionList
-              _valsItypeList :: ([Type])
-              -- "./TypeChecking/Dml.ag"(line 155, column 9)
-              _rowSetError =
-                  {-# LINE 155 "./TypeChecking/Dml.ag" #-}
-                  let atts = _attsIstrings
-                      types = getRowTypes _valsItypeList
-                  in if length atts /= length types
-                       then Just WrongNumberOfColumns
-                       else Nothing
-                  {-# LINE 8883 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 161, column 9)
-              _lhsOpairs =
-                  {-# LINE 161 "./TypeChecking/Dml.ag" #-}
-                  zip _attsIstrings $ getRowTypes _valsItypeList
-                  {-# LINE 8888 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  RowSetClause ann_ _attsIannotatedTree _valsIannotatedTree
-                  {-# LINE 8893 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  RowSetClause ann_ _attsIoriginalTree _valsIoriginalTree
-                  {-# LINE 8898 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8903 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8908 "AstInternal.hs" #-}
-              -- copy rule (from local)
-              _lhsOrowSetError =
-                  {-# LINE 148 "./TypeChecking/Dml.ag" #-}
-                  _rowSetError
-                  {-# LINE 8913 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8918 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8923 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8928 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8933 "AstInternal.hs" #-}
-              ( _attsIannotatedTree,_attsIoriginalTree,_attsIstrings) =
-                  (atts_ _attsOcat _attsOlib )
-              ( _valsIannotatedTree,_valsIoriginalTree,_valsItypeList) =
-                  (vals_ _valsOcat _valsOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetError)))
-sem_SetClause_SetClause :: Annotation ->
-                           String ->
-                           T_Expression  ->
-                           T_SetClause 
-sem_SetClause_SetClause ann_ att_ val_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOpairs :: ([(String,Type)])
-              _lhsOrowSetError :: (Maybe TypeError)
-              _lhsOannotatedTree :: SetClause
-              _lhsOoriginalTree :: SetClause
-              _valOcat :: Catalog
-              _valOlib :: LocalIdentifierBindings
-              _valIannotatedTree :: Expression
-              _valIliftedColumnName :: String
-              _valIoriginalTree :: Expression
-              -- "./TypeChecking/Dml.ag"(line 152, column 9)
-              _lhsOpairs =
-                  {-# LINE 152 "./TypeChecking/Dml.ag" #-}
-                  [(att_, getTypeAnnotation _valIannotatedTree)]
-                  {-# LINE 8959 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 153, column 9)
-              _lhsOrowSetError =
-                  {-# LINE 153 "./TypeChecking/Dml.ag" #-}
-                  Nothing
-                  {-# LINE 8964 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SetClause ann_ att_ _valIannotatedTree
-                  {-# LINE 8969 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SetClause ann_ att_ _valIoriginalTree
-                  {-# LINE 8974 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 8979 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 8984 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 8989 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 8994 "AstInternal.hs" #-}
-              ( _valIannotatedTree,_valIliftedColumnName,_valIoriginalTree) =
-                  (val_ _valOcat _valOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetError)))
--- SetClauseList -----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         pairs                : [(String,Type)]
-         rowSetErrors         : [TypeError]
-   alternatives:
-      alternative Cons:
-         child hd             : SetClause 
-         child tl             : SetClauseList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type SetClauseList  = [(SetClause)]
--- cata
-sem_SetClauseList :: SetClauseList  ->
-                     T_SetClauseList 
-sem_SetClauseList list  =
-    (Prelude.foldr sem_SetClauseList_Cons sem_SetClauseList_Nil (Prelude.map sem_SetClause list) )
--- semantic domain
-type T_SetClauseList  = Catalog ->
-                        LocalIdentifierBindings ->
-                        ( SetClauseList,SetClauseList,([(String,Type)]),([TypeError]))
-data Inh_SetClauseList  = Inh_SetClauseList {cat_Inh_SetClauseList :: Catalog,lib_Inh_SetClauseList :: LocalIdentifierBindings}
-data Syn_SetClauseList  = Syn_SetClauseList {annotatedTree_Syn_SetClauseList :: SetClauseList,originalTree_Syn_SetClauseList :: SetClauseList,pairs_Syn_SetClauseList :: [(String,Type)],rowSetErrors_Syn_SetClauseList :: [TypeError]}
-wrap_SetClauseList :: T_SetClauseList  ->
-                      Inh_SetClauseList  ->
-                      Syn_SetClauseList 
-wrap_SetClauseList sem (Inh_SetClauseList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetErrors) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SetClauseList _lhsOannotatedTree _lhsOoriginalTree _lhsOpairs _lhsOrowSetErrors ))
-sem_SetClauseList_Cons :: T_SetClause  ->
-                          T_SetClauseList  ->
-                          T_SetClauseList 
-sem_SetClauseList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOpairs :: ([(String,Type)])
-              _lhsOrowSetErrors :: ([TypeError])
-              _lhsOannotatedTree :: SetClauseList
-              _lhsOoriginalTree :: SetClauseList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: SetClause
-              _hdIoriginalTree :: SetClause
-              _hdIpairs :: ([(String,Type)])
-              _hdIrowSetError :: (Maybe TypeError)
-              _tlIannotatedTree :: SetClauseList
-              _tlIoriginalTree :: SetClauseList
-              _tlIpairs :: ([(String,Type)])
-              _tlIrowSetErrors :: ([TypeError])
-              -- "./TypeChecking/Dml.ag"(line 142, column 10)
-              _lhsOpairs =
-                  {-# LINE 142 "./TypeChecking/Dml.ag" #-}
-                  _hdIpairs ++ _tlIpairs
-                  {-# LINE 9066 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 143, column 10)
-              _lhsOrowSetErrors =
-                  {-# LINE 143 "./TypeChecking/Dml.ag" #-}
-                  maybeToList _hdIrowSetError ++ _tlIrowSetErrors
-                  {-# LINE 9071 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 9076 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 9081 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9086 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9091 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 9096 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 9101 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 9106 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 9111 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIoriginalTree,_hdIpairs,_hdIrowSetError) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlIpairs,_tlIrowSetErrors) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetErrors)))
-sem_SetClauseList_Nil :: T_SetClauseList 
-sem_SetClauseList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOpairs :: ([(String,Type)])
-              _lhsOrowSetErrors :: ([TypeError])
-              _lhsOannotatedTree :: SetClauseList
-              _lhsOoriginalTree :: SetClauseList
-              -- "./TypeChecking/Dml.ag"(line 144, column 9)
-              _lhsOpairs =
-                  {-# LINE 144 "./TypeChecking/Dml.ag" #-}
-                  []
-                  {-# LINE 9129 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 145, column 9)
-              _lhsOrowSetErrors =
-                  {-# LINE 145 "./TypeChecking/Dml.ag" #-}
-                  []
-                  {-# LINE 9134 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 9139 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 9144 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9149 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9154 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOpairs,_lhsOrowSetErrors)))
--- SetValue ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative SetId:
-         child ann            : {Annotation}
-         child string         : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative SetNum:
-         child ann            : {Annotation}
-         child double         : {Double}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative SetStr:
-         child ann            : {Annotation}
-         child string         : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data SetValue  = SetId (Annotation) (String) 
-               | SetNum (Annotation) (Double) 
-               | SetStr (Annotation) (String) 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_SetValue :: SetValue  ->
-                T_SetValue 
-sem_SetValue (SetId _ann _string )  =
-    (sem_SetValue_SetId _ann _string )
-sem_SetValue (SetNum _ann _double )  =
-    (sem_SetValue_SetNum _ann _double )
-sem_SetValue (SetStr _ann _string )  =
-    (sem_SetValue_SetStr _ann _string )
--- semantic domain
-type T_SetValue  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( SetValue,SetValue)
-data Inh_SetValue  = Inh_SetValue {cat_Inh_SetValue :: Catalog,lib_Inh_SetValue :: LocalIdentifierBindings}
-data Syn_SetValue  = Syn_SetValue {annotatedTree_Syn_SetValue :: SetValue,originalTree_Syn_SetValue :: SetValue}
-wrap_SetValue :: T_SetValue  ->
-                 Inh_SetValue  ->
-                 Syn_SetValue 
-wrap_SetValue sem (Inh_SetValue _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_SetValue _lhsOannotatedTree _lhsOoriginalTree ))
-sem_SetValue_SetId :: Annotation ->
-                      String ->
-                      T_SetValue 
-sem_SetValue_SetId ann_ string_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SetValue
-              _lhsOoriginalTree :: SetValue
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SetId ann_ string_
-                  {-# LINE 9223 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SetId ann_ string_
-                  {-# LINE 9228 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9233 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9238 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_SetValue_SetNum :: Annotation ->
-                       Double ->
-                       T_SetValue 
-sem_SetValue_SetNum ann_ double_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SetValue
-              _lhsOoriginalTree :: SetValue
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SetNum ann_ double_
-                  {-# LINE 9252 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SetNum ann_ double_
-                  {-# LINE 9257 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9262 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9267 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_SetValue_SetStr :: Annotation ->
-                       String ->
-                       T_SetValue 
-sem_SetValue_SetStr ann_ string_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: SetValue
-              _lhsOoriginalTree :: SetValue
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SetStr ann_ string_
-                  {-# LINE 9281 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SetStr ann_ string_
-                  {-# LINE 9286 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9291 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9296 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- Statement ---------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         inProducedCat        : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         catUpdates           : [CatalogUpdate]
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-         originalTree         : SELF 
-   alternatives:
-      alternative AlterSequence:
-         child ann            : {Annotation}
-         child name           : {String}
-         child ownedBy        : {String}
-         visit 0:
-            local libUpdates  : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative AlterTable:
-         child ann            : {Annotation}
-         child name           : {String}
-         child actions        : {[AlterTableAction]}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Assignment:
-         child ann            : {Annotation}
-         child target         : {String}
-         child value          : Expression 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CaseStatement:
-         child ann            : {Annotation}
-         child val            : Expression 
-         child cases          : ExpressionListStatementListPairList 
-         child els            : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ContinueStatement:
-         child ann            : {Annotation}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Copy:
-         child ann            : {Annotation}
-         child table          : {String}
-         child targetCols     : StringList 
-         child source         : CopySource 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative CopyData:
-         child ann            : {Annotation}
-         child insData        : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateDomain:
-         child ann            : {Annotation}
-         child name           : {String}
-         child typ            : TypeName 
-         child checkName      : {String}
-         child check          : MaybeBoolExpression 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local statementType : _
-            local catUpdates  : {[CatalogUpdate]}
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateFunction:
-         child ann            : {Annotation}
-         child name           : {String}
-         child params         : ParamDefList 
-         child rettype        : TypeName 
-         child lang           : Language 
-         child bodyQuote      : {String}
-         child body           : FnBody 
-         child vol            : Volatility 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local catUpdates  : {[CatalogUpdate]}
-            local parameterTypes : _
-            local backTree    : _
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateLanguage:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local statementType : _
-            local catUpdates  : {[CatalogUpdate]}
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateSequence:
-         child ann            : {Annotation}
-         child name           : {String}
-         child incr           : {Integer}
-         child min            : {Integer}
-         child max            : {Integer}
-         child start          : {Integer}
-         child cache          : {Integer}
-         visit 0:
-            local libUpdates  : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateTable:
-         child ann            : {Annotation}
-         child name           : {String}
-         child atts           : AttributeDefList 
-         child cons           : ConstraintList 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local catUpdates  : {[CatalogUpdate]}
-            local attrTypes   : {[Type]}
-            local statementType : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateTableAs:
-         child ann            : {Annotation}
-         child name           : {String}
-         child expr           : SelectExpression 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local catUpdates  : {[CatalogUpdate]}
-            local selType     : _
-            local attrs       : _
-            local backTree    : _
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateTrigger:
-         child ann            : {Annotation}
-         child name           : {String}
-         child wh             : TriggerWhen 
-         child events         : {[TriggerEvent]}
-         child tbl            : {String}
-         child firing         : TriggerFire 
-         child fnName         : {String}
-         child fnArgs         : {[Expression]}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateType:
-         child ann            : {Annotation}
-         child name           : {String}
-         child atts           : TypeAttributeDefList 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local statementType : _
-            local catUpdates  : {[CatalogUpdate]}
-            local annotatedTree : _
-            local originalTree : _
-      alternative CreateView:
-         child ann            : {Annotation}
-         child name           : {String}
-         child expr           : SelectExpression 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local attrs       : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Delete:
-         child ann            : {Annotation}
-         child table          : {String}
-         child whr            : MaybeBoolExpression 
-         child returning      : MaybeSelectList 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local statementType : _
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local lib         : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative DropFunction:
-         child ann            : {Annotation}
-         child ifE            : IfExists 
-         child sigs           : StringTypeNameListPairList 
-         child cascade        : Cascade 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative DropSomething:
-         child ann            : {Annotation}
-         child dropType       : DropType 
-         child ifE            : IfExists 
-         child names          : StringList 
-         child cascade        : Cascade 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Execute:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ExecuteInto:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         child targets        : StringList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ForIntegerStatement:
-         child ann            : {Annotation}
-         child var            : {String}
-         child from           : Expression 
-         child to             : Expression 
-         child sts            : StatementList 
-         visit 0:
-            local libUpdates  : _
-            local varTypeE    : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative ForSelectStatement:
-         child ann            : {Annotation}
-         child var            : {String}
-         child sel            : SelectExpression 
-         child sts            : StatementList 
-         visit 0:
-            local libUpdates  : _
-            local selType     : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative If:
-         child ann            : {Annotation}
-         child cases          : ExpressionStatementListPairList 
-         child els            : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Insert:
-         child ann            : {Annotation}
-         child table          : {String}
-         child targetCols     : StringList 
-         child insData        : SelectExpression 
-         child returning      : MaybeSelectList 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local statementType : _
-            local columnTypes : _
-            local insDataAddedInferredTypes : _
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local annotatedTree : _
-            local originalTree : _
-      alternative Notify:
-         child ann            : {Annotation}
-         child name           : {String}
-         visit 0:
-            local libUpdates  : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative NullStatement:
-         child ann            : {Annotation}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Perform:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Raise:
-         child ann            : {Annotation}
-         child level          : RaiseType 
-         child message        : {String}
-         child args           : ExpressionList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Return:
-         child ann            : {Annotation}
-         child value          : MaybeExpression 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local statementType : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative ReturnNext:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative ReturnQuery:
-         child ann            : {Annotation}
-         child sel            : SelectExpression 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative SelectStatement:
-         child ann            : {Annotation}
-         child ex             : SelectExpression 
-         visit 0:
-            local tpe         : {Either [TypeError] Type}
-            local statementType : _
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local libUpdates  : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Set:
-         child ann            : {Annotation}
-         child name           : {String}
-         child values         : {[SetValue]}
-         visit 0:
-            local libUpdates  : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Truncate:
-         child ann            : {Annotation}
-         child tables         : StringList 
-         child restartIdentity : RestartIdentity 
-         child cascade        : Cascade 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Update:
-         child ann            : {Annotation}
-         child table          : {String}
-         child assigns        : SetClauseList 
-         child whr            : MaybeBoolExpression 
-         child returning      : MaybeSelectList 
-         visit 0:
-            local libUpdates  : _
-            local tpe         : {Either [TypeError] Type}
-            local statementType : _
-            local columnTypes : _
-            local assignWInferredTypes : {SetClauseList}
-            local backTree    : _
-            local catUpdates  : {[CatalogUpdate]}
-            local lib         : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative WhileStatement:
-         child ann            : {Annotation}
-         child expr           : Expression 
-         child sts            : StatementList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Statement  = AlterSequence (Annotation) (String) (String) 
-                | AlterTable (Annotation) (String) ([AlterTableAction]) 
-                | Assignment (Annotation) (String) (Expression) 
-                | CaseStatement (Annotation) (Expression) (ExpressionListStatementListPairList) (StatementList) 
-                | ContinueStatement (Annotation) 
-                | Copy (Annotation) (String) (StringList) (CopySource) 
-                | CopyData (Annotation) (String) 
-                | CreateDomain (Annotation) (String) (TypeName) (String) (MaybeBoolExpression) 
-                | CreateFunction (Annotation) (String) (ParamDefList) (TypeName) (Language) (String) (FnBody) (Volatility) 
-                | CreateLanguage (Annotation) (String) 
-                | CreateSequence (Annotation) (String) (Integer) (Integer) (Integer) (Integer) (Integer) 
-                | CreateTable (Annotation) (String) (AttributeDefList) (ConstraintList) 
-                | CreateTableAs (Annotation) (String) (SelectExpression) 
-                | CreateTrigger (Annotation) (String) (TriggerWhen) ([TriggerEvent]) (String) (TriggerFire) (String) ([Expression]) 
-                | CreateType (Annotation) (String) (TypeAttributeDefList) 
-                | CreateView (Annotation) (String) (SelectExpression) 
-                | Delete (Annotation) (String) (MaybeBoolExpression) (MaybeSelectList) 
-                | DropFunction (Annotation) (IfExists) (StringTypeNameListPairList) (Cascade) 
-                | DropSomething (Annotation) (DropType) (IfExists) (StringList) (Cascade) 
-                | Execute (Annotation) (Expression) 
-                | ExecuteInto (Annotation) (Expression) (StringList) 
-                | ForIntegerStatement (Annotation) (String) (Expression) (Expression) (StatementList) 
-                | ForSelectStatement (Annotation) (String) (SelectExpression) (StatementList) 
-                | If (Annotation) (ExpressionStatementListPairList) (StatementList) 
-                | Insert (Annotation) (String) (StringList) (SelectExpression) (MaybeSelectList) 
-                | Notify (Annotation) (String) 
-                | NullStatement (Annotation) 
-                | Perform (Annotation) (Expression) 
-                | Raise (Annotation) (RaiseType) (String) (ExpressionList) 
-                | Return (Annotation) (MaybeExpression) 
-                | ReturnNext (Annotation) (Expression) 
-                | ReturnQuery (Annotation) (SelectExpression) 
-                | SelectStatement (Annotation) (SelectExpression) 
-                | Set (Annotation) (String) ([SetValue]) 
-                | Truncate (Annotation) (StringList) (RestartIdentity) (Cascade) 
-                | Update (Annotation) (String) (SetClauseList) (MaybeBoolExpression) (MaybeSelectList) 
-                | WhileStatement (Annotation) (Expression) (StatementList) 
-                deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Statement :: Statement  ->
-                 T_Statement 
-sem_Statement (AlterSequence _ann _name _ownedBy )  =
-    (sem_Statement_AlterSequence _ann _name _ownedBy )
-sem_Statement (AlterTable _ann _name _actions )  =
-    (sem_Statement_AlterTable _ann _name _actions )
-sem_Statement (Assignment _ann _target _value )  =
-    (sem_Statement_Assignment _ann _target (sem_Expression _value ) )
-sem_Statement (CaseStatement _ann _val _cases _els )  =
-    (sem_Statement_CaseStatement _ann (sem_Expression _val ) (sem_ExpressionListStatementListPairList _cases ) (sem_StatementList _els ) )
-sem_Statement (ContinueStatement _ann )  =
-    (sem_Statement_ContinueStatement _ann )
-sem_Statement (Copy _ann _table _targetCols _source )  =
-    (sem_Statement_Copy _ann _table (sem_StringList _targetCols ) (sem_CopySource _source ) )
-sem_Statement (CopyData _ann _insData )  =
-    (sem_Statement_CopyData _ann _insData )
-sem_Statement (CreateDomain _ann _name _typ _checkName _check )  =
-    (sem_Statement_CreateDomain _ann _name (sem_TypeName _typ ) _checkName (sem_MaybeBoolExpression _check ) )
-sem_Statement (CreateFunction _ann _name _params _rettype _lang _bodyQuote _body _vol )  =
-    (sem_Statement_CreateFunction _ann _name (sem_ParamDefList _params ) (sem_TypeName _rettype ) (sem_Language _lang ) _bodyQuote (sem_FnBody _body ) (sem_Volatility _vol ) )
-sem_Statement (CreateLanguage _ann _name )  =
-    (sem_Statement_CreateLanguage _ann _name )
-sem_Statement (CreateSequence _ann _name _incr _min _max _start _cache )  =
-    (sem_Statement_CreateSequence _ann _name _incr _min _max _start _cache )
-sem_Statement (CreateTable _ann _name _atts _cons )  =
-    (sem_Statement_CreateTable _ann _name (sem_AttributeDefList _atts ) (sem_ConstraintList _cons ) )
-sem_Statement (CreateTableAs _ann _name _expr )  =
-    (sem_Statement_CreateTableAs _ann _name (sem_SelectExpression _expr ) )
-sem_Statement (CreateTrigger _ann _name _wh _events _tbl _firing _fnName _fnArgs )  =
-    (sem_Statement_CreateTrigger _ann _name (sem_TriggerWhen _wh ) _events _tbl (sem_TriggerFire _firing ) _fnName _fnArgs )
-sem_Statement (CreateType _ann _name _atts )  =
-    (sem_Statement_CreateType _ann _name (sem_TypeAttributeDefList _atts ) )
-sem_Statement (CreateView _ann _name _expr )  =
-    (sem_Statement_CreateView _ann _name (sem_SelectExpression _expr ) )
-sem_Statement (Delete _ann _table _whr _returning )  =
-    (sem_Statement_Delete _ann _table (sem_MaybeBoolExpression _whr ) (sem_MaybeSelectList _returning ) )
-sem_Statement (DropFunction _ann _ifE _sigs _cascade )  =
-    (sem_Statement_DropFunction _ann (sem_IfExists _ifE ) (sem_StringTypeNameListPairList _sigs ) (sem_Cascade _cascade ) )
-sem_Statement (DropSomething _ann _dropType _ifE _names _cascade )  =
-    (sem_Statement_DropSomething _ann (sem_DropType _dropType ) (sem_IfExists _ifE ) (sem_StringList _names ) (sem_Cascade _cascade ) )
-sem_Statement (Execute _ann _expr )  =
-    (sem_Statement_Execute _ann (sem_Expression _expr ) )
-sem_Statement (ExecuteInto _ann _expr _targets )  =
-    (sem_Statement_ExecuteInto _ann (sem_Expression _expr ) (sem_StringList _targets ) )
-sem_Statement (ForIntegerStatement _ann _var _from _to _sts )  =
-    (sem_Statement_ForIntegerStatement _ann _var (sem_Expression _from ) (sem_Expression _to ) (sem_StatementList _sts ) )
-sem_Statement (ForSelectStatement _ann _var _sel _sts )  =
-    (sem_Statement_ForSelectStatement _ann _var (sem_SelectExpression _sel ) (sem_StatementList _sts ) )
-sem_Statement (If _ann _cases _els )  =
-    (sem_Statement_If _ann (sem_ExpressionStatementListPairList _cases ) (sem_StatementList _els ) )
-sem_Statement (Insert _ann _table _targetCols _insData _returning )  =
-    (sem_Statement_Insert _ann _table (sem_StringList _targetCols ) (sem_SelectExpression _insData ) (sem_MaybeSelectList _returning ) )
-sem_Statement (Notify _ann _name )  =
-    (sem_Statement_Notify _ann _name )
-sem_Statement (NullStatement _ann )  =
-    (sem_Statement_NullStatement _ann )
-sem_Statement (Perform _ann _expr )  =
-    (sem_Statement_Perform _ann (sem_Expression _expr ) )
-sem_Statement (Raise _ann _level _message _args )  =
-    (sem_Statement_Raise _ann (sem_RaiseType _level ) _message (sem_ExpressionList _args ) )
-sem_Statement (Return _ann _value )  =
-    (sem_Statement_Return _ann (sem_MaybeExpression _value ) )
-sem_Statement (ReturnNext _ann _expr )  =
-    (sem_Statement_ReturnNext _ann (sem_Expression _expr ) )
-sem_Statement (ReturnQuery _ann _sel )  =
-    (sem_Statement_ReturnQuery _ann (sem_SelectExpression _sel ) )
-sem_Statement (SelectStatement _ann _ex )  =
-    (sem_Statement_SelectStatement _ann (sem_SelectExpression _ex ) )
-sem_Statement (Set _ann _name _values )  =
-    (sem_Statement_Set _ann _name _values )
-sem_Statement (Truncate _ann _tables _restartIdentity _cascade )  =
-    (sem_Statement_Truncate _ann (sem_StringList _tables ) (sem_RestartIdentity _restartIdentity ) (sem_Cascade _cascade ) )
-sem_Statement (Update _ann _table _assigns _whr _returning )  =
-    (sem_Statement_Update _ann _table (sem_SetClauseList _assigns ) (sem_MaybeBoolExpression _whr ) (sem_MaybeSelectList _returning ) )
-sem_Statement (WhileStatement _ann _expr _sts )  =
-    (sem_Statement_WhileStatement _ann (sem_Expression _expr ) (sem_StatementList _sts ) )
--- semantic domain
-type T_Statement  = Catalog ->
-                    Catalog ->
-                    LocalIdentifierBindings ->
-                    ( Statement,([CatalogUpdate]),([LocalIdentifierBindingsUpdate]),Statement)
-data Inh_Statement  = Inh_Statement {cat_Inh_Statement :: Catalog,inProducedCat_Inh_Statement :: Catalog,lib_Inh_Statement :: LocalIdentifierBindings}
-data Syn_Statement  = Syn_Statement {annotatedTree_Syn_Statement :: Statement,catUpdates_Syn_Statement :: [CatalogUpdate],libUpdates_Syn_Statement :: [LocalIdentifierBindingsUpdate],originalTree_Syn_Statement :: Statement}
-wrap_Statement :: T_Statement  ->
-                  Inh_Statement  ->
-                  Syn_Statement 
-wrap_Statement sem (Inh_Statement _lhsIcat _lhsIinProducedCat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIinProducedCat _lhsIlib )
-     in  (Syn_Statement _lhsOannotatedTree _lhsOcatUpdates _lhsOlibUpdates _lhsOoriginalTree ))
-sem_Statement_AlterSequence :: Annotation ->
-                               String ->
-                               String ->
-                               T_Statement 
-sem_Statement_AlterSequence ann_ name_ ownedBy_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9832 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9837 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9842 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterSequence ann_ name_ ownedBy_
-                  {-# LINE 9847 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterSequence ann_ name_ ownedBy_
-                  {-# LINE 9852 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9857 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9862 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_AlterTable :: Annotation ->
-                            String ->
-                            ([AlterTableAction]) ->
-                            T_Statement 
-sem_Statement_AlterTable ann_ name_ actions_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9880 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9885 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterTable ann_ name_ actions_
-                  {-# LINE 9890 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  AlterTable ann_ name_ actions_
-                  {-# LINE 9895 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 9900 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9905 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Assignment :: Annotation ->
-                            String ->
-                            T_Expression  ->
-                            T_Statement 
-sem_Statement_Assignment ann_ target_ value_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _valueOcat :: Catalog
-              _valueOlib :: LocalIdentifierBindings
-              _valueIannotatedTree :: Expression
-              _valueIliftedColumnName :: String
-              _valueIoriginalTree :: Expression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 9934 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 9939 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 9944 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 9949 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 23, column 9)
-              _tpe =
-                  {-# LINE 23 "./TypeChecking/Plpgsql.ag" #-}
-                  do
-                  let fromType = getTypeAnnotation _valueIannotatedTree
-                  toType <- libLookupID _lhsIlib target_
-                  dependsOnRTpe [getTypeAnnotation _valueIannotatedTree, toType] $ do
-                  checkAssignmentValid _lhsIcat fromType toType
-                  return $ Pseudo Void
-                  {-# LINE 9959 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 30, column 9)
-              _backTree =
-                  {-# LINE 30 "./TypeChecking/Plpgsql.ag" #-}
-                  Assignment ann_ target_ _valueIannotatedTree
-                  {-# LINE 9964 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 31, column 9)
-              _catUpdates =
-                  {-# LINE 31 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 9969 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 32, column 9)
-              _statementType =
-                  {-# LINE 32 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 9974 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Assignment ann_ target_ _valueIannotatedTree
-                  {-# LINE 9979 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Assignment ann_ target_ _valueIoriginalTree
-                  {-# LINE 9984 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 9989 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 9994 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 9999 "AstInternal.hs" #-}
-              ( _valueIannotatedTree,_valueIliftedColumnName,_valueIoriginalTree) =
-                  (value_ _valueOcat _valueOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CaseStatement :: Annotation ->
-                               T_Expression  ->
-                               T_ExpressionListStatementListPairList  ->
-                               T_StatementList  ->
-                               T_Statement 
-sem_Statement_CaseStatement ann_ val_ cases_ els_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _elsOcatUpdates :: ([CatalogUpdate])
-              _elsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _valOcat :: Catalog
-              _valOlib :: LocalIdentifierBindings
-              _casesOcat :: Catalog
-              _casesOlib :: LocalIdentifierBindings
-              _elsOcat :: Catalog
-              _elsOlib :: LocalIdentifierBindings
-              _valIannotatedTree :: Expression
-              _valIliftedColumnName :: String
-              _valIoriginalTree :: Expression
-              _casesIannotatedTree :: ExpressionListStatementListPairList
-              _casesIoriginalTree :: ExpressionListStatementListPairList
-              _elsIannotatedTree :: StatementList
-              _elsIoriginalTree :: StatementList
-              _elsIproducedCat :: Catalog
-              _elsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10037 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10042 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 106, column 9)
-              _elsOcatUpdates =
-                  {-# LINE 106 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10047 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 107, column 9)
-              _elsOlibUpdates =
-                  {-# LINE 107 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10052 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CaseStatement ann_ _valIannotatedTree _casesIannotatedTree _elsIannotatedTree
-                  {-# LINE 10057 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CaseStatement ann_ _valIoriginalTree _casesIoriginalTree _elsIoriginalTree
-                  {-# LINE 10062 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10067 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10072 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10077 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10082 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10087 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10092 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10097 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10102 "AstInternal.hs" #-}
-              ( _valIannotatedTree,_valIliftedColumnName,_valIoriginalTree) =
-                  (val_ _valOcat _valOlib )
-              ( _casesIannotatedTree,_casesIoriginalTree) =
-                  (cases_ _casesOcat _casesOlib )
-              ( _elsIannotatedTree,_elsIoriginalTree,_elsIproducedCat,_elsIproducedLib) =
-                  (els_ _elsOcat _elsOcatUpdates _elsOlib _elsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ContinueStatement :: Annotation ->
-                                   T_Statement 
-sem_Statement_ContinueStatement ann_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10124 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10129 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ContinueStatement ann_
-                  {-# LINE 10134 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ContinueStatement ann_
-                  {-# LINE 10139 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10144 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10149 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Copy :: Annotation ->
-                      String ->
-                      T_StringList  ->
-                      T_CopySource  ->
-                      T_Statement 
-sem_Statement_Copy ann_ table_ targetCols_ source_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _targetColsOcat :: Catalog
-              _targetColsOlib :: LocalIdentifierBindings
-              _sourceOcat :: Catalog
-              _sourceOlib :: LocalIdentifierBindings
-              _targetColsIannotatedTree :: StringList
-              _targetColsIoriginalTree :: StringList
-              _targetColsIstrings :: ([String])
-              _sourceIannotatedTree :: CopySource
-              _sourceIoriginalTree :: CopySource
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10177 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10182 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Copy ann_ table_ _targetColsIannotatedTree _sourceIannotatedTree
-                  {-# LINE 10187 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Copy ann_ table_ _targetColsIoriginalTree _sourceIoriginalTree
-                  {-# LINE 10192 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10197 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10202 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetColsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10207 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetColsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10212 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sourceOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10217 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sourceOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10222 "AstInternal.hs" #-}
-              ( _targetColsIannotatedTree,_targetColsIoriginalTree,_targetColsIstrings) =
-                  (targetCols_ _targetColsOcat _targetColsOlib )
-              ( _sourceIannotatedTree,_sourceIoriginalTree) =
-                  (source_ _sourceOcat _sourceOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CopyData :: Annotation ->
-                          String ->
-                          T_Statement 
-sem_Statement_CopyData ann_ insData_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10243 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10248 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CopyData ann_ insData_
-                  {-# LINE 10253 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CopyData ann_ insData_
-                  {-# LINE 10258 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10263 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10268 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateDomain :: Annotation ->
-                              String ->
-                              T_TypeName  ->
-                              String ->
-                              T_MaybeBoolExpression  ->
-                              T_Statement 
-sem_Statement_CreateDomain ann_ name_ typ_ checkName_ check_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _checkOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _checkOcat :: Catalog
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              _checkIannotatedTree :: MaybeBoolExpression
-              _checkIoriginalTree :: MaybeBoolExpression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 10303 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 10308 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 10313 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10318 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 64, column 9)
-              _tpe =
-                  {-# LINE 64 "./TypeChecking/MiscCreates.ag" #-}
-                  Right $ Pseudo Void
-                  {-# LINE 10323 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 65, column 9)
-              _backTree =
-                  {-# LINE 65 "./TypeChecking/MiscCreates.ag" #-}
-                  CreateDomain ann_ name_ _typIannotatedTree checkName_ _checkIannotatedTree
-                  {-# LINE 10328 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 66, column 9)
-              _statementType =
-                  {-# LINE 66 "./TypeChecking/MiscCreates.ag" #-}
-                  []
-                  {-# LINE 10333 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 67, column 9)
-              _catUpdates =
-                  {-# LINE 67 "./TypeChecking/MiscCreates.ag" #-}
-                  [CatCreateDomain (DomainType name_) _typInamedType]
-                  {-# LINE 10338 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 69, column 9)
-              _checkOlib =
-                  {-# LINE 69 "./TypeChecking/MiscCreates.ag" #-}
-                  fromRight _lhsIlib $
-                  updateBindings _lhsIlib _lhsIcat
-                    [LibStackIDs [("", [("value", _typInamedType)])]]
-                  {-# LINE 10345 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateDomain ann_ name_ _typIannotatedTree checkName_ _checkIannotatedTree
-                  {-# LINE 10350 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateDomain ann_ name_ _typIoriginalTree checkName_ _checkIoriginalTree
-                  {-# LINE 10355 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10360 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10365 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10370 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _checkOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10375 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-              ( _checkIannotatedTree,_checkIoriginalTree) =
-                  (check_ _checkOcat _checkOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateFunction :: Annotation ->
-                                String ->
-                                T_ParamDefList  ->
-                                T_TypeName  ->
-                                T_Language  ->
-                                String ->
-                                T_FnBody  ->
-                                T_Volatility  ->
-                                T_Statement 
-sem_Statement_CreateFunction ann_ name_ params_ rettype_ lang_ bodyQuote_ body_ vol_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _bodyOcat :: Catalog
-              _bodyOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _paramsOcat :: Catalog
-              _paramsOlib :: LocalIdentifierBindings
-              _rettypeOcat :: Catalog
-              _rettypeOlib :: LocalIdentifierBindings
-              _langOcat :: Catalog
-              _langOlib :: LocalIdentifierBindings
-              _volOcat :: Catalog
-              _volOlib :: LocalIdentifierBindings
-              _paramsIannotatedTree :: ParamDefList
-              _paramsIoriginalTree :: ParamDefList
-              _paramsIparams :: ([(String, Type)])
-              _rettypeIannotatedTree :: TypeName
-              _rettypeInamedType :: Type
-              _rettypeIoriginalTree :: TypeName
-              _langIannotatedTree :: Language
-              _langIoriginalTree :: Language
-              _bodyIannotatedTree :: FnBody
-              _bodyIoriginalTree :: FnBody
-              _volIannotatedTree :: Volatility
-              _volIoriginalTree :: Volatility
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 10430 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 10435 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 10440 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10445 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 23, column 9)
-              _tpe =
-                  {-# LINE 23 "./TypeChecking/CreateFunction.ag" #-}
-                  dependsOnRTpe
-                    (_rettypeInamedType : _parameterTypes    ) $
-                    Right $ Pseudo Void
-                  {-# LINE 10452 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 26, column 9)
-              _catUpdates =
-                  {-# LINE 26 "./TypeChecking/CreateFunction.ag" #-}
-                  dependsOn [tpeToT _tpe    ] []
-                            [CatCreateFunction FunName
-                                               (map toLower name_)
-                                               _parameterTypes
-                                               _rettypeInamedType
-                                               False]
-                  {-# LINE 10462 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 32, column 9)
-              _parameterTypes =
-                  {-# LINE 32 "./TypeChecking/CreateFunction.ag" #-}
-                  (map snd _paramsIparams)
-                  {-# LINE 10467 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 34, column 9)
-              _backTree =
-                  {-# LINE 34 "./TypeChecking/CreateFunction.ag" #-}
-                  CreateFunction ann_
-                                 name_
-                                 _paramsIannotatedTree
-                                 _rettypeIannotatedTree
-                                 _langIannotatedTree
-                                 bodyQuote_
-                                 _bodyIannotatedTree
-                                 _volIannotatedTree
-                  {-# LINE 10479 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 42, column 9)
-              _statementType =
-                  {-# LINE 42 "./TypeChecking/CreateFunction.ag" #-}
-                  []
-                  {-# LINE 10484 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 43, column 9)
-              _bodyOcat =
-                  {-# LINE 43 "./TypeChecking/CreateFunction.ag" #-}
-                  _lhsIinProducedCat
-                  {-# LINE 10489 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateFunction.ag"(line 99, column 9)
-              _bodyOlib =
-                  {-# LINE 99 "./TypeChecking/CreateFunction.ag" #-}
-                  let p = _paramsIparams
-                          ++ (zip posNames $ map snd _paramsIparams)
-                  in fromRight _lhsIlib $
-                     updateBindings _lhsIlib _lhsIcat
-                                    [LibStackIDs [("", p)
-                                                 ,(name_, _paramsIparams)]]
-                  where
-                    posNames :: [String]
-                    posNames = map (\l -> '$':show l) [1..]
-                  {-# LINE 10502 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateFunction ann_ name_ _paramsIannotatedTree _rettypeIannotatedTree _langIannotatedTree bodyQuote_ _bodyIannotatedTree _volIannotatedTree
-                  {-# LINE 10507 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateFunction ann_ name_ _paramsIoriginalTree _rettypeIoriginalTree _langIoriginalTree bodyQuote_ _bodyIoriginalTree _volIoriginalTree
-                  {-# LINE 10512 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10517 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _paramsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10522 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _paramsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10527 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _rettypeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10532 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _rettypeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10537 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _langOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10542 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _langOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10547 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _volOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10552 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _volOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10557 "AstInternal.hs" #-}
-              ( _paramsIannotatedTree,_paramsIoriginalTree,_paramsIparams) =
-                  (params_ _paramsOcat _paramsOlib )
-              ( _rettypeIannotatedTree,_rettypeInamedType,_rettypeIoriginalTree) =
-                  (rettype_ _rettypeOcat _rettypeOlib )
-              ( _langIannotatedTree,_langIoriginalTree) =
-                  (lang_ _langOcat _langOlib )
-              ( _bodyIannotatedTree,_bodyIoriginalTree) =
-                  (body_ _bodyOcat _bodyOlib )
-              ( _volIannotatedTree,_volIoriginalTree) =
-                  (vol_ _volOcat _volOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateLanguage :: Annotation ->
-                                String ->
-                                T_Statement 
-sem_Statement_CreateLanguage ann_ name_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 10590 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 10595 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 10600 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10605 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 75, column 9)
-              _tpe =
-                  {-# LINE 75 "./TypeChecking/MiscCreates.ag" #-}
-                  Right $ Pseudo Void
-                  {-# LINE 10610 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 76, column 9)
-              _backTree =
-                  {-# LINE 76 "./TypeChecking/MiscCreates.ag" #-}
-                  CreateLanguage ann_ name_
-                  {-# LINE 10615 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 77, column 9)
-              _statementType =
-                  {-# LINE 77 "./TypeChecking/MiscCreates.ag" #-}
-                  []
-                  {-# LINE 10620 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 78, column 9)
-              _catUpdates =
-                  {-# LINE 78 "./TypeChecking/MiscCreates.ag" #-}
-                  [CatCreateFunction FunName "plpgsql_call_handler" [] (Pseudo LanguageHandler) False
-                  ,CatCreateFunction FunName "plpgsql_validator" [ScalarType "oid"] (Pseudo Void) False]
-                  {-# LINE 10626 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateLanguage ann_ name_
-                  {-# LINE 10631 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateLanguage ann_ name_
-                  {-# LINE 10636 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10641 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateSequence :: Annotation ->
-                                String ->
-                                Integer ->
-                                Integer ->
-                                Integer ->
-                                Integer ->
-                                Integer ->
-                                T_Statement 
-sem_Statement_CreateSequence ann_ name_ incr_ min_ max_ start_ cache_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10663 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10668 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10673 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateSequence ann_ name_ incr_ min_ max_ start_ cache_
-                  {-# LINE 10678 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateSequence ann_ name_ incr_ min_ max_ start_ cache_
-                  {-# LINE 10683 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10688 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10693 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateTable :: Annotation ->
-                             String ->
-                             T_AttributeDefList  ->
-                             T_ConstraintList  ->
-                             T_Statement 
-sem_Statement_CreateTable ann_ name_ atts_ cons_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _attrTypes :: ([Type])
-              _consOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _attsOcat :: Catalog
-              _attsOlib :: LocalIdentifierBindings
-              _consOcat :: Catalog
-              _attsIannotatedTree :: AttributeDefList
-              _attsIattrs :: ([(String, Type)])
-              _attsIoriginalTree :: AttributeDefList
-              _consIannotatedTree :: ConstraintList
-              _consIoriginalTree :: ConstraintList
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 10728 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 10733 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 10738 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10743 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 25, column 9)
-              _tpe =
-                  {-# LINE 25 "./TypeChecking/CreateTable.ag" #-}
-                  dependsOnRTpe _attrTypes     $ Right $ Pseudo Void
-                  {-# LINE 10748 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 26, column 9)
-              _catUpdates =
-                  {-# LINE 26 "./TypeChecking/CreateTable.ag" #-}
-                  dependsOn _attrTypes     []
-                    [CatCreateTable name_ _attsIattrs defaultSystemColumns]
-                  {-# LINE 10754 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 29, column 9)
-              _attrTypes =
-                  {-# LINE 29 "./TypeChecking/CreateTable.ag" #-}
-                  map snd _attsIattrs
-                  {-# LINE 10759 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 31, column 9)
-              _statementType =
-                  {-# LINE 31 "./TypeChecking/CreateTable.ag" #-}
-                  []
-                  {-# LINE 10764 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 32, column 9)
-              _backTree =
-                  {-# LINE 32 "./TypeChecking/CreateTable.ag" #-}
-                  CreateTable ann_
-                              name_
-                              _attsIannotatedTree
-                              _consIannotatedTree
-                  {-# LINE 10772 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 36, column 9)
-              _consOlib =
-                  {-# LINE 36 "./TypeChecking/CreateTable.ag" #-}
-                  case updateBindings _lhsIlib _lhsIcat
-                    [LibStackIDs [("", _attsIattrs)]] of
-                     Left x -> error $ show x
-                     Right e -> e
-                  {-# LINE 10780 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTable ann_ name_ _attsIannotatedTree _consIannotatedTree
-                  {-# LINE 10785 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTable ann_ name_ _attsIoriginalTree _consIoriginalTree
-                  {-# LINE 10790 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10795 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10800 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10805 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _consOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10810 "AstInternal.hs" #-}
-              ( _attsIannotatedTree,_attsIattrs,_attsIoriginalTree) =
-                  (atts_ _attsOcat _attsOlib )
-              ( _consIannotatedTree,_consIoriginalTree) =
-                  (cons_ _consOcat _consOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateTableAs :: Annotation ->
-                               String ->
-                               T_SelectExpression  ->
-                               T_Statement 
-sem_Statement_CreateTableAs ann_ name_ expr_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: SelectExpression
-              _exprIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _exprIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 10843 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 10848 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 10853 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10858 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 53, column 9)
-              _tpe =
-                  {-# LINE 53 "./TypeChecking/CreateTable.ag" #-}
-                  dependsOnRTpe [_selType    ] $ do
-                    _attrs
-                    Right _selType
-                  {-# LINE 10865 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 57, column 9)
-              _catUpdates =
-                  {-# LINE 57 "./TypeChecking/CreateTable.ag" #-}
-                  leftToEmpty (\as -> [CatCreateTable name_ as defaultSystemColumns]) $ do
-                     ats <- _attrs
-                     return $ dependsOn (tpeToT _tpe     :
-                                         (map snd ats)) [] ats
-                  {-# LINE 10873 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 63, column 9)
-              _selType =
-                  {-# LINE 63 "./TypeChecking/CreateTable.ag" #-}
-                  getTypeAnnotation _exprIannotatedTree
-                  {-# LINE 10878 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 65, column 9)
-              _attrs =
-                  {-# LINE 65 "./TypeChecking/CreateTable.ag" #-}
-                  unwrapSetOfComposite _selType
-                  {-# LINE 10883 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 67, column 9)
-              _backTree =
-                  {-# LINE 67 "./TypeChecking/CreateTable.ag" #-}
-                  CreateTableAs ann_ name_ _exprIannotatedTree
-                  {-# LINE 10888 "AstInternal.hs" #-}
-              -- "./TypeChecking/CreateTable.ag"(line 68, column 9)
-              _statementType =
-                  {-# LINE 68 "./TypeChecking/CreateTable.ag" #-}
-                  []
-                  {-# LINE 10893 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTableAs ann_ name_ _exprIannotatedTree
-                  {-# LINE 10898 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTableAs ann_ name_ _exprIoriginalTree
-                  {-# LINE 10903 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10908 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10913 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10918 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIlibUpdates,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateTrigger :: Annotation ->
-                               String ->
-                               T_TriggerWhen  ->
-                               ([TriggerEvent]) ->
-                               String ->
-                               T_TriggerFire  ->
-                               String ->
-                               ([Expression]) ->
-                               T_Statement 
-sem_Statement_CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ fnArgs_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _whOcat :: Catalog
-              _whOlib :: LocalIdentifierBindings
-              _firingOcat :: Catalog
-              _firingOlib :: LocalIdentifierBindings
-              _whIannotatedTree :: TriggerWhen
-              _whIoriginalTree :: TriggerWhen
-              _firingIannotatedTree :: TriggerFire
-              _firingIoriginalTree :: TriggerFire
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10951 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 10956 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTrigger ann_ name_ _whIannotatedTree events_ tbl_ _firingIannotatedTree fnName_ fnArgs_
-                  {-# LINE 10961 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateTrigger ann_ name_ _whIoriginalTree events_ tbl_ _firingIoriginalTree fnName_ fnArgs_
-                  {-# LINE 10966 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 10971 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 10976 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _whOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10981 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _whOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10986 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _firingOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 10991 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _firingOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 10996 "AstInternal.hs" #-}
-              ( _whIannotatedTree,_whIoriginalTree) =
-                  (wh_ _whOcat _whOlib )
-              ( _firingIannotatedTree,_firingIoriginalTree) =
-                  (firing_ _firingOcat _firingOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateType :: Annotation ->
-                            String ->
-                            T_TypeAttributeDefList  ->
-                            T_Statement 
-sem_Statement_CreateType ann_ name_ atts_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _attsOcat :: Catalog
-              _attsOlib :: LocalIdentifierBindings
-              _attsIannotatedTree :: TypeAttributeDefList
-              _attsIattrs :: ([(String, Type)])
-              _attsIoriginalTree :: TypeAttributeDefList
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11029 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11034 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11039 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11044 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 51, column 9)
-              _tpe =
-                  {-# LINE 51 "./TypeChecking/MiscCreates.ag" #-}
-                  Right $ Pseudo Void
-                  {-# LINE 11049 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 52, column 9)
-              _backTree =
-                  {-# LINE 52 "./TypeChecking/MiscCreates.ag" #-}
-                  CreateType ann_ name_ _attsIannotatedTree
-                  {-# LINE 11054 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 53, column 9)
-              _statementType =
-                  {-# LINE 53 "./TypeChecking/MiscCreates.ag" #-}
-                  []
-                  {-# LINE 11059 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 54, column 9)
-              _catUpdates =
-                  {-# LINE 54 "./TypeChecking/MiscCreates.ag" #-}
-                  [CatCreateComposite name_ _attsIattrs]
-                  {-# LINE 11064 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateType ann_ name_ _attsIannotatedTree
-                  {-# LINE 11069 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateType ann_ name_ _attsIoriginalTree
-                  {-# LINE 11074 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11079 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11084 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _attsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11089 "AstInternal.hs" #-}
-              ( _attsIannotatedTree,_attsIattrs,_attsIoriginalTree) =
-                  (atts_ _attsOcat _attsOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_CreateView :: Annotation ->
-                            String ->
-                            T_SelectExpression  ->
-                            T_Statement 
-sem_Statement_CreateView ann_ name_ expr_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: SelectExpression
-              _exprIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _exprIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11120 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11125 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11130 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11135 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 15, column 9)
-              _tpe =
-                  {-# LINE 15 "./TypeChecking/MiscCreates.ag" #-}
-                  dependsOnRTpe [getTypeAnnotation _exprIannotatedTree] $
-                    Right $ Pseudo Void
-                  {-# LINE 11141 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 17, column 9)
-              _backTree =
-                  {-# LINE 17 "./TypeChecking/MiscCreates.ag" #-}
-                  CreateView ann_ name_ _exprIannotatedTree
-                  {-# LINE 11146 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 18, column 9)
-              _attrs =
-                  {-# LINE 18 "./TypeChecking/MiscCreates.ag" #-}
-                  case getTypeAnnotation _exprIannotatedTree of
-                    SetOfType (CompositeType c) -> c
-                    _ -> []
-                  {-# LINE 11153 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 21, column 9)
-              _catUpdates =
-                  {-# LINE 21 "./TypeChecking/MiscCreates.ag" #-}
-                  [CatCreateView name_ _attrs    ]
-                  {-# LINE 11158 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 22, column 9)
-              _statementType =
-                  {-# LINE 22 "./TypeChecking/MiscCreates.ag" #-}
-                  []
-                  {-# LINE 11163 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateView ann_ name_ _exprIannotatedTree
-                  {-# LINE 11168 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  CreateView ann_ name_ _exprIoriginalTree
-                  {-# LINE 11173 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11178 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11183 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11188 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIlibUpdates,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Delete :: Annotation ->
-                        String ->
-                        T_MaybeBoolExpression  ->
-                        T_MaybeSelectList  ->
-                        T_Statement 
-sem_Statement_Delete ann_ table_ whr_ returning_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _whrOlib :: LocalIdentifierBindings
-              _returningOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _whrOcat :: Catalog
-              _returningOcat :: Catalog
-              _whrIannotatedTree :: MaybeBoolExpression
-              _whrIoriginalTree :: MaybeBoolExpression
-              _returningIannotatedTree :: MaybeSelectList
-              _returningIlistType :: (Maybe [(String,Type)])
-              _returningIoriginalTree :: MaybeSelectList
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11224 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11229 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11234 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11239 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 180, column 9)
-              _tpe =
-                  {-# LINE 180 "./TypeChecking/Dml.ag" #-}
-                  checkRelationExists _lhsIcat table_ >>
-                  Right (Pseudo Void)
-                  {-# LINE 11245 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 183, column 9)
-              _statementType =
-                  {-# LINE 183 "./TypeChecking/Dml.ag" #-}
-                  [StatementType (getPlaceholderTypes _whrIannotatedTree)
-                                 (fromMaybe [] _returningIlistType)]
-                  {-# LINE 11251 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 186, column 9)
-              _backTree =
-                  {-# LINE 186 "./TypeChecking/Dml.ag" #-}
-                  Delete ann_ table_ _whrIannotatedTree _returningIannotatedTree
-                  {-# LINE 11256 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 187, column 9)
-              _catUpdates =
-                  {-# LINE 187 "./TypeChecking/Dml.ag" #-}
-                  []
-                  {-# LINE 11261 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 192, column 9)
-              _lib =
-                  {-# LINE 192 "./TypeChecking/Dml.ag" #-}
-                  fromRight _lhsIlib $ do
-                  columnTypes <- catCompositeAttrs _lhsIcat relationComposites table_
-                  updateBindings _lhsIlib _lhsIcat [LibStackIDs [("", columnTypes)]]
-                  {-# LINE 11268 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 196, column 9)
-              _whrOlib =
-                  {-# LINE 196 "./TypeChecking/Dml.ag" #-}
-                  _lib
-                  {-# LINE 11273 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 197, column 9)
-              _returningOlib =
-                  {-# LINE 197 "./TypeChecking/Dml.ag" #-}
-                  _lib
-                  {-# LINE 11278 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Delete ann_ table_ _whrIannotatedTree _returningIannotatedTree
-                  {-# LINE 11283 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Delete ann_ table_ _whrIoriginalTree _returningIoriginalTree
-                  {-# LINE 11288 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11293 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _whrOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11298 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _returningOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11303 "AstInternal.hs" #-}
-              ( _whrIannotatedTree,_whrIoriginalTree) =
-                  (whr_ _whrOcat _whrOlib )
-              ( _returningIannotatedTree,_returningIlistType,_returningIoriginalTree) =
-                  (returning_ _returningOcat _returningOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_DropFunction :: Annotation ->
-                              T_IfExists  ->
-                              T_StringTypeNameListPairList  ->
-                              T_Cascade  ->
-                              T_Statement 
-sem_Statement_DropFunction ann_ ifE_ sigs_ cascade_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _ifEOcat :: Catalog
-              _ifEOlib :: LocalIdentifierBindings
-              _sigsOcat :: Catalog
-              _sigsOlib :: LocalIdentifierBindings
-              _cascadeOcat :: Catalog
-              _cascadeOlib :: LocalIdentifierBindings
-              _ifEIannotatedTree :: IfExists
-              _ifEIoriginalTree :: IfExists
-              _sigsIannotatedTree :: StringTypeNameListPairList
-              _sigsIfnSigs :: ([(String,[Type])])
-              _sigsIoriginalTree :: StringTypeNameListPairList
-              _cascadeIannotatedTree :: Cascade
-              _cascadeIoriginalTree :: Cascade
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11345 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11350 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11355 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11360 "AstInternal.hs" #-}
-              -- "./TypeChecking/Drops.ag"(line 10, column 9)
-              _tpe =
-                  {-# LINE 10 "./TypeChecking/Drops.ag" #-}
-                  Right $ Pseudo Void
-                  {-# LINE 11365 "AstInternal.hs" #-}
-              -- "./TypeChecking/Drops.ag"(line 11, column 9)
-              _backTree =
-                  {-# LINE 11 "./TypeChecking/Drops.ag" #-}
-                  DropFunction ann_ _ifEIannotatedTree _sigsIannotatedTree _cascadeIannotatedTree
-                  {-# LINE 11370 "AstInternal.hs" #-}
-              -- "./TypeChecking/Drops.ag"(line 12, column 9)
-              _catUpdates =
-                  {-# LINE 12 "./TypeChecking/Drops.ag" #-}
-                  flip map _sigsIfnSigs $ \(nm,args) ->
-                        CatDropFunction ifE nm args
-                  where
-                    ifE = _ifEIannotatedTree == IfExists
-                  {-# LINE 11378 "AstInternal.hs" #-}
-              -- "./TypeChecking/Drops.ag"(line 16, column 9)
-              _statementType =
-                  {-# LINE 16 "./TypeChecking/Drops.ag" #-}
-                  []
-                  {-# LINE 11383 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  DropFunction ann_ _ifEIannotatedTree _sigsIannotatedTree _cascadeIannotatedTree
-                  {-# LINE 11388 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  DropFunction ann_ _ifEIoriginalTree _sigsIoriginalTree _cascadeIoriginalTree
-                  {-# LINE 11393 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11398 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ifEOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11403 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ifEOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11408 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sigsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11413 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _sigsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11418 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11423 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11428 "AstInternal.hs" #-}
-              ( _ifEIannotatedTree,_ifEIoriginalTree) =
-                  (ifE_ _ifEOcat _ifEOlib )
-              ( _sigsIannotatedTree,_sigsIfnSigs,_sigsIoriginalTree) =
-                  (sigs_ _sigsOcat _sigsOlib )
-              ( _cascadeIannotatedTree,_cascadeIoriginalTree) =
-                  (cascade_ _cascadeOcat _cascadeOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_DropSomething :: Annotation ->
-                               T_DropType  ->
-                               T_IfExists  ->
-                               T_StringList  ->
-                               T_Cascade  ->
-                               T_Statement 
-sem_Statement_DropSomething ann_ dropType_ ifE_ names_ cascade_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _dropTypeOcat :: Catalog
-              _dropTypeOlib :: LocalIdentifierBindings
-              _ifEOcat :: Catalog
-              _ifEOlib :: LocalIdentifierBindings
-              _namesOcat :: Catalog
-              _namesOlib :: LocalIdentifierBindings
-              _cascadeOcat :: Catalog
-              _cascadeOlib :: LocalIdentifierBindings
-              _dropTypeIannotatedTree :: DropType
-              _dropTypeIoriginalTree :: DropType
-              _ifEIannotatedTree :: IfExists
-              _ifEIoriginalTree :: IfExists
-              _namesIannotatedTree :: StringList
-              _namesIoriginalTree :: StringList
-              _namesIstrings :: ([String])
-              _cascadeIannotatedTree :: Cascade
-              _cascadeIoriginalTree :: Cascade
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11471 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11476 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  DropSomething ann_ _dropTypeIannotatedTree _ifEIannotatedTree _namesIannotatedTree _cascadeIannotatedTree
-                  {-# LINE 11481 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  DropSomething ann_ _dropTypeIoriginalTree _ifEIoriginalTree _namesIoriginalTree _cascadeIoriginalTree
-                  {-# LINE 11486 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 11491 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11496 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _dropTypeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11501 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _dropTypeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11506 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ifEOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11511 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _ifEOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11516 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _namesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11521 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _namesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11526 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11531 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11536 "AstInternal.hs" #-}
-              ( _dropTypeIannotatedTree,_dropTypeIoriginalTree) =
-                  (dropType_ _dropTypeOcat _dropTypeOlib )
-              ( _ifEIannotatedTree,_ifEIoriginalTree) =
-                  (ifE_ _ifEOcat _ifEOlib )
-              ( _namesIannotatedTree,_namesIoriginalTree,_namesIstrings) =
-                  (names_ _namesOcat _namesOlib )
-              ( _cascadeIannotatedTree,_cascadeIoriginalTree) =
-                  (cascade_ _cascadeOcat _cascadeOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Execute :: Annotation ->
-                         T_Expression  ->
-                         T_Statement 
-sem_Statement_Execute ann_ expr_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11566 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11571 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Execute ann_ _exprIannotatedTree
-                  {-# LINE 11576 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Execute ann_ _exprIoriginalTree
-                  {-# LINE 11581 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 11586 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11591 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11596 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11601 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ExecuteInto :: Annotation ->
-                             T_Expression  ->
-                             T_StringList  ->
-                             T_Statement 
-sem_Statement_ExecuteInto ann_ expr_ targets_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _targetsOcat :: Catalog
-              _targetsOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              _targetsIannotatedTree :: StringList
-              _targetsIoriginalTree :: StringList
-              _targetsIstrings :: ([String])
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11631 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11636 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ExecuteInto ann_ _exprIannotatedTree _targetsIannotatedTree
-                  {-# LINE 11641 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ExecuteInto ann_ _exprIoriginalTree _targetsIoriginalTree
-                  {-# LINE 11646 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 11651 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11656 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11661 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11666 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11671 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11676 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-              ( _targetsIannotatedTree,_targetsIoriginalTree,_targetsIstrings) =
-                  (targets_ _targetsOcat _targetsOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ForIntegerStatement :: Annotation ->
-                                     String ->
-                                     T_Expression  ->
-                                     T_Expression  ->
-                                     T_StatementList  ->
-                                     T_Statement 
-sem_Statement_ForIntegerStatement ann_ var_ from_ to_ sts_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _stsOcatUpdates :: ([CatalogUpdate])
-              _stsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _stsOlib :: LocalIdentifierBindings
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _fromOcat :: Catalog
-              _fromOlib :: LocalIdentifierBindings
-              _toOcat :: Catalog
-              _toOlib :: LocalIdentifierBindings
-              _stsOcat :: Catalog
-              _fromIannotatedTree :: Expression
-              _fromIliftedColumnName :: String
-              _fromIoriginalTree :: Expression
-              _toIannotatedTree :: Expression
-              _toIliftedColumnName :: String
-              _toIoriginalTree :: Expression
-              _stsIannotatedTree :: StatementList
-              _stsIoriginalTree :: StatementList
-              _stsIproducedCat :: Catalog
-              _stsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11724 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11729 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11734 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11739 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 110, column 9)
-              _stsOcatUpdates =
-                  {-# LINE 110 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11744 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 111, column 9)
-              _stsOlibUpdates =
-                  {-# LINE 111 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11749 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 36, column 9)
-              _varTypeE =
-                  {-# LINE 36 "./TypeChecking/Plpgsql.ag" #-}
-                  libLookupID _lhsIlib var_
-                  {-# LINE 11754 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 37, column 9)
-              _tpe =
-                  {-# LINE 37 "./TypeChecking/Plpgsql.ag" #-}
-                  do
-                  let fromType = getTypeAnnotation _fromIannotatedTree
-                      toType = getTypeAnnotation _toIannotatedTree
-                  dependsOnRTpe [fromType,toType] $ do
-                  errorWhen (fromType /= toType) [FromToTypesNotSame fromType toType]
-                  case _varTypeE     of
-                    Right t -> checkAssignmentValid _lhsIcat fromType t
-                    Left _ -> return ()
-                  return $ Pseudo Void
-                  {-# LINE 11767 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 48, column 9)
-              _stsOlib =
-                  {-# LINE 48 "./TypeChecking/Plpgsql.ag" #-}
-                  case _varTypeE     of
-                    Left [UnrecognisedIdentifier var_] ->
-                        fromRight _lhsIlib $
-                        updateBindings _lhsIlib _lhsIcat
-                                       [LibStackIDs [("", [(var_,getTypeAnnotation _fromIannotatedTree)])]]
-                    _ -> _lhsIlib
-                  {-# LINE 11777 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 56, column 9)
-              _backTree =
-                  {-# LINE 56 "./TypeChecking/Plpgsql.ag" #-}
-                  ForIntegerStatement ann_ var_ _fromIannotatedTree _toIannotatedTree _stsIannotatedTree
-                  {-# LINE 11782 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 57, column 9)
-              _catUpdates =
-                  {-# LINE 57 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 11787 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 58, column 9)
-              _statementType =
-                  {-# LINE 58 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 11792 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ForIntegerStatement ann_ var_ _fromIannotatedTree _toIannotatedTree _stsIannotatedTree
-                  {-# LINE 11797 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ForIntegerStatement ann_ var_ _fromIoriginalTree _toIoriginalTree _stsIoriginalTree
-                  {-# LINE 11802 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11807 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fromOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11812 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fromOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11817 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _toOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11822 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _toOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11827 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11832 "AstInternal.hs" #-}
-              ( _fromIannotatedTree,_fromIliftedColumnName,_fromIoriginalTree) =
-                  (from_ _fromOcat _fromOlib )
-              ( _toIannotatedTree,_toIliftedColumnName,_toIoriginalTree) =
-                  (to_ _toOcat _toOlib )
-              ( _stsIannotatedTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
-                  (sts_ _stsOcat _stsOcatUpdates _stsOlib _stsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ForSelectStatement :: Annotation ->
-                                    String ->
-                                    T_SelectExpression  ->
-                                    T_StatementList  ->
-                                    T_Statement 
-sem_Statement_ForSelectStatement ann_ var_ sel_ sts_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _stsOcatUpdates :: ([CatalogUpdate])
-              _stsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _stsOlib :: LocalIdentifierBindings
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _stsOcat :: Catalog
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              _stsIannotatedTree :: StatementList
-              _stsIoriginalTree :: StatementList
-              _stsIproducedCat :: Catalog
-              _stsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 11876 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 11881 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 11886 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11891 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 110, column 9)
-              _stsOcatUpdates =
-                  {-# LINE 110 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11896 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 111, column 9)
-              _stsOlibUpdates =
-                  {-# LINE 111 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 11901 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 63, column 9)
-              _selType =
-                  {-# LINE 63 "./TypeChecking/Plpgsql.ag" #-}
-                  getTypeAnnotation _selIannotatedTree
-                  {-# LINE 11906 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 64, column 9)
-              _tpe =
-                  {-# LINE 64 "./TypeChecking/Plpgsql.ag" #-}
-                  do
-                  dependsOnRTpe [_selType    ] $ do
-                  toType <- libLookupID _lhsIlib var_
-                  dependsOnRTpe [toType] $ do
-                  checkAssignmentValid _lhsIcat _selType     toType
-                  return $ Pseudo Void
-                  {-# LINE 11916 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 75, column 9)
-              _stsOlib =
-                  {-# LINE 75 "./TypeChecking/Plpgsql.ag" #-}
-                  if okToUpdate
-                    then fromRight _lhsIlib $
-                         updateBindings _lhsIlib _lhsIcat [LibStackIDs [("", [(var_,_selType    )])]]
-                    else _lhsIlib
-                  where
-                    okToUpdate = isRight _tpe     && _selType     /= TypeCheckFailed
-                  {-# LINE 11926 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 84, column 9)
-              _backTree =
-                  {-# LINE 84 "./TypeChecking/Plpgsql.ag" #-}
-                  ForSelectStatement ann_ var_ _selIannotatedTree _stsIannotatedTree
-                  {-# LINE 11931 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 85, column 9)
-              _catUpdates =
-                  {-# LINE 85 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 11936 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 86, column 9)
-              _statementType =
-                  {-# LINE 86 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 11941 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ForSelectStatement ann_ var_ _selIannotatedTree _stsIannotatedTree
-                  {-# LINE 11946 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ForSelectStatement ann_ var_ _selIoriginalTree _stsIoriginalTree
-                  {-# LINE 11951 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 11956 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11961 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 11966 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 11971 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-              ( _stsIannotatedTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
-                  (sts_ _stsOcat _stsOcatUpdates _stsOlib _stsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_If :: Annotation ->
-                    T_ExpressionStatementListPairList  ->
-                    T_StatementList  ->
-                    T_Statement 
-sem_Statement_If ann_ cases_ els_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _elsOcatUpdates :: ([CatalogUpdate])
-              _elsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _casesOcat :: Catalog
-              _casesOlib :: LocalIdentifierBindings
-              _elsOcat :: Catalog
-              _elsOlib :: LocalIdentifierBindings
-              _casesIannotatedTree :: ExpressionStatementListPairList
-              _casesIoriginalTree :: ExpressionStatementListPairList
-              _elsIannotatedTree :: StatementList
-              _elsIoriginalTree :: StatementList
-              _elsIproducedCat :: Catalog
-              _elsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12005 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12010 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 106, column 9)
-              _elsOcatUpdates =
-                  {-# LINE 106 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12015 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 107, column 9)
-              _elsOlibUpdates =
-                  {-# LINE 107 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12020 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  If ann_ _casesIannotatedTree _elsIannotatedTree
-                  {-# LINE 12025 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  If ann_ _casesIoriginalTree _elsIoriginalTree
-                  {-# LINE 12030 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12035 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12040 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12045 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _casesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12050 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12055 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _elsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12060 "AstInternal.hs" #-}
-              ( _casesIannotatedTree,_casesIoriginalTree) =
-                  (cases_ _casesOcat _casesOlib )
-              ( _elsIannotatedTree,_elsIoriginalTree,_elsIproducedCat,_elsIproducedLib) =
-                  (els_ _elsOcat _elsOcatUpdates _elsOlib _elsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Insert :: Annotation ->
-                        String ->
-                        T_StringList  ->
-                        T_SelectExpression  ->
-                        T_MaybeSelectList  ->
-                        T_Statement 
-sem_Statement_Insert ann_ table_ targetCols_ insData_ returning_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _returningOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _targetColsOcat :: Catalog
-              _targetColsOlib :: LocalIdentifierBindings
-              _insDataOcat :: Catalog
-              _insDataOlib :: LocalIdentifierBindings
-              _returningOcat :: Catalog
-              _targetColsIannotatedTree :: StringList
-              _targetColsIoriginalTree :: StringList
-              _targetColsIstrings :: ([String])
-              _insDataIannotatedTree :: SelectExpression
-              _insDataIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _insDataIoriginalTree :: SelectExpression
-              _returningIannotatedTree :: MaybeSelectList
-              _returningIlistType :: (Maybe [(String,Type)])
-              _returningIoriginalTree :: MaybeSelectList
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 12105 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 12110 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 12115 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12120 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 18, column 9)
-              _tpe =
-                  {-# LINE 18 "./TypeChecking/Dml.ag" #-}
-                  dependsOnRTpe [getTypeAnnotation _insDataIannotatedTree] $ do
-                    _columnTypes
-                    Right $ Pseudo Void
-                  {-# LINE 12127 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 22, column 9)
-              _statementType =
-                  {-# LINE 22 "./TypeChecking/Dml.ag" #-}
-                  leftToEmpty (\ct -> [StatementType (getPlaceholderTypes _insDataAddedInferredTypes    ) (fromMaybe [] _returningIlistType)]) _columnTypes
-                  {-# LINE 12132 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 25, column 9)
-              _columnTypes =
-                  {-# LINE 25 "./TypeChecking/Dml.ag" #-}
-                  do
-                  tys <- unwrapSetOfComposite $
-                         getTypeAnnotation _insDataIannotatedTree
-                  checkColumnConsistency _lhsIcat
-                                         table_
-                                         _targetColsIstrings
-                                         tys
-                  {-# LINE 12143 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 33, column 9)
-              _insDataAddedInferredTypes =
-                  {-# LINE 33 "./TypeChecking/Dml.ag" #-}
-                  case _insDataIannotatedTree of
-                    Values ann [exl] ->
-                        let fargs = map snd (fromRight [] _columnTypes    ) ++ repeat TypeCheckFailed
-                            newExl = map (\(ex,ty) -> updateAnnotation (++ [InferredType ty]) ex) $ zip exl fargs
-                        in Values ann [newExl]
-                    x -> x
-                  {-# LINE 12153 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 41, column 9)
-              _backTree =
-                  {-# LINE 41 "./TypeChecking/Dml.ag" #-}
-                  Insert ann_ table_ _targetColsIannotatedTree
-                         _insDataAddedInferredTypes     _returningIannotatedTree
-                  {-# LINE 12159 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 43, column 9)
-              _catUpdates =
-                  {-# LINE 43 "./TypeChecking/Dml.ag" #-}
-                  []
-                  {-# LINE 12164 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 49, column 9)
-              _returningOlib =
-                  {-# LINE 49 "./TypeChecking/Dml.ag" #-}
-                  fromRight _lhsIlib $ do
-                    atts <- catCompositeAttrs _lhsIcat relationComposites table_
-                    updateBindings _lhsIlib _lhsIcat [LibStackIDs [("", atts)]]
-                  {-# LINE 12171 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Insert ann_ table_ _targetColsIannotatedTree _insDataIannotatedTree _returningIannotatedTree
-                  {-# LINE 12176 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Insert ann_ table_ _targetColsIoriginalTree _insDataIoriginalTree _returningIoriginalTree
-                  {-# LINE 12181 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12186 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetColsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12191 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _targetColsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12196 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _insDataOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12201 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _insDataOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12206 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _returningOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12211 "AstInternal.hs" #-}
-              ( _targetColsIannotatedTree,_targetColsIoriginalTree,_targetColsIstrings) =
-                  (targetCols_ _targetColsOcat _targetColsOlib )
-              ( _insDataIannotatedTree,_insDataIlibUpdates,_insDataIoriginalTree) =
-                  (insData_ _insDataOcat _insDataOlib )
-              ( _returningIannotatedTree,_returningIlistType,_returningIoriginalTree) =
-                  (returning_ _returningOcat _returningOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Notify :: Annotation ->
-                        String ->
-                        T_Statement 
-sem_Statement_Notify ann_ name_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12234 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12239 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12244 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Notify ann_ name_
-                  {-# LINE 12249 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Notify ann_ name_
-                  {-# LINE 12254 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12259 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12264 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_NullStatement :: Annotation ->
-                               T_Statement 
-sem_Statement_NullStatement ann_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12280 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12285 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  NullStatement ann_
-                  {-# LINE 12290 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  NullStatement ann_
-                  {-# LINE 12295 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12300 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12305 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Perform :: Annotation ->
-                         T_Expression  ->
-                         T_Statement 
-sem_Statement_Perform ann_ expr_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12327 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12332 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Perform ann_ _exprIannotatedTree
-                  {-# LINE 12337 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Perform ann_ _exprIoriginalTree
-                  {-# LINE 12342 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12347 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12352 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12357 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12362 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Raise :: Annotation ->
-                       T_RaiseType  ->
-                       String ->
-                       T_ExpressionList  ->
-                       T_Statement 
-sem_Statement_Raise ann_ level_ message_ args_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _levelOcat :: Catalog
-              _levelOlib :: LocalIdentifierBindings
-              _argsOcat :: Catalog
-              _argsOlib :: LocalIdentifierBindings
-              _levelIannotatedTree :: RaiseType
-              _levelIoriginalTree :: RaiseType
-              _argsIannotatedTree :: ExpressionList
-              _argsIoriginalTree :: ExpressionList
-              _argsItypeList :: ([Type])
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12392 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12397 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Raise ann_ _levelIannotatedTree message_ _argsIannotatedTree
-                  {-# LINE 12402 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Raise ann_ _levelIoriginalTree message_ _argsIoriginalTree
-                  {-# LINE 12407 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12412 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12417 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _levelOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12422 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _levelOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12427 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12432 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _argsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12437 "AstInternal.hs" #-}
-              ( _levelIannotatedTree,_levelIoriginalTree) =
-                  (level_ _levelOcat _levelOlib )
-              ( _argsIannotatedTree,_argsIoriginalTree,_argsItypeList) =
-                  (args_ _argsOcat _argsOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Return :: Annotation ->
-                        T_MaybeExpression  ->
-                        T_Statement 
-sem_Statement_Return ann_ value_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _valueOcat :: Catalog
-              _valueOlib :: LocalIdentifierBindings
-              _valueIannotatedTree :: MaybeExpression
-              _valueIoriginalTree :: MaybeExpression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 12468 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 12473 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 12478 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12483 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 12, column 9)
-              _tpe =
-                  {-# LINE 12 "./TypeChecking/Plpgsql.ag" #-}
-                  dependsOnRTpe [maybe typeBool
-                                      getTypeAnnotation
-                                      _valueIannotatedTree] $ Right $ Pseudo Void
-                  {-# LINE 12490 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 16, column 9)
-              _backTree =
-                  {-# LINE 16 "./TypeChecking/Plpgsql.ag" #-}
-                  Return ann_ _valueIannotatedTree
-                  {-# LINE 12495 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 17, column 9)
-              _catUpdates =
-                  {-# LINE 17 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 12500 "AstInternal.hs" #-}
-              -- "./TypeChecking/Plpgsql.ag"(line 18, column 9)
-              _statementType =
-                  {-# LINE 18 "./TypeChecking/Plpgsql.ag" #-}
-                  []
-                  {-# LINE 12505 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Return ann_ _valueIannotatedTree
-                  {-# LINE 12510 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Return ann_ _valueIoriginalTree
-                  {-# LINE 12515 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12520 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12525 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _valueOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12530 "AstInternal.hs" #-}
-              ( _valueIannotatedTree,_valueIoriginalTree) =
-                  (value_ _valueOcat _valueOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ReturnNext :: Annotation ->
-                            T_Expression  ->
-                            T_Statement 
-sem_Statement_ReturnNext ann_ expr_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12554 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12559 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ReturnNext ann_ _exprIannotatedTree
-                  {-# LINE 12564 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ReturnNext ann_ _exprIoriginalTree
-                  {-# LINE 12569 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12574 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12579 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12584 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12589 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_ReturnQuery :: Annotation ->
-                             T_SelectExpression  ->
-                             T_Statement 
-sem_Statement_ReturnQuery ann_ sel_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12613 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12618 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ReturnQuery ann_ _selIannotatedTree
-                  {-# LINE 12623 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ReturnQuery ann_ _selIoriginalTree
-                  {-# LINE 12628 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12633 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12638 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12643 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12648 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_SelectStatement :: Annotation ->
-                                 T_SelectExpression  ->
-                                 T_Statement 
-sem_Statement_SelectStatement ann_ ex_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _catUpdates :: ([CatalogUpdate])
-              _lhsOoriginalTree :: Statement
-              _exOcat :: Catalog
-              _exOlib :: LocalIdentifierBindings
-              _exIannotatedTree :: SelectExpression
-              _exIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _exIoriginalTree :: SelectExpression
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 12678 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 12683 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 12688 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 14, column 9)
-              _tpe =
-                  {-# LINE 14 "./TypeChecking/SelectStatement.ag" #-}
-                  dependsOnRTpe [getTypeAnnotation _exIannotatedTree] $ Right $ Pseudo Void
-                  {-# LINE 12693 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 15, column 9)
-              _statementType =
-                  {-# LINE 15 "./TypeChecking/SelectStatement.ag" #-}
-                  [StatementType (getPlaceholderTypes _exIannotatedTree) $ leftToEmpty id  $
-                                      unwrapSetOfComposite $
-                                      getTypeAnnotation _exIannotatedTree]
-                  {-# LINE 12700 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 18, column 9)
-              _backTree =
-                  {-# LINE 18 "./TypeChecking/SelectStatement.ag" #-}
-                  SelectStatement ann_ _exIannotatedTree
-                  {-# LINE 12705 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectStatement.ag"(line 19, column 9)
-              _catUpdates =
-                  {-# LINE 19 "./TypeChecking/SelectStatement.ag" #-}
-                  []
-                  {-# LINE 12710 "AstInternal.hs" #-}
-              -- "./TypeChecking/SelectLists.ag"(line 79, column 9)
-              _libUpdates =
-                  {-# LINE 79 "./TypeChecking/SelectLists.ag" #-}
-                  _exIlibUpdates
-                  {-# LINE 12715 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SelectStatement ann_ _exIannotatedTree
-                  {-# LINE 12720 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SelectStatement ann_ _exIoriginalTree
-                  {-# LINE 12725 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12730 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12735 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12740 "AstInternal.hs" #-}
-              ( _exIannotatedTree,_exIlibUpdates,_exIoriginalTree) =
-                  (ex_ _exOcat _exOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Set :: Annotation ->
-                     String ->
-                     ([SetValue]) ->
-                     T_Statement 
-sem_Statement_Set ann_ name_ values_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12760 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12765 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12770 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Set ann_ name_ values_
-                  {-# LINE 12775 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Set ann_ name_ values_
-                  {-# LINE 12780 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12785 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12790 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Truncate :: Annotation ->
-                          T_StringList  ->
-                          T_RestartIdentity  ->
-                          T_Cascade  ->
-                          T_Statement 
-sem_Statement_Truncate ann_ tables_ restartIdentity_ cascade_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _tablesOcat :: Catalog
-              _tablesOlib :: LocalIdentifierBindings
-              _restartIdentityOcat :: Catalog
-              _restartIdentityOlib :: LocalIdentifierBindings
-              _cascadeOcat :: Catalog
-              _cascadeOlib :: LocalIdentifierBindings
-              _tablesIannotatedTree :: StringList
-              _tablesIoriginalTree :: StringList
-              _tablesIstrings :: ([String])
-              _restartIdentityIannotatedTree :: RestartIdentity
-              _restartIdentityIoriginalTree :: RestartIdentity
-              _cascadeIannotatedTree :: Cascade
-              _cascadeIoriginalTree :: Cascade
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12822 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12827 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Truncate ann_ _tablesIannotatedTree _restartIdentityIannotatedTree _cascadeIannotatedTree
-                  {-# LINE 12832 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Truncate ann_ _tablesIoriginalTree _restartIdentityIoriginalTree _cascadeIoriginalTree
-                  {-# LINE 12837 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 12842 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 12847 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tablesOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12852 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tablesOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12857 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _restartIdentityOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12862 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _restartIdentityOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12867 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 12872 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _cascadeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 12877 "AstInternal.hs" #-}
-              ( _tablesIannotatedTree,_tablesIoriginalTree,_tablesIstrings) =
-                  (tables_ _tablesOcat _tablesOlib )
-              ( _restartIdentityIannotatedTree,_restartIdentityIoriginalTree) =
-                  (restartIdentity_ _restartIdentityOcat _restartIdentityOlib )
-              ( _cascadeIannotatedTree,_cascadeIoriginalTree) =
-                  (cascade_ _cascadeOcat _cascadeOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_Update :: Annotation ->
-                        String ->
-                        T_SetClauseList  ->
-                        T_MaybeBoolExpression  ->
-                        T_MaybeSelectList  ->
-                        T_Statement 
-sem_Statement_Update ann_ table_ assigns_ whr_ returning_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Statement
-              _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tpe :: (Either [TypeError] Type)
-              _assignWInferredTypes :: SetClauseList
-              _catUpdates :: ([CatalogUpdate])
-              _whrOlib :: LocalIdentifierBindings
-              _assignsOlib :: LocalIdentifierBindings
-              _returningOlib :: LocalIdentifierBindings
-              _lhsOoriginalTree :: Statement
-              _assignsOcat :: Catalog
-              _whrOcat :: Catalog
-              _returningOcat :: Catalog
-              _assignsIannotatedTree :: SetClauseList
-              _assignsIoriginalTree :: SetClauseList
-              _assignsIpairs :: ([(String,Type)])
-              _assignsIrowSetErrors :: ([TypeError])
-              _whrIannotatedTree :: MaybeBoolExpression
-              _whrIoriginalTree :: MaybeBoolExpression
-              _returningIannotatedTree :: MaybeSelectList
-              _returningIlistType :: (Maybe [(String,Type)])
-              _returningIoriginalTree :: MaybeSelectList
-              -- "./TypeChecking/Statements.ag"(line 61, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 61 "./TypeChecking/Statements.ag" #-}
-                  annTypesAndErrors _backTree
-                    (tpeToT _tpe    )
-                    (getErrors _tpe    )
-                    $ Just (map StatementTypeA _statementType     ++
-                            [CatUpdates _catUpdates    ])
-                  {-# LINE 12925 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 67, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 67 "./TypeChecking/Statements.ag" #-}
-                  _catUpdates
-                  {-# LINE 12930 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 68, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 68 "./TypeChecking/Statements.ag" #-}
-                  _libUpdates
-                  {-# LINE 12935 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 73, column 9)
-              _libUpdates =
-                  {-# LINE 73 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 12940 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 65, column 9)
-              _tpe =
-                  {-# LINE 65 "./TypeChecking/Dml.ag" #-}
-                  do
-                  checkRelationExists _lhsIcat table_
-                  dependsOnRTpe (map snd _assignsIpairs) $ do
-                    _columnTypes
-                    liftErrors _assignsIrowSetErrors
-                    return $ Pseudo Void
-                  {-# LINE 12950 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 72, column 9)
-              _statementType =
-                  {-# LINE 72 "./TypeChecking/Dml.ag" #-}
-                  leftToEmpty (\ct -> [StatementType (getPlaceholderTypes _assignWInferredTypes
-                                                      ++ getPlaceholderTypes _whrIannotatedTree)
-                                                     (fromMaybe [] _returningIlistType)])
-                     _columnTypes
-                  {-# LINE 12958 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 78, column 9)
-              _columnTypes =
-                  {-# LINE 78 "./TypeChecking/Dml.ag" #-}
-                  checkColumnConsistency _lhsIcat
-                                         table_
-                                         (map fst _assignsIpairs)
-                                         _assignsIpairs
-                  {-# LINE 12966 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 84, column 9)
-              _assignWInferredTypes =
-                  {-# LINE 84 "./TypeChecking/Dml.ag" #-}
-                  let colTypes :: [Type]
-                      colTypes = (map snd $ fromRight [] _columnTypes    )
-                  in setInferredTypesG colTypes _assignsIannotatedTree
-                  {-# LINE 12973 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 89, column 9)
-              _backTree =
-                  {-# LINE 89 "./TypeChecking/Dml.ag" #-}
-                  Update ann_
-                         table_
-                         _assignWInferredTypes
-                         _whrIannotatedTree
-                         _returningIannotatedTree
-                  {-# LINE 12982 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 94, column 9)
-              _catUpdates =
-                  {-# LINE 94 "./TypeChecking/Dml.ag" #-}
-                  []
-                  {-# LINE 12987 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 114, column 9)
-              _lib =
-                  {-# LINE 114 "./TypeChecking/Dml.ag" #-}
-                  fromRight _lhsIlib $ do
-                  ct <- catCompositeAttrs _lhsIcat
-                                          relationComposites
-                                          table_
-                  updateBindings _lhsIlib _lhsIcat [LibStackIDs [("", ct)]]
-                  {-# LINE 12996 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 120, column 9)
-              _whrOlib =
-                  {-# LINE 120 "./TypeChecking/Dml.ag" #-}
-                  _lib
-                  {-# LINE 13001 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 121, column 9)
-              _assignsOlib =
-                  {-# LINE 121 "./TypeChecking/Dml.ag" #-}
-                  _lib
-                  {-# LINE 13006 "AstInternal.hs" #-}
-              -- "./TypeChecking/Dml.ag"(line 122, column 9)
-              _returningOlib =
-                  {-# LINE 122 "./TypeChecking/Dml.ag" #-}
-                  _lib
-                  {-# LINE 13011 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Update ann_ table_ _assignsIannotatedTree _whrIannotatedTree _returningIannotatedTree
-                  {-# LINE 13016 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Update ann_ table_ _assignsIoriginalTree _whrIoriginalTree _returningIoriginalTree
-                  {-# LINE 13021 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13026 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _assignsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13031 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _whrOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13036 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _returningOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13041 "AstInternal.hs" #-}
-              ( _assignsIannotatedTree,_assignsIoriginalTree,_assignsIpairs,_assignsIrowSetErrors) =
-                  (assigns_ _assignsOcat _assignsOlib )
-              ( _whrIannotatedTree,_whrIoriginalTree) =
-                  (whr_ _whrOcat _whrOlib )
-              ( _returningIannotatedTree,_returningIlistType,_returningIoriginalTree) =
-                  (returning_ _returningOcat _returningOlib )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_Statement_WhileStatement :: Annotation ->
-                                T_Expression  ->
-                                T_StatementList  ->
-                                T_Statement 
-sem_Statement_WhileStatement ann_ expr_ sts_  =
-    (\ _lhsIcat
-       _lhsIinProducedCat
-       _lhsIlib ->
-         (let _lhsOcatUpdates :: ([CatalogUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _stsOcatUpdates :: ([CatalogUpdate])
-              _stsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: Statement
-              _lhsOoriginalTree :: Statement
-              _exprOcat :: Catalog
-              _exprOlib :: LocalIdentifierBindings
-              _stsOcat :: Catalog
-              _stsOlib :: LocalIdentifierBindings
-              _exprIannotatedTree :: Expression
-              _exprIliftedColumnName :: String
-              _exprIoriginalTree :: Expression
-              _stsIannotatedTree :: StatementList
-              _stsIoriginalTree :: StatementList
-              _stsIproducedCat :: Catalog
-              _stsIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 89, column 9)
-              _lhsOcatUpdates =
-                  {-# LINE 89 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 13078 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 90, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 90 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 13083 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 110, column 9)
-              _stsOcatUpdates =
-                  {-# LINE 110 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 13088 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 111, column 9)
-              _stsOlibUpdates =
-                  {-# LINE 111 "./TypeChecking/Statements.ag" #-}
-                  []
-                  {-# LINE 13093 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  WhileStatement ann_ _exprIannotatedTree _stsIannotatedTree
-                  {-# LINE 13098 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  WhileStatement ann_ _exprIoriginalTree _stsIoriginalTree
-                  {-# LINE 13103 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13108 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13113 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13118 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _exprOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13123 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13128 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _stsOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13133 "AstInternal.hs" #-}
-              ( _exprIannotatedTree,_exprIliftedColumnName,_exprIoriginalTree) =
-                  (expr_ _exprOcat _exprOlib )
-              ( _stsIannotatedTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
-                  (sts_ _stsOcat _stsOcatUpdates _stsOlib _stsOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOlibUpdates,_lhsOoriginalTree)))
--- StatementList -----------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         catUpdates           : [CatalogUpdate]
-         lib                  : LocalIdentifierBindings
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         producedCat          : Catalog
-         producedLib          : LocalIdentifierBindings
-   alternatives:
-      alternative Cons:
-         child hd             : Statement 
-         child tl             : StatementList 
-         visit 0:
-            local newCat      : _
-            local newLib      : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local newCat      : _
-            local newLib      : _
-            local annotatedTree : _
-            local originalTree : _
--}
-type StatementList  = [(Statement)]
--- cata
-sem_StatementList :: StatementList  ->
-                     T_StatementList 
-sem_StatementList list  =
-    (Prelude.foldr sem_StatementList_Cons sem_StatementList_Nil (Prelude.map sem_Statement list) )
--- semantic domain
-type T_StatementList  = Catalog ->
-                        ([CatalogUpdate]) ->
-                        LocalIdentifierBindings ->
-                        ([LocalIdentifierBindingsUpdate]) ->
-                        ( StatementList,StatementList,Catalog,LocalIdentifierBindings)
-data Inh_StatementList  = Inh_StatementList {cat_Inh_StatementList :: Catalog,catUpdates_Inh_StatementList :: [CatalogUpdate],lib_Inh_StatementList :: LocalIdentifierBindings,libUpdates_Inh_StatementList :: [LocalIdentifierBindingsUpdate]}
-data Syn_StatementList  = Syn_StatementList {annotatedTree_Syn_StatementList :: StatementList,originalTree_Syn_StatementList :: StatementList,producedCat_Syn_StatementList :: Catalog,producedLib_Syn_StatementList :: LocalIdentifierBindings}
-wrap_StatementList :: T_StatementList  ->
-                      Inh_StatementList  ->
-                      Syn_StatementList 
-wrap_StatementList sem (Inh_StatementList _lhsIcat _lhsIcatUpdates _lhsIlib _lhsIlibUpdates )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib) =
-             (sem _lhsIcat _lhsIcatUpdates _lhsIlib _lhsIlibUpdates )
-     in  (Syn_StatementList _lhsOannotatedTree _lhsOoriginalTree _lhsOproducedCat _lhsOproducedLib ))
-sem_StatementList_Cons :: T_Statement  ->
-                          T_StatementList  ->
-                          T_StatementList 
-sem_StatementList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIcatUpdates
-       _lhsIlib
-       _lhsIlibUpdates ->
-         (let _hdOcat :: Catalog
-              _tlOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOlib :: LocalIdentifierBindings
-              _lhsOproducedCat :: Catalog
-              _lhsOproducedLib :: LocalIdentifierBindings
-              _tlOcatUpdates :: ([CatalogUpdate])
-              _tlOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _hdOinProducedCat :: Catalog
-              _lhsOannotatedTree :: StatementList
-              _lhsOoriginalTree :: StatementList
-              _hdIannotatedTree :: Statement
-              _hdIcatUpdates :: ([CatalogUpdate])
-              _hdIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _hdIoriginalTree :: Statement
-              _tlIannotatedTree :: StatementList
-              _tlIoriginalTree :: StatementList
-              _tlIproducedCat :: Catalog
-              _tlIproducedLib :: LocalIdentifierBindings
-              -- "./TypeChecking/Statements.ag"(line 36, column 9)
-              _newCat =
-                  {-# LINE 36 "./TypeChecking/Statements.ag" #-}
-                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
-                  {-# LINE 13220 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 37, column 9)
-              _newLib =
-                  {-# LINE 37 "./TypeChecking/Statements.ag" #-}
-                  fromRight _lhsIlib $ updateBindings _lhsIlib _lhsIcat _lhsIlibUpdates
-                  {-# LINE 13225 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 39, column 9)
-              _hdOcat =
-                  {-# LINE 39 "./TypeChecking/Statements.ag" #-}
-                  _newCat
-                  {-# LINE 13230 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 40, column 9)
-              _tlOcat =
-                  {-# LINE 40 "./TypeChecking/Statements.ag" #-}
-                  _newCat
-                  {-# LINE 13235 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 41, column 9)
-              _hdOlib =
-                  {-# LINE 41 "./TypeChecking/Statements.ag" #-}
-                  _newLib
-                  {-# LINE 13240 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 42, column 9)
-              _tlOlib =
-                  {-# LINE 42 "./TypeChecking/Statements.ag" #-}
-                  _newLib
-                  {-# LINE 13245 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 46, column 9)
-              _lhsOproducedCat =
-                  {-# LINE 46 "./TypeChecking/Statements.ag" #-}
-                  _tlIproducedCat
-                  {-# LINE 13250 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 47, column 9)
-              _lhsOproducedLib =
-                  {-# LINE 47 "./TypeChecking/Statements.ag" #-}
-                  _tlIproducedLib
-                  {-# LINE 13255 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 50, column 9)
-              _tlOcatUpdates =
-                  {-# LINE 50 "./TypeChecking/Statements.ag" #-}
-                  _hdIcatUpdates
-                  {-# LINE 13260 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 51, column 9)
-              _tlOlibUpdates =
-                  {-# LINE 51 "./TypeChecking/Statements.ag" #-}
-                  _hdIlibUpdates
-                  {-# LINE 13265 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 76, column 12)
-              _hdOinProducedCat =
-                  {-# LINE 76 "./TypeChecking/Statements.ag" #-}
-                  _tlIproducedCat
-                  {-# LINE 13270 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 13275 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 13280 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13285 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13290 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIcatUpdates,_hdIlibUpdates,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOinProducedCat _hdOlib )
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlIproducedCat,_tlIproducedLib) =
-                  (tl_ _tlOcat _tlOcatUpdates _tlOlib _tlOlibUpdates )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
-sem_StatementList_Nil :: T_StatementList 
-sem_StatementList_Nil  =
-    (\ _lhsIcat
-       _lhsIcatUpdates
-       _lhsIlib
-       _lhsIlibUpdates ->
-         (let _lhsOproducedCat :: Catalog
-              _lhsOproducedLib :: LocalIdentifierBindings
-              _lhsOannotatedTree :: StatementList
-              _lhsOoriginalTree :: StatementList
-              -- "./TypeChecking/Statements.ag"(line 36, column 9)
-              _newCat =
-                  {-# LINE 36 "./TypeChecking/Statements.ag" #-}
-                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
-                  {-# LINE 13310 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 37, column 9)
-              _newLib =
-                  {-# LINE 37 "./TypeChecking/Statements.ag" #-}
-                  fromRight _lhsIlib $ updateBindings _lhsIlib _lhsIcat _lhsIlibUpdates
-                  {-# LINE 13315 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 53, column 9)
-              _lhsOproducedCat =
-                  {-# LINE 53 "./TypeChecking/Statements.ag" #-}
-                  _newCat
-                  {-# LINE 13320 "AstInternal.hs" #-}
-              -- "./TypeChecking/Statements.ag"(line 54, column 9)
-              _lhsOproducedLib =
-                  {-# LINE 54 "./TypeChecking/Statements.ag" #-}
-                  _newLib
-                  {-# LINE 13325 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13330 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13335 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13340 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13345 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
--- StringList --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-         strings              : [String]
-   alternatives:
-      alternative Cons:
-         child hd             : {String}
-         child tl             : StringList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type StringList  = [(String)]
--- cata
-sem_StringList :: StringList  ->
-                  T_StringList 
-sem_StringList list  =
-    (Prelude.foldr sem_StringList_Cons sem_StringList_Nil list )
--- semantic domain
-type T_StringList  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( StringList,StringList,([String]))
-data Inh_StringList  = Inh_StringList {cat_Inh_StringList :: Catalog,lib_Inh_StringList :: LocalIdentifierBindings}
-data Syn_StringList  = Syn_StringList {annotatedTree_Syn_StringList :: StringList,originalTree_Syn_StringList :: StringList,strings_Syn_StringList :: [String]}
-wrap_StringList :: T_StringList  ->
-                   Inh_StringList  ->
-                   Syn_StringList 
-wrap_StringList sem (Inh_StringList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOstrings) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_StringList _lhsOannotatedTree _lhsOoriginalTree _lhsOstrings ))
-sem_StringList_Cons :: String ->
-                       T_StringList  ->
-                       T_StringList 
-sem_StringList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOstrings :: ([String])
-              _lhsOannotatedTree :: StringList
-              _lhsOoriginalTree :: StringList
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _tlIannotatedTree :: StringList
-              _tlIoriginalTree :: StringList
-              _tlIstrings :: ([String])
-              -- "./TypeChecking/Misc.ag"(line 67, column 10)
-              _lhsOstrings =
-                  {-# LINE 67 "./TypeChecking/Misc.ag" #-}
-                  hd_ : _tlIstrings
-                  {-# LINE 13406 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) hd_ _tlIannotatedTree
-                  {-# LINE 13411 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) hd_ _tlIoriginalTree
-                  {-# LINE 13416 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13421 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13426 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13431 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13436 "AstInternal.hs" #-}
-              ( _tlIannotatedTree,_tlIoriginalTree,_tlIstrings) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOstrings)))
-sem_StringList_Nil :: T_StringList 
-sem_StringList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOstrings :: ([String])
-              _lhsOannotatedTree :: StringList
-              _lhsOoriginalTree :: StringList
-              -- "./TypeChecking/Misc.ag"(line 68, column 9)
-              _lhsOstrings =
-                  {-# LINE 68 "./TypeChecking/Misc.ag" #-}
-                  []
-                  {-# LINE 13451 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13456 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13461 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13466 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13471 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOstrings)))
--- StringTypeNameListPair --------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         fnSig                : (String,[Type])
-         originalTree         : SELF 
-   alternatives:
-      alternative Tuple:
-         child x1             : {String}
-         child x2             : TypeNameList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type StringTypeNameListPair  = ( (String),(TypeNameList))
--- cata
-sem_StringTypeNameListPair :: StringTypeNameListPair  ->
-                              T_StringTypeNameListPair 
-sem_StringTypeNameListPair ( x1,x2)  =
-    (sem_StringTypeNameListPair_Tuple x1 (sem_TypeNameList x2 ) )
--- semantic domain
-type T_StringTypeNameListPair  = Catalog ->
-                                 LocalIdentifierBindings ->
-                                 ( StringTypeNameListPair,((String,[Type])),StringTypeNameListPair)
-data Inh_StringTypeNameListPair  = Inh_StringTypeNameListPair {cat_Inh_StringTypeNameListPair :: Catalog,lib_Inh_StringTypeNameListPair :: LocalIdentifierBindings}
-data Syn_StringTypeNameListPair  = Syn_StringTypeNameListPair {annotatedTree_Syn_StringTypeNameListPair :: StringTypeNameListPair,fnSig_Syn_StringTypeNameListPair :: (String,[Type]),originalTree_Syn_StringTypeNameListPair :: StringTypeNameListPair}
-wrap_StringTypeNameListPair :: T_StringTypeNameListPair  ->
-                               Inh_StringTypeNameListPair  ->
-                               Syn_StringTypeNameListPair 
-wrap_StringTypeNameListPair sem (Inh_StringTypeNameListPair _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOfnSig,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_StringTypeNameListPair _lhsOannotatedTree _lhsOfnSig _lhsOoriginalTree ))
-sem_StringTypeNameListPair_Tuple :: String ->
-                                    T_TypeNameList  ->
-                                    T_StringTypeNameListPair 
-sem_StringTypeNameListPair_Tuple x1_ x2_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOfnSig :: ((String,[Type]))
-              _lhsOannotatedTree :: StringTypeNameListPair
-              _lhsOoriginalTree :: StringTypeNameListPair
-              _x2Ocat :: Catalog
-              _x2Olib :: LocalIdentifierBindings
-              _x2IannotatedTree :: TypeNameList
-              _x2InamedTypes :: ([Type])
-              _x2IoriginalTree :: TypeNameList
-              -- "./TypeChecking/Drops.ag"(line 25, column 13)
-              _lhsOfnSig =
-                  {-# LINE 25 "./TypeChecking/Drops.ag" #-}
-                  (x1_, _x2InamedTypes)
-                  {-# LINE 13528 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (x1_,_x2IannotatedTree)
-                  {-# LINE 13533 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (x1_,_x2IoriginalTree)
-                  {-# LINE 13538 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13543 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13548 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13553 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _x2Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13558 "AstInternal.hs" #-}
-              ( _x2IannotatedTree,_x2InamedTypes,_x2IoriginalTree) =
-                  (x2_ _x2Ocat _x2Olib )
-          in  ( _lhsOannotatedTree,_lhsOfnSig,_lhsOoriginalTree)))
--- StringTypeNameListPairList ----------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         fnSigs               : [(String,[Type])]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : StringTypeNameListPair 
-         child tl             : StringTypeNameListPairList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type StringTypeNameListPairList  = [(StringTypeNameListPair)]
--- cata
-sem_StringTypeNameListPairList :: StringTypeNameListPairList  ->
-                                  T_StringTypeNameListPairList 
-sem_StringTypeNameListPairList list  =
-    (Prelude.foldr sem_StringTypeNameListPairList_Cons sem_StringTypeNameListPairList_Nil (Prelude.map sem_StringTypeNameListPair list) )
--- semantic domain
-type T_StringTypeNameListPairList  = Catalog ->
-                                     LocalIdentifierBindings ->
-                                     ( StringTypeNameListPairList,([(String,[Type])]),StringTypeNameListPairList)
-data Inh_StringTypeNameListPairList  = Inh_StringTypeNameListPairList {cat_Inh_StringTypeNameListPairList :: Catalog,lib_Inh_StringTypeNameListPairList :: LocalIdentifierBindings}
-data Syn_StringTypeNameListPairList  = Syn_StringTypeNameListPairList {annotatedTree_Syn_StringTypeNameListPairList :: StringTypeNameListPairList,fnSigs_Syn_StringTypeNameListPairList :: [(String,[Type])],originalTree_Syn_StringTypeNameListPairList :: StringTypeNameListPairList}
-wrap_StringTypeNameListPairList :: T_StringTypeNameListPairList  ->
-                                   Inh_StringTypeNameListPairList  ->
-                                   Syn_StringTypeNameListPairList 
-wrap_StringTypeNameListPairList sem (Inh_StringTypeNameListPairList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOfnSigs,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_StringTypeNameListPairList _lhsOannotatedTree _lhsOfnSigs _lhsOoriginalTree ))
-sem_StringTypeNameListPairList_Cons :: T_StringTypeNameListPair  ->
-                                       T_StringTypeNameListPairList  ->
-                                       T_StringTypeNameListPairList 
-sem_StringTypeNameListPairList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOfnSigs :: ([(String,[Type])])
-              _lhsOannotatedTree :: StringTypeNameListPairList
-              _lhsOoriginalTree :: StringTypeNameListPairList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: StringTypeNameListPair
-              _hdIfnSig :: ((String,[Type]))
-              _hdIoriginalTree :: StringTypeNameListPair
-              _tlIannotatedTree :: StringTypeNameListPairList
-              _tlIfnSigs :: ([(String,[Type])])
-              _tlIoriginalTree :: StringTypeNameListPairList
-              -- "./TypeChecking/Drops.ag"(line 20, column 12)
-              _lhsOfnSigs =
-                  {-# LINE 20 "./TypeChecking/Drops.ag" #-}
-                  _hdIfnSig : _tlIfnSigs
-                  {-# LINE 13626 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 13631 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 13636 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13641 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13646 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13651 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13656 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 13661 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 13666 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIfnSig,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIfnSigs,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOfnSigs,_lhsOoriginalTree)))
-sem_StringTypeNameListPairList_Nil :: T_StringTypeNameListPairList 
-sem_StringTypeNameListPairList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOfnSigs :: ([(String,[Type])])
-              _lhsOannotatedTree :: StringTypeNameListPairList
-              _lhsOoriginalTree :: StringTypeNameListPairList
-              -- "./TypeChecking/Drops.ag"(line 21, column 11)
-              _lhsOfnSigs =
-                  {-# LINE 21 "./TypeChecking/Drops.ag" #-}
-                  []
-                  {-# LINE 13683 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13688 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 13693 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13698 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13703 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOfnSigs,_lhsOoriginalTree)))
--- TableAlias --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative FullAlias:
-         child alias          : {String}
-         child cols           : {[String]}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative NoAlias:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative TableAlias:
-         child alias          : {String}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data TableAlias  = FullAlias (String) ([String]) 
-                 | NoAlias 
-                 | TableAlias (String) 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TableAlias :: TableAlias  ->
-                  T_TableAlias 
-sem_TableAlias (FullAlias _alias _cols )  =
-    (sem_TableAlias_FullAlias _alias _cols )
-sem_TableAlias (NoAlias )  =
-    (sem_TableAlias_NoAlias )
-sem_TableAlias (TableAlias _alias )  =
-    (sem_TableAlias_TableAlias _alias )
--- semantic domain
-type T_TableAlias  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( TableAlias,TableAlias)
-data Inh_TableAlias  = Inh_TableAlias {cat_Inh_TableAlias :: Catalog,lib_Inh_TableAlias :: LocalIdentifierBindings}
-data Syn_TableAlias  = Syn_TableAlias {annotatedTree_Syn_TableAlias :: TableAlias,originalTree_Syn_TableAlias :: TableAlias}
-wrap_TableAlias :: T_TableAlias  ->
-                   Inh_TableAlias  ->
-                   Syn_TableAlias 
-wrap_TableAlias sem (Inh_TableAlias _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TableAlias _lhsOannotatedTree _lhsOoriginalTree ))
-sem_TableAlias_FullAlias :: String ->
-                            ([String]) ->
-                            T_TableAlias 
-sem_TableAlias_FullAlias alias_ cols_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableAlias
-              _lhsOoriginalTree :: TableAlias
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  FullAlias alias_ cols_
-                  {-# LINE 13769 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  FullAlias alias_ cols_
-                  {-# LINE 13774 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13779 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13784 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TableAlias_NoAlias :: T_TableAlias 
-sem_TableAlias_NoAlias  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableAlias
-              _lhsOoriginalTree :: TableAlias
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  NoAlias
-                  {-# LINE 13796 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  NoAlias
-                  {-# LINE 13801 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13806 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13811 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TableAlias_TableAlias :: String ->
-                             T_TableAlias 
-sem_TableAlias_TableAlias alias_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableAlias
-              _lhsOoriginalTree :: TableAlias
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TableAlias alias_
-                  {-# LINE 13824 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TableAlias alias_
-                  {-# LINE 13829 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 13834 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 13839 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- TableRef ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         jlibUpdates          : [LocalIdentifierBindingsUpdate]
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         idLookups            : [(String,Type)]
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-         originalTree         : SELF 
-         qidLookups           : [(String,[(String,Type)])]
-         qstarExpansion       : [(String,[(String,Type)])]
-         starExpansion        : [(String,Type)]
-   alternatives:
-      alternative JoinedTref:
-         child ann            : {Annotation}
-         child tbl            : TableRef 
-         child nat            : Natural 
-         child joinType       : JoinType 
-         child tbl1           : TableRef 
-         child onExpr         : OnExpr 
-         child alias          : TableAlias 
-         visit 0:
-            local libUpdates  : _
-            local errs        : _
-            local removeJoinAttrs : _
-            local ejoinAttrs  : {Either [TypeError] [(String,Type)]}
-            local joinNames   : _
-            local joinAttrs   : _
-            local idLookups   : {[(String,Type)]}
-            local qidLookups  : {[(String,[(String,Type)])]}
-            local starExpansion : {[(String,Type)]}
-            local qstarExpansion : {[(String,[(String,Type)])]}
-            local newLib      : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative SubTref:
-         child ann            : {Annotation}
-         child sel            : SelectExpression 
-         child alias          : TableAlias 
-         visit 0:
-            local libUpdates  : _
-            local errs        : _
-            local selectAttrs : {Either [TypeError] [(String,Type)]}
-            local idLookups   : {[(String,Type)]}
-            local qidLookups  : {[(String,[(String,Type)])]}
-            local starExpansion : {[(String,Type)]}
-            local qstarExpansion : {[(String,[(String,Type)])]}
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative Tref:
-         child ann            : {Annotation}
-         child tbl            : {String}
-         child alias          : TableAlias 
-         visit 0:
-            local libUpdates  : _
-            local errs        : _
-            local relType     : {Either [TypeError] ([(String, Type)], [(String, Type)])}
-            local relType1    : _
-            local pAttrs      : _
-            local sAttrs      : _
-            local idLookups   : {[(String,Type)]}
-            local alias       : _
-            local qidLookups  : {[(String,[(String,Type)])]}
-            local starExpansion : {[(String,Type)]}
-            local qstarExpansion : {[(String,[(String,Type)])]}
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative TrefFun:
-         child ann            : {Annotation}
-         child fn             : Expression 
-         child alias          : TableAlias 
-         visit 0:
-            local libUpdates  : _
-            local errs        : _
-            local eqfunIdens  : {Either [TypeError] (String,[(String,Type)])}
-            local qfunIdens   : _
-            local alias2      : _
-            local funIdens    : _
-            local alias       : _
-            local idLookups   : {[(String,Type)]}
-            local qidLookups  : {[(String,[(String,Type)])]}
-            local starExpansion : {[(String,Type)]}
-            local qstarExpansion : {[(String,[(String,Type)])]}
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
--}
-data TableRef  = JoinedTref (Annotation) (TableRef) (Natural) (JoinType) (TableRef) (OnExpr) (TableAlias) 
-               | SubTref (Annotation) (SelectExpression) (TableAlias) 
-               | Tref (Annotation) (String) (TableAlias) 
-               | TrefFun (Annotation) (Expression) (TableAlias) 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TableRef :: TableRef  ->
-                T_TableRef 
-sem_TableRef (JoinedTref _ann _tbl _nat _joinType _tbl1 _onExpr _alias )  =
-    (sem_TableRef_JoinedTref _ann (sem_TableRef _tbl ) (sem_Natural _nat ) (sem_JoinType _joinType ) (sem_TableRef _tbl1 ) (sem_OnExpr _onExpr ) (sem_TableAlias _alias ) )
-sem_TableRef (SubTref _ann _sel _alias )  =
-    (sem_TableRef_SubTref _ann (sem_SelectExpression _sel ) (sem_TableAlias _alias ) )
-sem_TableRef (Tref _ann _tbl _alias )  =
-    (sem_TableRef_Tref _ann _tbl (sem_TableAlias _alias ) )
-sem_TableRef (TrefFun _ann _fn _alias )  =
-    (sem_TableRef_TrefFun _ann (sem_Expression _fn ) (sem_TableAlias _alias ) )
--- semantic domain
-type T_TableRef  = Catalog ->
-                   ([LocalIdentifierBindingsUpdate]) ->
-                   LocalIdentifierBindings ->
-                   ( TableRef,([(String,Type)]),([LocalIdentifierBindingsUpdate]),TableRef,([(String,[(String,Type)])]),([(String,[(String,Type)])]),([(String,Type)]))
-data Inh_TableRef  = Inh_TableRef {cat_Inh_TableRef :: Catalog,jlibUpdates_Inh_TableRef :: [LocalIdentifierBindingsUpdate],lib_Inh_TableRef :: LocalIdentifierBindings}
-data Syn_TableRef  = Syn_TableRef {annotatedTree_Syn_TableRef :: TableRef,idLookups_Syn_TableRef :: [(String,Type)],libUpdates_Syn_TableRef :: [LocalIdentifierBindingsUpdate],originalTree_Syn_TableRef :: TableRef,qidLookups_Syn_TableRef :: [(String,[(String,Type)])],qstarExpansion_Syn_TableRef :: [(String,[(String,Type)])],starExpansion_Syn_TableRef :: [(String,Type)]}
-wrap_TableRef :: T_TableRef  ->
-                 Inh_TableRef  ->
-                 Syn_TableRef 
-wrap_TableRef sem (Inh_TableRef _lhsIcat _lhsIjlibUpdates _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOidLookups,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOqidLookups,_lhsOqstarExpansion,_lhsOstarExpansion) =
-             (sem _lhsIcat _lhsIjlibUpdates _lhsIlib )
-     in  (Syn_TableRef _lhsOannotatedTree _lhsOidLookups _lhsOlibUpdates _lhsOoriginalTree _lhsOqidLookups _lhsOqstarExpansion _lhsOstarExpansion ))
-sem_TableRef_JoinedTref :: Annotation ->
-                           T_TableRef  ->
-                           T_Natural  ->
-                           T_JoinType  ->
-                           T_TableRef  ->
-                           T_OnExpr  ->
-                           T_TableAlias  ->
-                           T_TableRef 
-sem_TableRef_JoinedTref ann_ tbl_ nat_ joinType_ tbl1_ onExpr_ alias_  =
-    (\ _lhsIcat
-       _lhsIjlibUpdates
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableRef
-              _ejoinAttrs :: (Either [TypeError] [(String,Type)])
-              _idLookups :: ([(String,Type)])
-              _qidLookups :: ([(String,[(String,Type)])])
-              _starExpansion :: ([(String,Type)])
-              _qstarExpansion :: ([(String,[(String,Type)])])
-              _onExprOlib :: LocalIdentifierBindings
-              _tblOjlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tbl1OjlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOidLookups :: ([(String,Type)])
-              _lhsOqidLookups :: ([(String,[(String,Type)])])
-              _lhsOstarExpansion :: ([(String,Type)])
-              _lhsOqstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOoriginalTree :: TableRef
-              _tblOcat :: Catalog
-              _tblOlib :: LocalIdentifierBindings
-              _natOcat :: Catalog
-              _natOlib :: LocalIdentifierBindings
-              _joinTypeOcat :: Catalog
-              _joinTypeOlib :: LocalIdentifierBindings
-              _tbl1Ocat :: Catalog
-              _tbl1Olib :: LocalIdentifierBindings
-              _onExprOcat :: Catalog
-              _aliasOcat :: Catalog
-              _aliasOlib :: LocalIdentifierBindings
-              _tblIannotatedTree :: TableRef
-              _tblIidLookups :: ([(String,Type)])
-              _tblIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tblIoriginalTree :: TableRef
-              _tblIqidLookups :: ([(String,[(String,Type)])])
-              _tblIqstarExpansion :: ([(String,[(String,Type)])])
-              _tblIstarExpansion :: ([(String,Type)])
-              _natIannotatedTree :: Natural
-              _natIoriginalTree :: Natural
-              _joinTypeIannotatedTree :: JoinType
-              _joinTypeIoriginalTree :: JoinType
-              _tbl1IannotatedTree :: TableRef
-              _tbl1IidLookups :: ([(String,Type)])
-              _tbl1IlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tbl1IoriginalTree :: TableRef
-              _tbl1IqidLookups :: ([(String,[(String,Type)])])
-              _tbl1IqstarExpansion :: ([(String,[(String,Type)])])
-              _tbl1IstarExpansion :: ([(String,Type)])
-              _onExprIannotatedTree :: OnExpr
-              _onExprIoriginalTree :: OnExpr
-              _aliasIannotatedTree :: TableAlias
-              _aliasIoriginalTree :: TableAlias
-              -- "./TypeChecking/TableRefs.ag"(line 33, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 33 "./TypeChecking/TableRefs.ag" #-}
-                  updateAnnotation (map TypeErrorA _errs     ++) _backTree
-                  {-# LINE 14028 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 75, column 9)
-              _libUpdates =
-                  {-# LINE 75 "./TypeChecking/TableRefs.ag" #-}
-                  if null _errs
-                    then [LibStackIDs $ ("", _idLookups    ): _qidLookups
-                         ,LibSetStarExpansion $ ("", _starExpansion    ): _qstarExpansion    ]
-                    else []
-                  {-# LINE 14036 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 135, column 9)
-              _errs =
-                  {-# LINE 135 "./TypeChecking/TableRefs.ag" #-}
-                  fromLeft [] _ejoinAttrs
-                  {-# LINE 14041 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 136, column 9)
-              _removeJoinAttrs =
-                  {-# LINE 136 "./TypeChecking/TableRefs.ag" #-}
-                  filter (\(n,_) -> n `notElem` _joinNames    )
-                  {-# LINE 14046 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 146, column 9)
-              _ejoinAttrs =
-                  {-# LINE 146 "./TypeChecking/TableRefs.ag" #-}
-                  do
-                  let jns = case (_natIannotatedTree, _onExprIoriginalTree) of
-                                (Natural, _) -> commonFieldNames
-                                (_,Just (JoinUsing _ s)) -> s
-                                _ -> []
-                      tjtsm = map (flip lookup _tblIidLookups) jns
-                      t1jtsm = map (flip lookup _tbl1IidLookups) jns
-                  errorWhen (not $ null $ filter (==Nothing) $ tjtsm ++ t1jtsm)
-                            [MissingJoinAttribute]
-                  let tjts = catMaybes tjtsm
-                      t1jts = catMaybes t1jtsm
-                      resolvedTypes :: [Either [TypeError] Type]
-                      resolvedTypes = map (\(a,b) -> resolveResultSetType _lhsIcat [a,b]) $ zip tjts t1jts
-                  liftErrors $ concat $ lefts resolvedTypes
-                  return $ zip jns $ rights resolvedTypes
-                  where
-                    commonFieldNames = intersect (f _tblIstarExpansion) (f _tbl1IstarExpansion)
-                                       where f = map fst
-                  {-# LINE 14068 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 170, column 9)
-              _joinNames =
-                  {-# LINE 170 "./TypeChecking/TableRefs.ag" #-}
-                  map fst _joinAttrs
-                  {-# LINE 14073 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 171, column 9)
-              _joinAttrs =
-                  {-# LINE 171 "./TypeChecking/TableRefs.ag" #-}
-                  fromRight [] _ejoinAttrs
-                  {-# LINE 14078 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 176, column 9)
-              _idLookups =
-                  {-# LINE 176 "./TypeChecking/TableRefs.ag" #-}
-                  _joinAttrs     ++
-                    _removeJoinAttrs     _tblIidLookups ++
-                    _removeJoinAttrs     _tbl1IidLookups
-                  {-# LINE 14085 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 179, column 9)
-              _qidLookups =
-                  {-# LINE 179 "./TypeChecking/TableRefs.ag" #-}
-                  _tblIqidLookups ++ _tbl1IqidLookups
-                  {-# LINE 14090 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 180, column 9)
-              _starExpansion =
-                  {-# LINE 180 "./TypeChecking/TableRefs.ag" #-}
-                  _joinAttrs     ++
-                    _removeJoinAttrs     _tblIstarExpansion ++
-                    _removeJoinAttrs     _tbl1IstarExpansion
-                  {-# LINE 14097 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 183, column 9)
-              _qstarExpansion =
-                  {-# LINE 183 "./TypeChecking/TableRefs.ag" #-}
-                  _tblIqstarExpansion ++ _tbl1IqstarExpansion
-                  {-# LINE 14102 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 187, column 9)
-              _newLib =
-                  {-# LINE 187 "./TypeChecking/TableRefs.ag" #-}
-                  case updateBindings _lhsIlib _lhsIcat (_libUpdates     ++ _lhsIjlibUpdates) of
-                    Left x -> error $ show x
-                    Right e ->                                      e
-                  {-# LINE 14109 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 190, column 9)
-              _onExprOlib =
-                  {-# LINE 190 "./TypeChecking/TableRefs.ag" #-}
-                  _newLib
-                  {-# LINE 14114 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 192, column 9)
-              _tblOjlibUpdates =
-                  {-# LINE 192 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14119 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 193, column 9)
-              _tbl1OjlibUpdates =
-                  {-# LINE 193 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14124 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 248, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 248 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14129 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 249, column 9)
-              _lhsOidLookups =
-                  {-# LINE 249 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14134 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 250, column 9)
-              _lhsOqidLookups =
-                  {-# LINE 250 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14139 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 251, column 9)
-              _lhsOstarExpansion =
-                  {-# LINE 251 "./TypeChecking/TableRefs.ag" #-}
-                  _starExpansion
-                  {-# LINE 14144 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 252, column 9)
-              _lhsOqstarExpansion =
-                  {-# LINE 252 "./TypeChecking/TableRefs.ag" #-}
-                  _qstarExpansion
-                  {-# LINE 14149 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 264, column 9)
-              _backTree =
-                  {-# LINE 264 "./TypeChecking/TableRefs.ag" #-}
-                  JoinedTref ann_
-                             _tblIannotatedTree
-                             _natIannotatedTree
-                             _joinTypeIannotatedTree
-                             _tbl1IannotatedTree
-                             _onExprIannotatedTree
-                             _aliasIannotatedTree
-                  {-# LINE 14160 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinedTref ann_ _tblIannotatedTree _natIannotatedTree _joinTypeIannotatedTree _tbl1IannotatedTree _onExprIannotatedTree _aliasIannotatedTree
-                  {-# LINE 14165 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  JoinedTref ann_ _tblIoriginalTree _natIoriginalTree _joinTypeIoriginalTree _tbl1IoriginalTree _onExprIoriginalTree _aliasIoriginalTree
-                  {-# LINE 14170 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14175 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tblOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14180 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tblOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14185 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _natOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14190 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _natOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14195 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _joinTypeOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14200 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _joinTypeOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14205 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tbl1Ocat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14210 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tbl1Olib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14215 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _onExprOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14220 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14225 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14230 "AstInternal.hs" #-}
-              ( _tblIannotatedTree,_tblIidLookups,_tblIlibUpdates,_tblIoriginalTree,_tblIqidLookups,_tblIqstarExpansion,_tblIstarExpansion) =
-                  (tbl_ _tblOcat _tblOjlibUpdates _tblOlib )
-              ( _natIannotatedTree,_natIoriginalTree) =
-                  (nat_ _natOcat _natOlib )
-              ( _joinTypeIannotatedTree,_joinTypeIoriginalTree) =
-                  (joinType_ _joinTypeOcat _joinTypeOlib )
-              ( _tbl1IannotatedTree,_tbl1IidLookups,_tbl1IlibUpdates,_tbl1IoriginalTree,_tbl1IqidLookups,_tbl1IqstarExpansion,_tbl1IstarExpansion) =
-                  (tbl1_ _tbl1Ocat _tbl1OjlibUpdates _tbl1Olib )
-              ( _onExprIannotatedTree,_onExprIoriginalTree) =
-                  (onExpr_ _onExprOcat _onExprOlib )
-              ( _aliasIannotatedTree,_aliasIoriginalTree) =
-                  (alias_ _aliasOcat _aliasOlib )
-          in  ( _lhsOannotatedTree,_lhsOidLookups,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOqidLookups,_lhsOqstarExpansion,_lhsOstarExpansion)))
-sem_TableRef_SubTref :: Annotation ->
-                        T_SelectExpression  ->
-                        T_TableAlias  ->
-                        T_TableRef 
-sem_TableRef_SubTref ann_ sel_ alias_  =
-    (\ _lhsIcat
-       _lhsIjlibUpdates
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableRef
-              _selectAttrs :: (Either [TypeError] [(String,Type)])
-              _idLookups :: ([(String,Type)])
-              _qidLookups :: ([(String,[(String,Type)])])
-              _starExpansion :: ([(String,Type)])
-              _qstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOidLookups :: ([(String,Type)])
-              _lhsOqidLookups :: ([(String,[(String,Type)])])
-              _lhsOstarExpansion :: ([(String,Type)])
-              _lhsOqstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOoriginalTree :: TableRef
-              _selOcat :: Catalog
-              _selOlib :: LocalIdentifierBindings
-              _aliasOcat :: Catalog
-              _aliasOlib :: LocalIdentifierBindings
-              _selIannotatedTree :: SelectExpression
-              _selIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _selIoriginalTree :: SelectExpression
-              _aliasIannotatedTree :: TableAlias
-              _aliasIoriginalTree :: TableAlias
-              -- "./TypeChecking/TableRefs.ag"(line 33, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 33 "./TypeChecking/TableRefs.ag" #-}
-                  updateAnnotation (map TypeErrorA _errs     ++) _backTree
-                  {-# LINE 14277 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 75, column 9)
-              _libUpdates =
-                  {-# LINE 75 "./TypeChecking/TableRefs.ag" #-}
-                  if null _errs
-                    then [LibStackIDs $ ("", _idLookups    ): _qidLookups
-                         ,LibSetStarExpansion $ ("", _starExpansion    ): _qstarExpansion    ]
-                    else []
-                  {-# LINE 14285 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 92, column 9)
-              _errs =
-                  {-# LINE 92 "./TypeChecking/TableRefs.ag" #-}
-                  case _selectAttrs     of
-                          Left e -> e
-                          Right _ -> []
-                  {-# LINE 14292 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 96, column 9)
-              _selectAttrs =
-                  {-# LINE 96 "./TypeChecking/TableRefs.ag" #-}
-                  unwrapSetOfComposite (getTypeAnnotation _selIannotatedTree)
-                  {-# LINE 14297 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 98, column 9)
-              _idLookups =
-                  {-# LINE 98 "./TypeChecking/TableRefs.ag" #-}
-                  fromRight [] _selectAttrs
-                  {-# LINE 14302 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 99, column 9)
-              _qidLookups =
-                  {-# LINE 99 "./TypeChecking/TableRefs.ag" #-}
-                  [(getAlias "" _aliasIannotatedTree, _idLookups    )]
-                  {-# LINE 14307 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 100, column 9)
-              _starExpansion =
-                  {-# LINE 100 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14312 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 101, column 9)
-              _qstarExpansion =
-                  {-# LINE 101 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14317 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 248, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 248 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14322 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 249, column 9)
-              _lhsOidLookups =
-                  {-# LINE 249 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14327 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 250, column 9)
-              _lhsOqidLookups =
-                  {-# LINE 250 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14332 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 251, column 9)
-              _lhsOstarExpansion =
-                  {-# LINE 251 "./TypeChecking/TableRefs.ag" #-}
-                  _starExpansion
-                  {-# LINE 14337 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 252, column 9)
-              _lhsOqstarExpansion =
-                  {-# LINE 252 "./TypeChecking/TableRefs.ag" #-}
-                  _qstarExpansion
-                  {-# LINE 14342 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 258, column 9)
-              _backTree =
-                  {-# LINE 258 "./TypeChecking/TableRefs.ag" #-}
-                  SubTref ann_ _selIannotatedTree _aliasIannotatedTree
-                  {-# LINE 14347 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SubTref ann_ _selIannotatedTree _aliasIannotatedTree
-                  {-# LINE 14352 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SubTref ann_ _selIoriginalTree _aliasIoriginalTree
-                  {-# LINE 14357 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14362 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14367 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _selOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14372 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14377 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14382 "AstInternal.hs" #-}
-              ( _selIannotatedTree,_selIlibUpdates,_selIoriginalTree) =
-                  (sel_ _selOcat _selOlib )
-              ( _aliasIannotatedTree,_aliasIoriginalTree) =
-                  (alias_ _aliasOcat _aliasOlib )
-          in  ( _lhsOannotatedTree,_lhsOidLookups,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOqidLookups,_lhsOqstarExpansion,_lhsOstarExpansion)))
-sem_TableRef_Tref :: Annotation ->
-                     String ->
-                     T_TableAlias  ->
-                     T_TableRef 
-sem_TableRef_Tref ann_ tbl_ alias_  =
-    (\ _lhsIcat
-       _lhsIjlibUpdates
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableRef
-              _relType :: (Either [TypeError] ([(String, Type)], [(String, Type)]))
-              _idLookups :: ([(String,Type)])
-              _qidLookups :: ([(String,[(String,Type)])])
-              _starExpansion :: ([(String,Type)])
-              _qstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOidLookups :: ([(String,Type)])
-              _lhsOqidLookups :: ([(String,[(String,Type)])])
-              _lhsOstarExpansion :: ([(String,Type)])
-              _lhsOqstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOoriginalTree :: TableRef
-              _aliasOcat :: Catalog
-              _aliasOlib :: LocalIdentifierBindings
-              _aliasIannotatedTree :: TableAlias
-              _aliasIoriginalTree :: TableAlias
-              -- "./TypeChecking/TableRefs.ag"(line 33, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 33 "./TypeChecking/TableRefs.ag" #-}
-                  updateAnnotation (map TypeErrorA _errs     ++) _backTree
-                  {-# LINE 14416 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 75, column 9)
-              _libUpdates =
-                  {-# LINE 75 "./TypeChecking/TableRefs.ag" #-}
-                  if null _errs
-                    then [LibStackIDs $ ("", _idLookups    ): _qidLookups
-                         ,LibSetStarExpansion $ ("", _starExpansion    ): _qstarExpansion    ]
-                    else []
-                  {-# LINE 14424 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 104, column 9)
-              _errs =
-                  {-# LINE 104 "./TypeChecking/TableRefs.ag" #-}
-                  case _relType     of
-                    Left e -> e
-                    Right _ -> []
-                  {-# LINE 14431 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 108, column 9)
-              _relType =
-                  {-# LINE 108 "./TypeChecking/TableRefs.ag" #-}
-                  catCompositeAttrsPair _lhsIcat [] tbl_
-                  {-# LINE 14436 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 109, column 9)
-              _relType1 =
-                  {-# LINE 109 "./TypeChecking/TableRefs.ag" #-}
-                  fromRight ([],[]) _relType
-                  {-# LINE 14441 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 110, column 9)
-              _pAttrs =
-                  {-# LINE 110 "./TypeChecking/TableRefs.ag" #-}
-                  fst _relType1
-                  {-# LINE 14446 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 111, column 9)
-              _sAttrs =
-                  {-# LINE 111 "./TypeChecking/TableRefs.ag" #-}
-                  snd _relType1
-                  {-# LINE 14451 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 113, column 9)
-              _idLookups =
-                  {-# LINE 113 "./TypeChecking/TableRefs.ag" #-}
-                  _pAttrs     ++ _sAttrs
-                  {-# LINE 14456 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 114, column 9)
-              _alias =
-                  {-# LINE 114 "./TypeChecking/TableRefs.ag" #-}
-                  getAlias tbl_ _aliasIannotatedTree
-                  {-# LINE 14461 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 115, column 9)
-              _qidLookups =
-                  {-# LINE 115 "./TypeChecking/TableRefs.ag" #-}
-                  [(_alias    , _idLookups    )]
-                  {-# LINE 14466 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 116, column 9)
-              _starExpansion =
-                  {-# LINE 116 "./TypeChecking/TableRefs.ag" #-}
-                  _pAttrs
-                  {-# LINE 14471 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 117, column 9)
-              _qstarExpansion =
-                  {-# LINE 117 "./TypeChecking/TableRefs.ag" #-}
-                  [(_alias    , _pAttrs    )]
-                  {-# LINE 14476 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 248, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 248 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14481 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 249, column 9)
-              _lhsOidLookups =
-                  {-# LINE 249 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14486 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 250, column 9)
-              _lhsOqidLookups =
-                  {-# LINE 250 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14491 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 251, column 9)
-              _lhsOstarExpansion =
-                  {-# LINE 251 "./TypeChecking/TableRefs.ag" #-}
-                  _starExpansion
-                  {-# LINE 14496 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 252, column 9)
-              _lhsOqstarExpansion =
-                  {-# LINE 252 "./TypeChecking/TableRefs.ag" #-}
-                  _qstarExpansion
-                  {-# LINE 14501 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 260, column 9)
-              _backTree =
-                  {-# LINE 260 "./TypeChecking/TableRefs.ag" #-}
-                  Tref ann_ tbl_ _aliasIannotatedTree
-                  {-# LINE 14506 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Tref ann_ tbl_ _aliasIannotatedTree
-                  {-# LINE 14511 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Tref ann_ tbl_ _aliasIoriginalTree
-                  {-# LINE 14516 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14521 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14526 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14531 "AstInternal.hs" #-}
-              ( _aliasIannotatedTree,_aliasIoriginalTree) =
-                  (alias_ _aliasOcat _aliasOlib )
-          in  ( _lhsOannotatedTree,_lhsOidLookups,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOqidLookups,_lhsOqstarExpansion,_lhsOstarExpansion)))
-sem_TableRef_TrefFun :: Annotation ->
-                        T_Expression  ->
-                        T_TableAlias  ->
-                        T_TableRef 
-sem_TableRef_TrefFun ann_ fn_ alias_  =
-    (\ _lhsIcat
-       _lhsIjlibUpdates
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TableRef
-              _eqfunIdens :: (Either [TypeError] (String,[(String,Type)]))
-              _idLookups :: ([(String,Type)])
-              _qidLookups :: ([(String,[(String,Type)])])
-              _starExpansion :: ([(String,Type)])
-              _qstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOidLookups :: ([(String,Type)])
-              _lhsOqidLookups :: ([(String,[(String,Type)])])
-              _lhsOstarExpansion :: ([(String,Type)])
-              _lhsOqstarExpansion :: ([(String,[(String,Type)])])
-              _lhsOoriginalTree :: TableRef
-              _fnOcat :: Catalog
-              _fnOlib :: LocalIdentifierBindings
-              _aliasOcat :: Catalog
-              _aliasOlib :: LocalIdentifierBindings
-              _fnIannotatedTree :: Expression
-              _fnIliftedColumnName :: String
-              _fnIoriginalTree :: Expression
-              _aliasIannotatedTree :: TableAlias
-              _aliasIoriginalTree :: TableAlias
-              -- "./TypeChecking/TableRefs.ag"(line 33, column 9)
-              _lhsOannotatedTree =
-                  {-# LINE 33 "./TypeChecking/TableRefs.ag" #-}
-                  updateAnnotation (map TypeErrorA _errs     ++) _backTree
-                  {-# LINE 14568 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 75, column 9)
-              _libUpdates =
-                  {-# LINE 75 "./TypeChecking/TableRefs.ag" #-}
-                  if null _errs
-                    then [LibStackIDs $ ("", _idLookups    ): _qidLookups
-                         ,LibSetStarExpansion $ ("", _starExpansion    ): _qstarExpansion    ]
-                    else []
-                  {-# LINE 14576 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 120, column 9)
-              _errs =
-                  {-# LINE 120 "./TypeChecking/TableRefs.ag" #-}
-                  case _eqfunIdens of
-                    Left e -> e
-                    Right _ -> []
-                  {-# LINE 14583 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 124, column 9)
-              _eqfunIdens =
-                  {-# LINE 124 "./TypeChecking/TableRefs.ag" #-}
-                  funIdens _lhsIcat _alias     _fnIannotatedTree
-                  {-# LINE 14588 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 125, column 9)
-              _qfunIdens =
-                  {-# LINE 125 "./TypeChecking/TableRefs.ag" #-}
-                  fromRight ("",[]) _eqfunIdens
-                  {-# LINE 14593 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 126, column 9)
-              _alias2 =
-                  {-# LINE 126 "./TypeChecking/TableRefs.ag" #-}
-                  fst _qfunIdens
-                  {-# LINE 14598 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 127, column 9)
-              _funIdens =
-                  {-# LINE 127 "./TypeChecking/TableRefs.ag" #-}
-                  snd _qfunIdens
-                  {-# LINE 14603 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 128, column 9)
-              _alias =
-                  {-# LINE 128 "./TypeChecking/TableRefs.ag" #-}
-                  getAlias "" _aliasIannotatedTree
-                  {-# LINE 14608 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 130, column 9)
-              _idLookups =
-                  {-# LINE 130 "./TypeChecking/TableRefs.ag" #-}
-                  _funIdens
-                  {-# LINE 14613 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 131, column 9)
-              _qidLookups =
-                  {-# LINE 131 "./TypeChecking/TableRefs.ag" #-}
-                  [(_alias2, _idLookups    )]
-                  {-# LINE 14618 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 132, column 9)
-              _starExpansion =
-                  {-# LINE 132 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14623 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 133, column 9)
-              _qstarExpansion =
-                  {-# LINE 133 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14628 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 248, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 248 "./TypeChecking/TableRefs.ag" #-}
-                  _libUpdates
-                  {-# LINE 14633 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 249, column 9)
-              _lhsOidLookups =
-                  {-# LINE 249 "./TypeChecking/TableRefs.ag" #-}
-                  _idLookups
-                  {-# LINE 14638 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 250, column 9)
-              _lhsOqidLookups =
-                  {-# LINE 250 "./TypeChecking/TableRefs.ag" #-}
-                  _qidLookups
-                  {-# LINE 14643 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 251, column 9)
-              _lhsOstarExpansion =
-                  {-# LINE 251 "./TypeChecking/TableRefs.ag" #-}
-                  _starExpansion
-                  {-# LINE 14648 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 252, column 9)
-              _lhsOqstarExpansion =
-                  {-# LINE 252 "./TypeChecking/TableRefs.ag" #-}
-                  _qstarExpansion
-                  {-# LINE 14653 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 262, column 9)
-              _backTree =
-                  {-# LINE 262 "./TypeChecking/TableRefs.ag" #-}
-                  TrefFun ann_ _fnIannotatedTree _aliasIannotatedTree
-                  {-# LINE 14658 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TrefFun ann_ _fnIannotatedTree _aliasIannotatedTree
-                  {-# LINE 14663 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TrefFun ann_ _fnIoriginalTree _aliasIoriginalTree
-                  {-# LINE 14668 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14673 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fnOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14678 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _fnOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14683 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14688 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _aliasOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14693 "AstInternal.hs" #-}
-              ( _fnIannotatedTree,_fnIliftedColumnName,_fnIoriginalTree) =
-                  (fn_ _fnOcat _fnOlib )
-              ( _aliasIannotatedTree,_aliasIoriginalTree) =
-                  (alias_ _aliasOcat _aliasOlib )
-          in  ( _lhsOannotatedTree,_lhsOidLookups,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOqidLookups,_lhsOqstarExpansion,_lhsOstarExpansion)))
--- TableRefList ------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         libUpdates           : [LocalIdentifierBindingsUpdate]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : TableRef 
-         child tl             : TableRefList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type TableRefList  = [(TableRef)]
--- cata
-sem_TableRefList :: TableRefList  ->
-                    T_TableRefList 
-sem_TableRefList list  =
-    (Prelude.foldr sem_TableRefList_Cons sem_TableRefList_Nil (Prelude.map sem_TableRef list) )
--- semantic domain
-type T_TableRefList  = Catalog ->
-                       LocalIdentifierBindings ->
-                       ( TableRefList,([LocalIdentifierBindingsUpdate]),TableRefList)
-data Inh_TableRefList  = Inh_TableRefList {cat_Inh_TableRefList :: Catalog,lib_Inh_TableRefList :: LocalIdentifierBindings}
-data Syn_TableRefList  = Syn_TableRefList {annotatedTree_Syn_TableRefList :: TableRefList,libUpdates_Syn_TableRefList :: [LocalIdentifierBindingsUpdate],originalTree_Syn_TableRefList :: TableRefList}
-wrap_TableRefList :: T_TableRefList  ->
-                     Inh_TableRefList  ->
-                     Syn_TableRefList 
-wrap_TableRefList sem (Inh_TableRefList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TableRefList _lhsOannotatedTree _lhsOlibUpdates _lhsOoriginalTree ))
-sem_TableRefList_Cons :: T_TableRef  ->
-                         T_TableRefList  ->
-                         T_TableRefList 
-sem_TableRefList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _hdOjlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: TableRefList
-              _lhsOoriginalTree :: TableRefList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: TableRef
-              _hdIidLookups :: ([(String,Type)])
-              _hdIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _hdIoriginalTree :: TableRef
-              _hdIqidLookups :: ([(String,[(String,Type)])])
-              _hdIqstarExpansion :: ([(String,[(String,Type)])])
-              _hdIstarExpansion :: ([(String,Type)])
-              _tlIannotatedTree :: TableRefList
-              _tlIlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _tlIoriginalTree :: TableRefList
-              -- "./TypeChecking/TableRefs.ag"(line 40, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 40 "./TypeChecking/TableRefs.ag" #-}
-                  _hdIlibUpdates
-                  {-# LINE 14768 "AstInternal.hs" #-}
-              -- "./TypeChecking/TableRefs.ag"(line 197, column 12)
-              _hdOjlibUpdates =
-                  {-# LINE 197 "./TypeChecking/TableRefs.ag" #-}
-                  []
-                  {-# LINE 14773 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 14778 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 14783 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 14788 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14793 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14798 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14803 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 14808 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 14813 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIidLookups,_hdIlibUpdates,_hdIoriginalTree,_hdIqidLookups,_hdIqstarExpansion,_hdIstarExpansion) =
-                  (hd_ _hdOcat _hdOjlibUpdates _hdOlib )
-              ( _tlIannotatedTree,_tlIlibUpdates,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree)))
-sem_TableRefList_Nil :: T_TableRefList 
-sem_TableRefList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOlibUpdates :: ([LocalIdentifierBindingsUpdate])
-              _lhsOannotatedTree :: TableRefList
-              _lhsOoriginalTree :: TableRefList
-              -- "./TypeChecking/TableRefs.ag"(line 38, column 9)
-              _lhsOlibUpdates =
-                  {-# LINE 38 "./TypeChecking/TableRefs.ag" #-}
-                  []
-                  {-# LINE 14830 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 14835 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 14840 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 14845 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14850 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOlibUpdates,_lhsOoriginalTree)))
--- TriggerEvent ------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative TDelete:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative TInsert:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative TUpdate:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data TriggerEvent  = TDelete 
-                   | TInsert 
-                   | TUpdate 
-                   deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TriggerEvent :: TriggerEvent  ->
-                    T_TriggerEvent 
-sem_TriggerEvent (TDelete )  =
-    (sem_TriggerEvent_TDelete )
-sem_TriggerEvent (TInsert )  =
-    (sem_TriggerEvent_TInsert )
-sem_TriggerEvent (TUpdate )  =
-    (sem_TriggerEvent_TUpdate )
--- semantic domain
-type T_TriggerEvent  = Catalog ->
-                       LocalIdentifierBindings ->
-                       ( TriggerEvent,TriggerEvent)
-data Inh_TriggerEvent  = Inh_TriggerEvent {cat_Inh_TriggerEvent :: Catalog,lib_Inh_TriggerEvent :: LocalIdentifierBindings}
-data Syn_TriggerEvent  = Syn_TriggerEvent {annotatedTree_Syn_TriggerEvent :: TriggerEvent,originalTree_Syn_TriggerEvent :: TriggerEvent}
-wrap_TriggerEvent :: T_TriggerEvent  ->
-                     Inh_TriggerEvent  ->
-                     Syn_TriggerEvent 
-wrap_TriggerEvent sem (Inh_TriggerEvent _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TriggerEvent _lhsOannotatedTree _lhsOoriginalTree ))
-sem_TriggerEvent_TDelete :: T_TriggerEvent 
-sem_TriggerEvent_TDelete  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerEvent
-              _lhsOoriginalTree :: TriggerEvent
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TDelete
-                  {-# LINE 14911 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TDelete
-                  {-# LINE 14916 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 14921 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14926 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TriggerEvent_TInsert :: T_TriggerEvent 
-sem_TriggerEvent_TInsert  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerEvent
-              _lhsOoriginalTree :: TriggerEvent
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TInsert
-                  {-# LINE 14938 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TInsert
-                  {-# LINE 14943 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 14948 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14953 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TriggerEvent_TUpdate :: T_TriggerEvent 
-sem_TriggerEvent_TUpdate  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerEvent
-              _lhsOoriginalTree :: TriggerEvent
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TUpdate
-                  {-# LINE 14965 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TUpdate
-                  {-# LINE 14970 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 14975 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 14980 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- TriggerFire -------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative EachRow:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative EachStatement:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data TriggerFire  = EachRow 
-                  | EachStatement 
-                  deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TriggerFire :: TriggerFire  ->
-                   T_TriggerFire 
-sem_TriggerFire (EachRow )  =
-    (sem_TriggerFire_EachRow )
-sem_TriggerFire (EachStatement )  =
-    (sem_TriggerFire_EachStatement )
--- semantic domain
-type T_TriggerFire  = Catalog ->
-                      LocalIdentifierBindings ->
-                      ( TriggerFire,TriggerFire)
-data Inh_TriggerFire  = Inh_TriggerFire {cat_Inh_TriggerFire :: Catalog,lib_Inh_TriggerFire :: LocalIdentifierBindings}
-data Syn_TriggerFire  = Syn_TriggerFire {annotatedTree_Syn_TriggerFire :: TriggerFire,originalTree_Syn_TriggerFire :: TriggerFire}
-wrap_TriggerFire :: T_TriggerFire  ->
-                    Inh_TriggerFire  ->
-                    Syn_TriggerFire 
-wrap_TriggerFire sem (Inh_TriggerFire _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TriggerFire _lhsOannotatedTree _lhsOoriginalTree ))
-sem_TriggerFire_EachRow :: T_TriggerFire 
-sem_TriggerFire_EachRow  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerFire
-              _lhsOoriginalTree :: TriggerFire
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  EachRow
-                  {-# LINE 15034 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  EachRow
-                  {-# LINE 15039 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15044 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15049 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TriggerFire_EachStatement :: T_TriggerFire 
-sem_TriggerFire_EachStatement  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerFire
-              _lhsOoriginalTree :: TriggerFire
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  EachStatement
-                  {-# LINE 15061 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  EachStatement
-                  {-# LINE 15066 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15071 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15076 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- TriggerWhen -------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative TriggerAfter:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative TriggerBefore:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data TriggerWhen  = TriggerAfter 
-                  | TriggerBefore 
-                  deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TriggerWhen :: TriggerWhen  ->
-                   T_TriggerWhen 
-sem_TriggerWhen (TriggerAfter )  =
-    (sem_TriggerWhen_TriggerAfter )
-sem_TriggerWhen (TriggerBefore )  =
-    (sem_TriggerWhen_TriggerBefore )
--- semantic domain
-type T_TriggerWhen  = Catalog ->
-                      LocalIdentifierBindings ->
-                      ( TriggerWhen,TriggerWhen)
-data Inh_TriggerWhen  = Inh_TriggerWhen {cat_Inh_TriggerWhen :: Catalog,lib_Inh_TriggerWhen :: LocalIdentifierBindings}
-data Syn_TriggerWhen  = Syn_TriggerWhen {annotatedTree_Syn_TriggerWhen :: TriggerWhen,originalTree_Syn_TriggerWhen :: TriggerWhen}
-wrap_TriggerWhen :: T_TriggerWhen  ->
-                    Inh_TriggerWhen  ->
-                    Syn_TriggerWhen 
-wrap_TriggerWhen sem (Inh_TriggerWhen _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TriggerWhen _lhsOannotatedTree _lhsOoriginalTree ))
-sem_TriggerWhen_TriggerAfter :: T_TriggerWhen 
-sem_TriggerWhen_TriggerAfter  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerWhen
-              _lhsOoriginalTree :: TriggerWhen
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TriggerAfter
-                  {-# LINE 15130 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TriggerAfter
-                  {-# LINE 15135 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15140 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15145 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_TriggerWhen_TriggerBefore :: T_TriggerWhen 
-sem_TriggerWhen_TriggerBefore  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: TriggerWhen
-              _lhsOoriginalTree :: TriggerWhen
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TriggerBefore
-                  {-# LINE 15157 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TriggerBefore
-                  {-# LINE 15162 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15167 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15172 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
--- TypeAttributeDef --------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         attrName             : String
-         namedType            : Type
-         originalTree         : SELF 
-   alternatives:
-      alternative TypeAttDef:
-         child ann            : {Annotation}
-         child name           : {String}
-         child typ            : TypeName 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data TypeAttributeDef  = TypeAttDef (Annotation) (String) (TypeName) 
-                       deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TypeAttributeDef :: TypeAttributeDef  ->
-                        T_TypeAttributeDef 
-sem_TypeAttributeDef (TypeAttDef _ann _name _typ )  =
-    (sem_TypeAttributeDef_TypeAttDef _ann _name (sem_TypeName _typ ) )
--- semantic domain
-type T_TypeAttributeDef  = Catalog ->
-                           LocalIdentifierBindings ->
-                           ( TypeAttributeDef,String,Type,TypeAttributeDef)
-data Inh_TypeAttributeDef  = Inh_TypeAttributeDef {cat_Inh_TypeAttributeDef :: Catalog,lib_Inh_TypeAttributeDef :: LocalIdentifierBindings}
-data Syn_TypeAttributeDef  = Syn_TypeAttributeDef {annotatedTree_Syn_TypeAttributeDef :: TypeAttributeDef,attrName_Syn_TypeAttributeDef :: String,namedType_Syn_TypeAttributeDef :: Type,originalTree_Syn_TypeAttributeDef :: TypeAttributeDef}
-wrap_TypeAttributeDef :: T_TypeAttributeDef  ->
-                         Inh_TypeAttributeDef  ->
-                         Syn_TypeAttributeDef 
-wrap_TypeAttributeDef sem (Inh_TypeAttributeDef _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOattrName,_lhsOnamedType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TypeAttributeDef _lhsOannotatedTree _lhsOattrName _lhsOnamedType _lhsOoriginalTree ))
-sem_TypeAttributeDef_TypeAttDef :: Annotation ->
-                                   String ->
-                                   T_TypeName  ->
-                                   T_TypeAttributeDef 
-sem_TypeAttributeDef_TypeAttDef ann_ name_ typ_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrName :: String
-              _lhsOnamedType :: Type
-              _lhsOannotatedTree :: TypeAttributeDef
-              _lhsOoriginalTree :: TypeAttributeDef
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/MiscCreates.ag"(line 40, column 9)
-              _lhsOattrName =
-                  {-# LINE 40 "./TypeChecking/MiscCreates.ag" #-}
-                  name_
-                  {-# LINE 15234 "AstInternal.hs" #-}
-              -- "./TypeChecking/MiscCreates.ag"(line 41, column 9)
-              _lhsOnamedType =
-                  {-# LINE 41 "./TypeChecking/MiscCreates.ag" #-}
-                  _typInamedType
-                  {-# LINE 15239 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  TypeAttDef ann_ name_ _typIannotatedTree
-                  {-# LINE 15244 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  TypeAttDef ann_ name_ _typIoriginalTree
-                  {-# LINE 15249 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15254 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15259 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15264 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15269 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOattrName,_lhsOnamedType,_lhsOoriginalTree)))
--- TypeAttributeDefList ----------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         attrs                : [(String, Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : TypeAttributeDef 
-         child tl             : TypeAttributeDefList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type TypeAttributeDefList  = [(TypeAttributeDef)]
--- cata
-sem_TypeAttributeDefList :: TypeAttributeDefList  ->
-                            T_TypeAttributeDefList 
-sem_TypeAttributeDefList list  =
-    (Prelude.foldr sem_TypeAttributeDefList_Cons sem_TypeAttributeDefList_Nil (Prelude.map sem_TypeAttributeDef list) )
--- semantic domain
-type T_TypeAttributeDefList  = Catalog ->
-                               LocalIdentifierBindings ->
-                               ( TypeAttributeDefList,([(String, Type)]),TypeAttributeDefList)
-data Inh_TypeAttributeDefList  = Inh_TypeAttributeDefList {cat_Inh_TypeAttributeDefList :: Catalog,lib_Inh_TypeAttributeDefList :: LocalIdentifierBindings}
-data Syn_TypeAttributeDefList  = Syn_TypeAttributeDefList {annotatedTree_Syn_TypeAttributeDefList :: TypeAttributeDefList,attrs_Syn_TypeAttributeDefList :: [(String, Type)],originalTree_Syn_TypeAttributeDefList :: TypeAttributeDefList}
-wrap_TypeAttributeDefList :: T_TypeAttributeDefList  ->
-                             Inh_TypeAttributeDefList  ->
-                             Syn_TypeAttributeDefList 
-wrap_TypeAttributeDefList sem (Inh_TypeAttributeDefList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TypeAttributeDefList _lhsOannotatedTree _lhsOattrs _lhsOoriginalTree ))
-sem_TypeAttributeDefList_Cons :: T_TypeAttributeDef  ->
-                                 T_TypeAttributeDefList  ->
-                                 T_TypeAttributeDefList 
-sem_TypeAttributeDefList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrs :: ([(String, Type)])
-              _lhsOannotatedTree :: TypeAttributeDefList
-              _lhsOoriginalTree :: TypeAttributeDefList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: TypeAttributeDef
-              _hdIattrName :: String
-              _hdInamedType :: Type
-              _hdIoriginalTree :: TypeAttributeDef
-              _tlIannotatedTree :: TypeAttributeDefList
-              _tlIattrs :: ([(String, Type)])
-              _tlIoriginalTree :: TypeAttributeDefList
-              -- "./TypeChecking/MiscCreates.ag"(line 46, column 12)
-              _lhsOattrs =
-                  {-# LINE 46 "./TypeChecking/MiscCreates.ag" #-}
-                  (_hdIattrName, _hdInamedType) : _tlIattrs
-                  {-# LINE 15338 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 15343 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 15348 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15353 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15358 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15363 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15368 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15373 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15378 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIattrName,_hdInamedType,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIattrs,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree)))
-sem_TypeAttributeDefList_Nil :: T_TypeAttributeDefList 
-sem_TypeAttributeDefList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOattrs :: ([(String, Type)])
-              _lhsOannotatedTree :: TypeAttributeDefList
-              _lhsOoriginalTree :: TypeAttributeDefList
-              -- "./TypeChecking/MiscCreates.ag"(line 47, column 11)
-              _lhsOattrs =
-                  {-# LINE 47 "./TypeChecking/MiscCreates.ag" #-}
-                  []
-                  {-# LINE 15395 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 15400 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 15405 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15410 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15415 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOoriginalTree)))
--- TypeName ----------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         namedType            : Type
-         originalTree         : SELF 
-   alternatives:
-      alternative ArrayTypeName:
-         child ann            : {Annotation}
-         child typ            : TypeName 
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative PrecTypeName:
-         child ann            : {Annotation}
-         child tn             : {String}
-         child prec           : {Integer}
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative SetOfTypeName:
-         child ann            : {Annotation}
-         child typ            : TypeName 
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
-      alternative SimpleTypeName:
-         child ann            : {Annotation}
-         child tn             : {String}
-         visit 0:
-            local tpe         : _
-            local backTree    : _
-            local annotatedTree : _
-            local originalTree : _
--}
-data TypeName  = ArrayTypeName (Annotation) (TypeName) 
-               | PrecTypeName (Annotation) (String) (Integer) 
-               | SetOfTypeName (Annotation) (TypeName) 
-               | SimpleTypeName (Annotation) (String) 
-               deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_TypeName :: TypeName  ->
-                T_TypeName 
-sem_TypeName (ArrayTypeName _ann _typ )  =
-    (sem_TypeName_ArrayTypeName _ann (sem_TypeName _typ ) )
-sem_TypeName (PrecTypeName _ann _tn _prec )  =
-    (sem_TypeName_PrecTypeName _ann _tn _prec )
-sem_TypeName (SetOfTypeName _ann _typ )  =
-    (sem_TypeName_SetOfTypeName _ann (sem_TypeName _typ ) )
-sem_TypeName (SimpleTypeName _ann _tn )  =
-    (sem_TypeName_SimpleTypeName _ann _tn )
--- semantic domain
-type T_TypeName  = Catalog ->
-                   LocalIdentifierBindings ->
-                   ( TypeName,Type,TypeName)
-data Inh_TypeName  = Inh_TypeName {cat_Inh_TypeName :: Catalog,lib_Inh_TypeName :: LocalIdentifierBindings}
-data Syn_TypeName  = Syn_TypeName {annotatedTree_Syn_TypeName :: TypeName,namedType_Syn_TypeName :: Type,originalTree_Syn_TypeName :: TypeName}
-wrap_TypeName :: T_TypeName  ->
-                 Inh_TypeName  ->
-                 Syn_TypeName 
-wrap_TypeName sem (Inh_TypeName _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TypeName _lhsOannotatedTree _lhsOnamedType _lhsOoriginalTree ))
-sem_TypeName_ArrayTypeName :: Annotation ->
-                              T_TypeName  ->
-                              T_TypeName 
-sem_TypeName_ArrayTypeName ann_ typ_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOannotatedTree :: TypeName
-              _lhsOoriginalTree :: TypeName
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/Misc.ag"(line 19, column 10)
-              _lhsOnamedType =
-                  {-# LINE 19 "./TypeChecking/Misc.ag" #-}
-                  tpeToT _tpe
-                  {-# LINE 15509 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 20, column 10)
-              _lhsOannotatedTree =
-                  {-# LINE 20 "./TypeChecking/Misc.ag" #-}
-                  updateAnnotation
-                    ((map TypeErrorA $ getErrors _tpe    ) ++)
-                    _backTree
-                  {-# LINE 15516 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 30, column 9)
-              _tpe =
-                  {-# LINE 30 "./TypeChecking/Misc.ag" #-}
-                  dependsOnRTpe [_typInamedType] $ Right $ ArrayType _typInamedType
-                  {-# LINE 15521 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 31, column 9)
-              _backTree =
-                  {-# LINE 31 "./TypeChecking/Misc.ag" #-}
-                  ArrayTypeName ann_ _typIannotatedTree
-                  {-# LINE 15526 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  ArrayTypeName ann_ _typIannotatedTree
-                  {-# LINE 15531 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  ArrayTypeName ann_ _typIoriginalTree
-                  {-# LINE 15536 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15541 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15546 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15551 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
-sem_TypeName_PrecTypeName :: Annotation ->
-                             String ->
-                             Integer ->
-                             T_TypeName 
-sem_TypeName_PrecTypeName ann_ tn_ prec_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOannotatedTree :: TypeName
-              _lhsOoriginalTree :: TypeName
-              -- "./TypeChecking/Misc.ag"(line 19, column 10)
-              _lhsOnamedType =
-                  {-# LINE 19 "./TypeChecking/Misc.ag" #-}
-                  tpeToT _tpe
-                  {-# LINE 15569 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 20, column 10)
-              _lhsOannotatedTree =
-                  {-# LINE 20 "./TypeChecking/Misc.ag" #-}
-                  updateAnnotation
-                    ((map TypeErrorA $ getErrors _tpe    ) ++)
-                    _backTree
-                  {-# LINE 15576 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 36, column 9)
-              _tpe =
-                  {-# LINE 36 "./TypeChecking/Misc.ag" #-}
-                  catLookupType _lhsIcat $ canonicalizeTypeName tn_
-                  {-# LINE 15581 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 37, column 9)
-              _backTree =
-                  {-# LINE 37 "./TypeChecking/Misc.ag" #-}
-                  PrecTypeName ann_ tn_ prec_
-                  {-# LINE 15586 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  PrecTypeName ann_ tn_ prec_
-                  {-# LINE 15591 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  PrecTypeName ann_ tn_ prec_
-                  {-# LINE 15596 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15601 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
-sem_TypeName_SetOfTypeName :: Annotation ->
-                              T_TypeName  ->
-                              T_TypeName 
-sem_TypeName_SetOfTypeName ann_ typ_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOannotatedTree :: TypeName
-              _lhsOoriginalTree :: TypeName
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/Misc.ag"(line 19, column 10)
-              _lhsOnamedType =
-                  {-# LINE 19 "./TypeChecking/Misc.ag" #-}
-                  tpeToT _tpe
-                  {-# LINE 15621 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 20, column 10)
-              _lhsOannotatedTree =
-                  {-# LINE 20 "./TypeChecking/Misc.ag" #-}
-                  updateAnnotation
-                    ((map TypeErrorA $ getErrors _tpe    ) ++)
-                    _backTree
-                  {-# LINE 15628 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 33, column 9)
-              _tpe =
-                  {-# LINE 33 "./TypeChecking/Misc.ag" #-}
-                  dependsOnRTpe [_typInamedType] $ Right $ SetOfType _typInamedType
-                  {-# LINE 15633 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 34, column 9)
-              _backTree =
-                  {-# LINE 34 "./TypeChecking/Misc.ag" #-}
-                  SetOfTypeName ann_ _typIannotatedTree
-                  {-# LINE 15638 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SetOfTypeName ann_ _typIannotatedTree
-                  {-# LINE 15643 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SetOfTypeName ann_ _typIoriginalTree
-                  {-# LINE 15648 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15653 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15658 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15663 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
-sem_TypeName_SimpleTypeName :: Annotation ->
-                               String ->
-                               T_TypeName 
-sem_TypeName_SimpleTypeName ann_ tn_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedType :: Type
-              _lhsOannotatedTree :: TypeName
-              _lhsOoriginalTree :: TypeName
-              -- "./TypeChecking/Misc.ag"(line 19, column 10)
-              _lhsOnamedType =
-                  {-# LINE 19 "./TypeChecking/Misc.ag" #-}
-                  tpeToT _tpe
-                  {-# LINE 15680 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 20, column 10)
-              _lhsOannotatedTree =
-                  {-# LINE 20 "./TypeChecking/Misc.ag" #-}
-                  updateAnnotation
-                    ((map TypeErrorA $ getErrors _tpe    ) ++)
-                    _backTree
-                  {-# LINE 15687 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 27, column 9)
-              _tpe =
-                  {-# LINE 27 "./TypeChecking/Misc.ag" #-}
-                  catLookupType _lhsIcat $ canonicalizeTypeName tn_
-                  {-# LINE 15692 "AstInternal.hs" #-}
-              -- "./TypeChecking/Misc.ag"(line 28, column 9)
-              _backTree =
-                  {-# LINE 28 "./TypeChecking/Misc.ag" #-}
-                  SimpleTypeName ann_ tn_
-                  {-# LINE 15697 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  SimpleTypeName ann_ tn_
-                  {-# LINE 15702 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  SimpleTypeName ann_ tn_
-                  {-# LINE 15707 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15712 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
--- TypeNameList ------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         namedTypes           : [Type]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : TypeName 
-         child tl             : TypeNameList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type TypeNameList  = [(TypeName)]
--- cata
-sem_TypeNameList :: TypeNameList  ->
-                    T_TypeNameList 
-sem_TypeNameList list  =
-    (Prelude.foldr sem_TypeNameList_Cons sem_TypeNameList_Nil (Prelude.map sem_TypeName list) )
--- semantic domain
-type T_TypeNameList  = Catalog ->
-                       LocalIdentifierBindings ->
-                       ( TypeNameList,([Type]),TypeNameList)
-data Inh_TypeNameList  = Inh_TypeNameList {cat_Inh_TypeNameList :: Catalog,lib_Inh_TypeNameList :: LocalIdentifierBindings}
-data Syn_TypeNameList  = Syn_TypeNameList {annotatedTree_Syn_TypeNameList :: TypeNameList,namedTypes_Syn_TypeNameList :: [Type],originalTree_Syn_TypeNameList :: TypeNameList}
-wrap_TypeNameList :: T_TypeNameList  ->
-                     Inh_TypeNameList  ->
-                     Syn_TypeNameList 
-wrap_TypeNameList sem (Inh_TypeNameList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOnamedTypes,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_TypeNameList _lhsOannotatedTree _lhsOnamedTypes _lhsOoriginalTree ))
-sem_TypeNameList_Cons :: T_TypeName  ->
-                         T_TypeNameList  ->
-                         T_TypeNameList 
-sem_TypeNameList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedTypes :: ([Type])
-              _lhsOannotatedTree :: TypeNameList
-              _lhsOoriginalTree :: TypeNameList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: TypeName
-              _hdInamedType :: Type
-              _hdIoriginalTree :: TypeName
-              _tlIannotatedTree :: TypeNameList
-              _tlInamedTypes :: ([Type])
-              _tlIoriginalTree :: TypeNameList
-              -- "./TypeChecking/Drops.ag"(line 30, column 12)
-              _lhsOnamedTypes =
-                  {-# LINE 30 "./TypeChecking/Drops.ag" #-}
-                  _hdInamedType : _tlInamedTypes
-                  {-# LINE 15778 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 15783 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 15788 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15793 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15798 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15803 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15808 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15813 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15818 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdInamedType,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlInamedTypes,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOnamedTypes,_lhsOoriginalTree)))
-sem_TypeNameList_Nil :: T_TypeNameList 
-sem_TypeNameList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOnamedTypes :: ([Type])
-              _lhsOannotatedTree :: TypeNameList
-              _lhsOoriginalTree :: TypeNameList
-              -- "./TypeChecking/Drops.ag"(line 31, column 11)
-              _lhsOnamedTypes =
-                  {-# LINE 31 "./TypeChecking/Drops.ag" #-}
-                  []
-                  {-# LINE 15835 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 15840 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 15845 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15850 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15855 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOnamedTypes,_lhsOoriginalTree)))
--- VarDef ------------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         def                  : (String,Type)
-         originalTree         : SELF 
-   alternatives:
-      alternative VarDef:
-         child ann            : {Annotation}
-         child name           : {String}
-         child typ            : TypeName 
-         child value          : {Maybe Expression}
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data VarDef  = VarDef (Annotation) (String) (TypeName) (Maybe Expression) 
-             deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_VarDef :: VarDef  ->
-              T_VarDef 
-sem_VarDef (VarDef _ann _name _typ _value )  =
-    (sem_VarDef_VarDef _ann _name (sem_TypeName _typ ) _value )
--- semantic domain
-type T_VarDef  = Catalog ->
-                 LocalIdentifierBindings ->
-                 ( VarDef,((String,Type)),VarDef)
-data Inh_VarDef  = Inh_VarDef {cat_Inh_VarDef :: Catalog,lib_Inh_VarDef :: LocalIdentifierBindings}
-data Syn_VarDef  = Syn_VarDef {annotatedTree_Syn_VarDef :: VarDef,def_Syn_VarDef :: (String,Type),originalTree_Syn_VarDef :: VarDef}
-wrap_VarDef :: T_VarDef  ->
-               Inh_VarDef  ->
-               Syn_VarDef 
-wrap_VarDef sem (Inh_VarDef _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOdef,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_VarDef _lhsOannotatedTree _lhsOdef _lhsOoriginalTree ))
-sem_VarDef_VarDef :: Annotation ->
-                     String ->
-                     T_TypeName  ->
-                     (Maybe Expression) ->
-                     T_VarDef 
-sem_VarDef_VarDef ann_ name_ typ_ value_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOdef :: ((String,Type))
-              _lhsOannotatedTree :: VarDef
-              _lhsOoriginalTree :: VarDef
-              _typOcat :: Catalog
-              _typOlib :: LocalIdentifierBindings
-              _typIannotatedTree :: TypeName
-              _typInamedType :: Type
-              _typIoriginalTree :: TypeName
-              -- "./TypeChecking/CreateFunction.ag"(line 131, column 14)
-              _lhsOdef =
-                  {-# LINE 131 "./TypeChecking/CreateFunction.ag" #-}
-                  (name_, if _typInamedType == Pseudo Record then PgRecord Nothing else _typInamedType)
-                  {-# LINE 15917 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  VarDef ann_ name_ _typIannotatedTree value_
-                  {-# LINE 15922 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  VarDef ann_ name_ _typIoriginalTree value_
-                  {-# LINE 15927 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 15932 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 15937 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 15942 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _typOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 15947 "AstInternal.hs" #-}
-              ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
-                  (typ_ _typOcat _typOlib )
-          in  ( _lhsOannotatedTree,_lhsOdef,_lhsOoriginalTree)))
--- VarDefList --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         defs                 : [(String,Type)]
-         originalTree         : SELF 
-   alternatives:
-      alternative Cons:
-         child hd             : VarDef 
-         child tl             : VarDefList 
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Nil:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-type VarDefList  = [(VarDef)]
--- cata
-sem_VarDefList :: VarDefList  ->
-                  T_VarDefList 
-sem_VarDefList list  =
-    (Prelude.foldr sem_VarDefList_Cons sem_VarDefList_Nil (Prelude.map sem_VarDef list) )
--- semantic domain
-type T_VarDefList  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( VarDefList,([(String,Type)]),VarDefList)
-data Inh_VarDefList  = Inh_VarDefList {cat_Inh_VarDefList :: Catalog,lib_Inh_VarDefList :: LocalIdentifierBindings}
-data Syn_VarDefList  = Syn_VarDefList {annotatedTree_Syn_VarDefList :: VarDefList,defs_Syn_VarDefList :: [(String,Type)],originalTree_Syn_VarDefList :: VarDefList}
-wrap_VarDefList :: T_VarDefList  ->
-                   Inh_VarDefList  ->
-                   Syn_VarDefList 
-wrap_VarDefList sem (Inh_VarDefList _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOdefs,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_VarDefList _lhsOannotatedTree _lhsOdefs _lhsOoriginalTree ))
-sem_VarDefList_Cons :: T_VarDef  ->
-                       T_VarDefList  ->
-                       T_VarDefList 
-sem_VarDefList_Cons hd_ tl_  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOdefs :: ([(String,Type)])
-              _lhsOannotatedTree :: VarDefList
-              _lhsOoriginalTree :: VarDefList
-              _hdOcat :: Catalog
-              _hdOlib :: LocalIdentifierBindings
-              _tlOcat :: Catalog
-              _tlOlib :: LocalIdentifierBindings
-              _hdIannotatedTree :: VarDef
-              _hdIdef :: ((String,Type))
-              _hdIoriginalTree :: VarDef
-              _tlIannotatedTree :: VarDefList
-              _tlIdefs :: ([(String,Type)])
-              _tlIoriginalTree :: VarDefList
-              -- "./TypeChecking/CreateFunction.ag"(line 134, column 12)
-              _lhsOdefs =
-                  {-# LINE 134 "./TypeChecking/CreateFunction.ag" #-}
-                  _hdIdef : _tlIdefs
-                  {-# LINE 16015 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIannotatedTree _tlIannotatedTree
-                  {-# LINE 16020 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  (:) _hdIoriginalTree _tlIoriginalTree
-                  {-# LINE 16025 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 16030 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 16035 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 16040 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _hdOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 16045 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOcat =
-                  {-# LINE 56 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIcat
-                  {-# LINE 16050 "AstInternal.hs" #-}
-              -- copy rule (down)
-              _tlOlib =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _lhsIlib
-                  {-# LINE 16055 "AstInternal.hs" #-}
-              ( _hdIannotatedTree,_hdIdef,_hdIoriginalTree) =
-                  (hd_ _hdOcat _hdOlib )
-              ( _tlIannotatedTree,_tlIdefs,_tlIoriginalTree) =
-                  (tl_ _tlOcat _tlOlib )
-          in  ( _lhsOannotatedTree,_lhsOdefs,_lhsOoriginalTree)))
-sem_VarDefList_Nil :: T_VarDefList 
-sem_VarDefList_Nil  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOdefs :: ([(String,Type)])
-              _lhsOannotatedTree :: VarDefList
-              _lhsOoriginalTree :: VarDefList
-              -- "./TypeChecking/CreateFunction.ag"(line 135, column 11)
-              _lhsOdefs =
-                  {-# LINE 135 "./TypeChecking/CreateFunction.ag" #-}
-                  []
-                  {-# LINE 16072 "AstInternal.hs" #-}
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 16077 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  []
-                  {-# LINE 16082 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 16087 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 16092 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOdefs,_lhsOoriginalTree)))
--- Volatility --------------------------------------------------
-{-
-   visit 0:
-      inherited attributes:
-         cat                  : Catalog
-         lib                  : LocalIdentifierBindings
-      synthesized attributes:
-         annotatedTree        : SELF 
-         originalTree         : SELF 
-   alternatives:
-      alternative Immutable:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Stable:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
-      alternative Volatile:
-         visit 0:
-            local annotatedTree : _
-            local originalTree : _
--}
-data Volatility  = Immutable 
-                 | Stable 
-                 | Volatile 
-                 deriving ( Data,Eq,Show,Typeable)
--- cata
-sem_Volatility :: Volatility  ->
-                  T_Volatility 
-sem_Volatility (Immutable )  =
-    (sem_Volatility_Immutable )
-sem_Volatility (Stable )  =
-    (sem_Volatility_Stable )
-sem_Volatility (Volatile )  =
-    (sem_Volatility_Volatile )
--- semantic domain
-type T_Volatility  = Catalog ->
-                     LocalIdentifierBindings ->
-                     ( Volatility,Volatility)
-data Inh_Volatility  = Inh_Volatility {cat_Inh_Volatility :: Catalog,lib_Inh_Volatility :: LocalIdentifierBindings}
-data Syn_Volatility  = Syn_Volatility {annotatedTree_Syn_Volatility :: Volatility,originalTree_Syn_Volatility :: Volatility}
-wrap_Volatility :: T_Volatility  ->
-                   Inh_Volatility  ->
-                   Syn_Volatility 
-wrap_Volatility sem (Inh_Volatility _lhsIcat _lhsIlib )  =
-    (let ( _lhsOannotatedTree,_lhsOoriginalTree) =
-             (sem _lhsIcat _lhsIlib )
-     in  (Syn_Volatility _lhsOannotatedTree _lhsOoriginalTree ))
-sem_Volatility_Immutable :: T_Volatility 
-sem_Volatility_Immutable  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Volatility
-              _lhsOoriginalTree :: Volatility
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Immutable
-                  {-# LINE 16153 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Immutable
-                  {-# LINE 16158 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 16163 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 16168 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Volatility_Stable :: T_Volatility 
-sem_Volatility_Stable  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Volatility
-              _lhsOoriginalTree :: Volatility
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Stable
-                  {-# LINE 16180 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Stable
-                  {-# LINE 16185 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 16190 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 16195 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
-sem_Volatility_Volatile :: T_Volatility 
-sem_Volatility_Volatile  =
-    (\ _lhsIcat
-       _lhsIlib ->
-         (let _lhsOannotatedTree :: Volatility
-              _lhsOoriginalTree :: Volatility
-              -- self rule
-              _annotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  Volatile
-                  {-# LINE 16207 "AstInternal.hs" #-}
-              -- self rule
-              _originalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  Volatile
-                  {-# LINE 16212 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOannotatedTree =
-                  {-# LINE 57 "./TypeChecking/TypeChecking.ag" #-}
-                  _annotatedTree
-                  {-# LINE 16217 "AstInternal.hs" #-}
-              -- self rule
-              _lhsOoriginalTree =
-                  {-# LINE 63 "./TypeChecking/TypeChecking.ag" #-}
-                  _originalTree
-                  {-# LINE 16222 "AstInternal.hs" #-}
-          in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
diff --git a/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs b/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs
+++ /dev/null
@@ -1,492 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This module contains the implementation of the Catalog data types
-and functions, and provides the api for the other type checking
-modules.
-
-> {-# LANGUAGE DeriveDataTypeable #-}
-> {-# OPTIONS_HADDOCK hide  #-}
-
-> module Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
->     (
->      Catalog
->     ,CastContext(..)
->     ,CompositeFlavour(..)
->     ,relationComposites
->     ,CompositeDef
->     ,FunctionPrototype
->     ,DomainDefinition
->     ,FunFlav(..)
->     ,emptyCatalog
->     ,defaultCatalog
->     ,CatalogUpdate(..)
->     ,ppCatUpdate
->     ,updateCatalog
->     ,deconstructCatalog
->     -- type checker stuff
->     ,catCompositeDef
->     ,catCompositeAttrsPair
->     ,catCompositeAttrs
->     ,catCompositePublicAttrs
->     ,catTypeCategory
->     ,catPreferredType
->     ,catCast
->     ,catDomainBaseType
->     ,catLookupFns
->     ,catTypeExists
->     ,catLookupType
->     ,OperatorType(..)
->     ,getOperatorType
->     ,isOperatorName
->     -- comparing catalogs
->     ,CatalogDiff(..)
->     ,compareCatalogs
->     ,ppCatDiff
->     ) where
-
-> import Control.Monad
-> import Data.List
-> import Data.Generics
-> -- import Debug.Trace
-> import Data.Char
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-> import Database.HsSqlPpp.Utils
-
-> -- | The main datatype, this holds the catalog and context
-> -- information to type check against.
-> data Catalog = Catalog
->                    {catTypeNames :: [(String, Type)]
->                    ,catDomainDefs :: [DomainDefinition]
->                    ,catCasts :: [(Type,Type,CastContext)]
->                    ,catTypeCategories :: [(Type,String,Bool)]
->                    ,catPrefixOperators :: [FunctionPrototype]
->                    ,catPostfixOperators :: [FunctionPrototype]
->                    ,catBinaryOperators :: [FunctionPrototype]
->                    ,catFunctions :: [FunctionPrototype]
->                    ,catAggregates :: [FunctionPrototype]
->                    ,catWindowFunctions :: [FunctionPrototype]
->                    ,catAttrDefs :: [CompositeDef]
->                    ,catUpdates :: [CatalogUpdate]}
->                    deriving Show
-
-> -- | Represents an empty catalog. This doesn't contain things
-> -- like the \'and\' operator, 'defaultCatalog' contains these.
-> emptyCatalog :: Catalog
-> emptyCatalog = Catalog [] [] [] [] [] [] [] [] [] [] [] []
-
-> -- | 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..
-> defaultCatalog :: Catalog
-> defaultCatalog = emptyCatalog {
->                       catTypeNames = pseudoTypes
->                      ,catBinaryOperators = ("=",[Pseudo AnyElement
->                                                 ,Pseudo AnyElement],
->                                             typeBool, False):keywordOperatorTypes
->                      ,catFunctions = specialFunctionTypes}
-
-
-> -- | Use to note what the flavour of a cast is, i.e. if/when it can
-> -- be used implicitly.
-> data CastContext = ImplicitCastContext
->                  | AssignmentCastContext
->                  | ExplicitCastContext
->                    deriving (Eq,Show,Ord,Typeable,Data)
-
-> -- | Used to distinguish between standalone composite types, and
-> -- automatically generated ones, generated from a table or view
-> -- respectively.
-> data CompositeFlavour = Composite | TableComposite | ViewComposite
->                         deriving (Eq,Ord,Show)
-
-> relationComposites :: [CompositeFlavour]
-> relationComposites = [TableComposite,ViewComposite]
-
-
-> -- | 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 'CompositeType's).
-> type CompositeDef = (String, CompositeFlavour, Type, Type)
-
-> -- | The components are: function (or operator) name, argument
-> -- types, return type and is variadic.
-> type FunctionPrototype = (String, [Type], Type, Bool)
-
-> -- | The components are domain type, base type (todo: add check
-> -- constraint).
-> type DomainDefinition = (Type,Type)
-
-> data CatalogUpdate =
->     -- | add a new scalar type with the name given, also creates
->     -- an array type automatically
->     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]
->     deriving (Eq,Ord,Typeable,Data,Show)
-
-> ppCatUpdate :: CatalogUpdate -> String
-> ppCatUpdate (CatCreateScalar t c p) = "CatCreateScalar " ++ show t ++ "(" ++ c ++ "," ++ show p ++ ")"
-> ppCatUpdate (CatCreateDomain t b) = "CatCreateDomain " ++ show t ++ " as " ++ show b
-> ppCatUpdate (CatCreateComposite nm flds) = "CatCreateComposite " ++ nm ++ showFlds flds
-> ppCatUpdate (CatCreateCast s t ctx) = "CatCreateCast " ++ show s ++ "->" ++ show t ++ " " ++ show ctx
-> ppCatUpdate (CatCreateTable nm flds1 flds2) = "CatCreateTable " ++ nm ++ showFlds flds1 ++ showFlds flds2
-> ppCatUpdate (CatCreateView nm flds) = "CatCreateView " ++ nm ++ showFlds flds
-> ppCatUpdate (CatCreateFunction flav nm args ret vdc) =
->     "CatCreateFunction " ++ show flav ++ " " ++ nm ++ " returns " ++ show ret ++
->     "(" ++ intercalate "," (map show args) ++ ")" ++ if vdc then " variadic" else ""
-> ppCatUpdate (CatDropFunction _ nm args) = "CatDropFunction " ++ nm ++ "(" ++ show args ++ ")"
-
-> showFlds :: [(String,Type)] -> String
-> showFlds flds = "(\n" ++ sfs flds ++ ")"
->                 where
->                   sfs ((nm,t):fs) = "    " ++ show nm ++ " " ++ show t ++ "\n" ++ sfs fs
->                   sfs [] = ""
-
-> data FunFlav = FunPrefix | FunPostfix | FunBinary
->              | FunName | FunAgg | FunWindow
->                deriving (Eq,Show,Ord,Typeable,Data)
-
-> -- | Applies a list of 'CatalogUpdate's to an 'Catalog' value
-> -- to produce a new Catalog value.
-> updateCatalog :: Catalog
->                   -> [CatalogUpdate]
->                   -> Either [TypeError] Catalog
-> updateCatalog cat' eus =
->   foldM updateCat' (cat' {catUpdates = catUpdates cat' ++ eus}) eus
->   where
->     updateCat' cat eu =
->       case eu of
->         CatCreateScalar ty catl pref -> do
->                 errorWhen (not allowed)
->                   [BadCatalogUpdate $ "can only add scalar types\
->                                       \this way, got " ++ show ty]
->                 let ScalarType nm = ty
->                 return $ addTypeWithArray cat nm ty catl pref
->                 where
->                   allowed = case ty of
->                                     ScalarType _ -> True
->                                     _ -> False
->         CatCreateDomain ty baseTy -> do
->                 errorWhen (not allowed)
->                   [BadCatalogUpdate $ "can only add domain types\
->                                       \this way, got " ++ show ty]
->                 errorWhen (not baseAllowed)
->                   [BadCatalogUpdate $ "can only add domain types\
->                                           \based on scalars, got "
->                                           ++ show baseTy]
->                 let DomainType nm = ty
->                 catl <- catTypeCategory cat baseTy
->                 return (addTypeWithArray cat nm ty catl False) {
->                                        catDomainDefs =
->                                          (ty,baseTy):catDomainDefs cat
->                                        ,catCasts =
->                                          (ty,baseTy,ImplicitCastContext):catCasts cat}
->                 where
->                   allowed = case ty of
->                                             DomainType _ -> True
->                                             _ -> False
->                   baseAllowed = case baseTy of
->                                                     ScalarType _ -> True
->                                                     _ -> False
-
->         CatCreateComposite nm flds ->
->                 return $ (addTypeWithArray cat nm (NamedCompositeType nm) "C" False) {
->                             catAttrDefs =
->                               (nm,Composite,CompositeType flds, CompositeType [])
->                               : catAttrDefs cat}
->         CatCreateCast src tgt ctx -> return $ cat {catCasts = (src,tgt,ctx):catCasts cat}
->         CatCreateTable nm attrs sysAttrs -> do
->                 checkTypeDoesntExist cat nm (NamedCompositeType nm)
->                 return $ (addTypeWithArray cat nm
->                             (NamedCompositeType nm) "C" False) {
->                             catAttrDefs =
->                               (nm,TableComposite,CompositeType attrs, CompositeType sysAttrs)
->                               : catAttrDefs cat}
->         CatCreateView nm attrs -> {-trace ("create view:" ++ show nm) $-} do
->                 checkTypeDoesntExist cat nm (NamedCompositeType nm)
->                 return $ (addTypeWithArray cat nm
->                             (NamedCompositeType nm) "C" False) {
->                             catAttrDefs =
->                               (nm,ViewComposite,CompositeType attrs, CompositeType [])
->                               : catAttrDefs cat}
->         CatCreateFunction f nm args ret vdc ->
->             return $ case f of
->               FunPrefix -> cat {catPrefixOperators=(nm,args,ret,vdc):catPrefixOperators cat}
->               FunPostfix -> cat {catPostfixOperators=(nm,args,ret,vdc):catPostfixOperators cat}
->               FunBinary -> cat {catBinaryOperators=(nm,args,ret,vdc):catBinaryOperators cat}
->               FunAgg -> cat {catAggregates=(nm,args,ret,vdc):catAggregates cat}
->               FunWindow -> cat {catWindowFunctions=(nm,args,ret,vdc):catWindowFunctions cat}
->               FunName -> cat {catFunctions=(nm,args,ret,vdc):catFunctions cat}
->         CatDropFunction ifexists nm args -> do
->             let matches =  filter matchingFn (catFunctions cat)
->             errorWhen (null matches) [BadCatalogUpdate $
->                                         "couldn't find function to drop " ++
->                                         show nm ++ "(" ++ show args++")"]
->             errorWhen (length matches > 1) [BadCatalogUpdate $
->                                               "multiple matching functions to drop " ++
->                                               show nm ++ "(" ++ show args++")"]
->             return cat {catFunctions = filter (not . matchingFn) (catFunctions cat)
->                        ,catUpdates = filter (not.matchingUpdate) (catUpdates cat)}
->             where
->               matchingFn (nm1,a1,_,_) = map toLower nm == map toLower nm1 && args == a1
->               matchingUpdate (CatDropFunction _ nm2 a2) | map toLower nm2 == map toLower nm
->                                                           && a2 == args = True
->               matchingUpdate (CatCreateFunction _ nm2 a2 _ _) | map toLower nm2 == map toLower nm
->                                                           && a2 == args = True
->               matchingUpdate _ = False
-
-todo:
-look for matching function in list, if not found then error
-remove from list, and remove from update list
-
-
->     addTypeWithArray cat nm ty catl pref =
->       cat {catTypeNames =
->                ('_':nm,ArrayType ty)
->                : (nm,ty)
->                : catTypeNames cat
->           ,catTypeCategories =
->                (ArrayType ty,"A",False)
->                : (ty,catl,pref)
->                : catTypeCategories cat}
->     checkTypeDoesntExist cat nm ty = do
->         errorWhen (any (==nm) $ map fst $ catTypeNames cat)
->             [TypeAlreadyExists ty]
->         errorWhen (any (==ty) $ map snd $ catTypeNames cat)
->             [TypeAlreadyExists ty]
->         return ()
-
-
-> {-
->  | Takes part an 'Catalog' value to produce a list of 'CatalogUpdate's.
->  You can use this to look inside the Catalog data type e.g. if you want to
->  examine a catalog. It should be the case that:
->  @
->   updateCatalog emptyCatalog (deconstructCatalog cat) = cat
->  @ -}
-> deconstructCatalog :: Catalog -> [CatalogUpdate]
-> deconstructCatalog = catUpdates
-
-
-================================================================================
-
-= type checking stuff
-
-> catCompositeDef :: Catalog -> [CompositeFlavour] -> String -> Either [TypeError] (CompositeDef)
-> catCompositeDef cat flvs nm = do
->   let c = filter (\(n,t,_,_) -> n == nm && (null flvs || t `elem` flvs)) $ catAttrDefs cat
->   errorWhen (null c)
->             [UnrecognisedRelation nm]
->   case c of
->     (_,fl1,r,s):[] -> return (nm,fl1,r,s)
->     _ -> Left [InternalError $ "problem getting attributes for: " ++ show nm ++ ", " ++ show c]
-
-> catCompositeAttrsPair :: Catalog -> [CompositeFlavour] -> String
->                       -> Either [TypeError] ([(String,Type)],[(String,Type)])
-> catCompositeAttrsPair cat flvs ty = do
->    (_,_,CompositeType a,CompositeType b) <- catCompositeDef cat flvs ty
->    return (a,b)
-
-> catCompositeAttrs :: Catalog -> [CompositeFlavour] -> String
->                   -> Either [TypeError] [(String,Type)]
-> catCompositeAttrs cat flvs ty = do
->   (a,b) <- catCompositeAttrsPair cat flvs ty
->   return $ a ++ b
-
-> catCompositePublicAttrs :: Catalog -> [CompositeFlavour] -> String
->                   -> Either [TypeError] [(String,Type)]
-> catCompositePublicAttrs cat flvs ty = do
->   (a,_) <- catCompositeAttrsPair cat flvs ty
->   return a
-
-
-> catTypeCategory :: Catalog -> Type -> Either [TypeError] String
-> catTypeCategory cat ty =
->   fmap fst $ catGetCategoryInfo cat ty
-
-> catPreferredType :: Catalog -> Type -> Either [TypeError] Bool
-> catPreferredType cat ty =
->   fmap snd $ catGetCategoryInfo cat ty
-
-> catCast :: Catalog -> CastContext -> Type -> Type -> Either [TypeError] Bool
-> catCast cat ctx from to = {-trace ("check cast " ++ show from ++ show to) $-}
->     case from of
->       t@(DomainType _) -> do
->                 baseType <- catDomainBaseType cat t
->                 cc <- catCast cat ctx baseType to
->                 return $ (baseType == to) ||
->                                (cc ||
->                                   any (== (from, to, ctx)) (catCasts cat))
->       _ -> Right $ any (==(from,to,ctx)) (catCasts cat)
-
-
-> catDomainBaseType :: Catalog -> Type -> Either [TypeError] Type
-> catDomainBaseType cat ty =
->   --check type is domain, check it exists in main list
->   case lookup ty (catDomainDefs cat) of
->       Nothing -> Left [DomainDefNotFound ty]
->       Just t -> Right t
-
-
-> catLookupFns :: Catalog -> String -> [FunctionPrototype]
-> catLookupFns cat name =
->     filter (\(nm,_,_,_) -> map toLower nm == map toLower name) catGetAllFns
->     where
->     catGetAllFns =
->         concat [catPrefixOperators cat
->                ,catPostfixOperators cat
->                ,catBinaryOperators cat
->                ,catFunctions cat
->                ,catAggregates cat
->                ,catWindowFunctions cat]
-
-== internal support for type checker fns above
-
-> catGetCategoryInfo :: Catalog -> Type -> Either [TypeError] (String, Bool)
-> catGetCategoryInfo cat ty =
->   case ty of
->     SetOfType _ -> Right ("", False)
->     AnonymousRecordType _ -> Right ("", False)
->     ArrayType (Pseudo _) -> Right ("A",False)
->     Pseudo _ -> Right ("P",False)
->     _ -> let l = filter (\(t,_,_) -> ty == t) $ catTypeCategories cat
->          in if null l
->               then Left [InternalError $ "no type category for " ++ show ty]
->               else let (_,c,p):_ =l
->                    in Right (c,p)
-
-> catTypeExists :: Catalog -> Type -> Either [TypeError] Type
-> catTypeExists cat t =
->     errorWhen (t `notElem` map snd (catTypeNames cat))
->               [UnknownTypeError t] >>
->     Right t
-
-> catLookupType :: Catalog -> String -> Either [TypeError] Type
-> catLookupType cat name =
->     liftME [UnknownTypeName name] $
->       lookup name (catTypeNames cat)
-
-
-================================================================================
-
-= built in stuff
-
-keyword operators, all of these are built in and don't appear in any
-postgresql catalog
-
-This is wrong, these need to be separated into prefix, postfix, binary
-
-> keywordOperatorTypes :: [FunctionPrototype]
-> keywordOperatorTypes = [
->   ("!and", [typeBool, typeBool], typeBool, False)
->  ,("!or", [typeBool, typeBool], typeBool, False)
->  ,("!like", [ScalarType "text", ScalarType "text"], typeBool, False)
->  ,("!not", [typeBool], typeBool, False)
->  ,("!isnull", [Pseudo AnyElement], typeBool, False)
->  ,("!isnotnull", [Pseudo AnyElement], typeBool, False)
->  ,("!arrayctor", [ArrayType $ Pseudo AnyElement], Pseudo AnyArray, True)
->  ,("!between", [Pseudo AnyElement
->                ,Pseudo AnyElement
->                ,Pseudo AnyElement], Pseudo AnyElement, False)
->  ,("!substring", [ScalarType "text",typeInt,typeInt], ScalarType "text", False)
->  ,("!arraysub", [Pseudo AnyArray,typeInt], Pseudo AnyElement, False)
->  ]
-
-these look like functions, but don't appear in the postgresql catalog.
-
-> specialFunctionTypes :: [FunctionPrototype]
-> specialFunctionTypes = [
->   ("coalesce", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement, True)
->  ,("nullif", [Pseudo AnyElement, Pseudo AnyElement], Pseudo AnyElement,False)
->  ,("greatest", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement,True)
->  ,("least", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement,True)
->  ]
-
-> pseudoTypes :: [(String, Type)]
-> pseudoTypes =
->     [("any",Pseudo Any)
->     ,("anyarray",Pseudo AnyArray)
->     ,("anyelement",Pseudo AnyElement)
->     ,("anyenum",Pseudo AnyEnum)
->     ,("anynonarray",Pseudo AnyNonArray)
->     ,("cstring",Pseudo Cstring)
->     ,("record",Pseudo Record)
->     ,("trigger",Pseudo Trigger)
->     ,("void",Pseudo Void)
->     ,("_cstring",ArrayType $ Pseudo Cstring)
->     ,("_record",ArrayType $ Pseudo Record)
->     --,Pseudo Internal
->     --,Pseudo LanguageHandler
->     --,Pseudo Opaque
->     ]
-
-================================================================================
-
-= getOperatorType
-
-used by the pretty printer, not sure this is a very good design
-
-for now, assume that all the overloaded operators that have the
-same name are all either binary, prefix or postfix, otherwise the
-getoperatortype would need the types of the arguments to determine
-the operator type, and the parser would have to be a lot cleverer
-although, parsec handles - being unary and binary without breaking
-a sweat, so maybe this isn't too difficult?
-
-this is why binary @ operator isn't currently supported
-
-> data OperatorType = BinaryOp | PrefixOp | PostfixOp
->                   deriving (Eq,Show)
-
-> getOperatorType :: Catalog -> String -> Either [TypeError] OperatorType
-> getOperatorType cat s = case () of
->                       _ | s `elem` ["!and", "!or","!like"] -> Right BinaryOp
->                         | s `elem` ["!not"] -> Right PrefixOp
->                         | s `elem` ["!isnull", "!isnotnull"] -> Right PostfixOp
->                         | any (\(x,_,_,_) -> x == s) (catBinaryOperators cat) ->
->                             Right BinaryOp
->                         | any (\(x,_,_,_) -> x == s ||
->                                            (x=="-" && s=="u-"))
->                               (catPrefixOperators cat) ->
->                             Right PrefixOp
->                         | any (\(x,_,_,_) -> x == s) (catPostfixOperators cat) ->
->                             Right PostfixOp
->                         | otherwise ->
->                             Left [InternalError $ "don't know flavour of operator " ++ s]
-
-> isOperatorName :: String -> Bool
-> isOperatorName = any (`elem` "+-*/<>=~!@#%^&|`?")
-
-================================================================================
-
-> -- | items in first catalog and not second, items in second and not first.
-> data CatalogDiff = CatalogDiff [CatalogUpdate] [CatalogUpdate]
->                deriving Show
-
-> -- | find differences between two catalogs
-> compareCatalogs :: Catalog -> Catalog -> Catalog -> CatalogDiff
-> compareCatalogs base start end =
->         let baseCatBits = deconstructCatalog base
->             startCatBits = deconstructCatalog start \\ baseCatBits
->             endCatBits = deconstructCatalog end \\ baseCatBits
->             missing = sort $ endCatBits \\ startCatBits
->             extras = sort $ startCatBits \\ endCatBits
->         in CatalogDiff missing extras
-
-> -- | print a catdiff in a more human readable way than show.
-> ppCatDiff :: CatalogDiff -> String
-> ppCatDiff (CatalogDiff missing extr) =
->     "\nmissing:\n"
->     ++ intercalate "\n" (map ppCatUpdate missing)
->     ++ "\nextra:\n"
->     ++ intercalate "\n" (map ppCatUpdate extr)
diff --git a/Database/HsSqlPpp/AstInternals/Catalog/CatalogReader.lhs b/Database/HsSqlPpp/AstInternals/Catalog/CatalogReader.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/Catalog/CatalogReader.lhs
+++ /dev/null
@@ -1,258 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This module contains the code to read a set of catalog updates
-from a database.
-
-The code here hasn't been tidied up since the Catalog data type
-was heavily changed so it's a bit messy.
-
-> {-# OPTIONS_HADDOCK hide  #-}
-
-> module Database.HsSqlPpp.AstInternals.Catalog.CatalogReader
->     (readCatalogFromDatabase) where
-
-> import qualified Data.Map as M
-> import Data.Maybe
-> import Control.Applicative
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.Dbms.DBAccess
-> import Database.HsSqlPpp.AstInternals.TypeType
-> import Database.HsSqlPpp.Utils
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-
-> -- | Creates an 'CatalogUpdate' list by reading the database given.
-> -- To create an Catalog value from this, use
-> --
-> -- @
-> -- cat <- readCatalogFromDatabase 'something'
-> -- let newCat = updateCatalog defaultCatalog cat
-> -- @
-> readCatalogFromDatabase :: String -- ^ name of the database to read
->                             -> IO [CatalogUpdate]
-> readCatalogFromDatabase dbName = withConn ("dbname=" ++ dbName) $ \conn -> do
->    typeInfo <- selectRelation conn
->                  "select t.oid as oid,\n\
->                  \       t.typtype,\n\
->                  \       case nspname\n\
->                  \         when 'public' then t.typname\n\
->                  \         when 'pg_catalog' then t.typname\n\
->                  \         else nspname || '.' || t.typname\n\
->                  \       end as typname,\n\
->                  \       t.typarray,\n\
->                  \       coalesce(e.typtype,'0') as atyptype,\n\
->                  \       e.oid as aoid,\n\
->                  \       e.typname as atypname\n\
->                  \  from pg_catalog.pg_type t\n\
->                  \  left outer join pg_type e\n\
->                  \    on t.typarray = e.oid\n\
->                  \   inner join pg_namespace ns\n\
->                  \      on t.typnamespace = ns.oid\n\
->                   \         and ns.nspname in ('pg_catalog', 'public', 'information_schema')\n\
->                  \  where /*pg_catalog.pg_type_is_visible(t.oid)\n\
->                  \   and */not exists(select 1 from pg_catalog.pg_type el\n\
->                  \                       where el.typarray = t.oid)\n\
->                  \  order by t.typname;" []
->    let typeStuff = concatMap convTypeInfoRow typeInfo
->        typeAssoc = map (\(a,b,_) -> (a,b)) typeStuff
->        typeMap = M.fromList typeAssoc
->    cts <- map (\(nm:cat:pref:[]) ->
->                CatCreateScalar (ScalarType nm) cat ( read pref :: Bool)) <$>
->           selectRelation conn
->                        "select t.typname,typcategory,typispreferred\n\
->                        \from pg_type t\n\
->                        \   inner join pg_namespace ns\n\
->                        \      on t.typnamespace = ns.oid\n\
->                        \         and ns.nspname in ('pg_catalog', 'public', 'information_schema')\n\
->                        \where t.typarray<>0 and\n\
->                        \    typtype='b' /*and\n\
->                        \    pg_catalog.pg_type_is_visible(t.oid)*/;" []
->    domainDefInfo <- selectRelation conn
->                       "select pg_type.oid, typbasetype\n\
->                       \  from pg_type\n\
->                       \  inner join pg_namespace ns\n\
->                       \      on pg_type.typnamespace = ns.oid\n\
->                       \         and ns.nspname in ('pg_catalog', 'public', 'information_schema')\n\
->                       \ where typtype = 'd'\n\
->                       \     /*and  pg_catalog.pg_type_is_visible(oid)*/;" []
->    let jlt k = fromJust $ M.lookup k typeMap
->    let domainDefs = map (\l -> (jlt (l!!0),  jlt (l!!1))) domainDefInfo
->    --let domainCasts = map (\(t,b) ->(t,b,ImplicitCastContext)) domainDefs
->    castInfo <- selectRelation conn
->                  "select castsource,casttarget,castcontext from pg_cast;" []
->    let casts = {- domainCasts ++ -}  flip map castInfo
->                  (\l -> (jlt (l!!0), jlt (l!!1),
->                          case (l!!2) of
->                                      "a" -> AssignmentCastContext
->                                      "i" -> ImplicitCastContext
->                                      "e" -> ExplicitCastContext
->                                      _ -> error $ "internal error: unknown cast context " ++ (l!!2)))
->    operatorInfo <- selectRelation conn
->                        "select oprname,\n\
->                        \       oprleft,\n\
->                        \       oprright,\n\
->                        \       oprresult\n\
->                        \from pg_operator\n\
->                        \      where not (oprleft <> 0 and oprright <> 0\n\
->                        \         and oprname = '@') --hack for now\n\
->                        \      order by oprname;" []
->    let getOps a b c [] = (a,b,c)
->        getOps pref post bin (l:ls) =
->          let bit = (\a -> (l!!0, a, jlt(l!!3)))
->          in case () of
->                   _ | l!!1 == "0" -> getOps (bit [jlt (l!!2)]:pref) post bin ls
->                     | l!!2 == "0" -> getOps pref (bit [jlt (l!!1)]:post) bin ls
->                     | otherwise -> getOps pref post (bit [jlt (l!!1), jlt (l!!2)]:bin) ls
->    let (prefixOps, postfixOps, binaryOps) = getOps [] [] [] operatorInfo
->    functionInfo <- selectRelation conn
->                       "select proname,\n\
->                       \       array_to_string(proargtypes,','),\n\
->                       \       proretset,\n\
->                       \       prorettype\n\
->                       \from pg_proc\n\
->                       \where pg_catalog.pg_function_is_visible(pg_proc.oid)\n\
->                       \      and provariadic = 0\n\
->                       \      and not proisagg\n\
->                       \      and not proiswindow\n\
->                       \order by proname,proargtypes;" []
->    let fnProts = map (convFnRow jlt) functionInfo
-
->    aggregateInfo <- selectRelation conn
->                       "select proname,\n\
->                       \       array_to_string(proargtypes,','),\n\
->                       \       proretset,\n\
->                       \       prorettype\n\
->                       \from pg_proc\n\
->                       \where pg_catalog.pg_function_is_visible(pg_proc.oid)\n\
->                       \      and provariadic = 0\n\
->                       \      and proisagg\n\
->                       \order by proname,proargtypes;" []
->    let aggProts = map (convFnRow jlt) aggregateInfo
-
->    windowInfo <- selectRelation conn
->                       "select proname,\n\
->                       \       array_to_string(proargtypes,','),\n\
->                       \       proretset,\n\
->                       \       prorettype\n\
->                       \from pg_proc\n\
->                       \where pg_catalog.pg_function_is_visible(pg_proc.oid)\n\
->                       \      and provariadic = 0\n\
->                       \      and proiswindow\n\
->                       \order by proname,proargtypes;" []
->    let winProts = map (convFnRow jlt) windowInfo
-
-
->    comps <- map (\(kind:nm:atts:sysatts:nsp:[]) ->
->              let nm1 = case nsp of
->                                 "pg_catalog" -> nm
->                                 "public" -> nm
->                                 n -> n ++ "." ++ nm
->              in case kind of
->                     "c" -> CatCreateComposite nm1 (convertAttString jlt atts)
->                     "r" -> CatCreateTable nm1 (convertAttString jlt atts) (convertAttString jlt sysatts)
->                     "v" -> CatCreateView nm1 (convertAttString jlt atts)
->                     _ -> error $ "unrecognised relkind: " ++ kind) <$>
->                 selectRelation conn
->                   "with att1 as (\n\
->                   \ select\n\
->                   \     attrelid,\n\
->                   \     attname,\n\
->                   \     attnum,\n\
->                   \     atttypid\n\
->                   \   from pg_attribute\n\
->                   \   inner join pg_class cls\n\
->                   \      on cls.oid = attrelid\n\
->                   \   inner join pg_namespace ns\n\
->                   \      on cls.relnamespace = ns.oid\n\
->                   \         and ns.nspname in ('pg_catalog', 'public', 'information_schema')\n\
->                   \   where /*pg_catalog.pg_table_is_visible(cls.oid)\n\
->                   \      and*/ cls.relkind in ('r','v','c')\n\
->                   \      and not attisdropped),\n\
->                   \ sysAtt as (\n\
->                   \ select attrelid,\n\
->                   \     array_to_string(\n\
->                   \       array_agg(attname || ';' || atttypid)\n\
->                   \         over (partition by attrelid order by attnum\n\
->                   \               range between unbounded preceding\n\
->                   \               and unbounded following)\n\
->                   \       ,',') as sysAtts\n\
->                   \   from att1\n\
->                   \   where attnum < 0),\n\
->                   \ att as (\n\
->                   \ select attrelid,\n\
->                   \     array_to_string(\n\
->                   \       array_agg(attname || ';' || atttypid)\n\
->                   \          over (partition by attrelid order by attnum\n\
->                   \                range between unbounded preceding\n\
->                   \                and unbounded following)\n\
->                   \       ,',') as atts\n\
->                   \   from att1\n\
->                   \   where attnum > 0)\n\
->                   \ select distinct\n\
->                   \     cls.relkind,\n\
->                   \     cls.relname,\n\
->                   \     atts,\n\
->                   \     coalesce(sysAtts,''),\n\
->                   \     nspname\n\
->                   \   from att left outer join sysAtt using (attrelid)\n\
->                   \   inner join pg_class cls\n\
->                   \     on cls.oid = attrelid\n\
->                   \   inner join pg_namespace ns\n\
->                   \      on cls.relnamespace = ns.oid\n\
->                   \   order by relkind,relname;" []
-
-
->    return $ concat [
->                cts
->               ,map (uncurry CatCreateDomain) domainDefs
->               ,map (\(a,b,c) -> CatCreateCast a b c) casts
->               ,map (\(a,b,c) -> CatCreateFunction FunPrefix a b c False) prefixOps
->               ,map (\(a,b,c) -> CatCreateFunction FunPostfix a b c False) postfixOps
->               ,map (\(a,b,c) -> CatCreateFunction FunBinary a b c False) binaryOps
->               ,map (\(a,b,c) -> CatCreateFunction FunName a b c False) fnProts
->               ,map (\(a,b,c) -> CatCreateFunction FunAgg a b c False) aggProts
->               ,map (\(a,b,c) -> CatCreateFunction FunWindow a b c False) winProts
->               ,comps]
->    where
->      convertAttString jlt s =
->          let ps = split ',' s
->              ps1 = map (split ';') ps
->          in map (\pl -> (head pl, jlt (pl!!1))) ps1
->      convFnRow jlt l =
->         (head l,fnArgs,fnRet)
->         where
->           fnRet = let rt1 = jlt (l!!3)
->                   in if read (l!!2)::Bool
->                        then SetOfType rt1
->                        else rt1
->           fnArgs = if (l!!1) == ""
->                      then []
->                      else let a = split ',' (l!!1)
->                           in map jlt a
->      convTypeInfoRow l =
->        let name = canonicalizeTypeName (l!!2)
->            ctor = case (l!!1) of
->                     "b" -> ScalarType
->                     "c" -> NamedCompositeType
->                     "d" -> DomainType
->                     "e" -> EnumType
->                     "p" -> (\t -> Pseudo (case t of
->                                                  "any" -> Any
->                                                  "anyarray" -> AnyArray
->                                                  "anyelement" -> AnyElement
->                                                  "anyenum" -> AnyEnum
->                                                  "anynonarray" -> AnyNonArray
->                                                  "cstring" -> Cstring
->                                                  "internal" -> Internal
->                                                  "language_handler" -> LanguageHandler
->                                                  "opaque" -> Opaque
->                                                  "record" -> Record
->                                                  "trigger" -> Trigger
->                                                  "void" -> Void
->                                                  _ -> error $ "internal error: unknown pseudo " ++ t))
->                     _ -> error $ "internal error: unknown type type: " ++ (l !! 1)
->            scType = (head l, ctor name, name)
->        in if (l!!4) /= "0"
->           then [(l!!5,ArrayType $ ctor name, '_':name), scType]
->           else [scType]
-
diff --git a/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs b/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs
+++ /dev/null
@@ -1,29023 +0,0 @@
-> {-# OPTIONS_HADDOCK hide  #-}
-
-> module Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
->     (defaultTemplate1Catalog
->      ) where
-
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-> import Database.HsSqlPpp.AstInternals.TypeType
-
-> defaultTemplate1Catalog :: Catalog
-> defaultTemplate1Catalog =
->    (\l -> case l of
->             Left x -> error $ show x
->             Right e -> e) $
->     updateCatalog defaultCatalog
-
->        [ CatCreateScalar (
->            ScalarType "bool" )
->            "B"
->            True
->        , CatCreateScalar (
->            ScalarType "bytea" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "char" )
->            "S"
->            False
->        , CatCreateScalar (
->            ScalarType "name" )
->            "S"
->            False
->        , CatCreateScalar (
->            ScalarType "int8" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "int2" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "int2vector" )
->            "A"
->            False
->        , CatCreateScalar (
->            ScalarType "int4" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regproc" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "text" )
->            "S"
->            True
->        , CatCreateScalar (
->            ScalarType "oid" )
->            "N"
->            True
->        , CatCreateScalar (
->            ScalarType "tid" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "xid" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "cid" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "oidvector" )
->            "A"
->            False
->        , CatCreateScalar (
->            ScalarType "xml" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "point" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "lseg" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "path" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "box" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "polygon" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "line" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "float4" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "float8" )
->            "N"
->            True
->        , CatCreateScalar (
->            ScalarType "abstime" )
->            "D"
->            False
->        , CatCreateScalar (
->            ScalarType "reltime" )
->            "T"
->            False
->        , CatCreateScalar (
->            ScalarType "tinterval" )
->            "T"
->            False
->        , CatCreateScalar (
->            ScalarType "circle" )
->            "G"
->            False
->        , CatCreateScalar (
->            ScalarType "money" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "macaddr" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "inet" )
->            "I"
->            True
->        , CatCreateScalar (
->            ScalarType "cidr" )
->            "I"
->            False
->        , CatCreateScalar (
->            ScalarType "aclitem" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "bpchar" )
->            "S"
->            False
->        , CatCreateScalar (
->            ScalarType "varchar" )
->            "S"
->            False
->        , CatCreateScalar (
->            ScalarType "date" )
->            "D"
->            False
->        , CatCreateScalar (
->            ScalarType "time" )
->            "D"
->            False
->        , CatCreateScalar (
->            ScalarType "timestamp" )
->            "D"
->            False
->        , CatCreateScalar (
->            ScalarType "timestamptz" )
->            "D"
->            True
->        , CatCreateScalar (
->            ScalarType "interval" )
->            "T"
->            True
->        , CatCreateScalar (
->            ScalarType "timetz" )
->            "D"
->            False
->        , CatCreateScalar (
->            ScalarType "bit" )
->            "V"
->            False
->        , CatCreateScalar (
->            ScalarType "varbit" )
->            "V"
->            True
->        , CatCreateScalar (
->            ScalarType "numeric" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "refcursor" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "regprocedure" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regoper" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regoperator" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regclass" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regtype" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "uuid" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "tsvector" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "gtsvector" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "tsquery" )
->            "U"
->            False
->        , CatCreateScalar (
->            ScalarType "regconfig" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "regdictionary" )
->            "N"
->            False
->        , CatCreateScalar (
->            ScalarType "txid_snapshot" )
->            "U"
->            False
->        , CatCreateDomain (
->            DomainType "information_schema.cardinal_number" ) (
->            ScalarType "int4" )
->        , CatCreateDomain (
->            DomainType "information_schema.character_data" ) (
->            ScalarType "varchar" )
->        , CatCreateDomain (
->            DomainType "information_schema.sql_identifier" ) (
->            ScalarType "varchar" )
->        , CatCreateDomain (
->            DomainType "information_schema.time_stamp" ) (
->            ScalarType "timestamptz" )
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "int2" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "float4" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "float8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "numeric" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "int8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "int4" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "float4" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "float8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "numeric" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "int8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "int2" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "float4" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "float8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "numeric" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "float4" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float4" ) (
->            ScalarType "int2" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float4" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float4" ) (
->            ScalarType "float8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "float4" ) (
->            ScalarType "numeric" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float8" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float8" ) (
->            ScalarType "int2" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float8" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float8" ) (
->            ScalarType "float4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "float8" ) (
->            ScalarType "numeric" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "int2" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "float4" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "float8" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "bool" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "bool" ) (
->            ScalarType "int4" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regproc" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regproc" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regproc" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regproc" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regproc" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regproc" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regproc" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regproc" ) (
->            ScalarType "regprocedure" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regprocedure" ) (
->            ScalarType "regproc" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regprocedure" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regprocedure" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regprocedure" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regprocedure" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regprocedure" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regprocedure" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regprocedure" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regoper" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regoper" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regoper" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regoper" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regoper" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regoper" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regoper" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regoper" ) (
->            ScalarType "regoperator" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regoperator" ) (
->            ScalarType "regoper" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regoperator" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regoperator" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regoperator" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regoperator" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regoperator" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regoperator" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regoperator" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regclass" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regclass" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regclass" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regtype" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regtype" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regtype" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regtype" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regtype" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regtype" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regtype" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regconfig" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regconfig" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regconfig" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regconfig" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regconfig" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regconfig" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regconfig" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "oid" ) (
->            ScalarType "regdictionary" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regdictionary" ) (
->            ScalarType "oid" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "regdictionary" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int2" ) (
->            ScalarType "regdictionary" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "regdictionary" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "regdictionary" ) (
->            ScalarType "int8" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "regdictionary" ) (
->            ScalarType "int4" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "regclass" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "bpchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "varchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "text" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "varchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "text" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "bpchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "char" ) (
->            ScalarType "text" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "char" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "char" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "name" ) (
->            ScalarType "text" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "name" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "name" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "char" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "char" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "char" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "name" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "name" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "name" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "char" ) (
->            ScalarType "int4" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "char" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "abstime" ) (
->            ScalarType "date" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "abstime" ) (
->            ScalarType "time" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "abstime" ) (
->            ScalarType "timestamp" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "abstime" ) (
->            ScalarType "timestamptz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "reltime" ) (
->            ScalarType "interval" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "date" ) (
->            ScalarType "timestamp" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "date" ) (
->            ScalarType "timestamptz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "time" ) (
->            ScalarType "interval" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "time" ) (
->            ScalarType "timetz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "timestamp" ) (
->            ScalarType "abstime" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamp" ) (
->            ScalarType "date" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamp" ) (
->            ScalarType "time" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamp" ) (
->            ScalarType "timestamptz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "abstime" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "date" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "time" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "timestamp" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "timetz" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "interval" ) (
->            ScalarType "reltime" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "interval" ) (
->            ScalarType "time" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "timetz" ) (
->            ScalarType "time" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "abstime" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "abstime" ) (
->            ScalarType "int4" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "reltime" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "reltime" ) (
->            ScalarType "int4" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "lseg" ) (
->            ScalarType "point" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "path" ) (
->            ScalarType "point" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "path" ) (
->            ScalarType "polygon" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "box" ) (
->            ScalarType "point" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "box" ) (
->            ScalarType "lseg" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "box" ) (
->            ScalarType "polygon" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "box" ) (
->            ScalarType "circle" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "polygon" ) (
->            ScalarType "point" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "polygon" ) (
->            ScalarType "path" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "polygon" ) (
->            ScalarType "box" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "polygon" ) (
->            ScalarType "circle" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "circle" ) (
->            ScalarType "point" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "circle" ) (
->            ScalarType "box" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "circle" ) (
->            ScalarType "polygon" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "cidr" ) (
->            ScalarType "inet" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "inet" ) (
->            ScalarType "cidr" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bit" ) (
->            ScalarType "varbit" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varbit" ) (
->            ScalarType "bit" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "int8" ) (
->            ScalarType "bit" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "int4" ) (
->            ScalarType "bit" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "bit" ) (
->            ScalarType "int8" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "bit" ) (
->            ScalarType "int4" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "cidr" ) (
->            ScalarType "text" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "inet" ) (
->            ScalarType "text" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bool" ) (
->            ScalarType "text" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "xml" ) (
->            ScalarType "text" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "text" ) (
->            ScalarType "xml" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "cidr" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "inet" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bool" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "xml" ) (
->            ScalarType "varchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "xml" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "cidr" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "inet" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bool" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "xml" ) (
->            ScalarType "bpchar" )
->            AssignmentCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "xml" )
->            ExplicitCastContext
->        , CatCreateCast (
->            ScalarType "bpchar" ) (
->            ScalarType "bpchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varchar" ) (
->            ScalarType "varchar" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "time" ) (
->            ScalarType "time" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "timestamp" ) (
->            ScalarType "timestamp" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "timestamptz" ) (
->            ScalarType "timestamptz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "interval" ) (
->            ScalarType "interval" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "timetz" ) (
->            ScalarType "timetz" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "bit" ) (
->            ScalarType "bit" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "varbit" ) (
->            ScalarType "varbit" )
->            ImplicitCastContext
->        , CatCreateCast (
->            ScalarType "numeric" ) (
->            ScalarType "numeric" )
->            ImplicitCastContext
->        , CatCreateFunction
->            FunPrefix
->            "~"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "~"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "~"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "~"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "~"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "||/"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "|/"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "|"
->            [ ScalarType "tinterval"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@@"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@@"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@@"
->            [ ScalarType "path"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@@"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@@"
->            [ ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@-@"
->            [ ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@-@"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "@"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "?|"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "?|"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "?-"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "?-"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "-"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "+"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "#"
->            [ ScalarType "path"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "#"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "!!"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunPrefix
->            "!!"
->            [ ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunPostfix
->            "!"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~*"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~*"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~*"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~>~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~>~"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~>=~"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~>=~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~="
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~="
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~="
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~="
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~="
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~<~"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~<~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~<=~"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~<=~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~*"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~*"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~*"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "polygon"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "~"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "varbit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ Pseudo AnyElement
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ Pseudo AnyNonArray
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ Pseudo AnyArray
->            , Pseudo AnyElement
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunBinary
->            "||"
->            [ ScalarType "text"
->            , Pseudo AnyNonArray
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|>>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|>>"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|>>"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|&>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|&>"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|&>"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "|"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "^"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "^"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@@"
->            [ ScalarType "tsquery"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@@"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@"
->            [ ScalarType "text"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@"
->            [ ScalarType "tsquery"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@@"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "polygon"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "@>"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?||"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?||"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?|"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?-|"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?-|"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?-"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "?#"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">^"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">^"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>="
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">>"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">="
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            ">"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "aclitem"
->            , ScalarType "aclitem"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int2vector"
->            , ScalarType "int2vector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "cid"
->            , ScalarType "cid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "xid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "xid"
->            , ScalarType "xid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "="
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<^"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<^"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<@"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<?>"
->            [ ScalarType "abstime"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<>"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<="
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<|"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<|"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<|"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<="
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<<"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "circle"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<->"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<#>"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "tinterval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "<"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "money"
->            , ScalarType "float4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "money"
->            , ScalarType "int4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "interval"
->            , ScalarType "float8"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "money"
->            , ScalarType "int2"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "money"
->            , ScalarType "float8"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "/"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "date"
->            , ScalarType "int4"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "date"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ArrayType ( ScalarType "aclitem" ) )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "inet"
->            , ScalarType "int8"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "timetz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "abstime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "-"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "date"
->            , ScalarType "time"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "timetz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "time"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "date"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int8"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ArrayType ( ScalarType "aclitem" ) )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "inet"
->            , ScalarType "int8"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "date"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "timetz"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "date"
->            , ScalarType "int4"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "int4"
->            , ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "abstime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "+"
->            [ ScalarType "interval"
->            , ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "money"
->            , ScalarType "float4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float4"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "money"
->            , ScalarType "float8"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "money"
->            , ScalarType "int4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "money"
->            , ScalarType "int2"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float8"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int4"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int2"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float8"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "interval"
->            , ScalarType "float8"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "*"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&>"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&>"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&>"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<|"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<|"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<|"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&<"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&&"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "&"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "%"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "%"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "%"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "%"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#>="
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#>"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#="
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#<>"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#<="
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#<"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "line"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "##"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "#"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~*"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~*"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~*"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~~"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~*"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~*"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~*"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunBinary
->            "!~"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_cascade_del"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_cascade_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_check_ins"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_check_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_noaction_del"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_noaction_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_restrict_del"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_restrict_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_setdefault_del"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_setdefault_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_setnull_del"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "RI_FKey_setnull_upd"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "abbrev"
->            [ ScalarType "cidr"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "abbrev"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "abs"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstime"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstime"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimeeq"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimege"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimegt"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimein"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimele"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimelt"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimene"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimeout"
->            [ ScalarType "abstime"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimerecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "abstimesend"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "aclcontains"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "aclinsert"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ArrayType ( ScalarType "aclitem" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "aclitemeq"
->            [ ScalarType "aclitem"
->            , ScalarType "aclitem"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "aclitemin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "aclitem" )
->            False
->        , CatCreateFunction
->            FunName
->            "aclitemout"
->            [ ScalarType "aclitem"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "aclremove"
->            [ ArrayType ( ScalarType "aclitem" )
->            , ScalarType "aclitem"
->            ] (
->            ArrayType ( ScalarType "aclitem" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "acos"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "age"
->            [ ScalarType "xid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "age"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "age"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "age"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "age"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "any_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Any )
->            False
->        , CatCreateFunction
->            FunName
->            "any_out"
->            [ Pseudo Any
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "anyarray_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "anyarray_out"
->            [ Pseudo AnyArray
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "anyarray_recv"
->            [ Pseudo Internal
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "anyarray_send"
->            [ Pseudo AnyArray
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "anyelement_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunName
->            "anyelement_out"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "anyenum_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "anyenum_out"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "anynonarray_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo AnyNonArray )
->            False
->        , CatCreateFunction
->            FunName
->            "anynonarray_out"
->            [ Pseudo AnyNonArray
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "anytextcat"
->            [ Pseudo AnyNonArray
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "area"
->            [ ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "area"
->            [ ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "area"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "areajoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "areasel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_agg_finalfn"
->            [ Pseudo Internal
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_agg_transfn"
->            [ Pseudo Internal
->            , Pseudo AnyElement
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "array_append"
->            [ Pseudo AnyArray
->            , Pseudo AnyElement
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_cat"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_dims"
->            [ Pseudo AnyArray
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_eq"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_fill"
->            [ Pseudo AnyElement
->            , ArrayType ( ScalarType "int4" )
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_fill"
->            [ Pseudo AnyElement
->            , ArrayType ( ScalarType "int4" )
->            , ArrayType ( ScalarType "int4" )
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_ge"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_gt"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_larger"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_le"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_length"
->            [ Pseudo AnyArray
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_lower"
->            [ Pseudo AnyArray
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_lt"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_ndims"
->            [ Pseudo AnyArray
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_ne"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_out"
->            [ Pseudo AnyArray
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "array_prepend"
->            [ Pseudo AnyElement
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_send"
->            [ Pseudo AnyArray
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_smaller"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "array_to_string"
->            [ Pseudo AnyArray
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "array_upper"
->            [ Pseudo AnyArray
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "arraycontained"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "arraycontains"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "arrayoverlap"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ascii"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ascii_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "ascii_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "asin"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "atan"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "atan2"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "big5_to_euc_tw"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "big5_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "big5_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "bit"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_length"
->            [ ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_length"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_length"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_out"
->            [ ScalarType "bit"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bit_send"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitand"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitcat"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "varbit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitcmp"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "biteq"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitge"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitgt"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitle"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitlt"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitne"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitnot"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitor"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitshiftleft"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bitshiftright"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bittypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bittypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "bitxor"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "bool"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "booland_statefunc"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "booleq"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolge"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolgt"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolle"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boollt"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolne"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolor_statefunc"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolout"
->            [ ScalarType "bool"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "boolrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "boolsend"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "box"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_above"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_above_eq"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_add"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_below"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_below_eq"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_center"
->            [ ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_contain"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_contained"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_distance"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_div"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_eq"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_ge"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_gt"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_intersect"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_le"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_left"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_lt"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_mul"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_out"
->            [ ScalarType "box"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "box_overabove"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_overbelow"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_overlap"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_overleft"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_overright"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_right"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_same"
->            [ ScalarType "box"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_send"
->            [ ScalarType "box"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "box_sub"
->            [ ScalarType "box"
->            , ScalarType "point"
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar"
->            [ ScalarType "char"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar"
->            [ ScalarType "name"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar"
->            [ ScalarType "bpchar"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_larger"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_pattern_ge"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_pattern_gt"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_pattern_le"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_pattern_lt"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchar_smaller"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharcmp"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchareq"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharge"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchargt"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchariclike"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharicnlike"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharicregexeq"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharicregexne"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharin"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharle"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharlike"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharlt"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharne"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharnlike"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharout"
->            [ ScalarType "bpchar"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharrecv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharregexeq"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharregexne"
->            [ ScalarType "bpchar"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpcharsend"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchartypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bpchartypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "broadcast"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "btabstimecmp"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btarraycmp"
->            [ Pseudo AnyArray
->            , Pseudo AnyArray
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btbeginscan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "btboolcmp"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btbpchar_pattern_cmp"
->            [ ScalarType "bpchar"
->            , ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btbuild"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "btbulkdelete"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "btcharcmp"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btcostestimate"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "btendscan"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "btfloat48cmp"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btfloat4cmp"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btfloat84cmp"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btfloat8cmp"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btgetbitmap"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "btgettuple"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "btinsert"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint24cmp"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint28cmp"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint2cmp"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint42cmp"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint48cmp"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint4cmp"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint82cmp"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint84cmp"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btint8cmp"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btmarkpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "btnamecmp"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btoidcmp"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btoidvectorcmp"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btoptions"
->            [ ArrayType ( ScalarType "text" )
->            , ScalarType "bool"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "btrecordcmp"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btreltimecmp"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btrescan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "btrestrpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "btrim"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "btrim"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "btrim"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "bttext_pattern_cmp"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bttextcmp"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bttidcmp"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "bttintervalcmp"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "btvacuumcleanup"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "byteacat"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteacmp"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteaeq"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteage"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteagt"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteain"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteale"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bytealike"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "bytealt"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteane"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteanlike"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteaout"
->            [ ScalarType "bytea"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "bytearecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "byteasend"
->            [ ScalarType "bytea"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_cmp"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_div_flt4"
->            [ ScalarType "money"
->            , ScalarType "float4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_div_flt8"
->            [ ScalarType "money"
->            , ScalarType "float8"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_div_int2"
->            [ ScalarType "money"
->            , ScalarType "int2"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_div_int4"
->            [ ScalarType "money"
->            , ScalarType "int4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_eq"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_ge"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_gt"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_le"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_lt"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_mi"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_mul_flt4"
->            [ ScalarType "money"
->            , ScalarType "float4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_mul_flt8"
->            [ ScalarType "money"
->            , ScalarType "float8"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_mul_int2"
->            [ ScalarType "money"
->            , ScalarType "int2"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_mul_int4"
->            [ ScalarType "money"
->            , ScalarType "int4"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_ne"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_out"
->            [ ScalarType "money"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_pl"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_send"
->            [ ScalarType "money"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "cash_words"
->            [ ScalarType "money"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "cashlarger"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cashsmaller"
->            [ ScalarType "money"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "cbrt"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "ceil"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "ceil"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "ceiling"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "ceiling"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "center"
->            [ ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "center"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "char"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "char" )
->            False
->        , CatCreateFunction
->            FunName
->            "char"
->            [ ScalarType "text"
->            ] (
->            ScalarType "char" )
->            False
->        , CatCreateFunction
->            FunName
->            "char_length"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "char_length"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "character_length"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "character_length"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "chareq"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "charge"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "chargt"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "charin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "char" )
->            False
->        , CatCreateFunction
->            FunName
->            "charle"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "charlt"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "charne"
->            [ ScalarType "char"
->            , ScalarType "char"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "charout"
->            [ ScalarType "char"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "charrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "char" )
->            False
->        , CatCreateFunction
->            FunName
->            "charsend"
->            [ ScalarType "char"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "chr"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "cideq"
->            [ ScalarType "cid"
->            , ScalarType "cid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "cid" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidout"
->            [ ScalarType "cid"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cidr"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "cidr" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidr_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "cidr" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidr_out"
->            [ ScalarType "cidr"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cidr_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "cidr" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidr_send"
->            [ ScalarType "cidr"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "cid" )
->            False
->        , CatCreateFunction
->            FunName
->            "cidsend"
->            [ ScalarType "cid"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle"
->            [ ScalarType "box"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle"
->            [ ScalarType "point"
->            , ScalarType "float8"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_above"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_add_pt"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_below"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_center"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_contain"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_contain_pt"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_contained"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_distance"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_div_pt"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_eq"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_ge"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_gt"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_le"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_left"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_lt"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_mul_pt"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_ne"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_out"
->            [ ScalarType "circle"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_overabove"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_overbelow"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_overlap"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_overleft"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_overright"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_right"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_same"
->            [ ScalarType "circle"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_send"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "circle_sub_pt"
->            [ ScalarType "circle"
->            , ScalarType "point"
->            ] (
->            ScalarType "circle" )
->            False
->        , CatCreateFunction
->            FunName
->            "clock_timestamp"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_lb"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_ls"
->            [ ScalarType "line"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_lseg"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_pb"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_pl"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_ps"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_sb"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "close_sl"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "col_description"
->            [ ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "contjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "contsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "convert"
->            [ ScalarType "bytea"
->            , ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "convert_from"
->            [ ScalarType "bytea"
->            , ScalarType "name"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "convert_to"
->            [ ScalarType "text"
->            , ScalarType "name"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "cos"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "cot"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "cstring_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cstring_out"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cstring_recv"
->            [ Pseudo Internal
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "cstring_send"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "current_database"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "current_query"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "current_schema"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "current_schemas"
->            [ ScalarType "bool"
->            ] (
->            ArrayType ( ScalarType "name" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "current_setting"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "current_user"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "currtid"
->            [ ScalarType "oid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "currtid2"
->            [ ScalarType "text"
->            , ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "currval"
->            [ ScalarType "regclass"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "cursor_to_xml"
->            [ ScalarType "refcursor"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "cursor_to_xmlschema"
->            [ ScalarType "refcursor"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "database_to_xml"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "database_to_xml_and_xmlschema"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "database_to_xmlschema"
->            [ ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "date"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_cmp"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_cmp_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_cmp_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_eq"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_eq_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_eq_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ge"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ge_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ge_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_gt"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_gt_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_gt_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_larger"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_le"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_le_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_le_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_lt"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_lt_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_lt_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_mi"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_mi_interval"
->            [ ScalarType "date"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_mii"
->            [ ScalarType "date"
->            , ScalarType "int4"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ne"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ne_timestamp"
->            [ ScalarType "date"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_ne_timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_out"
->            [ ScalarType "date"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "date"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "time"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "interval"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_part"
->            [ ScalarType "text"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_pl_interval"
->            [ ScalarType "date"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_pli"
->            [ ScalarType "date"
->            , ScalarType "int4"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_send"
->            [ ScalarType "date"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_smaller"
->            [ ScalarType "date"
->            , ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_trunc"
->            [ ScalarType "text"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_trunc"
->            [ ScalarType "text"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "date_trunc"
->            [ ScalarType "text"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "datetime_pl"
->            [ ScalarType "date"
->            , ScalarType "time"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "datetimetz_pl"
->            [ ScalarType "date"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "dcbrt"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "decode"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "degrees"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dexp"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "diagonal"
->            [ ScalarType "box"
->            ] (
->            ScalarType "lseg" )
->            False
->        , CatCreateFunction
->            FunName
->            "diameter"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dispell_init"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dispell_lexize"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_cpoly"
->            [ ScalarType "circle"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_lb"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_pb"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_pc"
->            [ ScalarType "point"
->            , ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_pl"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_ppath"
->            [ ScalarType "point"
->            , ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_ps"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_sb"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dist_sl"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "div"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "dlog1"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dlog10"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "domain_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo Any )
->            False
->        , CatCreateFunction
->            FunName
->            "domain_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo Any )
->            False
->        , CatCreateFunction
->            FunName
->            "dpow"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dround"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dsimple_init"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dsimple_lexize"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dsnowball_init"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dsnowball_lexize"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dsqrt"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "dsynonym_init"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dsynonym_lexize"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "dtrunc"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "encode"
->            [ ScalarType "bytea"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_cmp"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_eq"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_first"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_ge"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_gt"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_larger"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_last"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_le"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_lt"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_ne"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_out"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_range"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_range"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_recv"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_send"
->            [ Pseudo AnyEnum
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "enum_smaller"
->            [ Pseudo AnyEnum
->            , Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunName
->            "eqjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "eqsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_cn_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_cn_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_jis_2004_to_shift_jis_2004"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_jis_2004_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_jp_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_jp_to_sjis"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_jp_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_kr_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_kr_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_tw_to_big5"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_tw_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "euc_tw_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "exp"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "exp"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "factorial"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "family"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "flatfile_update_trigger"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "float4"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48div"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48eq"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48ge"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48gt"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48le"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48lt"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48mi"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48mul"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48ne"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float48pl"
->            [ ScalarType "float4"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4_accum"
->            [ ArrayType ( ScalarType "float8" )
->            , ScalarType "float4"
->            ] (
->            ArrayType ( ScalarType "float8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "float4abs"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4div"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4eq"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4ge"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4gt"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4larger"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4le"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4lt"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4mi"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4mul"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4ne"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4out"
->            [ ScalarType "float4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "float4pl"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4send"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4smaller"
->            [ ScalarType "float4"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4um"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float4up"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84div"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84eq"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84ge"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84gt"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84le"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84lt"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84mi"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84mul"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84ne"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float84pl"
->            [ ScalarType "float8"
->            , ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_accum"
->            [ ArrayType ( ScalarType "float8" )
->            , ScalarType "float8"
->            ] (
->            ArrayType ( ScalarType "float8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_avg"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_corr"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_covar_pop"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_covar_samp"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_accum"
->            [ ArrayType ( ScalarType "float8" )
->            , ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ArrayType ( ScalarType "float8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_avgx"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_avgy"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_intercept"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_r2"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_slope"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_sxx"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_sxy"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_regr_syy"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_stddev_pop"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_stddev_samp"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_var_pop"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8_var_samp"
->            [ ArrayType ( ScalarType "float8" )
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8abs"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8div"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8eq"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8ge"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8gt"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8larger"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8le"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8lt"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8mi"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8mul"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8ne"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8out"
->            [ ScalarType "float8"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "float8pl"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8send"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8smaller"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8um"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "float8up"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "floor"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "floor"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "flt4_mul_cash"
->            [ ScalarType "float4"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "flt8_mul_cash"
->            [ ScalarType "float8"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "fmgr_c_validator"
->            [ ScalarType "oid"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "fmgr_internal_validator"
->            [ ScalarType "oid"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "fmgr_sql_validator"
->            [ ScalarType "oid"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "format_type"
->            [ ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "gb18030_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gbk_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            SetOfType ( ScalarType "int8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            SetOfType ( ScalarType "int4" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            SetOfType ( ScalarType "int8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            SetOfType ( ScalarType "int4" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            SetOfType ( ScalarType "timestamp" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_series"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            SetOfType ( ScalarType "timestamptz" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_subscripts"
->            [ Pseudo AnyArray
->            , ScalarType "int4"
->            ] (
->            SetOfType ( ScalarType "int4" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "generate_subscripts"
->            [ Pseudo AnyArray
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            SetOfType ( ScalarType "int4" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "get_bit"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "get_byte"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "get_current_ts_config"
->            [] (
->            ScalarType "regconfig" )
->            False
->        , CatCreateFunction
->            FunName
->            "getdatabaseencoding"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "getpgusername"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "gin_cmp_prefix"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "gin_cmp_tslexeme"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "gin_extract_tsquery"
->            [ ScalarType "tsquery"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gin_extract_tsvector"
->            [ ScalarType "tsvector"
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gin_tsquery_consistent"
->            [ Pseudo Internal
->            , ScalarType "int2"
->            , ScalarType "tsquery"
->            , ScalarType "int4"
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ginarrayconsistent"
->            [ Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo AnyArray
->            , ScalarType "int4"
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ginarrayextract"
->            [ Pseudo AnyArray
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "ginbeginscan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "ginbuild"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "ginbulkdelete"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gincostestimate"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "ginendscan"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gingetbitmap"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "gininsert"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ginmarkpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "ginoptions"
->            [ ArrayType ( ScalarType "text" )
->            , ScalarType "bool"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "ginqueryarrayextract"
->            [ Pseudo AnyArray
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "ginrescan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "ginrestrpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "ginvacuumcleanup"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_compress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_consistent"
->            [ Pseudo Internal
->            , ScalarType "box"
->            , ScalarType "int4"
->            , ScalarType "oid"
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_decompress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_penalty"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_picksplit"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_same"
->            [ ScalarType "box"
->            , ScalarType "box"
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_box_union"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "box" )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_circle_compress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_circle_consistent"
->            [ Pseudo Internal
->            , ScalarType "circle"
->            , ScalarType "int4"
->            , ScalarType "oid"
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_poly_compress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gist_poly_consistent"
->            [ Pseudo Internal
->            , ScalarType "polygon"
->            , ScalarType "int4"
->            , ScalarType "oid"
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gistbeginscan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gistbuild"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gistbulkdelete"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gistcostestimate"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gistendscan"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gistgetbitmap"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "gistgettuple"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gistinsert"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gistmarkpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gistoptions"
->            [ ArrayType ( ScalarType "text" )
->            , ScalarType "bool"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "gistrescan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gistrestrpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "gistvacuumcleanup"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_compress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_consistent"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , ScalarType "int4"
->            , ScalarType "oid"
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_decompress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_penalty"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_picksplit"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_same"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsquery_union"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_compress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_consistent"
->            [ Pseudo Internal
->            , ScalarType "gtsvector"
->            , ScalarType "int4"
->            , ScalarType "oid"
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_decompress"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_penalty"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_picksplit"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_same"
->            [ ScalarType "gtsvector"
->            , ScalarType "gtsvector"
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvector_union"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvectorin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "gtsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "gtsvectorout"
->            [ ScalarType "gtsvector"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_any_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "text"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "int2"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_column_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_database_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_foreign_data_wrapper_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_function_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_language_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_schema_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_server_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_table_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "name"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "has_tablespace_privilege"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "hash_aclitem"
->            [ ScalarType "aclitem"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hash_numeric"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashbeginscan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "hashbpchar"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashbuild"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "hashbulkdelete"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "hashchar"
->            [ ScalarType "char"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashcostestimate"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "hashendscan"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "hashenum"
->            [ Pseudo AnyEnum
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashfloat4"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashfloat8"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashgetbitmap"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashgettuple"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashinet"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashinsert"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashint2"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashint2vector"
->            [ ScalarType "int2vector"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashint4"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashint8"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashmacaddr"
->            [ ScalarType "macaddr"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashmarkpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "hashname"
->            [ ScalarType "name"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashoid"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashoidvector"
->            [ ScalarType "oidvector"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashoptions"
->            [ ArrayType ( ScalarType "text" )
->            , ScalarType "bool"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashrescan"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "hashrestrpos"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "hashtext"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "hashvacuumcleanup"
->            [ Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "hashvarlena"
->            [ Pseudo Internal
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "height"
->            [ ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "host"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "hostmask"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "iclikejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "iclikesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icnlikejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icnlikesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icregexeqjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icregexeqsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icregexnejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "icregexnesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_client_addr"
->            [] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_client_port"
->            [] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_out"
->            [ ScalarType "inet"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_send"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_server_addr"
->            [] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inet_server_port"
->            [] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetand"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetmi"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetmi_int8"
->            [ ScalarType "inet"
->            , ScalarType "int8"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetnot"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetor"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "inetpl"
->            [ ScalarType "inet"
->            , ScalarType "int8"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "initcap"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24div"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24eq"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24ge"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24gt"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24le"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24lt"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24mi"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24mul"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24ne"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int24pl"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28div"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28eq"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28ge"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28gt"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28le"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28lt"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28mi"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28mul"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28ne"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int28pl"
->            [ ScalarType "int2"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "int2"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int2_avg_accum"
->            [ ArrayType ( ScalarType "int8" )
->            , ScalarType "int2"
->            ] (
->            ArrayType ( ScalarType "int8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int2_mul_cash"
->            [ ScalarType "int2"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2_sum"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2abs"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2and"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2div"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2eq"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2ge"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2gt"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2larger"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2le"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2lt"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2mi"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2mod"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2mul"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2ne"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2not"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2or"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2out"
->            [ ScalarType "int2"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "int2pl"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2send"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2shl"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2shr"
->            [ ScalarType "int2"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2smaller"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2um"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2up"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2vectoreq"
->            [ ScalarType "int2vector"
->            , ScalarType "int2vector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2vectorin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "int2vector" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2vectorout"
->            [ ScalarType "int2vector"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "int2vectorrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "int2vector" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2vectorsend"
->            [ ScalarType "int2vector"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "int2xor"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "char"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42div"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42eq"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42ge"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42gt"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42le"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42lt"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42mi"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42mul"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42ne"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int42pl"
->            [ ScalarType "int4"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48div"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48eq"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48ge"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48gt"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48le"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48lt"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48mi"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48mul"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48ne"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int48pl"
->            [ ScalarType "int4"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "int4"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int4_avg_accum"
->            [ ArrayType ( ScalarType "int8" )
->            , ScalarType "int4"
->            ] (
->            ArrayType ( ScalarType "int8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int4_mul_cash"
->            [ ScalarType "int4"
->            , ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4_sum"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4abs"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4and"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4div"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4eq"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4ge"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4gt"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4inc"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4larger"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4le"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4lt"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4mi"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4mod"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4mul"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4ne"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4not"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4or"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4out"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "int4pl"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4send"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4shl"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4shr"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4smaller"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4um"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4up"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int4xor"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82div"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82eq"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82ge"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82gt"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82le"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82lt"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82mi"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82mul"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82ne"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int82pl"
->            [ ScalarType "int8"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84div"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84eq"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84ge"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84gt"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84le"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84lt"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84mi"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84mul"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84ne"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int84pl"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "int8"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int8_avg"
->            [ ArrayType ( ScalarType "int8" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8_avg_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "int8"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "int8_sum"
->            [ ScalarType "numeric"
->            , ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8abs"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8and"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8div"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8eq"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8ge"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8gt"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8inc"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8inc_any"
->            [ ScalarType "int8"
->            , Pseudo Any
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8inc_float8_float8"
->            [ ScalarType "int8"
->            , ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8larger"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8le"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8lt"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8mi"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8mod"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8mul"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8ne"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8not"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8or"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8out"
->            [ ScalarType "int8"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "int8pl"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8pl_inet"
->            [ ScalarType "int8"
->            , ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8send"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8shl"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8shr"
->            [ ScalarType "int8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8smaller"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8um"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8up"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "int8xor"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "integer_pl_date"
->            [ ScalarType "int4"
->            , ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "inter_lb"
->            [ ScalarType "line"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "inter_sb"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "inter_sl"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "internal_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "internal_out"
->            [ Pseudo Internal
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "interval"
->            [ ScalarType "reltime"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval"
->            [ ScalarType "time"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval"
->            [ ScalarType "interval"
->            , ScalarType "int4"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_accum"
->            [ ArrayType ( ScalarType "interval" )
->            , ScalarType "interval"
->            ] (
->            ArrayType ( ScalarType "interval" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_avg"
->            [ ArrayType ( ScalarType "interval" )
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_cmp"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_div"
->            [ ScalarType "interval"
->            , ScalarType "float8"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_eq"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_ge"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_gt"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_hash"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_larger"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_le"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_lt"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_mi"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_mul"
->            [ ScalarType "interval"
->            , ScalarType "float8"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_ne"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_out"
->            [ ScalarType "interval"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl_date"
->            [ ScalarType "interval"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl_time"
->            [ ScalarType "interval"
->            , ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl_timestamp"
->            [ ScalarType "interval"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl_timestamptz"
->            [ ScalarType "interval"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_pl_timetz"
->            [ ScalarType "interval"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_send"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_smaller"
->            [ ScalarType "interval"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "interval_um"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "intervaltypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "intervaltypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "intinterval"
->            [ ScalarType "abstime"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isclosed"
->            [ ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isfinite"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isfinite"
->            [ ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isfinite"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isfinite"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isfinite"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ishorizontal"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ishorizontal"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ishorizontal"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "iso8859_1_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "iso8859_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "iso_to_koi8r"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "iso_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "iso_to_win1251"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "iso_to_win866"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "isopen"
->            [ ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isparallel"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isparallel"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isperp"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isperp"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isvertical"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isvertical"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "isvertical"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "johab_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "justify_days"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "justify_hours"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "justify_interval"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8r_to_iso"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8r_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8r_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8r_to_win1251"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8r_to_win866"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "koi8u_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "language_handler_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo LanguageHandler )
->            False
->        , CatCreateFunction
->            FunName
->            "language_handler_out"
->            [ Pseudo LanguageHandler
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "lastval"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "latin1_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "latin2_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "latin2_to_win1250"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "latin3_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "latin4_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "tsvector"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "length"
->            [ ScalarType "bytea"
->            , ScalarType "name"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "like"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "like"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "like"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "like_escape"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "like_escape"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "likejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "likesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "line"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "line" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_distance"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_eq"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_horizontal"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "line" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_interpt"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_intersect"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_out"
->            [ ScalarType "line"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "line_parallel"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_perp"
->            [ ScalarType "line"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "line" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_send"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "line_vertical"
->            [ ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ln"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "ln"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_close"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_creat"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_create"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_export"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_import"
->            [ ScalarType "text"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_import"
->            [ ScalarType "text"
->            , ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_lseek"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_open"
->            [ ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_tell"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_truncate"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lo_unlink"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "log"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "log"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "log"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "loread"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "lower"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "lowrite"
->            [ ScalarType "int4"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "lpad"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "lpad"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg"
->            [ ScalarType "box"
->            ] (
->            ScalarType "lseg" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "lseg" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_center"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_distance"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_eq"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_ge"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_gt"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_horizontal"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "lseg" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_interpt"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_intersect"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_le"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_length"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_lt"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_ne"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_out"
->            [ ScalarType "lseg"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_parallel"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_perp"
->            [ ScalarType "lseg"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "lseg" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_send"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "lseg_vertical"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ltrim"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "ltrim"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_cmp"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_eq"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_ge"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_gt"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "macaddr" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_le"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_lt"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_ne"
->            [ ScalarType "macaddr"
->            , ScalarType "macaddr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_out"
->            [ ScalarType "macaddr"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "macaddr" )
->            False
->        , CatCreateFunction
->            FunName
->            "macaddr_send"
->            [ ScalarType "macaddr"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "makeaclitem"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            , ScalarType "bool"
->            ] (
->            ScalarType "aclitem" )
->            False
->        , CatCreateFunction
->            FunName
->            "masklen"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "md5"
->            [ ScalarType "bytea"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "md5"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_ascii"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_big5"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_euc_cn"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_euc_jp"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_euc_kr"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_euc_tw"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_iso"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_koi8r"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_latin1"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_latin2"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_latin3"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_latin4"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_sjis"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_win1250"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_win1251"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mic_to_win866"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "mktinterval"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "tinterval" )
->            False
->        , CatCreateFunction
->            FunName
->            "mod"
->            [ ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "mod"
->            [ ScalarType "int2"
->            , ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunName
->            "mod"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "mod"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "mul_d_interval"
->            [ ScalarType "float8"
->            , ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "name"
->            [ ScalarType "text"
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "name"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "name"
->            [ ScalarType "varchar"
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameeq"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namege"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namegt"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameiclike"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameicnlike"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameicregexeq"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameicregexne"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namein"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "namele"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namelike"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namelt"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namene"
->            [ ScalarType "name"
->            , ScalarType "name"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namenlike"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameout"
->            [ ScalarType "name"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "namerecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameregexeq"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nameregexne"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "namesend"
->            [ ScalarType "name"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "neqjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "neqsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "netmask"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "network"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "cidr" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_cmp"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_eq"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_ge"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_gt"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_le"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_lt"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_ne"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_sub"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_subeq"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_sup"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "network_supeq"
->            [ ScalarType "inet"
->            , ScalarType "inet"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "nextval"
->            [ ScalarType "regclass"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "nlikejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "nlikesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "notlike"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "notlike"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "notlike"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "now"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "npoints"
->            [ ScalarType "path"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "npoints"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric"
->            [ ScalarType "numeric"
->            , ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_abs"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "numeric"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_add"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_avg"
->            [ ArrayType ( ScalarType "numeric" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_avg_accum"
->            [ ArrayType ( ScalarType "numeric" )
->            , ScalarType "numeric"
->            ] (
->            ArrayType ( ScalarType "numeric" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_cmp"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_div"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_div_trunc"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_eq"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_exp"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_fac"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_ge"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_gt"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_inc"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_larger"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_le"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_ln"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_log"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_lt"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_mod"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_mul"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_ne"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_out"
->            [ ScalarType "numeric"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_power"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_send"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_smaller"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_sqrt"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_stddev_pop"
->            [ ArrayType ( ScalarType "numeric" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_stddev_samp"
->            [ ArrayType ( ScalarType "numeric" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_sub"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_uminus"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_uplus"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_var_pop"
->            [ ArrayType ( ScalarType "numeric" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numeric_var_samp"
->            [ ArrayType ( ScalarType "numeric" )
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "numerictypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "numerictypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "numnode"
->            [ ScalarType "tsquery"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "obj_description"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "obj_description"
->            [ ScalarType "oid"
->            , ScalarType "name"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "octet_length"
->            [ ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "octet_length"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "octet_length"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "octet_length"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "oid"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "oideq"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidge"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidgt"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidlarger"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidle"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidlt"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidne"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidout"
->            [ ScalarType "oid"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "oidrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidsend"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidsmaller"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectoreq"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorge"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorgt"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "oidvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorle"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorlt"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorne"
->            [ ScalarType "oidvector"
->            , ScalarType "oidvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorout"
->            [ ScalarType "oidvector"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "oidvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectorsend"
->            [ ScalarType "oidvector"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "oidvectortypes"
->            [ ScalarType "oidvector"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_pb"
->            [ ScalarType "point"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_pl"
->            [ ScalarType "point"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_ppath"
->            [ ScalarType "point"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_ps"
->            [ ScalarType "point"
->            , ScalarType "lseg"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_sb"
->            [ ScalarType "lseg"
->            , ScalarType "box"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "on_sl"
->            [ ScalarType "lseg"
->            , ScalarType "line"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "opaque_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Opaque )
->            False
->        , CatCreateFunction
->            FunName
->            "opaque_out"
->            [ Pseudo Opaque
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "time"
->            , ScalarType "time"
->            , ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "time"
->            , ScalarType "time"
->            , ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            , ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            , ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            , ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            , ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            , ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            , ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            , ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            , ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlaps"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            , ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlay"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "overlay"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "path"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_add"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_add_pt"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_center"
->            [ ScalarType "path"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_contain_pt"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_distance"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_div_pt"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_inter"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_length"
->            [ ScalarType "path"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_mul_pt"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_n_eq"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_n_ge"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_n_gt"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_n_le"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_n_lt"
->            [ ScalarType "path"
->            , ScalarType "path"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_npoints"
->            [ ScalarType "path"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_out"
->            [ ScalarType "path"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "path_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_send"
->            [ ScalarType "path"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "path_sub_pt"
->            [ ScalarType "path"
->            , ScalarType "point"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "pclose"
->            [ ScalarType "path"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_lock"
->            [ ScalarType "int8"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_lock"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_lock_shared"
->            [ ScalarType "int8"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_lock_shared"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_unlock"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_unlock"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_unlock_all"
->            [] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_unlock_shared"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_advisory_unlock_shared"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_backend_pid"
->            [] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_cancel_backend"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_char_to_encoding"
->            [ ScalarType "name"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_client_encoding"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_column_size"
->            [ Pseudo Any
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_conf_load_time"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_conversion_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_current_xlog_insert_location"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_current_xlog_location"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_cursor"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_database_size"
->            [ ScalarType "name"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_database_size"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_encoding_to_char"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_function_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_constraintdef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_constraintdef"
->            [ ScalarType "oid"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_expr"
->            [ ScalarType "text"
->            , ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_expr"
->            [ ScalarType "text"
->            , ScalarType "oid"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_function_arguments"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_function_identity_arguments"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_function_result"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_functiondef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_indexdef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_indexdef"
->            [ ScalarType "oid"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_keywords"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_ruledef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_ruledef"
->            [ ScalarType "oid"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_serial_sequence"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_triggerdef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_userbyid"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_viewdef"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_viewdef"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_viewdef"
->            [ ScalarType "text"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_get_viewdef"
->            [ ScalarType "oid"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "name"
->            , ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "name"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "oid"
->            , ScalarType "name"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_has_role"
->            [ ScalarType "oid"
->            , ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_is_other_temp_schema"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_lock_status"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_ls_dir"
->            [ ScalarType "text"
->            ] (
->            SetOfType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_my_temp_schema"
->            [] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_opclass_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_operator_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_options_to_table"
->            [ ArrayType ( ScalarType "text" )
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_postmaster_start_time"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_prepared_statement"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_prepared_xact"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_read_file"
->            [ ScalarType "text"
->            , ScalarType "int8"
->            , ScalarType "int8"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_relation_size"
->            [ ScalarType "regclass"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_relation_size"
->            [ ScalarType "regclass"
->            , ScalarType "text"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_reload_conf"
->            [] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_rotate_logfile"
->            [] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_show_all_settings"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_size_pretty"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_sleep"
->            [ ScalarType "float8"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_start_backup"
->            [ ScalarType "text"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_clear_snapshot"
->            [] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_file"
->            [ ScalarType "text"
->            ] (
->            Pseudo Record )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_activity"
->            [ ScalarType "int4"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_activity"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_activity_start"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_client_addr"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_client_port"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_dbid"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_idset"
->            [] (
->            SetOfType ( ScalarType "int4" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_pid"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_start"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_userid"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_waiting"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_backend_xact_start"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_bgwriter_buf_written_checkpoints"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_bgwriter_buf_written_clean"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_bgwriter_maxwritten_clean"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_bgwriter_requested_checkpoints"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_bgwriter_timed_checkpoints"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_blocks_fetched"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_blocks_hit"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_buf_alloc"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_buf_written_backend"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_blocks_fetched"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_blocks_hit"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_numbackends"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_tuples_deleted"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_tuples_fetched"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_tuples_inserted"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_tuples_returned"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_tuples_updated"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_xact_commit"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_db_xact_rollback"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_dead_tuples"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_function_calls"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_function_self_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_function_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_last_analyze_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_last_autoanalyze_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_last_autovacuum_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_last_vacuum_time"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_live_tuples"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_numscans"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_deleted"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_fetched"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_hot_updated"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_inserted"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_returned"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_get_tuples_updated"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stat_reset"
->            [] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_stop_backup"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_switch_xlog"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_table_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_tablespace_databases"
->            [ ScalarType "oid"
->            ] (
->            SetOfType ( ScalarType "oid" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_tablespace_size"
->            [ ScalarType "name"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_tablespace_size"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_terminate_backend"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_timezone_abbrevs"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_timezone_names"
->            [] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_total_relation_size"
->            [ ScalarType "regclass"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_try_advisory_lock"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_try_advisory_lock"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_try_advisory_lock_shared"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_try_advisory_lock_shared"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_ts_config_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_ts_dict_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_ts_parser_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_ts_template_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_type_is_visible"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_typeof"
->            [ Pseudo Any
->            ] (
->            ScalarType "regtype" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_xlogfile_name"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "pg_xlogfile_name_offset"
->            [ ScalarType "text"
->            ] (
->            Pseudo Record )
->            False
->        , CatCreateFunction
->            FunName
->            "pi"
->            [] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "plainto_tsquery"
->            [ ScalarType "text"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "plainto_tsquery"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "lseg"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "path"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "box"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_above"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_add"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_below"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_distance"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_div"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_eq"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_horiz"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_left"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_mul"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_ne"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_out"
->            [ ScalarType "point"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "point_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_right"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_send"
->            [ ScalarType "point"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_sub"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "point_vert"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_above"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_below"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_center"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "point" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_contain"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_contain_pt"
->            [ ScalarType "polygon"
->            , ScalarType "point"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_contained"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_distance"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_left"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_npoints"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_out"
->            [ ScalarType "polygon"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_overabove"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_overbelow"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_overlap"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_overleft"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_overright"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_right"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_same"
->            [ ScalarType "polygon"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "poly_send"
->            [ ScalarType "polygon"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "polygon"
->            [ ScalarType "path"
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "polygon"
->            [ ScalarType "box"
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "polygon"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "polygon"
->            [ ScalarType "int4"
->            , ScalarType "circle"
->            ] (
->            ScalarType "polygon" )
->            False
->        , CatCreateFunction
->            FunName
->            "popen"
->            [ ScalarType "path"
->            ] (
->            ScalarType "path" )
->            False
->        , CatCreateFunction
->            FunName
->            "position"
->            [ ScalarType "bytea"
->            , ScalarType "bytea"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "position"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "position"
->            [ ScalarType "bit"
->            , ScalarType "bit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "positionjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "positionsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "postgresql_fdw_validator"
->            [ ArrayType ( ScalarType "text" )
->            , ScalarType "oid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pow"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "pow"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "power"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "power"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "prsd_end"
->            [ Pseudo Internal
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "prsd_headline"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , ScalarType "tsquery"
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "prsd_lextype"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "prsd_nexttoken"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "prsd_start"
->            [ Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "pt_contained_circle"
->            [ ScalarType "point"
->            , ScalarType "circle"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "pt_contained_poly"
->            [ ScalarType "point"
->            , ScalarType "polygon"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "query_to_xml"
->            [ ScalarType "text"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "query_to_xml_and_xmlschema"
->            [ ScalarType "text"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "query_to_xmlschema"
->            [ ScalarType "text"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "querytree"
->            [ ScalarType "tsquery"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "quote_ident"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "quote_literal"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "quote_literal"
->            [ Pseudo AnyElement
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "quote_nullable"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "quote_nullable"
->            [ Pseudo AnyElement
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "radians"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "radius"
->            [ ScalarType "circle"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "random"
->            [] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_eq"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_ge"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_gt"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo Record )
->            False
->        , CatCreateFunction
->            FunName
->            "record_le"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_lt"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_ne"
->            [ Pseudo Record
->            , Pseudo Record
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "record_out"
->            [ Pseudo Record
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "record_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            Pseudo Record )
->            False
->        , CatCreateFunction
->            FunName
->            "record_send"
->            [ Pseudo Record
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regclass"
->            [ ScalarType "text"
->            ] (
->            ScalarType "regclass" )
->            False
->        , CatCreateFunction
->            FunName
->            "regclassin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regclass" )
->            False
->        , CatCreateFunction
->            FunName
->            "regclassout"
->            [ ScalarType "regclass"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regclassrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regclass" )
->            False
->        , CatCreateFunction
->            FunName
->            "regclasssend"
->            [ ScalarType "regclass"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regconfigin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regconfig" )
->            False
->        , CatCreateFunction
->            FunName
->            "regconfigout"
->            [ ScalarType "regconfig"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regconfigrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regconfig" )
->            False
->        , CatCreateFunction
->            FunName
->            "regconfigsend"
->            [ ScalarType "regconfig"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regdictionaryin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regdictionary" )
->            False
->        , CatCreateFunction
->            FunName
->            "regdictionaryout"
->            [ ScalarType "regdictionary"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regdictionaryrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regdictionary" )
->            False
->        , CatCreateFunction
->            FunName
->            "regdictionarysend"
->            [ ScalarType "regdictionary"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexeqjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexeqsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexnejoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexnesel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_matches"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( ArrayType ( ScalarType "text" ) ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_matches"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( ArrayType ( ScalarType "text" ) ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_replace"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_replace"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_split_to_array"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ArrayType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_split_to_array"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ArrayType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_split_to_table"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regexp_split_to_table"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperatorin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regoperator" )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperatorout"
->            [ ScalarType "regoperator"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperatorrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regoperator" )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperatorsend"
->            [ ScalarType "regoperator"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regoper" )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperout"
->            [ ScalarType "regoper"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regoperrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regoper" )
->            False
->        , CatCreateFunction
->            FunName
->            "regopersend"
->            [ ScalarType "regoper"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocedurein"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regprocedure" )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocedureout"
->            [ ScalarType "regprocedure"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocedurerecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regprocedure" )
->            False
->        , CatCreateFunction
->            FunName
->            "regproceduresend"
->            [ ScalarType "regprocedure"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regproc" )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocout"
->            [ ScalarType "regproc"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regproc" )
->            False
->        , CatCreateFunction
->            FunName
->            "regprocsend"
->            [ ScalarType "regproc"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "regtypein"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "regtype" )
->            False
->        , CatCreateFunction
->            FunName
->            "regtypeout"
->            [ ScalarType "regtype"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "regtyperecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "regtype" )
->            False
->        , CatCreateFunction
->            FunName
->            "regtypesend"
->            [ ScalarType "regtype"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltime"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "reltime" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimeeq"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimege"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimegt"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimein"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "reltime" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimele"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimelt"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimene"
->            [ ScalarType "reltime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimeout"
->            [ ScalarType "reltime"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimerecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "reltime" )
->            False
->        , CatCreateFunction
->            FunName
->            "reltimesend"
->            [ ScalarType "reltime"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "repeat"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "replace"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "round"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "round"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "round"
->            [ ScalarType "numeric"
->            , ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "rpad"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "rpad"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "rtrim"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "rtrim"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "scalargtjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "scalargtsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "scalarltjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "scalarltsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "schema_to_xml"
->            [ ScalarType "name"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "schema_to_xml_and_xmlschema"
->            [ ScalarType "name"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "schema_to_xmlschema"
->            [ ScalarType "name"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "session_user"
->            [] (
->            ScalarType "name" )
->            False
->        , CatCreateFunction
->            FunName
->            "set_bit"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "set_byte"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "set_config"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "set_masklen"
->            [ ScalarType "cidr"
->            , ScalarType "int4"
->            ] (
->            ScalarType "cidr" )
->            False
->        , CatCreateFunction
->            FunName
->            "set_masklen"
->            [ ScalarType "inet"
->            , ScalarType "int4"
->            ] (
->            ScalarType "inet" )
->            False
->        , CatCreateFunction
->            FunName
->            "setseed"
->            [ ScalarType "float8"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "setval"
->            [ ScalarType "regclass"
->            , ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "setval"
->            [ ScalarType "regclass"
->            , ScalarType "int8"
->            , ScalarType "bool"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "setweight"
->            [ ScalarType "tsvector"
->            , ScalarType "char"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "shell_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Opaque )
->            False
->        , CatCreateFunction
->            FunName
->            "shell_out"
->            [ Pseudo Opaque
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "shift_jis_2004_to_euc_jis_2004"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "shift_jis_2004_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "shobj_description"
->            [ ScalarType "oid"
->            , ScalarType "name"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "sign"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "sign"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "similar_escape"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "sin"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "sjis_to_euc_jp"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "sjis_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "sjis_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "slope"
->            [ ScalarType "point"
->            , ScalarType "point"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "smgreq"
->            [ ScalarType "smgr"
->            , ScalarType "smgr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "smgrin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "smgr" )
->            False
->        , CatCreateFunction
->            FunName
->            "smgrne"
->            [ ScalarType "smgr"
->            , ScalarType "smgr"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "smgrout"
->            [ ScalarType "smgr"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "split_part"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "sqrt"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "sqrt"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "statement_timestamp"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "string_to_array"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ArrayType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "strip"
->            [ ScalarType "tsvector"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "strpos"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "substr"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "substr"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substr"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "substr"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "bytea"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "substring"
->            [ ScalarType "bit"
->            , ScalarType "int4"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunName
->            "suppress_redundant_updates_trigger"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "table_to_xml"
->            [ ScalarType "regclass"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "table_to_xml_and_xmlschema"
->            [ ScalarType "regclass"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "table_to_xmlschema"
->            [ ScalarType "regclass"
->            , ScalarType "bool"
->            , ScalarType "bool"
->            , ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "tan"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "char"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "name"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "xml"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "inet"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_ge"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_gt"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_larger"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_le"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_lt"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_pattern_ge"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_pattern_gt"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_pattern_le"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_pattern_lt"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "text_smaller"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "textanycat"
->            [ ScalarType "text"
->            , Pseudo AnyNonArray
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "textcat"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "texteq"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "texticlike"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "texticnlike"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "texticregexeq"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "texticregexne"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "textlen"
->            [ ScalarType "text"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "textlike"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textne"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textnlike"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textout"
->            [ ScalarType "text"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "textrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "textregexeq"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textregexne"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "textsend"
->            [ ScalarType "text"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "thesaurus_init"
->            [ Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "thesaurus_lexize"
->            [ Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            , Pseudo Internal
->            ] (
->            Pseudo Internal )
->            False
->        , CatCreateFunction
->            FunName
->            "tideq"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidge"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidgt"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidlarger"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidle"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidlt"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidne"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidout"
->            [ ScalarType "tid"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "tidrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidsend"
->            [ ScalarType "tid"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "tidsmaller"
->            [ ScalarType "tid"
->            , ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "timetz"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time"
->            [ ScalarType "time"
->            , ScalarType "int4"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_cmp"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_eq"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_ge"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_gt"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_hash"
->            [ ScalarType "time"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_larger"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_le"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_lt"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_mi_interval"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_mi_time"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_ne"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_out"
->            [ ScalarType "time"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "time_pl_interval"
->            [ ScalarType "time"
->            , ScalarType "interval"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_send"
->            [ ScalarType "time"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "time_smaller"
->            [ ScalarType "time"
->            , ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunName
->            "timedate_pl"
->            [ ScalarType "time"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timemi"
->            [ ScalarType "abstime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "timenow"
->            [] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "timeofday"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "timepl"
->            [ ScalarType "abstime"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp"
->            [ ScalarType "date"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp"
->            [ ScalarType "date"
->            , ScalarType "time"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp"
->            [ ScalarType "timestamp"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_cmp"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_cmp_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_cmp_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_eq"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_eq_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_eq_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ge"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ge_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ge_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_gt"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_gt_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_gt_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_hash"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_larger"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_le"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_le_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_le_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_lt"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_lt_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_lt_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_mi"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_mi_interval"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ne"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ne_date"
->            [ ScalarType "timestamp"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_ne_timestamptz"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_out"
->            [ ScalarType "timestamp"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_pl_interval"
->            [ ScalarType "timestamp"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_send"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamp_smaller"
->            [ ScalarType "timestamp"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "date"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "date"
->            , ScalarType "time"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "date"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz"
->            [ ScalarType "timestamptz"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_cmp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_cmp_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_cmp_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_eq"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_eq_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_eq_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ge"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ge_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ge_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_gt"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_gt_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_gt_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_larger"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_le"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_le_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_le_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_lt"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_lt_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_lt_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_mi"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_mi_interval"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ne"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ne_date"
->            [ ScalarType "timestamptz"
->            , ScalarType "date"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_ne_timestamp"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_out"
->            [ ScalarType "timestamptz"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_pl_interval"
->            [ ScalarType "timestamptz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_send"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptz_smaller"
->            [ ScalarType "timestamptz"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptztypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timestamptztypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timetypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz"
->            [ ScalarType "time"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz"
->            [ ScalarType "timetz"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_cmp"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_eq"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_ge"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_gt"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_hash"
->            [ ScalarType "timetz"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_larger"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_le"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_lt"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_mi_interval"
->            [ ScalarType "timetz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_ne"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_out"
->            [ ScalarType "timetz"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_pl_interval"
->            [ ScalarType "timetz"
->            , ScalarType "interval"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_send"
->            [ ScalarType "timetz"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetz_smaller"
->            [ ScalarType "timetz"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetzdate_pl"
->            [ ScalarType "timetz"
->            , ScalarType "date"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetztypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "timetztypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "text"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "text"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "text"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "interval"
->            , ScalarType "timestamp"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "interval"
->            , ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunName
->            "timezone"
->            [ ScalarType "interval"
->            , ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunName
->            "tinterval"
->            [ ScalarType "abstime"
->            , ScalarType "abstime"
->            ] (
->            ScalarType "tinterval" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalct"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalend"
->            [ ScalarType "tinterval"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervaleq"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalge"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalgt"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "tinterval" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalle"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalleneq"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallenge"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallengt"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallenle"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallenlt"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallenne"
->            [ ScalarType "tinterval"
->            , ScalarType "reltime"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervallt"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalne"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalout"
->            [ ScalarType "tinterval"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalov"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "tinterval" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalrel"
->            [ ScalarType "tinterval"
->            ] (
->            ScalarType "reltime" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalsame"
->            [ ScalarType "tinterval"
->            , ScalarType "tinterval"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalsend"
->            [ ScalarType "tinterval"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "tintervalstart"
->            [ ScalarType "tinterval"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_ascii"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_ascii"
->            [ ScalarType "text"
->            , ScalarType "name"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_ascii"
->            [ ScalarType "text"
->            , ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "int8"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "int4"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "float4"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "float8"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "timestamp"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "timestamptz"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "interval"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_char"
->            [ ScalarType "numeric"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_date"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_hex"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_hex"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_number"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_timestamp"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_timestamp"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_tsquery"
->            [ ScalarType "text"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_tsquery"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_tsvector"
->            [ ScalarType "text"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "to_tsvector"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "transaction_timestamp"
->            [] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunName
->            "translate"
->            [ ScalarType "text"
->            , ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "trigger_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "trigger_out"
->            [ Pseudo Trigger
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "trunc"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "trunc"
->            [ ScalarType "macaddr"
->            ] (
->            ScalarType "macaddr" )
->            False
->        , CatCreateFunction
->            FunName
->            "trunc"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "trunc"
->            [ ScalarType "numeric"
->            , ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_debug"
->            [ ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_debug"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_headline"
->            [ ScalarType "text"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_headline"
->            [ ScalarType "text"
->            , ScalarType "tsquery"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_headline"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_headline"
->            [ ScalarType "regconfig"
->            , ScalarType "text"
->            , ScalarType "tsquery"
->            , ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_lexize"
->            [ ScalarType "regdictionary"
->            , ScalarType "text"
->            ] (
->            ArrayType ( ScalarType "text" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_match_qv"
->            [ ScalarType "tsquery"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_match_tq"
->            [ ScalarType "text"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_match_tt"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_match_vq"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_parse"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_parse"
->            [ ScalarType "oid"
->            , ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank"
->            [ ArrayType ( ScalarType "float4" )
->            , ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            , ScalarType "int4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank"
->            [ ArrayType ( ScalarType "float4" )
->            , ScalarType "tsvector"
->            , ScalarType "tsquery"
->            , ScalarType "int4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank_cd"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank_cd"
->            [ ArrayType ( ScalarType "float4" )
->            , ScalarType "tsvector"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank_cd"
->            [ ScalarType "tsvector"
->            , ScalarType "tsquery"
->            , ScalarType "int4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rank_cd"
->            [ ArrayType ( ScalarType "float4" )
->            , ScalarType "tsvector"
->            , ScalarType "tsquery"
->            , ScalarType "int4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rewrite"
->            [ ScalarType "tsquery"
->            , ScalarType "text"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_rewrite"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_stat"
->            [ ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_stat"
->            [ ScalarType "text"
->            , ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_token_type"
->            [ ScalarType "text"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_token_type"
->            [ ScalarType "oid"
->            ] (
->            SetOfType ( Pseudo Record ) )
->            False
->        , CatCreateFunction
->            FunName
->            "ts_typanalyze"
->            [ Pseudo Internal
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsmatchjoinsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int2"
->            , Pseudo Internal
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsmatchsel"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsq_mcontained"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsq_mcontains"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_and"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_cmp"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_eq"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_ge"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_gt"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_le"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_lt"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_ne"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_not"
->            [ ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquery_or"
->            [ ScalarType "tsquery"
->            , ScalarType "tsquery"
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsqueryin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsqueryout"
->            [ ScalarType "tsquery"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "tsqueryrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "tsquery" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsquerysend"
->            [ ScalarType "tsquery"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_cmp"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_concat"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_eq"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_ge"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_gt"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_le"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_lt"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_ne"
->            [ ScalarType "tsvector"
->            , ScalarType "tsvector"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_update_trigger"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvector_update_trigger_column"
->            [] (
->            Pseudo Trigger )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvectorin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvectorout"
->            [ ScalarType "tsvector"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvectorrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "tsvector" )
->            False
->        , CatCreateFunction
->            FunName
->            "tsvectorsend"
->            [ ScalarType "tsvector"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_current"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_current_snapshot"
->            [] (
->            ScalarType "txid_snapshot" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "txid_snapshot" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_out"
->            [ ScalarType "txid_snapshot"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "txid_snapshot" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_send"
->            [ ScalarType "txid_snapshot"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_xip"
->            [ ScalarType "txid_snapshot"
->            ] (
->            SetOfType ( ScalarType "int8" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_xmax"
->            [ ScalarType "txid_snapshot"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_snapshot_xmin"
->            [ ScalarType "txid_snapshot"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunName
->            "txid_visible_in_snapshot"
->            [ ScalarType "int8"
->            , ScalarType "txid_snapshot"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uhc_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "unknownin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "unknown" )
->            False
->        , CatCreateFunction
->            FunName
->            "unknownout"
->            [ ScalarType "unknown"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "unknownrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "unknown" )
->            False
->        , CatCreateFunction
->            FunName
->            "unknownsend"
->            [ ScalarType "unknown"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "unnest"
->            [ Pseudo AnyArray
->            ] (
->            SetOfType ( Pseudo AnyElement ) )
->            False
->        , CatCreateFunction
->            FunName
->            "upper"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_ascii"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_big5"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_euc_cn"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_euc_jis_2004"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_euc_jp"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_euc_kr"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_euc_tw"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_gb18030"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_gbk"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_iso8859"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_iso8859_1"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_johab"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_koi8r"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_koi8u"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_shift_jis_2004"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_sjis"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_uhc"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "utf8_to_win"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_cmp"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_eq"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_ge"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_gt"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_hash"
->            [ ScalarType "uuid"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "uuid" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_le"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_lt"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_ne"
->            [ ScalarType "uuid"
->            , ScalarType "uuid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_out"
->            [ ScalarType "uuid"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "uuid" )
->            False
->        , CatCreateFunction
->            FunName
->            "uuid_send"
->            [ ScalarType "uuid"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbit"
->            [ ScalarType "varbit"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            ScalarType "varbit" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbit_in"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "varbit" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbit_out"
->            [ ScalarType "varbit"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "varbit_recv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "varbit" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbit_send"
->            [ ScalarType "varbit"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitcmp"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbiteq"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitge"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitgt"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitle"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitlt"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbitne"
->            [ ScalarType "varbit"
->            , ScalarType "varbit"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbittypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "varbittypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "varchar"
->            [ ScalarType "name"
->            ] (
->            ScalarType "varchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "varchar"
->            [ ScalarType "varchar"
->            , ScalarType "int4"
->            , ScalarType "bool"
->            ] (
->            ScalarType "varchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "varcharin"
->            [ Pseudo Cstring
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "varchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "varcharout"
->            [ ScalarType "varchar"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "varcharrecv"
->            [ Pseudo Internal
->            , ScalarType "oid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "varchar" )
->            False
->        , CatCreateFunction
->            FunName
->            "varcharsend"
->            [ ScalarType "varchar"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "varchartypmodin"
->            [ ArrayType ( Pseudo Cstring )
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "varchartypmodout"
->            [ ScalarType "int4"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "version"
->            [] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunName
->            "void_in"
->            [ Pseudo Cstring
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "void_out"
->            [ Pseudo Void
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "width"
->            [ ScalarType "box"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunName
->            "width_bucket"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            , ScalarType "float8"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "width_bucket"
->            [ ScalarType "numeric"
->            , ScalarType "numeric"
->            , ScalarType "numeric"
->            , ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunName
->            "win1250_to_latin2"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win1250_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win1251_to_iso"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win1251_to_koi8r"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win1251_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win1251_to_win866"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win866_to_iso"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win866_to_koi8r"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win866_to_mic"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win866_to_win1251"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "win_to_utf8"
->            [ ScalarType "int4"
->            , ScalarType "int4"
->            , Pseudo Cstring
->            , Pseudo Internal
->            , ScalarType "int4"
->            ] (
->            Pseudo Void )
->            False
->        , CatCreateFunction
->            FunName
->            "xideq"
->            [ ScalarType "xid"
->            , ScalarType "xid"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "xideqint4"
->            [ ScalarType "xid"
->            , ScalarType "int4"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "xidin"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "xid" )
->            False
->        , CatCreateFunction
->            FunName
->            "xidout"
->            [ ScalarType "xid"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "xidrecv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "xid" )
->            False
->        , CatCreateFunction
->            FunName
->            "xidsend"
->            [ ScalarType "xid"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "xml"
->            [ ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "xml_in"
->            [ Pseudo Cstring
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "xml_out"
->            [ ScalarType "xml"
->            ] (
->            Pseudo Cstring )
->            False
->        , CatCreateFunction
->            FunName
->            "xml_recv"
->            [ Pseudo Internal
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "xml_send"
->            [ ScalarType "xml"
->            ] (
->            ScalarType "bytea" )
->            False
->        , CatCreateFunction
->            FunName
->            "xmlcomment"
->            [ ScalarType "text"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "xmlconcat2"
->            [ ScalarType "xml"
->            , ScalarType "xml"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunName
->            "xmlvalidate"
->            [ ScalarType "xml"
->            , ScalarType "text"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunName
->            "xpath"
->            [ ScalarType "text"
->            , ScalarType "xml"
->            ] (
->            ArrayType ( ScalarType "xml" ) )
->            False
->        , CatCreateFunction
->            FunName
->            "xpath"
->            [ ScalarType "text"
->            , ScalarType "xml"
->            , ArrayType ( ScalarType "text" )
->            ] (
->            ArrayType ( ScalarType "xml" ) )
->            False
->        , CatCreateFunction
->            FunAgg
->            "array_agg"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "avg"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_and"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_and"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_and"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_and"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_or"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_or"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_or"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bit_or"
->            [ ScalarType "bit"
->            ] (
->            ScalarType "bit" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bool_and"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "bool_or"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "corr"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "count"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "count"
->            [ Pseudo Any
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "covar_pop"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "covar_samp"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "every"
->            [ ScalarType "bool"
->            ] (
->            ScalarType "bool" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunAgg
->            "max"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int2" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "text"
->            ] (
->            ScalarType "text" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "oid"
->            ] (
->            ScalarType "oid" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "tid"
->            ] (
->            ScalarType "tid" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "abstime"
->            ] (
->            ScalarType "abstime" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "bpchar"
->            ] (
->            ScalarType "bpchar" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "date"
->            ] (
->            ScalarType "date" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "time"
->            ] (
->            ScalarType "time" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "timestamp"
->            ] (
->            ScalarType "timestamp" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "timestamptz"
->            ] (
->            ScalarType "timestamptz" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "timetz"
->            ] (
->            ScalarType "timetz" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ Pseudo AnyArray
->            ] (
->            Pseudo AnyArray )
->            False
->        , CatCreateFunction
->            FunAgg
->            "min"
->            [ Pseudo AnyEnum
->            ] (
->            Pseudo AnyEnum )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_avgx"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_avgy"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_count"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_intercept"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_r2"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_slope"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_sxx"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_sxy"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "regr_syy"
->            [ ScalarType "float8"
->            , ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_pop"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "stddev_samp"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float4" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "money"
->            ] (
->            ScalarType "money" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "interval"
->            ] (
->            ScalarType "interval" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "sum"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_pop"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "var_samp"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "int8"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "int2"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "float4"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "float8"
->            ] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "variance"
->            [ ScalarType "numeric"
->            ] (
->            ScalarType "numeric" )
->            False
->        , CatCreateFunction
->            FunAgg
->            "xmlagg"
->            [ ScalarType "xml"
->            ] (
->            ScalarType "xml" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "cume_dist"
->            [] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "dense_rank"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "first_value"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lag"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lag"
->            [ Pseudo AnyElement
->            , ScalarType "int4"
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lag"
->            [ Pseudo AnyElement
->            , ScalarType "int4"
->            , Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "last_value"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lead"
->            [ Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lead"
->            [ Pseudo AnyElement
->            , ScalarType "int4"
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "lead"
->            [ Pseudo AnyElement
->            , ScalarType "int4"
->            , Pseudo AnyElement
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "nth_value"
->            [ Pseudo AnyElement
->            , ScalarType "int4"
->            ] (
->            Pseudo AnyElement )
->            False
->        , CatCreateFunction
->            FunWindow
->            "ntile"
->            [ ScalarType "int4"
->            ] (
->            ScalarType "int4" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "percent_rank"
->            [] (
->            ScalarType "float8" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "rank"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateFunction
->            FunWindow
->            "row_number"
->            [] (
->            ScalarType "int8" )
->            False
->        , CatCreateTable
->            "pg_aggregate"
->            [ ( "aggfnoid"
->              , ScalarType "regproc"
->              )
->            , ( "aggtransfn"
->              , ScalarType "regproc"
->              )
->            , ( "aggfinalfn"
->              , ScalarType "regproc"
->              )
->            , ( "aggsortop"
->              , ScalarType "oid"
->              )
->            , ( "aggtranstype"
->              , ScalarType "oid"
->              )
->            , ( "agginitval"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_am"
->            [ ( "amname"
->              , ScalarType "name"
->              )
->            , ( "amstrategies"
->              , ScalarType "int2"
->              )
->            , ( "amsupport"
->              , ScalarType "int2"
->              )
->            , ( "amcanorder"
->              , ScalarType "bool"
->              )
->            , ( "amcanbackward"
->              , ScalarType "bool"
->              )
->            , ( "amcanunique"
->              , ScalarType "bool"
->              )
->            , ( "amcanmulticol"
->              , ScalarType "bool"
->              )
->            , ( "amoptionalkey"
->              , ScalarType "bool"
->              )
->            , ( "amindexnulls"
->              , ScalarType "bool"
->              )
->            , ( "amsearchnulls"
->              , ScalarType "bool"
->              )
->            , ( "amstorage"
->              , ScalarType "bool"
->              )
->            , ( "amclusterable"
->              , ScalarType "bool"
->              )
->            , ( "amkeytype"
->              , ScalarType "oid"
->              )
->            , ( "aminsert"
->              , ScalarType "regproc"
->              )
->            , ( "ambeginscan"
->              , ScalarType "regproc"
->              )
->            , ( "amgettuple"
->              , ScalarType "regproc"
->              )
->            , ( "amgetbitmap"
->              , ScalarType "regproc"
->              )
->            , ( "amrescan"
->              , ScalarType "regproc"
->              )
->            , ( "amendscan"
->              , ScalarType "regproc"
->              )
->            , ( "ammarkpos"
->              , ScalarType "regproc"
->              )
->            , ( "amrestrpos"
->              , ScalarType "regproc"
->              )
->            , ( "ambuild"
->              , ScalarType "regproc"
->              )
->            , ( "ambulkdelete"
->              , ScalarType "regproc"
->              )
->            , ( "amvacuumcleanup"
->              , ScalarType "regproc"
->              )
->            , ( "amcostestimate"
->              , ScalarType "regproc"
->              )
->            , ( "amoptions"
->              , ScalarType "regproc"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_amop"
->            [ ( "amopfamily"
->              , ScalarType "oid"
->              )
->            , ( "amoplefttype"
->              , ScalarType "oid"
->              )
->            , ( "amoprighttype"
->              , ScalarType "oid"
->              )
->            , ( "amopstrategy"
->              , ScalarType "int2"
->              )
->            , ( "amopopr"
->              , ScalarType "oid"
->              )
->            , ( "amopmethod"
->              , ScalarType "oid"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_amproc"
->            [ ( "amprocfamily"
->              , ScalarType "oid"
->              )
->            , ( "amproclefttype"
->              , ScalarType "oid"
->              )
->            , ( "amprocrighttype"
->              , ScalarType "oid"
->              )
->            , ( "amprocnum"
->              , ScalarType "int2"
->              )
->            , ( "amproc"
->              , ScalarType "regproc"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_attrdef"
->            [ ( "adrelid"
->              , ScalarType "oid"
->              )
->            , ( "adnum"
->              , ScalarType "int2"
->              )
->            , ( "adbin"
->              , ScalarType "text"
->              )
->            , ( "adsrc"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_attribute"
->            [ ( "attrelid"
->              , ScalarType "oid"
->              )
->            , ( "attname"
->              , ScalarType "name"
->              )
->            , ( "atttypid"
->              , ScalarType "oid"
->              )
->            , ( "attstattarget"
->              , ScalarType "int4"
->              )
->            , ( "attlen"
->              , ScalarType "int2"
->              )
->            , ( "attnum"
->              , ScalarType "int2"
->              )
->            , ( "attndims"
->              , ScalarType "int4"
->              )
->            , ( "attcacheoff"
->              , ScalarType "int4"
->              )
->            , ( "atttypmod"
->              , ScalarType "int4"
->              )
->            , ( "attbyval"
->              , ScalarType "bool"
->              )
->            , ( "attstorage"
->              , ScalarType "char"
->              )
->            , ( "attalign"
->              , ScalarType "char"
->              )
->            , ( "attnotnull"
->              , ScalarType "bool"
->              )
->            , ( "atthasdef"
->              , ScalarType "bool"
->              )
->            , ( "attisdropped"
->              , ScalarType "bool"
->              )
->            , ( "attislocal"
->              , ScalarType "bool"
->              )
->            , ( "attinhcount"
->              , ScalarType "int4"
->              )
->            , ( "attacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_auth_members"
->            [ ( "roleid"
->              , ScalarType "oid"
->              )
->            , ( "member"
->              , ScalarType "oid"
->              )
->            , ( "grantor"
->              , ScalarType "oid"
->              )
->            , ( "admin_option"
->              , ScalarType "bool"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_authid"
->            [ ( "rolname"
->              , ScalarType "name"
->              )
->            , ( "rolsuper"
->              , ScalarType "bool"
->              )
->            , ( "rolinherit"
->              , ScalarType "bool"
->              )
->            , ( "rolcreaterole"
->              , ScalarType "bool"
->              )
->            , ( "rolcreatedb"
->              , ScalarType "bool"
->              )
->            , ( "rolcatupdate"
->              , ScalarType "bool"
->              )
->            , ( "rolcanlogin"
->              , ScalarType "bool"
->              )
->            , ( "rolconnlimit"
->              , ScalarType "int4"
->              )
->            , ( "rolpassword"
->              , ScalarType "text"
->              )
->            , ( "rolvaliduntil"
->              , ScalarType "timestamptz"
->              )
->            , ( "rolconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_cast"
->            [ ( "castsource"
->              , ScalarType "oid"
->              )
->            , ( "casttarget"
->              , ScalarType "oid"
->              )
->            , ( "castfunc"
->              , ScalarType "oid"
->              )
->            , ( "castcontext"
->              , ScalarType "char"
->              )
->            , ( "castmethod"
->              , ScalarType "char"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_class"
->            [ ( "relname"
->              , ScalarType "name"
->              )
->            , ( "relnamespace"
->              , ScalarType "oid"
->              )
->            , ( "reltype"
->              , ScalarType "oid"
->              )
->            , ( "relowner"
->              , ScalarType "oid"
->              )
->            , ( "relam"
->              , ScalarType "oid"
->              )
->            , ( "relfilenode"
->              , ScalarType "oid"
->              )
->            , ( "reltablespace"
->              , ScalarType "oid"
->              )
->            , ( "relpages"
->              , ScalarType "int4"
->              )
->            , ( "reltuples"
->              , ScalarType "float4"
->              )
->            , ( "reltoastrelid"
->              , ScalarType "oid"
->              )
->            , ( "reltoastidxid"
->              , ScalarType "oid"
->              )
->            , ( "relhasindex"
->              , ScalarType "bool"
->              )
->            , ( "relisshared"
->              , ScalarType "bool"
->              )
->            , ( "relistemp"
->              , ScalarType "bool"
->              )
->            , ( "relkind"
->              , ScalarType "char"
->              )
->            , ( "relnatts"
->              , ScalarType "int2"
->              )
->            , ( "relchecks"
->              , ScalarType "int2"
->              )
->            , ( "relhasoids"
->              , ScalarType "bool"
->              )
->            , ( "relhaspkey"
->              , ScalarType "bool"
->              )
->            , ( "relhasrules"
->              , ScalarType "bool"
->              )
->            , ( "relhastriggers"
->              , ScalarType "bool"
->              )
->            , ( "relhassubclass"
->              , ScalarType "bool"
->              )
->            , ( "relfrozenxid"
->              , ScalarType "xid"
->              )
->            , ( "relacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            , ( "reloptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_constraint"
->            [ ( "conname"
->              , ScalarType "name"
->              )
->            , ( "connamespace"
->              , ScalarType "oid"
->              )
->            , ( "contype"
->              , ScalarType "char"
->              )
->            , ( "condeferrable"
->              , ScalarType "bool"
->              )
->            , ( "condeferred"
->              , ScalarType "bool"
->              )
->            , ( "conrelid"
->              , ScalarType "oid"
->              )
->            , ( "contypid"
->              , ScalarType "oid"
->              )
->            , ( "confrelid"
->              , ScalarType "oid"
->              )
->            , ( "confupdtype"
->              , ScalarType "char"
->              )
->            , ( "confdeltype"
->              , ScalarType "char"
->              )
->            , ( "confmatchtype"
->              , ScalarType "char"
->              )
->            , ( "conislocal"
->              , ScalarType "bool"
->              )
->            , ( "coninhcount"
->              , ScalarType "int4"
->              )
->            , ( "conkey"
->              , ArrayType ( ScalarType "int2" )
->              )
->            , ( "confkey"
->              , ArrayType ( ScalarType "int2" )
->              )
->            , ( "conpfeqop"
->              , ArrayType ( ScalarType "oid" )
->              )
->            , ( "conppeqop"
->              , ArrayType ( ScalarType "oid" )
->              )
->            , ( "conffeqop"
->              , ArrayType ( ScalarType "oid" )
->              )
->            , ( "conbin"
->              , ScalarType "text"
->              )
->            , ( "consrc"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_conversion"
->            [ ( "conname"
->              , ScalarType "name"
->              )
->            , ( "connamespace"
->              , ScalarType "oid"
->              )
->            , ( "conowner"
->              , ScalarType "oid"
->              )
->            , ( "conforencoding"
->              , ScalarType "int4"
->              )
->            , ( "contoencoding"
->              , ScalarType "int4"
->              )
->            , ( "conproc"
->              , ScalarType "regproc"
->              )
->            , ( "condefault"
->              , ScalarType "bool"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_database"
->            [ ( "datname"
->              , ScalarType "name"
->              )
->            , ( "datdba"
->              , ScalarType "oid"
->              )
->            , ( "encoding"
->              , ScalarType "int4"
->              )
->            , ( "datcollate"
->              , ScalarType "name"
->              )
->            , ( "datctype"
->              , ScalarType "name"
->              )
->            , ( "datistemplate"
->              , ScalarType "bool"
->              )
->            , ( "datallowconn"
->              , ScalarType "bool"
->              )
->            , ( "datconnlimit"
->              , ScalarType "int4"
->              )
->            , ( "datlastsysoid"
->              , ScalarType "oid"
->              )
->            , ( "datfrozenxid"
->              , ScalarType "xid"
->              )
->            , ( "dattablespace"
->              , ScalarType "oid"
->              )
->            , ( "datconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "datacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_depend"
->            [ ( "classid"
->              , ScalarType "oid"
->              )
->            , ( "objid"
->              , ScalarType "oid"
->              )
->            , ( "objsubid"
->              , ScalarType "int4"
->              )
->            , ( "refclassid"
->              , ScalarType "oid"
->              )
->            , ( "refobjid"
->              , ScalarType "oid"
->              )
->            , ( "refobjsubid"
->              , ScalarType "int4"
->              )
->            , ( "deptype"
->              , ScalarType "char"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_description"
->            [ ( "objoid"
->              , ScalarType "oid"
->              )
->            , ( "classoid"
->              , ScalarType "oid"
->              )
->            , ( "objsubid"
->              , ScalarType "int4"
->              )
->            , ( "description"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_enum"
->            [ ( "enumtypid"
->              , ScalarType "oid"
->              )
->            , ( "enumlabel"
->              , ScalarType "name"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_foreign_data_wrapper"
->            [ ( "fdwname"
->              , ScalarType "name"
->              )
->            , ( "fdwowner"
->              , ScalarType "oid"
->              )
->            , ( "fdwvalidator"
->              , ScalarType "oid"
->              )
->            , ( "fdwacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            , ( "fdwoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_foreign_server"
->            [ ( "srvname"
->              , ScalarType "name"
->              )
->            , ( "srvowner"
->              , ScalarType "oid"
->              )
->            , ( "srvfdw"
->              , ScalarType "oid"
->              )
->            , ( "srvtype"
->              , ScalarType "text"
->              )
->            , ( "srvversion"
->              , ScalarType "text"
->              )
->            , ( "srvacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            , ( "srvoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_index"
->            [ ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "indrelid"
->              , ScalarType "oid"
->              )
->            , ( "indnatts"
->              , ScalarType "int2"
->              )
->            , ( "indisunique"
->              , ScalarType "bool"
->              )
->            , ( "indisprimary"
->              , ScalarType "bool"
->              )
->            , ( "indisclustered"
->              , ScalarType "bool"
->              )
->            , ( "indisvalid"
->              , ScalarType "bool"
->              )
->            , ( "indcheckxmin"
->              , ScalarType "bool"
->              )
->            , ( "indisready"
->              , ScalarType "bool"
->              )
->            , ( "indkey"
->              , ScalarType "int2vector"
->              )
->            , ( "indclass"
->              , ScalarType "oidvector"
->              )
->            , ( "indoption"
->              , ScalarType "int2vector"
->              )
->            , ( "indexprs"
->              , ScalarType "text"
->              )
->            , ( "indpred"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_inherits"
->            [ ( "inhrelid"
->              , ScalarType "oid"
->              )
->            , ( "inhparent"
->              , ScalarType "oid"
->              )
->            , ( "inhseqno"
->              , ScalarType "int4"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_language"
->            [ ( "lanname"
->              , ScalarType "name"
->              )
->            , ( "lanowner"
->              , ScalarType "oid"
->              )
->            , ( "lanispl"
->              , ScalarType "bool"
->              )
->            , ( "lanpltrusted"
->              , ScalarType "bool"
->              )
->            , ( "lanplcallfoid"
->              , ScalarType "oid"
->              )
->            , ( "lanvalidator"
->              , ScalarType "oid"
->              )
->            , ( "lanacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_largeobject"
->            [ ( "loid"
->              , ScalarType "oid"
->              )
->            , ( "pageno"
->              , ScalarType "int4"
->              )
->            , ( "data"
->              , ScalarType "bytea"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_listener"
->            [ ( "relname"
->              , ScalarType "name"
->              )
->            , ( "listenerpid"
->              , ScalarType "int4"
->              )
->            , ( "notification"
->              , ScalarType "int4"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_namespace"
->            [ ( "nspname"
->              , ScalarType "name"
->              )
->            , ( "nspowner"
->              , ScalarType "oid"
->              )
->            , ( "nspacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_opclass"
->            [ ( "opcmethod"
->              , ScalarType "oid"
->              )
->            , ( "opcname"
->              , ScalarType "name"
->              )
->            , ( "opcnamespace"
->              , ScalarType "oid"
->              )
->            , ( "opcowner"
->              , ScalarType "oid"
->              )
->            , ( "opcfamily"
->              , ScalarType "oid"
->              )
->            , ( "opcintype"
->              , ScalarType "oid"
->              )
->            , ( "opcdefault"
->              , ScalarType "bool"
->              )
->            , ( "opckeytype"
->              , ScalarType "oid"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_operator"
->            [ ( "oprname"
->              , ScalarType "name"
->              )
->            , ( "oprnamespace"
->              , ScalarType "oid"
->              )
->            , ( "oprowner"
->              , ScalarType "oid"
->              )
->            , ( "oprkind"
->              , ScalarType "char"
->              )
->            , ( "oprcanmerge"
->              , ScalarType "bool"
->              )
->            , ( "oprcanhash"
->              , ScalarType "bool"
->              )
->            , ( "oprleft"
->              , ScalarType "oid"
->              )
->            , ( "oprright"
->              , ScalarType "oid"
->              )
->            , ( "oprresult"
->              , ScalarType "oid"
->              )
->            , ( "oprcom"
->              , ScalarType "oid"
->              )
->            , ( "oprnegate"
->              , ScalarType "oid"
->              )
->            , ( "oprcode"
->              , ScalarType "regproc"
->              )
->            , ( "oprrest"
->              , ScalarType "regproc"
->              )
->            , ( "oprjoin"
->              , ScalarType "regproc"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_opfamily"
->            [ ( "opfmethod"
->              , ScalarType "oid"
->              )
->            , ( "opfname"
->              , ScalarType "name"
->              )
->            , ( "opfnamespace"
->              , ScalarType "oid"
->              )
->            , ( "opfowner"
->              , ScalarType "oid"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_pltemplate"
->            [ ( "tmplname"
->              , ScalarType "name"
->              )
->            , ( "tmpltrusted"
->              , ScalarType "bool"
->              )
->            , ( "tmpldbacreate"
->              , ScalarType "bool"
->              )
->            , ( "tmplhandler"
->              , ScalarType "text"
->              )
->            , ( "tmplvalidator"
->              , ScalarType "text"
->              )
->            , ( "tmpllibrary"
->              , ScalarType "text"
->              )
->            , ( "tmplacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_proc"
->            [ ( "proname"
->              , ScalarType "name"
->              )
->            , ( "pronamespace"
->              , ScalarType "oid"
->              )
->            , ( "proowner"
->              , ScalarType "oid"
->              )
->            , ( "prolang"
->              , ScalarType "oid"
->              )
->            , ( "procost"
->              , ScalarType "float4"
->              )
->            , ( "prorows"
->              , ScalarType "float4"
->              )
->            , ( "provariadic"
->              , ScalarType "oid"
->              )
->            , ( "proisagg"
->              , ScalarType "bool"
->              )
->            , ( "proiswindow"
->              , ScalarType "bool"
->              )
->            , ( "prosecdef"
->              , ScalarType "bool"
->              )
->            , ( "proisstrict"
->              , ScalarType "bool"
->              )
->            , ( "proretset"
->              , ScalarType "bool"
->              )
->            , ( "provolatile"
->              , ScalarType "char"
->              )
->            , ( "pronargs"
->              , ScalarType "int2"
->              )
->            , ( "pronargdefaults"
->              , ScalarType "int2"
->              )
->            , ( "prorettype"
->              , ScalarType "oid"
->              )
->            , ( "proargtypes"
->              , ScalarType "oidvector"
->              )
->            , ( "proallargtypes"
->              , ArrayType ( ScalarType "oid" )
->              )
->            , ( "proargmodes"
->              , ArrayType ( ScalarType "char" )
->              )
->            , ( "proargnames"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "proargdefaults"
->              , ScalarType "text"
->              )
->            , ( "prosrc"
->              , ScalarType "text"
->              )
->            , ( "probin"
->              , ScalarType "bytea"
->              )
->            , ( "proconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "proacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_rewrite"
->            [ ( "rulename"
->              , ScalarType "name"
->              )
->            , ( "ev_class"
->              , ScalarType "oid"
->              )
->            , ( "ev_attr"
->              , ScalarType "int2"
->              )
->            , ( "ev_type"
->              , ScalarType "char"
->              )
->            , ( "ev_enabled"
->              , ScalarType "char"
->              )
->            , ( "is_instead"
->              , ScalarType "bool"
->              )
->            , ( "ev_qual"
->              , ScalarType "text"
->              )
->            , ( "ev_action"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_shdepend"
->            [ ( "dbid"
->              , ScalarType "oid"
->              )
->            , ( "classid"
->              , ScalarType "oid"
->              )
->            , ( "objid"
->              , ScalarType "oid"
->              )
->            , ( "objsubid"
->              , ScalarType "int4"
->              )
->            , ( "refclassid"
->              , ScalarType "oid"
->              )
->            , ( "refobjid"
->              , ScalarType "oid"
->              )
->            , ( "deptype"
->              , ScalarType "char"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_shdescription"
->            [ ( "objoid"
->              , ScalarType "oid"
->              )
->            , ( "classoid"
->              , ScalarType "oid"
->              )
->            , ( "description"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_statistic"
->            [ ( "starelid"
->              , ScalarType "oid"
->              )
->            , ( "staattnum"
->              , ScalarType "int2"
->              )
->            , ( "stanullfrac"
->              , ScalarType "float4"
->              )
->            , ( "stawidth"
->              , ScalarType "int4"
->              )
->            , ( "stadistinct"
->              , ScalarType "float4"
->              )
->            , ( "stakind1"
->              , ScalarType "int2"
->              )
->            , ( "stakind2"
->              , ScalarType "int2"
->              )
->            , ( "stakind3"
->              , ScalarType "int2"
->              )
->            , ( "stakind4"
->              , ScalarType "int2"
->              )
->            , ( "staop1"
->              , ScalarType "oid"
->              )
->            , ( "staop2"
->              , ScalarType "oid"
->              )
->            , ( "staop3"
->              , ScalarType "oid"
->              )
->            , ( "staop4"
->              , ScalarType "oid"
->              )
->            , ( "stanumbers1"
->              , ArrayType ( ScalarType "float4" )
->              )
->            , ( "stanumbers2"
->              , ArrayType ( ScalarType "float4" )
->              )
->            , ( "stanumbers3"
->              , ArrayType ( ScalarType "float4" )
->              )
->            , ( "stanumbers4"
->              , ArrayType ( ScalarType "float4" )
->              )
->            , ( "stavalues1"
->              , Pseudo AnyArray
->              )
->            , ( "stavalues2"
->              , Pseudo AnyArray
->              )
->            , ( "stavalues3"
->              , Pseudo AnyArray
->              )
->            , ( "stavalues4"
->              , Pseudo AnyArray
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_tablespace"
->            [ ( "spcname"
->              , ScalarType "name"
->              )
->            , ( "spcowner"
->              , ScalarType "oid"
->              )
->            , ( "spclocation"
->              , ScalarType "text"
->              )
->            , ( "spcacl"
->              , ArrayType ( ScalarType "aclitem" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_trigger"
->            [ ( "tgrelid"
->              , ScalarType "oid"
->              )
->            , ( "tgname"
->              , ScalarType "name"
->              )
->            , ( "tgfoid"
->              , ScalarType "oid"
->              )
->            , ( "tgtype"
->              , ScalarType "int2"
->              )
->            , ( "tgenabled"
->              , ScalarType "char"
->              )
->            , ( "tgisconstraint"
->              , ScalarType "bool"
->              )
->            , ( "tgconstrname"
->              , ScalarType "name"
->              )
->            , ( "tgconstrrelid"
->              , ScalarType "oid"
->              )
->            , ( "tgconstraint"
->              , ScalarType "oid"
->              )
->            , ( "tgdeferrable"
->              , ScalarType "bool"
->              )
->            , ( "tginitdeferred"
->              , ScalarType "bool"
->              )
->            , ( "tgnargs"
->              , ScalarType "int2"
->              )
->            , ( "tgattr"
->              , ScalarType "int2vector"
->              )
->            , ( "tgargs"
->              , ScalarType "bytea"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_ts_config"
->            [ ( "cfgname"
->              , ScalarType "name"
->              )
->            , ( "cfgnamespace"
->              , ScalarType "oid"
->              )
->            , ( "cfgowner"
->              , ScalarType "oid"
->              )
->            , ( "cfgparser"
->              , ScalarType "oid"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_ts_config_map"
->            [ ( "mapcfg"
->              , ScalarType "oid"
->              )
->            , ( "maptokentype"
->              , ScalarType "int4"
->              )
->            , ( "mapseqno"
->              , ScalarType "int4"
->              )
->            , ( "mapdict"
->              , ScalarType "oid"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_ts_dict"
->            [ ( "dictname"
->              , ScalarType "name"
->              )
->            , ( "dictnamespace"
->              , ScalarType "oid"
->              )
->            , ( "dictowner"
->              , ScalarType "oid"
->              )
->            , ( "dicttemplate"
->              , ScalarType "oid"
->              )
->            , ( "dictinitoption"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_ts_parser"
->            [ ( "prsname"
->              , ScalarType "name"
->              )
->            , ( "prsnamespace"
->              , ScalarType "oid"
->              )
->            , ( "prsstart"
->              , ScalarType "regproc"
->              )
->            , ( "prstoken"
->              , ScalarType "regproc"
->              )
->            , ( "prsend"
->              , ScalarType "regproc"
->              )
->            , ( "prsheadline"
->              , ScalarType "regproc"
->              )
->            , ( "prslextype"
->              , ScalarType "regproc"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_ts_template"
->            [ ( "tmplname"
->              , ScalarType "name"
->              )
->            , ( "tmplnamespace"
->              , ScalarType "oid"
->              )
->            , ( "tmplinit"
->              , ScalarType "regproc"
->              )
->            , ( "tmpllexize"
->              , ScalarType "regproc"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_type"
->            [ ( "typname"
->              , ScalarType "name"
->              )
->            , ( "typnamespace"
->              , ScalarType "oid"
->              )
->            , ( "typowner"
->              , ScalarType "oid"
->              )
->            , ( "typlen"
->              , ScalarType "int2"
->              )
->            , ( "typbyval"
->              , ScalarType "bool"
->              )
->            , ( "typtype"
->              , ScalarType "char"
->              )
->            , ( "typcategory"
->              , ScalarType "char"
->              )
->            , ( "typispreferred"
->              , ScalarType "bool"
->              )
->            , ( "typisdefined"
->              , ScalarType "bool"
->              )
->            , ( "typdelim"
->              , ScalarType "char"
->              )
->            , ( "typrelid"
->              , ScalarType "oid"
->              )
->            , ( "typelem"
->              , ScalarType "oid"
->              )
->            , ( "typarray"
->              , ScalarType "oid"
->              )
->            , ( "typinput"
->              , ScalarType "regproc"
->              )
->            , ( "typoutput"
->              , ScalarType "regproc"
->              )
->            , ( "typreceive"
->              , ScalarType "regproc"
->              )
->            , ( "typsend"
->              , ScalarType "regproc"
->              )
->            , ( "typmodin"
->              , ScalarType "regproc"
->              )
->            , ( "typmodout"
->              , ScalarType "regproc"
->              )
->            , ( "typanalyze"
->              , ScalarType "regproc"
->              )
->            , ( "typalign"
->              , ScalarType "char"
->              )
->            , ( "typstorage"
->              , ScalarType "char"
->              )
->            , ( "typnotnull"
->              , ScalarType "bool"
->              )
->            , ( "typbasetype"
->              , ScalarType "oid"
->              )
->            , ( "typtypmod"
->              , ScalarType "int4"
->              )
->            , ( "typndims"
->              , ScalarType "int4"
->              )
->            , ( "typdefaultbin"
->              , ScalarType "text"
->              )
->            , ( "typdefault"
->              , ScalarType "text"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "pg_user_mapping"
->            [ ( "umuser"
->              , ScalarType "oid"
->              )
->            , ( "umserver"
->              , ScalarType "oid"
->              )
->            , ( "umoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_features"
->            [ ( "feature_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "feature_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sub_feature_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sub_feature_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_supported"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_verified_by"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_implementation_info"
->            [ ( "implementation_info_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "implementation_info_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "integer_value"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_value"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_languages"
->            [ ( "sql_language_source"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_year"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_conformance"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_integrity"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_implementation"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_binding_style"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_language_programming_language"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_packages"
->            [ ( "feature_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "feature_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_supported"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_verified_by"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_parts"
->            [ ( "feature_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "feature_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_supported"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_verified_by"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_sizing"
->            [ ( "sizing_id"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "sizing_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "supported_value"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateTable
->            "information_schema.sql_sizing_profiles"
->            [ ( "sizing_id"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "sizing_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "profile_id"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "required_value"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "comments"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->            [ ( "tableoid"
->              , ScalarType "oid"
->              )
->            , ( "cmax"
->              , ScalarType "cid"
->              )
->            , ( "xmax"
->              , ScalarType "xid"
->              )
->            , ( "cmin"
->              , ScalarType "cid"
->              )
->            , ( "xmin"
->              , ScalarType "xid"
->              )
->            , ( "ctid"
->              , ScalarType "tid"
->              )
->            ]
->        , CatCreateView
->            "information_schema._pg_foreign_data_wrappers"
->            [ ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "fdwowner"
->              , ScalarType "oid"
->              )
->            , ( "fdwoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "foreign_data_wrapper_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_language"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema._pg_foreign_servers"
->            [ ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "srvoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "foreign_server_version"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema._pg_user_mappings"
->            [ ( "oid"
->              , ScalarType "oid"
->              )
->            , ( "umoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "umuser"
->              , ScalarType "oid"
->              )
->            , ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "srvowner"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.administrable_role_authorizations"
->            [ ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "role_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.applicable_roles"
->            [ ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "role_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.attributes"
->            [ ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "attribute_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "ordinal_position"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "attribute_default"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_nullable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "attribute_udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "attribute_udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "attribute_udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_derived_reference_attribute"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.check_constraint_routine_usage"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.check_constraints"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "check_clause"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.column_domain_usage"
->            [ ( "domain_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.column_privileges"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.column_udt_usage"
->            [ ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.columns"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "ordinal_position"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "column_default"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_nullable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_self_referencing"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_identity"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_generation"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_start"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_increment"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_maximum"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_minimum"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "identity_cycle"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_generated"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "generation_expression"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_updatable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.constraint_column_usage"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.constraint_table_usage"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.data_type_privileges"
->            [ ( "object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.domain_constraints"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_deferrable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "initially_deferred"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.domain_udt_usage"
->            [ ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.domains"
->            [ ( "domain_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "domain_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "domain_default"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.element_types"
->            [ ( "object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "collection_type_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "domain_default"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.enabled_roles"
->            [ ( "role_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.foreign_data_wrapper_options"
->            [ ( "foreign_data_wrapper_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_value"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.foreign_data_wrappers"
->            [ ( "foreign_data_wrapper_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "library_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "foreign_data_wrapper_language"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.foreign_server_options"
->            [ ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_value"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.foreign_servers"
->            [ ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_data_wrapper_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "foreign_server_version"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.information_schema_catalog_name"
->            [ ( "catalog_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.key_column_usage"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "ordinal_position"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "position_in_unique_constraint"
->              , DomainType "information_schema.cardinal_number"
->              )
->            ]
->        , CatCreateView
->            "information_schema.parameters"
->            [ ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "ordinal_position"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "parameter_mode"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_result"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "as_locator"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "parameter_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "pg_cursors"
->            [ ( "name"
->              , ScalarType "text"
->              )
->            , ( "statement"
->              , ScalarType "text"
->              )
->            , ( "is_holdable"
->              , ScalarType "bool"
->              )
->            , ( "is_binary"
->              , ScalarType "bool"
->              )
->            , ( "is_scrollable"
->              , ScalarType "bool"
->              )
->            , ( "creation_time"
->              , ScalarType "timestamptz"
->              )
->            ]
->        , CatCreateView
->            "pg_group"
->            [ ( "groname"
->              , ScalarType "name"
->              )
->            , ( "grosysid"
->              , ScalarType "oid"
->              )
->            , ( "grolist"
->              , ArrayType ( ScalarType "oid" )
->              )
->            ]
->        , CatCreateView
->            "pg_indexes"
->            [ ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "tablename"
->              , ScalarType "name"
->              )
->            , ( "indexname"
->              , ScalarType "name"
->              )
->            , ( "tablespace"
->              , ScalarType "name"
->              )
->            , ( "indexdef"
->              , ScalarType "text"
->              )
->            ]
->        , CatCreateView
->            "pg_locks"
->            [ ( "locktype"
->              , ScalarType "text"
->              )
->            , ( "database"
->              , ScalarType "oid"
->              )
->            , ( "relation"
->              , ScalarType "oid"
->              )
->            , ( "page"
->              , ScalarType "int4"
->              )
->            , ( "tuple"
->              , ScalarType "int2"
->              )
->            , ( "virtualxid"
->              , ScalarType "text"
->              )
->            , ( "transactionid"
->              , ScalarType "xid"
->              )
->            , ( "classid"
->              , ScalarType "oid"
->              )
->            , ( "objid"
->              , ScalarType "oid"
->              )
->            , ( "objsubid"
->              , ScalarType "int2"
->              )
->            , ( "virtualtransaction"
->              , ScalarType "text"
->              )
->            , ( "pid"
->              , ScalarType "int4"
->              )
->            , ( "mode"
->              , ScalarType "text"
->              )
->            , ( "granted"
->              , ScalarType "bool"
->              )
->            ]
->        , CatCreateView
->            "pg_prepared_statements"
->            [ ( "name"
->              , ScalarType "text"
->              )
->            , ( "statement"
->              , ScalarType "text"
->              )
->            , ( "prepare_time"
->              , ScalarType "timestamptz"
->              )
->            , ( "parameter_types"
->              , ArrayType ( ScalarType "regtype" )
->              )
->            , ( "from_sql"
->              , ScalarType "bool"
->              )
->            ]
->        , CatCreateView
->            "pg_prepared_xacts"
->            [ ( "transaction"
->              , ScalarType "xid"
->              )
->            , ( "gid"
->              , ScalarType "text"
->              )
->            , ( "prepared"
->              , ScalarType "timestamptz"
->              )
->            , ( "owner"
->              , ScalarType "name"
->              )
->            , ( "database"
->              , ScalarType "name"
->              )
->            ]
->        , CatCreateView
->            "pg_roles"
->            [ ( "rolname"
->              , ScalarType "name"
->              )
->            , ( "rolsuper"
->              , ScalarType "bool"
->              )
->            , ( "rolinherit"
->              , ScalarType "bool"
->              )
->            , ( "rolcreaterole"
->              , ScalarType "bool"
->              )
->            , ( "rolcreatedb"
->              , ScalarType "bool"
->              )
->            , ( "rolcatupdate"
->              , ScalarType "bool"
->              )
->            , ( "rolcanlogin"
->              , ScalarType "bool"
->              )
->            , ( "rolconnlimit"
->              , ScalarType "int4"
->              )
->            , ( "rolpassword"
->              , ScalarType "text"
->              )
->            , ( "rolvaliduntil"
->              , ScalarType "timestamptz"
->              )
->            , ( "rolconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "oid"
->              , ScalarType "oid"
->              )
->            ]
->        , CatCreateView
->            "pg_rules"
->            [ ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "tablename"
->              , ScalarType "name"
->              )
->            , ( "rulename"
->              , ScalarType "name"
->              )
->            , ( "definition"
->              , ScalarType "text"
->              )
->            ]
->        , CatCreateView
->            "pg_settings"
->            [ ( "name"
->              , ScalarType "text"
->              )
->            , ( "setting"
->              , ScalarType "text"
->              )
->            , ( "unit"
->              , ScalarType "text"
->              )
->            , ( "category"
->              , ScalarType "text"
->              )
->            , ( "short_desc"
->              , ScalarType "text"
->              )
->            , ( "extra_desc"
->              , ScalarType "text"
->              )
->            , ( "context"
->              , ScalarType "text"
->              )
->            , ( "vartype"
->              , ScalarType "text"
->              )
->            , ( "source"
->              , ScalarType "text"
->              )
->            , ( "min_val"
->              , ScalarType "text"
->              )
->            , ( "max_val"
->              , ScalarType "text"
->              )
->            , ( "enumvals"
->              , ArrayType ( ScalarType "text" )
->              )
->            , ( "boot_val"
->              , ScalarType "text"
->              )
->            , ( "reset_val"
->              , ScalarType "text"
->              )
->            , ( "sourcefile"
->              , ScalarType "text"
->              )
->            , ( "sourceline"
->              , ScalarType "int4"
->              )
->            ]
->        , CatCreateView
->            "pg_shadow"
->            [ ( "usename"
->              , ScalarType "name"
->              )
->            , ( "usesysid"
->              , ScalarType "oid"
->              )
->            , ( "usecreatedb"
->              , ScalarType "bool"
->              )
->            , ( "usesuper"
->              , ScalarType "bool"
->              )
->            , ( "usecatupd"
->              , ScalarType "bool"
->              )
->            , ( "passwd"
->              , ScalarType "text"
->              )
->            , ( "valuntil"
->              , ScalarType "abstime"
->              )
->            , ( "useconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->        , CatCreateView
->            "pg_stat_activity"
->            [ ( "datid"
->              , ScalarType "oid"
->              )
->            , ( "datname"
->              , ScalarType "name"
->              )
->            , ( "procpid"
->              , ScalarType "int4"
->              )
->            , ( "usesysid"
->              , ScalarType "oid"
->              )
->            , ( "usename"
->              , ScalarType "name"
->              )
->            , ( "current_query"
->              , ScalarType "text"
->              )
->            , ( "waiting"
->              , ScalarType "bool"
->              )
->            , ( "xact_start"
->              , ScalarType "timestamptz"
->              )
->            , ( "query_start"
->              , ScalarType "timestamptz"
->              )
->            , ( "backend_start"
->              , ScalarType "timestamptz"
->              )
->            , ( "client_addr"
->              , ScalarType "inet"
->              )
->            , ( "client_port"
->              , ScalarType "int4"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_all_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_all_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "seq_scan"
->              , ScalarType "int8"
->              )
->            , ( "seq_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_ins"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_del"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_hot_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_live_tup"
->              , ScalarType "int8"
->              )
->            , ( "n_dead_tup"
->              , ScalarType "int8"
->              )
->            , ( "last_vacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autovacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_analyze"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autoanalyze"
->              , ScalarType "timestamptz"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_bgwriter"
->            [ ( "checkpoints_timed"
->              , ScalarType "int8"
->              )
->            , ( "checkpoints_req"
->              , ScalarType "int8"
->              )
->            , ( "buffers_checkpoint"
->              , ScalarType "int8"
->              )
->            , ( "buffers_clean"
->              , ScalarType "int8"
->              )
->            , ( "maxwritten_clean"
->              , ScalarType "int8"
->              )
->            , ( "buffers_backend"
->              , ScalarType "int8"
->              )
->            , ( "buffers_alloc"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_database"
->            [ ( "datid"
->              , ScalarType "oid"
->              )
->            , ( "datname"
->              , ScalarType "name"
->              )
->            , ( "numbackends"
->              , ScalarType "int4"
->              )
->            , ( "xact_commit"
->              , ScalarType "int8"
->              )
->            , ( "xact_rollback"
->              , ScalarType "int8"
->              )
->            , ( "blks_read"
->              , ScalarType "int8"
->              )
->            , ( "blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "tup_returned"
->              , ScalarType "int8"
->              )
->            , ( "tup_fetched"
->              , ScalarType "int8"
->              )
->            , ( "tup_inserted"
->              , ScalarType "int8"
->              )
->            , ( "tup_updated"
->              , ScalarType "int8"
->              )
->            , ( "tup_deleted"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_sys_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_sys_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "seq_scan"
->              , ScalarType "int8"
->              )
->            , ( "seq_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_ins"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_del"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_hot_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_live_tup"
->              , ScalarType "int8"
->              )
->            , ( "n_dead_tup"
->              , ScalarType "int8"
->              )
->            , ( "last_vacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autovacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_analyze"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autoanalyze"
->              , ScalarType "timestamptz"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_user_functions"
->            [ ( "funcid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "funcname"
->              , ScalarType "name"
->              )
->            , ( "calls"
->              , ScalarType "int8"
->              )
->            , ( "total_time"
->              , ScalarType "int8"
->              )
->            , ( "self_time"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_user_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stat_user_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "seq_scan"
->              , ScalarType "int8"
->              )
->            , ( "seq_tup_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_scan"
->              , ScalarType "int8"
->              )
->            , ( "idx_tup_fetch"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_ins"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_del"
->              , ScalarType "int8"
->              )
->            , ( "n_tup_hot_upd"
->              , ScalarType "int8"
->              )
->            , ( "n_live_tup"
->              , ScalarType "int8"
->              )
->            , ( "n_dead_tup"
->              , ScalarType "int8"
->              )
->            , ( "last_vacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autovacuum"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_analyze"
->              , ScalarType "timestamptz"
->              )
->            , ( "last_autoanalyze"
->              , ScalarType "timestamptz"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_all_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_all_sequences"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "blks_read"
->              , ScalarType "int8"
->              )
->            , ( "blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_all_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "heap_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "heap_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_sys_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_sys_sequences"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "blks_read"
->              , ScalarType "int8"
->              )
->            , ( "blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_sys_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "heap_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "heap_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_user_indexes"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "indexrelid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "indexrelname"
->              , ScalarType "name"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_user_sequences"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "blks_read"
->              , ScalarType "int8"
->              )
->            , ( "blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_statio_user_tables"
->            [ ( "relid"
->              , ScalarType "oid"
->              )
->            , ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "relname"
->              , ScalarType "name"
->              )
->            , ( "heap_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "heap_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "idx_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "toast_blks_hit"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_read"
->              , ScalarType "int8"
->              )
->            , ( "tidx_blks_hit"
->              , ScalarType "int8"
->              )
->            ]
->        , CatCreateView
->            "pg_stats"
->            [ ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "tablename"
->              , ScalarType "name"
->              )
->            , ( "attname"
->              , ScalarType "name"
->              )
->            , ( "null_frac"
->              , ScalarType "float4"
->              )
->            , ( "avg_width"
->              , ScalarType "int4"
->              )
->            , ( "n_distinct"
->              , ScalarType "float4"
->              )
->            , ( "most_common_vals"
->              , Pseudo AnyArray
->              )
->            , ( "most_common_freqs"
->              , ArrayType ( ScalarType "float4" )
->              )
->            , ( "histogram_bounds"
->              , Pseudo AnyArray
->              )
->            , ( "correlation"
->              , ScalarType "float4"
->              )
->            ]
->        , CatCreateView
->            "pg_tables"
->            [ ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "tablename"
->              , ScalarType "name"
->              )
->            , ( "tableowner"
->              , ScalarType "name"
->              )
->            , ( "tablespace"
->              , ScalarType "name"
->              )
->            , ( "hasindexes"
->              , ScalarType "bool"
->              )
->            , ( "hasrules"
->              , ScalarType "bool"
->              )
->            , ( "hastriggers"
->              , ScalarType "bool"
->              )
->            ]
->        , CatCreateView
->            "pg_timezone_abbrevs"
->            [ ( "abbrev"
->              , ScalarType "text"
->              )
->            , ( "utc_offset"
->              , ScalarType "interval"
->              )
->            , ( "is_dst"
->              , ScalarType "bool"
->              )
->            ]
->        , CatCreateView
->            "pg_timezone_names"
->            [ ( "name"
->              , ScalarType "text"
->              )
->            , ( "abbrev"
->              , ScalarType "text"
->              )
->            , ( "utc_offset"
->              , ScalarType "interval"
->              )
->            , ( "is_dst"
->              , ScalarType "bool"
->              )
->            ]
->        , CatCreateView
->            "pg_user"
->            [ ( "usename"
->              , ScalarType "name"
->              )
->            , ( "usesysid"
->              , ScalarType "oid"
->              )
->            , ( "usecreatedb"
->              , ScalarType "bool"
->              )
->            , ( "usesuper"
->              , ScalarType "bool"
->              )
->            , ( "usecatupd"
->              , ScalarType "bool"
->              )
->            , ( "passwd"
->              , ScalarType "text"
->              )
->            , ( "valuntil"
->              , ScalarType "abstime"
->              )
->            , ( "useconfig"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->        , CatCreateView
->            "pg_user_mappings"
->            [ ( "umid"
->              , ScalarType "oid"
->              )
->            , ( "srvid"
->              , ScalarType "oid"
->              )
->            , ( "srvname"
->              , ScalarType "name"
->              )
->            , ( "umuser"
->              , ScalarType "oid"
->              )
->            , ( "usename"
->              , ScalarType "name"
->              )
->            , ( "umoptions"
->              , ArrayType ( ScalarType "text" )
->              )
->            ]
->        , CatCreateView
->            "pg_views"
->            [ ( "schemaname"
->              , ScalarType "name"
->              )
->            , ( "viewname"
->              , ScalarType "name"
->              )
->            , ( "viewowner"
->              , ScalarType "name"
->              )
->            , ( "definition"
->              , ScalarType "text"
->              )
->            ]
->        , CatCreateView
->            "information_schema.referential_constraints"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "unique_constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "unique_constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "unique_constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "match_option"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "update_rule"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "delete_rule"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.role_column_grants"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.role_routine_grants"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.role_table_grants"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "with_hierarchy"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.role_usage_grants"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.routine_privileges"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.routines"
->            [ ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "module_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "module_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "module_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "character_maximum_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "type_udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "type_udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "type_udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "routine_body"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "routine_definition"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "external_name"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "external_language"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "parameter_style"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_deterministic"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_data_access"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_null_call"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "sql_path"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "schema_level_routine"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "max_dynamic_result_sets"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "is_user_defined_cast"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_implicitly_invocable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "security_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "to_sql_specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "to_sql_specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "to_sql_specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "as_locator"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "created"
->              , DomainType "information_schema.time_stamp"
->              )
->            , ( "last_altered"
->              , DomainType "information_schema.time_stamp"
->              )
->            , ( "new_savepoint_level"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_udt_dependent"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "result_cast_from_data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "result_cast_as_locator"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "result_cast_char_max_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_char_octet_length"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_char_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_char_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_collation_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_collation_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_collation_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_datetime_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_interval_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "result_cast_interval_precision"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "result_cast_type_udt_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_type_udt_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_type_udt_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_scope_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_scope_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_scope_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "result_cast_maximum_cardinality"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "result_cast_dtd_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.schemata"
->            [ ( "catalog_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "schema_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "schema_owner"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "default_character_set_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "default_character_set_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "default_character_set_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "sql_path"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.sequences"
->            [ ( "sequence_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "sequence_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "sequence_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "data_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "numeric_precision"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_precision_radix"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "numeric_scale"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "maximum_value"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "minimum_value"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "increment"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "cycle_option"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.table_constraints"
->            [ ( "constraint_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "constraint_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_deferrable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "initially_deferred"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.table_privileges"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "with_hierarchy"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.tables"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "self_referencing_column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "reference_generation"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "user_defined_type_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "user_defined_type_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "user_defined_type_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "is_insertable_into"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_typed"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "commit_action"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.triggered_update_columns"
->            [ ( "trigger_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "trigger_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "trigger_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_table"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_column"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.triggers"
->            [ ( "trigger_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "trigger_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "trigger_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_manipulation"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "event_object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "event_object_table"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "action_order"
->              , DomainType "information_schema.cardinal_number"
->              )
->            , ( "action_condition"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "action_statement"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "action_orientation"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "condition_timing"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "condition_reference_old_table"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "condition_reference_new_table"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "condition_reference_old_row"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "condition_reference_new_row"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "created"
->              , DomainType "information_schema.time_stamp"
->              )
->            ]
->        , CatCreateView
->            "information_schema.usage_privileges"
->            [ ( "grantor"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "grantee"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "object_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "privilege_type"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_grantable"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.user_mapping_options"
->            [ ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "option_value"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        , CatCreateView
->            "information_schema.user_mappings"
->            [ ( "authorization_identifier"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "foreign_server_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.view_column_usage"
->            [ ( "view_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "view_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "view_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "column_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.view_routine_usage"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "specific_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.view_table_usage"
->            [ ( "view_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "view_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "view_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            ]
->        , CatCreateView
->            "information_schema.views"
->            [ ( "table_catalog"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_schema"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "table_name"
->              , DomainType "information_schema.sql_identifier"
->              )
->            , ( "view_definition"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "check_option"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_updatable"
->              , DomainType "information_schema.character_data"
->              )
->            , ( "is_insertable_into"
->              , DomainType "information_schema.character_data"
->              )
->            ]
->        ]
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/CreateFunction.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/CreateFunction.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/CreateFunction.ag
+++ /dev/null
@@ -1,135 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the ag code for create function statements. This
-includes producing the function prototype, and passing the parameter
-and variable declaration bindings into the statement body.
-
-== function prototype
-
-all we do here is type check enough to produce the prototype
-information which is added to the catalog, this means the function
-name, parameter types, and the return type.
-
-type checking failure is contained so that the function prototype is
-produced iff the parameter and return types check ok. Any type errors
-in the function body (including the top level variable declarations
-don't affect the prototype, and hence callers of the function).
-
--}
-
-SEM Statement
-    | CreateFunction
-        loc.tpe = dependsOnRTpe
-                    (@rettype.namedType : @loc.parameterTypes) $
-                    Right $ Pseudo Void
-        loc.catUpdates = dependsOn [tpeToT @loc.tpe] []
-                                   [CatCreateFunction FunName
-                                                      (map toLower @name)
-                                                      @loc.parameterTypes
-                                                      @rettype.namedType
-                                                      False]
-        loc.parameterTypes = (map snd @params.params)
-
-        loc.backTree = CreateFunction @ann
-                                      @name
-                                      @params.annotatedTree
-                                      @rettype.annotatedTree
-                                      @lang.annotatedTree
-                                      @bodyQuote
-                                      @body.annotatedTree
-                                      @vol.annotatedTree
-        loc.statementType = []
-        body.cat = @lhs.inProducedCat
-
-{-
-== parameters
--}
-
-ATTR ParamDef [||paramName : String
-                 namedType : Type]
-
-ATTR ParamDefList [||params : {[(String, Type)]}]
-
-SEM ParamDef
-    | ParamDef ParamDefTp
-        lhs.namedType = @typ.namedType
-    | ParamDef
-        lhs.paramName = @name
-    | ParamDefTp
-        lhs.paramName = ""
-
-SEM ParamDefList
-     | Nil lhs.params = []
-     | Cons lhs.params = ((@hd.paramName, @hd.namedType) : @tl.params)
-
-
-{-
-ISSUE:
-
-when writing an sql file, you can put a create function which refers
-to a table definition that is given later. As long as the function
-isn't called before the table definition is given, this is ok. To
-handle this, need to gather the function prototype, but delay checking
-the contents until either a) all the other type checking has been
-done, or b) the function is needed (list ways this can happen: used in
-a view (even then, not needed until view is used), function can be
-called directly, or indirectly in another function call, ...)
-
-No thoughts on how to do this - but at some point want to support
-'declarative' sql source code, where the order doesn't matter, and
-this code figures out an order to load it into the database which will
-get past pgs checks, so hopefully the solution will move towards this
-goal also. One additional consideration is that the error message in a
-situation like this would be really helpful if it could tell that a
-problem like this could be fixed with a reordering, and suggest that
-reordering.
-
-New plan: do two passes, type check everything but the bodies of
-functions in first pass, then type check bodies of functions in second
-pass. Not perfect, but better than current situation. This will be
-achieved by using a separate cat attribute which is the same as the cat
-value which gets returned from the annotation functions in AstInternal.ag
-
--}
-
-SEM Statement
-    | CreateFunction
-        --add the parameters to the catalog for the contained statements
-        body.lib = let p = @params.params
-                           ++ (zip posNames $ map snd @params.params)
-                   in fromRight @lhs.lib $
-                      updateBindings @lhs.lib @lhs.cat
-                                     [LibStackIDs [("", p)
-                                                  ,(@name, @params.params)]]
-                   where
-                     posNames :: [String]
-                     posNames = map (\l -> '$':show l) [1..]
-{-
-TODO: using fromRight on it's own for identifier bindings or cat
-updates is wrong, if an error is produced then this needs to be added
-to an annotation somewhere. Some of the code uses error instead of fromRight
-which is even worse.
--}
-
-SEM FnBody
-    | PlpgsqlFnBody
-        --make the variable names available in the body of the
-        --function this needs to be generalised to begin/end blocks
-        --which can nest inside plpgsql functions (they aren't even
-        --supported by the parser at the moment)
-        sts.lib = fromRight @lhs.lib $
-                  updateBindings @lhs.lib @lhs.cat
-                                 [LibStackIDs [("", @vars.defs)]]
-
-ATTR VarDef [||def : {(String,Type)}]
-
-ATTR VarDefList [||defs : {[(String,Type)]}]
-
---slightly hacky, should fix this better
-SEM VarDef
-    | VarDef lhs.def = (@name, if @typ.namedType == Pseudo Record then PgRecord Nothing else @typ.namedType)
-
-SEM VarDefList
-    | Cons lhs.defs = @hd.def : @tl.defs
-    | Nil lhs.defs = []
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/CreateTable.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/CreateTable.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/CreateTable.ag
+++ /dev/null
@@ -1,101 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the code for typechecking create table statements
-(and also create table as statements). It's pretty limited at the
-moment, the bits that work are:
-
-gathers enough information to add the table attributes types to the
-catalog
-
-typechecks row check constraints properly, but table check constraints
-and all other constraints are not checked at all.
-
-doesn't check for duplicate attribute names. doesn't check if the
-types are valid for a table (e.g. disallow setof types)
-
-We produce a valid catalog update if the types of the attributes
-check ok, any errors in the constraints aren't leaked.
-
--}
-
-
-SEM Statement
-    | CreateTable
-        loc.tpe = dependsOnRTpe @loc.attrTypes $ Right $ Pseudo Void
-        loc.catUpdates = dependsOn @loc.attrTypes []
-                           [CatCreateTable @name @atts.attrs defaultSystemColumns]
-        loc.attrTypes : {[Type]}
-        loc.attrTypes = map snd @atts.attrs
-
-        loc.statementType = []
-        loc.backTree = CreateTable @ann
-                                   @name
-                                   @atts.annotatedTree
-                                   @cons.annotatedTree
-        cons.lib = case updateBindings @lhs.lib @lhs.cat
-                     [LibStackIDs [("", @atts.attrs)]] of
-                      Left x -> error $ show x
-                      Right e -> e
-{
-defaultSystemColumns :: [(String,Type)]
-defaultSystemColumns = [("tableoid", ScalarType "oid")
-                       ,("cmax", ScalarType "cid")
-                       ,("xmax", ScalarType "xid")
-                       ,("cmin", ScalarType "cid")
-                       ,("xmin", ScalarType "xid")
-                       ,("ctid", ScalarType "tid")]
-}
-
-
-SEM Statement
-    | CreateTableAs
-        loc.tpe =
-            dependsOnRTpe [@loc.selType] $ do
-              @loc.attrs
-              Right @loc.selType
-        loc.catUpdates =
-           leftToEmpty (\as -> [CatCreateTable @name as defaultSystemColumns]) $ do
-              ats <- @loc.attrs
-              return $ dependsOn (tpeToT @loc.tpe :
-                                  (map snd ats)) [] ats
-
-        loc.selType = getTypeAnnotation @expr.annotatedTree
-        -- type of the columns in the select expression
-        loc.attrs = unwrapSetOfComposite @loc.selType
-
-        loc.backTree = CreateTableAs @ann @name @expr.annotatedTree
-        loc.statementType = []
-
-{-
-attribute name and type gathering
--}
-
-ATTR AttributeDef [||attrName : String
-                     namedType : Type]
-
-SEM AttributeDef
-    | AttributeDef
-        lhs.attrName = map toLower @name
-        lhs.namedType = @typ.namedType
-
-ATTR AttributeDefList [||attrs : {[(String, Type)]}]
-
-SEM AttributeDefList
-    | Cons lhs.attrs = (@hd.attrName, @hd.namedType) : @tl.attrs
-    | Nil lhs.attrs = []
-
-{-
-row check constraint:
-inject the column name and type into the column constraints
--}
-
-SEM AttributeDef
-    | AttributeDef
-        cons.lib =
-            case updateBindings @lhs.lib @lhs.cat
-                     [LibStackIDs [("", [(@name, @typ.namedType)])]] of
-              Left x -> error $ show x
-              Right e -> e
-
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Dml.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Dml.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Dml.ag
+++ /dev/null
@@ -1,236 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the type checking code for dml, currently insert,
-update and delete.
-
-================================================================================
-
-= insert
-
-check the insert data is the correct type. Doesn't cope with columns
-with default values at the moment.
-
--}
-
-SEM Statement
-    | Insert
-        loc.tpe =
-            dependsOnRTpe [getTypeAnnotation @insData.annotatedTree] $ do
-              @loc.columnTypes
-              Right $ Pseudo Void
-        loc.statementType =
-            leftToEmpty (\ct -> [StatementType (getPlaceholderTypes @loc.insDataAddedInferredTypes) (fromMaybe [] @returning.listType)]) @loc.columnTypes
-
-        loc.columnTypes =
-            do
-            tys <- unwrapSetOfComposite $
-                   getTypeAnnotation @insData.annotatedTree
-            checkColumnConsistency @lhs.cat
-                                   @table
-                                   @targetCols.strings
-                                   tys
-        loc.insDataAddedInferredTypes =
-            case @insData.annotatedTree of
-              Values ann [exl] ->
-                  let fargs = map snd (fromRight [] @loc.columnTypes) ++ repeat TypeCheckFailed
-                      newExl = map (\(ex,ty) -> updateAnnotation (++ [InferredType ty]) ex) $ zip exl fargs
-                  in Values ann [newExl]
-              x -> x
-
-        loc.backTree = Insert @ann @table @targetCols.annotatedTree
-                              @loc.insDataAddedInferredTypes @returning.annotatedTree
-        loc.catUpdates = []
-
--- inject the ids into the returning part
-
-SEM Statement
-    | Insert
-        returning.lib =
-            fromRight @lhs.lib $ do
-              atts <- catCompositeAttrs @lhs.cat relationComposites @table
-              updateBindings @lhs.lib @lhs.cat [LibStackIDs [("", atts)]]
-
-{-
-================================================================================
-
-= update
-
-check the set clause assignments are ok, and inject ids into the where part
-
--}
-
-SEM Statement
-    | Update
-        loc.tpe =
-            do
-            checkRelationExists @lhs.cat @table
-            dependsOnRTpe (map snd @assigns.pairs) $ do
-              @loc.columnTypes
-              liftErrors @assigns.rowSetErrors
-              return $ Pseudo Void
-        loc.statementType =
-            leftToEmpty (\ct -> [StatementType (getPlaceholderTypes @loc.assignWInferredTypes
-                                                ++ getPlaceholderTypes @whr.annotatedTree)
-                                               (fromMaybe [] @returning.listType)])
-               @loc.columnTypes
-
-        loc.columnTypes =
-            checkColumnConsistency @lhs.cat
-                                   @table
-                                   (map fst @assigns.pairs)
-                                   @assigns.pairs
-        loc.assignWInferredTypes : SetClauseList
-        loc.assignWInferredTypes =
-            let colTypes :: [Type]
-                colTypes = (map snd $ fromRight [] @loc.columnTypes)
-            in setInferredTypesG colTypes @assigns.annotatedTree
-
-        loc.backTree = Update @ann
-                              @table
-                              @loc.assignWInferredTypes
-                              @whr.annotatedTree
-                              @returning.annotatedTree
-        loc.catUpdates = []
-
-{
-
-setInferredTypesG :: Data a => [Type] -> a -> a
-setInferredTypesG tys x =
-  evalState (transformBiM f x) tys
-  where
-    f (p@(Placeholder _)) = do
-         y:ys <- get
-         put ys
-         return $ updateAnnotation (++ [InferredType y]) p
-    f z = return z
-}
-
--- local identifier bindings: pass the table attribute names and types
--- into the where expression, and the set clause expressions
-
-SEM Statement
-    | Update
-        loc.lib =
-             fromRight @lhs.lib $ do
-             ct <- catCompositeAttrs @lhs.cat
-                                     relationComposites
-                                     @table
-             updateBindings @lhs.lib @lhs.cat [LibStackIDs [("", ct)]]
-        whr.lib = @loc.lib
-        assigns.lib = @loc.lib
-        returning.lib = @loc.lib
-
-{-
-== set clauses
-
-small complication is slightly hacky code to deal with row set
-assignments, where we assign from a multiple attribute subselect into
-multiple columns - todo: check if we need so much special casing for
-this: should be able to reuse the funcall typing of row set equality
-(trade one hack for another, squinting so that assignment looks like
-an equality check - since it type checks the same we might be ok). If
-we do this, we only need to expand the row sets out to produce a
-single string,type list at the end.
-
--}
-
-ATTR SetClauseList [||pairs : {[(String,Type)]}
-                      rowSetErrors : {[TypeError]}]
-
-SEM SetClauseList
-  | Cons lhs.pairs = @hd.pairs ++ @tl.pairs
-         lhs.rowSetErrors = maybeToList @hd.rowSetError ++ @tl.rowSetErrors
-  | Nil lhs.pairs = []
-        lhs.rowSetErrors = []
-
-ATTR SetClause [||pairs : {[(String,Type)]}
-                  rowSetError : {Maybe TypeError}]
-
-SEM SetClause
-    | SetClause
-        lhs.pairs = [(@att, getTypeAnnotation @val.annotatedTree)]
-        lhs.rowSetError = Nothing
-    | RowSetClause
-        loc.rowSetError =
-          let atts = @atts.strings
-              types = getRowTypes @vals.typeList
-          in if length atts /= length types
-               then Just WrongNumberOfColumns
-               else Nothing
-        lhs.pairs = zip @atts.strings $ getRowTypes @vals.typeList
-
-{
-getRowTypes :: [Type] -> [Type]
-getRowTypes [AnonymousRecordType ts] = ts
-getRowTypes ts = ts
-}
-
-{-
-================================================================================
-
-= delete
-
-pretty simple, mainly just need to inject ids into the where part
-
--}
-
-SEM Statement
-    | Delete
-        loc.tpe =
-            checkRelationExists @lhs.cat @table >>
-            Right (Pseudo Void)
-        loc.statementType = [StatementType (getPlaceholderTypes @whr.annotatedTree)
-                                           (fromMaybe [] @returning.listType)]
-
-        loc.backTree = Delete @ann @table @whr.annotatedTree @returning.annotatedTree
-        loc.catUpdates = []
-
-
-SEM Statement
-    | Delete
-        loc.lib =
-            fromRight @lhs.lib $ do
-            columnTypes <- catCompositeAttrs @lhs.cat relationComposites @table
-            updateBindings @lhs.lib @lhs.cat [LibStackIDs [("", columnTypes)]]
-        whr.lib = @loc.lib
-        returning.lib = @loc.lib
-
-{-
-================================================================================
--}
-{
-
---small shortcut to help produce better errors?
-checkRelationExists :: Catalog -> String -> Either [TypeError] ()
-checkRelationExists cat tbl =
-    catCompositeDef cat relationComposites tbl >>
-    return ()
-
---used by both insert and update
-checkColumnConsistency :: Catalog ->  String -> [String] -> [(String,Type)]
-                       -> Either [TypeError] [(String,Type)]
-checkColumnConsistency cat tbl cols' insNameTypePairs = do
-  ttcols <- lowerize <$> catCompositePublicAttrs cat [] tbl
-  let cols = if null cols'
-               then map fst ttcols
-               else map (map toLower) cols'
-  errorWhen (length insNameTypePairs /= length cols) [WrongNumberOfColumns]
-  let nonMatchingColumns = cols \\ map fst ttcols
-  errorWhen (not $ null nonMatchingColumns) $
-       map UnrecognisedIdentifier nonMatchingColumns
-  let targetNameTypePairs = map (\l -> (l,fromJust $ lookup l ttcols)) cols
-        --check the types of the insdata match the column targets
-        --name datatype columntype
-      typeTriples = map (\((a,b),c) -> (a,b,c)) $
-                    zip targetNameTypePairs $
-                    map snd insNameTypePairs
-      errs :: [TypeError]
-      errs = concat $ lefts $
-             map (\(_,b,c) -> checkAssignmentValid cat c b) typeTriples
-  liftErrors errs
-  return targetNameTypePairs
-  where
-    lowerize = map (\(a,b) -> (map toLower a,b))
-
-}
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Drops.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Drops.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Drops.ag
+++ /dev/null
@@ -1,31 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the code for drop statements, only does drop function at the moment
-
--}
-
-SEM Statement
-    | DropFunction
-        loc.tpe = Right $ Pseudo Void
-        loc.backTree = DropFunction @ann @ifE.annotatedTree @sigs.annotatedTree @cascade.annotatedTree
-        loc.catUpdates = flip map @sigs.fnSigs $ \(nm,args) ->
-                               CatDropFunction ifE nm args
-                         where
-                           ifE = @ifE.annotatedTree == IfExists
-        loc.statementType = []
-
-ATTR StringTypeNameListPairList [||fnSigs:{[(String,[Type])]}]
-SEM StringTypeNameListPairList
-    | Cons lhs.fnSigs = @hd.fnSig : @tl.fnSigs
-    | Nil lhs.fnSigs = []
-
-ATTR StringTypeNameListPair [||fnSig:{(String,[Type])}]
-SEM StringTypeNameListPair
-    | Tuple lhs.fnSig = (@x1, @x2.namedTypes)
-
-ATTR TypeNameList [||namedTypes:{[Type]}]
-
-SEM TypeNameList
-    | Cons lhs.namedTypes = @hd.namedType : @tl.namedTypes
-    | Nil lhs.namedTypes = []
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs b/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs
+++ /dev/null
@@ -1,57 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains a bunch of small low level utilities to help with
-type checking.
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
->     (
->      dependsOn
->     ,dependsOnRTpe
->     ,dependsOnT
->     ,tpeToT
->     ,liftErrors
->     ,getErrors
->     ) where
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-
-================================================================================
-
-= type checking utils
-
-== checkErrors
-
-if we find a typecheckfailed in the list, then propagate that, else
-use the final argument.
-
-> dependsOn :: [Type] -> t -> t -> t
-> dependsOn ts bad ok =
->   if any (==TypeCheckFailed) ts
->     then bad
->     else ok
-
-> dependsOnRTpe :: [Type] -> Either a Type -> Either a Type
-> dependsOnRTpe ts = dependsOn ts (Right TypeCheckFailed)
-
-> dependsOnT :: [Type] -> Type -> Type
-> dependsOnT ts = dependsOn ts TypeCheckFailed
-
-convert an 'either [typeerror] type' to a type
-
-> tpeToT :: Either [TypeError] Type -> Type
-> tpeToT tpe = case tpe of
->                   Left _ -> TypeCheckFailed
->                   Right t -> t
-
-> liftErrors :: [TypeError] -> Either [TypeError] ()
-> liftErrors es = if null es
->                   then Right ()
->                   else Left es
-
-extract errors from an either, gives empty list if right
-
-> getErrors :: Either [TypeError] Type -> [TypeError]
-> getErrors = either id (const [])
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Expressions.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Expressions.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Expressions.ag
+++ /dev/null
@@ -1,342 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the type checking code for the expression ast data
-type.
-
--}
-
---gather the backtree, type errors and types together and add annotations
-SEM Expression
-    | IntegerLit StringLit FloatLit BooleanLit NullLit FunCall Identifier
-      Exists Case CaseSimple Cast InPredicate ScalarSubQuery LiftOperator
-      PositionalArg Placeholder WindowFn
-        lhs.annotatedTree = annTypesAndErrors @loc.backTree
-                              (tpeToT @loc.tpe)
-                              (getErrors @loc.tpe)
-                              $ fmap ((:[]) . FunctionPrototypeA) @loc.prototype
-
-SEM Expression
-    | IntegerLit StringLit FloatLit BooleanLit NullLit FunCall Identifier
-      Exists Case CaseSimple Cast InPredicate ScalarSubQuery LiftOperator
-      PositionalArg Placeholder WindowFn
-        loc.prototype : {Maybe FunctionPrototype}
-
-SEM Expression
-    | IntegerLit StringLit FloatLit BooleanLit NullLit Identifier
-      Exists Case CaseSimple Cast InPredicate ScalarSubQuery LiftOperator
-      PositionalArg Placeholder WindowFn
-        loc.prototype = Nothing
-
-{-
-== literals
-
-pretty straightforward
--}
-
-SEM Expression
-     | IntegerLit loc.tpe = Right typeInt
-     | StringLit loc.tpe = Right UnknownType
-     | FloatLit loc.tpe = Right typeNumeric
-     | BooleanLit loc.tpe = Right typeBool
-     -- I think a null has the same type resolution as an unknown string lit
-     | NullLit loc.tpe = Right UnknownType
-
-SEM Expression
-    | IntegerLit
-        loc.backTree = IntegerLit @ann @i
-    | StringLit
-        loc.backTree = StringLit @ann @quote @value
-    | FloatLit
-        loc.backTree = FloatLit @ann @d
-    | BooleanLit
-        loc.backTree = BooleanLit @ann @b
-    | NullLit
-        loc.backTree = NullLit @ann
-
-
-{-
-
-== cast expression
-
-all the work is done in the typename node
--}
-
-SEM Expression
-    | Cast loc.tpe = Right $ @tn.namedType
-           loc.backTree = Cast @ann @expr.annotatedTree @tn.annotatedTree
-
-{-
-== operators and functions
--}
-SEM Expression
-    | FunCall
-        (loc.tpe, loc.prototype) = if any (==TypeCheckFailed) @args.typeList
-                                   then (Right TypeCheckFailed, Nothing)
-                                   else
-                                     let fe = typeCheckFunCall
-                                              @lhs.cat
-                                              @funName
-                                              @args.typeList
-                                     in (dependsOnRTpe @args.typeList $ fmap (\(_,_,r,_) -> r) fe
-                                        ,eitherToMaybe fe)
-        loc.backTree = FunCall @ann @funName @args.annotatedTree
-
-
-   | WindowFn
-        loc.tpe = Right (getTypeAnnotation @fn.annotatedTree)
-        loc.backTree = WindowFn @ann
-                                @fn.annotatedTree
-                                @partitionBy.annotatedTree
-                                @orderBy.annotatedTree
-                                @dir.annotatedTree
-                                @frm.annotatedTree
-{
-{-
-
-small shim in front of findCallMatch in the type conversion code, to
-handle some special cases.
-
-Some of the special cases will no longer be needed when variadic
-support is added.
-
-between, greatest and least are treated as syntactic sugar so we
-delegate the function lookups to the <=/>= operators.
-
-the row comparison should be more general than this, since it supports
-any operator satisfying some properties
-
-
-TODO: move all of this into find call match. Don't know why it's separate
--}
-typeCheckFunCall :: Catalog -> String -> [Type] -> Either [TypeError] FunctionPrototype
-typeCheckFunCall cat fnName' argsType =
-    {-trace ("typecheckfncall " ++ fnName' ++ show argsType) $-}
-    --dependsOnRTpe argsType $
-      case fnName of
-              "count" -> -- not quite sure how this is suppose to work,
-                         -- the counts in the pg catalog accept either
-                         -- no args, or one arg of type any, but you can call
-                         -- count with multiple arguments?
-                         return ("count", argsType, typeBigInt, False)
-              "!between" -> do
-                    f1 <- lookupReturnType ">=" [argsType !! 0, argsType !! 1]
-                    f2 <- lookupReturnType "<=" [argsType !! 0, argsType !! 2]
-                    lookupFn "!and" [f1,f2]
-              "greatest" -> do
-                    fp@(_,_,t,_) <- lookupFn fnName argsType
-                    lookupFn ">=" [t,t]
-                    return fp
-              "least" -> do
-                    fp@(_,_,t,_) <- lookupFn fnName argsType
-                    lookupFn "<=" [t,t]
-                    return fp
-              "!rowctor" -> return $ ("!rowCtor", argsType, AnonymousRecordType argsType, False)
-                    -- special case the row comparison ops
-                    -- this needs to be fixed: we want to match
-                    -- any implicit casts to functions on composite types
-                    -- first, then we can use the anonymous record type on
-                    -- any composite
-              _ | fnName `elem` ["=", "<>", "<=", ">=", "<", ">"]
-                         && length argsType == 2
-                         && all isCompositeOrSetOfCompositeType argsType
-                         && compositesCompatible cat (head argsType) (head $ tail argsType) -> return (fnName, argsType, typeBool, False)
-              --checked for all special cases, so run general case now
-              s -> lookupFn s argsType
-    where
-      lookupReturnType :: String -> [Type] -> Either [TypeError] Type
-      lookupReturnType s1 args = fmap (\(_,_,r,_) -> r) $ lookupFn s1 args
-      lookupFn :: String -> [Type] -> Either [TypeError] FunctionPrototype
-      lookupFn s1 args = findCallMatch cat
-                             (if s1 == "u-" then "-" else s1) args
-      fnName = map toLower fnName'
-}
-
-{-
-lifted operator:
-pretty much the same as haskell 'any (lhs [op]) rhss' (or all instead of any)
-where lhs is the first argument and rhss is the second argument
-which must be an array
-
-pg allows the rhss to also be a subselect, this is a todo
-
--}
-
-SEM Expression
-    | LiftOperator
-        loc.tpe = dependsOnRTpe @args.typeList $ do
-                  let args = @args.annotatedTree
-                  errorWhen (length args /= 2)
-                            [AnyAllError $ "must have two args, got " ++ show args]
-                  let [a,b] = args
-                      aType = getTypeAnnotation a
-                      bType = getTypeAnnotation b
-                  dependsOnRTpe [aType,bType] $ do
-                  errorWhen (not $ isArrayType bType)
-                            [AnyAllError $ "second arg must be array, got " ++ show args]
-                  elemType <- unwrapArray $ bType
-                  resType <- fmap (\(_,_,r,_) -> r) $ typeCheckFunCall
-                                     @lhs.cat
-                                     @oper
-                                     [aType,elemType]
-                  errorWhen (resType /= typeBool)
-                            [AnyAllError $ "operator must have bool return, got " ++ show resType]
-                  return resType
-        loc.backTree = LiftOperator @ann @oper @flav.annotatedTree @args.annotatedTree
-
-
-{-
-== case expression
-
-for non simple cases, we need all the when expressions to be bool, and
-then to collect the types of the then parts to see if we can resolve a
-common type
-
-for simple cases, we need to check all the when parts have the same type
-as the value to check against, then we collect the then parts as above.
-
--}
-
-SEM Expression
-    | Case CaseSimple
-        loc.whenTypes = map getTypeAnnotation $ concatMap fst $
-                        @cases.annotatedTree
-        loc.thenTypes = map getTypeAnnotation $
-                            (map snd $ @cases.annotatedTree) ++
-                              maybeToList @els.annotatedTree
-
-SEM Expression
-    | Case
-        loc.tpe =
-            dependsOnRTpe @loc.whenTypes $ do
-            errorWhen (any (/= typeBool) @loc.whenTypes) $
-                      [WrongTypes typeBool @loc.whenTypes]
-            dependsOnRTpe @loc.thenTypes $
-              resolveResultSetType @lhs.cat @loc.thenTypes
-        loc.backTree = Case @ann @cases.annotatedTree @els.annotatedTree
-
-
-SEM Expression
-    | CaseSimple
-        loc.tpe =
-          dependsOnRTpe @loc.whenTypes $ do
-          let valueType = getTypeAnnotation @value.annotatedTree
-          checkWhenTypes <-
-              resolveResultSetType @lhs.cat (valueType : @loc.whenTypes)
-          dependsOnRTpe @loc.thenTypes $
-            resolveResultSetType @lhs.cat @loc.thenTypes
-        loc.backTree = CaseSimple @ann
-                                  @value.annotatedTree
-                                  @cases.annotatedTree
-                                  @els.annotatedTree
-
-{-
-== identifiers
-pull id types out of cat for identifiers
-
--}
-
-SEM Expression
-    | Identifier
-        loc.tpe = libLookupID @lhs.lib @i
-        loc.backTree = Identifier @ann @i
-
-
-SEM Expression
-    | PositionalArg
-        loc.tpe = libLookupID @lhs.lib ('$':show @p)
-        loc.backTree = PositionalArg @ann @p
-
-
-SEM Expression
-    | Placeholder
-        loc.tpe = Right UnknownType
-        loc.backTree = Placeholder @ann
-
--- exists: will work on any subselect so we don't need to do any checking
-SEM Expression
-    | Exists
-        loc.tpe = Right typeBool
-        loc.backTree = Exists @ann @sel.annotatedTree
-
-
-{-
-== scalar subquery
-1 col -> type of that col
-2 + cols -> row type
--}
-
-SEM Expression
-    | ScalarSubQuery
-        loc.tpe =
-            do
-            let selType = getTypeAnnotation @sel.annotatedTree
-            dependsOnRTpe [selType] $ do
-            f <- map snd <$> unwrapSetOfComposite selType
-            case length f of
-              0 -> Left [InternalError "no columns in scalar subquery?"]
-              1 -> Right $ head f
-              _ -> Right $ AnonymousRecordType f
-
-        loc.backTree = ScalarSubQuery @ann @sel.annotatedTree
-{-
-== inlist
-todo: make the ast and typechecking a special case of lifted operator
--}
-
-SEM Expression
-    | InPredicate
-        loc.tpe = do
-                  lt <- @list.listType
-                  ty <- resolveResultSetType
-                            @lhs.cat
-                            [getTypeAnnotation @expr.annotatedTree, lt]
-                  return typeBool
-        loc.backTree = InPredicate @ann
-                                   @expr.annotatedTree
-                                   @i
-                                   @list.annotatedTree
-
-
-ATTR InList [||listType : {Either [TypeError] Type}]
-
-SEM InList
-    | InList
-        lhs.listType = resolveResultSetType @lhs.cat @exprs.typeList
-    | InSelect
-        lhs.listType =
-            do
-            attrs <- map snd <$> (unwrapSetOfComposite $
-                                  getTypeAnnotation @sel.annotatedTree)
-            typ <- case length attrs of
-                      0 -> Left [InternalError
-                                 "got subquery with no columns? in inselect"]
-                      1 -> Right $ head attrs
-                      _ -> Right $ AnonymousRecordType attrs
-            dependsOnRTpe attrs $ Right typ
-{-
-================================================================================
-
-dodgy type inference for parameterized statements
-
-start with ? in function calls only
-
-the idea is to assume the type is unknown, save the matched function prototype,
-then set an inferred type attribute back down into the ? node,
-then convert this to an annotation
-
-the matched function prototype gets saved in Expression.loc.protoType
-above when resolving the matching function
-
-won't work: the function prototype lookup uses the annotation on the
-argument nodes, and this will make the annotation dependent on already
-having the function prototype.
-
--}
-
--- ATTR Expression [inferredType:Type||]
--- ATTR ExpressionList [inferredTypes:{[Type]}||]
-
--- SEM Expression
---    | FunCall
---        args.inferredTypes = let t = 
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs b/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs
+++ /dev/null
@@ -1,120 +0,0 @@
-Copyright 2010 Jake Wheat
-
-This module contains the code to manage local identifier bindings
-during the type checking process. This is used for e.g. looking up the
-types of parameter and variable references in plpgsql functions, and
-for looking up the types of identifiers in select expressions.
-
-Some notes on lookups
-all lookups are case insensitive - todo: change correlation names and
-ids to lower case in the lbupdate function
-start by searching the head of the lookup update list and working down
-the code here handles resolving the types of join columns when they
-are not the same, and the update routine returns error if the join columns are not compatible
-the code here handles expanding record types so that the components can be looked up
-
-
-
-
-> {-# OPTIONS_HADDOCK hide  #-}
-
-> module Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
->     (
->      LocalBindingsUpdate(..)
->     ,LocalBindings
->     ,emptyBindings
->     ,lbUpdate
->     ,lbExpandStar
->     ,lbLookupID
->     ) where
-
-> import Control.Monad
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-> --import Database.HsSqlPpp.Utils
-> --import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-
-> data LocalBindings = LocalBindings [LocalBindingsUpdate]
-
-> emptyBindings :: LocalBindings
-> emptyBindings = LocalBindings []
-
-> data LocalBindingsUpdate = LBQualifiedIds {
->                              source :: String
->                             ,correlationName :: String
->                             ,lbids :: [(String,Type)]
->                             ,internalIds :: [(String,Type)]
->                             }
->                          | LBUnqualifiedIds {
->                              source :: String
->                             ,lbids :: [(String,Type)]
->                             ,internalIds :: [(String,Type)]
->                             }
->                          | LBJoinIds {
->                              source1 :: String
->                             ,correlationName1 :: String
->                             ,lbids1 :: [(String,Type)]
->                             ,internalIds1 :: [(String,Type)]
->                             ,source2 :: String
->                             ,correlationName2 :: String
->                             ,lbids2 :: [(String,Type)]
->                             ,internalIds2 :: [(String,Type)]
->                             ,joinIds :: [String]
->                             }
-
-> lbUpdate :: LocalBindingsUpdate -> LocalBindings -> LocalBindings
-> lbUpdate lbu (LocalBindings lb) = LocalBindings (lbu : lb)
-
-> lbExpandStar :: LocalBindings
->              -> String -- correlation name
->              -> Either [TypeError] [(String,String,String,Type)] -- either error or [source,(corr,name,type)]
-> lbExpandStar (LocalBindings l) cor =
->   es l
->   where
->     es :: [LocalBindingsUpdate] -> Either [TypeError] [(String,String,String,Type)]
->     es (LBQualifiedIds src cor1 ids _ :lbus) = if cor == cor1 || cor == ""
->                                                then mapEm src cor1 ids
->                                                else es lbus
->     es (LBUnqualifiedIds src ids _ : lbus) = if cor == ""
->                                              then mapEm src "" ids
->                                              else es lbus
->     es (LBJoinIds _ _ _ _ _ _ _ _ _ :lbus) = undefined
->     es [] = Left [UnrecognisedCorrelationName cor]
->     mapEm :: String -> String -> [(String,Type)] -> Either [TypeError] [(String,String,String,Type)]
->     mapEm src c = Right . map (\(a,b) -> (src,c,a,b))
-
-> lbLookupID :: LocalBindings
->            -> String -- correlation name
->            -> String -- identifier name
->            -> Either [TypeError] (String,String,String,Type) -- type error or source, corr, type
-> lbLookupID (LocalBindings lb) cor i =
->   lk lb
->   where
->     lk (lbu:lbus) = case findID cor i lbu of
->                                           Nothing -> lk lbus
->                                           Just t -> t
->     lk [] = Left [UnrecognisedIdentifier (if cor == "" then i else cor ++ "." ++ i)]
-
-> findID :: String
->        -> String
->        -> LocalBindingsUpdate
->        -> Maybe (Either [TypeError] (String,String,String,Type))
-> findID cor i (LBQualifiedIds src cor1 ids intIds) =
->     if cor `elem` ["", cor1]
->     then case (msum [lookup i ids
->                     ,lookup i intIds]) of
->            Just ty -> Just $ Right (src,cor1,i,ty)
->            Nothing -> if cor == ""
->                       then Nothing
->                       else Just $ Left [UnrecognisedIdentifier (if cor == "" then i else cor ++ "." ++ i)]
->     else Nothing
-
-> findID cor i (LBUnqualifiedIds src ids intIds) =
->   if cor == ""
->   then flip fmap (msum [lookup i ids
->                        ,lookup i intIds])
->          $ \ty -> Right (src,"",i,ty)
->   else Nothing
-> findID cor i (LBJoinIds _ _ _ _ _ _ _ _ _)  = undefined
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/LocalIdentifierBindings.lhs b/Database/HsSqlPpp/AstInternals/TypeChecking/LocalIdentifierBindings.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/LocalIdentifierBindings.lhs
+++ /dev/null
@@ -1,238 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This module contains the code to manage local identifier bindings
-during the type checking process.
-
-Main areas to support are parameters and variables
-
-> {-# OPTIONS_HADDOCK hide  #-}
-
-> module Database.HsSqlPpp.AstInternals.TypeChecking.LocalIdentifierBindings
->     (
->      QualifiedIDs
->     ,LocalIdentifierBindings
->     ,emptyBindings
->     ,updateBindings
->     ,LocalIdentifierBindingsUpdate(..)
->     ,libExpandStar
->     ,libLookupID
->     ) where
-
-> import Control.Monad
-> import Data.Char
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-> import Database.HsSqlPpp.Utils
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-
-> -- | The main datatype, this holds the catalog and context
-> -- information to type check against.
-> data LocalIdentifierBindings = LocalIdentifierBindings
->                    {identifierTypes :: [[QualifiedIDs]]
->                    ,starTypes :: [QualifiedIDs]}
-
-
-
-> -- | Represents an empty catalog. This doesn't contain things
-> -- like the \'and\' operator, and so if you try to use it it will
-> -- almost certainly not work.
-> emptyBindings :: LocalIdentifierBindings
-> emptyBindings = LocalIdentifierBindings [] []
-
-> -- | 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.
-> type QualifiedIDs = (String, [(String,Type)])
-
-> instance Show LocalIdentifierBindings where
->   show (LocalIdentifierBindings idTypes starEx) =
->       "ID Types:\n" ++ concatMap (flip showQList 0) idTypes ++
->         "Star Exp:\n" ++ concatMap showQuals starEx
->       where
->         showQList :: [QualifiedIDs] -> Int -> String
->         showQList (x:xs) n = show n ++ ":\n" ++
->                               showQuals x ++ "\n" ++ showQList xs (n + 1)
->         showQList [] _ = ""
->         showQuals :: QualifiedIDs -> String
->         showQuals (co, idList) = "qual: " ++ co ++ ":\n" ++ concatMap (\(n,t) -> n ++ "::" ++ show t ++ "\n") idList
-
-
-
-= Attribute identifier scoping
-
-The way this scoping works is we have a list of prefixes/namespaces,
-which is generally the table/view name, or the alias given to it, and
-then a list of identifiers (with no dots) and their types. When we
-look up the type of an identifier, if it has an correlation name we
-try to match that against a table name or alias in that list, if it is
-not present or not unique then throw an error. Similarly with no
-correlation name, we look at all the lists, if the id is not present
-or not unique then throw an error.
-
-catIdentifierTypes is for expanding *. If we want to access the
-common attributes from one of the tables in a using or natural join,
-this attribute can be qualified with either of the table names/
-aliases. But when we expand the *, we only output these common fields
-once, so keep a separate list of these fields used just for expanding
-the star. The other twist is that these common fields appear first in
-the resultant field list.
-
-System columns: pg also has these - they have names and types like
-other attributes, but are not included when expanding stars, so you
-only get them when you explicitly ask for them. The main use is using
-the oid system column which is heavily used as a target for foreign
-key references in the pg catalog.
-
-This system still isn't working right. Subqueries are a
-problem. Aspects which don't work right now are:
-
-consider this query:
-select relname as relvar_name
-    from pg_class
-    where ((relnamespace =
-           (select oid
-              from pg_namespace
-              where (nspname = 'public'))) and (relkind = 'r'));
-
-we need to be able to access attributes from pg_class inside the subquery,
-but 1) they aren't inserted if you use * in the inner query
-2) they can't make an identifier ambiguous, so the oid here in the subquery
-is ok even though both the oid from pg_namespace and the oid from pg_class
-are in scope.
-
-So there are two problems with the current code:
-it's too aggressive at throwing ambiguous identifier errors
-it pulls in too many identifiers when expanding star
-
-Solution ideas:
-for the ambiguous errors, create a stack of identifiers, then split
-the CatUpdateIDs into two, one to replace the current set, and one to
-push a new set on the stack. Then fix the lookup to walk the stack level by level.
-
-for the *, we already have special cases for system columns, and for
-join ids. I think the best solution is to provide a separate list of *
-columns and types, with a separate cat update ctor, and get the type
-checker to resolve the list for * expansion rather than doing it here.
-
-This should also handle parameters and variable declarations in plpgsql
-functions too, these stack in the same way, with one complication to
-do with parameters:
-
-there is an additional complication with plpgsql, which isn't going to
-be handled for now: instead of stacking like everything else, for
-variable references inside select, insert, update and delete
-statements only, which aren't qualified and match a parameter name,
-then the parameter is used in lieu of variable declarations or
-attributes inside a select expression. This will be handled at some
-point.
-
-this is something the lint checker should flag when it's written, it
-will also flag any ambiguous identifiers which resolve ok only because
-of stacking, this is a standard warning in many flavours of lint
-checkers.
-
-One last thing is that we need to make sure identifiers availability doesn't
-get inherited too far: e.g. a create function inside a create function
-can't access ids from the outer create function. This is pretty easy:
-the following things generate identifier bindings:
-select expressions, inside the expression
-parameter defs
-variable defs
-
-since select expressions can't contain statements, we don't need to
-worry about e.g. if statements, they want to inherit ids from params
-and variable defs, so the default is good.
-
-For catalogs being updated sequentially: since the catalog is
-updated in a statement list (i.e. catalog updates stack from one
-statement to the next within a single statement list), any var defs
-can't break out of the containing list, so we are covered e.g. for a
-variable def leaking from an inner block to an outer block.
-
-With ids going into select expressions: we want the default which is
-parameters, vardefs and ids from containing select expressions to be
-inherited. So, in the end the only case to deal with is a create
-function inside another create function. This isn't dealt with at the
-moment.
-
-
-
-> libExpandStar :: LocalIdentifierBindings -> String -> Either [TypeError] [(String,Type)]
-> libExpandStar cat correlationName =
->     case lookup correlationName $ starTypes cat of
->       Nothing -> errorWhen (correlationName == "")
->                            [InternalError "no star expansion found?"] >>
->                  Left [UnrecognisedCorrelationName correlationName]
->       Just l -> Right l
-
-> splitIdentifier :: String -> (String,String)
-> splitIdentifier s = let (a,b) = span (/= '.') s
->                     in if b == ""
->                          then ("", a)
->                          else (a,tail b)
-
-> libLookupID :: LocalIdentifierBindings -> String -> Either [TypeError] Type
-> libLookupID cat iden1 =
->   catLookupID' $ identifierTypes cat
->   where
->     (correlationName,iden) = splitIdentifier $ map toLower iden1
->     catLookupID' (its:itss) =
->       case lookup correlationName its of
->         Nothing -> catLookupID' itss
->         Just s -> case filter (\(n,_) -> map toLower n==iden) s of
->                     [] -> if correlationName == ""
->                             then catLookupID' itss
->                             else Left [UnrecognisedIdentifier $ correlationName ++ "." ++ iden]
->                     (_,t):[] -> Right t
->                     _ -> Left [AmbiguousIdentifier iden]
->     catLookupID' [] =
->       Left [if correlationName == ""
->               then UnrecognisedIdentifier iden
->               else UnrecognisedCorrelationName correlationName]
-
-> -- | Applies a list of 'CatalogUpdate's to an 'Catalog' value
-> -- to produce a new Catalog value.
-> updateBindings :: LocalIdentifierBindings
->                -> Catalog
->                -> [LocalIdentifierBindingsUpdate]
->                -> Either [TypeError] LocalIdentifierBindings
-> updateBindings lbs' cat eus =
->   let r = foldM updateCat' lbs' eus
->   in {-trace ("*********************************************\nupdatebindings from " ++ show lbs' ++ "\nto\n" ++ show r) -} r
->   where
->     updateCat' lbs eu =
->       case eu of
->         LibStackIDs qids -> return $ lbs {identifierTypes = expandComposites qids : identifierTypes lbs}
->         LibSetStarExpansion sids -> return $ lbs {starTypes = sids}
->     --take all the composite typed ids, and expand them out
->     expandComposites :: [(String, [(String,Type)])] -> [(String, [(String,Type)])]
->     expandComposites ((q,attrs):qis) =
->         ec attrs ++ (q, map (\(n,t) -> (n,wrapIfRecord n t)) attrs) : expandComposites qis
->         where
->           ec :: [(String,Type)] -> [(String, [(String,Type)])]
->           ec [] = []
->           ec ((nm,NamedCompositeType t):xs) = (nm,compFields t):ec xs
->           ec ((nm,SetOfType(NamedCompositeType t)):xs) = (nm,compFields t):ec xs
->           ec ((nm,CompositeType t):xs) = (nm, t):ec xs
->           ec ((nm,SetOfType(CompositeType t)):xs) = (nm, t):ec xs
->           ec (_:xs) = ec xs
->           wrapIfRecord n t =
->             case libLookupID lbs' n of
->               Right (PgRecord _) -> PgRecord (Just t)
->               _ -> t
->     expandComposites [] = []
->     compFields = fromRight [] . catCompositePublicAttrs cat []
-
-> data LocalIdentifierBindingsUpdate =
->     -- | 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
->       LibStackIDs [QualifiedIDs]
->     -- | to allow an unqualified star to work you need to
->     -- supply an extra entry with \"\" as the alias, and all the fields
->     | LibSetStarExpansion [QualifiedIDs]
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Misc.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Misc.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Misc.ag
+++ /dev/null
@@ -1,171 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-Contains bit and pieces of type checking which don't fit anywhere else
-
-================================================================================
-
-= type names
-
-Types with type modifiers (called PrecTypeName here, to be changed),
-are not supported at the moment.
-
--}
-
-ATTR TypeName [||namedType : Type]
-
-SEM TypeName
-     | SimpleTypeName ArrayTypeName SetOfTypeName PrecTypeName
-         lhs.namedType = tpeToT @loc.tpe
-         lhs.annotatedTree = updateAnnotation
-                               ((map TypeErrorA $ getErrors @loc.tpe) ++)
-                               @loc.backTree
-
-
-SEM TypeName
-     | SimpleTypeName
-        loc.tpe = catLookupType @lhs.cat $ canonicalizeTypeName @tn
-        loc.backTree = SimpleTypeName @ann @tn
-     | ArrayTypeName
-        loc.tpe = dependsOnRTpe [@typ.namedType] $ Right $ ArrayType @typ.namedType
-        loc.backTree = ArrayTypeName @ann @typ.annotatedTree
-     | SetOfTypeName
-        loc.tpe = dependsOnRTpe [@typ.namedType] $ Right $ SetOfType @typ.namedType
-        loc.backTree = SetOfTypeName @ann @typ.annotatedTree
-     | PrecTypeName
-        loc.tpe = catLookupType @lhs.cat $ canonicalizeTypeName @tn
-        loc.backTree = PrecTypeName @ann @tn @prec
-
-
-{-
-================================================================================
-
-= generic node types
-
--}
-
---expression list and list list - just collect up the types
-
-ATTR ExpressionList [||typeList : {[Type]}]
-
-SEM ExpressionList
-    | Cons lhs.typeList = getTypeAnnotation @hd.annotatedTree : @tl.typeList
-    | Nil lhs.typeList = []
-
-
-ATTR ExpressionListList  [||typeListList : {[[Type]]}]
-
-SEM ExpressionListList
-    | Cons lhs.typeListList = @hd.typeList : @tl.typeListList
-    | Nil lhs.typeListList = []
-
-
--- stringlist: collect the strings
-ATTR StringList [||strings : {[String]}]
-
-SEM StringList
-  | Cons lhs.strings = @hd : @tl.strings
-  | Nil lhs.strings = []
-
--- maybe bool expression: if present, then check its type is bool
-
-SEM MaybeBoolExpression
-    | Just
-        lhs.annotatedTree =
-          if getTypeAnnotation @just.annotatedTree `notElem` [typeBool, TypeCheckFailed]
-            then Just $ updateAnnotation ((TypeErrorA ExpressionMustBeBool) :)
-                          @just.annotatedTree
-            else Just $ @just.annotatedTree
-
-
-{
-{-
-================================================================================
-
-= couple of small utils
-
-I think this should be alright, an identifier referenced in an
-expression can only have zero or one dot in it.
--}
-
-splitIdentifier :: String -> (String,String)
-splitIdentifier s = let (a,b) = span (/= '.') s
-                    in if b == ""
-                         then ("", a)
-                         else (a,tail b)
-
-{-
-helper to make adding annotations a bit easier
--}
-
-annTypesAndErrors :: Data a => a -> Type -> [TypeError]
-                  -> Maybe [AnnotationElement] -> a
-annTypesAndErrors item nt errs add =
-    updateAnnotation modifier item
-    where
-      modifier = (([TypeAnnotation nt] ++ fromMaybe [] add ++
-       map TypeErrorA errs) ++)
-
-{-
-================================================================================
-
-proper dodgy:
-1st pass is to add inferred types to the tree. This is done only for
-expressions in a funcall argument list atm. Then we pull out the
-placeholders after they've had this information added. Only the
-placeholders in funcall argument lists will have their type inferred
-in this way, to be expanded. Insert also does this currently, but in Dml.ag
-
-This should probably be done during the typechecking phase instead,
-but probably needs a proper type inferencing algorithm to be used, is
-done like this for development expediency.
-
--}
-getPlaceholders :: Data a => a -> [Expression]
-getPlaceholders st =
-    filter isPlaceholder $ everything (++) (mkQ [] ga) (setInferredTypes st)
-    where
-      ga :: Expression -> [Expression]
-      ga s = [s]
-      isPlaceholder e = case e of
-                          PositionalArg _ _ -> True
-                          Placeholder _ -> True
-                          _ -> False
-
-getPlaceholderTypes :: Data a => a -> [Type]
-getPlaceholderTypes ex =
-    map (getInferredType . getAnnotation) $ getPlaceholders ex
-    where
-      getInferredType (InferredType t:_) = t
-      getInferredType (_:as) = getInferredType as
-      getInferredType [] = TypeCheckFailed
-
-
-setInferredTypes :: Data a => a -> a
-setInferredTypes =
-      doExprs {-. doSts-}
-     where
-       doExprs =
-         transformBi (\x ->
-           case x of
-             FunCall an op exprs
-                 -> FunCall an op (addInferredTypes an exprs)
-             x1 -> x1)
-       {-doSts =
-         transformBi (\x ->
-           case x of
-             Insert ann table targetCols insData returning
-                 -> Insert ann table targetCols insData returning
-             x1 -> x1)-}
-       addInferredTypes an exprs =
-           let args1 = fmap (\(_,a,_,_) -> a) $ fp an
-               args = fromMaybe [] args1
-               fargs = args ++ repeat TypeCheckFailed
-           in flip map (zip exprs fargs)
-                  (\(ex, ty) -> updateAnnotation (++ [InferredType ty]) ex)
-           where
-             fp (FunctionPrototypeA f:_) = Just f
-             fp (_:ls) = fp ls
-             fp [] = Nothing
-
-}
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/MiscCreates.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/MiscCreates.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/MiscCreates.ag
+++ /dev/null
@@ -1,79 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the ddl checking, apart from create function and
-create table which have their own files.
-
-= create view
-
-pretty simple, just forwards the select expression type
-
--}
-
-SEM Statement
-    | CreateView
-        loc.tpe = dependsOnRTpe [getTypeAnnotation @expr.annotatedTree] $
-                    Right $ Pseudo Void
-        loc.backTree = CreateView @ann @name @expr.annotatedTree
-        loc.attrs = case getTypeAnnotation @expr.annotatedTree of
-                      SetOfType (CompositeType c) -> c
-                      _ -> [] --TODO: error ignored
-        loc.catUpdates = [CatCreateView @name @loc.attrs]
-        loc.statementType = []
-
-{-
-================================================================================
-
-= create type
-
-might move this to create table since they have a fair bit in common
-
-main shortcomings are the names and types aren't checked
-
--}
-
-ATTR TypeAttributeDef [||attrName : String
-                         namedType : Type]
-
-SEM TypeAttributeDef
-    | TypeAttDef
-        lhs.attrName = @name
-        lhs.namedType = @typ.namedType
-
-ATTR TypeAttributeDefList [||attrs : {[(String, Type)]}]
-
-SEM TypeAttributeDefList
-    | Cons lhs.attrs = (@hd.attrName, @hd.namedType) : @tl.attrs
-    | Nil lhs.attrs = []
-
-SEM Statement
-    | CreateType
-        loc.tpe = Right $ Pseudo Void
-        loc.backTree = CreateType @ann @name @atts.annotatedTree
-        loc.statementType = []
-        loc.catUpdates = [CatCreateComposite @name @atts.attrs]
-
-{-
-
-= create domain
-
--}
-
-SEM Statement
-    | CreateDomain
-        loc.tpe = Right $ Pseudo Void
-        loc.backTree = CreateDomain @ann @name @typ.annotatedTree @checkName @check.annotatedTree
-        loc.statementType = []
-        loc.catUpdates = [CatCreateDomain (DomainType @name) @typ.namedType]
-        --allow refering to value as 'value' in check expression
-        check.lib = fromRight @lhs.lib $
-                    updateBindings @lhs.lib @lhs.cat
-                      [LibStackIDs [("", [("value", @typ.namedType)])]]
-
-SEM Statement
-    | CreateLanguage
-        loc.tpe = Right $ Pseudo Void
-        loc.backTree = CreateLanguage @ann @name
-        loc.statementType = []
-        loc.catUpdates = [CatCreateFunction FunName "plpgsql_call_handler" [] (Pseudo LanguageHandler) False
-                         ,CatCreateFunction FunName "plpgsql_validator" [ScalarType "oid"] (Pseudo Void) False]
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Plpgsql.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Plpgsql.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Plpgsql.ag
+++ /dev/null
@@ -1,87 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the checking code for a few plpgsql statements.
-
-
--}
-
---todo: check return type consistent with function return type
-SEM Statement
-    | Return
-        loc.tpe =
-            dependsOnRTpe [maybe typeBool
-                                getTypeAnnotation
-                                @value.annotatedTree] $ Right $ Pseudo Void
-        loc.backTree = Return @ann @value.annotatedTree
-        loc.catUpdates = []
-        loc.statementType = []
-
-
-SEM Statement
-    | Assignment
-        loc.tpe =
-            do
-            let fromType = getTypeAnnotation @value.annotatedTree
-            toType <- libLookupID @lhs.lib @target
-            dependsOnRTpe [getTypeAnnotation @value.annotatedTree, toType] $ do
-            checkAssignmentValid @lhs.cat fromType toType
-            return $ Pseudo Void
-        loc.backTree = Assignment @ann @target @value.annotatedTree
-        loc.catUpdates = []
-        loc.statementType = []
-
-SEM Statement
-    | ForIntegerStatement
-        loc.varTypeE = libLookupID @lhs.lib @var
-        loc.tpe =
-          do
-          let fromType = getTypeAnnotation @from.annotatedTree
-              toType = getTypeAnnotation @to.annotatedTree
-          dependsOnRTpe [fromType,toType] $ do
-          --probably a bit too strict:
-          errorWhen (fromType /= toType) [FromToTypesNotSame fromType toType]
-          case @loc.varTypeE of
-            Right t -> checkAssignmentValid @lhs.cat fromType t
-            Left _ -> return ()
-          return $ Pseudo Void
-        sts.lib =
-            case @loc.varTypeE of
-              Left [UnrecognisedIdentifier @var] ->
-                  fromRight @lhs.lib $
-                  updateBindings @lhs.lib @lhs.cat
-                                 [LibStackIDs [("", [(@var,getTypeAnnotation @from.annotatedTree)])]]
-              _ -> @lhs.lib
-
-        loc.backTree = ForIntegerStatement @ann @var @from.annotatedTree @to.annotatedTree @sts.annotatedTree
-        loc.catUpdates = []
-        loc.statementType = []
-
-
-SEM Statement
-    | ForSelectStatement
-        loc.selType = getTypeAnnotation @sel.annotatedTree
-        loc.tpe =
-          do
-          dependsOnRTpe [@loc.selType] $ do
-          toType <- libLookupID @lhs.lib @var
-          dependsOnRTpe [toType] $ do
-          checkAssignmentValid @lhs.cat @loc.selType toType
-          return $ Pseudo Void
-        --just handles assigning to a record type for now
-        --one thing that isn't quite right is that the record variable
-        --holds the last row in it after the for statement, which isn't
-        --supported here
-        sts.lib =
-            if okToUpdate
-              then fromRight @lhs.lib $
-                   updateBindings @lhs.lib @lhs.cat [LibStackIDs [("", [(@var,@loc.selType)])]]
-                   -- todo:ignoring error
-              else @lhs.lib
-            where
-              okToUpdate = isRight @loc.tpe && @loc.selType /= TypeCheckFailed
-
-        loc.backTree = ForSelectStatement @ann @var @sel.annotatedTree @sts.annotatedTree
-        loc.catUpdates = []
-        loc.statementType = []
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/SelectLists.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/SelectLists.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/SelectLists.ag
+++ /dev/null
@@ -1,184 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the code that handles the select list part of a
-select expression.
-
-TODO: stop wrapping string,type lists in unnamedcompositetypes, pointless
-
--}
-
-SEM SelectItem
-    | SelExp
-        loc.annotatedTree = SelExp @ann $ fixStar @ex.annotatedTree
-    | SelectItem
-        loc.annotatedTree = SelectItem @ann (fixStar @ex.annotatedTree) @name
-
-ATTR MaybeSelectList [||listType : {Maybe [(String,Type)]}]
-
-ATTR SelectItemList SelectList [||listType : {[(String,Type)]}]
-ATTR SelectItem [||itemType : Type]
-
-ATTR SelectList [||libUpdates : {[LocalIdentifierBindingsUpdate]}]
-
-SEM MaybeSelectList
-    | Just lhs.listType = Just @just.listType
-    | Nothing lhs.listType = Nothing
-
-SEM SelectItemList
-    | Cons lhs.listType = expandStar @lhs.lib @hd.columnName @hd.itemType @tl.listType
-    | Nil lhs.listType = []
-
-
-SEM SelectItem
-    | SelExp SelectItem
-        lhs.itemType = getTypeAnnotation @ex.annotatedTree
-
-
-
-SEM SelectList
-    | SelectList
-        lhs.listType = @items.listType
--- check the into types
-        loc.errs = case @loc.stuff of
-                     (er,_) -> er
-        loc.stuff =
-          case () of
-            _ | null sl -> ([],Nothing)
-              | not (null targetTypeErrs) -> (targetTypeErrs,Nothing)
-              | (case targetTypes of
-                   [PgRecord _] -> True
-                   _ -> False) -> ([],Just (head sl, CompositeType @items.listType))
-              | matchingComposite /= Left [] -> (fromLeft [] matchingComposite,Nothing)
-              | length sl /= length @items.listType -> ([WrongNumberOfColumns],Nothing)
-              | not (null assignErrs) -> (assignErrs,Nothing)
-              | otherwise -> ([],Nothing)
-          where
-            targetTypeEithers = map (libLookupID @lhs.lib) sl
-            targetTypeErrs = concat $ lefts $ targetTypeEithers
-            targetTypes = rights $ targetTypeEithers
-            typePairs = zip (map snd @items.listType) targetTypes
-            assignErrs = concat $ lefts $ map (uncurry $ checkAssignmentValid @lhs.cat) typePairs
-            sl = @into.strings
-            matchingComposite =
-                case targetTypes of
-                  [t] | isCompositeType t -> checkAssignmentValid @lhs.cat (AnonymousRecordType (map snd @items.listType)) t
-                  _ -> Left []
-
-        lhs.annotatedTree = SelectList (@ann ++ map TypeErrorA @loc.errs)
-                                       @items.annotatedTree
-                                       @into.annotatedTree
-        lhs.libUpdates =
-            case @loc.stuff of
-              (_,Just r) -> [LibStackIDs [("", [r])]]
-              _ -> []
---[(@var,@loc.selType)]
-
-SEM Statement
-    | SelectStatement
-        loc.libUpdates = @ex.libUpdates
-
-ATTR SelectExpression [||libUpdates : {[LocalIdentifierBindingsUpdate]}]
-
-SEM SelectExpression
-    | Select
-        lhs.libUpdates = @selSelectList.libUpdates
-    | CombineSelect Values
-          lhs.libUpdates = []
-
--- utils to handle a star, bit hacky, maybe should use a separate pass
--- or something?
-
-{
-expandStar :: LocalIdentifierBindings
-           -> String
-           -> Type
-           -> [(String,Type)]
-           -> [(String,Type)]
-expandStar cat colName colType types =
-    fromRight types $ do
-    let (correlationName,iden) = splitIdentifier colName
-    newCols <- if iden == "*"
-                 then libExpandStar cat correlationName
-                 else return [(iden, colType)]
-    return $ newCols ++ types
-
-fixStar :: Expression -> Expression
-fixStar =
-    everywhere (mkT fixStar')
-    where
-      fixStar' :: Annotation -> Annotation
-      fixStar' a =
-          if TypeAnnotation TypeCheckFailed `elem` a
-              && any (\an ->
-                       case an of
-                         TypeErrorA (UnrecognisedIdentifier x) |
-                           let (_,iden) = splitIdentifier x
-                           in iden == "*" -> True
-                         _ -> False) a
-             then filter (\an -> case an of
-                                   TypeAnnotation TypeCheckFailed -> False
-                                   TypeErrorA (UnrecognisedIdentifier _) -> False
-                                   _ -> True) a
-             else a
-}
-
-
-{-
-
-================================================================================
-
-= attribute names
-
-columnName is used to collect the column names that the select list
-produces, it is combined into an unnamedcompositetype in
-selectitemlist, which is also where star expansion happens.
-
--}
-
-ATTR SelectItem [||columnName : String]
-
-{-
-if the select item is just an identifier, then that column is named
-after the identifier
-e.g. select a, b as c, b + c from d, gives three columns one named
-a, one named c, and one unnamed, even though only one has an alias
-if the select item is a function or aggregate call at the top level,
-then it is named after that function or aggregate
-
-if it is a cast, the column is named after the target data type name
-iff it is a simple type name
-
--}
-
---default value for non identifier nodes
-
-{-
-override for identifier nodes, this only makes it out to the selectitem
-node if the identifier is not wrapped in parens, function calls, etc.
--}
-
-ATTR Expression [||liftedColumnName : String]
-
-SEM Expression
-  | Identifier lhs.liftedColumnName = @i
-  | FunCall lhs.liftedColumnName =
-      if isOperatorName @funName
-         then ""
-         else @funName
-  | Cast lhs.liftedColumnName = case @tn.annotatedTree of
-                                  SimpleTypeName _ tn -> tn
-                                  _ -> ""
-
-
-SEM Expression
-  | BooleanLit Case Exists FloatLit IntegerLit LiftOperator
-    NullLit PositionalArg Placeholder ScalarSubQuery StringLit
-      lhs.liftedColumnName = ""
-
--- collect the aliases and column names for use by the selectitemlist nodes
-SEM SelectItem
-    | SelExp lhs.columnName = case @ex.liftedColumnName of
-                                "" -> "?column?"
-                                s -> s
-    | SelectItem lhs.columnName = @name
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/SelectStatement.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/SelectStatement.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/SelectStatement.ag
+++ /dev/null
@@ -1,174 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-= basic select statements
-
-This is a bit of a mess, will be rewritten with a proper literate
-flavour once all the different bits are type checking ok, which should
-make it much more readable.
-
--}
-
-SEM Statement
-    | SelectStatement
-        loc.tpe = dependsOnRTpe [getTypeAnnotation @ex.annotatedTree] $ Right $ Pseudo Void
-        loc.statementType = [StatementType (getPlaceholderTypes @ex.annotatedTree) $ leftToEmpty id  $
-                                                unwrapSetOfComposite $
-                                                getTypeAnnotation @ex.annotatedTree]
-        loc.backTree = SelectStatement @ann @ex.annotatedTree
-        loc.catUpdates = []
-
-SEM SelectExpression
-    | Values Select CombineSelect
-        lhs.annotatedTree = annTypesAndErrors @loc.backTree
-                              (tpeToT @loc.tpe)
-                              (getErrors @loc.tpe)
-                              Nothing
-{-
-
-================================================================================
-
-Type checking select expressions
-
-The main issue is the complicated flow of identifier bindings through the
-various parts. This is the rough order in which this happens:
-
-with
-from
-where
-groupby
-having
-select
-combine
-orderby
-limit
-
-if a type error occurs, we want to give up on any following stages,
-rather than create loads of type errors (maybe this could be refined
-more).
-
-The select list produces the final type which the selectexpression has.
-
-inside the from, if we have any join expressions we need to pass the types
-from the joined trefs to the join expressions.
-
-So, the basic plan is to propagate the iden bindings in the cat attribute
-as elsewhere, and also pass along a flag to say whether the previous stage
-type checked or not, so we can bail if it has failed.
-
-alternative idea: explore transforming the ast for a select expression into
-something using relational algebra-like operations - can then follow the flow
-of ids easily. The problem might be with updating the annotations in the original
-tree though.
-
-== cat passing current bodge
-
-cat flow:
-current simple version:
-from tref -> select list
-          -> where
-
-(so we take the identifiers and types from the tref part, and send
-them into the selectlist and where parts)
-
-full order of identifier passing:
-   1. from
-   2. where
-   3. group by
-   4. having
-   5. select
-
-
-group by notes, from the pg manual:
-group by expressions can be an input column name, or the name or
-ordinal number of an output column (SELECT list item), or an arbitrary
-expression formed from input-column values. In case of ambiguity, a
-GROUP BY name will be interpreted as an input-column name rather than
-an output column name.
-
-For now, just send the input columns in as identifiers
--}
-
-SEM SelectExpression
-    | Select
-         loc.newLib = case updateBindings @lhs.lib @lhs.cat @selTref.libUpdates of
-                        Left x -> error $ show x -- @lhs.cat
-                        Right e -> e
-         selSelectList.lib = @loc.newLib
-         selWhere.lib = @loc.newLib
-         selGroupBy.lib = @loc.newLib
-         selOrderBy.lib = @loc.newLib
-
-
-
-SEM SelectExpression
-    | Values
-        loc.tpe = typeCheckValuesExpr
-                              @lhs.cat
-                              @vll.typeListList
-        loc.backTree = Values @ann @vll.annotatedTree
-    | Select
-        loc.tpe =
-           do
-           --let trefType = fromMaybe typeBool $ fmap getTypeAnnotation
-           --                                         @selTref.annotatedTree
-           Right $ case @selSelectList.listType of
-                     [(_,Pseudo Void)] -> Pseudo Void
-                     _ -> SetOfType $ CompositeType @selSelectList.listType
-        loc.backTree = Select @ann
-                              @selDistinct.annotatedTree
-                              @selSelectList.annotatedTree
-                              @selTref.annotatedTree
-                              @selWhere.annotatedTree
-                              @selGroupBy.annotatedTree
-                              @selHaving.annotatedTree
-                              @selOrderBy.annotatedTree
-                              @selLimit.annotatedTree
-                              @selOffset.annotatedTree
-    | CombineSelect
-        loc.tpe =
-          let sel1t = getTypeAnnotation @sel1.annotatedTree
-              sel2t = getTypeAnnotation @sel2.annotatedTree
-          in dependsOnRTpe [sel1t, sel2t] $
-                typeCheckCombineSelect @lhs.cat sel1t sel2t
-        loc.backTree = CombineSelect @ann @ctype.annotatedTree
-                                     @sel1.annotatedTree
-                                     @sel2.annotatedTree
-
-{
-
-typeCheckValuesExpr :: Catalog -> [[Type]] -> Either [TypeError] Type
-typeCheckValuesExpr cat rowsTs =
-        let colNames = zipWith (++)
-                           (repeat "column")
-                           (map show [1..length $ head rowsTs])
-        in unionRelTypes cat rowsTs colNames
-
-
-typeCheckCombineSelect :: Catalog -> Type -> Type -> Either [TypeError] Type
-typeCheckCombineSelect cat v1 v2 = do
-    u1 <- unwrapSetOfComposite v1
-    let colNames = map fst u1
-    u2 <- unwrapSetOfComposite v2
-    let colTypes1 = map snd u1
-    let colTypes2 = map snd u2
-    unionRelTypes cat [colTypes1,colTypes2] colNames
-
-unionRelTypes :: Catalog -> [[Type]] -> [String] -> Either [TypeError] Type
-unionRelTypes cat rowsTs colNames =
-  let lengths = map length rowsTs
-  in case () of
-             _ | null rowsTs ->
-                   Left [NoRowsGivenForValues]
-               | not (all (==head lengths) lengths) ->
-                   Left [ValuesListsMustBeSameLength]
-               | otherwise ->
-                   --i don't think this propagates all the errors, just the first set
-                   mapM (resolveResultSetType cat) (transpose rowsTs) >>=
-                     (return . SetOfType . CompositeType . zip colNames)
-
-}
-
-INCLUDE "TypeChecking/TableRefs.ag"
-
-INCLUDE "TypeChecking/SelectLists.ag"
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/Statements.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/Statements.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/Statements.ag
+++ /dev/null
@@ -1,122 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the general code for statements and statement
-lists, and includes the ag files for various flavours of statement.
-
-The attributes and sem statements in this file are for chaining the
-cat updates as we progress through a statement list, and for producing
-the resultant cat after we've checked a whole ast, this can be used
-e.g. to type check multiple files in a row which depend on eachother.
-
--}
-
--- cat updates syn attr is used by each statement to report
--- what changes it makes to the catalog, we use this to update
--- the cat to feed into the next statement
-
-ATTR Statement [||catUpdates : {[CatalogUpdate]}
-                  libUpdates : {[LocalIdentifierBindingsUpdate]}]
-
-
-ATTR StatementList [catUpdates : {[CatalogUpdate]}
-                    libUpdates : {[LocalIdentifierBindingsUpdate]}||]
-
-
---producedcat is used to pass the final updated cat out
-ATTR StatementList Root [|| producedCat : Catalog
-                            producedLib : LocalIdentifierBindings]
-
-ATTR Statement [inProducedCat: Catalog||]
-
-SEM StatementList
-    | Cons Nil
-        --newcat is the catalog passed into the head statement
-        --updated with any catalog changes that that statement has made
-        loc.newCat = fromRight @lhs.cat $ updateCatalog @lhs.cat @lhs.catUpdates
-        loc.newLib = fromRight @lhs.lib $ updateBindings @lhs.lib @lhs.cat @lhs.libUpdates
-    | Cons
-        hd.cat = @loc.newCat
-        tl.cat = @loc.newCat
-        hd.lib = @loc.newLib
-        tl.lib = @loc.newLib
-        --produced cat is used to chain the final updated catalog from the last
-        --element of the list and pass it back up the list so in can be pushed up
-        -- to the root element and sent out from there
-        lhs.producedCat = @tl.producedCat
-        lhs.producedLib = @tl.producedLib
-        --this is probably a bit inefficient: it creates a new catalog from scratch
-        --on each statement instead of chaining on the last updated cat
-        tl.catUpdates = @hd.catUpdates
-        tl.libUpdates = @hd.libUpdates
-    | Nil
-        lhs.producedCat = @loc.newCat
-        lhs.producedLib = @loc.newLib
-
-SEM Statement
-    | SelectStatement Insert Update Delete CreateView CreateDomain CreateLanguage
-      CreateFunction CreateType CreateTable CreateTableAs Return Assignment
-      ForSelectStatement ForIntegerStatement DropFunction
-        loc.tpe : {Either [TypeError] Type}
-        lhs.annotatedTree = annTypesAndErrors @loc.backTree
-                              (tpeToT @loc.tpe)
-                              (getErrors @loc.tpe)
-                              $ Just (map StatementTypeA @loc.statementType ++
-                                      [CatUpdates @loc.catUpdates])
-        loc.catUpdates : {[CatalogUpdate]}
-        lhs.catUpdates = @loc.catUpdates
-        lhs.libUpdates = @loc.libUpdates
-    | Insert Update Delete CreateView CreateDomain
-      CreateFunction CreateType CreateTable CreateTableAs Return
-      Assignment ForSelectStatement ForIntegerStatement Set CreateLanguage
-      Notify CreateSequence AlterSequence DropFunction
-        loc.libUpdates = []
-
-SEM StatementList
-    | Cons hd.inProducedCat = @tl.producedCat
-
-
-SEM Root
-    | Root statements.catUpdates = []
-           statements.libUpdates = []
-
-SEM Statement
-    | CaseStatement ContinueStatement Copy CopyData
-      DropSomething Execute ExecuteInto
-      If NullStatement Perform Raise ReturnNext ReturnQuery Truncate
-      WhileStatement Set Notify CreateSequence
-      AlterSequence AlterTable CreateTrigger
-        lhs.catUpdates = []
-        lhs.libUpdates = []
-
-SEM ExpressionListStatementListPair
-    | Tuple
-        x2.catUpdates = []
-        x2.libUpdates = []
-SEM ExpressionStatementListPair
-    | Tuple
-        x2.catUpdates = []
-        x2.libUpdates = []
-SEM FnBody
-    | PlpgsqlFnBody SqlFnBody
-        sts.catUpdates = []
-        sts.libUpdates = []
-SEM Statement
-    | CaseStatement If
-        els.catUpdates = []
-        els.libUpdates = []
-SEM Statement
-    | ForIntegerStatement ForSelectStatement WhileStatement
-        sts.catUpdates = []
-        sts.libUpdates = []
-
-
-
-INCLUDE "TypeChecking/SelectStatement.ag"
-INCLUDE "TypeChecking/Dml.ag"
-INCLUDE "TypeChecking/CreateTable.ag"
-INCLUDE "TypeChecking/MiscCreates.ag"
-INCLUDE "TypeChecking/CreateFunction.ag"
-INCLUDE "TypeChecking/Drops.ag"
-INCLUDE "TypeChecking/Plpgsql.ag"
-
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/TableRefs.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/TableRefs.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/TableRefs.ag
+++ /dev/null
@@ -1,270 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the checking for tablerefs (the from part of a
-select expression).
-
--}
-
--- lib update contains the updated id and star expansions coming out
--- of the tableref part of a select expression. These updates aren't
--- used for chaining these things for nested table refs (in join
--- statements) - use attributes for them
-
-ATTR TableRef TableRefList [|| libUpdates: {[LocalIdentifierBindingsUpdate]}]
-
--- use these attributes which contain a copy of the info in lib
--- updates in a form more digestible to the join attributes resolution
--- the main advantages is we don't have to pull the ids out of a list
--- of update wrappers, and we don't have to split the id bindings into
--- qualified and unqualified parts. We could do it just using the
--- libupdates in principle, but this way seems to be a bit more direct
--- and clear to write and read (i.e. when I tried to to it using
--- libupdates I failed and gave up several times).
-ATTR TableRef [|| idLookups : {[(String,Type)]}
-                  starExpansion : {[(String,Type)]}
-                  qidLookups : {[(String,[(String,Type)])]}
-                  qstarExpansion : {[(String,[(String,Type)])]}]
-
--- set the annotations, just need to pick up any type errors whilst
--- calculating the new bindings
-SEM TableRef
-    | SubTref Tref TrefFun JoinedTref
-        lhs.annotatedTree =
-            updateAnnotation (map TypeErrorA @loc.errs ++) @loc.backTree
-
-SEM TableRefList
-    | Nil
-        lhs.libUpdates = []
-    | Cons
-        lhs.libUpdates = @hd.libUpdates
-
-{-
-
-in the individual sem parts, we set four values:
-idlookups : [(string,type)] pairs for all the unqualified ids which will be in scope coming out of the tref
-qidlookups: [(string, [(string,type)])] for all the qualified ids
-starexpansion: to expand unqualified *
-qstarexpansion: to expand qualified *
-(we need idlookups and starexpansion because of pg system columns,
-which are a serious pain to deal with).
-
-These are set as local vars, because we need to feed the resultant lib
-update into the on expressions in joins lower down, which we can't do
-directly with a syn attribute, so we collect them in locals, the
-combined the in a local for libupdates. We copy all the parts and the
-lib updates to regular attributes so we can access them from other
-sems (the components (idlookups, etc.) are needed in working out joins
-attributes, and the libupdate is used in the join expression, so all
-this extra copying is only needed to support joins).
-
-in each part, we collect errors in the errs local which we can then
-add to the annotation for the node. when this happens, further type
-checking in the select statement should stop but this isn't properly
-implemented yet (this is to avoid too many type errors all over the
-tree resulting from one mistake - a user friendliness consideration)
-
--}
-
-SEM TableRef
-    | SubTref Tref TrefFun JoinedTref
-        loc.idLookups : {[(String,Type)]}
-        loc.qidLookups : {[(String,[(String,Type)])]}
-        loc.starExpansion : {[(String,Type)]}
-        loc.qstarExpansion : {[(String,[(String,Type)])]}
-        loc.libUpdates = if null @errs
-                           then [LibStackIDs $ ("", @loc.idLookups): @loc.qidLookups
-                                ,LibSetStarExpansion $ ("", @loc.starExpansion): @loc.qstarExpansion]
-                           else []
-
-ATTR TableRef [jlibUpdates: {[LocalIdentifierBindingsUpdate]}||]
-
-{-
-
-similar sort of pattern for each sem:
-forward the errs
-get the information we need to fill in the lookups and expansions as an either
-fill in the lookups and expansions
-
--}
-SEM TableRef
-    | SubTref
-        loc.errs = case @loc.selectAttrs of
-                           Left e -> e
-                           Right _ -> []
-        loc.selectAttrs : {Either [TypeError] [(String,Type)]}
-        loc.selectAttrs = unwrapSetOfComposite (getTypeAnnotation @sel.annotatedTree)
-
-        loc.idLookups = fromRight [] @loc.selectAttrs
-        loc.qidLookups = [(getAlias "" @alias.annotatedTree, @loc.idLookups)]
-        loc.starExpansion = @loc.idLookups
-        loc.qstarExpansion = @loc.qidLookups
-
-    | Tref
-        loc.errs = case @loc.relType of
-                     Left e -> e
-                     Right _ -> []
-        loc.relType : {Either [TypeError] ([(String, Type)], [(String, Type)])}
-        loc.relType = catCompositeAttrsPair @lhs.cat [] @tbl
-        loc.relType1 = fromRight ([],[]) @loc.relType
-        loc.pAttrs = fst @loc.relType1
-        loc.sAttrs = snd @loc.relType1
-
-        loc.idLookups = @loc.pAttrs ++ @loc.sAttrs
-        loc.alias = getAlias @tbl @alias.annotatedTree
-        loc.qidLookups = [(@loc.alias, @loc.idLookups)]
-        loc.starExpansion = @loc.pAttrs
-        loc.qstarExpansion = [(@loc.alias, @loc.pAttrs)]
-
-    | TrefFun
-        loc.errs = case @eqfunIdens of
-                     Left e -> e
-                     Right _ -> []
-        loc.eqfunIdens : {Either [TypeError] (String,[(String,Type)])}
-        loc.eqfunIdens = funIdens @lhs.cat @loc.alias @fn.annotatedTree
-        loc.qfunIdens = fromRight ("",[]) @loc.eqfunIdens
-        loc.alias2 = fst @loc.qfunIdens
-        loc.funIdens = snd @loc.qfunIdens
-        loc.alias = getAlias "" @alias.annotatedTree
-
-        loc.idLookups = @loc.funIdens
-        loc.qidLookups = [(@alias2, @loc.idLookups)]
-        loc.starExpansion = @loc.idLookups
-        loc.qstarExpansion = @loc.qidLookups
-    | JoinedTref
-        loc.errs = fromLeft [] @loc.ejoinAttrs
-        loc.removeJoinAttrs = filter (\(n,_) -> n `notElem` @loc.joinNames)
-        --the main meat: find out the name and types of all the common
-        -- join attributes that need to be combined in the result
-        -- (this is all the attributes which appear in both tables in
-        -- the case of a natural join, or all the attributes appearing
-        -- in the join list in the case of a using join.  for other
-        -- joins, this list is empty
-        -- all the attributes which don't appear in this list just
-        -- get added together so we don't need to worry about them
-        loc.ejoinAttrs : {Either [TypeError] [(String,Type)]}
-        loc.ejoinAttrs =
-            do
-            -- get the names of the join columns
-            let jns = case (@nat.annotatedTree, @onExpr.originalTree) of
-                          (Natural, _) -> commonFieldNames
-                          (_,Just (JoinUsing _ s)) -> s
-                          _ -> []
-                --make sure these columns appear in both tables
-                tjtsm = map (flip lookup @tbl.idLookups) jns
-                t1jtsm = map (flip lookup @tbl1.idLookups) jns
-            errorWhen (not $ null $ filter (==Nothing) $ tjtsm ++ t1jtsm)
-                      [MissingJoinAttribute]
-            let tjts = catMaybes tjtsm -- should be no nothings at this stage
-                t1jts = catMaybes t1jtsm
-                -- find the types of these columns - this uses the result set
-                -- type resolution (see typeconversion.lhs for more details
-                -- and the relevant link to the pg manual
-                resolvedTypes :: [Either [TypeError] Type]
-                resolvedTypes = map (\(a,b) -> resolveResultSetType @lhs.cat [a,b]) $ zip tjts t1jts
-            liftErrors $ concat $ lefts resolvedTypes
-            return $ zip jns $ rights resolvedTypes
-            where
-              commonFieldNames = intersect (f @tbl.starExpansion) (f @tbl1.starExpansion)
-                                 where f = map fst
-        loc.joinNames = map fst @loc.joinAttrs
-        loc.joinAttrs = fromRight [] @loc.ejoinAttrs
-
-        --this is where we use the joinAttrs to filter the lookups and
-        --expansions: stick the joinattrs at the start
-        -- and add the other two lists minus the join attributes
-        loc.idLookups = @loc.joinAttrs ++
-                          @loc.removeJoinAttrs @tbl.idLookups ++
-                          @loc.removeJoinAttrs @tbl1.idLookups
-        loc.qidLookups = @tbl.qidLookups ++ @tbl1.qidLookups
-        loc.starExpansion = @loc.joinAttrs ++
-                              @loc.removeJoinAttrs @tbl.starExpansion ++
-                              @loc.removeJoinAttrs @tbl1.starExpansion
-        loc.qstarExpansion = @tbl.qstarExpansion ++ @tbl1.qstarExpansion
-
-        -- we need the attributes from the joined tables to be available
-        -- in the join expression.
-        loc.newLib = case updateBindings @lhs.lib @lhs.cat (@loc.libUpdates ++ @lhs.jlibUpdates) of
-                       Left x -> error $ show x
-                       Right e -> {-trace ("on expr lib:" ++ show e)-} e
-        onExpr.lib = @loc.newLib
-        --need to pass this into nested joins also
-        tbl.jlibUpdates = @loc.libUpdates
-        tbl1.jlibUpdates = @loc.libUpdates
-
-
-SEM TableRefList
-    | Cons hd.jlibUpdates = []
-
-
-{
-{-
-convert a function call into a [String,[(string,type)]] list for use
-in a tableref context
-first consideration is the alias: if there is an alias in the select,
-e.g. select * from generate_series(1,2) x;  (alias is x)
-we use that, otherwise we use the name of the function
-second consideration is the attributes coming out, roughly speaking
-we have to convert an arbitrary type to a relation type
-if we have a relation valued function, we don't need to do anything
-if we have a setof non composite, we lift the single type to an
-attribute, using the function name for the attribute name
-if we have a non setof, we lift the single type to an attribute and
-then relation, using the function name for the attribute name
-need to check to see what should happen with arrayof
-
--}
-funIdens :: Catalog -> String -> Expression -> Either [TypeError] (String,[(String,Type)])
-funIdens cat alias fnVal = do
-   errorWhen (case fnVal of
-                FunCall _ _ _ -> False
-                _ -> True)
-             [ContextError "FunCall"]
-   let (FunCall _ fnName _) = fnVal
-       correlationName = if alias /= ""
-                           then alias
-                           else fnName
-   attrs <- do
-     case getTypeAnnotation fnVal of
-       SetOfType (NamedCompositeType t) -> catCompositePublicAttrs cat [] t
-       SetOfType x -> return [(correlationName,x)]
-       y -> return [(correlationName,y)]
-   return (correlationName, attrs)
-
-getAlias :: String -> TableAlias -> String
-getAlias def alias =
-  case alias of
-    NoAlias -> def
-    TableAlias t -> t
-    FullAlias t _ -> t
-
-}
-
--- boilerplate
--- copying the locals to syn attrs
-
-SEM TableRef
-    | SubTref Tref TrefFun JoinedTref
-        lhs.libUpdates = @loc.libUpdates
-        lhs.idLookups = @loc.idLookups
-        lhs.qidLookups = @loc.qidLookups
-        lhs.starExpansion = @loc.starExpansion
-        lhs.qstarExpansion = @loc.qstarExpansion
-
--- backtrees
-
-SEM TableRef
-    | SubTref
-        loc.backTree = SubTref @ann @sel.annotatedTree @alias.annotatedTree
-    | Tref
-        loc.backTree = Tref @ann @tbl @alias.annotatedTree
-    | TrefFun
-        loc.backTree = TrefFun @ann @fn.annotatedTree @alias.annotatedTree
-    | JoinedTref
-        loc.backTree = JoinedTref @ann
-                                  @tbl.annotatedTree
-                                  @nat.annotatedTree
-                                  @joinType.annotatedTree
-                                  @tbl1.annotatedTree
-                                  @onExpr.annotatedTree
-                                  @alias.annotatedTree
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/TypeChecking.ag b/Database/HsSqlPpp/AstInternals/TypeChecking/TypeChecking.ag
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/TypeChecking.ag
+++ /dev/null
@@ -1,235 +0,0 @@
-{-
-Copyright 2009 Jake Wheat
-
-This file contains the attr and sem definitions, which do the type
-checking, etc..
-
-A lot of the haskell code has been moved into other files:
-TypeCheckingH, AstUtils.lhs, it is intended that only small amounts of
-code appear (i.e. one-liners) inline in this file, and larger bits go
-in AstUtils.lhs. These are only divided because the attribute grammar
-system uses a custom syntax with a custom preprocessor. These
-guidelines aren't followed very well.
-
-The current type checking approach doesn't quite match how SQL
-works. The main problem is that you can e.g. exec create table
-statements inside a function. This is something that the type checker
-will probably not be able to deal for a while if ever. (Will need
-hooks into postgresql to do this properly, which might not be
-impossible...).
-
-Once most of the type checking is working, all the code and
-documentation will be overhauled quite a lot. Alternatively put, this
-code is in need of better documentation and organisation, and serious
-refactoring.
-
-An unholy mixture of Maybe, Either, Either/Error Monad and TypeCheckFailed
-is used to do error handling.
-
-One of the common patterns is when type checking a node:
-
-first check any types of subnodes which it depends on, if any are
-typecheckfailed, then this node's type is typecheckfailed and we stop
-there.
-
-otherwise, calculate the type of this node, or get an error if there
-is a problem, this is put into loc.tpe which is Either TypeError
-Type. Then some common code takes this value and sets the node type to
-the type or typecheckfailed if tpe is left, and if it is left add a
-type error annotation also.
-
-================================================================================
-
-= main attributes used
-
-Here are the main attributes used in the type checking:
-
-cat is used to chain the catalogs up and down the tree, to allow
-access to the catalog information, and to store the in catalog
-identifier names and types e.g. inside a select expression.
-
-annotatedTree is used to create a copy of the ast with the type,
-etc. annotations.
-
--}
-ATTR AllNodes Root ExpressionRoot
-  [ cat : Catalog
-    lib : LocalIdentifierBindings || annotatedTree : SELF
-                                     -- workaround: avoid bogus cycle
-                                     -- detections search for this,
-                                     -- replace with annotated tree
-                                     -- and uuagc can't tell that
-                                     -- there aren't any real cycles
-                                     originalTree : SELF]
-
-
-
-INCLUDE "TypeChecking/Misc.ag"
-INCLUDE "TypeChecking/Expressions.ag"
-INCLUDE "TypeChecking/Statements.ag"
-
-
-{-
-
-old stuff:
-
-================================================================================
-
-= static tests
-
-Try to use a list of message data types to hold all sorts of
-information which works its way out to the top level where the client
-code gets it. Want to have the lists concatenated together
-automatically from subnodes to parent node, and then to be able to add
-extra messages to this list at each node also.
-
-Problem 1: can't have two sem statements for the same node type which
-both add messages, and then the messages get combined to provide the
-final message list attribute value for that node. You want this so
-that e.g. that different sorts of checks appear in different
-sections. Workaround is instead of having each check in it's own
-section, to combine them all into one SEM. Can work around this
-without too much difficulty by using local attributes. Not sure if
-something more clever would be an improvement.
-
-Problem 2: no shorthand to combine what the default rule for messages
-would be and then add a bit extra - so if you want all the children
-messages, plus possibly an extra message or two, have to write out the
-default rule in full explicitly. Can get round this by writing out
-loads of code, which is error prone. Don't know if there is a better way
-
-================================================================================
-
-= inloop testing
-
-inloop - use to check continue, exit, and other commands that can only
-appear inside loops (for, while, loop)
-
-the only nodes that really need this attribute are the ones which can
-contain statements
-
-The inloop test is the only thing which uses the messages atm. It
-shouldn't, at some point inloop testing will become part of the type
-checking.
-
-This is just some example code, will probably do something a lot more
-heavy weight like symbolic interpretation - want to do all sorts of
-loop, return, nullability, etc. analysis.
-
--}
-{-
-ATTR AllNodes Root ExpressionRoot [||messages USE {++} {[]} : {[Message]}]
-
-ATTR AllNodes
-  [ inLoop: Bool||]
-
-SEM Root
-  | Root statements.inLoop = False
-
-SEM ExpressionRoot
-  | ExpressionRoot expr.inLoop = False
-
--- set the inloop stuff which nests, it's reset inside a create
--- function statement, in case you have a create function inside a
--- loop, seems unlikely you'd do this though
-
-SEM Statement
-     | ForSelectStatement ForIntegerStatement WhileStatement sts.inLoop = True
-     | CreateFunction body.inLoop = False
-
--- now we can check when we hit a continue statement if it is in the
--- right context
-SEM Statement
-    | ContinueStatement  lhs.messages = if not @lhs.inLoop
-                                          then [Error ContinueNotInLoop]
-                                          else []
--}
-{-
-================================================================================
-
-= notes and todo
-
-
-containment guide for select expressions:
-combineselect 2 selects
-insert ?select
-createtableas 1 select
-createview 1 select
-return query 1 select
-forselect 1 select
-select->subselect select
-expression->exists select
-            scalarsubquery select
-            inselect select
-
-containment guide for statements:
-forselect [statement]
-forinteger [statement]
-while [statement]
-casestatement [[statement]]
-if [[statement]]
-createfunction->fnbody [Statement]
-
-TODO
-
-some non type-check checks:
-check plpgsql only in plpgsql function
-orderby in top level select only
-copy followed immediately by copydata iff stdin, copydata only follows
-  copy from stdin
-count args to raise, etc., check same number as placeholders in string
-no natural with onexpr in joins
-typename -> setof (& fix parsing), what else like this?
-expressions: positionalarg in function, window function only in select
- list top level
-
-review all ast checks, and see if we can also catch them during
-parsing (e.g. typeName parses setof, but this should only be allowed
-for a function return, and we can make this a parse error when parsing
-from source code rather than checking a generated ast. This needs
-judgement to say whether a parse error is better than a check error, I
-think for setof it is, but e.g. for a continue not in a loop (which
-could be caught during parsing) works better as a check error, looking
-at the error message the user will get. This might be wrong, haven't
-thought too carefully about it yet).
-
-
-TODO: canonicalize ast process, as part of type checking produces a
-canonicalized ast which:
-all implicit casts appear explicitly in the ast (maybe distinguished
-from explicit casts?)
-all names fully qualified
-all types use canonical names
-literal values and selectors in one form (use row style?)
-nodes are tagged with types
-what else?
-
-Canonical form only defined for type consistent asts.
-
-This canonical form should pretty print and parse back to the same
-form, and type check correctly.
-
-
-================================================================================
-
-type inferencing
-
-some random ideas about using type inferencing
-
-1) need to be able to gather the constraints: introduce a variable
-   name for each node that has a type collect together all the
-   equations that relate these variables
-2) need to be able to unify these to get types or errors
-3) need to rebuild the tree containing the results of this process in
-   the annotations, either types or errors
-
-possible issues, don't know how these will affect the process:
-
-literal strings in pg have the type unknown as well as possibly a real
-type determined by inference
-the implicit type casting e.g. for function resolution is pretty wacky
-combinining these, function call resolution apparently distinguishes
-between arguments which are unknown and then resolve to being text,
-and arguments which are already known to be text, e.g.
-
--}
diff --git a/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs b/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs
+++ /dev/null
@@ -1,571 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains the functions for resolving types and
-function/operator resolution. See the pg manual chapter 10:
-
-http://www.postgresql.org/docs/8.4/interactive/typeconv.html
-
-This code is really spaghettified.
-
-findCallMatch - pass in a name and a list of arguments, and it returns
-the matching function. (pg manual 10.2,10.3)
-
-resolveResultSetType - pass in a set of types, and it tries to find
-the common type they can all be cast to. (pg manual 10.5)
-
-checkAssignmentValid - pass in source type and target type, returns
-                typelist[] if ok, otherwise error, pg manual 10.4
-                Value Storage
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion (
->                        findCallMatch
->                       ,resolveResultSetType
->                       ,checkAssignmentValid
->                       ,compositesCompatible
->                       ) where
-
-> import Data.Maybe
-> import Data.List
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.AstInternals.TypeType
-> import Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
-> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-> import Database.HsSqlPpp.Utils
-
- > traceIt :: Show a => String -> a -> a
- > traceIt s t = trace (s ++ ": " ++ show t) t
-
-= findCallMatch
-
-findCallMatch - partially implements the type conversion rules for
-finding an operator or function match given a name and list of
-arguments with partial or fully specified types
-
-TODO:, qualifiers
-namespaces
-function style casts not in catalog
-variadic args
-default args
-domains -> base type
-what about aggregates and window functions?
-
-Algo:
-
-cands = all fns with matching names
-        and same number of args
-
-if exact match on types in this list, use it
-  (if binary operator being matched, and one arg is typed and one is
-  unknown, also match an operator by assuming the unknown is the same
-  as the typed arg)
-
-best match part:
-
-filter cands with args which don't exactly match input args, and input
-args cannot be converted by an implicit cast. unknowns count as
-matching anything
-if one left: use it
-
-filter for preferred types:
-
-for each cand, count each arg at each position which needs conversion,
-and the cand type is a preferred type at that position.
-if there are cands with count>0, keep only cands with the max count,
-if one return it
-if there are no cands with count>0, keep them all
-
-check unknowns:
-if any input args are unknown, and any cand accepts string at that
-position, fix that arg's category as string, otherwise if all cands
-accept same category at that position, fix that input args as that
-category.
-if we still have unknowns, then fail
-
-discard cands which don't match the new input arg/category list
-
-for each categorised input arg, if any cand accepts preferred type at
-that position, get rid of cands which don't accept preferred type at
-that position
-
-if one left: use
-else fail
-
-polymorphic matching:
-want to create a set of matches to insert into the cast pairs list
-so:
-
-find all matches on name, num args and have polymorphic parameters
-
-for each one, check the polymorphic categories - eliminate fns that
-have params in wrong category - array, non array, enum.
-work out the base types for the polymorphic args at each spot based on
-the args passed - so each arg is unchanged except arrays which have
-the array part stripped off
-
-now we have a list of types to match against the polymorphic params,
-use resolveResultSetType to see if we can produce a match, if so,
-create a new prototype which is the same as the polymorphic function
-but with this matching arg swapped in, work out the casts and add it
-into cand cast pairs, after exact match has been run.
-
-
-findCallMatch is a bit of a mess
-
-todos:
-
-rewrite this to try to make it a bit clearer
-
-find some way to draw a data flow diagram of the code easily
-
-add a logging facility so the function can explain what has happened
-at each state, so you can provide a detailed explanation e.g. if the
-code can't find an operator match to see what it has tried to match
-against.
-
-> type ProtArgCast = (FunctionPrototype, [ArgCastFlavour])
-
-> findCallMatch :: Catalog -> String -> [Type] ->  Either [TypeError] FunctionPrototype
-> findCallMatch cat f inArgs =
->     returnIfOnne [
->        exactMatch
->       ,binOp1UnknownMatch
->       ,polymorpicExactMatches
->       ,reachable
->       ,mostExactMatches
->       ,filteredForPreferred
->       ,unknownMatchesByCat]
->       [NoMatchingOperator f inArgs]
->     where
->       -- basic lists which roughly mirror algo
->       -- get the possibly matching candidates
->       initialCandList :: [FunctionPrototype]
->       initialCandList = filter (\(_,candArgs,_,_) ->
->                                   length candArgs == length inArgs) $
->                                map expandVariadic $ catLookupFns cat f
->
->       expandVariadic fp@(fn,a,r,v) =
->         if v
->           then case last a of
->                  ArrayType t -> (fn, na,r,v)
->                                 where na = init a ++ replicate (length inArgs - length a + 1) t
->                  _ -> fp --should be error
->           else fp
->
->       -- record what casts are needed for each candidate
->       castPairs :: [[ArgCastFlavour]]
->       castPairs = map (listCastPairs . getFnArgs) initialCandList
->
->       candCastPairs :: [ProtArgCast]
->       candCastPairs = {-traceIt "candCastPairs" $-} zip initialCandList castPairs
->
->       -- see if we have an exact match
->       exactMatch :: [ProtArgCast]
->       exactMatch = filterCandCastPairs (all (==ExactMatch)) candCastPairs
->
->       -- implement the one known, one unknown resolution for binary operators
->       binOp1UnknownMatch :: [ProtArgCast]
->       binOp1UnknownMatch = getBinOp1UnknownMatch candCastPairs
->
->       --collect possible polymorphic matches
->       polymorphicMatches :: [ProtArgCast]
->       polymorphicMatches = filterPolymorphics candCastPairs
->
->       polymorpicExactMatches :: [ProtArgCast]
->       polymorpicExactMatches = filterCandCastPairs (all (==ExactMatch)) polymorphicMatches
->
->       -- eliminate candidates for which the inargs cannot be casted to
->       reachable :: [ProtArgCast]
->       reachable = mergePolys (filterCandCastPairs (none (==CannotCast)) candCastPairs)
->                     polymorphicMatches
->
->       mostExactMatches :: [ProtArgCast]
->       mostExactMatches =
->         let inArgsBase = map (replaceWithBase cat) inArgs
->             exactCounts :: [Int]
->             exactCounts =
->               map ((length
->                       . filter (\(a1,a2) -> a1==replaceWithBase cat a2)
->                       . zip inArgsBase)
->                 . (\((_,a,_,_),_) -> a)) reachable
->             pairs = zip reachable exactCounts
->             maxm = maximum exactCounts
->         in case () of
->              _ | null reachable -> []
->                | maxm > 0 -> map fst $ filter (\(_,b) -> b == maxm) pairs
->                | otherwise -> []
->
->       -- keep the cands with the most casts to preferred types
->       preferredTypesCounts = countPreferredTypeCasts reachable
->       keepCounts = maximum preferredTypesCounts
->       itemCountPairs :: [(ProtArgCast,Int)]
->       itemCountPairs = zip reachable preferredTypesCounts
->       filteredForPreferred :: [ProtArgCast]
->       filteredForPreferred = map fst $ filter (\(_,i) -> i == keepCounts) itemCountPairs
->
->       -- collect the inArg type categories to do unknown inArg resolution
->       argCats :: [Either () String]
->       argCats = getCastCategoriesForUnknowns filteredForPreferred
->       unknownMatchesByCat :: [ProtArgCast]
->       unknownMatchesByCat = getCandCatMatches filteredForPreferred argCats
->
->       -------------
->
->       listCastPairs :: [Type] -> [ArgCastFlavour]
->       listCastPairs l = listCastPairs' inArgs l
->                         where
->                           listCastPairs' :: [Type] -> [Type] -> [ArgCastFlavour]
->                           listCastPairs' (ia:ias) (ca:cas) =
->                               (case () of
->                                  _ | ia == ca -> ExactMatch
->                                    | castableFromTo cat ImplicitCastContext ia ca ->
->                                        if forceRight (catPreferredType cat ca)
->                                          then ImplicitToPreferred
->                                          else ImplicitToNonPreferred
->                                    | otherwise -> CannotCast
->                               ) : listCastPairs' ias cas
->                           listCastPairs' [] [] = []
->                           listCastPairs' _ _ = error "internal error: mismatched num args in implicit cast algorithm"
->
->
->       getBinOp1UnknownMatch :: [ProtArgCast] -> [ProtArgCast]
->       getBinOp1UnknownMatch cands =
->           if not (isOperatorName f &&
->                   length inArgs == 2 &&
->                   count (==UnknownType) inArgs == 1)
->             then []
->             else let newInArgs =
->                          replicate 2 (if head inArgs == UnknownType
->                                         then inArgs !! 1
->                                         else head inArgs)
->                  in filter (\((_,a,_,_),_) -> a == newInArgs) cands
->
->       filterPolymorphics :: [ProtArgCast] -> [ProtArgCast]
->       filterPolymorphics cl =
->           let ms :: [ProtArgCast]
->               ms = filter canMatch polys
->               polyTypes :: [Maybe Type]
->               polyTypes = map resolvePolyType ms
->               polyTypePairs :: [(Maybe Type, ProtArgCast)]
->               polyTypePairs = zip polyTypes ms
->               keepPolyTypePairs :: [(Type, ProtArgCast)]
->               keepPolyTypePairs =
->                 mapMaybe (\(t,p) -> case t of
->                                            Nothing -> Nothing
->                                            Just t' -> Just (t',p))
->                               polyTypePairs
->               finalRows = map (\(t,p) -> instantiatePolyType p t)
->                               keepPolyTypePairs
->               --create the new cast lists
->               cps :: [[ArgCastFlavour]]
->               cps = map (listCastPairs . getFnArgs . fst) finalRows
->           in zip (map fst finalRows) cps
->           where
->             polys :: [ProtArgCast]
->             polys = filter (\((_,a,_,_),_) -> any (`elem`
->                                              [Pseudo Any
->                                              ,Pseudo AnyArray
->                                              ,Pseudo AnyElement
->                                              ,Pseudo AnyEnum
->                                              ,Pseudo AnyNonArray]) a) cl
->             canMatch :: ProtArgCast -> Bool
->             canMatch pac =
->                let ((_,fnArgs,_,_),_) = pac
->                in canMatch' inArgs fnArgs
->                where
->                  canMatch' [] [] = True
->                  canMatch' (ia:ias) (pa:pas) =
->                    case pa of
->                      Pseudo Any -> nextMatch
->                      Pseudo AnyArray -> isArrayType ia && nextMatch
->                      Pseudo AnyElement -> nextMatch
->                      Pseudo AnyEnum -> False
->                      Pseudo AnyNonArray -> if isArrayType ia
->                                              then False
->                                              else nextMatch
->                      _ -> True
->                    where
->                      nextMatch = canMatch' ias pas
->                  canMatch' _ _ = error "internal error: mismatched lists in canMatch'"
->             resolvePolyType :: ProtArgCast -> Maybe Type
->             resolvePolyType ((_,fnArgs,_,_),_) =
->                 {-trace ("\nresolving " ++ show fnArgs ++ " against " ++ show inArgs ++ "\n") $-}
->                 let argPairs = zip inArgs fnArgs
->                     typeList :: [Type]
->                     typeList = catMaybes $ flip map argPairs
->                                  (\(ia,fa) -> case fa of
->                                                   Pseudo Any -> if isArrayType ia
->                                                                          then eitherToMaybe $ unwrapArray ia
->                                                                          else Just ia
->                                                   Pseudo AnyArray -> eitherToMaybe $ unwrapArray ia
->                                                   Pseudo AnyElement -> if isArrayType ia
->                                                                          then eitherToMaybe $ unwrapArray ia
->                                                                          else Just ia
->                                                   Pseudo AnyEnum -> Nothing
->                                                   Pseudo AnyNonArray -> Just ia
->                                                   _ -> Nothing)
->                 in {-trace ("\nresolve types: " ++ show typeList ++ "\n") $-}
->                    case resolveResultSetType cat typeList of
->                      Left _ -> Nothing
->                      Right t -> Just t
->             instantiatePolyType :: ProtArgCast -> Type -> ProtArgCast
->             instantiatePolyType pac t =
->               let ((fn,a,r,v),_) = pac
->                   instArgs = swapPolys t a
->                   p1 = (fn, instArgs, swapPoly t r,v)
->               in let x = (p1,listCastPairs instArgs)
->                  in {-trace ("\nfixed:" ++ show x ++ "\n")-} x
->               where
->                 swapPolys :: Type -> [Type] -> [Type]
->                 swapPolys = map . swapPoly
->                 swapPoly :: Type -> Type -> Type
->                 swapPoly pit at =
->                   case at of
->                     Pseudo Any -> if isArrayType at
->                                     then ArrayType pit
->                                     else pit
->                     Pseudo AnyArray -> ArrayType pit
->                     Pseudo AnyElement -> if isArrayType at
->                                            then ArrayType pit
->                                            else pit
->                     Pseudo AnyEnum -> pit
->                     Pseudo AnyNonArray -> pit
->                     _ -> at
->       --merge in the instantiated poly functions, with a twist:
->       -- if we already have the exact same set of args in the non poly list
->       -- as a poly, then don't include that poly
->       mergePolys :: [ProtArgCast] -> [ProtArgCast] -> [ProtArgCast]
->       mergePolys orig polys =
->           let origArgs = map (\((_,a,_,_),_) -> a) orig
->               filteredPolys = filter (\((_,a,_,_),_) -> a `notElem` origArgs) polys
->           in orig ++ filteredPolys
->
->       countPreferredTypeCasts :: [ProtArgCast] -> [Int]
->       countPreferredTypeCasts =
->           map (\(_,cp) -> count (==ImplicitToPreferred) cp)
->
->       -- Left () is used for inArgs which aren't unknown,
->       --                      and for unknowns which we don't have a
->       --                      unique category
->       -- Right s -> s is the single letter category at
->       --                           that position
->       getCastCategoriesForUnknowns :: [ProtArgCast] -> [Either () String]
->       getCastCategoriesForUnknowns cands =
->           filterArgN 0
->           where
->             candArgLists :: [[Type]]
->             candArgLists = map (\((_,a,_,_), _) -> a) cands
->             filterArgN :: Int -> [Either () String]
->             filterArgN n =
->                 if n == length inArgs
->                   then []
->                   else let targType = inArgs !! n
->                        in ((if targType /= UnknownType
->                               then Left ()
->                               else getCandsCatAt n) : filterArgN (n+1))
->                 where
->                   getCandsCatAt :: Int -> Either () String
->                   getCandsCatAt n' =
->                       let typesAtN = map (!!n') candArgLists
->                           catsAtN = map (forceRight . catTypeCategory cat) typesAtN
->                       in case () of
->                            --if any are string choose string
->                            _ | any (== "S") catsAtN -> Right "S"
->                              -- if all are same cat choose that
->                              | all (== head catsAtN) catsAtN -> Right $ head catsAtN
->                              -- otherwise no match, this will be
->                              -- picked up as complete failure to match
->                              -- later on
->                              | otherwise -> Left ()
->
->       getCandCatMatches :: [ProtArgCast] -> [Either () String] -> [ProtArgCast]
->       getCandCatMatches candsA cats = getMatches candsA 0
->          where
->            getMatches :: [ProtArgCast] -> Int -> [ProtArgCast]
->            getMatches cands n =
->                case () of
->                  _ | n == length inArgs -> cands
->                    | (inArgs !! n) /= UnknownType -> getMatches cands (n + 1)
->                    | otherwise ->
->                        let catMatches :: [ProtArgCast]
->                            catMatches = filter (\c -> Right (getCatForArgN n c) ==
->                                                      (cats !! n)) cands
->                            prefMatches :: [ProtArgCast]
->                            prefMatches = filter (forceRight . catPreferredType cat .
->                                                    getTypeForArgN n) catMatches
->                            keepMatches :: [ProtArgCast]
->                            keepMatches = if length prefMatches > 0
->                                            then prefMatches
->                                            else catMatches
->                        in getMatches keepMatches (n + 1)
->            getTypeForArgN :: Int -> ProtArgCast -> Type
->            getTypeForArgN n ((_,a,_,_),_) = a !! n
->            getCatForArgN :: Int -> ProtArgCast -> String
->            getCatForArgN n = forceRight . catTypeCategory cat . getTypeForArgN n
->
->       -- utils
->       -- filter a candidate/cast flavours pair by a predicate on each
->       -- individual cast flavour
->       filterCandCastPairs :: ([ArgCastFlavour] -> Bool)
->                           -> [ProtArgCast]
->                           -> [ProtArgCast]
->       filterCandCastPairs predi = filter (\(_,cp) -> predi cp)
->
->       getFnArgs :: FunctionPrototype -> [Type]
->       getFnArgs (_,a,_,_) = a
->       returnIfOnne [] e = Left e
->       returnIfOnne (l:ls) e = if length l == 1
->                               then Right $ getHeadFn l
->                               else returnIfOnne ls e
->
->       getHeadFn :: [ProtArgCast] -> FunctionPrototype
->       getHeadFn l =  let ((hdFn, _):_) = l
->                      in hdFn
->       none p = not . any p
->       count p = length . filter p
->
-> data ArgCastFlavour = ExactMatch
->                     | CannotCast
->                     | ImplicitToPreferred
->                     | ImplicitToNonPreferred
->                       deriving (Eq,Show)
->
-
-resolveResultSetType -
-partially implement the typing of results sets where the types aren't
-all the same and not unknown
-used in union,except,intersect columns, case, array ctor, values, greatest and least
-
-algo:
-if all inputs are same and not unknown -> that type
-replace domains with base types
-if all inputs are unknown then text
-if the non unknown types aren't all in same category then fail
-choose first input type that is a preferred type if there is one
-choose last non unknown type that has implicit casts from all preceding inputs
-check all can convert to selected type else fail
-
-code is not as much of a mess as findCallMatch
-
-> resolveResultSetType :: Catalog -> [Type] -> Either [TypeError] Type
-> resolveResultSetType cat inArgs =
->   dependsOnRTpe inArgs $ do
->   errorWhen (null inArgs) [TypelessEmptyArray]
->   returnWhen allSameType (head inArgs) $ do
->   returnWhen allSameBaseType (head inArgsBase) $ do
->   --returnWhen allUnknown (UnknownType) $ do
->   errorWhen (not allSameCat) [IncompatibleTypeSet inArgs]
->   returnWhen (isJust targetType &&
->               allConvertibleToFrom (fromJust targetType) inArgs)
->               (fromJust targetType) $ do
->   Left [IncompatibleTypeSet inArgs]
->   where
->      allSameType = all (== head inArgs) inArgs -- &&
->                      --head inArgs /= UnknownType
->      allSameBaseType = all (== head inArgsBase) inArgsBase &&
->                      head inArgsBase /= UnknownType
->      inArgsBase = map (replaceWithBase cat) inArgs
->      --allUnknown = all (==UnknownType) inArgsBase
->      allSameCat = let firstCat = catTypeCategory cat (head knownTypes)
->                   in all (\t -> catTypeCategory cat t == firstCat)
->                          knownTypes
->      targetType = case catMaybes [firstPreferred, lastAllConvertibleTo] of
->                     [] -> Nothing
->                     (x:_) -> Just x
->      firstPreferred = find (forceRight . catPreferredType cat) knownTypes
->      lastAllConvertibleTo = firstAllConvertibleTo (reverse knownTypes)
->      firstAllConvertibleTo (x:xs) = if allConvertibleToFrom x xs
->                                       then Just x
->                                       else firstAllConvertibleTo xs
->      firstAllConvertibleTo [] = Nothing
->      knownTypes = filter (/=UnknownType) inArgsBase
->      allConvertibleToFrom = all . flip (castableFromTo cat ImplicitCastContext)
-
-todo:
-cast empty array, where else can an empty array work?
-
-================================================================================
-
-= checkAssignmentValue
-
-> checkAssignmentValid :: Catalog -> Type -> Type -> Either [TypeError] ()
-> checkAssignmentValid cat from to =
->     if castableFromTo cat AssignmentCastContext from to
->        then Right ()
->        else Left [IncompatibleTypes to from]
-
-> compositesCompatible :: Catalog -> Type -> Type -> Bool
-> compositesCompatible cat =
->     castableFromTo cat ImplicitCastContext
-
-================================================================================
-
-= castable function
-
-wrapper around the catalog to add a bunch of extra valid casts
-
-> castableFromTo :: Catalog -> CastContext -> Type -> Type -> Bool
-> castableFromTo cat cc from to =
->   {-trace ("check cast " ++ show from ++ "->" ++ show to) $-}
->   -- put this here to avoid having to write it everywhere else
->   from == to
->   -- unknown can be implicitly cast to anything (is this completely true?)
->   || from == UnknownType
->   --hack?
->   || to == UnknownType
->   -- check base types of domains
->   || ((isDomainType from || isDomainType to)
->       && castableFromTo cat cc (replaceWithBase cat from)
->                                (replaceWithBase cat to))
->   -- check the casts listed in the catalog
->   || forceRight (catCast cat cc from to)
->   -- implicitcast => assignment cast
->   || (cc == AssignmentCastContext
->       && forceRight (catCast cat ImplicitCastContext from to))
->   -- can assign composite to record
->   || (cc == AssignmentCastContext
->       && isCompOrSetoOfComp from
->       && case to of
->            PgRecord _ -> True
->            _ -> False)
->   -- check unboxing: wrapped single attribute
->   || recurseTransFrom (unboxedSingleType from)
->   || recurseTransTo (unboxedSingleType to)
->   -- check unboxing: wrapped composite
->   || recurseTransFrom (unboxedSetOfType from)
->   || recurseTransTo (unboxedSetOfType to)
->   -- check composites compatible by comparing attribute types
->   || case (getCompositeTypes from
->           ,getCompositeTypes to) of
->        -- zip almost does the right thing here, needs a bit of tweaking
->        (Just ft, Just tt) | length ft == length tt -> all (uncurry $ castableFromTo cat cc) $ zip ft tt
->        _ -> False
->   where
-
->     getCompositeTypes (NamedCompositeType n) =
->         Just $ map snd $ fromRight [] $ catCompositePublicAttrs cat [] n
->     getCompositeTypes (CompositeType t) = Just $ map snd t
->     getCompositeTypes (AnonymousRecordType t) = Just t
->     getCompositeTypes (PgRecord Nothing) = Nothing
->     getCompositeTypes (PgRecord (Just t)) = getCompositeTypes t
->     getCompositeTypes _ = Nothing
-
->     isCompOrSetoOfComp (SetOfType c) = isCompositeType c
->     isCompOrSetoOfComp c = isCompositeType c
-
->     unboxedSingleType (SetOfType (CompositeType [(_,t)])) = Just t
->     unboxedSingleType (PgRecord (Just t)) = unboxedSingleType t
->     unboxedSingleType _ = Nothing
-
->     unboxedSetOfType (SetOfType a) = Just a
->     unboxedSetOfType (PgRecord (Just t)) = unboxedSetOfType t
->     unboxedSetOfType _ = Nothing
-
->     recurseTransFrom = maybe False (flip (castableFromTo cat cc) to)
->     recurseTransTo = maybe False (castableFromTo cat cc from)
-
-> replaceWithBase :: Catalog -> Type -> Type
-> replaceWithBase cat t@(DomainType _) = forceRight $ catDomainBaseType cat t
-> replaceWithBase _ t = t
diff --git a/Database/HsSqlPpp/AstInternals/TypeType.lhs b/Database/HsSqlPpp/AstInternals/TypeType.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/AstInternals/TypeType.lhs
+++ /dev/null
@@ -1,385 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains the data type Type. It is kept separate so we can
-compile the types and function information from the database
-separately to AstInternal.ag.
-
-Types overview:
-
-Regular types: scalarType, arrayType, composite type, domaintype
-we can use these anywhere.
-
-semi first class types: row, unknownstringlit (called unknown in pg) -
-these can be used in some places, but not others, in particular an
-expression can have this type or select can have a row with these
-type, but a view can't have a column with this type (so a select can
-be valid on it's own but not as a view. Not sure if Row types can be
-variables, unknownstringlit definitely can't. (Update, seems a view
-can have a column with type unknown.)
-
-pseudo types - mirror pg pseudo types
-Internal, LanguageHandler, Opaque probably won't ever be properly supported
-Not sure exactly what Any is, can't use it in functions like the other any types?
- - update: seems that Any is like AnyElement, but multiple Anys don't
-   have to have the same type.
-AnyElement, AnyArray, AnyEnum, AnyNonArray - used to implement polymorphic functions,
-  can only be used in these functions as params, return type (and local vars?).
-Cstring - treated as variant of text?
-record -dynamically typed, depends where it is used, i think is used
-for type inference in function return types (so you don't have to
-write the correct type, the compiler fills it in), and as a dynamically
-typed variable in functions, where it can take any composite typed
-value.
-void is used for functions which return nothing
-trigger is a tag to say a function is used in triggers, used as a
-return type only
-typecheckfailed is used to represent the type of anything which the code
-is currently unable to type check, this usage should disappear at some
-point, and then it will only represent code which doesn't type check
-because of a mistake.
-
-The Type type identifies the type of a node, but doesn't necessarily
-describe the type.
-
-Typing relational valued expressions:
-use SetOfType combined with composite type for now, see if it works
-out. If not, will have to add another type.
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> {-# LANGUAGE FlexibleInstances,DeriveDataTypeable #-}
-
-
-> module Database.HsSqlPpp.AstInternals.TypeType where
-
-> import Control.Monad.Error
-
-> import Data.Generics
-> import Data.Generics.PlateData
-
- > import Data.Binary
-
-> data Type = ScalarType String
->           | ArrayType Type
->           | SetOfType Type
->             --three variations, choose better name for rowctor
->             --refer to composite type in catalog
->           | NamedCompositeType String
->             --refer to composite type either in catalog or one generated on fly
->           | CompositeType [(String,Type)]
->             --refer to anonymous composite type: the fields have no names
->             --these three types are equality and assign compatible if the fields
->             --are ignoring the names, so the fields have to be in the same order.
->           | AnonymousRecordType [Type] -- was rowctor
->           | PgRecord (Maybe Type) -- can only hold namedcomposite, composite or anonymousrecord
->           | DomainType String
->           | EnumType String
->           | Pseudo PseudoType
->           | TypeCheckFailed -- represents something which the type checker
->                             -- doesn't know how to type check
->                             -- or it cannot work the type out because of errors
->           | UnknownType -- represents a string literal
->                              -- token whose type isn't yet
->                              -- determined
->             deriving (Eq,Show,Ord,Typeable,Data)
-
-> data PseudoType = Any
->                 | AnyArray
->                 | AnyElement
->                 | AnyEnum
->                 | AnyNonArray
->                 | Cstring
->                 | Record
->                 | Trigger
->                 | Void
->                 | Internal
->                 | LanguageHandler
->                 | Opaque
->                   deriving (Eq,Show,Ord,Typeable,Data)
-
-this list will need reviewing, probably refactor to a completely
-different set of infos, also will want to add more information to
-these, and to provide a way of converting into a user friendly
-string. It is intended for this code to produce highly useful errors
-later on down the line.
-
->                    -- mostly expected,got
-> data TypeError = WrongTypes Type [Type]
->                | UnknownTypeError Type
->                | UnknownTypeName String
->                | NoMatchingOperator String [Type]
->                | TypelessEmptyArray
->                | IncompatibleTypeSet [Type]
->                | IncompatibleTypes Type Type
->                | ValuesListsMustBeSameLength
->                | NoRowsGivenForValues
->                | UnrecognisedIdentifier String
->                | UnrecognisedRelation String
->                | UnrecognisedCorrelationName String
->                | AmbiguousIdentifier String
->                | ContextError String
->                | MissingJoinAttribute
->                | ExpressionMustBeBool
->                | WrongNumberOfColumns
->                | ExpectedDomainType Type
->                | DomainDefNotFound Type
->                | BadCatalogUpdate String
->                | TypeAlreadyExists Type
->                | AnyAllError String
->                | InternalError String
->                | FromToTypesNotSame Type Type
->                 --shoved in to humour the Either Monad
->                | MiscError String
->                  deriving (Eq,Show,Ord,Typeable,Data)
-
-> instance Error ([TypeError]) where
->   noMsg = [MiscError "Unknown error"]
->   strMsg str = [MiscError str]
-
-=== canonical type name support
-
-Introduce some aliases to protect client code if/when the ast
-canonical names are changed:
-
-> typeSmallInt,typeBigInt,typeInt,typeNumeric,typeFloat4,
->   typeFloat8,typeVarChar,typeChar,typeBool :: Type
-> typeSmallInt = ScalarType "int2"
-> typeBigInt = ScalarType "int8"
-> typeInt = ScalarType "int4"
-> typeNumeric = ScalarType "numeric"
-> typeFloat4 = ScalarType "float4"
-> typeFloat8 = ScalarType "float8"
-> typeVarChar = ScalarType "varchar"
-> typeChar = ScalarType "char"
-> typeBool = ScalarType "bool"
-
-this converts the name of a type to its canonical name:
-try to follow the names that pg uses in a dump
-
-> canonicalizeTypeName :: String -> String
-> canonicalizeTypeName s =
->   case () of
->                   _ | s `elem` smallIntNames -> "int2"
->                     | s `elem` intNames -> "int4"
->                     | s `elem` bigIntNames -> "int8"
->                     | s `elem` numericNames -> "numeric"
->                     | s `elem` float4Names -> "float4"
->                     | s `elem` float8Names -> "float8"
->                     | s `elem` varcharNames -> "varchar"
->                     | s `elem` charNames -> "char"
->                     | s `elem` boolNames -> "bool"
->                     | otherwise -> s
->   where
->       smallIntNames = ["int2", "smallint"]
->       intNames = ["int4", "integer", "int", "serial"]
->       bigIntNames = ["int8", "bigint"]
->       numericNames = ["numeric", "decimal"]
->       float4Names = ["real", "float4"]
->       float8Names = ["double precision", "float"]
->       varcharNames = ["character varying", "varchar"]
->       charNames = ["character", "char"]
->       boolNames = ["boolean", "bool"]
-
-> canonicalizeTypes :: Data a => a -> a
-> canonicalizeTypes =
->   transformBi $ \x ->
->       case x of
->         ScalarType s -> ScalarType $ canonicalizeTypeName s
->         x1 -> x1
-
-random notes on pg types:
-
-== domains:
-the point of domains is you can't put constraints on types, but you
-can wrap a type up in a domain and put a constraint on it there.
-
-== literals/selectors
-
-source strings are parsed as unknown type: they can be implicitly cast
-to almost any type in the right context.
-
-rows ctors can also be implicitly cast to any composite type matching
-the elements (now sure how exactly are they matched? - number of
-elements, type compatibility of elements, just by context?).
-
-string literals are not checked for valid syntax currently, but this
-will probably change so we can type check string literals statically.
-Postgres defers all checking to runtime, because it has to cope with
-custom data types. This code will allow adding a grammar checker for
-each type so you can optionally check the string lits statically.
-
-== notes on type checking types
-
-=== basic type checking
-Currently can lookup type names against a default template1 list of
-types, or against the current list in a database (which is read before
-processing and sql code).
-
-todo: collect type names from current source file to check against
-A lot of the infrastructure to do this is already in place. We also
-need to do this for all other definitions, etc.
-
-=== Type aliases
-
-Some types in postgresql have multiple names. I think this is
-hardcoded in the pg parser.
-
-For the canonical name in this code, we use the name given in the
-postgresql pg_type catalog relvar.
-
-TODO: Change the ast canonical names: where there is a choice, prefer
-the sql standard name, where there are multiple sql standard names,
-choose the most concise or common one, so the ast will use different
-canonical names to postgresql.
-
-planned ast canonical names:
-numbers:
-int2, int4/integer, int8 -> smallint, int, bigint
-numeric, decimal -> numeric
-float(1) to float(24), real -> float(24)
-float, float(25) to float(53), double precision -> float
-serial, serial4 -> int
-bigserial, serial8 -> bigint
-character varying(n), varchar(n)-> varchar(n)
-character(n), char(n) -> char(n)
-
-TODO:
-
-what about PrecTypeName? - need to fix the ast and parser (found out
-these are called type modifiers in pg)
-
-also, what can setof be applied to - don't know if it can apply to an
-array or setof type
-
-array types have to match an exact array type in the catalog, so we
-can't create an arbitrary array of any type. Not sure if this is
-handled quite correctly in this code.
-
-================================================================================
-
-utilities for working with Types
-
-These may indicate that the haskell type system isn't being used very well.
-
-> isArrayType :: Type -> Bool
-> isArrayType (ArrayType _) = True
-> isArrayType _ = False
-
-> isDomainType :: Type -> Bool
-> isDomainType (DomainType _) = True
-> isDomainType _ = False
-
-
-> isCompositeType :: Type -> Bool
-> isCompositeType (CompositeType _) = True
-> isCompositeType (NamedCompositeType _) = True
-> isCompositeType (AnonymousRecordType _) = True
-> isCompositeType (PgRecord _) = True
-> isCompositeType _ = False
-
-> isCompositeOrSetOfCompositeType :: Type -> Bool
-> isCompositeOrSetOfCompositeType (SetOfType a) = isCompositeType a
-> isCompositeOrSetOfCompositeType a = isCompositeType a
-
-> unwrapArray :: Type -> Either [TypeError] Type
-> unwrapArray (ArrayType t) = Right t
-> unwrapArray x = Left [InternalError $ "can't get types from non array " ++ show x]
-
-> unwrapSetOfWhenComposite :: Type -> Either [TypeError] Type
-> unwrapSetOfWhenComposite (SetOfType a@(CompositeType _)) = Right a
-> unwrapSetOfWhenComposite x = Left [InternalError $ "tried to unwrapSetOfWhenComposite on " ++ show x]
-
-> unwrapSetOfComposite :: Type -> Either [TypeError]  [(String,Type)]
-> unwrapSetOfComposite (SetOfType (CompositeType a)) = Right a
-> unwrapSetOfComposite x = Left [InternalError $ "tried to unwrapSetOfComposite on " ++ show x]
-
-
-> unwrapSetOf :: Type -> Either [TypeError] Type
-> unwrapSetOf (SetOfType a) = Right a
-> unwrapSetOf x = Left [InternalError $ "tried to unwrapSetOf on " ++ show x]
-
-> unwrapComposite :: Type -> Either [TypeError] [(String,Type)]
-> unwrapComposite (CompositeType a) = Right a
-> unwrapComposite x = Left [InternalError $ "cannot unwrapComposite on " ++ show x]
-
-> consComposite :: (String,Type) -> Type -> Either [TypeError] Type
-> consComposite l (CompositeType a) = Right $ CompositeType (l:a)
-> consComposite a b = Left [InternalError $ "called consComposite on " ++ show (a,b)]
-
-> unwrapRowCtor :: Type -> Either [TypeError] [Type]
-> unwrapRowCtor (AnonymousRecordType a) = Right a
-> unwrapRowCtor x = Left [InternalError $ "cannot unwrapRowCtor on " ++ show x]
-
-================================================================================
-
-new plan for types:
-
-The type annotations attached to nodes will be either typecheckfailed 'type'
-this will allow chaining type check failed more robustly. Type errors don't change.
-
-the sql type type will be changed so we can track the different
-contexts where different sql types can be used, split to use different
-sets of types so we can use the haskell type system to enforce these
-contexts.
-
-rename type to sqltype, too confusing otherwise
-new set of sqltypes: (these aren't in one haskell type anymore)
-scalar type - corresponds to sqltypes in pg which aren't one of the
-  other types (no easy way to define this)
-array type
-setof type : can be applied to scalar, domain, ... but not all types
-composite types are changed:
-namedcomposite string
-composite [(string,type)] -> what types can appear in the attribute list?
-anonymousrecord [type] -> what types can appear here? -> this
-represents a row expression type, which can be returned in select
-expressions (but not as a column in a view), and is used in other places
-domaintype : what types are allowable as the base type?
-pseudo types: these are used for arguments and return values for function prototypes only
-any*, record - just means pg infers the return type which will be a composite type (namedcomposite, composite or anonymousrecord), trigger: just a tag, void: just a tag, any*: polymorphic functions, ignore cstring, internal, language handler and opaque.
-issue: a variable declaration can be a polymorphic type in a polymorphic function, but we can't use the other pseudo types so need to split these
-a variable declared as type record IS NOT the same thing as the pseudo record type, I've finally worked out.
-so our plpgsqlrecordtype is plpgsqlrecordtype (Nothing|one of the three composite types)
-
-typechecking polymorphic functions: will have to relax the type
-checking to some degree. want to check against each usage of the
-polymorphic function in the source, so substitute in the actual types
-and check the function.
-
-contexts:
-function prototypes: args and return type
-function calls: args and return
-variable declaration in plpgsql
-attribute in a select expression
-attribute in a view (less permissive than a select expression), also create table as?
-attribute in a table, type (is this the same list as for composite and anonymous records? - can nest anonymous records)
-base type for domain
-cast expression
-insert: targetatts are same set of types as attributes in a table
-update: targets can be attr types or anonymous records of attr types for rowset style assign (x,y) = selectexp
-assignment statement: type on left same set as type in a for, types in select into, etc?
-return statement
-return query statement
-expressions in a raise statement
-expressions in execute, anything else?
-types used inside select expression checking:
-  selectlist, trefs, groupby, orderby, limit, offset, where, having
-expressions:
-what can an identifiers type be?
-what can the type of an Expression node be?
-  scalar: integerlit,floatlit
-  stringlit: what can an unknown resolve to (not quite everything)
-  booleanlit: scalar
-  nulllit: same as stringlit?
-  positionalarg: any type that a function arg can have
-  cast: any type you can cast to
-  identifier: ?
-  case, casesimple: any type in the rhs expressions, what are these?
-  exists: scalar
-  funcall: any type a function return type can have
-  inpredicate: scalar
-  windowfn: ?
-  liftoperator: booleans only?
-
-problem: can't get types using gettypeannotation function and support
-different valid combinations of types
diff --git a/Database/HsSqlPpp/Dbms/DBAccess.lhs b/Database/HsSqlPpp/Dbms/DBAccess.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/DBAccess.lhs
+++ /dev/null
@@ -1,59 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains a few (almost pointlessly) lightweight wrappers
-around hdbc for running commands and queries.
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.Dbms.DBAccess (runSqlCommand
->                 ,withConn
->                 ,selectValue
->                 ,catchSql
->                 ,seErrorMsg
->                 ,selectRelation) where
-
-> import qualified Database.HDBC.PostgreSQL as Pg
-> import Database.HDBC
-> import Control.Monad
-> import Control.Exception
-
-> runSqlCommand :: (IConnection conn) =>
->           conn -> String -> IO ()
-> runSqlCommand conn query = do
->     _ <- run conn query []
->     commit conn
-
-> withConn :: String -> (Pg.Connection -> IO c) -> IO c
-> withConn cs = bracket (Pg.connectPostgreSQL cs) disconnect
-
-> selectValue :: (IConnection conn) =>
->                conn -> String -> IO String
-> selectValue conn query = do
->   r <- quickQuery' conn query []
->   case length r of
->     0 -> error $ "select value on " ++ query ++
->                         " returned 0 rows, expected 1"
->     1 -> do
->       let t = head r
->       when (length t /= 1)
->         (error $ "select value on " ++ query ++
->              " returned " ++ show (length t) ++ " attributes, expected 1.")
->       return $ toS $ head t
->     _ -> error $ "select value on " ++ query ++
->              " returned " ++ show (length r) ++ " tuples, expected 0 or 1."
->   where
->     toS a = fromSql a :: String
-
-> selectRelation ::(IConnection conn) =>
->                  conn -> String -> [String] -> IO [[String]]
-> selectRelation conn query args = do
->   sth <- prepare conn query
->   _ <- execute sth $ map sToSql args
->   v <- fetchAllRows' sth
->   return $ map (map sqlToS) v
-
-> sToSql :: String -> SqlValue
-> sToSql s = toSql (s::String)
-
-> sqlToS :: SqlValue -> String
-> sqlToS = fromSql
diff --git a/Database/HsSqlPpp/Dbms/DBAccess2.lhs b/Database/HsSqlPpp/Dbms/DBAccess2.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/DBAccess2.lhs
+++ /dev/null
@@ -1,184 +0,0 @@
-Copyright 2010 Jake Wheat
-
-More refined example wrapper generator, uses template haskell. See the
-docs attached to sqlStmt function below
-
-> {-# LANGUAGE TemplateHaskell #-}
-
-> module Database.HsSqlPpp.Dbms.DBAccess2
->     (withConn
->     ,sqlStmt
->     ,IConnection) where
-
-> import Language.Haskell.TH
-
-> import Data.Maybe
-> import Control.Applicative
-> import Control.Monad.Error
-> import Control.Monad
-> import Control.Exception
-
-> import Database.HDBC
-> import qualified Database.HDBC.PostgreSQL as Pg
-
-> import System.IO.Unsafe
-> import Data.IORef
-
-> import Database.HsSqlPpp.Dbms.WrapLib
-> import qualified Database.HsSqlPpp.Ast.SqlTypes as Sql
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Utils
-
-> -- | template haskell fn to roughly do typesafe database access, pretty experimental atm
-> --
-> -- sketch is:
-> --
-> -- > $(sqlStmt connStr sqlStr)
-> -- >
-> -- > -- is transformed into
-> -- >
-> -- >  \conn a_0 a_0 ... ->
-> -- >         selectRelation conn sqlStr [toSql (a_0::Ti0)
-> -- >                                    ,toSql (a_1::Ti1), ... ] >>=
-> -- >         return . map (\ [r_0, r_1, ...] ->
-> -- >           (fromSql r_0::To0
-> -- >           ,fromSql r_1::To1
-> -- >           ,...)
-> --
-> -- example usage:
-> --
-> -- > pieces_at_pos = $(sqlStmt connStr "select * from pieces where x = ? and y = ?;")
-> --
-> -- will come close enough to inferring the type:
-> --
-> -- > pieces_at_pos :: IConnection conn =>
-> -- >                 conn
-> -- >              -> Maybe Int
-> -- >              -> Maybe Int
-> -- >              -> IO [(Maybe String, Maybe String, Maybe Int, Maybe Int, Maybe Int)]
-> --
-> -- (as well as producing a working function which accesses a database)
-> --
-> sqlStmt :: String -> String -> Q Exp
-> sqlStmt dbName sqlStr = do
->   (StatementHaskellType inA outA) <- liftStType
->   let cnName = mkName "cn"
->   argNames <- getNNewNames "a" $ length inA
->   lamE (map varP (cnName : argNames))
->     [| selectRelation $(varE cnName) sqlStr
->                       $(ListE <$> zipWithM toSqlIt argNames inA) >>=
->        return . map $(mapTupleFromSql $ map snd outA)|]
->
->   where
->     liftStType :: Q StatementHaskellType
->     liftStType = runIO stType >>= (either (error . show) toH)
->
->     stType :: IO (Either String StatementType)
->     stType = runErrorT $ do
->       cat <- getCat
->       tsl (getStatementType cat sqlStr)
->
->     getCat :: ErrorT String IO Catalog
->     getCat = do
->       -- bad code to avoid reading the catalog multiple times
->       c1 <- liftIO $ readIORef globalCachedCatalog
->       case c1 of
->         Just c -> return c
->         Nothing -> do
->                    c <- liftIO (readCatalogFromDatabase dbName) >>=
->                           (tsl . updateCatalog defaultCatalog)
->                    liftIO $ writeIORef globalCachedCatalog (Just c)
->                    return c
->
->     -- lambda which does [SqlValue] -> (T1, T2, ...)
->     mapTupleFromSql :: [Type] -> Q Exp
->     mapTupleFromSql outT = do
->       retNames <- getNNewNames "r" $ length outT
->       lamE [listP (map varP retNames)]
->         (tupE $ zipWith fromSqlIt retNames outT)
->
->     toSqlIt :: Name -> Type -> Q Exp
->     toSqlIt n t = [| toSql $(castName n t)|]
->
->     fromSqlIt :: Name -> Type -> Q Exp
->     fromSqlIt n t = do
->       n1 <- [| fromSql $(varE n) |]
->       cast n1 t
->
->     cast :: Exp -> Type -> Q Exp
->     cast e = return . SigE e
->
->     castName :: Name -> Type -> Q Exp
->     castName = cast . VarE
->
->     getNNewNames :: String -> Int -> Q [Name]
->     getNNewNames i n = forM [1..n] $ const $ newName i
-
-================================================================================
-
-> -- | Simple wrapper so that all client code needs to do is import this file
-> -- and use withConn and sqlStmt without importing HDBC, etc.
-
-> withConn :: String -> (Pg.Connection -> IO c) -> IO c
-> withConn cs = bracket (Pg.connectPostgreSQL cs) disconnect
-
-================================================================================
-
-evil hack to avoid reading the catalog from the database for each call
-to sqlStmt. Atm this means that you can only read the catalog from one
-database at compile time, but this should be an easy fix if too
-limiting. TODO: make this change, in case the catalog ends up being
-cached in ghci meaning if you change the database whilst developing in
-emacs it will go wrong
-
-> globalCachedCatalog :: IORef (Maybe Catalog)
-> {-# NOINLINE globalCachedCatalog #-}
-> globalCachedCatalog = unsafePerformIO (newIORef Nothing)
-
-================================================================================
-
-sql parsing and typechecking
-
-get the input and output types for a parameterized sql statement:
-
-> getStatementType :: Catalog -> String -> Either String StatementType
-> getStatementType cat sql = do
->     ast <- tsl $ parseSql "" sql
->     let (_,aast) = typeCheck cat ast
->     let a = getTopLevelInfos aast
->     return $ fromJust $ head a
-
-convert sql statement type to equivalent with sql types replaced with
-haskell equivalents - HDBC knows how to convert the actual values using
-toSql and fromSql as long as we add in the appropriate casts
-
-> data StatementHaskellType = StatementHaskellType [Type] [(String,Type)]
-
-> toH :: StatementType -> Q StatementHaskellType
-> toH (StatementType i o) = do
->   ih <- mapM sqlTypeToHaskell i
->   oht <- mapM (sqlTypeToHaskell . snd) o
->   return $ StatementHaskellType ih $ zip (map fst o) oht
->   where
->     sqlTypeToHaskell :: Sql.Type -> TypeQ
->     sqlTypeToHaskell t =
->       case t of
->         Sql.ScalarType "text" -> [t| Maybe String |]
->         Sql.ScalarType "int4" -> [t| Maybe Int |]
->         Sql.ScalarType "int8" -> [t| Maybe Int |]
->         Sql.ScalarType "bool" -> [t| Maybe Bool |]
->         Sql.DomainType _ -> [t| Maybe String |]
->         x -> error $ show x
-
-================================================================================
-
-TODO:
-get error reporting at compile time working nicely:
-can't connect to database
-problem getting catalog -> report connection string used and source
-  position
-problem getting statement type: parse and type check issues, report
-  source position
diff --git a/Database/HsSqlPpp/Dbms/DBAccess3.lhs b/Database/HsSqlPpp/Dbms/DBAccess3.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/DBAccess3.lhs
+++ /dev/null
@@ -1,284 +0,0 @@
-Copyright 2010 Jake Wheat
-
-Do type safe database access using template haskell and
-hlists. Limitation is that you have to edit this file to add the field
-definitions and possibly exports. Suggested use is to copy this file
-into your own project and edit it there.
-
-> {-# LANGUAGE TemplateHaskell,EmptyDataDecls,DeriveDataTypeable #-}
-
-> module Database.HsSqlPpp.Dbms.DBAccess3
->     (withConn
->     ,sqlStmt
->     ,IConnection
-
-Export the field proxies for your project here.  If you want to write
-down type signatures of the result hlists then export the proxy types
-here also, exporting them isn't neccessarily neccessary otherwise.
-
->     ,ptype,allegiance,tag,x,y
->     ,get_turn_number,current_wizard,colour,sprite
->     ,Ptype,Allegiance,Tag,X,Y
->     ,Get_turn_number,Current_wizard,Colour,Sprite
-
-
->     ) where
-
-> import Language.Haskell.TH
-
-> import Data.Maybe
-> import Control.Applicative
-> import Control.Monad.Error
-> import Control.Exception
-
-> import Database.HDBC
-> import qualified Database.HDBC.PostgreSQL as Pg
-
-> import Data.HList
-> import Data.HList.Label4 ()
-> import Data.HList.TypeEqGeneric1 ()
-> import Data.HList.TypeCastGeneric1 ()
-> import Database.HsSqlPpp.Dbms.MakeLabels
-
-> import System.IO.Unsafe
-> --import Data.IORef
-
-> import Database.HsSqlPpp.Dbms.WrapLib
-> import qualified Database.HsSqlPpp.Ast.SqlTypes as Sql
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Utils
-
-
-================================================================================
-
-If you are using this file, this is the bit where you add your own
-fields.
-
-> $(makeLabels ["ptype"
->              ,"allegiance"
->              ,"tag"
->              ,"x"
->              ,"y"
->              ,"get_turn_number"
->              ,"current_wizard"
->              ,"colour"
->              ,"sprite"])
-
-================================================================================
-
-> -- | template haskell fn to roughly do typesafe database access with
-> -- hlists, pretty experimental atm
-> --
-> -- sketch is:
-> --
-> -- >
-> -- > $(sqlStmt connStr sqlStr)
-> -- >
-> -- > -- is transformed into
-> -- >
-> -- >
-> -- >  \conn a_0 a_1 ... ->
-> -- >      selectRelation conn sqlStr [toSql (a_0::Ti0)
-> -- >                                 ,toSql (a_1::Ti1), ... ] >>=
-> -- >      return . map (\ [r_0, r_1, ...] ->
-> -- >        f1 .=. fromSql (r_0::To0) .*.
-> -- >        f2 .=. fromSql (r_1::To1) .*.
-> -- >        ... .*.
-> -- >        emptyRecord)
-> -- >
-> --
-> -- where the names f1, f2 are the attribute names from the database,
-> -- the types Ti[n] are the types of the placeholders in the sql
-> -- string, and the types To[n] are the types of the attributes in
-> -- the returned relation. To work around a limitation in the
-> -- implementation, these names must be in scope in this file, so to
-> -- use this in your own projects you need to copy the source and
-> -- then add the field defitions in as needed.
-> --
-> -- example usage:
-> --
-> -- >
-> -- > pieces_at_pos = $(sqlStmt connStr "select * from pieces where x = ? and y = ?;")
-> -- >
-> --
-> -- might (!) infer the type:
-> --
-> -- >
-> -- >   pieces_at_pos :: IConnection conn =>
-> -- >                    conn
-> -- >                 -> Maybe Int
-> -- >                 -> Maybe Int
-> -- >                 -> IO [Record (HCons (LVPair (Proxy Ptype)
-> -- >                                              (Maybe String))
-> -- >                               (HCons (LVPair (Proxy Allegiance)
-> -- >                                              (Maybe String))
-> -- >                               (HCons (LVPair (Proxy Tag)
-> -- >                                              (Maybe Int))
-> -- >                               (HCons (LVPair (Proxy X)
-> -- >                                              (Maybe Int))
-> -- >                               (HCons (LVPair (Proxy Y)
-> -- >                                              (Maybe Int))
-> -- >                                HNil)))))]
-> -- >
-> --
-> -- (as well as producing a working function which accesses a database). Currently, I get
-> --
-> -- >
-> -- > Test3.lhs:16:12:
-> -- >     Ambiguous type variable `conn' in the constraint:
-> -- >       `IConnection conn'
-> -- >         arising from a use of `pieces' at Test3.lhs:16:12-22
-> -- >     Probable fix: add a type signature that fixes these type variable(s)
-> -- >
-> --
-> -- which can be worked around by adding a type signature like
-> --
-> -- >
-> -- > pieces_at_pos :: IConnection conn =>
-> -- >                  conn
-> -- >               -> a
-> -- >               -> b
-> -- >               -> IO c
-> -- >
-> --
-> -- and then ghc will complain and tell you what a,b,c should be (make
-> -- sure you match the number of arguments after conn to the number
-> -- of ? placeholders in the sql string).
-
-> sqlStmt :: String -> String -> Q Exp
-> sqlStmt dbName sqlStr = do
->   (StatementHaskellType inA outA) <- liftStType
->   let cnName = mkName "cn"
->   argNames <- getNNewNames "a" $ length inA
->   lamE (map varP (cnName : argNames))
->     [| selectRelation $(varE cnName) sqlStr
->                       $(ListE <$> zipWithM toSqlIt argNames inA) >>=
->        return . map $(mapHlistFromSql outA)|]
->
->   where
->     -- th code gen utils
->     mapHlistFromSql :: [(String,Type)] -> Q Exp
->     mapHlistFromSql outA = do
->       retNames <- getNNewNames "r" $ length outA
->       l1 <- mapM (\(a,b,c) -> toHlistField a b c) $ zipWith (\(a,b) c -> (a,b,c)) outA retNames
->       lamE [listP (map varP retNames)] $ foldHlist l1
->
->     toHlistField :: String -> Type -> Name -> Q Exp
->     toHlistField f t v = [| $(varE $ mkName f) .=. $(fromSqlIt v t) |]
->
->     foldHlist :: [Exp] -> Q Exp
->     foldHlist (e:e1) = [| $(return e) .*. $(foldHlist e1) |]
->     foldHlist [] = [| emptyRecord |]
->
->     toSqlIt :: Name -> Type -> Q Exp
->     toSqlIt n t = [| toSql $(castName n t)|]
->
->     fromSqlIt :: Name -> Type -> Q Exp
->     fromSqlIt n t = do
->       n1 <- [| fromSql $(varE n) |]
->       casti n1 t
->
->     casti :: Exp -> Type -> Q Exp
->     casti e = return . SigE e
->
->     castName :: Name -> Type -> Q Exp
->     castName = casti . VarE
->
->     getNNewNames :: String -> Int -> Q [Name]
->     getNNewNames i n = replicateM n $ newName i
->
->     -- statement type stuff
->     liftStType :: Q StatementHaskellType
->     liftStType = runIO stType >>= either (error . show) toH
->
->     stType :: IO (Either String StatementType)
->     stType = runErrorT $ do
->       cat <- getCat
->       tsl (getStatementType cat sqlStr)
->
->     getCat :: ErrorT String IO Catalog
->     getCat = do
->       -- bad code to avoid reading the catalog multiple times
->       c1 <- liftIO $ readIORef globalCachedCatalog
->       case c1 of
->         Just c -> return c
->         Nothing -> do
->                    c <- liftIO (readCatalogFromDatabase dbName) >>=
->                           (tsl . updateCatalog defaultCatalog)
->                    liftIO $ writeIORef globalCachedCatalog (Just c)
->                    return c
->
-
-================================================================================
-
-> -- | Simple wrapper so that all client code needs to do is import this file
-> -- and use withConn and sqlStmt without importing HDBC, etc.
-
-> withConn :: String -> (Pg.Connection -> IO c) -> IO c
-> withConn cs = bracket (Pg.connectPostgreSQL cs) disconnect
-
-================================================================================
-
-evil hack to avoid reading the catalog from the database for each call
-to sqlStmt. Atm this means that you can only read the catalog from one
-database at compile time, but this should be an easy fix if too
-limiting. TODO: make this change, in case the catalog ends up being
-cached in ghci meaning if you change the database whilst developing in
-emacs it will go wrong
-
-> globalCachedCatalog :: IORef (Maybe Catalog)
-> {-# NOINLINE globalCachedCatalog #-}
-> globalCachedCatalog = unsafePerformIO (newIORef Nothing)
-
-================================================================================
-
-sql parsing and typechecking
-
-get the input and output types for a parameterized sql statement:
-
-> getStatementType :: Catalog -> String -> Either String StatementType
-> getStatementType cat sql = do
->     ast <- tsl $ parseSql "" sql
->     let (_,aast) = typeCheck cat ast
->     let a = getTopLevelInfos aast
->     return $ fromJust $ head a
-
-convert sql statement type to equivalent with sql types replaced with
-haskell equivalents - HDBC knows how to convert the actual values using
-toSql and fromSql as long as we add in the appropriate casts
-
-> data StatementHaskellType = StatementHaskellType [Type] [(String,Type)]
-
-> toH :: StatementType -> Q StatementHaskellType
-> toH (StatementType i o) = do
->   ih <- mapM sqlTypeToHaskell i
->   oht <- mapM (sqlTypeToHaskell . snd) o
->   return $ StatementHaskellType ih $ zip (map fst o) oht
->   where
->     sqlTypeToHaskell :: Sql.Type -> TypeQ
->     sqlTypeToHaskell t =
->       case t of
->         Sql.ScalarType "text" -> [t| Maybe String |]
->         Sql.ScalarType "int4" -> [t| Maybe Int |]
->         Sql.ScalarType "int8" -> [t| Maybe Int |]
->         Sql.ScalarType "bool" -> [t| Maybe Bool |]
->         Sql.DomainType _ -> [t| Maybe String |]
->         z -> error $ show z
-
-================================================================================
-
-TODO:
-get error reporting at compile time working nicely:
-can't connect to database
-problem getting catalog -> report connection string used and source
-  position
-problem getting statement type: parse and type check issues, report
-  source position
-
-turn this file into a toolkit of bits, which can import so can use
-without having to copy then edit this file
-
-figure out a better way of handling the proxies
diff --git a/Database/HsSqlPpp/Dbms/DBUtils.lhs b/Database/HsSqlPpp/Dbms/DBUtils.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/DBUtils.lhs
+++ /dev/null
@@ -1,63 +0,0 @@
-Copyright 2010 Jake Wheat
-
-This file contains a few hacked together utility functions for working
-with postgres.
-
-> module Database.HsSqlPpp.Dbms.DBUtils
->     (readCatalog
->     ,loadSqlUsingPsql
->     ,loadSqlUsingPsqlFromFile
->     ,clearDB
->     ,pgDump) where
-
-
-> import System
-
-> import System.Process.Pipe
-> --import Text.Pandoc
-
-
-> import Database.HsSqlPpp.Ast.Catalog
-
-> import Database.HsSqlPpp.Ast.SqlTypes
-
-> import Database.HsSqlPpp.Dbms.DBAccess
-
-> -- | get the catalog from the database, and return an Catalog value
-> readCatalog :: String -> IO (Either [TypeError] Catalog)
-> readCatalog dbName =
->   (readCatalogFromDatabase dbName) >>=
->     return . updateCatalog defaultCatalog
-
-> -- | run psql to load the sql text into a database.
-> loadSqlUsingPsql :: String -> String -> IO String
-> loadSqlUsingPsql dbName =
->   pipeString [("psql", [dbName
->                        ,"-q"
->                        ,"--set"
->                        ,"ON_ERROR_STOP=on"
->                        ,"--file=-"])]
-
-> -- | run psql to load sql from the filename given into a database.
-> loadSqlUsingPsqlFromFile :: String -> FilePath -> IO (Either String String)
-> loadSqlUsingPsqlFromFile dbName fn = do
->   ex <- system ("psql " ++ dbName ++
->                 " -q --set ON_ERROR_STOP=on" ++
->                 " --file=" ++ fn)
->   case ex of
->     ExitFailure e -> return $ Left $ "psql failed with " ++ show e
->     ExitSuccess -> return $ Right ""
-
-> -- | use a dodgy hack to clear the database given
-> clearDB :: String -> IO ()
-> clearDB db =
->   withConn ("dbname=" ++ db) $ \conn ->
->     runSqlCommand conn "drop owned by jake cascade;"
-
-> -- | dump the given database to sql source using pg_dump
-> pgDump :: String -> IO String
-> pgDump db = pipeString [("pg_dump", [db
->                                              ,"--schema-only"
->                                              ,"--no-owner"
->                                              ,"--no-privileges"])] ""
-
diff --git a/Database/HsSqlPpp/Dbms/DatabaseLoader.lhs b/Database/HsSqlPpp/Dbms/DatabaseLoader.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/DatabaseLoader.lhs
+++ /dev/null
@@ -1,217 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This module mainly contains the function to take a statement list and
-load it into the database.
-
-The loading system works by parsing a sql file then passing the
-[Statement] to this module which pretty prints each Statement. (There
-is no fundamental reason why it loads each statement one at a time
-instead of pretty printing the whole lot, just that the run command
-from hdbc only supports one command at a time. This might be a
-postgresql limitation.)
-
-The next todo to help this code move along is to use the source
-position information in the ast when error (and notice, etc.)
-messages come back from the database whilst loading the sql, can try to show the source position from the original file, which will be different to what postgresql reports.
-
-This seems like a whole lot of effort for nothing, but will then allow
-using transforming the ast so it no longer directly corresponds to the
-source sql, and loading the transformed sql into the database. For
-generated code, some thought will be needed on how to link any errors
-back to the original source text.
-
-One option for some of the code is to use the original source code
-when it hasn't been changed for a given statement, instead of the
-pretty printed stuff, don't know how much help this will be.
-
-This code is currently on the backburner, and is a mess.
-
-> {- | Routine load SQL into a database. Should work alright, but if
->  you get any errors from PostgreSQL it won't be easy to track them
->   down in the original source.-}
-> module Database.HsSqlPpp.Dbms.DatabaseLoader
->     (
->      loadIntoDatabase
->     ) where
-
-> import System.Directory
-> import Control.Exception
-> import Text.Regex.Posix
-> import Data.List
-
-> import Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
-> import Database.HsSqlPpp.Ast.Ast as Ast
-> import Database.HsSqlPpp.Dbms.DBAccess
-> import Database.HsSqlPpp.Ast.Annotation
-
-> loadIntoDatabase :: String -- ^ database name
->                  -> FilePath -- ^ filename to include in error messages
->                              -- (this file is not accessed)
->                  -> StatementList -- ^ ast to load into database
->                  -> IO ()
-> loadIntoDatabase dbName fn ast =
->   withConn ("dbname=" ++ dbName) $ \conn -> do
->          --loadPlpgsqlIntoDatabase conn
->          mapM_ (\st ->
->                 loadStatement conn st
->                 >> putStr ".") (filterStatements ast)
->   where
->     loadStatement conn st = case st of
->                                          Skipit -> return ()
->                                          VanillaStatement vs ->
->                                              {-putStrLn (printSql [vs]) >> -}
->                                              handleError fn (getSourcePos vs) vs (runSqlCommand conn
->                                                       (printSql [vs]))
->                                          CopyStdin a b -> runCopy conn a b (getSourcePos a)
->     getSourcePos st = let a = getAnnotation st
->                       in sp a
->                       where
->                         sp (x:xs) = case x of
->                                       SourcePos s l c -> (s,l,c)
->                                       _ -> sp xs
->                         sp [] = ("",0,0)
->     --hack cos we don't have support in hdbc for copy from stdin
->     --(which libpq does support - adding this properly should be a todo)
->     --we need the copy from stdin and the copydata to be processed in one go,
->     --so filter the list to replace instances of these with a replacement
->     --and a dummy statement following. Well dodgy, don't really know
->     --how it manages to work correctly.
->     filterStatements sts =
->        map (\(x,y) ->
->                 case (x,y) of
->                        (a@(Copy _ _ _ Stdin), b@(CopyData _ _)) -> (CopyStdin a b)
->                        (CopyData _ _, _) -> Skipit
->                        (vs,_) -> VanillaStatement vs)
->            statementWithNextStatement
->            where
->              statementWithNextStatement =
->                  zip sts (tail sts ++ [NullStatement []])
->     runCopy conn a b _ = case (a,b) of
->                          (Copy _ tb cl Stdin, CopyData _ s) ->
->                            withTemporaryFile (\tfn -> do
->                                writeFile tfn s
->                                tfn1 <- canonicalizePath tfn
->                                loadStatement conn
->                                  (VanillaStatement (Copy [] tb cl
->                                                     (CopyFilename tfn1))))
->                          _ -> error "internal error: pattern match fail in runCopy in loadIntoDatabase"
->     {-loadPlpgsqlIntoDatabase conn = do
->          -- first, check plpgsql is in the database
->          x <- selectValue conn
->                 "select count(1) from pg_language where lanname='plpgsql';"
->          when (readInt x == 0) $
->               runSqlCommand conn "create procedural language plpgsql;"
->     readInt x = read x :: Int-}
-
-> data Wrapper = CopyStdin Ast.Statement Ast.Statement
->              | Skipit
->              | VanillaStatement Ast.Statement
->                deriving Show
-
-================================================================================
-
-= Error reporting
-
-The goal is to give a position in the original source when an error
-occurs as best as possible.
-
-For now, all statements in the ast correspond 1:1 with statement text
-in the source code, so each line,col pair coming from pg should
-correspond to onne line,col pair in the original source text.
-
-The lines load in one at a time, so there needs to be a fair bit of
-translation to ultimately output the original line and source number.
-
-(For code with no source information, e.g. stuff which is generated
-programmatically from scratch, plan is to give a index (the statement
-position in the [Statement] arg, and then pretty print this statement
-and provide a line and column just for this statement text.
-
-Later on, when working with generated code may need to make guesses as
-to which line, and possibly supply multiple references (e.g. for a
-template you might want to see the part of the template which is
-causing the error, plus the arguments being passed to that template
-instantiation call (if nested, you want to see all of them back up to the
-top level).
-
-So, for now: want to get the line number and column number from the
-error message text
-
-If there is a line and column number in the error coming from
-postgresql, they should appear something like this:
-
-execute: PGRES_FATAL_ERROR: ERROR:  column "object_name" of relation "system_implementation_objects" does not exist
-LINE 1: insert into system_implementation_objects (object_name,objec...
-                                                   ^
-
-So we are looking at the LINE x: part, and the line with a bunch of
-blanks preceding the ^
-
-Parse the line number out : easy
-Parse the number of spaces before the ^ easy
-
-Problem: the text following the LINE 1: is a arbitrary snippet of the
-source so the column number of the ^ doesn't relate to the column
-number in the source in any straightforward way at all...
-
-Probably a better way of doing this, might need alterations to HDBC
-though
-
-> getLineAndColumnFromErrorText :: String -> (Int, Int)
-> getLineAndColumnFromErrorText errorText =
->   let ls = lines errorText
->       lineLine = find isLineLine ls
->       lineNo = case lineLine of
->                              Nothing -> 0
->                              Just ll -> getLineNo ll
->       column = 0 --(case find isHatLine ls of
->                  --                     Nothing -> 0
->                  --                     Just ll -> getHatPos ll 0)
->       prestuff = 0 --case lineLine of
->       --             Nothing -> 0
->       --             Just l -> getLineStuffLength l
->   in (column - prestuff,lineNo)
->   -- wish I knew how to get haskell regexes working...
->   -- can't find a way to get just the () part out
->   where
->     isLineLine l = l =~ "^LINE ([0-9]+):" :: Bool
->     getLineNo l = read (stripCrap (l =~ "^LINE ([0-9]+):" :: String)) :: Int
->     stripCrap = reverse . drop 1 . reverse . drop 5
-
- >     isHatLine l = l =~ "^[ ]*\\^" :: Bool
- >     getHatPos l i = case l of
- >                            (x:xs) | x == ' ' -> getHatPos xs (i + 1)
- >                                   | otherwise -> i
- >                            _ -> 0
- >     getLineStuffLength l = length (l =~ "^LINE ([0-9]+):" :: String) + 1
-
-> handleError :: String -> (String,Int,Int) -> Ast.Statement -> IO () -> IO ()
-> handleError fn (_, sl,sc) _ f = catchSql f
->                    (\e -> do
->                      --s <- readFile fn
->                      let (l,c) = getLineAndColumnFromErrorText (seErrorMsg e)
->                      --let (sl,sc) = getStatementPos st
->                      error $ "ERROR!!!!\n"
->                                ++ show l ++ ":" ++ show c ++ ":\n"
->                                ++ "from here:\n"
->                                ++ fn ++ ":" ++ show sl ++ ":" ++ show sc ++ ":\n"
->                                ++ seErrorMsg e)
-
- > getStatementPos (Insert (Just (SourcePos x y)) _ _ _ _) = (x,y)
-
- > getStatementPos :: t -> (Integer, Integer)
- > getStatementPos _ = (0::Integer,0::Integer)
-
-================================================================================
-
-withtemporaryfile, part of the copy from stdin hack
-
-can't use opentempfile since it gets locked and then pg program can't
-open the file for reading
-
-proper dodgy, needs fixing:
-
-> withTemporaryFile :: (String -> IO c) -> IO c
-> withTemporaryFile f = bracket (return ())
->                               (\_ -> removeFile "hssqlppptemp.temp")
->                               (\_ -> f "hssqlppptemp.temp")
diff --git a/Database/HsSqlPpp/Dbms/MakeLabels.hs b/Database/HsSqlPpp/Dbms/MakeLabels.hs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/MakeLabels.hs
+++ /dev/null
@@ -1,126 +0,0 @@
-{-# LANGUAGE TemplateHaskell, FlexibleInstances, EmptyDataDecls, DeriveDataTypeable #-}
-
--- robbed from the darcs version of hlist
-
--- Making labels
-
-{-
- The following TH splice
-      $(makeLabels ["getX","getY","draw"])
-
-should expand into the following declarations
-
-data GetX;     getX     = proxy::Proxy GetX
-data GetY;     getY     = proxy::Proxy GetY
-data Draw;     draw     = proxy::Proxy Draw
-
--}
-
-module Database.HsSqlPpp.Dbms.MakeLabels (makeLabels,label) where
-
-import Data.HList.FakePrelude
-
-import Language.Haskell.TH.Ppr () --pprint,Ppr)
-import Language.Haskell.TH.Syntax
-
-import Data.Char (toUpper, toLower)
-import Control.Monad (liftM)
-
-import Data.Typeable
-
-capitalize, uncapitalize :: String -> String
-capitalize   (c:rest) = toUpper c : rest
-capitalize [] = []
-uncapitalize (c:rest) = toLower c : rest
-uncapitalize [] = []
-
-
--- Make the name of the type constructor whose string representation
--- is capitalized str
-make_tname :: String -> Name
-make_tname str = mkName $ capitalize str
-
--- Make the name of the value identifier whose string representation
--- is uncapitalized str
-make_dname :: String -> Name
-make_dname str = mkName $ uncapitalize str
-
--- The template of our declaration. We will then replace all occurences
--- of Foo with the desired name
-dcl_template :: Q [Dec]
-dcl_template = [d| data Foo deriving Typeable; foo :: Proxy Foo; foo = proxy::Proxy Foo |]
-
--- A very dirty traversal/replacement...
-
-class ReplaceSyntax a where
-    replace_name :: (Name,Name) -> (Name,Name) -> a -> a
-
-instance ReplaceSyntax [Dec] where
-    replace_name frm to dcls = map (replace_name frm to) dcls
-
-instance ReplaceSyntax Dec where
-    replace_name (tfrom,_) (tto,_)
-                 dcl@(DataD ctx n parms con othern) =
-                     if tfrom == n then
-                        DataD ctx tto parms con othern
-                        else dcl
-    replace_name (tfrom,dfrom) (tto,dto)
-                 (ValD (VarP n) (NormalB body) []) =
-          let n' = if n == dfrom then dto else n
-          in ValD (VarP n')
-                  (NormalB (replace_name (tfrom,dfrom) (tto,dto) body)) []
-
-    replace_name (tfrom,dfrom) (tto,dto) (SigD n t) =
-          let n' = if n == dfrom then dto else n
-          in SigD n' (replace_name (tfrom,dfrom) (tto,dto) t)
-
-    replace_name _ _ dcl =
-        error $ "Can't handle: " ++ show dcl
-
-
-instance ReplaceSyntax Exp where
-    replace_name from to (SigE exp' tp) =
-                     SigE (replace_name from to exp')
-                          (replace_name from to tp)
-    replace_name _ _ exp' = exp'
-
-
-instance ReplaceSyntax Type where
-    replace_name (tfrom,_) (tto,_) tp@(ConT n) =
-        if n == tfrom then (ConT tto) else tp
-    replace_name from to (AppT t1 t2) =
-        (AppT (replace_name from to t1) (replace_name from to t2))
-    replace_name _ _ t = error $ "Can't handle: " ++ show t
-
-
--- Our main function
-makeLabels :: [String] -> Q [Dec]
-makeLabels = liftM concat . sequence . map repl
- where
- repl n = liftM (replace_name from (to n)) dcl_template
- from = (make_tname "foo",make_dname "foo")
- to n = (make_tname n,make_dname n)
-
-label :: String -> Q [Dec]
-label s = makeLabels [s]
-
-{-
--- Show the code expression
-show_code :: Ppr a => Q a -> IO ()
-show_code cde = runQ cde >>= putStrLn . pprint
-
-t1 :: IO ()
-t1 = show_code [d| data Foo |]
-
-t2 :: String
-t2 = showName $ mkName "Foo"
-
-t3 :: IO ()
-t3 = show_code $
-     liftM (replace_name
-            (make_tname "foo",make_dname "foo")
-            (make_tname "bar",make_dname "bar")) dcl_template
-
-t4 :: IO ()
-t4 = show_code $ makeLabels ["getX","getY","draw"]
--}
diff --git a/Database/HsSqlPpp/Dbms/WrapLib.lhs b/Database/HsSqlPpp/Dbms/WrapLib.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/WrapLib.lhs
+++ /dev/null
@@ -1,15 +0,0 @@
-Copyright 2010 Jake Wheat
-
-> -- | Utility function for use with WrapperGen example code
-> module Database.HsSqlPpp.Dbms.WrapLib where
-
-> import Database.HDBC
-
-> selectRelation :: (IConnection conn) =>
->                   conn -> String -> [SqlValue] -> IO [[SqlValue]]
-> selectRelation conn query args = do
->   sth <- prepare conn query
->   _ <- execute sth args
->   v <- fetchAllRows' sth
->   return v
-
diff --git a/Database/HsSqlPpp/Dbms/WrapperGen.lhs b/Database/HsSqlPpp/Dbms/WrapperGen.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Dbms/WrapperGen.lhs
+++ /dev/null
@@ -1,275 +0,0 @@
-Copyright 2010 Jake Wheat
-
-demo code for using the hssqlppp typechecker to generate typesafe
-database access code
-
-could probably use some quasi quotation
-
-> {-# LANGUAGE FlexibleContexts #-}
-
-> module Database.HsSqlPpp.Dbms.WrapperGen
->     (wrapperGen) where
-
-> import Text.Show.Pretty (ppShow)
-> import Language.Haskell.Exts hiding (String)
-> import qualified Language.Haskell.Exts as Exts
-> import Data.Generics.PlateData
-> import Data.Generics hiding (Prefix,Infix)
-> import Control.Monad.Error
-> import Data.Maybe
-
-> import Database.HsSqlPpp.Ast.SqlTypes as Sql
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.Annotation
-
-
-> -- | takes a haskell source file and produces a haskell source file
-> -- with typesafe wrappers
-> --
-> -- Example:
-> --
-> -- > module Testhesql1 where
-> -- > pieces = "select * from pieces;"
-> -- > turn_number = "select get_turn_number();"
-> -- > pieces_at_pos = "select * from pieces where x = ? and y = ?;"
-> --
-> -- is transformed to
-> --
-> -- > module Testhesql1 where
-> -- > import Database.HDBC
-> -- > import Database.HsSqlPpp.Dbms.WrapLib
-> -- >
-> -- > pieces ::
-> -- >          (IConnection conn) =>
-> -- >          conn ->
-> -- >            IO [(Maybe String, Maybe String, Maybe Int, Maybe Int, Maybe Int)]
-> -- > pieces conn
-> -- >   = do r <- selectRelation conn "select * from pieces;" []
-> -- >        return $
-> -- >          flip map r $
-> -- >            \ [a0, a1, a2, a3, a4] ->
-> -- >              (fromSql a0, fromSql a1, fromSql a2, fromSql a3, fromSql a4)
-> -- >
-> -- > turn_number :: (IConnection conn) => conn -> IO [(Maybe Int)]
-> -- > turn_number conn
-> -- >   = do r <- selectRelation conn "select get_turn_number();" []
-> -- >        return $ flip map r $ \ [a0] -> (fromSql a0)
-> -- >
-> -- > pieces_at_pos ::
-> -- >                 (IConnection conn) =>
-> -- >                 conn ->
-> -- >                   Maybe Int ->
-> -- >                     Maybe Int ->
-> -- >                       IO [(Maybe String, Maybe String, Maybe Int, Maybe Int, Maybe Int)]
-> -- > pieces_at_pos conn b0 b1
-> -- >   = do r <- selectRelation conn
-> -- >               "select * from pieces where x = ? and y = ?;"
-> -- >               [toSql b0, toSql b1]
-> -- >        return $
-> -- >          flip map r $
-> -- >            \ [a0, a1, a2, a3, a4] ->
-> -- >              (fromSql a0, fromSql a1, fromSql a2, fromSql a3, fromSql a4)
-> --
-> -- This code is just an example of how to get the type information
-> -- out for each sql statement, please see the source code for how it
-> -- works.  It's not nearly good enough for production use.
-
-> wrapperGen :: String -- ^ name of database to typecheck against
->            -> FilePath -- ^ haskell source filename to process
->            -> IO String -- ^ generated wrapper source code
-> wrapperGen db fn = do
->   p <- parseFile fn
->   case p of
->     ParseOk ast -> do
->                    catU <- readCatalogFromDatabase db
->                    case updateCatalog defaultCatalog catU of
->                      Left er -> return $ show er
->                      Right cat ->
->                          return $ {-ppShow ast ++  "\n\n" ++ -} prettyPrint (processTree cat (addImports ast))
->     x -> return $ ppShow x
-
-This is the function which finds the statements which look like
-ident = "string"
-and converts them into hdbc wrappers with the correct types
-
-> processTree :: Data a => Catalog -> a -> a
-> processTree cat =
->     transformBi $ \x ->
->       case x of
->         (PatBind _
->              (PVar (Ident fnName))
->              Nothing
->              (UnGuardedRhs(Lit (Exts.String sqlSrc)))
->              (BDecls [])) : tl
->           -> createWrapper cat fnName sqlSrc ++ tl
->         x1 -> x1
-
-for each bind to convert, lookup the haskell types needed, then
-create a type sig and a function to use hdbc to run the sql
-
-> createWrapper :: Catalog
->               -> String
->               -> String
->               -> [Decl]
-> createWrapper cat fnName sql =
->     let rt = getStatementType cat sql
->     in case rt of
->       Left e -> error e
->       Right (StatementType pt ts) ->
->           let pts = map sqlTypeToHaskellTypeName pt
->               tns = map (sqlTypeToHaskellTypeName . snd) ts
->           in [makeTypeSig fnName pts tns
->              ,makeFn fnName sql pts tns]
-
-================================================================================
-
-create the type signature for a wrapper, produces something like
-(IConnection conn) => conn -> inarg1 -> inarg2 -> ... ->
-             IO [(outarg1, outarg2, ...)]
-
-> makeTypeSig :: String -> [String] -> [String] -> Decl
-> makeTypeSig fnName argTypes typeNames =
->   TypeSig noSrcLoc [Ident fnName] $
->     TyForall Nothing [ClassA (UnQual (Ident "IConnection")) [TyVar(Ident "conn")]] $
->       foldr TyFun lastArg args
->   where
->     tc = TyCon . UnQual . Ident
->     tntt = (TyApp (tc "Maybe")) . tc
->     args = ((TyVar (Ident "conn")) : map tntt argTypes)
->     lastArg = (TyApp (tc "IO") (TyList (TyTuple Boxed $ map tntt typeNames)))
-
-================================================================================
-
-create the function which calls hdbc
-
-takes something like:
-pieces_at_pos = "select * from pieces where x = ? and y = ?;"
-and produces:
-
-pieces_at_pos conn b0 b1
-  = do r <- selectRelation conn
-              "select * from pieces where x = ? and y = ?;"
-              [toSql b0, toSql b1]
-       return $
-         flip map r $
-           \ [a0, a1, a2, a3, a4] ->
-             (fromSql a0, fromSql a1, fromSql a2, fromSql a3, fromSql a4)
-
-doesn't really need to know the types, just the number of inargs and outargs,
-since the work is done by hdbc's toSql and fromSql, and by the type signature
-that is generated in the function above
-
-> makeFn :: String -> String -> [String] -> [String] -> Decl
-> makeFn fnName sql pts typeNames = FunBind
->       [ Match noSrcLoc(
->           Ident fnName )
->           (PVar (Ident "conn") : map (PVar . Ident) pNames)
->           Nothing (
->           UnGuardedRhs (
->             Do
->               [ Generator noSrcLoc (
->                   PVar ( Ident "r" ) ) (
->                   App (
->                     App (
->                       App (
->                         Var ( UnQual ( Ident "selectRelation" ) ) ) (
->                         Var ( UnQual ( Ident "conn" ) ) ) ) (
->                       Lit ( Exts.String sql ) ) ) (
->                     List $ map (\l -> App (
->                         Var ( UnQual ( Ident "toSql" ) ) ) (
->                         Var ( UnQual ( Ident l ) ) )) pNames
->                     ))
->               , Qualifier (
->                   InfixApp (
->                     Var ( UnQual ( Ident "return" ) ) ) (
->                     QVarOp ( UnQual ( Symbol "$" ) ) ) (
->                     InfixApp (
->                       App (
->                         App (
->                           Var ( UnQual ( Ident "flip" ) ) ) (
->                           Var ( UnQual ( Ident "map" ) ) ) ) (
->                         Var ( UnQual ( Ident "r" ) ) ) ) (
->                       QVarOp ( UnQual ( Symbol "$" ) ) ) (
->                       Lambda noSrcLoc
->                         [ PList (map (PVar . Ident) vns)
->                         ] (
->                         Tuple (map (\n -> App (vui "fromSql") (vui n)) vns)
->                         ) ) ) )
->               ] ) ) (
->           BDecls [] )
->       ]
->       where
->         varName n = "a" ++ show n
->         vns = map varName [0..length typeNames - 1]
->         vui = Var . UnQual . Ident
->         pName n = "b" ++ show n
->         pNames = map pName [0..length pts - 1]
-
-================================================================================
-
-> addImports :: Data a => a -> a
-> addImports =
->     transformBi $ \x ->
->       case x of
->         Module sl mn o wt es im d -> Module sl mn o wt es (imports ++ im) d
-
-> imports :: [ImportDecl]
-> imports = [ImportDecl {importLoc = noSrcLoc
->                       ,importModule = ModuleName "Database.HDBC"
->                       ,importQualified = False
->                       ,importSrc = False
->                       ,importPkg = Nothing
->                       ,importAs = Nothing
->                       ,importSpecs = Nothing
->                       }
->           ,ImportDecl {importLoc = noSrcLoc
->                       ,importModule = ModuleName "Database.HsSqlPpp.Dbms.WrapLib"
->                       ,importQualified = False
->                       ,importSrc = False
->                       ,importPkg = Nothing
->                       ,importAs = Nothing
->                       ,importSpecs = Nothing
->                       }]
-
-================================================================================
-
-parsing and typechecking
-
-get the input and output types for a parameterized sql statement:
-
-> getStatementType :: Catalog -> String -> Either String StatementType
-> getStatementType cat sql = do
->     ast <- tsl $ parseSql "" sql
->     let (_,aast) = typeCheck cat ast
->     let a = getTopLevelInfos aast
->     return $ fromJust $ head a
-
-return the equivalent haskell type for a sql type as a string
-
-> sqlTypeToHaskellTypeName :: Sql.Type -> String
-> sqlTypeToHaskellTypeName t =
->     case t of
->        ScalarType "text" -> "String"
->        ScalarType "int4" -> "Int"
->        ScalarType "int8" -> "Int"
->        ScalarType "bool" -> "Bool"
->        DomainType _ -> "String"
->        x -> show x
-
-================================================================================
-
-simple ast shortcuts
-
-> noSrcLoc :: SrcLoc
-> noSrcLoc = (SrcLoc "" 0 0)
-
-================================================================================
-
-error utility - convert either to ErrorT String
-
-> tsl :: (MonadError String m, Show t) => Either t a -> m a
-> tsl x = case x of
->                Left s -> throwError $ show s
->                Right b -> return b
diff --git a/Database/HsSqlPpp/Extensions/ChaosExtensions.lhs b/Database/HsSqlPpp/Extensions/ChaosExtensions.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Extensions/ChaosExtensions.lhs
+++ /dev/null
@@ -1,497 +0,0 @@
-Copyright 2009 Jake Wheat
-
-Experimental code to use uniplate to implement extensions
-
-> {-# LANGUAGE ViewPatterns #-}
-
-> {- | Experimental code to half implement some simple syntax
->      extensions for plpgsql. Eventually, want to use this to write
->      macro type things for plpgsql.
->
->      The transforms here were already implemented as dynamic pl/pgsql
->      generation from pl/pgsql itself, hopefully this approach will
->      turn out to be a bit more maintainable, and the resultant code
->      visible to the hssqlppp type checking process.
->
->      Only some of the extensions needed are here, and they are only
->      part implemented, the first milestone is to get the type
->      checking working, without e.g. worrying about the bodies of
->      generated functions.
->  -}
-
-> module Database.HsSqlPpp.Extensions.ChaosExtensions
->     (
->      extensionize
->     ,addReadonlyTriggers
->     ,rewriteCreateVars
->     ,createClientActionWrapper
->     ,addNotifyTriggers
->     ,addConstraint
->     ,addKey
->     ,addForeignKey
->     ,zeroOneTuple
->     ,noDelIns
->     ,transitionConstraints
->     ,replaceGenerateSpellChoiceActions
->     ) where
-
-> import Data.Generics
-> import Data.Generics.Uniplate.Data
-> import Debug.Trace
-
-> import Text.Parsec hiding(many, optional, (<|>))
-> import qualified Text.Parsec.Token as P
-> import Text.Parsec.Language
-
-> import Control.Applicative
-> import Control.Monad.Identity
-> import Data.List
-
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Parsing.Lexer
-> import Database.HsSqlPpp.Parsing.Parser
-
-
-
-> data FunCallView = FUnit
->                  | FunCallView Annotation String [Expression]
-
-> funCallView :: Statement -> FunCallView
-> funCallView (SelectStatement an (Select _ _ (SelectList _ [SelExp _ (FunCall _ fnName
->               args)] []) [] Nothing [] Nothing [] Nothing Nothing)) = FunCallView an fnName args
-> funCallView _ = FUnit
-
-> -- | run all the extensions in this module on the given ast
-> extensionize :: Data a => a -> a
-> extensionize = addReadonlyTriggers .
->                rewriteCreateVars .
->                createClientActionWrapper .
->                addNotifyTriggers .
->                addConstraint .
->                addKey .
->                addForeignKey .
->                zeroOneTuple .
->                noDelIns .
->                transitionConstraints .
->                replaceGenerateSpellChoiceActions
-
-
-================================================================================
-
-My dodgy SQL code uses a function called create_var to create a table
-with a single attribute, which can hold 0 or 1 tuples (it adds the
-constraints to handle all this), a bit like a global maybe
-variable. It also creates a wrapper function to return the value from
-the table which is sometimes more convenient to use in expressions
-instead of e.g. a join.
-e.g.
-select create_var('name', 'type');
-->
-create table name_table (
-    name type
-);
-
-create function get_name() returns type as $a$
-  select * from name_table;
-$a$ language sql stable;
-[missing constraint stuff...]
-
-When trying to type check these files, my code can't work out that the
-create_var invocation changes the catalog in this way, as a hack to
-get round this tried to write a little generic function which
-transforms the create var invocation to the create table and create
-function by transforming the ast tree before it is type checked. With
-this in place, the code can type check these tables.
-
-The future plan is to get rid of the create var function definition in
-the sql entirely, and just use this macro feature instead. (so we
-still call create_var in the same way). The main motivation is to make
-type checking the code easier (the other obvious alternative is to
-write a partial interpreter for pl/pgsql which sounds like an immense
-amount of work in comparison).
-
-> -- | short cut for creating a table with exactly one attribute whose
-> -- cardinality is restricted to 0 or 1. Also provides a get_var function shortcut.
-> rewriteCreateVars :: Data a => a -> a
-> rewriteCreateVars =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "create_var" [StringLit _ _ tableName,StringLit _ _ typeName]):tl
->             -> [(CreateTable an
->                            (tableName ++ "_table")
->                            [AttributeDef an
->                                          tableName
->                                          (SimpleTypeName an typeName)
->                                          Nothing
->                                          []]
->                            [])
->                 ,(CreateFunction an ("get_" ++ tableName) []
->                     (SimpleTypeName an typeName) Sql "$a$"
->                     (SqlFnBody an
->                      [SelectStatement an
->                       (Select an Dupes
->                        (SelectList an
->                         [SelExp an
->                          (Identifier an "*")] [])
->                        [Tref an (tableName ++ "_table") NoAlias]
->                        Nothing [] Nothing [] Nothing Nothing)]) Stable)]
->                ++ createKey an (tableName ++ "_table") [tableName]
->                ++ createConstraint True an [tableName ++ "_table"] (tableName ++ "_table_01_tuple") "true"
->                ++ tl
->         x1 -> x1
-
-================================================================================
-
-> -- | looks for calls to function set_relvar_type and adds triggers to prevent the
-> -- referenced table from being updated
-> addReadonlyTriggers :: Data a => a -> a
-> addReadonlyTriggers =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "set_relvar_type" [StringLit _ _ tableName,StringLit _ _ "readonly"]):tl
->             -> (flip map "diu" ( \t ->
->                     (CreateFunction an ("check_" ++ tableName ++ "_" ++ [t] ++ "_readonly") []
->                                     (SimpleTypeName an "trigger") Plpgsql
->                                     "$a$"
->                                     (PlpgsqlFnBody an [] [
->                                       If an
->                                         [(FunCall an "!not" [BooleanLit an False]
->                                          ,[Raise an RException
->                                            "delete on base_relvar_metadata \
->                                            \violates transition constraint \
->                                            \base_relvar_metadata_d_readonly" []])] []
->                                      ,Return an $ Just $ NullLit an])
->                                     Volatile)) ++ tl)
->         x1 -> x1
-
-================================================================================
-
-> -- | a numpty currying type thing for plpgsql functions
-> createClientActionWrapper :: Data a => a -> a
-> createClientActionWrapper =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "create_client_action_wrapper" [StringLit _ _ actname,StringLit _ _ actcall]):tl
->           -> (CreateFunction an ("action_" ++ actname) []
->                                     (SimpleTypeName an "void") Plpgsql
->                                     "$a$"
->                                     (PlpgsqlFnBody an [] [
->                                       let (n,as) = parseActionCall actcall
->                                       in Perform an (FunCall an ("action_" ++ n) (map (StringLit an "'") as))
->                                      ]) Volatile : tl)
->         x1 -> x1
->     where
->       parseActionCall :: String -> (String,[String])
->       parseActionCall = parseCcawac
-
-> parseCcawac :: String -> (String,[String])
-> parseCcawac s = case runParser ccawac [] "" s of
->                   Left e -> trace ("failed to parse " ++ s) $ error $ show e
->                   Right r -> r
-
-> ccawac :: ParsecT String LexState Identity (String, [String])
-> ccawac = (,)
->          <$> identifierString
->          <*> parens (sepBy ccawacarg (symbol ","))
-
-> ccawacarg :: ParsecT String LexState Identity String
-> ccawacarg = (symbol "'" *> many (noneOf "'") <* symbol "'")
->             <|> identifierString
-
-> parens :: ParsecT String LexState Identity a -> ParsecT String LexState Identity a
-> parens = between (symbol "(") (symbol ")")
-
-> symbol :: String -> ParsecT String LexState Identity String
-> symbol = P.symbol lexer
-
-> lexer :: P.GenTokenParser String LexState Identity
-> lexer = P.makeTokenParser emptyDef
-
-================================================================================
-
-> -- | add a trigger to each data table to raise a notify signal when changed
-> addNotifyTriggers :: Data a => a -> a
-> addNotifyTriggers =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "set_relvar_type" [StringLit _ _ tableName,StringLit _ _ "data"]):tl
->           -> (CreateFunction an (tableName ++ "_changed") []
->                                     (SimpleTypeName an "trigger") Plpgsql
->                                     "$a$"
->                                     (PlpgsqlFnBody an [] [
->                                       Notify an tableName
->                                      ,Return an $ Just $ NullLit an
->                                      ]) Volatile : tl)
->         x1 -> x1
-
-================================================================================
-
-> -- | wrapped for the extended constraint system - allows adding constraints
-> -- which refer to multiple rows/ multiple tables.
-> addConstraint :: Data a => a -> a
-> addConstraint =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "add_constraint"
->                           [StringLit _ _ conName
->                           ,StringLit _ _ expr
->                           ,FunCall _ "!arrayctor" tbls]):tl
->           -> createConstraint True an (getStrings tbls) conName expr ++ tl
->         x1 -> x1
-
-> parseExpressionWrap :: String -> Expression
-> parseExpressionWrap s = case parseExpression "" s of
->                           Left e -> trace ("parsing expression: " ++ s) $ error $ show e
->                           Right ast -> ast
-
-> createConstraint :: Bool
->                  -> Annotation
->                  -> [String]
->                  -> String
->                  -> String
->                  -> [Statement]
-> createConstraint tr an tbls name expr =
->     CreateFunction an ("check_con_" ++ name) []
->      (SimpleTypeName an "boolean") Plpgsql "$a$"
->      (PlpgsqlFnBody an [] [
->         Return an $ Just $
->         stripAnnotations (parseExpressionWrap expr)
->       ]) Stable :
->     if tr
->       then concatMap (\t -> [DropFunction an IfExists [(t ++ "_constraint_trigger_operator",[])] Restrict
->                ,CreateFunction an (t ++ "_constraint_trigger_operator") []
->                                    (SimpleTypeName an "trigger") Plpgsql "$a$"
->                                    (PlpgsqlFnBody an [] [
->                                                        NullStatement an]) Volatile]
->                                    ) tbls
->       else []
-
-> -- | implement key constraints so that they are integrated with the extended constraint
-> -- system, uses pg keys internally.
-> addKey :: Data a => a -> a
-> addKey =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "add_key"
->                           [StringLit _ _ tableName
->                           ,StringLit _ _ columnName]):tl
->           -> createKey an tableName [columnName] ++ tl
->         (funCallView -> FunCallView an "add_key"
->                           [StringLit _ _ tableName
->                           ,FunCall _ "!arrayctor" cols]):tl
->           -> createKey an tableName (getStrings cols) ++ tl
->         x1 -> x1
-
-> getStrings :: [Expression] -> [String]
-> getStrings = map (\(StringLit _ _ c) -> c)
-
-> createKey :: Annotation
->           -> String
->           -> [String]
->           -> [Statement]
-> createKey an tableName colNames =
->    let cn = take 49 (tableName ++ "_" ++ intercalate "_" colNames) ++ "_key"
->    in createConstraint False an [tableName] cn "true"
-
-> -- | extended inclusion dependency (I think that is the fashionable term these days).
-> -- to allow 'foreign keys' to non key attributes, as well as regular foreign keys
-> addForeignKey :: Data a => a -> a
-> addForeignKey =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "add_foreign_key"
->                           [StringLit _ _ tableName
->                           ,StringLit _ _ colName
->                           ,StringLit _ _ ttableName]):tl
->           -> createFk an tableName [colName] ttableName [colName] ++ tl
->         (funCallView -> FunCallView an "add_foreign_key"
->                           [StringLit _ _ tableName
->                           ,FunCall _ "!arrayctor" cols
->                           ,StringLit _ _ ttableName]):tl
->           -> createFk an tableName (getStrings cols) ttableName (getStrings cols) ++ tl
->         (funCallView -> FunCallView an "add_foreign_key"
->                           [StringLit _ _ tableName
->                           ,StringLit _ _ colName
->                           ,StringLit _ _ ttableName
->                           ,StringLit _ _ tcolName]):tl
->           -> createFk an tableName [colName] ttableName [tcolName] ++ tl
->         (funCallView -> FunCallView an "add_foreign_key"
->                           [StringLit _ _ tableName
->                           ,FunCall _ "!arrayctor" cols
->                           ,StringLit _ _ ttableName
->                           ,FunCall _ "!arrayctor" tcols]):tl
->           -> createFk an tableName (getStrings cols) ttableName (getStrings tcols) ++ tl
->         x1 -> x1
->     where
->       createFk an tbl atts _ _  =
->           createConstraint False an [tbl] (tbl ++ "_" ++ intercalate "_" atts ++ "_fkey") "true"
-
-> -- | convert calls to zero or one tuple to constraint
-> zeroOneTuple :: Data a => a -> a
-> zeroOneTuple =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "constrain_to_zero_or_one_tuple"
->                           [StringLit _ _ tableName]):tl
->           -> createConstraint True an [tableName] (tableName ++ "_01_tuple") "true" ++ tl
->         x1 -> x1
-
-================================================================================
-
-> noDelIns :: Data a => a -> a
-> noDelIns =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "no_deletes_inserts_except_new_game"
->                           [StringLit _ _ tbl]):tl
->           -> flip map ["_no_delete","_no_insert"] (\n ->
->                CreateFunction an ("check_" ++ tbl ++ n) []
->                (SimpleTypeName an "trigger") Plpgsql "$a$"
->                (PlpgsqlFnBody an [] [
->                                  NullStatement an
->                                 ]) Stable) ++ tl
->         x1 -> x1
-
-================================================================================
-
-> transitionConstraints :: Data a => a -> a
-> transitionConstraints =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "create_update_transition_tuple_constraint"
->                           [StringLit _ _ _
->                           ,StringLit _ _ cn
->                           ,StringLit _ _ _]):tl
->           -> addTrigger an cn ++ tl
->         (funCallView -> FunCallView an "create_insert_transition_tuple_constraint"
->                           [StringLit _ _ _
->                           ,StringLit _ _ cn
->                           ,StringLit _ _ _]):tl
->           -> addTrigger an cn ++ tl
->         (funCallView -> FunCallView an "create_delete_transition_tuple_constraint"
->                           [StringLit _ _ _
->                           ,StringLit _ _ cn
->                           ,StringLit _ _ _]):tl
->           -> addTrigger an cn ++ tl
->         x1 -> x1
->     where
->       addTrigger an n =
->           [CreateFunction an ("check_" ++ n) []
->                (SimpleTypeName an "trigger") Plpgsql "$a$"
->                (PlpgsqlFnBody an [] [
->                 NullStatement an
->                 ]) Stable]
-
-================================================================================
-
-generate_spell_choice_actions
-
-quite dynamic: need to read the data from the spells_mr table to
-generate the names of the functions
-
-approach:
-first: remove the create function generate_spell_choice_actions, the
-select generate_spel..., and the drop function so these aren't used at
-all
-second: at the point where generate_spell_choice_actions was called,
-insert the create functions. To do this need to get the copydata for
-the copy statement which set up the data in spells_mr, then read the
-first cell from each line in the copy data string.
-
-additional hack: just hardcode the spell names here since they are
-unlikely to change for quite a while
-
-> getSpellNames :: Data a => a -> [String]
-> getSpellNames _ = ["chaos"
->                   ,"dark_citadel"
->                   ,"dark_power"
->                   ,"decree"
->                   ,"disbelieve"
->                   ,"eagle"
->                   ,"elf"
->                   ,"faun"
->                   ,"ghost"
->                   ,"giant_rat"
->                   ,"giant"
->                   ,"goblin"
->                   ,"golden_dragon"
->                   ,"gooey_blob"
->                   ,"gorilla"
->                   ,"green_dragon"
->                   ,"gryphon"
->                   ,"harpy"
->                   ,"horse"
->                   ,"hydra"
->                   ,"justice"
->                   ,"king_cobra"
->                   ,"large_chaos"
->                   ,"large_law"
->                   ,"law"
->                   ,"lightning"
->                   ,"lion"
->                   ,"magic_armour"
->                   ,"magic_bolt"
->                   ,"magic_bow"
->                   ,"magic_castle"
->                   ,"magic_fire"
->                   ,"magic_knife"
->                   ,"magic_shield"
->                   ,"magic_sword"
->                   ,"magic_wings"
->                   ,"magic_wood"
->                   ,"manticore"
->                   ,"ogre"
->                   ,"orc"
->                   ,"pegasus"
->                   ,"raise_dead"
->                   ,"red_dragon"
->                   ,"shadow_form"
->                   ,"shadow_wood"
->                   ,"skeleton"
->                   ,"spectre"
->                   ,"subversion"
->                   ,"turmoil"
->                   ,"unicorn"
->                   ,"vampire"
->                   ,"vengeance"
->                   ,"wall"
->                   ,"wraith"
->                   ,"zombie"]
-
-
-> replaceGenerateSpellChoiceActions :: Data a => a -> a
-> replaceGenerateSpellChoiceActions d = let sn = getSpellNames d
->                                       in replaceGenerateSpellChoiceActionsInt sn d
-
-> replaceGenerateSpellChoiceActionsInt :: Data a => [String] -> a -> a
-> replaceGenerateSpellChoiceActionsInt spellNames =
->     transformBi $ \x ->
->       case x of
->         (funCallView -> FunCallView an "generate_spell_choice_actions" []):tl
->           -> map (createChoiceFn an) spellNames ++ tl
->         (CreateFunction _ "generate_spell_choice_actions" _ _ _ _ _ _):tl
->           -> tl
->         (DropFunction _ _ [("generate_spell_choice_actions",[])] _):tl
->           -> tl
->         x1 -> x1
->     where
->       createChoiceFn an sn =
->         CreateFunction an ("action_choose_" ++ sn ++ "_spell")
->                        []
->                        (SimpleTypeName [] "void")
->                        Plpgsql
->                        "$$"
->                        (PlpgsqlFnBody an [] [
->                                            NullStatement an
->                                           ]) Volatile
-
-CREATE FUNCTION action_choose_horse_spell() RETURNS void
-    LANGUAGE plpgsql
-    AS $$
-begin
-  perform check_can_run_action('choose_horse_spell');
-  perform action_choose_spell('horse');
-end;
-$$;
-
diff --git a/Database/HsSqlPpp/Here.lhs b/Database/HsSqlPpp/Here.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Here.lhs
+++ /dev/null
@@ -1,15 +0,0 @@
-
-Multiline string support, mainly used to enter multiline sql strings
-
-robbed from http://old.nabble.com/Multi-line-string-literals-are-both-easy--and--elegant-in-Haskell-td19959973.html
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.Here where
-
-> import Language.Haskell.TH.Quote
-> --import Language.Haskell.TH.Syntax
-> import Language.Haskell.TH.Lib
-
-> here :: QuasiQuoter
-> here = QuasiQuoter (litE . stringL) (litP . stringL)
diff --git a/Database/HsSqlPpp/HsText/Commands.lhs b/Database/HsSqlPpp/HsText/Commands.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/HsText/Commands.lhs
+++ /dev/null
@@ -1,46 +0,0 @@
-
-> module Database.HsSqlPpp.HsText.Commands
->     (defaultCommands
->     ,makeFile
->     ,shell
->     ,wrapCommand
->     ) where
-
-> import Data.Char
-> import Data.List
-> import System.Exit
-> import System.Process (readProcessWithExitCode)
-> import System.FilePath
-
-> import Control.Monad.Error
-
-
-> defaultCommands :: [(String,String -> IO String)]
-> defaultCommands = [("file", makeFile)
->                   ,("shell", shell)]
-
-> makeFile :: String -> IO String
-> makeFile s =
->   let (fn,content) = break ws $ dropWhile space s
->   in do
->     writeFile fn content
->     return $
->      "File " ++ fn ++ "\n\n"
->      ++ "~~~~~~~~~~~~{" ++ takeExtension fn ++ "}"
->      ++ content ++ "\n~~~~~~~~~~~~\n\n"
->   where
->     ws = (`elem` " \n\t")
->     space = (==' ')
-
-> shell :: String -> IO String
-> shell s = {-let (c:as) = words s
->           in -} do
->              (ex,o,e) <- readProcessWithExitCode "bash" ["-c", ("PATH=$PATH:~/wd/hssqlppp/trunk " ++ s)] ""
->              return $ o ++ e ++ case ex of
->                                         ExitSuccess -> ""
->                                         ExitFailure i -> "\nErrorCode: " ++ show i ++ "\n"
-
-PATH=$PATH:~/wd/hssqlppp/trunk && HsSqlSystem
-
-> wrapCommand :: String -> String -> (String -> IO String) -> (String -> IO String)
-> wrapCommand pre post c l = c l >>= \m -> return $ pre ++ m ++ post
diff --git a/Database/HsSqlPpp/HsText/HsText.lhs b/Database/HsSqlPpp/HsText/HsText.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/HsText/HsText.lhs
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-> module Database.HsSqlPpp.HsText.HsText
->     (hsTextify
->     ,defaultCommands
->     ,makeFile
->     ,shell
->     ,wrapCommand
->     ) where
-
-> import Text.Parsec hiding(many, optional, (<|>))
-
-> import Data.Char
-> import Data.List
-> import System.Directory
-
-> import Control.Applicative
-> import Control.Monad.Identity
-> import Control.Monad.Error
-> import Control.Exception (bracket)
-
-> import Database.HsSqlPpp.HsText.Commands
-
-> data TextChunk = TextChunk String
->                | CommandInfo String String
->                  deriving Show
-
-> type Command = String -> IO String
-
-> hsTextify :: [(String, Command)] -> String -> String -> IO (Either String String)
-> hsTextify cmds folder txt = do
->   cd <- getCurrentDirectory
->   setCurrentDirectory folder
->   bracket (return ())
->           (\_ -> setCurrentDirectory cd)
->    $ return $ runErrorT $
->        liftM concat
->          (either (throwError . show) return (parseText txt) >>=
->            mapM (liftIO . processCommand cmds))
-
-> processCommand :: [(String, Command)] -> TextChunk -> IO String
-> processCommand _ (TextChunk s) = return s
-> processCommand cmds (CommandInfo c a) = do
->   let cr = lookup (map toLower c) cmds
->   case cr of
->     Nothing -> return $ "Command not found: " ++ c
->     Just f -> catchEx (f a)
-
-> catchEx :: IO String -> IO String
-> catchEx s = catch s (\i -> return $ "ERROR: " ++ show i)
-
-================================================================================
-
-parsing
-
-> parseText :: String -> Either ParseError [TextChunk]
-> parseText = runParser (many textChunk) () ""
-
-> textChunk :: ParsecT String () Identity TextChunk
-> textChunk = command <|> nonCommand
-
-> command :: ParsecT String () Identity TextChunk
-> command = CommandInfo
->           <$> (string "<%Command " *> many (noneOf " "))
->           <*> manyTill anyChar (try (string "%>"))
-
-> nonCommand :: ParsecT String () Identity TextChunk
-> nonCommand = TextChunk
->              <$> ((:) <$> anyChar <*>
->                   manyTill anyChar
->                      (try (lookAhead(string "<%Command ") >> return ())
->                       <|> eof))
diff --git a/Database/HsSqlPpp/Parsing/Lexer.lhs b/Database/HsSqlPpp/Parsing/Lexer.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Parsing/Lexer.lhs
+++ /dev/null
@@ -1,298 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains the lexer for sql source text.
-
-Lexicon:
-
-string
-identifier or keyword
-symbols - operators and ;,()[]
-positional arg
-int
-float
-copy payload (used to lex copy from stdin data)
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.Parsing.Lexer (
->               Token
->              ,Tok(..)
->              ,lexSqlFile
->              ,lexSqlText
->              ,lexSqlTextWithPosition
->              ,identifierString
->              ,LexState
->              ) where
-
-> import Text.Parsec hiding(many, optional, (<|>))
-> import qualified Text.Parsec.Token as P
-> import Text.Parsec.Language
-> import Text.Parsec.String
-> import Text.Parsec.Pos
-
-> import Control.Applicative
-> import Control.Monad.Identity
-
-> import Database.HsSqlPpp.Parsing.ParseErrors
-> import Database.HsSqlPpp.Utils
-
-================================================================================
-
-= data types
-
-> type Token = (SourcePos, Tok)
-
-> data Tok = StringTok String String --delim, value (delim will one of
->                                    --', $$, $[stuff]$
->          | IdStringTok String --includes . and x.y.* type stuff
->          | SymbolTok String -- operators, and ()[],;:
->                             -- '*' is currently always lexed as an id
->                             --   rather than an operator
->                             -- this gets fixed in the parsing stage
->          | PositionalArgTok Integer -- used for $1, etc.
->          | FloatTok Double
->          | IntegerTok Integer
->          | CopyPayloadTok String -- support copy from stdin; with inline data
->            deriving (Eq,Show)
-
-> type LexState = [Tok]
-
-> lexSqlFile :: FilePath -> IO (Either ParseErrorExtra [Token])
-> lexSqlFile f = do
->   te <- readFile f
->   let x = runParser sqlTokens [] f te
->   return $ toParseErrorExtra x Nothing te
-
-> lexSqlText :: String -> String -> Either ParseErrorExtra [Token]
-> lexSqlText f s = toParseErrorExtra (runParser sqlTokens [] f s) Nothing s
-
-> lexSqlTextWithPosition :: String -> Int -> Int -> String -> Either ParseErrorExtra [Token]
-> lexSqlTextWithPosition f l c s =
->   toParseErrorExtra (runParser (do
->                                 setPosition (newPos f l c)
->                                 sqlTokens) [] f s) (Just (l,c)) s
-
-================================================================================
-
-= lexers
-
-lexer for tokens, contains a hack for copy from stdin with inline
-table data.
-
-> sqlTokens :: ParsecT String LexState Identity [Token]
-> sqlTokens =
->   setState [] >>
->   whiteSpace >>
->   many sqlToken <* eof
-
-Lexer for an individual token.
-
-What we could do is lex lazily and when the lexer reads a copy from
-stdin statement, it switches lexers to lex the inline table data, then
-switches back. Don't know how to do this in parsec, or even if it is
-possible, so as a work around, we use the state to trap if we've just
-seen 'from stdin;', if so, we read the copy payload as one big token,
-otherwise we read a normal token.
-
-> sqlToken :: ParsecT String LexState Identity Token
-> sqlToken = do
->            sp <- getPosition
->            sta <- getState
->            t <- if sta == [ft,st,mt]
->                 then copyPayload
->                 else try sqlString
->                  <|> try idString
->                  <|> try positionalArg
->                  <|> try sqlSymbol
->                  <|> try sqlFloat
->                  <|> try sqlInteger
->            updateState $ \stt ->
->              case () of
->                      _ | stt == [] && t == ft -> [ft]
->                        | stt == [ft] && t == st -> [ft,st]
->                        | stt == [ft,st] && t == mt -> [ft,st,mt]
->                        | otherwise -> []
-
->            return (sp,t)
->            where
->              ft = IdStringTok "from"
->              st = IdStringTok "stdin"
->              mt = SymbolTok ";"
-
-== specialized token parsers
-
-> sqlString :: ParsecT String LexState Identity Tok
-> sqlString = stringQuotes <|> stringLD
->   where
->     --parse a string delimited by single quotes
->     stringQuotes = StringTok "\'" <$> stringPar
->     stringPar = optional (char 'E') *> char '\''
->                 *> readQuoteEscape <* whiteSpace
->     --(readquoteescape reads the trailing ')
-
-have to read two consecutive single quotes as a quote character
-instead of the end of the string, probably an easier way to do this
-
-other escapes (e.g. \n \t) are left unprocessed
-
->     readQuoteEscape = do
->                       x <- anyChar
->                       if x == '\''
->                         then try ((x:) <$> (char '\'' *> readQuoteEscape))
->                              <|> return ""
->                         else (x:) <$> readQuoteEscape
-
-parse a dollar quoted string
-
->     stringLD = do
->                -- cope with $$ as well as $[identifier]$
->                tag <- try (char '$' *> ((char '$' *> return "")
->                                    <|> (identifierString <* char '$')))
->                s <- lexeme $ manyTill anyChar
->                       (try $ char '$' <* string tag <* char '$')
->                return $ StringTok ("$" ++ tag ++ "$") s
-
-> idString :: ParsecT String LexState Identity Tok
-> idString = IdStringTok <$> identifierString
-
-> positionalArg :: ParsecT String LexState Identity Tok
-> positionalArg = char '$' >> PositionalArgTok <$> integer
-
-
-Lexing symbols:
-
-approach 1:
-try to keep multi symbol operators as single lexical items
-(e.g. "==", "~=="
-
-approach 2:
-make each character a separate element
-e.g. == lexes to ['=', '=']
-then the parser sorts this out
-
-Sort of using approach 1 at the moment, see below
-
-== notes on symbols in pg operators
-pg symbols can be made from:
-
-=_*/<>=~!@#%^&|`?
-
-no --, /* in symbols
-
-can't end in + or - unless contains
-~!@#%^&|?
-
-Most of this isn't relevant for the current lexer.
-
-== sql symbols for this lexer:
-
-sql symbol is one of
-()[],; - single character
-+-*/<>=~!@#%^&|`? string - one or more of these, parsed until hit char
-which isn't one of these (including whitespace). This will parse some
-standard sql expressions wrongly at the moment, work around is to add
-whitespace e.g. i think 3*-4 is valid sql, should lex as '3' '*' '-'
-'4', but will currently lex as '3' '*-' '4'. This is planned to be
-fixed in the parser.
-.. := :: : - other special cases
-A single * will lex as an identifier rather than a symbol, the parser
-deals with this.
-
-> sqlSymbol :: ParsecT String LexState Identity Tok
-> sqlSymbol =
->   SymbolTok <$> lexeme (choice [
->                          replicate 1 <$> oneOf "()[],;"
->                         ,string ".."
->                         ,try $ string "::"
->                         ,try $ string ":="
->                         ,string ":"
->                         ,many1 (oneOf "+-*/<>=~!@#%^&|`?")
->                         ])
-
-> sqlFloat :: ParsecT String LexState Identity Tok
-> sqlFloat = FloatTok <$> float
-
-> sqlInteger :: ParsecT String LexState Identity Tok
-> sqlInteger = IntegerTok <$> integer
-
-================================================================================
-
-additional parser bits and pieces
-
-include dots, * in all identifier strings during lexing. This parser
-is also used for keywords, so identifiers and keywords aren't
-distinguished until during proper parsing, and * and qualifiers aren't
-really examined until type checking
-
-> identifierString :: ParsecT String LexState Identity String
-> identifierString = lexeme $ choice [
->                     "*" <$ symbol "*"
->                    ,do
->                      a <- nonStarPart
->                      b <- tryMaybeP ((++) <$> symbol "." <*> identifierString)
->                      case b of Nothing -> return a
->                                Just c -> return $ a ++ c]
->   where
->     nonStarPart = idpart <|> (char '"' *> many (noneOf "\"") <* char '"')
->                   where idpart = (letter <|> char '_') <:> secondOnwards
->     secondOnwards = many (alphaNum <|> char '_')
-
-parse the block of inline data for a copy from stdin, ends with \. on
-its own on a line
-
-> copyPayload :: ParsecT String LexState Identity Tok
-> copyPayload = CopyPayloadTok <$> lexeme (getLinesTillMatches "\\.\n")
->   where
->     getLinesTillMatches s = do
->                             x <- getALine
->                             if x == s
->                               then return ""
->                               else (x++) <$> getLinesTillMatches s
->     getALine = (++"\n") <$> manyTill anyChar (try newline)
-
-> tryMaybeP :: GenParser tok st a
->           -> ParsecT [tok] st Identity (Maybe a)
-> tryMaybeP p = try (optionMaybe p) <|> return Nothing
-
-
-================================================================================
-
-= parsec pass throughs
-
-> symbol :: String -> ParsecT String LexState Identity String
-> symbol = P.symbol lexer
-
-> integer :: ParsecT String LexState Identity Integer
-> integer = lexeme $ P.integer lexer
-
-> float :: ParsecT String LexState Identity Double
-> float = lexeme $ P.float lexer
-
-> whiteSpace :: ParsecT String LexState Identity ()
-> whiteSpace= P.whiteSpace lexer
-
-> lexeme :: ParsecT String LexState Identity a
->           -> ParsecT String LexState Identity a
-> lexeme = P.lexeme lexer
-
-this lexer isn't really used as much as it could be, probably some of
-the fields are not used at all (like identifier and operator stuff)
-
-> lexer :: P.GenTokenParser String LexState Identity
-> lexer = P.makeTokenParser (emptyDef {
->                             P.commentStart = "/*"
->                            ,P.commentEnd = "*/"
->                            ,P.commentLine = "--"
->                            ,P.nestedComments = False
->                            ,P.identStart = letter <|> char '_'
->                            ,P.identLetter    = alphaNum <|> oneOf "_"
->                            ,P.opStart        = P.opLetter emptyDef
->                            ,P.opLetter       = oneOf opLetters
->                            ,P.reservedOpNames= []
->                            ,P.reservedNames  = []
->                            ,P.caseSensitive  = False
->                            })
-
-> opLetters :: String
-> opLetters = ".:^*/%+-<>=|!"
-
diff --git a/Database/HsSqlPpp/Parsing/ParseErrors.lhs b/Database/HsSqlPpp/Parsing/ParseErrors.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Parsing/ParseErrors.lhs
+++ /dev/null
@@ -1,76 +0,0 @@
-Copyright 2009 Jake Wheat
-
-convert error messages to show source text fragment with little hat,
-plus output error location in emacs friendly format.
-
-> {-# OPTIONS_HADDOCK hide #-}
-
-> module Database.HsSqlPpp.Parsing.ParseErrors
->     (toParseErrorExtra
->     ,ParseErrorExtra(..)) where
-
-> import Text.Parsec
-> import Control.Monad.Error
-
-> showPE :: ParseError -> Maybe (Int,Int) -> String -> String
-> showPE pe sp src = show pe ++ "\n" ++ pePosToEmacs pe ++ "\n" ++ peToContext pe sp src
-
-> pePosToEmacs :: ParseError -> String
-> pePosToEmacs pe = let p = errorPos pe
->                       f = sourceName p
->                       l = sourceLine p
->                       c = sourceColumn p
->                   in f ++ ":" ++ show l ++ ":" ++ show c ++ ":"
-
-> peToContext :: ParseError -> Maybe (Int,Int) -> String -> String
-> peToContext pe sp src =
->      let ls = lines src
->          line = safeGet ls(lineNo - 1)
->          prelines = map (safeGet ls) [(lineNo - 5) .. (lineNo - 2)]
->          postlines = map (safeGet ls) [lineNo .. (lineNo + 5)]
->          caretLine = replicate (colNo - 1) ' ' ++ "^"
->          errorHighlightText = prelines
->                               ++ [line, caretLine, "ERROR HERE"]
->                               ++ postlines
->     in "\nContext:\n"
->        ++ unlines (trimLines errorHighlightText) ++ "\n"
->     where
->       safeGet a i = if i < 0 || i >= length a
->                       then ""
->                       else a !! i
->       trimLines = trimStartLines . reverse . trimStartLines . reverse
->       trimStartLines = dropWhile (=="")
->       pos = errorPos pe
->       lineNo = sourceLine pos - adjLine
->       colNo = sourceColumn pos
->       adjLine = case sp of
->                         Just (l, _) -> l - 1
->                         Nothing -> 0
-
-> -- | Simple wrapper to allow showing the source context of a ParseError
-> data ParseErrorExtra = ParseErrorExtra {
->                                        -- | wrapped error
->                                        parseErrorError :: ParseError
->                                        -- | source position
->                                        -- adjustment to get the
->                                        -- context bit in error
->                                        -- messages right - this is
->                                        -- the same as what is passed
->                                        -- into parseSqlWithPosition
->                                       ,parseErrorPosition :: (Maybe (Int, Int))
->                                        -- | sql source
->                                       ,parseErrorSqlSource :: String
->     }
-
-> instance Show ParseErrorExtra where
->     show (ParseErrorExtra pe sp src) = showPE pe sp src
-
-> instance Error ParseErrorExtra where
->   noMsg = ParseErrorExtra undefined Nothing "unknown"
->   strMsg = ParseErrorExtra undefined Nothing
-
-
-> toParseErrorExtra :: Either ParseError b -> Maybe (Int,Int) -> String -> Either ParseErrorExtra b
-> toParseErrorExtra a sp src = case a of
->                                Left pe -> Left $ ParseErrorExtra pe sp src
->                                Right x -> Right x
diff --git a/Database/HsSqlPpp/Parsing/Parser.lhs b/Database/HsSqlPpp/Parsing/Parser.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Parsing/Parser.lhs
+++ /dev/null
@@ -1,1510 +0,0 @@
-Copyright 2009 Jake Wheat
-
-The main file for parsing sql, uses parsec. Not sure if parsec is the
-right choice, but it seems to do the job pretty well at the moment.
-
-For syntax reference see
-http://savage.net.au/SQL/sql-2003-2.bnf.html
-and
-http://savage.net.au/SQL/sql-92.bnf.html
-for some online sql grammar guides
-and
-http://www.postgresql.org/docs/8.4/interactive/sql-syntax.html
-for some notes on postgresql syntax (the rest of that manual is also helpful)
-
-Some further reference/reading:
-
-parsec tutorial:
-http://legacy.cs.uu.nl/daan/download/parsec/parsec.html
-
-parsec reference:
-http://hackage.haskell.org/package/parsec-3.0.0
-
-pdf about parsing, uses haskell and parser combinators for examples
-and exercises:
-http://www.cs.uu.nl/docs/vakken/gont/diktaat.pdf
-
-The parsers are written top down as you go through the file, so the
-top level sql text parsers appear first, then the statements, then the
-fragments, then the utility parsers and other utilities at the bottom.
-
-> {-# LANGUAGE RankNTypes,FlexibleContexts #-}
-
-> {- | Functions to parse sql.
-> -}
-> module Database.HsSqlPpp.Parsing.Parser (
->              -- * Main
->               parseSql
->              ,parseSqlWithPosition
->              ,parseSqlFile
->              -- * Testing
->              ,parseExpression
->              ,parsePlpgsql
->              -- * errors
->              ,ParseErrorExtra(..)
->              )
->     where
-
-> import Text.Parsec hiding(many, optional, (<|>), string)
-> import Text.Parsec.Expr
-> import Text.Parsec.String
-> import Text.Parsec.Perm
-> --import Text.Parsec.Error
-
-> import Control.Applicative
-> import Control.Monad.Identity
-
-> import Data.Maybe
-> import Data.Char
-
-> import Data.Generics.PlateData
-> import Data.Generics hiding (Prefix,Infix)
-
-> import Database.HsSqlPpp.Parsing.Lexer
-> import Database.HsSqlPpp.Parsing.ParseErrors
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Annotation as A
-> import Database.HsSqlPpp.Utils
-> import Database.HsSqlPpp.Ast.Catalog
-
-The parse state is used to keep track of source positions inside
-function bodies, these bodies are parsed separately to the rest of the
-code which is why we need to do this.
-
-> type MySourcePos = (String,Int,Int)
-> type ParseState = [MySourcePos]
-
-> startState :: ParseState
-> startState = []
-
-> toMySp :: SourcePos -> MySourcePos
-> toMySp sp = (sourceName sp, sourceLine sp, sourceColumn sp)
-
-================================================================================
-
-= Top level parsing functions
-
-> parseSql :: String -- ^ filename to use in errors
->          -> String -- ^ a string containing the sql to parse
->          -> Either ParseErrorExtra StatementList
-> parseSql f s = parseIt (lexSqlText f s) sqlStatements f Nothing s startState
-
-> parseSqlWithPosition :: FilePath -- ^ filename to use in errors
->                      -> Int -- ^ adjust line number in errors by adding this
->                      -> Int -- ^ adjust column in errors by adding this
->                      -> String -- ^ a string containing the sql to parse
->                      -> Either ParseErrorExtra StatementList
-> parseSqlWithPosition f l c s = parseIt (lexSqlTextWithPosition f l c s) sqlStatements f (Just (l,c)) s startState
-
-
-> parseSqlFile :: FilePath -- ^ file name of file containing sql
->              -> IO (Either ParseErrorExtra StatementList)
-> parseSqlFile fn = do
->   sc <- readFile fn
->   x <- lexSqlFile fn
->   return $ parseIt x sqlStatements fn Nothing sc startState
-
-> -- | Parse expression fragment, used for testing purposes
-> parseExpression :: String
->                 -> String -- ^ sql string containing a single expression, with no
->                           -- trailing ';'
->                 -> Either ParseErrorExtra Expression
-> parseExpression f s = parseIt (lexSqlText f s) (expr <* eof) f Nothing s startState
-
-> -- | Parse plpgsql statements, used for testing purposes -
-> -- this can be used to parse a list of plpgsql statements which
-> -- aren't contained in a create function.
-> -- (The produced ast won't pass a type check.)
-> parsePlpgsql :: String
->              -> String
->              -> Either ParseErrorExtra StatementList
-> parsePlpgsql f s =  parseIt (lexSqlText f s) (many plPgsqlStatement <* eof) f Nothing s startState
-
-utility function to do error handling in one place
-TODO: support parsewithposition
-
-> parseIt :: forall t s u b.(Stream s Identity t, Data b) =>
->            Either ParseErrorExtra s
->         -> Parsec s u b
->         -> SourceName
->         -> Maybe (Int,Int)
->         -> String
->         -> u
->         -> Either ParseErrorExtra b
-> parseIt lexed parser fn sp src ss =
->     case lexed of
->                Left er -> Left er
->                Right toks -> let r1 = runParser parser ss fn toks
->                              in case toParseErrorExtra r1 sp src of
->                                   Left er -> Left er
->                                   Right t -> Right $ fixupTree t
-
-================================================================================
-
-= Parsing top level statements
-
-> sqlStatements :: ParsecT [Token] ParseState Identity [Statement]
-> sqlStatements = many (sqlStatement True) <* eof
-
-parse a statement
-
-> sqlStatement :: Bool -> ParsecT [Token] ParseState Identity Statement
-> sqlStatement reqSemi =
->    (choice [
->      selectStatement
->     ,insert
->     ,update
->     ,delete
->     ,truncateSt
->     ,copy
->     ,set
->     ,notify
->     ,keyword "create" *>
->              choice [
->                 createTable
->                ,createSequence
->                ,createType
->                ,createFunction
->                ,createView
->                ,createDomain
->                ,createLanguage
->                ,createTrigger]
->     ,keyword "alter" *>
->              choice [
->                 alterSequence
->                ,alterTable]
->     ,keyword "drop" *>
->              choice [
->                 dropSomething
->                ,dropFunction]]
->     <* (if reqSemi
->           then symbol ";" >> return ()
->           else optional (symbol ";") >> return ()))
->    <|> copyData
-
-================================================================================
-
-statement flavour parsers
-
-top level/sql statements first
-
-= select
-
-select parser, parses things starting with the keyword 'select'
-
-supports plpgsql 'select into' only for the variants which look like
-'select into ([targets]) [columnNames] from ...
-or
-'select [columnNames] into ([targets]) from ...
-This should be changed so it can only parse an into clause when
-expecting a plpgsql statement.
-
-recurses to support parsing excepts, unions, etc.
-this recursion needs refactoring cos it's a mess
-
-> selectStatement :: ParsecT [Token] ParseState Identity Statement
-> selectStatement = SelectStatement <$> pos <*> selectExpression
-
-> selectExpression :: ParsecT [Token] ParseState Identity SelectExpression
-> selectExpression =
->   buildExpressionParser combTable selFactor
->   where
->         selFactor = try (parens selectExpression) <|> selQuerySpec <|> values
->         combTable = [map (\(c,p) -> Infix (CombineSelect <$> pos <*> (c <$ p)) AssocLeft)
->                         [(Except, keyword "except")
->                         ,(Intersect, keyword "intersect")
->                         ,(UnionAll, try (keyword "union" *> keyword "all"))
->                         ,(Union, keyword "union")]]
->         selQuerySpec = Select <$> (pos <* keyword "select")
->                    <*> option Dupes (Distinct <$ keyword "distinct")
->                    <*> selectList
->                    <*> option [] from
->                    <*> optionMaybe whereClause
->                    <*> option [] groupBy
->                    <*> optionMaybe having
->                    <*> option [] orderBy
->                    <*> optionMaybe limit
->                    <*> optionMaybe offset
->         from = keyword "from" *> commaSep1 tref
->         groupBy = keyword "group" *> keyword "by"
->                   *> commaSep1 expr
->         having = keyword "having" *> expr
->         orderBy = keyword "order" *> keyword "by"
->                     *> commaSep1 oneOrder
->         oneOrder = (,) <$> expr
->                        <*> option Asc (choice [
->                                         Asc <$ keyword "asc"
->                                        ,Desc <$ keyword "desc"])
->         limit = keyword "limit" *> expr
->         offset = keyword "offset" *> expr
-
->         -- table refs
->         -- have to cope with:
->         -- a simple tableref i.e just a name
->         -- an aliased table ref e.g. select a.b from tbl as a
->         -- a sub select e.g. select a from (select b from c)
->         --  - these are handled in tref
->         -- then cope with joins recursively using joinpart below
->         tref = buildExpressionParser [] trefFactor
->         trefFactor = threadOptionalSuffix (nonJoinTref <|> try (parens tref)) joinPart <|> parens tref
->         --tref = optParens (threadOptionalSuffix (try (parens tref) <|> nonJoinTref) joinPart)
->         nonJoinTref = try $ optParens $ do
->                   p2 <- pos
->                   choice [
->                          SubTref p2
->                          <$> parens selectExpression
->                          <*> palias
->                         ,TrefFun p2
->                          <$> try (identifier >>= functionCallSuffix)
->                          <*> palias
->                         ,Tref p2
->                          <$> nkwid
->                          <*> palias]
->         --joinpart: parse a join after the first part of the tableref
->         --(which is a table name, aliased table name or subselect) -
->         --takes this tableref as an arg so it can recurse to multiple
->         --joins
->         joinPart tr1 = threadOptionalSuffix (readOneJoinPart tr1) joinPart
->         readOneJoinPart tr1 = do
->            p2 <- pos
->            JoinedTref p2 tr1
->              --look for the join flavour first
->              <$> option Unnatural (Natural <$ keyword "natural")
->              <*> choice [
->                 LeftOuter <$ try (keyword "left" *> optional (keyword "outer"))
->                ,RightOuter <$ try (keyword "right" *> optional (keyword "outer"))
->                ,FullOuter <$ try (keyword "full" >> optional (keyword "outer"))
->                ,Cross <$ keyword "cross"
->                ,Inner <$ optional (keyword "inner")]
->              --recurse back to tref to read the table
->              <*> (keyword "join" *> tref)
->              --now try and read the join condition
->              <*> choice [
->                  Just <$> (JoinOn <$> pos <*> (keyword "on" *> expr))
->                 ,Just <$> (JoinUsing <$> pos <*> (keyword "using" *> columnNameList))
->                 ,return Nothing]
->              <*> palias
->         palias = option NoAlias
->                    (optionalSuffix
->                       TableAlias (optional (keyword "as") *> nkwid)
->                       FullAlias () (parens $ commaSep1 idString))
->         nkwid = try $ do
->                  x <- idString
->                  --avoid all these keywords as aliases since they can
->                  --appear immediately following a tableref as the next
->                  --part of the statement, if we don't do this then lots
->                  --of things don't parse. Seems a bit inelegant but
->                  --works for the tests and the test sql files don't know
->                  --if these should be allowed as aliases without "" or
->                  --[]
->                  -- TODO find out what the correct behaviour here is.
->                  if map toLower x `elem` ["as"
->                              ,"where"
->                              ,"except"
->                              ,"union"
->                              ,"intersect"
->                              ,"loop"
->                              ,"inner"
->                              ,"on"
->                              ,"left"
->                              ,"right"
->                              ,"full"
->                              ,"cross"
->                              ,"join"
->                              ,"natural"
->                              ,"order"
->                              ,"group"
->                              ,"limit"
->                              ,"using"
->                              ,"from"]
->                    then fail "not keyword"
->                    else return x
->         values = Values <$> (pos <* keyword "values") <*> commaSep1 (parens $ commaSep1 expr)
-
-> optParens :: ParsecT [Token] ParseState Identity a
->           -> ParsecT [Token] ParseState Identity a
-> optParens p = try (parens p) <|> p
-
-= insert, update and delete
-
-insert statement: supports option column name list,
-multiple rows to insert and insert from select statements
-
-> insert :: ParsecT [Token] ParseState Identity Statement
-> insert = Insert
->          <$> pos <* keyword "insert" <* keyword "into"
->          <*> idString
->          <*> option [] (try columnNameList)
->          <*> selectExpression
->          <*> tryOptionMaybe returning
-
-> update :: ParsecT [Token] ParseState Identity Statement
-> update = Update
->          <$> pos <* keyword "update"
->          <*> idString
->          <*> (keyword "set" *> commaSep1 setClause)
->          <*> tryOptionMaybe whereClause
->          <*> tryOptionMaybe returning
->     where
->       setClause = choice
->             [RowSetClause <$> pos
->                           <*> parens (commaSep1 idString)
->                           <*> (symbol "=" *> parens (commaSep1 expr))
->             ,SetClause <$> pos
->                        <*> idString
->                        <*> (symbol "=" *> expr)]
-
-> delete :: ParsecT [Token] ParseState Identity Statement
-> delete = Delete
->          <$> pos <* keyword "delete" <* keyword "from"
->          <*> idString
->          <*> tryOptionMaybe whereClause
->          <*> tryOptionMaybe returning
-
-> truncateSt :: ParsecT [Token] ParseState Identity Statement
-> truncateSt =
->            Truncate
->            <$> pos <* keyword "truncate" <* optional (keyword "table")
->            <*> commaSep1 idString
->            <*> option ContinueIdentity (choice [
->                                 ContinueIdentity <$ (keyword "continue"
->                                                      <* keyword "identity")
->                                ,RestartIdentity <$ (keyword "restart"
->                                                     <* keyword "identity")])
->            <*> cascade
-
-> copy :: ParsecT [Token] ParseState Identity Statement
-> copy = do
->        p <- pos
->        keyword "copy"
->        tableName <- idString
->        cols <- option [] (parens $ commaSep1 idString)
->        keyword "from"
->        src <- choice [
->                CopyFilename <$> extrStr <$> stringLit
->               ,Stdin <$ keyword "stdin"]
->        return $ Copy p tableName cols src
-
-> copyData :: ParsecT [Token] ParseState Identity Statement
-> copyData = CopyData <$> pos <*> mytoken (\tok ->
->                                         case tok of
->                                                  CopyPayloadTok n -> Just n
->                                                  _ -> Nothing)
-
-> set :: ParsecT [Token] ParseState Identity Statement
-> set = Set <$> pos
->           <*> (keyword "set" *> idString)
->           <*> ((keyword "to" <|> symbol "=") *>
->               commaSep1 sv)
->       where
->         sv = choice [
->               SetStr <$> pos <*> stringN
->              ,SetId <$> pos <*> idString
->              ,SetNum <$> pos <*> ((fromInteger <$> integer) <|> float)]
-
-> notify :: ParsecT [Token] ParseState Identity Statement
-> notify = Notify <$> pos
->                 <*> (keyword "notify" *> idString)
-
-= ddl
-
-> createTable :: ParsecT [Token] ParseState Identity Statement
-> createTable = do
->   p <- pos
->   keyword "table"
->   tname <- idString
->   choice [
->      CreateTableAs p tname <$> (keyword "as" *> selectExpression)
->     ,uncurry (CreateTable p tname) <$> readAttsAndCons]
->   where
->     --parse our unordered list of attribute defs or constraints, for
->     --each line want to try the constraint parser first, then the
->     --attribute parser, so we need the swap to feed them in the
->     --right order into createtable
->     readAttsAndCons = parens (swap <$> multiPerm
->                                          (try tableConstraint)
->                                          tableAtt
->                                          (symbol ","))
->                       where swap (a,b) = (b,a)
->     tableAtt = AttributeDef
->                <$> pos
->                <*> idString
->                <*> typeName
->                <*> tryOptionMaybe (keyword "default" *> expr)
->                <*> many rowConstraint
->     rowConstraint = do
->        p <- pos
->        cn <- option "" (keyword "constraint" *> idString)
->        choice [
->           RowUniqueConstraint p cn <$ keyword "unique"
->          ,RowPrimaryKeyConstraint p cn <$ keyword "primary" <* keyword "key"
->          ,RowCheckConstraint p cn <$> (keyword "check" *> parens expr)
->          ,NullConstraint p cn <$ keyword "null"
->          ,NotNullConstraint p cn <$ (keyword "not" <* keyword "null")
->          ,RowReferenceConstraint p cn
->          <$> (keyword "references" *> idString)
->          <*> option Nothing (try $ parens $ Just <$> idString)
->          <*> onDelete
->          <*> onUpdate
->          ]
-
-> onDelete,onUpdate :: ParsecT [Token] ParseState Identity Cascade
-> onDelete = onSomething "delete"
-> onUpdate = onSomething "update"
-> onSomething :: String -> ParsecT [Token] ParseState Identity Cascade
-> onSomething k = option Restrict $ try $ keyword "on"
->                 *> keyword k *> cascade
-
-> tableConstraint :: ParsecT [Token] ParseState Identity Constraint
-> tableConstraint = do
->                 p <- pos
->                 cn <- option "" (keyword "constraint" *> option "" conName)
->                 choice [
->                    UniqueConstraint p cn
->                    <$> try (keyword "unique" *> optParens columnNameList)
->                    ,PrimaryKeyConstraint p cn
->                    <$> try (keyword "primary" *> keyword "key"
->                                     *> choice [
->                                             (:[]) <$> idString
->                                            ,parens (commaSep1 idString)])
->                    ,CheckConstraint p cn
->                    <$>try (keyword "check" *> parens expr)
->                    ,ReferenceConstraint p cn
->                    <$> try (keyword "foreign" *> keyword "key"
->                             *> parens (commaSep1 idString))
->                    <*> (keyword "references" *> idString)
->                    <*> option [] (parens $ commaSep1 idString)
->                    <*> onUpdate
->                    <*> onDelete]
->                 where
->                   conName = try $ do
->                             x <- idString
->                             if map toLower x `elem` [
->                                     "unique"
->                                    ,"primary"
->                                    ,"check"
->                                    ,"foreign"
->                                    ,"references"]
->                               then fail "not keyword"
->                               else return x
-
-
-> alterTable :: ParsecT [Token] ParseState Identity Statement
-> alterTable = AlterTable <$> (pos <* keyword "table" <* optional (keyword "only"))
->                         <*> idString
->                         <*> many1 action
->              where action = choice [
->                              AlterColumnDefault
->                              <$> (pos <* keyword "alter" <* keyword "column")
->                              <*> idString
->                              <*> (keyword "set" *> keyword "default" *> expr)
->                             ,AddConstraint
->                              <$> (pos <* keyword "add")
->                              <*> tableConstraint]
-
-> createType :: ParsecT [Token] ParseState Identity Statement
-> createType = CreateType
->              <$> pos <* keyword "type"
->              <*> idString
->              <*> (keyword "as" *> parens (commaSep1 typeAtt))
->   where
->     typeAtt = TypeAttDef <$> pos <*> idString <*> typeName
-
-> createSequence :: ParsecT [Token] ParseState Identity Statement
-> createSequence = do
->   p <- pos
->   keyword "sequence"
->   nm <- idString
->   (stw, incr, mx, mn, c) <- permute ((,,,,) <$?> (1,startWith)
->                                             <|?> (1,increment)
->                                             <|?> ((2::Integer) ^ (63::Integer) - 1, maxi)
->                                             <|?> (1, mini)
->                                             <|?> (1, cache))
->   return $ CreateSequence p nm incr mn mx stw c
->   where
->     startWith = keyword "start" *> optional (keyword "with") *> integer
->     increment = keyword "increment" *> optional (keyword "by") *> integer
->     maxi = (2::Integer) ^ (63::Integer) - 1 <$ try (keyword "no" <* keyword "maxvalue")
->     mini = 1 <$ try (keyword "no" <* keyword "minvalue")
->     cache = keyword "cache" *> integer
-
-> alterSequence :: ParsecT [Token] ParseState Identity Statement
-> alterSequence = AlterSequence <$> pos
->                               <*> (keyword "sequence" *> idString)
->                               <*> (keyword "owned" *> keyword "by" *> idString)
-
-create function, support sql functions and plpgsql functions. Parses
-the body in both cases and provides a statement list for the body
-rather than just a string.
-
-> createFunction :: ParsecT [Token] ParseState Identity Statement
-> createFunction = do
->   p <- pos
->   keyword "function"
->   fnName <- idString
->   params <- parens $ commaSep param
->   retType <- keyword "returns" *> typeName
->   ((bodypos,body), lang,vol) <-
->     permute ((,,) <$$> parseAs
->                   <||> readLang
->                   <|?> (Volatile,pVol))
->   case parseBody lang body bodypos of
->        Left er -> fail er
->        Right (q,b) -> return $ CreateFunction p fnName params retType lang q b vol
->     where
->         parseAs = do
->                    keyword "as"
->                    bodypos <- getAdjustedPosition
->                    body <- stringLit
->                    return (bodypos,body)
->         pVol = matchAKeyword [("volatile", Volatile)
->                              ,("stable", Stable)
->                              ,("immutable", Immutable)]
->         readLang = keyword "language" *> matchAKeyword [("plpgsql", Plpgsql)
->                                                        ,("sql",Sql)]
->         parseBody :: Language -> Expression -> MySourcePos -> Either String (String, FnBody)
->         parseBody lang body bodypos@(fileName,line,col) =
->             case (parseIt
->                   (lexSqlTextWithPosition fileName line col (extrStr body))
->                   (functionBody lang)
->                   fileName
->                   (Just (line,col))
->                   (extrStr body)
->                   [bodypos]) of
->                      Left er@(ParseErrorExtra _ _ _) -> Left $ show er
->                      Right body' -> Right (quoteOfString body, body')
-
-sql function is just a list of statements, the last one has the
-trailing semicolon optional
-
->         functionBody Sql = do
->            p <- pos
->            a <- many (try $ sqlStatement True)
->            -- this makes my head hurt, should probably write out
->            -- more longhand
->            SqlFnBody p <$> option a ((\b -> (a++[b])) <$> sqlStatement False)
-
-plpgsql function has an optional declare section, plus the statements
-are enclosed in begin ... end; (semi colon after end is optional(
-
->         functionBody Plpgsql =
->             PlpgsqlFnBody
->             <$> pos
->             <*> option [] declarePart
->             <*> statementPart
->             where
->               statementPart = keyword "begin"
->                     *> many plPgsqlStatement
->                     <* keyword "end" <* optional (symbol ";") <* eof
->               declarePart = keyword "declare"
->                   *> manyTill (try varDef) (lookAhead $ keyword "begin")
-
-params to a function
-
-> param :: ParsecT [Token] ParseState Identity ParamDef
-> param = choice [
->          try (ParamDef <$> pos <*> idString <*> typeName)
->         ,ParamDefTp <$> pos <*> typeName]
-
-variable declarations in a plpgsql function
-
-> varDef :: ParsecT [Token] ParseState Identity VarDef
-> varDef = VarDef
->          <$> pos
->          <*> idString
->          <*> typeName
->          <*> tryOptionMaybe ((symbol ":=" <|> symbol "=")*> expr) <* symbol ";"
-
-
-> createView :: ParsecT [Token] ParseState Identity Statement
-> createView = CreateView
->              <$> pos <* keyword "view"
->              <*> idString
->              <*> (keyword "as" *> selectExpression)
-
-> createDomain :: ParsecT [Token] ParseState Identity Statement
-> createDomain = CreateDomain
->                <$> pos <* keyword "domain"
->                <*> idString
->                <*> (tryOptionMaybe (keyword "as") *> typeName)
->                <*> option "" (keyword "constraint" *> idString)
->                <*> tryOptionMaybe (keyword "check" *> parens expr)
-
-> dropSomething :: ParsecT [Token] ParseState Identity Statement
-> dropSomething = do
->   p <- pos
->   x <- try (choice [
->                  Domain <$ keyword "domain"
->                 ,Type <$ keyword "type"
->                 ,Table <$ keyword "table"
->                 ,View <$ keyword "view"
->             ])
->   (i,e,r) <- parseDrop idString
->   return $ DropSomething p x i e r
-
-> dropFunction :: ParsecT [Token] ParseState Identity Statement
-> dropFunction = do
->                p <- pos
->                keyword "function"
->                (i,e,r) <- parseDrop pFun
->                return $ DropFunction p i e r
->                where
->                  pFun = (,) <$> idString
->                             <*> parens (many typeName)
-
-> parseDrop :: ParsecT [Token] ParseState Identity a
->           -> ParsecT [Token] ParseState Identity (IfExists, [a], Cascade)
-> parseDrop p = (,,)
->               <$> ifExists
->               <*> commaSep1 p
->               <*> cascade
->     where
->       ifExists = option Require
->                  (try $ IfExists <$ (keyword "if"
->                                      *> keyword "exists"))
-
-> createLanguage :: ParsecT [Token] ParseState Identity Statement
-> createLanguage =
->   CreateLanguage <$> pos
->                  <*> (optional (keyword "procedural") *>
->                       keyword "language" *>
->                       idString)
-
-> createTrigger :: ParsecT [Token] ParseState Identity Statement
-> createTrigger =
->   CreateTrigger <$> pos
->                 <*> (keyword "trigger" *> idString)
->                 <*> twhen
->                 <*> tevents
->                 <*> (keyword "on" *> idString)
->                 <*> tfiring
->                 <*> (keyword "execute" *> keyword "procedure"
->                      *> idString)
->                 <*> parens (commaSep expr)
->   where
->     twhen = choice [TriggerBefore <$ keyword "before"
->                    ,TriggerAfter <$ keyword "after"]
->     tevents :: ParsecT [Token] ParseState Identity [TriggerEvent]
->     tevents = sepBy1 (choice [
->                TInsert <$ keyword "insert"
->               ,TUpdate <$ keyword "update"
->               ,TDelete <$ keyword "delete"]) (keyword "or")
->     tfiring = option EachStatement
->                 (keyword "for" *> optional (keyword "each") *>
->                 choice [
->                   EachRow <$ keyword "row"
->                  ,EachStatement <$ keyword "statement"])
-
-[ FOR [ EACH ] { ROW | STATEMENT } ]
-
-    | CreateTrigger ann:Annotation
-                    name:String
-                    wh : TriggerWhen
-                    events: {[TriggerEvent]}
-                    tbl : String
-                    firing : TriggerFire
-                    fnName : String
-                    fnArgs : {[Expression]}
-
-================================================================================
-
-= component parsers for sql statements
-
-> whereClause :: ParsecT [Token] ParseState Identity Expression
-> whereClause = keyword "where" *> expr
-
-selectlist and selectitem: the bit between select and from
-check for into either before the whole list of select columns
-or after the whole list
-
-> selectList :: ParsecT [Token] ParseState Identity SelectList
-> selectList =
->     pos >>= \p ->
->     choice [
->         flip (SelectList p) <$> readInto <*> itemList
->        ,SelectList p  <$> itemList <*> option [] readInto]
->   where
->     readInto = keyword "into" *> commaSep1 idString
->     itemList = commaSep1 selectItem
->     selectItem = pos >>= \p ->
->                  optionalSuffix
->                    (SelExp p) expr
->                    (SelectItem p) () (keyword "as" *> idString)
-
-> returning :: ParsecT [Token] ParseState Identity SelectList
-> returning = keyword "returning" *> selectList
-
-> columnNameList :: ParsecT [Token] ParseState Identity [String]
-> columnNameList = parens $ commaSep1 idString
-
-> typeName :: ParsecT [Token] ParseState Identity TypeName
-> typeName = choice [
->             SetOfTypeName <$> pos <*> (keyword "setof" *> typeName)
->            ,do
->              p <- pos
->              s <- map toLower <$> pTypeNameString
->              choice [
->                PrecTypeName p s <$> parens integer
->               ,ArrayTypeName p (SimpleTypeName p s) <$ symbol "[" <* symbol "]"
->               ,return $ SimpleTypeName p s]]
->            where
->              --todo: add special cases for the other type names with spaces in them
->              pTypeNameString = ("double precision" <$ try (keyword "double"
->                                                            <* keyword "precision"))
->                              <|> idString
-
-> cascade :: ParsecT [Token] ParseState Identity Cascade
-> cascade = option Restrict (choice [
->                             Restrict <$ keyword "restrict"
->                            ,Cascade <$ keyword "cascade"])
-
-================================================================================
-
-= plpgsql statements
-
-> plPgsqlStatement :: ParsecT [Token] ParseState Identity Statement
-> plPgsqlStatement =
->    sqlStatement True
->     <|> (choice [
->           continue
->          ,execute
->          ,caseStatement
->          ,assignment
->          ,ifStatement
->          ,returnSt
->          ,raise
->          ,forStatement
->          ,whileStatement
->          ,perform
->          ,nullStatement]
->          <* symbol ";")
-
-> nullStatement :: ParsecT [Token] ParseState Identity Statement
-> nullStatement = NullStatement <$> (pos <* keyword "null")
-
-> continue :: ParsecT [Token] ParseState Identity Statement
-> continue = ContinueStatement <$> (pos <* keyword "continue")
-
-> perform :: ParsecT [Token] ParseState Identity Statement
-> perform = Perform <$> (pos <* keyword "perform") <*> expr
-
-> execute :: ParsecT [Token] ParseState Identity Statement
-> execute = pos >>= \p -> keyword "execute" >>
->           optionalSuffix
->             (Execute p) expr
->             (ExecuteInto p) () readInto
->     where
->       readInto = keyword "into" *> commaSep1 idString
-
-> assignment :: ParsecT [Token] ParseState Identity Statement
-> assignment = Assignment
->              <$> pos
->              -- put the := in the first try to attempt to get a
->              -- better error if the code looks like malformed
->              -- assignment statement
->              <*> try (idString <* (symbol ":=" <|> symbol "="))
->              <*> expr
-
-> returnSt :: ParsecT [Token] ParseState Identity Statement
-> returnSt = pos >>= \p -> keyword "return" >>
->            choice [
->             ReturnNext p <$> (keyword "next" *> expr)
->            ,ReturnQuery p <$> (keyword "query" *> selectExpression)
->            ,Return p <$> tryOptionMaybe expr]
-
-> raise :: ParsecT [Token] ParseState Identity Statement
-> raise = pos >>= \p -> keyword "raise" >>
->         Raise p
->         <$> raiseType
->         <*> (extrStr <$> stringLit)
->         <*> option [] (symbol "," *> commaSep1 expr)
->         where
->           raiseType = matchAKeyword [("notice", RNotice)
->                                      ,("exception", RException)
->                                      ,("error", RError)]
-
-> forStatement :: ParsecT [Token] ParseState Identity Statement
-> forStatement = do
->                p <- pos
->                keyword "for"
->                start <- idString
->                keyword "in"
->                choice [(ForSelectStatement p start <$> try selectExpression <*> theRest)
->                       ,(ForIntegerStatement p start
->                               <$> expr
->                               <*> (symbol ".." *> expr)
->                               <*> theRest)]
->   where
->     theRest = keyword "loop" *> many plPgsqlStatement
->               <* keyword "end" <* keyword "loop"
-
-> whileStatement :: ParsecT [Token] ParseState Identity Statement
-> whileStatement = WhileStatement
->                  <$> (pos <* keyword "while")
->                  <*> (expr <* keyword "loop")
->                  <*> many plPgsqlStatement <* keyword "end" <* keyword "loop"
-
-> ifStatement :: ParsecT [Token] ParseState Identity Statement
-> ifStatement = If
->               <$> (pos <* keyword "if")
->               <*> (ifPart <:> elseifParts)
->               <*> (elsePart <* endIf)
->   where
->     ifPart = expr <.> (thn *> many plPgsqlStatement)
->     elseifParts = many ((elseif *> expr) <.> (thn *> many plPgsqlStatement))
->     elsePart = option [] (keyword "else" *> many plPgsqlStatement)
->     endIf = keyword "end" <* keyword "if"
->     thn = keyword "then"
->     elseif = keyword "elseif"
->     --might as well throw this in as well after all that
->     -- can't do <,> unfortunately, so use <.> instead
->     (<.>) a b = (,) <$> a <*> b
-
-> caseStatement :: ParsecT [Token] ParseState Identity Statement
-> caseStatement =
->     CaseStatement <$> (pos <* keyword "case")
->                   <*> expr
->                   <*> many whenSt
->                   <*> option [] (keyword "else" *> many plPgsqlStatement)
->                           <* keyword "end" <* keyword "case"
->     where
->       whenSt = keyword "when" >>
->                (,) <$> commaSep1 expr
->                    <*> (keyword "then" *> many plPgsqlStatement)
-
-================================================================================
-
-= expressions
-
-This is the bit that makes it the most obvious that I don't really
-know haskell, parsing theory or parsec ... robbed a parsing example
-from haskell-cafe and mainly just kept changing it until it seemed to
-work
-
-> expr :: ParsecT [Token] ParseState Identity Expression
-> expr = buildExpressionParser table factor
->        <?> "expression"
-
-> factor :: ParsecT [Token] ParseState Identity Expression
-> factor =
-
-First job is to take care of forms which start as a regular
-expression, and then add a suffix on
-
->          threadOptionalSuffixes fct [castSuffix
->                                     ,betweenSuffix
->                                     ,arraySubSuffix]
->          where
->            fct = choice [
-
-order these so the ones which can be valid prefixes of others appear
-further down the list (used to be a lot more important when there
-wasn't a separate lexer), probably want to refactor this to use the
-optionalsuffix parsers to improve speed.
-
-One little speed optimisation, to help with pretty printed code which
-can contain a lot of parens - check for nested ((
-This little addition speeds up ./ParseFile.lhs sqltestfiles/system.sql
-on my system from ~4 minutes to ~4 seconds (most of the 4s is probably
-compilation overhead).
-
->                try (lookAhead (symbol "(" >> symbol "(")) >> parens expr
-
-start with the factors which start with parens - eliminate scalar
-subqueries since they're easy to distinguish from the others then do in
-predicate before row constructor, since an in predicate can start with
-a row constructor looking thing, then finally vanilla parens
-
->               ,scalarSubQuery
->               ,try $ threadOptionalSuffix rowCtor inPredicateSuffix
->               ,parens expr
-
-try a few random things which can't start a different expression
-
->               ,positionalArg
->               ,placeholder
->               ,stringLit
-
->               ,floatLit
->               ,integerLit
-
-put the factors which start with keywords before the ones which start
-with a function, so we don't try an parse a keyword as a function name
-
->               ,caseParse
->               ,exists
->               ,booleanLit
->               ,nullLit
->               ,arrayLit
->               ,castKeyword
->               ,substring
-
-now do identifiers, functions, and window functions (each is a prefix
-to the next one)
-
->               ,threadOptionalSuffixes
->                 identifier
->                 [inPredicateSuffix
->                 ,\l -> threadOptionalSuffix (functionCallSuffix l) windowFnSuffix]]
-
-== operator table
-
-proper hacky, but sort of does the job
-the 'missing' notes refer to pg operators which aren't yet supported,
-or supported in a different way (e.g. cast uses the type name parser
-for one of it's argument, not the expression parser - I don't know if
-there is a better way of doing this but there usually is in parsec)
-
-pg's operator table is on this page:
-http://www.postgresql.org/docs/8.4/interactive/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS
-
-will probably need something more custom to handle full range of sql
-syntactical novelty, in particular the precedence rules mix these
-operators up with irregular syntax operators, you can create new
-operators during parsing, and some operators are prefix/postfix or
-binary depending on the types of their operands (how do you parse
-something like this?)
-
-The full list of operators from a standard template1 database should
-be used here.
-
-> table :: [[Operator [Token] ParseState Identity Expression]]
-> table = [--[binary "::" (BinOpCall Cast) AssocLeft]
->          --missing [] for array element select
->          [prefix "-" "u-"]
->         ,[binary "^" AssocLeft]
->         ,[binary "*" AssocLeft
->          ,idHackBinary "*" AssocLeft
->          ,binary "/" AssocLeft
->          ,binary "%" AssocLeft]
->         ,[binary "+" AssocLeft
->          ,binary "-" AssocLeft]
->          --should be is isnull and notnull
->         ,[postfixks ["is", "not", "null"] "!isnotnull"
->          ,postfixks ["is", "null"] "!isnull"]
->          --other operators all added in this list according to the pg docs:
->         ,[binary "<->" AssocNone
->          ,binary "<=" AssocRight
->          ,binary ">=" AssocRight
->          ,binary "||" AssocLeft
->          ,prefix "@" "@"
->          ]
->          --in should be here, but is treated as a factor instead
->          --between
->          --overlaps
->         ,[binaryk "like" "!like" AssocNone
->          ,binarycust (symbol "!=") "<>" AssocNone]
->          --(also ilike similar)
->         ,[binary "<" AssocNone
->          ,binary ">" AssocNone]
->         ,[binary "=" AssocRight
->          ,binary "<>" AssocNone]
->         ,[notNot
->          ,prefixk "not" "!not"
->          ]
->         ,[binaryk "and" "!and" AssocLeft
->          ,binaryk "or" "!or" AssocLeft]]
->     where
->       binary s = binarycust (symbol s) s
->       -- '*' is lexed as an id token rather than a symbol token, so
->       -- work around here
->       idHackBinary s = binarycust (keyword s) s
->       binaryk = binarycust . keyword
->       prefix = unaryCust Prefix . symbol
->       prefixk = unaryCust Prefix . keyword
->       postfixks = unaryCust Postfix . mapM_ keyword
->       binarycust opParse t =
->         Infix $ try $ do
->              f <- FunCall <$> pos <*> (t <$ opParse)
->              return (\l -> \m -> f [l,m])
->       unaryCust ctor opParse t =
->         ctor $ try $ do
->           f <- FunCall <$> pos <*> (t <$ opParse)
->           return (\l -> f [l])
->       --hack - haven't worked out why parsec buildexpression parser won't parse
->       -- something like "not not EXPR" without parens so hack here
->       notNot = Prefix (try $ do
->                          p1 <- pos
->                          keyword "not"
->                          p2 <- pos
->                          keyword "not"
->                          return (\l -> FunCall p1 "!not" [FunCall p2 "!not" [l]]))
-
-== factor parsers
-
-I think the lookahead is used in an attempt to help the error messages.
-
-> scalarSubQuery :: ParsecT [Token] ParseState Identity Expression
-> scalarSubQuery = try (symbol "(" *> lookAhead (keyword "select")) >>
->                  ScalarSubQuery
->                  <$> pos
->                  <*> selectExpression <* symbol ")"
-
-in predicate - an identifier or row constructor followed by 'in'
-then a list of expressions or a subselect
-
-> inPredicateSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> inPredicateSuffix e =
->   InPredicate
->   <$> pos
->   <*> return e
->   <*> option True (False <$ keyword "not")
->   <*> (keyword "in" *> parens ((InSelect <$> pos <*> selectExpression)
->                                <|>
->                                (InList <$> pos <*> commaSep1 expr)))
-
-row ctor: one of
-row ()
-row (expr)
-row (expr, expr1, ...)
-(expr, expr2,...) [implicit (no row keyword) version, at least two elements
-                   must be present]
-
-(expr) parses to just expr rather than row(expr)
-and () is a syntax error.
-
-> rowCtor :: ParsecT [Token] ParseState Identity Expression
-> rowCtor = FunCall
->           <$> pos
->           <*> return "!rowctor"
->           <*> choice [
->            keyword "row" *> parens (commaSep expr)
->           ,parens $ commaSep2 expr]
-
-> floatLit :: ParsecT [Token] ParseState Identity Expression
-> floatLit = FloatLit <$> pos <*> float
-
-> integerLit :: ParsecT [Token] ParseState Identity Expression
-> integerLit = IntegerLit <$> pos <*> integer
-
-case - only supports 'case when condition' flavour and not 'case
-expression when value' currently
-
-> caseParse :: ParsecT [Token] ParseState Identity Expression
-> caseParse = do
->   p <- pos
->   keyword "case"
->   choice [
->              try $ CaseSimple p <$> expr
->                                 <*> many whenParse
->                                 <*> tryOptionMaybe (keyword "else" *> expr)
->                                         <* keyword "end"
->             ,Case p <$> many whenParse
->                     <*> tryOptionMaybe (keyword "else" *> expr)
->                             <* keyword "end"]
->   where
->     whenParse = (,) <$> (keyword "when" *> commaSep1 expr)
->                     <*> (keyword "then" *> expr)
-
-> exists :: ParsecT [Token] ParseState Identity Expression
-> exists = Exists <$> pos <* keyword "exists" <*> parens selectExpression
-
-> booleanLit :: ParsecT [Token] ParseState Identity Expression
-> booleanLit = BooleanLit <$> pos <*> (True <$ keyword "true"
->                                      <|> False <$ keyword "false")
-
-> nullLit :: ParsecT [Token] ParseState Identity Expression
-> nullLit = NullLit <$> pos <* keyword "null"
-
-> arrayLit :: ParsecT [Token] ParseState Identity Expression
-> arrayLit = FunCall <$> pos <* keyword "array"
->                    <*> return "!arrayctor"
->                    <*> squares (commaSep expr)
-
-> arraySubSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> arraySubSuffix e = case e of
->                      Identifier _ "array" -> fail "can't use array as identifier name"
->                      _ -> FunCall <$> pos
->                                   <*> return "!arraysub"
->                                   <*> ((e:) <$> squares (commaSep1 expr))
-
-supports basic window functions of the form
-fn() over ([partition bit]? [order bit]?)
-
-frame clauses todo:
-range unbounded preceding
-range between unbounded preceding and current row
-range between unbounded preceding and unbounded following
-rows unbounded preceding
-rows between unbounded preceding and current row
-rows between unbounded preceding and unbounded following
-
-> windowFnSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> windowFnSuffix e = WindowFn <$> pos <*> return e
->                    <*> (keyword "over" *> (symbol "(" *> option [] partitionBy))
->                    <*> option [] orderBy1
->                    <*> option Asc (try $ choice [
->                                             Asc <$ keyword "asc"
->                                            ,Desc <$ keyword "desc"])
->                    <*> frm
->                    <* symbol ")"
->   where
->     orderBy1 = keyword "order" *> keyword "by" *> commaSep1 expr
->     partitionBy = keyword "partition" *> keyword "by" *> commaSep1 expr
->     frm = option FrameUnboundedPreceding $ choice $ map (\(a,b) -> a <$ try (ks b)) [
->            (FrameUnboundedPreceding, ["range","unbounded","preceding"])
->           ,(FrameUnboundedPreceding, ["range","between","unbounded","preceding","and","current","row"])
->           ,(FrameUnboundedFull, ["range","between","unbounded","preceding","and","unbounded","following"])
->           ,(FrameUnboundedFull, ["rows","between","unbounded","preceding","and","unbounded","following"])
->           ,(FrameRowsUnboundedPreceding, ["rows","unbounded","preceding"])
->           ,(FrameRowsUnboundedPreceding, ["rows","between","unbounded","preceding","and","current","row"])]
->     ks = mapM keyword
-
-> betweenSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> betweenSuffix a = do
->   p <- pos
->   keyword "between"
->   b <- dodgyParseElement
->   keyword "and"
->   c <- dodgyParseElement
->   return $ FunCall p "!between" [a,b,c]
->              --can't use the full expression parser at this time
->              --because of a conflict between the operator 'and' and
->              --the 'and' part of a between
-
-From postgresql src/backend/parser/gram.y
-
- * We have two expression types: a_expr is the unrestricted kind, and
- * b_expr is a subset that must be used in some places to avoid shift/reduce
- * conflicts.  For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr"
- * because that use of AND conflicts with AND as a boolean operator.  So,
- * b_expr is used in BETWEEN and we remove boolean keywords from b_expr.
- *
- * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can
- * always be used by surrounding it with parens.
-
-TODO: copy this approach here.
-
->              where
->                dodgyParseElement = factor
-
-> functionCallSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> functionCallSuffix (Identifier _ fnName) =
->   pos >>= \p -> FunCall p fnName
->                 <$> parens (optional (keyword "all" <|> keyword "distinct") *> commaSep expr)
-> functionCallSuffix s = error $ "internal error: cannot make functioncall from " ++ show s
-
-> castKeyword :: ParsecT [Token] ParseState Identity Expression
-> castKeyword = Cast
->               <$> pos <* keyword "cast" <* symbol "("
->               <*> expr
->               <*> (keyword "as" *> typeName <* symbol ")")
-
-> castSuffix :: Expression -> ParsecT [Token] ParseState Identity Expression
-> castSuffix ex = pos >>= \p -> Cast p ex <$> (symbol "::" *> typeName)
-
-> substring :: ParsecT [Token] ParseState Identity Expression
-> substring = do
->             p <- pos
->             keyword "substring"
->             symbol "("
->             a <- expr
->             keyword "from"
->             b <- expr
->             keyword "for"
->             c <- expr
->             symbol ")"
->             return $ FunCall p "!substring" [a,b,c]
-
-> identifier :: ParsecT [Token] ParseState Identity Expression
-> identifier = Identifier <$> pos <*> idString
-
-try $ do
- >   p <- pos
- >   i <- idString
- >   if i `elem` ["not"]
- >     then fail "can't use keyword"
- >     else return $ Identifier p i
-
-================================================================================
-
-= Utility parsers
-
-== tokeny things
-
-keyword has to not be immediately followed by letters or numbers
-(symbols and whitespace are ok) so we know that we aren't reading an
-identifier which happens to start with a complete keyword
-
-> keyword :: String -> ParsecT [Token] ParseState Identity ()
-> keyword k = mytoken (\tok ->
->                                case tok of
->                                IdStringTok i | lcase k == lcase i -> Just ()
->                                _ -> Nothing)
->                       where
->                         lcase = map toLower
-
-> idString :: MyParser String
-> idString = mytoken (\tok -> case tok of
->                                      IdStringTok "not" -> Nothing
->                                      IdStringTok i -> Just i
->                                      _ -> Nothing)
-
-> symbol :: String -> ParsecT [Token] ParseState Identity ()
-> symbol c = mytoken (\tok -> case tok of
->                                    SymbolTok s | c==s -> Just ()
->                                    _           -> Nothing)
-
-> integer :: MyParser Integer
-> integer = mytoken (\tok -> case tok of
->                                     IntegerTok n -> Just n
->                                     _ -> Nothing)
-
-> positionalArg :: ParsecT [Token] ParseState Identity Expression
-> positionalArg = PositionalArg [] <$> mytoken (\tok -> case tok of
->                                     PositionalArgTok n -> Just n
->                                     _ -> Nothing)
-
-> placeholder :: ParsecT [Token] ParseState Identity Expression
-> placeholder = Placeholder [] <$ symbol "?"
-
-
-> float :: MyParser Double
-> float = mytoken (\tok -> case tok of
->                                     FloatTok n -> Just n
->                                     _ -> Nothing)
-
-> stringLit :: MyParser Expression
-> stringLit = mytoken (\tok ->
->                   case tok of
->                            StringTok d s -> Just $ StringLit [] d s
->                            _ -> Nothing)
-
-> stringN :: MyParser String
-> stringN = mytoken (\tok ->
->                   case tok of
->                            StringTok _ s -> Just s
->                            _ -> Nothing)
-
-
-couple of helper functions which extract the actual string
-from a StringLD or StringL, and the delimiters which were used
-(either ' or a dollar tag)
-
-> extrStr :: Expression -> String
-> extrStr (StringLit _ _ s) = s
-> extrStr x = error $ "internal error: extrStr not supported for this type " ++ show x
-
-> quoteOfString :: Expression -> String
-> quoteOfString (StringLit _ tag _) = tag
-> quoteOfString x = error $ "internal error: quoteType not supported for this type " ++ show x
-
-== combinatory things
-
-> parens :: ParsecT [Token] ParseState Identity a
->        -> ParsecT [Token] ParseState Identity a
-> parens = between (symbol "(") (symbol ")")
-
-> squares :: ParsecT [Token] ParseState Identity a
->        -> ParsecT [Token] ParseState Identity a
-> squares = between (symbol "[") (symbol "]")
-
-> tryOptionMaybe :: (Stream s m t) =>
->              ParsecT s u m a -> ParsecT s u m (Maybe a)
-> tryOptionMaybe p = try (optionMaybe p) <|> return Nothing
-
-> commaSep2 :: ParsecT [Token] ParseState Identity a
->           -> ParsecT [Token] ParseState Identity [a]
-> commaSep2 p = sepBy2 p (symbol ",")
-
-> sepBy2 :: (Stream s m t) =>
->           ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m [a]
-> sepBy2 p sep = (p <* sep) <:> sepBy1 p sep
-
-> commaSep :: ParsecT [Token] ParseState Identity a
->          -> ParsecT [Token] ParseState Identity [a]
-> commaSep p = sepBy p (symbol ",")
-
-> commaSep1 :: ParsecT [Token] ParseState Identity a
->           -> ParsecT [Token] ParseState Identity [a]
-> commaSep1 p = sepBy1 p (symbol ",")
-
-pass a list of pairs of strings and values
-try each pair k,v in turn,
-if keyword k matches then return v
-doesn't really add a lot of value
-
-> matchAKeyword :: [(String, a)] -> ParsecT [Token] ParseState Identity a
-> matchAKeyword [] = fail "no matches"
-> matchAKeyword ((k,v):kvs) = v <$ keyword k <|> matchAKeyword kvs
-
-parseOptionalSuffix
-
-parse the start of something -> parseResultA,
-then parse an optional suffix -> parseResultB
-if this second parser succeeds, return fn2 parseResultA parseResultB
-else return fn1 parseResultA
-
-e.g.
-parsing an identifier in a select list can be
-fieldName
-or
-fieldName as alias
-so we can pass
-* IdentifierCtor
-* identifier (returns aval)
-* AliasedIdentifierCtor
-* () - looks like a place holder, probably a crap idea
-* parser for (as b) (returns bval)
-as the args, which I like to ident like:
-parseOptionalSuffix
-  IdentifierCtor identifierParser
-  AliasedIdentifierCtor () asAliasParser
-and we get either
-* IdentifierCtor identifierValue
-or
-* AliasedIdentifierCtor identifierValue aliasValue
-as the result depending on whether the asAliasParser
-succeeds or not.
-
-probably this concept already exists under a better name in parsing
-theory
-
-> optionalSuffix :: (Stream s m t2) =>
->                   (t1 -> b)
->                -> ParsecT s u m t1
->                -> (t1 -> a -> b)
->                -> ()
->                -> ParsecT s u m a
->                -> ParsecT s u m b
-> optionalSuffix c1 p1 c2 _ p2 = do
->   x <- p1
->   option (c1 x) (c2 x <$> try p2)
-
-threadOptionalSuffix
-
-parse the start of something -> parseResultA,
-then parse an optional suffix, passing parseResultA
-  to this parser -> parseResultB
-return parseResultB is it succeeds, else return parseResultA
-
-sort of like a suffix operator parser where the suffixisable part
-is parsed, then if the suffix is there it wraps the suffixisable
-part in an enclosing tree node.
-
-parser1 -> tree1
-(parser2 tree1) -> maybe tree2
-tree2 isnothing ? tree1 : tree2
-
-> threadOptionalSuffix :: ParsecT [tok] st Identity a
->                      -> (a -> GenParser tok st a)
->                      -> ParsecT [tok] st Identity a
-> threadOptionalSuffix p1 p2 = do
->   x <- p1
->   option x (try $ p2 x)
-
-I'm pretty sure this is some standard monad operation but I don't know
-what. It's a bit like the maybe monad but when you get nothing it
-returns the previous result instead of nothing
-- if you take the parsing specific stuff out you get:
-
-p1 :: (Monad m) =>
-      m b -> (b -> m (Maybe b)) -> m b
-p1 = do
-   x <- p1
-   y <- p2 x
-   case y of
-     Nothing -> return x
-     Just z -> return z
-=====
-
-like thread optional suffix, but we pass a list of suffixes in, not
-much of a shorthand
-
-> threadOptionalSuffixes :: ParsecT [tok] st Identity a
->                        -> [a -> GenParser tok st a]
->                        -> ParsecT [tok] st Identity a
-> threadOptionalSuffixes p1 p2s = do
->   x <- p1
->   option x (try $ choice (map (\l -> l x) p2s))
-
-couldn't work how to to perms so just did this hack instead
-e.g.
-a1,a2,b1,b2,a2,b3,b4 parses to ([a1,a2,a3],[b1,b2,b3,b4])
-
-> multiPerm :: (Stream s m t) =>
->                ParsecT s u m a1
->             -> ParsecT s u m a
->             -> ParsecT s u m sep
->             -> ParsecT s u m ([a1], [a])
-
-> multiPerm p1 p2 sep = do
->   (r1, r2) <- unzip <$> sepBy1 parseAorB sep
->   return (catMaybes r1, catMaybes r2)
->   where
->     parseAorB = choice [
->                   (\x -> (Just x,Nothing)) <$> p1
->                  ,(\y -> (Nothing, Just y)) <$> p2]
-
-== position stuff
-
-getAdjustedPosition is used to modify the positions within a function
-body, to absolute positions within the file being parsed.
-
-> getAdjustedPosition :: ParsecT [Token] ParseState Identity MySourcePos
-> getAdjustedPosition = do
->   p <- toMySp <$> getPosition
->   s <- getState
->   case s of
->     [] -> return p
->     x:_ -> return $ adjustPosition x p
-
-> adjustPosition :: MySourcePos -> MySourcePos -> MySourcePos
-> adjustPosition (fn,pl,_) (_,l,c) = (fn,pl+l-1,c)
-
-> pos :: ParsecT [Token] ParseState Identity Annotation
-> pos = do
->   p <- toSp <$> getPosition
->   s <- getState
->   case s of
->     [] -> return [p]
->     x:_ -> return [adjustPos x p]
->   where
->     toSp sp = A.SourcePos (sourceName sp) (sourceLine sp) (sourceColumn sp)
->     adjustPos (fn,pl,_) (A.SourcePos _ l c) = A.SourcePos fn (pl+l-1) c
->     adjustPos _ x = error $ "internal error - tried to adjust as sourcepos: " ++ show x
-
-== lexer stuff
-
-> type MyParser = GenParser Token ParseState
-
-> mytoken :: (Tok -> Maybe a) -> MyParser a
-> mytoken test
->   = token showToken posToken testToken
->   where
->   showToken (_,tok)   = show tok
->   posToken  (posi,_)  = posi
->   testToken (_,tok)   = test tok
-
-================================================================================
-
-= fixup tree
-
-this is where some generics code is used to transform the parse trees
-to alter the nodes used where it's too difficult to do whilst
-parsing. The only item at the moment that needs this treatment is te
-any/some/all construct which looks like this:
-expr operator [any|some|all] (expr)
-
-This gets parsed as
-funcall operator [expr1,funcall [any|some|all] [expr2,...]]
-and we want to transform it to
-liftoperator operator any|some|all [expr1, expr2,...]
-not doing anything if the funcall name isn't any,some,all
-any other checks are left to the type checking stage
-(e.g. there can only be one expression in the expr2 part, and it must
-be an array or subselect, etc)
-
-> fixupTree :: Data a => a -> a
-> fixupTree =
->     transformBi $ \x ->
->       case x of
->              FunCall an op (expr1:FunCall _ nm expr2s:expr3s)
->                | isOperatorName op && map toLower nm `elem` ["any", "some", "all"]
->                -> LiftOperator an op flav (expr1:expr2s ++ expr3s)
->                   where flav = case (map toLower nm) of
->                                  "any" -> LiftAny
->                                  "some" -> LiftAny
->                                  "all" -> LiftAll
->                                  z -> error $ "internal error in parsing lift transform: " ++ z
->              x1 -> x1
diff --git a/Database/HsSqlPpp/PrettyPrinter/AnnotateSource.lhs b/Database/HsSqlPpp/PrettyPrinter/AnnotateSource.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/PrettyPrinter/AnnotateSource.lhs
+++ /dev/null
@@ -1,125 +0,0 @@
-Copyright 2009 Jake Wheat
-
-The purpose of this module is to add annotations in comments to the
-original source code, so that we can preserve the original formatting
-and comments.
-
-A second goal will be to update these comments if they are already
-present, so we can run this process repeatedly on a file and not fill
-it with junk, or can e.g. make a few changes to the sql, run this
-process, then use source control diff to view how the types, etc. have
-changed.
-
-
-Algorithm design
-
-Get all the annotations ordered by source position. Split the original
-text on these points, then zip it and output it.
-
-
-> {- | Function to pretty print annotation information interspersed
->      with original source file, so e.g. you can view types,
->      etc. inline in the source whilst preserving the original
->      formatting and comments.  -}
-> module Database.HsSqlPpp.PrettyPrinter.AnnotateSource
->     (annotateSource) where
-
-> import Data.List
-> import Data.Maybe
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Ast.TypeChecker
-
-> annotateSource :: Bool -> String -> StatementList -> String
-> annotateSource doErrs src aast =
-
-Details:
-
-First need better syb so we can get two separate lists of annotations,
-one for statements and one for non-statements. This will allow us to
-output full information for each statement, but output reduced
-information for other nodes - just want to output type error
-annotations for now. (This could be made more general by allowing a
-different kind of annotation pretty printer depending on the node
-type, value or context?)
-
-filter these two lists, mainly to strip all the annotations from the
-non-statement annotation list except the source positions and the type
-errors.
-
-merge these two lists and sort by source position, then map to get
-[(sourceposition, annotation without sourceposition)]
-
-Now we have a list of sourcepositions that we can split the original source with:
-0->firstsp, firstsp->secondsp, ... second last sp-> last sp, last sp -> eof
--> this produces a [string] from the original source
-use a zip:
-zip splitSource $ ([]:map snd mungedAnnotationlist)
-to get [(string,annotation)]
-then do map second prettyPrint over this
-to gives us a [(string,string)] which we can concatenate to produce
-the output text.
-
-To replace existing comments rather than repeatedly add them:
-1) make sure the pretty printed comments have some marker
-
-2) strip all the comments with this marker out after splitting the
-   string on the annotation source positions, i.e. when we get to
-   [(string,annotation)] or [(string,string)] stage.
-
-
->    let allAnn = sortBy ordSps $ getStatementPosStringPairs ++ getTypeErrorPosPairs
->        splitPoints = map ((\(SourcePos _ l _) -> l - 1) . fst) allAnn
->        splitsSrc = splitAts src splitPoints
->        anSrcPairs = zip splitsSrc $ map snd allAnn
->    in concatMap (uncurry (++)) anSrcPairs
->           -- make sure we get the last bit of the source code
->           ++ last splitsSrc
->    where
->      ordSps :: (AnnotationElement,String) -> (AnnotationElement,String) -> Ordering
->      ordSps a b = case (a,b) of
->                     ((SourcePos _ l c, _),(SourcePos _ l1 c1, _)) -> compare (l,c) (l1,c1)
->                     _ -> EQ
->      getTypeErrorPosPairs :: [(AnnotationElement, String)]
->      getTypeErrorPosPairs =
->          if doErrs
->            then map (\(a,b) -> (a,"\n/*ERROR:" ++ show b ++ "*/\n")) typeErrorsWithPositions
->            else []
->          where
->            typeErrorsWithPositions = mapMaybe (\(a,b) -> case a of
->                                                                 Nothing -> Nothing
->                                                                 Just a1 -> Just (a1,b)) typeErrors
->            typeErrors = getTypeErrors aast
->      getStatementPosStringPairs :: [(AnnotationElement, String)]
->      getStatementPosStringPairs =
->          let statementAnnotations = map interestingAnn $ getStatementAnnotations aast
->              split = mapMaybe (\l -> let notSp = filter (not.isSp) l
->                                      in if notSp == []
->                                           then Nothing
->                                           else Just (find isSp l, notSp)) statementAnnotations
->              splitsWithSps = mapMaybe (\(a,b) -> case a of
->                                                         Nothing -> Nothing
->                                                         Just a1 -> Just (a1,b)) split
->          in map (\(a,b) -> (a, "\n/*" ++ show b ++ "*/\n")) splitsWithSps
->          where
->            interestingAnn anns =
->              flip filter anns (\a ->
->                                case a of
->                                       TypeAnnotation _ -> False
->                                       CatUpdates [] -> False
->                                       _ -> True)
-
->      isSp t = case t of
->                      SourcePos _ _ _ -> True
->                      _ -> False
->      splitAts :: String -> [Int] -> [String]
->      splitAts s splits =
->          let slines = lines s
->              --make sure we get from the last split to the end of the file
->              splits1 = splits ++ [length slines]
->              pairs :: [(Int,Int)]
->              pairs = zip (0:splits) splits1
->          in map (\(st,en) -> unlines $ take (en - st) $ drop st slines) pairs
-
diff --git a/Database/HsSqlPpp/PrettyPrinter/PrettyPrinter.lhs b/Database/HsSqlPpp/PrettyPrinter/PrettyPrinter.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/PrettyPrinter/PrettyPrinter.lhs
+++ /dev/null
@@ -1,683 +0,0 @@
-Copyright 2009 Jake Wheat
-
-The pretty printer which prints ast nodes from Ast.hs
-It uses the hughes pj pretty printer
-
-Produces sort of readable code, but mainly just written to produce
-reparsable text. Could do with some work to make the outputted text
-layout better.
-
-Not much other comments, since it all should be pretty self evident.
-
-> {- | Functions to convert sql asts to valid SQL source code. Includes
->    a function - 'printSqlAnn' - to output the annotations from a tree
->    in comments in the outputted SQL source.
-> -}
-> module Database.HsSqlPpp.PrettyPrinter.PrettyPrinter (
->                       --convert a sql ast to text
->                       printSql
->                      ,printSqlAnn
->                       --convert a single expression parse node to text
->                      ,printExpression
->                      )
->     where
-
-> import Text.PrettyPrint
-> import Data.Char
-> import Data.List
-
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Utils
-
-================================================================================
-
-Public functions
-
-> -- | convert an ast back to valid SQL source, it's also almost human readable.
-> printSql :: StatementList -> String
-> printSql = printSqlAnn (const "")
-
-> -- | convert the ast back to valid source, and convert any annotations to
-> -- text using the function provided and interpolate the output of this function
-> -- (inside comments) with the SQL source.
-> printSqlAnn :: (Annotation -> String) -> StatementList -> String
-> printSqlAnn f ast = render $ vcat (map (convStatement f) ast) <> text "\n"
-
-> -- | Testing function, pretty print an expression
-> printExpression :: Expression -> String
-> printExpression = render . convExp
-
-================================================================================
-
-Conversion routines - convert Sql asts into Docs
-= Statements
-
-> convStatement :: (Annotation -> String) -> Statement -> Doc
-
-== selects
-
-> convStatement ca (SelectStatement ann s) =
->   convPa ca ann <+>
->   convSelectExpression True True s <> statementEnd
-
-== dml
-
-> convStatement pa (Insert ann tb atts idata rt) =
->   convPa pa ann <+>
->   text "insert into" <+> text tb
->   <+> ifNotEmpty (parens . hcatCsvMap text) atts
->   $+$ convSelectExpression True True idata
->   $+$ convReturning rt
->   <> statementEnd
-
-> convStatement ca (Update ann tb scs wh rt) =
->    convPa ca ann <+>
->    text "update" <+> text tb <+> text "set"
->    <+> hcatCsvMap convSetClause scs
->    <+> convWhere wh
->    $+$ convReturning rt <> statementEnd
->    where
->      convSetClause (SetClause _ att ex) = text att <+> text "=" <+> convExp ex
->      convSetClause (RowSetClause _ atts exs) =
->        parens (hcatCsvMap text atts)
->        <+> text "="
->        <+> parens (hcatCsvMap convExp exs)
-
-> convStatement ca (Delete ann tbl wh rt) =
->    convPa ca ann <+>
->    text "delete from" <+> text tbl
->    <+> convWhere wh
->    $+$ convReturning rt
->    <> statementEnd
-
-> convStatement ca (Truncate ann names ri casc) =
->     convPa ca ann <+>
->     text "truncate"
->     <+> hcatCsvMap text names
->     <+> text (case ri of
->                       RestartIdentity -> "restart identity"
->                       ContinueIdentity -> "continue identity")
->     <+> convCasc casc
->     <> statementEnd
-
-== ddl
-
-> convStatement ca (CreateTable ann tbl atts cns) =
->     convPa ca ann <+>
->     text "create table"
->     <+> text tbl <+> lparen
-
->     $+$ nest 2 (vcat (csv (map convAttDef atts ++ map convCon cns)))
->     $+$ rparen <> statementEnd
->     where
->       convAttDef (AttributeDef _ n t def cons) =
->         text n <+> convTypeName t
->         <+> maybeConv (\e -> text "default" <+> convExp e) def
->         <+> hsep (map (\e -> (case e of
->                                 NullConstraint _ cn -> mname cn <+> text "null"
->                                 NotNullConstraint _ cn -> mname cn <+> text "not null"
->                                 RowCheckConstraint _ cn ew ->
->                                     mname cn <+> text "check" <+> parens (convExp ew)
->                                 RowUniqueConstraint _ cn -> mname cn <+> text "unique"
->                                 RowPrimaryKeyConstraint _ cn -> mname cn <+> text "primary key"
->                                 RowReferenceConstraint _ cn tb att ondel onupd ->
->                                     mname cn <+>
->                                     text "references" <+> text tb
->                                     <+> maybeConv (parens . text) att
->                                     <+> text "on delete" <+> convCasc ondel
->                                     <+> text "on update" <+> convCasc onupd
->                         )) cons)
-
-> convStatement ca (AlterTable ann name act) =
->     convPa ca ann <+>
->     text "alter table" <+> text name
->     <+> hcatCsvMap convAct act <> statementEnd
->     where
->       convAct (AlterColumnDefault _ nm def) =
->           text "alter column" <+> text nm <+> text "set default" <+> convExp def
->       convAct (AddConstraint _ con) =
->           text "add constraint" <+> convCon con
-
-> convStatement ca (CreateSequence ann nm incr _ _ start cache) =
->     convPa ca ann <+>
->     text "create sequence" <+> text nm <+>
->     text "increment" <+> text (show incr) <+>
->     text "no minvalue" <+>
->     text "no maxvalue" <+>
->     text "start" <+> text (show start) <+>
->     text "cache" <+> text (show cache) <> statementEnd
-
-> convStatement ca (AlterSequence ann nm o) =
->     convPa ca ann <+>
->     text "alter sequence" <+> text nm
->     <+> text "owned by" <+> text o <> statementEnd
-
-
-> convStatement ca (CreateTableAs ann t sel) =
->     convPa ca ann <+>
->     text "create table"
->     <+> text t <+> text "as"
->     $+$ convSelectExpression True True sel
->     <> statementEnd
-
-> convStatement ca (CreateFunction ann name args retType lang qt body vol) =
->     convPa ca ann <+>
->     text "create function" <+> text name
->     <+> parens (hcatCsvMap convParamDef args)
->     <+> text "returns" <+> convTypeName retType <+> text "as" <+> text qt
->     $+$ convFnBody body
->     $+$ text qt <+> text "language"
->     <+> text (case lang of
->                         Sql -> "sql"
->                         Plpgsql -> "plpgsql")
->     <+> text (case vol of
->                        Volatile -> "volatile"
->                        Stable -> "stable"
->                        Immutable -> "immutable")
->     <> statementEnd
->     where
->       convFnBody (SqlFnBody ann1 sts) =
->         convPa ca ann1 <+>
->         convNestedStatements ca sts
->       convFnBody (PlpgsqlFnBody ann1 decls sts) =
->           convPa ca ann1 <+>
->           ifNotEmpty (\l -> text "declare"
->                   $+$ nest 2 (vcat $ map convVarDef l)) decls
->           $+$ text "begin"
->           $+$ convNestedStatements ca sts
->           $+$ text "end;"
->       convParamDef (ParamDef _ n t) = text n <+> convTypeName t
->       convParamDef  (ParamDefTp _ t) = convTypeName t
->       convVarDef (VarDef _ n t v) =
->         text n <+> convTypeName t
->         <+> maybeConv (\x -> text ":=" <+> convExp x) v <> semi
-
-
-
-> convStatement ca (CreateView ann name sel) =
->     convPa ca ann <+>
->     text "create view" <+> text name <+> text "as"
->     $+$ nest 2 (convSelectExpression True True sel) <> statementEnd
-
-> convStatement ca (CreateDomain ann name tp n ex) =
->     convPa ca ann <+>
->     text "create domain" <+> text name <+> text "as"
->     <+> convTypeName tp <+> cname <+> checkExp ex <> statementEnd
->     where
->       checkExp = maybeConv (\e -> text "check" <+> parens (convExp e))
->       cname = if n == ""
->                then empty
->                else text "constraint" <+> text n
-
-> convStatement ca (DropFunction ann ifExists fns casc) =
->   convPa ca ann <+>
->   text "drop function"
->   <+> convIfExists ifExists
->   <+> hcatCsvMap doFunction fns
->   <+> convCasc casc
->   <> statementEnd
->   where
->     doFunction (name,types) = text name <> parens (hcatCsvMap convTypeName types)
-
-> convStatement ca (DropSomething ann dropType ifExists names casc) =
->     convPa ca ann <+>
->     text "drop"
->     <+> text (case dropType of
->                 Table -> "table"
->                 View -> "view"
->                 Domain -> "domain"
->                 Type -> "type")
->     <+> convIfExists ifExists
->     <+> hcatCsvMap text names
->     <+> convCasc casc
->     <> statementEnd
-
-> convStatement ca (CreateType ann name atts) =
->     convPa ca ann <+>
->     text "create type" <+> text name <+> text "as" <+> lparen
->     $+$ nest 2 (vcat (csv
->           (map (\(TypeAttDef _ n t) -> text n <+> convTypeName t)  atts)))
->     $+$ rparen <> statementEnd
-
-> convStatement ca (CreateLanguage ann name) =
->     convPa ca ann <+>
->     text "create language" <+> text name <> statementEnd
-
-> convStatement ca (CreateTrigger ann name wh events tbl firing fnName fnArgs) =
->     convPa ca ann <+>
->     text "create trigger" <+> text name
->     <+> text (case wh of
->                       TriggerBefore -> "before"
->                       TriggerAfter -> "after")
->     <+> hcat (map text $ intersperse " or " $ map (\e -> case e of
->                                                    TInsert -> "insert"
->                                                    TUpdate -> "update"
->                                                    TDelete -> "delete") events)
->     <+> text "on" <+> text tbl
->     <+> text "for" <+> text (case firing of
->                                         EachRow -> "row"
->                                         EachStatement -> "statement")
->     <+> text "execute procedure" <+> text fnName
->     <> parens (hcatCsvMap convExp fnArgs) <> statementEnd
-
-== plpgsql
-
-> convStatement ca (NullStatement ann) = convPa ca ann <+> text "null" <> statementEnd
-
-> convStatement ca (Assignment ann name val) =
->     convPa ca ann <+>
->     text name <+> text ":=" <+> convExp val <> statementEnd
-
-> convStatement ca (Return ann ex) =
->     convPa ca ann <+>
->     text "return" <+> maybeConv convExp ex <> statementEnd
-
-> convStatement ca (ReturnNext ann ex) =
->     convPa ca ann <+>
->     text "return" <+> text "next" <+> convExp ex <> statementEnd
-
-> convStatement ca (ReturnQuery ann sel) =
->     convPa ca ann <+>
->     text "return" <+> text "query"
->     <+> convSelectExpression True True sel <> statementEnd
-
-> convStatement ca (Raise ann rt st exps) =
->     convPa ca ann <+>
->     text "raise"
->     <+> case rt of
->                 RNotice -> text "notice"
->                 RException -> text "exception"
->                 RError -> text "error"
->     <+> convExp (StringLit [] "'" st)
->     <> ifNotEmpty (\e -> comma <+> csvExp e) exps
->     <> statementEnd
-
-> convStatement ca (ForSelectStatement ann i sel stmts) =
->     convPa ca ann <+>
->     text "for" <+> text i <+> text "in"
->     <+> convSelectExpression True True sel <+> text "loop"
->     $+$ convNestedStatements ca stmts
->     $+$ text "end loop" <> statementEnd
-
-> convStatement ca (ForIntegerStatement ann var st en stmts) =
->     convPa ca ann <+>
->     text "for" <+> text var <+> text "in"
->     <+> convExp st <+> text ".." <+> convExp en <+> text "loop"
->     $+$ convNestedStatements ca stmts
->     $+$ text "end loop" <> statementEnd
-
-> convStatement ca (WhileStatement ann ex stmts) =
->     convPa ca ann <+>
->     text "while" <+> convExp ex <+> text "loop"
->     $+$ convNestedStatements ca stmts
->     $+$ text "end loop" <> statementEnd
-
-> convStatement ca (ContinueStatement ann) =
->     convPa ca ann <+> text "continue" <> statementEnd
-
-> convStatement ca (Perform ann f@(FunCall _ _ _)) =
->     convPa ca ann <+>
->     text "perform" <+> convExp f <> statementEnd
-> convStatement _ (Perform _ x) =
->    error $ "internal error: convStatement not supported for " ++ show x
-
-> convStatement ca (Copy ann tb cols src) =
->     convPa ca ann <+>
->     text "copy" <+> text tb
->     <+> ifNotEmpty (parens . hcatCsvMap text) cols
->     <+> text "from" <+> case src of
->                                  CopyFilename s -> quotes $ text s
->                                  Stdin -> text "stdin"
->     <> statementEnd
-
-> convStatement ca (CopyData ann s) =
->     convPa ca ann <+>
->     text s <> text "\\." <> newline
-
-> convStatement ca (If ann conds els) =
->    convPa ca ann <+>
->    text "if" <+> convCond (head conds)
->    $+$ vcat (map (\c -> text "elseif" <+> convCond c) $ tail conds)
->    $+$ ifNotEmpty (\e -> text "else" $+$ convNestedStatements ca e) els
->    $+$ text "end if" <> statementEnd
->     where
->       convCond (ex, sts) = convExp ex <+> text "then"
->                            $+$ convNestedStatements ca sts
-> convStatement ca (Execute ann s) =
->     convPa ca ann <+>
->     text "execute" <+> convExp s <> statementEnd
-
-> convStatement ca (ExecuteInto ann s is) =
->     convPa ca ann <+>
->     text "execute" <+> convExp s
->     <+> text "into" <+> hcatCsvMap text is
->     <> statementEnd
-
-> convStatement ca (CaseStatement ann c conds els) =
->     convPa ca ann <+>
->     text "case" <+> convExp c
->     $+$ nest 2 (
->                 vcat (map (uncurry convWhenSt) conds)
->                 $+$ convElseSt els
->                 ) $+$ text "end case" <> statementEnd
->     where
->       convWhenSt ex sts = text "when" <+> hcatCsvMap convExp ex
->                           <+> text "then" $+$ convNestedStatements ca sts
->       convElseSt = ifNotEmpty (\s -> text "else" $+$ convNestedStatements ca s)
-
-== misc
-
-> convStatement _ (Set _ n vs) =
->   text "set" <+> text n <+> text "=" <+> hcatCsvMap (text . dv) vs <> statementEnd
->   where
->     dv (SetStr _ s) = "'" ++ s ++ "'"
->     dv (SetId _ i) = i
->     dv (SetNum _ nm) = show nm
-
-> convStatement _ (Notify _ n) =
->   text "notify" <+> text n  <> statementEnd
-
-> statementEnd :: Doc
-> statementEnd = semi <> newline
-
-================================================================================
-
-= Statement components
-
-== selects
-
-> convSelectExpression :: Bool -> Bool -> SelectExpression -> Doc
-> convSelectExpression writeSelect _ (Select _ dis l tb wh grp hav
->                                 order lim off) =
->   text (if writeSelect then "select" else "")
->   <+> (case dis of
->          Dupes -> empty
->          Distinct -> text "distinct")
->   <+> convSelList l
->   $+$ nest 2 (
->               (if null tb
->                  then empty
->                  else text "from" <+> hcatCsvMap convTref tb)
->               $+$ convWhere wh)
->   <+> ifNotEmpty (\g -> text "group by" <+> hcatCsvMap convExp g) grp
->   <+> maybeConv (\h -> text "having" <+> convExp h) hav
->   <+> ifNotEmpty (\o -> text "order by" <+> hcatCsvMap (\(oe,od) -> convExp oe
->                   <+> convDir od) o) order
->   <+> maybeConv (\lm -> text "limit" <+> convExp lm) lim
->   <+> maybeConv (\offs -> text "offset" <+> convExp offs) off
->   where
->     convTref (Tref _ f a) = text f <+> convTrefAlias a
->     convTref (JoinedTref _ t1 nat jt t2 ex a) =
->         parens (convTref t1
->         $+$ (case nat of
->                       Natural -> text "natural"
->                       Unnatural -> empty)
->         <+> text (case jt of
->                           Inner -> "inner"
->                           Cross -> "cross"
->                           LeftOuter -> "left outer"
->                           RightOuter -> "right outer"
->                           FullOuter -> "full outer")
->         <+> text "join"
->         <+> convTref t2
->         <+> maybeConv (nest 2 . convJoinExpression) ex
->         <+> convTrefAlias a)
->         where
->           convJoinExpression (JoinOn _ e) = text "on" <+> convExp e
->           convJoinExpression (JoinUsing _ ids) =
->               text "using" <+> parens (hcatCsvMap text ids)
-
->     convTref (SubTref _ sub alias) =
->         parens (convSelectExpression True True sub)
->         <+> text "as" <+> convTrefAlias alias
->     convTref (TrefFun _ f@(FunCall _ _ _) a) = convExp f <+> convTrefAlias a
->     convTref (TrefFun _ x _) =
->         error $ "internal error: node not supported in function tref: " ++ show x
->     convTrefAlias NoAlias = empty
->     convTrefAlias (TableAlias t) = text t
->     convTrefAlias (FullAlias t s) = text t <+> parens (hcatCsvMap text s)
-
-> convSelectExpression writeSelect topLev (CombineSelect _ tp s1 s2) =
->   let p = convSelectExpression writeSelect False s1
->           $+$ (case tp of
->                        Except -> text "except"
->                        Union -> text "union"
->                        UnionAll -> text "union" <+> text "all"
->                        Intersect -> text "intersect")
->           $+$ convSelectExpression True False s2
->   in if topLev then p else parens p
-> convSelectExpression _ _ (Values _ expss) =
->   text "values" $$ nest 2 (vcat $ csv $ map (parens . csvExp) expss)
-
-> convDir :: Direction -> Doc
-> convDir d = text $ case d of
->                           Asc -> "asc"
->                           Desc -> "desc"
-
-
-> convWhere :: (Maybe Expression) -> Doc
-> convWhere (Just ex) = text "where" <+> convExp ex
-> convWhere Nothing = empty
-
-> convSelList :: SelectList -> Doc
-> convSelList (SelectList _ ex into) =
->   hcatCsvMap convSelItem ex
->   <+> ifNotEmpty (\i -> text "into" <+> hcatCsvMap text i) into
->   where
->     convSelItem (SelectItem _ ex1 nm) = convExp ex1 <+> text "as" <+> text nm
->     convSelItem (SelExp _ e) = convExp e
-
-> convCasc :: Cascade -> Doc
-> convCasc casc = text $ case casc of
->                                  Cascade -> "cascade"
->                                  Restrict -> "restrict"
-
-== ddl
-
-> convCon :: Constraint -> Doc
-> convCon (UniqueConstraint _ n c) =
->         mname n <+> text "unique"
->         <+> parens (hcatCsvMap text c)
-> convCon (PrimaryKeyConstraint _ n p) =
->         mname n <+>
->         text "primary key"
->         <+> parens (hcatCsvMap text p)
-> convCon (CheckConstraint _ n c) = mname n <+> text "check" <+> parens (convExp c)
-> convCon (ReferenceConstraint _ n at tb rat ondel onupd) =
->         mname n <+>
->         text "foreign key" <+> parens (hcatCsvMap text at)
->         <+> text "references" <+> text tb
->         <+> ifNotEmpty (parens . hcatCsvMap text) rat
->         <+> text "on update" <+> convCasc onupd
->         <+> text "on delete" <+> convCasc ondel
-
-> mname :: String -> Doc
-> mname n = if n == ""
->           then empty
->           else text "constraint" <+> text n
-
-
-> convReturning :: Maybe SelectList -> Doc
-> convReturning l = case l of
->                 Nothing -> empty
->                 Just ls -> nest 2 (text "returning" <+> convSelList ls)
-
-> convIfExists :: IfExists -> Doc
-> convIfExists i = case i of
->                         Require -> empty
->                         IfExists -> text "if exists"
-
-== plpgsql
-
-> convNestedStatements :: (Annotation -> String) -> StatementList -> Doc
-> convNestedStatements pa = nest 2 . vcat . map (convStatement pa)
-
-> convTypeName :: TypeName -> Doc
-> convTypeName (SimpleTypeName _ s) = text s
-> convTypeName (PrecTypeName _ s i) = text s <> parens(integer i)
-> convTypeName (ArrayTypeName _ t) = convTypeName t <> text "[]"
-> convTypeName (SetOfTypeName _ t) = text "setof" <+> convTypeName t
-
-= Expressions
-
-> convExp :: Expression -> Doc
-> convExp (Identifier _ i) =
->   if quotesNeeded
->      then text $ "\"" ++ i ++ "\""
->      else text i
->   where
->     --needs some work - quotes needed if contains invalid unquoted
->     --chars, or maybe if matches keyword or similar
->     quotesNeeded = case i of
->                      x:_ | not (isLetter x || x `elem` "_*") -> True
->                      _ | all okChar i -> False
->                        | otherwise -> True
->                    where
->                      okChar x =isAlphaNum x || x `elem` "*_."
-> convExp (IntegerLit _ n) = integer n
-> convExp (FloatLit _ n) = double n
-> convExp (StringLit _ tag s) = text tag <> text replaceQuotes <> text tag
->                           where
->                             replaceQuotes = if tag == "'"
->                                               then replace "'" "''" s
->                                               else s
-
-> convExp (FunCall _ n es) =
->     --check for special operators
->    case n of
->      "!arrayctor" -> text "array" <> brackets (csvExp es)
->      "!between" -> convExp (head es) <+> text "between"
->                    <+> parens (convExp (es !! 1))
->                   <+> text "and"
->                   <+> parens (convExp (es !! 2))
->      "!substring" -> text "substring"
->                      <> parens (convExp (head es)
->                                 <+> text "from" <+> convExp (es !! 1)
->                                 <+> text "for" <+> convExp (es !! 2))
->      "!arraysub" -> case es of
->                        ((Identifier _ i):es1) -> text i <> brackets (csvExp es1)
->                        _ -> parens (convExp (head es)) <> brackets (csvExp (tail es))
->      "!rowctor" -> text "row" <> parens (hcatCsvMap convExp es)
->      _ | isOperatorName n ->
->         case forceRight (getOperatorType defaultTemplate1Catalog n) of
->                           BinaryOp ->
->                               parens (convExp (head es)
->                                       <+> text (filterKeyword n)
->                                       <+> convExp (es !! 1))
->                           PrefixOp -> parens (text (if n == "u-"
->                                                        then "-"
->                                                        else filterKeyword n)
->                                                <+> parens (convExp (head es)))
->                           PostfixOp -> parens (convExp (head es) <+> text (filterKeyword n))
->        | otherwise -> text n <> parens (csvExp es)
->    where
->      filterKeyword t = case t of
->                          "!and" -> "and"
->                          "!or" -> "or"
->                          "!not" -> "not"
->                          "!isnull" -> "is null"
->                          "!isnotnull" -> "is not null"
->                          "!like" -> "like"
->                          x -> x
-
-> convExp (BooleanLit _ b) = bool b
-> convExp (InPredicate _ att t lst) =
->   convExp att <+> (if not t then text "not" else empty) <+> text "in"
->   <+> parens (case lst of
->                        InList _ expr -> csvExp expr
->                        InSelect _ sel -> convSelectExpression True True sel)
-> convExp (LiftOperator _ op flav args) =
->   convExp (head args) <+> text op
->   <+> text (case flav of
->               LiftAny -> "any"
->               LiftAll -> "all")
->   <+> parens (convExp $ head $ tail args)
-> convExp (ScalarSubQuery _ s) = parens (convSelectExpression True True s)
-> convExp (NullLit _) = text "null"
-> convExp (WindowFn _ fn part order asc frm) =
->   convExp fn <+> text "over"
->   <+> (if hp || ho
->        then
->           parens ((if hp
->                      then text "partition by" <+> csvExp part
->                      else empty)
->                   <+> (if ho
->                          then text "order by" <+> csvExp order
->                               <+> convDir asc
->                          else empty)
->                   <+> convFrm)
->        else empty)
->   where
->     hp = not (null part)
->     ho = not (null order)
->     convFrm = case frm of
->                 FrameUnboundedPreceding -> text "range unbounded preceding"
->                 FrameUnboundedFull -> text "range between unbounded preceding and unbounded following"
->                 FrameRowsUnboundedPreceding -> text "rows unbounded preceding"
-
-> convExp (Case _ whens els) =
->   text "case"
->   $+$ nest 2 (vcat (map convWhen whens)
->               $+$ maybeConv (\e -> text "else" <+> convExp e) els)
->   $+$ text "end"
->       where
->         convWhen (ex1, ex2) =
->             text "when" <+> hcatCsvMap convExp ex1
->             <+> text "then" <+> convExp ex2
-
-> convExp (CaseSimple _ val whens els) =
->   text "case" <+> convExp val
->   $+$ nest 2 (vcat (map convWhen whens)
->               $+$ maybeConv (\e -> text "else" <+> convExp e) els)
->   $+$ text "end"
->       where
->         convWhen (ex1, ex2) =
->             text "when" <+> hcatCsvMap convExp ex1
->             <+> text "then" <+> convExp ex2
-
-> convExp (PositionalArg _ a) = text "$" <> integer a
-> convExp (Placeholder _) = text "?"
-> convExp (Exists _ s) = text "exists" <+> parens (convSelectExpression True True s)
-> convExp (Cast _ ex t) = text "cast" <> parens (convExp ex
->                                              <+> text "as"
->                                              <+> convTypeName t)
-
-= Utils
-
-convert a list of expressions to horizontal csv
-
-> csvExp :: [Expression] -> Doc
-> csvExp = hcatCsvMap convExp
-
-> maybeConv :: (t -> Doc) -> Maybe t -> Doc
-> maybeConv f c =
->     case c of
->       Nothing -> empty
->       Just a -> f a
-
-> csv :: [Doc] -> [Doc]
-> csv = punctuate comma
-
-> hcatCsv :: [Doc] -> Doc
-> hcatCsv = hcat . csv
-
-> ifNotEmpty :: ([a] -> Doc) -> [a] -> Doc
-> ifNotEmpty c l = if null l then empty else c l
-
-> hcatCsvMap :: (a -> Doc) -> [a] -> Doc
-> hcatCsvMap ex = hcatCsv . map ex
-
-> bool :: Bool -> Doc
-> bool b = if b then text "true" else text "false"
-
-> newline :: Doc
-> newline = text "\n"
-
-> convPa :: (Annotation -> String) -> Annotation -> Doc
-> convPa ca a = let s = ca a
->               in if s == ""
->                    then empty
->                    else text "/*\n" <+> text s
->                         <+> text "*/\n"
diff --git a/Database/HsSqlPpp/Tests/DatabaseLoaderTests.lhs b/Database/HsSqlPpp/Tests/DatabaseLoaderTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/DatabaseLoaderTests.lhs
+++ /dev/null
@@ -1,33 +0,0 @@
-Copyright 2009 Jake Wheat
-
-TODO: the point of these tests will be to check the line and column
-mapping from parsed and pretty printed sql back to the original source
-text.
-Will be revived when the DatabaseLoader code is being worked on again.
-
-> module Database.HsSqlPpp.Tests.DatabaseLoaderTests (databaseLoaderTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-
-> import Database.HsSqlPpp.Dbms.DatabaseLoader
-
-> databaseLoaderTests :: Test.Framework.Test
-> databaseLoaderTests = testGroup "databaseLoaderTests" [] {-testGroup "databaseLoaderTests" [
->      t "execute: PGRES_FATAL_ERROR: ERROR:  column \"object_name\" of relation \"system_implementation_objects\" does not exist\n\
->        \LINE 1: insert into system_implementation_objects (object_name,objec...\n\
->        \                                                   ^\n"
->        0 1 --0 should be 43
-
->     ,t "execute: PGRES_FATAL_ERROR: ERROR:  column \"x\" does not exist\n\
->        \LINE 3:   (x,'base_relvar')\n\
->        \           ^\n"
->        0 3
-
-
->   ]
->         where
->           t et l c = testCase et $ do
->                           let (rl, rc) = getLineAndColumnFromErrorText et
->                           assertEqual "" (l,c) (rl,rc)-}
diff --git a/Database/HsSqlPpp/Tests/ExtensionTests.lhs b/Database/HsSqlPpp/Tests/ExtensionTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/ExtensionTests.lhs
+++ /dev/null
@@ -1,180 +0,0 @@
-Copyright 2009 Jake Wheat
-
-Set of tests for the extensions
-
-> {-# LANGUAGE RankNTypes,FlexibleContexts #-}
-
-> module Database.HsSqlPpp.Tests.ExtensionTests (extensionTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Extensions.ChaosExtensions
-> import Database.HsSqlPpp.Ast.Ast
-> --import Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
-
-> extensionTests :: Test.Framework.Test
-> extensionTests =
->   testGroup "extensionTests" (mapCheckExtension [
->     t rewriteCreateVars
->       "select create_var('varname','vartype');"
->       "create table varname_table (\n\
->       \  varname vartype);\n\
->       \create function get_varname() returns vartype as $a$\n\
->       \  select * from varname_table;\n\
->       \$a$ language sql stable;\n\
->       \create function check_con_varname_table_varname_key() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \/*drop function if exists varname_table_constraint_trigger_operator();\n\
->       \create function varname_table_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;*/\n\
->       \create function check_con_varname_table_01_tuple() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \drop function if exists varname_table_constraint_trigger_operator();\n\
->       \create function varname_table_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;"
-
->    ,t addReadonlyTriggers
->       "select set_relvar_type('stuff','readonly');"
->       "create function check_stuff_d_readonly() returns trigger as $a$\n\
->       \begin\n\
->       \  if (not (false)) then\n\
->       \    raise exception 'delete on base_relvar_metadata violates transition constraint base_relvar_metadata_d_readonly';\n\
->       \  end if;\n\
->       \return null;\n\
->       \end;\n\
->       \$a$ language plpgsql volatile;\n\
->       \create function check_stuff_i_readonly() returns trigger as $a$\n\
->       \begin\n\
->       \  if (not (false)) then\n\
->       \       raise exception 'delete on base_relvar_metadata violates transition constraint base_relvar_metadata_d_readonly';\n\
->       \  end if;\n\
->       \  return null;\n\
->       \end;\n\
->       \$a$ language plpgsql volatile;\n\
->       \create function check_stuff_u_readonly() returns trigger as $a$\n\
->       \begin\n\
->       \  if (not (false)) then\n\
->       \       raise exception 'delete on base_relvar_metadata violates transition constraint base_relvar_metadata_d_readonly';\n\
->       \  end if;\n\
->       \  return null;\n\
->       \end;\n\
->       \$a$ language plpgsql volatile;"
-
->    ,t createClientActionWrapper
->       "select create_client_action_wrapper('actname', $$actcall()$$);"
->       "create function action_actname() returns void as $a$\n\
->       \begin\n\
->       \  perform action_actcall();\n\
->       \end;\n\
->       \$a$ language plpgsql;"
->    ,t createClientActionWrapper
->       "select create_client_action_wrapper('actname', $$actcall('test')$$);"
->       "create function action_actname() returns void as $a$\n\
->       \begin\n\
->       \  perform action_actcall('test');\n\
->       \end;\n\
->       \$a$ language plpgsql;"
->    ,t addNotifyTriggers
->       "select set_relvar_type('stuff','data');"
->       "create function stuff_changed() returns trigger as $a$\n\
->       \begin\n\
->       \  notify stuff;\n\
->       \  return null;\n\
->       \end;\n\
->       \$a$ language plpgsql;"
->    ,t addConstraint
->       "select add_constraint('name', 'true', array['t1', 't2']);"
->       "create function check_con_name() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \drop function if exists t1_constraint_trigger_operator();\n\
->       \create function t1_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;\n\
->       \drop function if exists t2_constraint_trigger_operator();\n\
->       \create function t2_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;"
->    ,t addKey
->       "select add_key('tbl', 'attr');"
->       "create function check_con_tbl_attr_key() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \/*drop function if exists tbl_constraint_trigger_operator();\n\
->       \create function tbl_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;*/"
->    ,t addKey
->       "select add_key('tbl', array['attr1','attr2']);"
->       "create function check_con_tbl_attr1_attr2_key() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \/*drop function if exists tbl_constraint_trigger_operator();\n\
->       \create function tbl_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;*/"
->    ,t zeroOneTuple
->       "select constrain_to_zero_or_one_tuple('tbl');"
->       "create function check_con_tbl_01_tuple() returns boolean as $a$\n\
->       \begin\n\
->       \  return true;\n\
->       \end;\n\
->       \$a$ language plpgsql stable;\n\
->       \drop function if exists tbl_constraint_trigger_operator();\n\
->       \create function tbl_constraint_trigger_operator() returns trigger as $a$\n\
->       \begin\n\
->       \  null;\n\
->       \end;\n\
->       \$a$ language plpgsql;"
-
-
-add_foreign_key
-constrain zero one
-add constraint
-
->    ])
-
->   where
->     t a b c = (a,b,c)
->     mapCheckExtension = map (\(a,b,c) ->  checkExtension a b c)
->     checkExtension :: (StatementList -> StatementList) -> String -> String -> Test.Framework.Test
->     checkExtension f stxt ttxt = testCase ("check " ++ stxt) $
->       case (do
->             sast <- parseSql "" stxt
->             let esast = f sast
->             --trace (printSql esast) $ return ()
->             tast <- parseSql "" ttxt
->             return (tast,esast)) of
->         Left e -> assertFailure $ show e
->         Right (ts,es) -> assertEqual "" (stripAnnotations ts) (stripAnnotations es)
diff --git a/Database/HsSqlPpp/Tests/LocalBindingsTests.lhs b/Database/HsSqlPpp/Tests/LocalBindingsTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/LocalBindingsTests.lhs
+++ /dev/null
@@ -1,225 +0,0 @@
-Copyright 2010 Jake Wheat
-
-Tests for the local bindings lookup code, which is a bit convoluted in
-places, particularly for joins
-
-> module Database.HsSqlPpp.Tests.LocalBindingsTests (localBindingsTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> --import Text.Show.Pretty
-> --import Debug.Trace
-
-> import Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
-
-> import Database.HsSqlPpp.Ast.SqlTypes
-> --import Database.HsSqlPpp.Ast.Annotation
-> --import Database.HsSqlPpp.Parsing.Parser
-> --import Database.HsSqlPpp.Ast.TypeChecker
-> --import Database.HsSqlPpp.Ast.Catalog
-
-> data Item = Group String [Item]
->           | Lookup [([LocalBindingsUpdate]
->                     ,String -- correlation name
->                     ,String -- id name
->                     ,Either [TypeError] (String,String,String,Type))] -- source, corr, type
->           | StarExpand [([LocalBindingsUpdate], String, Either [TypeError] [(String,String,String,Type)])]
-
-> localBindingsTests :: [Test.Framework.Test]
-> localBindingsTests = itemToTft testData
-
-test plan:
-no updates uncor lookup, star
-cor lookup,star
-1 update
-  uncor match, match sys, no match, star (with sys not appearing)
-  cor same "
-  join update: join col type tests + incompatible
-               join on system columns
-               ambiguous ids
-               do cor tests with both cors
-2 updates: just one pair: lookup in head with shadowing
-           lookup in tail
-           no match
-           use difference cor to get to shadowed in tail
-case insensitive tests
-expand composite tests
-n layers of joins with ids from each layer cor and uncor, plus star expands
-
-> testData :: Item
-> testData =
->   Group "local bindings tests" [ Lookup [
->     testUnRec [] "" "test"
->    ,testUnRec [] "test" "test"
->    ,testRec [LBQualifiedIds "source1"
->                      ""
->                      [("test1", typeInt)
->                      ,("test2", typeBool)]
->                      []]
->              ("source1","","test1",typeInt)
-
->    ,testRec [unquids1] res11
->    ,testRec [unquids1] res12
->    ,testRec [unquids1] res13
->    ,testRec [unquids1] res14
->    ,testUnRec [unquids1] "" "asdasd"
-
->    ,testRec [quids1] res21
->    ,testRec [quids1] res22
->    ,testRec [quids1] res23
->    ,testRec [quids1] res24
->    ,testUnRec [quids1] "qid1" "asdasd"
->    ,testUnRec [quids1] "" "asdasd"
-
->    ,testRec [quids2] res31
->    ,testRec [quids2] res32
->    ,testRec [quids2] res33
->    ,testRec [quids2] res34
->    ,testUnRec [quids2] "qid2" "asdasd"
->    ,testUnRec [quids2] "" "asdasd"
-
->    ,testRecNoCor [quids2] res31
->    ,testRecNoCor [quids2] res32
->    ,testRecNoCor [quids2] res33
->    ,testRecNoCor [quids2] res34
-
-
->    ]
->    ,StarExpand [
->     testStar [unquids1] "" $ Right [res11,res12]
->    ,testStar [unquids1] "test" $ Left [UnrecognisedCorrelationName "test"]
->    ,testStar [quids1] "" $ Right [res21,res22]
->    ,testStar [quids1] "test2" $ Left [UnrecognisedCorrelationName "test2"]
->    ,testStar [quids2] "" $ Right [res31,res32]
->    ,testStar [quids2] "qid2" $ Right [res31,res32]
->    ,testStar [quids2] "qid3" $ Left [UnrecognisedCorrelationName "qid3"]
-
->   ]]
->   where
->     unquids1 = LBUnqualifiedIds "unqid1s"
->                             [("test1", typeInt)
->                             ,("test2", typeBool)]
->                             [("inttest1", typeInt)
->                             ,("inttest2", typeBool)]
->     res11 = ("unqid1s","","test1",typeInt)
->     res12 = ("unqid1s","","test2",typeBool)
->     res13 = ("unqid1s","","inttest1",typeInt)
->     res14 = ("unqid1s","","inttest2",typeBool)
-
->     unquids2 = LBUnqualifiedIds "unqid2s"
->                             [("test1", ScalarType "text")
->                             ,("test3", ScalarType "int2")]
->                             [("inttest1", ScalarType "text")
->                             ,("inttest3", ScalarType "int2")]
->     res211 = ("unqid2s","","test1",ScalarType "text")
->     res212 = ("unqid2s","","test3",ScalarType "int2")
->     res213 = ("unqid2s","","inttest1",ScalarType "text")
->     res214 = ("unqid2s","","inttest3",ScalarType "int2")
-
-
->     quids1 = LBQualifiedIds "qid1s"
->                             ""
->                             [("test1", typeInt)
->                             ,("test2", typeBool)]
->                             [("inttest1", typeInt)
->                             ,("inttest2", typeBool)]
->     res21 = ("qid1s","","test1",typeInt)
->     res22 = ("qid1s","","test2",typeBool)
->     res23 = ("qid1s","","inttest1",typeInt)
->     res24 = ("qid1s","","inttest2",typeBool)
-
->     quids2 = LBQualifiedIds "qid2s"
->                             "qid2"
->                             [("test3", typeInt)
->                             ,("test4", typeBool)]
->                             [("inttest3", typeInt)
->                             ,("inttest4", typeBool)]
->     res31 = ("qid2s","qid2","test3",typeInt)
->     res32 = ("qid2s","qid2","test4",typeBool)
->     res33 = ("qid2s","qid2","inttest3",typeInt)
->     res34 = ("qid2s","qid2","inttest4",typeBool)
-
-
->     testUnRec :: [LocalBindingsUpdate] -> String -> String
->               -> ([LocalBindingsUpdate]
->                  ,String -- correlation name
->                  ,String -- id name
->                  ,Either [TypeError] (String,String,String,Type))
->     testUnRec lbus cor i = (lbus,cor,i
->                            , Left [UnrecognisedIdentifier $
->                                    if cor == "" then i else cor ++ "." ++ i])
->     testRec :: [LocalBindingsUpdate]
->             -> (String,String,String,Type)
->             -> ([LocalBindingsUpdate]
->                ,String -- correlation name
->                ,String -- id name
->                ,Either [TypeError] (String,String,String,Type))
->     testRec lbus (src,cor,i,ty) = (lbus,cor,i,Right (src,cor,i,ty))
-
->     testRecNoCor :: [LocalBindingsUpdate]
->                  -> (String,String,String,Type)
->                  -> ([LocalBindingsUpdate]
->                     ,String -- correlation name
->                     ,String -- id name
->                     ,Either [TypeError] (String,String,String,Type))
->     testRecNoCor lbus (src,cor,i,ty) = (lbus,"",i,Right (src,cor,i,ty))
-
-
->     testStar :: [LocalBindingsUpdate]
->              -> String
->              -> Either [TypeError] [(String,String,String,Type)]
->              -> ([LocalBindingsUpdate]
->                 ,String -- correlation name
->                 ,Either [TypeError] [(String,String,String,Type)])
->     testStar lbus cor res = (lbus,cor,res)
-
-LBQualifiedIds {
-                              source :: String
-                             ,correlationName :: String
-                             ,ids :: [(String,Type)]
-                             ,internalIds :: [(String,Type)]
-                             }
-                          | LBUnqualifiedIds {
-                              source :: String
-                             ,ids :: [(String,Type)]
-                             ,internalIds :: [(String,Type)]
-                             }
-                          | LBJoinIds {
-                              source1 :: String
-                             ,correlationName1 :: String
-                             ,ids1 :: [(String,Type)]
-                             ,internalIds1 :: [(String,Type)]
-                             ,source2 :: String
-                             ,correlationName2 :: String
-                             ,ids2 :: [(String,Type)]
-                             ,internalIds2 :: [(String,Type)]
-                             ,joinIds :: [String]
-                             }
-
-
-================================================================================
-
-> testIdLookup :: [LocalBindingsUpdate]
->              -> String
->              -> String
->              -> Either [TypeError] (String,String,String,Type)
->              -> Test.Framework.Test
-> testIdLookup lbus cn i res = testCase ("lookup " ++ cn ++ "." ++ i) $ do
->     let lb = foldr lbUpdate emptyBindings lbus
->         r = lbLookupID lb cn i
->     assertEqual "lookupid" res r
-
-> testStarExpand :: [LocalBindingsUpdate]
->                -> String
->                -> Either [TypeError] [(String,String,String,Type)]
->                -> Test.Framework.Test
-> testStarExpand lbus cn res = testCase ("expand star " ++ cn) $ do
->     let lb = foldr lbUpdate emptyBindings lbus
->         r = lbExpandStar lb cn
->     assertEqual "lookupid" res r
-
-> itemToTft :: Item -> [Test.Framework.Test]
-> itemToTft (Lookup es) = map (\(a,b,c,d) -> testIdLookup a b c d) es
-> itemToTft (StarExpand es) = map (\(a,b,c) -> testStarExpand a b c) es
-> itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is]
diff --git a/Database/HsSqlPpp/Tests/ParameterizedStatementTests.lhs b/Database/HsSqlPpp/Tests/ParameterizedStatementTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/ParameterizedStatementTests.lhs
+++ /dev/null
@@ -1,147 +0,0 @@
-Copyright 2010 Jake Wheat
-
-Tests for the infrastructure to create type safe access to databases -
-the information needed is gathered during typechecking and exposed
-in the StatementType annotation.
-
-> module Database.HsSqlPpp.Tests.ParameterizedStatementTests (parameterizedStatementTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> --import Text.Show.Pretty
-> --import Debug.Trace
-
-
-> import Database.HsSqlPpp.Ast.SqlTypes
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Ast.Catalog
-
-> data Item = Group String [Item]
->           | Statements [(String, [CatalogUpdate], StatementType)]
-
-> parameterizedStatementTests :: [Test.Framework.Test]
-> parameterizedStatementTests = itemToTft testData
-
-> testData :: Item
-> testData =
->   Group "parameterized statement tests" [
->     Group "simple selects" [ Statements [
->        ("select test();"
->        ,[CatCreateFunction FunName "test" [] (Pseudo Void) False]
->        ,StatementType [] [])
->       ,("select adnum,adbin from pg_attrdef;"
->        ,[]
->        ,StatementType [] [("adnum", ScalarType "int2")
->                          ,("adbin", ScalarType "text")])
->       ,("select adnum,adbin from pg_attrdef where oid= ?;"
->        ,[]
->        ,StatementType [ScalarType "oid"] [("adnum", ScalarType "int2")
->                                           ,("adbin", ScalarType "text")])
->       ,("select count(1) from pg_attrdef;"
->        ,[]
->        ,StatementType [] [("count", ScalarType "int8")])
->        {-,("select test($1);"
->        ,[CatCreateFunction FunName "test" [ScalarType "int4"] (ScalarType "text") False]
->        ,StatementType [ScalarType "int4"] [("test",ScalarType "text")])
->       ,-}
->       ,("select test(?);"
->        ,[CatCreateFunction FunName "test" [ScalarType "int4"] (ScalarType "text") False]
->        ,StatementType [ScalarType "int4"] [("test",ScalarType "text")])
->        ]
->     ]
->    ,Group "simple dml" [ Statements [
->        ("insert into testt values (1, 'test');"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [] [])
->       ,("insert into testt (c1,c2) values (?, ?);"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt, ScalarType "text"] [])
->       ,("insert into testt (c1,c2) values (1, 'test') returning c1;"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [] [("c1",typeInt)])
->       ,("insert into testt (c1,c2) values (?, ?) returning c1 as d1, c2;"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt, ScalarType "text"] [("d1", typeInt)
->                                                    ,("c2", ScalarType "text")])
->       {-,("insert into testt (c1,c2) values (?, ?) returning *;"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt, ScalarType "text"] [("c1", typeInt)
->                                                    ,("c2", ScalarType "text")])-}
->       ,("update testt set c1= ?,c2= ? where c1= ? returning c2;"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt, ScalarType "text", typeInt] [("c2", ScalarType "text")])
->       ,("update testt set (c1,c2) = (?,?);"
->        ,[CatCreateTable "testt" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt, ScalarType "text"] [])
->       ,("delete from blah where c1= ? returning c2;"
->        ,[CatCreateTable "blah" [("c1", typeInt)
->                                 ,("c2", ScalarType "text")] []]
->        ,StatementType [typeInt] [("c2", ScalarType "text")])
->       ]
->     ]
->    ]
-
-select a,b from c where d=e group by f having  g=h orderby i limit j offset k;
-select function(a,b);
-insert into a (b,c) values (d,e) returning f,g
-update a set b=c,d=e where f=g returning h,i
-delete from t where a=b returning c,d
-
-rough list of grammar elements to possibly add inference support to:
-
-where top level - >maybeboolexpr
-having
-limit, offset
-values for table literal or insert
-set clause
-rowsetclause
-onexpr, joinon?
-windowfn
-liftoperator
-selectitem?
-castexpression
-caseexpression
-funcall
-inpredicate
-
-  TODO: add support in each of these places for position args only when
-        doing typecheckPS
-        do typecheck error if come across ? when not doing typecheckPS
-        make sure ? fails type check if not in a valid place in the ast
-
-================================================================================
-
-
-> testStatementType :: String -> [CatalogUpdate] -> StatementType -> Test.Framework.Test
-> testStatementType src eu st = testCase ("typecheck " ++ src) $
->   let ast = case parseSql "" src of
->                               Left e -> error $ show e
->                               Right l -> l
->   in case typeCheckPS makeCat (head ast) of
->        Left e -> error $ show e
->        Right aast -> --trace (ppShow aast) $
->                      let is = getTopLevelInfos [aast]
->                          er = concatMap snd $ getTypeErrors [aast]
->                      in case is of
->                                 _ | not (null er) -> assertFailure $ show er
->                                 [Just is1] -> assertEqual ("typecheck " ++ src) st is1
->                                 _ -> assertFailure ("expected onne statementinfo, got " ++ show is)
->   where
->     makeCat = case updateCatalog defaultTemplate1Catalog eu of
->                         Left x -> error $ show x
->                         Right e -> e
-
-> itemToTft :: Item -> [Test.Framework.Test]
-> itemToTft (Statements es) = map (\(a,b,c) -> testStatementType a b c) es
-> itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is]
-
diff --git a/Database/HsSqlPpp/Tests/ParserTests.lhs b/Database/HsSqlPpp/Tests/ParserTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/ParserTests.lhs
+++ /dev/null
@@ -1,1262 +0,0 @@
-Copyright 2009 Jake Wheat
-
-The automated tests, uses hunit to check a bunch of text expressions
-and sql statements parse to the correct tree, and then checks pretty
-printing and then reparsing gives the same tree. The code was mostly
-written in a tdd style, which the coverage of the tests reflects.
-
-There are no tests for invalid sql at the moment.
-
-> {-# LANGUAGE QuasiQuotes #-}
-
-> module Database.HsSqlPpp.Tests.ParserTests (parserTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> import Data.Generics
-
-> import Database.HsSqlPpp.Here
-
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
-
-
-> data Item = Expressions [(String, Expression)]
->           | Statements [(String, [Statement])]
->           | PlpgsqlStatements [(String, [Statement])]
->           | Group String [Item]
-
-> parserTests :: [Test.Framework.Test]
-> parserTests = itemToTft parserTestData
-
-> parserTestData :: Item
-> parserTestData =
->   Group "parserTests" [
-
-================================================================================
-
-expressions
-
->    Group "parse expressions" [
->     Group "basic expressions" [Expressions [
->       p "1" (IntegerLit [] 1)
->      ,p "-1" (FunCall [] "u-" [IntegerLit [] 1])
->      ,p "1.1" (FloatLit [] 1.1)
->      ,p "-1.1" (FunCall [] "u-" [FloatLit [] 1.1])
->      ,p " 1 + 1 " (FunCall [] "+" [IntegerLit [] 1
->                               ,IntegerLit [] 1])
->      ,p "1+1+1" (FunCall [] "+" [FunCall [] "+" [IntegerLit [] 1
->                                         ,IntegerLit [] 1]
->                             ,IntegerLit [] 1])
->      ]]
-
-
->    ,Group "parens" [Expressions [
-
-check some basic parens use wrt naked values and row constructors
-these tests reflect how pg seems to interpret the variants.
-
->       p "(1)" (IntegerLit [] 1)
->      ,p "row ()" (FunCall [] "!rowctor" [])
->      ,p "row (1)" (FunCall [] "!rowctor" [IntegerLit [] 1])
->      ,p "row (1,2)" (FunCall [] "!rowctor" [IntegerLit [] 1,IntegerLit [] 2])
->      ,p "(1,2)" (FunCall [] "!rowctor" [IntegerLit [] 1,IntegerLit [] 2])
->      ]]
-
->    ,Group "more basic expressions" [Expressions [
-
-test some more really basic expressions
-
->       p "'test'" (stringQ "test")
->      ,p "''" (stringQ "")
->      ,p "hello" (Identifier [] "hello")
->      ,p "helloTest" (Identifier [] "helloTest")
->      ,p "hello_test" (Identifier [] "hello_test")
->      ,p "\"this is an identifier\"" (Identifier [] "this is an identifier")
->      ,p "hello1234" (Identifier [] "hello1234")
->      ,p "true" (BooleanLit [] True)
->      ,p "false" (BooleanLit [] False)
->      ,p "null" (NullLit [])
->      ]]
-
->    ,Group "array ctor and selector" [Expressions [
->       p "array[1,2]" (FunCall [] "!arrayctor" [IntegerLit [] 1, IntegerLit [] 2])
->      ,p "a[1]" (FunCall [] "!arraysub" [Identifier [] "a", IntegerLit [] 1])
-
->      ]]
-
->    ,Group "simple operators" [Expressions [
->       p "1 + tst1" (FunCall [] "+" [IntegerLit [] 1
->                                ,Identifier [] "tst1"])
->      ,p "tst1 + 1" (FunCall [] "+" [Identifier [] "tst1"
->                                ,IntegerLit [] 1])
->      ,p "tst + tst1" (FunCall [] "+" [Identifier [] "tst"
->                                  ,Identifier [] "tst1"])
->      ,p "'a' || 'b'" (FunCall [] "||" [stringQ "a"
->                                   ,stringQ "b"])
->      ,p "'stuff'::text" (Cast [] (stringQ "stuff") (SimpleTypeName [] "text"))
->      ,p "245::float(24)" (Cast [] (IntegerLit [] 245) (PrecTypeName [] "float" 24))
-
->      ,p "245::double precision" (Cast [] (IntegerLit [] 245) (SimpleTypeName [] "double precision"))
-
->      ,p "a between 1 and 3"
->         (FunCall [] "!between" [Identifier [] "a", IntegerLit [] 1, IntegerLit [] 3])
->      ,p "cast(a as text)"
->         (Cast [] (Identifier [] "a") (SimpleTypeName [] "text"))
->      ,p "@ a"
->         (FunCall [] "@" [Identifier [] "a"])
-
->      ,p "substring(a from 0 for 3)"
->         (FunCall [] "!substring" [Identifier [] "a", IntegerLit [] 0, IntegerLit [] 3])
-
->      ,p "substring(a from 0 for (5 - 3))"
->         (FunCall [] "!substring" [Identifier [] "a",IntegerLit [] 0,
->          FunCall [] "-" [IntegerLit [] 5,IntegerLit [] 3]])
->      ,p "a like b"
->         (FunCall [] "!like" [Identifier [] "a", Identifier [] "b"])
->      ]]
-
->    ,Group "function calls" [Expressions [
->       p "fn()" (FunCall [] "fn" [])
->      ,p "fn(1)" (FunCall [] "fn" [IntegerLit [] 1])
->      ,p "fn('test')" (FunCall [] "fn" [stringQ "test"])
->      ,p "fn(1,'test')" (FunCall [] "fn" [IntegerLit [] 1, stringQ "test"])
->      ,p "fn('test')" (FunCall [] "fn" [stringQ "test"])
->      ]]
-
->    ,Group "simple whitespace sanity checks" [Expressions [
->       p "fn (1)" (FunCall [] "fn" [IntegerLit [] 1])
->      ,p "fn( 1)" (FunCall [] "fn" [IntegerLit [] 1])
->      ,p "fn(1 )" (FunCall [] "fn" [IntegerLit [] 1])
->      ,p "fn(1) " (FunCall [] "fn" [IntegerLit [] 1])
-
->      ]]
-
->    ,Group "null stuff" [Expressions [
->       p "not null" (FunCall [] "!not" [NullLit []])
->      ,p "a is null" (FunCall [] "!isnull" [Identifier [] "a"])
->      ,p "a is not null" (FunCall [] "!isnotnull" [Identifier [] "a"])
-
->      ,p "not not true" (FunCall [] "!not"
->                          [FunCall [] "!not"
->                           [BooleanLit [] True]])
->      ]]
-
->    ,Group "case expressions" [Expressions [
->       p {-"case when a,b then 3\n\
->         \     when c then 4\n\
->         \     else 5\n\
->         \end" -}
->         [$here|
->          case when a,b then 3
->               when c then 4
->               else 5
->          end
->          |]
->         (Case [] [([Identifier [] "a", Identifier [] "b"], IntegerLit [] 3)
->               ,([Identifier [] "c"], IntegerLit [] 4)]
->          (Just $ IntegerLit [] 5))
-
->      ,p  "case 1 when 2 then 3 else 4 end"
->         (CaseSimple [] (IntegerLit [] 1)
->            [([IntegerLit [] 2], IntegerLit [] 3)]
->          (Just $ IntegerLit [] 4))
->      ]]
-
->    ,Group "positional args" [Expressions [
->       p "$1" (PositionalArg [] 1)
->      ,p "?" (Placeholder [])
->      ,p "a = ?" (FunCall [] "=" [Identifier [] "a",Placeholder []])
->      ]]
-
->    ,Group "exists" [Expressions [
->       p "exists (select 1 from a)"
->       (Exists [] (selectFrom [SelExp [] (IntegerLit [] 1)] (Tref [] "a" NoAlias)))
->      ]]
-
->    ,Group "in variants" [Expressions [
->       p "t in (1,2)"
->       (InPredicate [] (Identifier [] "t") True (InList [] [IntegerLit [] 1,IntegerLit [] 2]))
->      ,p "t not in (1,2)"
->       (InPredicate [] (Identifier [] "t") False (InList [] [IntegerLit [] 1,IntegerLit [] 2]))
->      ,p "(t,u) in (1,2)"
->       (InPredicate [] (FunCall [] "!rowctor" [Identifier [] "t",Identifier [] "u"]) True
->        (InList [] [IntegerLit [] 1,IntegerLit [] 2]))
->      ,p "3 = any (array[1,2])"
->       (LiftOperator [] "=" LiftAny [IntegerLit [] 3
->                                     ,FunCall [] "!arrayctor" [IntegerLit [] 1
->                                                              ,IntegerLit [] 2]])
->      ,p "3 = all (array[1,2,4])"
->       (LiftOperator [] "=" LiftAll [IntegerLit [] 3
->                                     ,FunCall [] "!arrayctor" [IntegerLit [] 1
->                                                              ,IntegerLit [] 2
->                                                              ,IntegerLit [] 4]])
->      ]]
-
->    ,Group "comparison operators" [Expressions [
->       p "a < b"
->       (FunCall [] "<" [Identifier [] "a", Identifier [] "b"])
->      ,p "a <> b"
->       (FunCall [] "<>" [Identifier [] "a", Identifier [] "b"])
->      ,p "a != b"
->       (FunCall [] "<>" [Identifier [] "a", Identifier [] "b"])
->      ]]
-
-test some string parsing, want to check single quote behaviour,
-and dollar quoting, including nesting.
-
->    ,Group "string parsing" [Expressions [
->       p "''" (stringQ "")
->      ,p "''''" (stringQ "'")
->      ,p "'test'''" (stringQ "test'")
->      ,p "'''test'" (stringQ "'test")
->      ,p "'te''st'" (stringQ "te'st")
->      ,p "$$test$$" (StringLit [] "$$" "test")
->      ,p "$$te'st$$" (StringLit [] "$$" "te'st")
->      ,p "$st$test$st$" (StringLit [] "$st$" "test")
->      ,p "$outer$te$$yup$$st$outer$" (StringLit [] "$outer$" "te$$yup$$st")
->      ,p "'spl$$it'" (stringQ "spl$$it")
->      ]]
->      ]
-
-================================================================================
-
-select statements
-
->   ,Group "simple select statements" [
->     Group "select no table" [Statements [
->       p "select 1;" [SelectStatement [] $ selectE (SelectList [] [SelExp [] (IntegerLit [] 1)] [])]
->      ]]
->    ,Group "select from table" [Statements [
->       p "select * from tbl;"
->       [SelectStatement [] $ selectFrom (selIL ["*"]) (Tref [] "tbl" NoAlias)]
->      ,p "select a,b from tbl;"
->       [SelectStatement [] $ selectFrom (selIL ["a", "b"]) (Tref [] "tbl" NoAlias)]
-
->      ,p "select a,b from inf.tbl;"
->       [SelectStatement [] $ selectFrom (selIL ["a", "b"]) (Tref [] "inf.tbl" NoAlias)]
-
->      ,p "select distinct * from tbl;"
->       [SelectStatement [] $ Select [] Distinct (SelectList [] (selIL ["*"]) []) [Tref [] "tbl" NoAlias]
->        Nothing [] Nothing [] Nothing Nothing]
-
->      ,p "select a from tbl where b=2;"
->       [SelectStatement [] $ selectFromWhere
->         (selIL ["a"])
->         (Tref [] "tbl" NoAlias)
->         (FunCall [] "="
->          [Identifier [] "b", IntegerLit [] 2])]
->      ,p "select a from tbl where b=2 and c=3;"
->       [SelectStatement [] $ selectFromWhere
->         (selIL ["a"])
->         (Tref [] "tbl" NoAlias)
->         (FunCall [] "!and"
->          [FunCall [] "="  [Identifier [] "b", IntegerLit [] 2]
->          ,FunCall [] "=" [Identifier [] "c", IntegerLit [] 3]])]
-
->      ]]
-
->    ,Group "more select statements" [Statements [
->       p "select a from tbl\n\
->         \except\n\
->         \select a from tbl1;"
->       [SelectStatement [] $ CombineSelect [] Except
->        (selectFrom (selIL ["a"]) (Tref [] "tbl" NoAlias))
->        (selectFrom (selIL ["a"]) (Tref [] "tbl1" NoAlias))]
->      ,p "select a from tbl where true\n\
->         \except\n\
->         \select a from tbl1 where true;"
->       [SelectStatement [] $ CombineSelect [] Except
->        (selectFromWhere (selIL ["a"]) (Tref [] "tbl" NoAlias) (BooleanLit [] True))
->        (selectFromWhere (selIL ["a"]) (Tref [] "tbl1" NoAlias) (BooleanLit [] True))]
->      ,p "select a from tbl\n\
->         \union\n\
->         \select a from tbl1;"
->       [SelectStatement [] $ CombineSelect [] Union
->        (selectFrom (selIL ["a"]) (Tref [] "tbl" NoAlias))
->        (selectFrom (selIL ["a"]) (Tref [] "tbl1" NoAlias))]
->      ,p "select a from tbl\n\
->         \union all\n\
->         \select a from tbl1;"
->       [SelectStatement [] $ CombineSelect [] UnionAll
->        (selectFrom (selIL ["a"]) (Tref [] "tbl" NoAlias))
->        (selectFrom (selIL ["a"]) (Tref [] "tbl1" NoAlias))]
-
->      ,p "(select 1 union select 2) union select 3;"
->       [SelectStatement []
->        (CombineSelect [] Union
->         (CombineSelect [] Union
->          (selectE (SelectList [] [SelExp [] (IntegerLit [] 1)] []))
->          (selectE (SelectList [] [SelExp [] (IntegerLit [] 2)] [])))
->         (selectE (SelectList [] [SelExp [] (IntegerLit [] 3)] [])))]
-
->      ,p "select 1 union (select 2 union select 3);"
->       [SelectStatement []
->        (CombineSelect [] Union
->         (selectE (SelectList [] [SelExp [] (IntegerLit [] 1)] []))
->         (CombineSelect [] Union
->          (selectE (SelectList [] [SelExp [] (IntegerLit [] 2)] []))
->          (selectE (SelectList [] [SelExp [] (IntegerLit [] 3)] []))))]
-
->      ,p "select a as b from tbl;"
->       [SelectStatement [] $ selectFrom [SelectItem [] (Identifier [] "a") "b"] (Tref [] "tbl" NoAlias)]
->      ,p "select a + b as b from tbl;"
->       [SelectStatement [] $ selectFrom
->        [SelectItem []
->         (FunCall [] "+"
->          [Identifier [] "a", Identifier [] "b"]) "b"]
->        (Tref [] "tbl" NoAlias)]
->      ,p "select a.* from tbl a;"
->       [SelectStatement [] $ selectFrom (selIL ["a.*"]) (Tref [] "tbl" (TableAlias "a"))]
-
->      ,p "select a.* from tbl a(b,c);"
->       [SelectStatement [] $ selectFrom (selIL ["a.*"]) (Tref [] "tbl" (FullAlias "a" ["b","c"]))]
-
->      ,p "select * from t1 a, t2 b;"
->             [SelectStatement []
->              (Select [] Dupes
->               (SelectList []
->                [SelExp [] (Identifier [] "*")] [])
->               [Tref [] "t1" (TableAlias "a"),Tref [] "t2" (TableAlias "b")]
->               Nothing [] Nothing [] Nothing Nothing)]
->      ,p "select a from b inner join c on b.a=c.a;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural Inner (Tref [] "c" NoAlias)
->           (Just (JoinOn []
->            (FunCall [] "=" [Identifier [] "b.a", Identifier [] "c.a"]))) NoAlias)]
->      ,p "select a from b inner join c as d on b.a=d.a;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural Inner (Tref [] "c" (TableAlias "d"))
->           (Just (JoinOn []
->            (FunCall [] "=" [Identifier [] "b.a", Identifier [] "d.a"]))) NoAlias)]
-
->      ,p "select a from b inner join c using(d,e);"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural Inner (Tref [] "c" NoAlias)
->           (Just (JoinUsing [] ["d","e"])) NoAlias)]
-
->      ,p "select a from b natural inner join c;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Natural Inner (Tref [] "c" NoAlias) Nothing NoAlias)]
->      ,p "select a from b left outer join c;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural LeftOuter (Tref [] "c" NoAlias) Nothing NoAlias)]
->      ,p "select a from b full outer join c;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural FullOuter (Tref [] "c" NoAlias) Nothing NoAlias)]
->      ,p "select a from b right outer join c;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural RightOuter (Tref [] "c" NoAlias) Nothing NoAlias)]
->      ,p "select a from b cross join c;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Unnatural Cross (Tref [] "c" NoAlias) Nothing NoAlias)]
-
->      ,p "select a from (b natural join c);"
->       [SelectStatement [] $ selectFrom
->        (selIL ["a"])
->        (JoinedTref [] (Tref [] "b" NoAlias) Natural Inner (Tref [] "c" NoAlias) Nothing NoAlias)]
-
->      ,p "select x from ((a cross join b) cross join c);"
->        [SelectStatement []
->         (selectFrom (selIL ["x"])
->          (JoinedTref []
->          (JoinedTref []
->           (Tref [] "a" NoAlias)
->            Unnatural Cross
->           (Tref [] "b" NoAlias)
->           Nothing NoAlias)
->          Unnatural Cross
->          (Tref [] "c" NoAlias)
->          Nothing NoAlias))]
-
->      ,p "select x from (a cross join (b cross join c));"
->        [SelectStatement []
->         (selectFrom (selIL ["x"])
->          (JoinedTref []
->           (Tref [] "a" NoAlias)
->           Unnatural Cross
->           (JoinedTref []
->            (Tref [] "b" NoAlias)
->            Unnatural Cross
->            (Tref [] "c" NoAlias)
->            Nothing NoAlias)
->           Nothing NoAlias))]
-
->      ,p "select x from ((a cross join b) cross join c);"
->        [SelectStatement []
->         (selectFrom (selIL ["x"])
->          (JoinedTref []
->          (JoinedTref []
->           (Tref [] "a" NoAlias)
->            Unnatural Cross
->           (Tref [] "b" NoAlias)
->           Nothing NoAlias)
->          Unnatural Cross
->          (Tref [] "c" NoAlias)
->          Nothing NoAlias))]
-
->      ,p "select x from (a cross join b) cross join c;"
->        [SelectStatement []
->         (selectFrom (selIL ["x"])
->          (JoinedTref []
->          (JoinedTref []
->           (Tref [] "a" NoAlias)
->            Unnatural Cross
->           (Tref [] "b" NoAlias)
->           Nothing NoAlias)
->          Unnatural Cross
->          (Tref [] "c" NoAlias)
->          Nothing NoAlias))]
-
->      ,p "select x from ((a cross join b) cross join c) cross join d;"
->        [SelectStatement []
->         (selectFrom (selIL ["x"])
->          (JoinedTref []
->           (JoinedTref []
->            (JoinedTref []
->             (Tref [] "a" NoAlias)
->             Unnatural Cross
->             (Tref [] "b" NoAlias)
->             Nothing NoAlias)
->            Unnatural Cross
->            (Tref [] "c" NoAlias)
->            Nothing NoAlias)
->           Unnatural Cross
->           (Tref [] "d" NoAlias)
->           Nothing NoAlias))]
-
-
->      ,p "select a from b\n\
->         \    inner join c\n\
->         \      on true\n\
->         \    inner join d\n\
->         \      on 1=1;"
->       [SelectStatement [] $ selectFrom
->        [SelExp [] (Identifier [] "a")]
->        (JoinedTref []
->         (JoinedTref [] (Tref [] "b" NoAlias) Unnatural Inner (Tref [] "c" NoAlias)
->          (Just $ JoinOn [] (BooleanLit [] True)) NoAlias)
->         Unnatural Inner (Tref [] "d" NoAlias)
->         (Just  $ JoinOn [] (FunCall [] "="
->                [IntegerLit [] 1, IntegerLit [] 1])) NoAlias)]
-
->      ,p "select row_number() over(order by a) as place from tbl;"
->       [SelectStatement [] $ selectFrom [SelectItem []
->                    (WindowFn []
->                     (FunCall [] "row_number" [])
->                     []
->                     [Identifier [] "a"] Asc FrameUnboundedPreceding)
->                    "place"]
->        (Tref [] "tbl" NoAlias)]
->      ,p "select row_number() over(order by a asc) as place from tbl;"
->       [SelectStatement [] $ selectFrom [SelectItem []
->                    (WindowFn []
->                     (FunCall [] "row_number" [])
->                     []
->                     [Identifier [] "a"] Asc FrameUnboundedPreceding)
->                    "place"]
->        (Tref [] "tbl" NoAlias)]
->      ,p "select row_number() over(order by a desc) as place from tbl;"
->       [SelectStatement [] $ selectFrom [SelectItem []
->                    (WindowFn []
->                     (FunCall [] "row_number" [])
->                     []
->                     [Identifier [] "a"] Desc FrameUnboundedPreceding)
->                    "place"]
->        (Tref [] "tbl" NoAlias)]
->      ,p "select row_number()\n\
->         \over(partition by (a,b) order by c) as place\n\
->         \from tbl;"
->       [SelectStatement [] $ selectFrom [SelectItem []
->                    (WindowFn []
->                     (FunCall [] "row_number" [])
->                     [FunCall [] "!rowctor" [Identifier [] "a",Identifier [] "b"]]
->                     [Identifier [] "c"] Asc FrameUnboundedPreceding)
->                    "place"]
->        (Tref [] "tbl" NoAlias)]
-
->      ,p "select * from a natural inner join (select * from b) as a;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["*"])
->        (JoinedTref [] (Tref [] "a" NoAlias) Natural
->         Inner (SubTref [] (selectFrom
->                         (selIL ["*"])
->                         (Tref [] "b" NoAlias)) (TableAlias "a"))
->         Nothing NoAlias)]
-
->      ,p "select * from a order by c;"
->       [SelectStatement [] $ Select []  Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "a" NoAlias]
->        Nothing [] Nothing [(Identifier [] "c",Asc)] Nothing Nothing]
-
->      ,p "select *\n\
->            \from Adventure\n\
->            \order by Clicks desc, AdventureID;"
->       [SelectStatement [] $ Select [] Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "Adventure" NoAlias]
->        Nothing [] Nothing [(Identifier [] "Clicks",Desc)
->                           ,(Identifier [] "AdventureID",Asc)] Nothing Nothing]
-
->      ,p "select * from a order by c,d asc;"
->       [SelectStatement [] $ Select [] Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "a" NoAlias]
->        Nothing [] Nothing [(Identifier [] "c", Asc)
->                           ,(Identifier [] "d", Asc)] Nothing Nothing]
-
->      ,p "select * from a order by c,d desc;"
->       [SelectStatement [] $ Select [] Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "a" NoAlias]
->        Nothing [] Nothing [(Identifier [] "c", Asc)
->                           ,(Identifier [] "d", Desc)] Nothing Nothing]
-
->      ,p "select * from a order by c limit 1;"
->       [SelectStatement [] $ Select [] Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "a" NoAlias]
->        Nothing [] Nothing [(Identifier [] "c",Asc)] (Just (IntegerLit [] 1)) Nothing]
-
->      ,p "select * from a order by c offset 3;"
->       [SelectStatement [] $ Select [] Dupes
->        (sl (selIL ["*"]))
->        [Tref [] "a" NoAlias]
->        Nothing [] Nothing [(Identifier [] "c",Asc)] Nothing (Just $ IntegerLit [] 3)]
-
->      ,p "select a from (select b from c) as d;"
->         [SelectStatement [] $ selectFrom
->          (selIL ["a"])
->          (SubTref [] (selectFrom
->                    (selIL ["b"])
->                    (Tref [] "c" NoAlias))
->           (TableAlias "d"))]
-
->      ,p "select * from gen();"
->         [SelectStatement [] $ selectFrom (selIL ["*"]) (TrefFun [] (FunCall [] "gen" []) NoAlias)]
->      ,p "select * from gen() as t;"
->       [SelectStatement [] $ selectFrom
->        (selIL ["*"])
->        (TrefFun [] (FunCall [] "gen" [])(TableAlias  "t"))]
-
->      ,p "select a, count(b) from c group by a;"
->         [SelectStatement [] $ Select [] Dupes
->          (sl [selI "a", SelExp [] (FunCall [] "count" [Identifier [] "b"])])
->          [Tref [] "c" NoAlias] Nothing [Identifier [] "a"]
->          Nothing [] Nothing Nothing]
-
->      ,p "select a, count(b) as cnt from c group by a having cnt > 4;"
->         [SelectStatement [] $ Select [] Dupes
->          (sl [selI "a", SelectItem [] (FunCall [] "count" [Identifier [] "b"]) "cnt"])
->          [Tref [] "c" NoAlias] Nothing [Identifier [] "a"]
->          (Just $ FunCall [] ">" [Identifier [] "cnt", IntegerLit [] 4])
->          [] Nothing Nothing]
-
->      ,p "select a from (select 1 as a, 2 as b) x;"
->         [SelectStatement [] $ selectFrom
->          [selI "a"]
->          (SubTref [] (selectE $ SelectList []
->                                [SelectItem [] (IntegerLit [] 1) "a"
->                                ,SelectItem [] (IntegerLit [] 2) "b"] [])
->                   (TableAlias "x"))]
->      ]]
-
->    ,Group "multiple statements" [Statements [
->       p "select 1;\nselect 2;" [SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 1)]
->                                ,SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 2)]]
->      ]]
-
->    ,Group "comments" [Statements [
->       p "" []
->      ,p "-- this is a test" []
->      ,p "/* this is\n\
->         \a test*/" []
->      ,p "select 1;\n\
->         \-- this is a test\n\
->         \select -- this is a test\n\
->         \2;" [SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 1)]
->              ,SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 2)]
->              ]
->      ,p "select 1;\n\
->         \/* this is\n\
->         \a test*/\n\
->         \select /* this is a test*/2;"
->                     [SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 1)]
->                     ,SelectStatement [] $ selectE $ sl [SelExp [] (IntegerLit [] 2)]
->                     ]
->      ]]
->      ]
-
-================================================================================
-
-dml statements
-
->    ,Group "dml" [
->      Group "insert" [Statements [
->       p "insert into testtable\n\
->         \(columna,columnb)\n\
->         \values (1,2);\n"
->        [Insert []
->         "testtable"
->         ["columna", "columnb"]
->         (Values [] [[IntegerLit [] 1, IntegerLit [] 2]])
->         Nothing]
-
-multi row insert, test the stand alone values statement first, maybe
-that should be in the select section?
-
->      ,p "values (1,2), (3,4);"
->      [SelectStatement [] $ Values [] [[IntegerLit [] 1, IntegerLit [] 2]
->              ,[IntegerLit [] 3, IntegerLit [] 4]]]
-
->      ,p "insert into testtable\n\
->         \(columna,columnb)\n\
->         \values (1,2), (3,4);\n"
->       [Insert []
->         "testtable"
->         ["columna", "columnb"]
->         (Values [] [[IntegerLit [] 1, IntegerLit [] 2]
->                 ,[IntegerLit [] 3, IntegerLit [] 4]])
->         Nothing]
-
-insert from select
-
->      ,p "insert into a\n\
->          \    select b from c;"
->       [Insert [] "a" []
->        (selectFrom [selI "b"] (Tref [] "c" NoAlias))
->        Nothing]
-
->      ,p "insert into testtable\n\
->         \(columna,columnb)\n\
->         \values (1,2) returning id;\n"
->       [Insert []
->         "testtable"
->         ["columna", "columnb"]
->         (Values [] [[IntegerLit [] 1, IntegerLit [] 2]])
->         (Just $ sl [selI "id"])]
->      ]]
-
->     ,Group "update" [Statements [
->       p "update tb\n\
->         \  set x = 1, y = 2;"
->       [Update [] "tb" [SetClause [] "x" (IntegerLit [] 1)
->                    ,SetClause [] "y" (IntegerLit [] 2)]
->        Nothing Nothing]
->      ,p "update tb\n\
->         \  set x = 1, y = 2 where z = true;"
->       [Update [] "tb" [SetClause [] "x" (IntegerLit [] 1)
->                    ,SetClause [] "y" (IntegerLit [] 2)]
->        (Just $ FunCall [] "="
->         [Identifier [] "z", BooleanLit [] True])
->        Nothing]
->      ,p "update tb\n\
->         \  set x = 1, y = 2 returning id;"
->       [Update [] "tb" [SetClause [] "x" (IntegerLit [] 1)
->                    ,SetClause [] "y" (IntegerLit [] 2)]
->        Nothing (Just $ sl [selI "id"])]
->      ,p "update pieces\n\
->         \set a=b returning tag into r.tag;"
->       [Update [] "pieces" [SetClause [] "a" (Identifier [] "b")]
->        Nothing (Just (SelectList []
->                       [SelExp [] (Identifier [] "tag")]
->                       ["r.tag"]))]
->      ,p "update tb\n\
->         \  set (x,y) = (1,2);"
->       [Update [] "tb" [RowSetClause []
->                     ["x","y"]
->                     [IntegerLit [] 1,IntegerLit [] 2]]
->        Nothing Nothing]
->      ]]
-
->     ,Group "delete" [Statements [
->       p "delete from tbl1 where x = true;"
->       [Delete [] "tbl1" (Just $ FunCall [] "="
->                                [Identifier [] "x", BooleanLit [] True])
->        Nothing]
->      ,p "delete from tbl1 where x = true returning id;"
->       [Delete [] "tbl1" (Just $ FunCall [] "="
->                                [Identifier [] "x", BooleanLit [] True])
->        (Just $ sl [selI "id"])]
->      ]]
-
->     ,Group "truncate" [Statements [
->       p "truncate test;"
->        [Truncate [] ["test"] ContinueIdentity Restrict]
-
->      ,p "truncate table test, test2 restart identity cascade;"
->        [Truncate [] ["test","test2"] RestartIdentity Cascade]
->      ]]
-
-copy, bit crap at the moment
-
->     ,Group "copy" [Statements [
->       p "copy tbl(a,b) from stdin;\n\
->         \bat\tt\n\
->         \bear\tf\n\
->         \\\.\n"
->       [Copy [] "tbl" ["a", "b"] Stdin
->        ,CopyData [] "\
->         \bat\tt\n\
->         \bear\tf\n"]
->      ]]
-
-================================================================================
-
-ddl statements
-
->    ,Group "ddl" [
->      Group "simple tables" [Statements [
->       p "create table test (\n\
->         \  fielda text,\n\
->         \  fieldb int\n\
->         \);"
->       [CreateTable []
->        "test"
->        [att "fielda" "text"
->        ,att "fieldb" "int"
->        ]
->        []]
->      ,p "create table tbl (\n\
->         \  fld boolean default false);"
->       [CreateTable [] "tbl" [AttributeDef [] "fld" (SimpleTypeName [] "boolean")
->                           (Just $ BooleanLit [] False) []][]]
-
->      ,p "create table tbl as select 1;"
->       [CreateTableAs [] "tbl"
->        (selectE (SelectList [] [SelExp [] (IntegerLit [] 1)] []))]
-
-
->      ,p "alter table a alter column b set default 1;"
->       [AlterTable [] "a" [AlterColumnDefault [] "b" (IntegerLit [] 1)]]
-
->      ,p "alter table a add constraint unique(b);"
->       [AlterTable [] "a" [AddConstraint [] (UniqueConstraint [] "" ["b"])]]
->      ]]
-
->     ,Group "others" [Statements [
->       p "create view v1 as\n\
->         \select a,b from t;"
->       [CreateView []
->        "v1"
->        (selectFrom [selI "a", selI "b"] (Tref [] "t" NoAlias))]
->      ,p "create domain td as text check (value in ('t1', 't2'));"
->       [CreateDomain [] "td" (SimpleTypeName [] "text") ""
->        (Just (InPredicate [] (Identifier [] "value") True
->               (InList [] [stringQ "t1" ,stringQ "t2"])))]
->      ,p "create type tp1 as (\n\
->         \  f1 text,\n\
->         \  f2 text\n\
->         \);"
->       [CreateType [] "tp1" [TypeAttDef [] "f1" (SimpleTypeName [] "text")
->                         ,TypeAttDef [] "f2" (SimpleTypeName [] "text")]]
-
->      ,p "create sequence s start with 5 increment by 4 no maxvalue no minvalue cache 1;"
->         [CreateSequence [] "s" 4 1 ((2::Integer) ^ (63::Integer) - 1) 5 1]
-
->      ,p "alter sequence s owned by a.b;"
->         [AlterSequence [] "s" "a.b"]
-
->      ,p "create trigger tr\n\
->          \after insert or delete on tb\n\
->          \for each statement\n\
->          \execute procedure fb();"
->         [CreateTrigger [] "tr" TriggerAfter [TInsert,TDelete] "tb" EachStatement "fb" []]
->      ]]
-
->     ,Group "drops" [Statements [
->       p "drop domain t;"
->       [DropSomething [] Domain Require ["t"] Restrict]
->      ,p "drop domain if exists t,u cascade;"
->       [DropSomething [] Domain IfExists ["t", "u"] Cascade]
->      ,p "drop domain t restrict;"
->       [DropSomething [] Domain Require ["t"] Restrict]
-
->      ,p "drop type t;"
->       [DropSomething [] Type Require ["t"] Restrict]
->      ,p "drop table t;"
->       [DropSomething [] Table Require ["t"] Restrict]
->      ,p "drop view t;"
->       [DropSomething [] View Require ["t"] Restrict]
-
->      ]]
-
->     ,Group "constraints" [
->       Group "nulls" [Statements [
->       p "create table t1 (\n\
->         \ a text null\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "a" (SimpleTypeName [] "text")
->                            Nothing [NullConstraint [] ""]]
->          []]
->      ,p "create table t1 (\n\
->         \ a text not null\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "a" (SimpleTypeName [] "text")
->                            Nothing [NotNullConstraint [] ""]]
->          []]
->      ]]
-
->      ,Group "unique" [Statements [
->       p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ unique (x,y)\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [UniqueConstraint [] "" ["x","y"]]]
-
-test arbitrary ordering
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ unique (x),\n\
->         \ y int\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [UniqueConstraint [] "" ["x"]]]
-
-unique row
-
->      ,p "create table t1 (\n\
->         \ x int unique\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowUniqueConstraint [] ""]][]]
-
->      ,p "create table t1 (\n\
->         \ x int unique not null\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowUniqueConstraint [] ""
->                            ,NotNullConstraint [] ""]][]]
-
-quick sanity check
-
->      ,p "create table t1 (\n\
->         \ x int not null unique\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [NotNullConstraint [] ""
->                            ,RowUniqueConstraint [] ""]][]]
->      ]]
-
->      ,Group "primary key" [Statements [
->       p "create table t1 (\n\
->         \ x int primary key\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowPrimaryKeyConstraint [] ""]][]]
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ primary key (x,y)\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [PrimaryKeyConstraint [] "" ["x", "y"]]]
-
->      ]]
-
->      ,Group "check" [Statements [
->       p "create table t (\n\
->         \f text check (f in('a', 'b'))\n\
->         \);"
->         [CreateTable [] "t"
->          [AttributeDef [] "f" (SimpleTypeName [] "text") Nothing
->           [RowCheckConstraint [] "" (InPredicate []
->                                   (Identifier [] "f") True
->                                   (InList [] [stringQ "a", stringQ "b"]))]] []]
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ check (x>y)\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [CheckConstraint [] "" (FunCall [] ">" [Identifier [] "x", Identifier [] "y"])]]
->      ]]
-
->      ,Group "misc" [Statements [
->       p "create table t (\n\
->         \f text not null unique check (f in('a', 'b'))\n\
->         \);"
->         [CreateTable [] "t"
->          [AttributeDef [] "f" (SimpleTypeName [] "text") Nothing
->           [NotNullConstraint [] ""
->            ,RowUniqueConstraint [] ""
->            ,RowCheckConstraint [] "" (InPredicate []
->                                    (Identifier [] "f") True
->                                    (InList [] [stringQ "a"
->                                            ,stringQ "b"]))]] []]
-
->      ]]
-
->      ,Group "references" [Statements [
->       p "create table t1 (\n\
->         \ x int references t2\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowReferenceConstraint [] "" "t2" Nothing
->                             Restrict Restrict]][]]
-
->      ,p "create table t1 (\n\
->         \ x int references t2(y)\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowReferenceConstraint [] "" "t2" (Just "y")
->                             Restrict Restrict]][]]
-
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ foreign key (x,y) references t2\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [ReferenceConstraint [] "" ["x", "y"] "t2" []
->           Restrict Restrict]]
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ foreign key (x,y) references t2(z,w)\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [ReferenceConstraint [] "" ["x", "y"] "t2" ["z", "w"]
->           Restrict Restrict]]
-
->      ,p "create table t1 (\n\
->         \ x int references t2 on delete cascade\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowReferenceConstraint [] "" "t2" Nothing
->                             Cascade Restrict]][]]
-
->      ,p "create table t1 (\n\
->         \ x int references t2 on update cascade\n\
->         \);"
->         [CreateTable [] "t1" [AttributeDef [] "x" (SimpleTypeName [] "int") Nothing
->                            [RowReferenceConstraint [] "" "t2" Nothing
->                             Restrict Cascade]][]]
-
->      ,p "create table t1 (\n\
->         \ x int,\n\
->         \ y int,\n\
->         \ foreign key (x,y) references t2 on update cascade on delete cascade\n\
->         \);"
->         [CreateTable [] "t1" [att "x" "int"
->                           ,att "y" "int"]
->          [ReferenceConstraint [] "" ["x", "y"] "t2" []
->           Cascade Cascade]]
-
->      ]]
->      ]]
->    ,Group "functions" [
->      Group "basics" [Statements [
->       p "create function t1(text) returns text as $$\n\
->         \select a from t1 where b = $1;\n\
->         \$$ language sql stable;"
->       [CreateFunction [] "t1" [ParamDefTp [] $ SimpleTypeName [] "text"]
->        (SimpleTypeName [] "text") Sql "$$"
->        (SqlFnBody []
->         [SelectStatement [] $ selectFromWhere [SelExp [] (Identifier [] "a")] (Tref [] "t1" NoAlias)
->          (FunCall [] "="
->           [Identifier [] "b", PositionalArg [] 1])])
->        Stable]
->      ,p "create function fn() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql volatile;"
->       [CreateFunction [] "fn" [] (SimpleTypeName [] "void") Plpgsql "$$"
->        (PlpgsqlFnBody [] [VarDef [] "a" (SimpleTypeName [] "int") Nothing
->                          ,VarDef [] "b" (SimpleTypeName [] "text") Nothing]
->         [NullStatement []])
->        Volatile]
->      ,p "create function fn() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql volatile;"
->       [CreateFunction [] "fn" [] (SimpleTypeName [] "void") Plpgsql "$$"
->        (PlpgsqlFnBody [] [VarDef [] "a" (SimpleTypeName [] "int") Nothing
->                          ,VarDef [] "b" (SimpleTypeName [] "text") Nothing]
->         [NullStatement []])
->        Volatile]
->      ,p "create function fn(a text[]) returns int[] as $$\n\
->         \declare\n\
->         \  b xtype[] := '{}';\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql immutable;"
->       [CreateFunction [] "fn"
->        [ParamDef [] "a" $ ArrayTypeName [] $ SimpleTypeName [] "text"]
->        (ArrayTypeName [] $ SimpleTypeName [] "int") Plpgsql "$$"
->        (PlpgsqlFnBody []
->         [VarDef [] "b" (ArrayTypeName [] $ SimpleTypeName [] "xtype") (Just $ stringQ "{}")]
->         [NullStatement []])
->        Immutable]
->      ,p "create function fn() returns void as '\n\
->         \declare\n\
->         \  a int := 3;\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \' language plpgsql stable;"
->       [CreateFunction [] "fn" [] (SimpleTypeName [] "void") Plpgsql "'"
->        (PlpgsqlFnBody [] [VarDef [] "a" (SimpleTypeName [] "int") (Just $ IntegerLit [] 3)]
->         [NullStatement []])
->        Stable]
->      ,p "create function fn() returns setof int as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->       [CreateFunction [] "fn" []
->        (SetOfTypeName [] $ SimpleTypeName [] "int") Plpgsql "$$"
->        (PlpgsqlFnBody [] [] [NullStatement []])
->        Stable]
->      ,p "create function fn() returns void as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end\n\
->         \$$ language plpgsql stable;"
->       [CreateFunction [] "fn" []
->        (SimpleTypeName [] "void") Plpgsql "$$"
->        (PlpgsqlFnBody [] [] [NullStatement []])
->        Stable]
->      ,p "drop function test(text);"
->       [DropFunction [] Require [("test",[SimpleTypeName [] "text"])] Restrict]
->      ,p "drop function if exists a(),test(text) cascade;"
->       [DropFunction [] IfExists [("a",[])
->                           ,("test",[SimpleTypeName [] "text"])] Cascade]
->     ]]
-
->     ,Group "simple plpgsql statements" [PlpgsqlStatements [
->       p "success := true;"
->       [Assignment [] "success" (BooleanLit [] True)]
->      ,p "success = true;"
->       [Assignment [] "success" (BooleanLit [] True)]
->      ,p "return true;"
->       [Return [] $ Just (BooleanLit [] True)]
->      ,p "return;"
->       [Return [] Nothing]
->      ,p "return next 1;"
->       [ReturnNext [] $ IntegerLit [] 1]
->      ,p "return query select a from b;"
->       [ReturnQuery [] $ selectFrom [selI "a"] (Tref [] "b" NoAlias)]
->      ,p "raise notice 'stuff %', 1;"
->       [Raise [] RNotice "stuff %" [IntegerLit [] 1]]
->      ,p "perform test();"
->       [Perform [] $ FunCall [] "test" []]
->      ,p "perform test(a,b);"
->       [Perform [] $ FunCall [] "test" [Identifier [] "a", Identifier [] "b"]]
->      ,p "perform test(r.relvar_name || '_and_stuff');"
->       [Perform [] $ FunCall [] "test" [
->                     FunCall [] "||" [Identifier [] "r.relvar_name"
->                                 ,stringQ "_and_stuff"]]]
->      ,p "select into a,b c,d from e;"
->       [SelectStatement [] $ Select [] Dupes (SelectList [] [selI "c", selI "d"] ["a", "b"])
->                   [Tref [] "e" NoAlias] Nothing [] Nothing [] Nothing Nothing]
->      ,p "select c,d into a,b from e;"
->       [SelectStatement [] $ Select [] Dupes (SelectList [] [selI "c", selI "d"] ["a", "b"])
->                   [Tref [] "e" NoAlias] Nothing [] Nothing [] Nothing Nothing]
-
->      ,p "execute s;"
->       [Execute [] (Identifier [] "s")]
->      ,p "execute s into r;"
->       [ExecuteInto [] (Identifier [] "s") ["r"]]
-
->      ,p "continue;" [ContinueStatement []]
->     ]]
-
->     ,Group "other plpgsql statements" [PlpgsqlStatements [
->       p "for r in select a from tbl loop\n\
->         \null;\n\
->         \end loop;"
->       [ForSelectStatement [] "r" (selectFrom  [selI "a"] (Tref [] "tbl" NoAlias))
->        [NullStatement []]]
->      ,p "for r in select a from tbl where true loop\n\
->         \null;\n\
->         \end loop;"
->       [ForSelectStatement [] "r"
->        (selectFromWhere [selI "a"] (Tref [] "tbl" NoAlias) (BooleanLit [] True))
->        [NullStatement []]]
->      ,p "for r in 1 .. 10 loop\n\
->         \null;\n\
->         \end loop;"
->       [ForIntegerStatement [] "r"
->        (IntegerLit [] 1) (IntegerLit [] 10)
->        [NullStatement []]]
-
->      ,p "if a=b then\n\
->         \  update c set d = e;\n\
->         \end if;"
->       [If [] [((FunCall [] "=" [Identifier [] "a", Identifier [] "b"])
->           ,[Update [] "c" [SetClause [] "d" (Identifier [] "e")] Nothing Nothing])]
->        []]
->      ,p "if true then\n\
->         \  null;\n\
->         \else\n\
->         \  null;\n\
->         \end if;"
->       [If [] [((BooleanLit [] True),[NullStatement []])]
->        [NullStatement []]]
->      ,p "if true then\n\
->         \  null;\n\
->         \elseif false then\n\
->         \  return;\n\
->         \end if;"
->       [If [] [((BooleanLit [] True), [NullStatement []])
->           ,((BooleanLit [] False), [Return [] Nothing])]
->        []]
->      ,p "if true then\n\
->         \  null;\n\
->         \elseif false then\n\
->         \  return;\n\
->         \elseif false then\n\
->         \  return;\n\
->         \else\n\
->         \  return;\n\
->         \end if;"
->       [If [] [((BooleanLit [] True), [NullStatement []])
->           ,((BooleanLit [] False), [Return [] Nothing])
->           ,((BooleanLit [] False), [Return [] Nothing])]
->        [Return [] Nothing]]
->      ,p "case a\n\
->         \  when b then null;\n\
->         \  when c,d then null;\n\
->         \  else null;\n\
->         \end case;"
->      [CaseStatement [] (Identifier [] "a")
->       [([Identifier [] "b"], [NullStatement []])
->       ,([Identifier [] "c", Identifier [] "d"], [NullStatement []])]
->       [NullStatement []]]
-
->     ]]
-
->    ,Group "misc" [Statements [
->       p "SET search_path TO my_schema, public;"
->         [Set [] "search_path" [SetId [] "my_schema"
->                               ,SetId [] "public"]]
->      ,p "SET t1 = 3;"
->         [Set [] "t1" [SetNum [] 3]]
->      ,p "SET t1 = 'stuff';"
->         [Set [] "t1" [SetStr [] "stuff"]]
->      ,p "create language plpgsql;"
->         [CreateLanguage [] "plpgsql"]
-
->     ]]
-
->     ]]]
-
-================================================================================
-
-shortcuts for constructing test data and asts
-
-> p :: t -> t1 -> (t, t1)
-> p a b = (a,b)
-
-> stringQ :: String -> Expression
-> stringQ = StringLit [] "'"
-
-> selectFrom :: SelectItemList
->            -> TableRef
->            -> SelectExpression
-> selectFrom selList frm = Select [] Dupes (SelectList [] selList [])
->                            [frm] Nothing [] Nothing [] Nothing Nothing
-
-> selectE :: SelectList -> SelectExpression
-> selectE selList = Select [] Dupes selList
->                     [] Nothing [] Nothing [] Nothing Nothing
-
-> selIL :: [String] -> [SelectItem]
-> selIL = map selI
-
-> selI :: String -> SelectItem
-> selI = SelExp [] . Identifier []
-
-> sl :: SelectItemList -> SelectList
-> sl a = SelectList [] a []
-
-> selectFromWhere :: SelectItemList
->                 -> TableRef
->                 -> Expression
->                 -> SelectExpression
-> selectFromWhere selList frm whr =
->     Select [] Dupes (SelectList [] selList [])
->                [frm] (Just whr) [] Nothing [] Nothing Nothing
-
-> att :: String -> String -> AttributeDef
-> att n t = AttributeDef [] n (SimpleTypeName [] t) Nothing []
-
-
-================================================================================
-
-Unit test helpers
-
-> itemToTft :: Item -> [Test.Framework.Test]
-> itemToTft (Expressions es) = map (uncurry testParseExpression) es
-> itemToTft (PlpgsqlStatements es) = map (uncurry testParsePlpgsqlStatements) es
-> itemToTft (Statements es) = map (uncurry testParseStatements) es
-> itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is]
-
-
-> testParseExpression :: String -> Expression -> Test.Framework.Test
-> testParseExpression src ast = parseUtil src ast
->                                  (parseExpression "") printExpression
-
-> testParseStatements :: String -> [Statement] -> Test.Framework.Test
-> testParseStatements src ast = parseUtil src ast (parseSql "") printSql
-
-> testParsePlpgsqlStatements :: String -> [Statement] -> Test.Framework.Test
-> testParsePlpgsqlStatements src ast = parseUtil src ast (parsePlpgsql "") printSql
-
-> parseUtil :: (Show t, Eq b, Show b, Data b) =>
->              String
->           -> b
->           -> (String -> Either t b)
->           -> (b -> String)
->           -> Test.Framework.Test
-> parseUtil src ast parser printer = testCase ("parse " ++ src) $
->   case parser src of
->     Left er -> assertFailure $ show er
->     Right ast' -> do
->       assertEqual ("parse " ++ src) ast $ stripAnnotations ast'
->       case parser (printer ast) of
->         Left er -> assertFailure $ "reparse\n" ++ show er ++ "\n" -- ++ pp ++ "\n"
->         Right ast'' -> assertEqual ("reparse " ++ printer ast) ast $ stripAnnotations ast''
-
-TODO
-new idea for testing:
-parsesql -> ast1
-parse, pretty print, parse -> ast2
-load into pg, pg_dump, parse -> ast3
-parse, pretty print, load into pg, pg_dump, parse -> ast4
-check all these asts are the same
diff --git a/Database/HsSqlPpp/Tests/RoundtripTests.lhs b/Database/HsSqlPpp/Tests/RoundtripTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/RoundtripTests.lhs
+++ /dev/null
@@ -1,249 +0,0 @@
-Copyright 2010 Jake Wheat
-
-Test sql by typechecking it, then running it through Postgres and comparing:
-* compare the catalog from typechecking to the one read from postgres
-* load then dump the sql and compare post and pre asts
-* (NOT STARTED ON YET) create views and check the type from type
-  checking to the one from pg
-
-> module Database.HsSqlPpp.Tests.RoundtripTests (roundtripTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> import Control.Monad.Error
-> import Data.List
-> import Data.Generics
-> import Data.Generics.PlateData
-> import Data.Char
-
-> import Database.HsSqlPpp.Utils
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Dbms.DBUtils
-> import Database.HsSqlPpp.Dbms.DatabaseLoader
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.SqlTypes
-
-slightly dodgy, these tests automatically connect to this database and
-clear it. hopefully no-one running these tests is storing important
-data in a database with this name
-
-> testDatabaseName :: String
-> testDatabaseName = "hssqlpppautomatedtests"
-
-> data Item = Group String [Item]
->           | Src [(String,String)]
-
-> roundtripTests :: [Test.Framework.Test]
-> roundtripTests = itemToTft roundtripTestData
-
-> roundtripTestData :: Item
-> roundtripTestData =
->     Group "round trip tests" [ Src [
->       ("simple select"
->       ,"select 1 from pg_attrdef;")
->      ,("create domain"
->       ,"create domain testd as text;")
->      ,("create domain with check"
->       ,"create domain testd as text check (length(value) > 2);")
->      ,("create composite"
->       ,"create type pos as (\n\
->        \  x int,\n\
->        \  y int);")
->      ,("create table"
->       ,"create table ttable (\n\
->        \  x int,\n\
->        \  y int);")
->      --,("create table with constraints"
->      -- ,"create table ttable (\n\
->      --  \  x int primary key,\n\
->      --  \  y int not null);")
->      ,("create view"
->       ,"create view v1 as select * from pg_attrdef;")
->      ,("create function"
->       ,"create function test1() returns integer as $$\n\
->        \  select 1;\n\
->        \$$ language sql;")
->      ,("create plpgsql function"
->       ,"create language plpgsql;\n\
->        \create function test1() returns void as $$\n\
->        \begin\n\
->        \  null;\n\
->        \end;\n\
->        \$$ language plpgsql;")
->     ]]
-
-TODO for test data:
-run through constraints in create table after attribute and as seperate rows
-do multiple constraints on a line
-use create view to run through select variations
-
-
-================================================================================
-
-
-> itemToTft :: Item -> [Test.Framework.Test]
-> itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is]
-> itemToTft (Src ss) = map (uncurry testRoundtrip) ss
-
-> testRoundtrip :: String -> String -> Test.Framework.Test
-> testRoundtrip name sql = testCase ("test " ++ name) $ wrapETT $ do
->   astOrig <- tsl $ parseSql "" sql
->   let (catOrig, astOrigTC) = typeCheck defaultTemplate1Catalog astOrig
->   failIfTypeErrors astOrigTC
->   -- run the tests first using psql to load the sql into the database
->   -- and then using hssqlppp's database loader to load the sql into
->   -- the database
->   doPgTests astOrig catOrig (liftIO (loadSqlUsingPsql testDatabaseName sql >> return ()))
->   doPgTests astOrig catOrig (liftIO $ loadIntoDatabase testDatabaseName "" astOrig)
->   where
->     doPgTests :: [Statement] -> Catalog -> ErrorT String IO () -> ErrorT String IO () -- a -> a
->     doPgTests astOrig catOrig loadIntoDb = do
->       -- parse and type check the test sql
->       -- load this sql into pg
->       liftIO $ clearDB testDatabaseName
->       loadIntoDb
->       -- check the catalog in pg is the same as the one from type checking
->       catPsql <- liftIO (readCatalog testDatabaseName) >>= tsl
->       compareCats "load" catOrig catPsql
->       -- dump the database to get the sql having been normalized by passing
->       -- it through pg's digestive system
->       dumpSql <- liftIO $ pgDump testDatabaseName
->       astDumped <- tsl $ parseSql "" dumpSql
->       let (catDumped, astDumpedTC) = typeCheck defaultTemplate1Catalog astDumped
->       failIfTypeErrors $ astDumpedTC
->       -- check the original catalog from the catalog gotten from
->       -- dumping then typechecking the dump, maybe a little excessive
->       compareCats "dump" catOrig catDumped
->       -- compare the original ast to the dump ast, uses a transform
->       -- to match the changes that happen to the sql when loaded
->       -- then dumped by pg
->       let astOrigAdj = adjustAstToLookLikeDump $ adjTree astOrig
->           astDumpedAdj = adjTree astDumped
->       -- do this when a test fails to help diagnose why
->       when (astOrigAdj /= astDumpedAdj) $
->             liftIO $ putStrLn $ sql ++ "\n" ++ dumpSql
->       liftIO $ assertEqual "check dump ast" astOrigAdj astDumpedAdj
-
->     compareCats s c1 c2 =
->       case compareCatalogs defaultTemplate1Catalog c1 c2 of
->               CatalogDiff [] [] -> liftIO $ return ()
->               c -> liftIO $ assertFailure $ s ++ ", catalogs different: " ++ ppCatDiff c
->     -- adjust tree is the normalization that we run on the original ast as
->     -- well as the dumped ast
->     adjTree :: [Statement] -> [Statement]
->     adjTree = canonicalizeTypeNames . stripAnnotations
->     failIfTypeErrors xast = do
->       let te = getTypeErrors xast
->       when (not $ null te) $ throwError $ show te
-
-take the parse tree and change the type names to the canonical versions
-
-> canonicalizeTypeNames :: Data a => a -> a
-> canonicalizeTypeNames =
->   transformBi $ \x ->
->       case x of
->         SimpleTypeName a tn -> SimpleTypeName a $ canonicalizeTypeName tn
->         x1 -> x1
-
-
-================================================================================
-
-ast roundtrip tests:
-want to compare the asts of parsed sql, with the asts of the sql
-loaded into pg, dumped and parsed
-issues:
-some statements are split apart e.g. create table with constraints
-some statements are reordered in the dump
-a create, select and then drop will be a problem
-so need some sort of map function to convert between, and use
-extensions to cover the dynamic ddl
-
-
-one of the things really want to double check is associativity and
-precedence mainly in select expressions, pg_dump puts in the implicit
-brackets which we can use to check these things
-
-
-> adjustAstToLookLikeDump :: [Statement] -> [Statement]
-> adjustAstToLookLikeDump ast =
->   (addPresets . stripDml . addConstraintNames) ast
->   where
->     -- add the following at the beginning of the ast, since this is what pg_dump does
->     -- SET statement_timeout = 0;
->     -- SET client_encoding = 'UTF8';
->     -- SET standard_conforming_strings = off;
->     -- SET check_function_bodies = false;
->     -- SET client_min_messages = warning;
->     -- SET escape_string_warning = off;
->
->     -- SET search_path = public, pg_catalog;
->     noDml = stripDml ast
->     addPresets = adjustForCreatePlpgsql . (presets ++)
->     adjustForCreatePlpgsql =
->       transformBi $ \x ->
->           case x of
->             s@(Set _ "search_path" _):s1@(CreateLanguage _ _):s2 -> s1:s:s2
->             z -> z
-
->     presets = [Set [] "statement_timeout" [SetNum [] 0.0]
->               ,Set [] "client_encoding" [SetStr [] "UTF8"]
->               ,Set [] "standard_conforming_strings" [SetId [] "off"]
->               ,Set [] "check_function_bodies" [SetId [] "false"]
->               ,Set [] "client_min_messages" [SetId [] "warning"]
->               ,Set [] "escape_string_warning" [SetId [] "off"]]
->               -- if there are no statements, pg_dump doesn't spit out the search path
->               ++ if null noDml then [] else
->                      [Set [] "search_path" [SetId [] "public", SetId [] "pg_catalog"]]
->               -- these two sets get added if there are create tables
->               ++ case flip find ast (\s ->
->                                   case s of
->                                     CreateTable _ _ _ _ -> True
->                                     _ -> False) of
->                    Nothing -> []
->                    Just _ -> [Set [] "default_tablespace" [SetStr [] ""]
->                              ,Set [] "default_with_oids" [SetId [] "false"]]
->     -- dml statements don't appear in the dump
->     stripDml = filter (\s -> case s of
->                                SelectStatement _ _ -> False
->                                Insert _ _ _ _ _ -> False
->                                Update _ _ _ _ _ -> False
->                                Delete _ _ _ _ -> False
->                                Copy _ _ _ _ -> False
->                                CopyData _ _ -> False
->                                Truncate _ _ _ _ -> False
->                                _ -> True)
-
-when pg comes across a constraint without a name, it generates one
-automatically and this appears in the dump, so try to follow the
-generation here, also any 'value' identifiers will be in uppercase
-
-> addConstraintNames :: Data a => a -> a
-> addConstraintNames =
->   transformBi $ \x ->
->       case x of
->         CreateDomain a name base "" cons ->
->             CreateDomain a name base
->               (case cons of
->                          Nothing -> ""
->                          Just _ -> name ++ "_check") (upcaseValue cons)
->                   where
->                     upcaseValue = transformBi $ \y ->
->                                   case y of
->                                     Identifier a1 i | map toUpper i == "VALUE" ->
->                                           Identifier a1 "VALUE"
->                                     y1 -> y1
->         x1 -> x1
-
-================================================================================
-
-some random support functions, to be tidied up
-
-> wrapETT :: (Show e) => ErrorT e IO () -> IO ()
-> wrapETT c = runErrorT c >>= \x ->
->          case x of
->            Left er -> assertFailure $ show er
->            Right l -> return l
diff --git a/Database/HsSqlPpp/Tests/TypeCheckTests.lhs b/Database/HsSqlPpp/Tests/TypeCheckTests.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Tests/TypeCheckTests.lhs
+++ /dev/null
@@ -1,1119 +0,0 @@
-Copyright 2009 Jake Wheat
-
-Set of tests to check the type checking code. Includes some tests for
-sql which doesn't type check.
-
-
-> module Database.HsSqlPpp.Tests.TypeCheckTests (typeCheckTests) where
-
-> import Test.HUnit
-> import Test.Framework
-> import Test.Framework.Providers.HUnit
-> import Data.List
-
-> import Database.HsSqlPpp.Parsing.Parser
-> import Database.HsSqlPpp.Ast.TypeChecker
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Ast.Catalog
-> import Database.HsSqlPpp.Ast.SqlTypes
-
-> data Item = Expressions [(String, Either [TypeError] Type)]
->           | StatementTypes [(String, Either [TypeError] [Maybe StatementType])]
->           | CatUpStatementTypes [(String
->                                  ,[CatalogUpdate]
->                                  ,Either [TypeError] [Maybe StatementType])]
->           | DdlStatements [(String, [[CatalogUpdate]])]
->           | DdlStatementsCat [(String, [CatalogUpdate])]
->           | Group String [Item]
-
-> typeCheckTests :: [Test.Framework.Test]
-> typeCheckTests = itemToTft typeCheckTestData
-
-> typeCheckTestData :: Item
-> typeCheckTestData =
->   Group "astCheckTests" [
-
->    Group "basic literal types" [ Expressions [
->       p "1" $ Right typeInt
->      ,p "1.0" $ Right typeNumeric
->      ,p "'test'" $ Right UnknownType
->      ,p "true" $ Right typeBool
->      ,p "array[1,2,3]" $ Right (ArrayType typeInt)
->      ,p "array['a','b']" $ Right (ArrayType UnknownType)
->      ,p "array['a'::text,'b']" $ Right (ArrayType (ScalarType "text"))
->      ,p "array['a','b'::text]" $ Right (ArrayType (ScalarType "text"))
->      ,p "array[1,'b']" $ Right (ArrayType typeInt)
->      ,p "array[1,true]" $ Left [NoMatchingOperator "!arrayctor" [ScalarType "int4",ScalarType "bool"]]
->      ]]
-
->   ,Group "some expressions" [ Expressions [
->       p "1=1" $ Right typeBool
->      ,p "1=true" $ Left [NoMatchingOperator "=" [typeInt,typeBool]]
->      ,p "substring('aqbc' from 2 for 2)" $ Right (ScalarType "text")
-
->      ,p "substring(3 from 2 for 2)" $ Left
->                                      [NoMatchingOperator "!substring"
->                                       [ScalarType "int4"
->                                       ,ScalarType "int4"
->                                       ,ScalarType "int4"]]
->      ,p "substring('aqbc' from 2 for true)" $ Left
->                     [NoMatchingOperator "!substring"
->                      [UnknownType
->                      ,ScalarType "int4"
->                      ,ScalarType "bool"]]
-
->      ,p "3 between 2 and 4" $ Right typeBool
->      ,p "3 between true and 4" $ Left
->                                [NoMatchingOperator ">="
->                                 [typeInt
->                                 ,typeBool]]
-
->      ,p "array[1,2,3][2]" $ Right typeInt
->      ,p "array['a','b'][1]" $ Right UnknownType
->      ,p "array['a'::text,'b'][1]" $ Right (ScalarType "text")
-
- >      ,p "array['a','b'][true]" (TypeError ("",0,0)
- >                                   (WrongType
- >                                    typeInt
- >                                    UnknownType))
-
->      ,p "not true" $ Right typeBool
->      ,p "not 1" $ Left
->                  [NoMatchingOperator "!not" [typeInt]]
-
->      ,p "@ 3" $ Right typeInt
->      ,p "@ true" $ Left
->                  [NoMatchingOperator "@" [ScalarType "bool"]]
-
->      ,p "-3" $ Right typeInt
->      ,p "-'a'" $ Left
->                  [NoMatchingOperator "-" [UnknownType]]
-
->      ,p "4-3" $ Right typeInt
-
->      ,p "1 is null" $ Right typeBool
->      ,p "1 is not null" $ Right typeBool
-
->      ,p "1+1" $ Right typeInt
->      ,p "1+1" $ Right typeInt
->      ,p "31*511" $ Right typeInt
->      ,p "5/2" $ Right typeInt
->      ,p "2^10" $ Right typeFloat8
->      ,p "17%5" $ Right typeInt
-
->      ,p "3 and 4" $ Left
->                   [NoMatchingOperator "!and" [typeInt,typeInt]]
-
->      ,p "True and False" $ Right typeBool
->      ,p "false or true" $ Right typeBool
-
->      ,p "lower('TEST')" $ Right (ScalarType "text")
->      ,p "lower(1)" $ Left [NoMatchingOperator "lower" [typeInt]]
->      ]]
-
->   ,Group "special functions" [ Expressions [
->       p "coalesce(null,1,2,null)" $ Right typeInt
->      ,p "coalesce('3',1,2,null)" $ Right typeInt
->      ,p "coalesce('3',1,true,null)"
->             $ Left [NoMatchingOperator "coalesce" [UnknownType
->                                                   ,ScalarType "int4"
->                                                   ,ScalarType "bool"
->                                                   ,UnknownType]]
->      ,p "nullif('hello','hello')" $ Right UnknownType
->      ,p "nullif('hello'::text,'hello')" $ Right (ScalarType "text")
->      ,p "nullif(3,4)" $ Right typeInt
->      ,p "nullif(true,3)"
->             $ Left [NoMatchingOperator "nullif" [ScalarType "bool"
->                                           ,ScalarType "int4"]]
->      ,p "greatest(3,5,6,4,3)" $ Right typeInt
->      ,p "least(3,5,6,4,3)" $ Right typeInt
->      ,p "least(5,true)"
->             $ Left [NoMatchingOperator "least" [ScalarType "int4",ScalarType "bool"]]
-
-
->      ]]
-
-implicit casting and function/operator choice tests:
-check when multiple implicit and one exact match on num args
-check multiple matches with num args, only one with implicit conversions
-check multiple implicit matches with one preferred
-check multiple implicit matches with one preferred highest count
-check casts from unknown string lits
-
->   ,Group "some expressions" [ Expressions [
->       p "3 + '4'" $ Right typeInt
->      ,p "3.0 + '4'" $ Right typeNumeric
->      ,p "'3' + '4'" $ Left [NoMatchingOperator "+" [UnknownType
->                                               ,UnknownType]]
-
->      ]]
-
->   ,Group "exists expressions" [ Expressions [
->       p "exists (select 1 from pg_type)" $ Right typeBool
->      ,p "exists (select testit from pg_type)"
->        $ Left [UnrecognisedIdentifier "testit"]
->      ]]
-
->   ,Group "row comparison expressions" [ Expressions [
-
-rows different lengths
-rows match types pairwise, same and different types
-rows implicit cast from unknown
-rows don't match types
-
->       p "row(1)" $ Right (AnonymousRecordType [typeInt])
->      ,p "row(1,2)" $ Right (AnonymousRecordType [typeInt,typeInt])
->      ,p "row('t1','t2')" $ Right (AnonymousRecordType [UnknownType,UnknownType])
->      ,p "row(true,1,'t3')" $ Right (AnonymousRecordType [typeBool, typeInt,UnknownType])
->      ,p "(true,1,'t3',75.3)" $ Right (AnonymousRecordType [typeBool,typeInt
->                                       ,UnknownType,typeNumeric])
->      ,p "row(1) = row(2)" $ Right typeBool
->      ,p "row(1,2) = row(2,1)" $ Right typeBool
->      ,p "(1,2) = (2,1)" $ Right typeBool
->      ,p "(1,2,3) = (2,1)" $ Left [NoMatchingOperator "="
->                                   [AnonymousRecordType [ScalarType "int4"
->                                                        ,ScalarType "int4"
->                                                        ,ScalarType "int4"]
->                                    ,AnonymousRecordType [ScalarType "int4"
->                                                         ,ScalarType "int4"]]]
->      ,p "('1',2) = (2,'1')" $ Right typeBool
->      ,p "(1,true) = (2,1)" $ Left [NoMatchingOperator "="
->                                    [AnonymousRecordType [ScalarType "int4"
->                                                         ,ScalarType "bool"]
->                                    ,AnonymousRecordType [ScalarType "int4"
->                                                         ,ScalarType "int4"]]]
->      ,p "(1,2) <> (2,1)" $ Right typeBool
->      ,p "(1,2) >= (2,1)" $ Right typeBool
->      ,p "(1,2) <= (2,1)" $ Right typeBool
->      ,p "(1,2) > (2,1)" $ Right typeBool
->      ,p "(1,2) < (2,1)" $ Right typeBool
->      ]]
-
->   ,Group "case expressions" [ Expressions [
->       p "case\n\
->         \ when true then 1\n\
->         \end" $ Right typeInt
->      ,p "case\n\
->         \ when 1=2 then 'stuff'\n\
->         \ when 2=3 then 'blah'\n\
->         \ else 'test'\n\
->         \end" $ Right UnknownType
->      ,p "case\n\
->         \ when 1=2 then 'stuff'\n\
->         \ when 2=3 then 'blah'\n\
->         \ else 'test'::text\n\
->         \end" $ Right $ ScalarType "text"
->      ,p "case\n\
->         \ when 1=2 then 'stuff'\n\
->         \ when true=3 then 'blah'\n\
->         \ else 'test'\n\
->         \end" $ Left [NoMatchingOperator "=" [typeBool,typeInt]]
->      ,p "case\n\
->         \ when 1=2 then true\n\
->         \ when 2=3 then false\n\
->         \ else 1\n\
->         \end" $ Left [IncompatibleTypeSet [typeBool
->                                         ,typeBool
->                                         ,typeInt]]
->      ,p "case\n\
->         \ when 1=2 then false\n\
->         \ when 2=3 then 1\n\
->         \ else true\n\
->         \end" $ Left [IncompatibleTypeSet [typeBool
->                                           ,typeInt
->                                           ,typeBool]]
-
->      ,p "case 1 when 2 then 3 else 4 end" $ Right typeInt
->      ,p "case 1 when true then 3 else 4 end"
->             $ Left [IncompatibleTypeSet [ScalarType "int4"
->                                          ,ScalarType "bool"]]
->      ,p "case 1 when 2 then true else false end" $ Right typeBool
->      ,p "case 1 when 2 then 3 else false end"
->             $ Left [IncompatibleTypeSet [ScalarType "int4"
->                                          ,ScalarType "bool"]]
->      ]]
-
->   ,Group "polymorphic functions" [ Expressions [
->       p "array_append(ARRAY[1,2], 3)"
->         $ Right (ArrayType typeInt)
->      ,p "array_append(ARRAY['a','b'], 'c')"
->         $ Right (ArrayType UnknownType)
->      ,p "array_append(ARRAY['a','b'], 'c'::text)"
->         $ Right (ArrayType $ ScalarType "text")
->      ,p "array_append(ARRAY['a','b'::text], 'c')"
->         $ Right (ArrayType $ ScalarType "text")
->      ,p "array_append(ARRAY['a'::int,'b'], 'c')"
->         $ Right (ArrayType typeInt)
->      ]]
-
->   ,Group "cast expressions" [ Expressions [
->       p "cast ('1' as integer)"
->         $ Right typeInt
->      ,p "cast ('1' as baz)"
->         $ Left [UnknownTypeName "baz"]
->      ,p "array[]" -- this isn't quite right but not sure how to do it atm
->                   -- no point fixing this case since need a load of other
->                   -- test cases where the behaviour is different
->         $ Right (Pseudo AnyArray) -- Left [TypelessEmptyArray]
->      ,p "array[] :: text[]"
->         $ Right (ArrayType (ScalarType "text"))
->      ]]
-
->   ,Group "simple selects" [ StatementTypes [
->       p "select 1;" $ Right [Just $ StatementType [] [("?column?", typeInt)]]
->      ,p "select 1 as a;" $
->         Right [Just $ StatementType [] [("a", typeInt)]]
->      ,p "select 1,2;" $
->         Right [Just $ StatementType [] [("?column?", typeInt)
->                                                 ,("?column?", typeInt)]]
->      ,p "select 1 as a, 2 as b;" $
->         Right [Just $ StatementType [] [("a", typeInt)
->                                                 ,("b", typeInt)]]
->      ,p "select 1+2 as a, 'a' || 'b';" $
->         Right [Just $ StatementType [] [("a", typeInt)
->                                        ,("?column?", ScalarType "text")]]
->      ,p "values (1,2);" $ Right [Just $ StatementType []
->                                           [("column1", typeInt)
->                                           ,("column2", typeInt)]]
->      ,p "values (1,2),('3', '4');" $ Right [Just $ StatementType []
->                                                      [("column1", typeInt)
->                                                      ,("column2", typeInt)]]
->      ,p "values (1,2),('a', true);" $ Left [IncompatibleTypeSet [typeInt
->                                                                 ,typeBool]]
->      ,p "values ('3', '4'),(1,2);" $ Right [Just $ StatementType []
->                                                      [("column1", typeInt)
->                                                      ,("column2", typeInt)]]
->      ,p "values ('a', true),(1,2);" $ Left [IncompatibleTypeSet [typeBool
->                                                                 ,typeInt]]
->      ,p "values ('a'::text, '2'::int2),('1','2');" $ Right [Just $ StatementType []
->                                      [("column1", ScalarType "text")
->                                      ,("column2", typeSmallInt)]]
->      ,p "values (1,2,3),(1,2);" $ Left [ValuesListsMustBeSameLength]
-
->      ]]
-
->   ,Group "simple combine selects" [ StatementTypes [
->      p "select 1,2  union select '3', '4';" $ Right [Just $ StatementType []
->                                      [("?column?", typeInt)
->                                      ,("?column?", typeInt)]]
->      ,p "select 1,2 intersect select 'a', true;" $ Left [IncompatibleTypeSet [typeInt
->                                                         ,typeBool]]
->      ,p "select '3', '4' except select 1,2;" $ Right [Just $ StatementType []
->                                      [("?column?", typeInt)
->                                      ,("?column?", typeInt)]]
->      ,p "select 'a', true union select 1,2;"
->                                      $ Left [IncompatibleTypeSet [typeBool
->                                                         ,typeInt]]
->      ,p "select 'a'::text, '2'::int2 intersect select '1','2';" $ Right [Just $ StatementType []
->                                      [("text", ScalarType "text")
->                                      ,("int2", typeSmallInt)]]
->      ,p "select 1,2,3 except select 1,2;" $ Left [ValuesListsMustBeSameLength]
->      ,p "select '3' as a, '4' as b except select 1,2;" $ Right [Just $ StatementType []
->                                      [("a", typeInt)
->                                      ,("b", typeInt)]]
-
->      ]]
-
->   ,Group "simple selects from" [ StatementTypes [
->       p "select a from (select 1 as a, 2 as b) x;"
->         $ Right [Just $ StatementType [] [("a", typeInt)]]
->      ,p "select b from (select 1 as a, 2 as b) x;"
->         $ Right [Just $ StatementType [] [("b", typeInt)]]
->      ,p "select c from (select 1 as a, 2 as b) x;"
->         $ Left [UnrecognisedIdentifier "c"]
->      ,p "select typlen from pg_type;"
->         $ Right [Just $ StatementType [] [("typlen", typeSmallInt)]]
->      ,p "select oid from pg_type;"
->         $ Right [Just $ StatementType [] [("oid", ScalarType "oid")]]
->      ,p "select p.oid from pg_type p;"
->         $ Right [Just $ StatementType [] [("oid", ScalarType "oid")]]
->      ,p "select typlen from nope;"
->         $ Left [UnrecognisedIdentifier "typlen",UnrecognisedRelation "nope"]
->      ,p "select generate_series from generate_series(1,7);"
->         $ Right [Just $ StatementType [] [("generate_series", typeInt)]]
-
-check aliasing
-
->      ,p "select generate_series.generate_series from generate_series(1,7);"
->         $ Right [Just $ StatementType [] [("generate_series", typeInt)]]
->      ,p "select g from generate_series(1,7) g;"
->         $ Right [Just $ StatementType [] [("g", typeInt)]]
->      ,p "select g.g from generate_series(1,7) g;"
->         $ Right [Just $ StatementType [] [("g", typeInt)]]
->      ,p "select generate_series.g from generate_series(1,7) g;"
->         $ Left [UnrecognisedCorrelationName "generate_series"]
->      ,p "select g.generate_series from generate_series(1,7) g;"
->         $ Left [UnrecognisedIdentifier "g.generate_series"]
-
-
->      ,p "select * from pg_attrdef;"
->         $ Right [Just $ StatementType []
->          [("adrelid",ScalarType "oid")
->          ,("adnum",ScalarType "int2")
->          ,("adbin",ScalarType "text")
->          ,("adsrc",ScalarType "text")]]
->      ,p "select abs from abs(3);"
->         $ Right [Just $ StatementType [] [("abs", typeInt)]]
->         --todo: these are both valid,
->         --the second one means select 3+generate_series from generate_series(1,7)
->         --  select generate_series(1,7);
->         -- select 3 + generate_series(1,7);
-
->      ]]
-
->   ,Group "simple selects from 2" [ CatUpStatementTypes [
->       t "select a,b from testfunc();"
->         [CatCreateComposite "testType" [("a", ScalarType "text")
->                                        ,("b", typeInt)
->                                        ,("c", typeInt)]
->         ,CatCreateFunction FunName "testfunc" []
->          (SetOfType $ NamedCompositeType "testType") False]
->         $ Right [Just $ StatementType []
->                  [("a",ScalarType "text"),("b",ScalarType "int4")]]
-
->      ,t "select testfunc();"
->         [CatCreateFunction FunName "testfunc" [] (Pseudo Void) False]
->         $ Right [Just $ StatementType [] []]
-
->      ]]
-
->   ,Group "simple join selects" [ StatementTypes [
->       p "select * from (select 1 as a, 2 as b) a\n\
->         \  cross join (select true as c, 4.5 as d) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)
->                                           ,("c", typeBool)
->                                           ,("d", typeNumeric)]]
->      ,p "select * from (select 1 as a, 2 as b) a\n\
->         \  inner join (select true as c, 4.5 as d) b on true;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)
->                                           ,("c", typeBool)
->                                           ,("d", typeNumeric)]]
->      ,p "select * from (select 1 as a, 2 as b) a\n\
->         \  inner join (select 1 as a, 4.5 as d) b using(a);"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)
->                                           ,("d", typeNumeric)]]
->      ,p "select * from (select 1 as a, 2 as b) a\n\
->         \ natural inner join (select 1 as a, 4.5 as d) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)
->                                           ,("d", typeNumeric)]]
->         --check the attribute order
->      ,p "select * from (select 2 as b, 1 as a) a\n\
->         \ natural inner join (select 4.5 as d, 1 as a) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)
->                                           ,("d", typeNumeric)]]
->      ,p "select * from (select 1 as a1, 2 as b) a\n\
->         \ natural inner join (select true as a1, 4.5 as d) b;"
->         $ Left [IncompatibleTypeSet [ScalarType "int4"
->                                      ,ScalarType "bool"]]
->      ,p "select * from (select 1 as a1, 2 as b) a\n\
->         \ natural inner join (select true as a1, 4.5 as d) b;"
->         $ Left [IncompatibleTypeSet [ScalarType "int4"
->                                      ,ScalarType "bool"]]
-
->      ,p "select * from (select 1 as a1) a, (select 2 as a2) b;"
->         $ Right [Just $ StatementType [] [("a1", typeInt)
->                                                                ,("a2", typeInt)]]
-
->      ,p "select * from (select 1 as a1) a, (select 2 as a1) b;"
->         $ Right [Just $ StatementType [] [("a1", typeInt)
->                                                                ,("a1", typeInt)]]
-
->      ,p "select a1 from (select 1 as a1) a,  (select 2 as a1) b;"
->         $ Left [AmbiguousIdentifier "a1"]
->      ]]
-
->   ,Group "simple scalar identifier qualification" [ StatementTypes [
->       p "select a.* from \n\
->         \(select 1 as a, 2 as b) a \n\
->         \cross join (select 3 as c, 4 as d) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("b", typeInt)]]
->      ,p "select nothere.* from \n\
->         \(select 1 as a, 2 as b) a \n\
->         \cross join (select 3 as c, 4 as d) b;"
->         $ Left [UnrecognisedCorrelationName "nothere"]
->      ,p "select a.b,b.c from \n\
->         \(select 1 as a, 2 as b) a \n\
->         \natural inner join (select 3 as a, 4 as c) b;"
->         $ Right [Just $ StatementType [] [("b", typeInt)
->                                           ,("c", typeInt)]]
->      ,p "select a.a,b.a from \n\
->         \(select 1 as a, 2 as b) a \n\
->         \natural inner join (select 3 as a, 4 as c) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)
->                                           ,("a", typeInt)]]
-
->      ,p "select pg_attrdef.adsrc from pg_attrdef;"
->         $ Right [Just $ StatementType [] [("adsrc", ScalarType "text")]]
-
->      ,p "select a.adsrc from pg_attrdef a;"
->         $ Right [Just $ StatementType [] [("adsrc", ScalarType "text")]]
-
->      ,p "select pg_attrdef.adsrc from pg_attrdef a;"
->         $ Left [UnrecognisedCorrelationName "pg_attrdef"]
-
->      ,p "select a from (select 2 as b, 1 as a) a\n\
->         \natural inner join (select 4.5 as d, 1 as a) b;"
->         $ Right [Just $ StatementType [] [("a", typeInt)]]
-
-select g.fn from fn() g
-
->      ]]
-
->   ,Group "aggregates" [ StatementTypes [
->        p "select max(prorettype::int) from pg_proc;"
->         $ Right [Just $ StatementType [] [("max", typeInt)]]
->      ]]
-
->   ,Group "simple wheres" [ StatementTypes [
->       p "select 1 from pg_type where true;"
->         $ Right [Just $ StatementType [] [("?column?", typeInt)]]
->      ,p "select 1 from pg_type where 1;"
->         $ Left [ExpressionMustBeBool]
->      ,p "select typname from pg_type where typbyval;"
->         $ Right [Just $ StatementType [] [("typname", ScalarType "name")]]
->      ,p "select typname from pg_type where typtype = 'b';"
->         $ Right [Just $ StatementType [] [("typname", ScalarType "name")]]
->      ,p "select typname from pg_type where what = 'b';"
->         $ Left [UnrecognisedIdentifier "what"]
->      ]]
-
-TODO: check identifier stacking working, then remove the pg_namespace
-qualifier before oid and this should still work
-
->   ,Group "subqueries" [ StatementTypes [
->       p "select relname as relvar_name\n\
->         \    from pg_class\n\
->         \    where ((relnamespace =\n\
->         \           (select oid\n\
->         \              from pg_namespace\n\
->         \              where (nspname = 'public'))) and (relkind = 'r'));"
->         $ Right [Just $ StatementType [] [("relvar_name",ScalarType "name")]]
->      ,p "select relname from pg_class where relkind in ('r', 'v');"
->         $ Right [Just $ StatementType [] [("relname",ScalarType "name")]]
->      ,p "select * from generate_series(1,7) g\n\
->         \where g not in (select * from generate_series(3,5));"
->         $ Right [Just $ StatementType [] [("g",typeInt)]]
->      ,p "select 3 = any(array[1,2,3]);"
->         $ Right [Just $ StatementType [] [("?column?",typeBool)]]
->      ]]
-
-identifiers in select parts
-
->{-    ,testGroup "select part identifiers"
->     (mapStatementTypes [
->       p "select relname,attname from pg_class\n\
->         \inner join pg_attribute\n\
->         \on pg_attribute.attrelid = pg_class.oid;"
->         $ Right [Just $ StatementType [] [("relvar_name",ScalarType "name")]]
->      ])-}
-
->   ,Group "insert" [ StatementTypes [
->       p "insert into nope (a,b) values (c,d);"
->         $ Left [UnrecognisedRelation "nope",UnrecognisedIdentifier "c",UnrecognisedIdentifier "d"]
->      ,p "insert into pg_attrdef (adrelid,adnum,adbin,adsrc)\n\
->         \values (1,2, 'a', 'b');"
->         $ Right [Just $ StatementType [] [] {-InsertInfo "pg_attrdef"
->                           [("adrelid",ScalarType "oid")
->                           ,("adnum",ScalarType "int2")
->                           ,("adbin",ScalarType "text")
->                           ,("adsrc",ScalarType "text")]-}]
->      ,p "insert into pg_attrdef\n\
->         \values (1,2, 'a', 'b');"
->         $ Right [Just $ StatementType [] [] {-InsertInfo "pg_attrdef"
->                           [("adrelid",ScalarType "oid")
->                           ,("adnum",ScalarType "int2")
->                           ,("adbin",ScalarType "text")
->                           ,("adsrc",ScalarType "text")]-}]
->      ,p "insert into pg_attrdef (hello,adnum,adbin,adsrc)\n\
->         \values (1,2, 'a', 'b');"
->         $ Left [UnrecognisedIdentifier "hello"]
->      ,p "insert into pg_attrdef (adrelid,adnum,adbin,adsrc)\n\
->         \values (1,true, 'a', 'b');"
->         $ Left [IncompatibleTypes (ScalarType "int2") (ScalarType "bool")]
->      ,p "insert into pg_attrdef (adrelid,adnum,adbin,adsrc)\n\
->         \values (1,true, 'a', 'b','c');"
->         $ Left [WrongNumberOfColumns]
->      ]]
-
->   ,Group "update" [ StatementTypes [
->       p "update nope set a = 1;"
->         $ Left [UnrecognisedRelation "nope"]
->      ,p "update pg_attrdef set adsrc = '' where 1;"
->         $ Left [ExpressionMustBeBool]
->      ,p "update pg_attrdef set (adbin,adsrc) = ('a','b','c');"
->         $ Left [WrongNumberOfColumns]
->      ,p "update pg_attrdef set (adrelid,adsrc) = (true,'b');"
->         $ Left [IncompatibleTypes (ScalarType "oid") typeBool]
->      ,p "update pg_attrdef set (shmadrelid,adsrc) = ('a','b');"
->         $ Left [UnrecognisedIdentifier "shmadrelid"]
->      ,p "update pg_attrdef set adsrc='';"
->         $ Right [Just $ StatementType [] [] {-UpdateInfo "pg_attrdef" [("adsrc",ScalarType "text")]-}]
->      ,p "update pg_attrdef set adsrc='' where 1=2;"
->         $ Right [Just $ StatementType [] [] {-UpdateInfo "pg_attrdef" [("adsrc",ScalarType "text")]-}]
->       -- TODO: actually, pg doesn't support this so need to generate error instead
->      ,p "update pg_attrdef set (adbin,adsrc) = ((select 'a','b'));"
->         $ Right [Just $ StatementType [] [] {-UpdateInfo "pg_attrdef" [("adbin",ScalarType "text"),("adsrc",ScalarType "text")]-}]
->      --check where ids
->      ,p "update pg_attrdef set adsrc='' where adsrc='';"
->         $ Right [Just $ StatementType [] [] {-UpdateInfo "pg_attrdef" [("adsrc",ScalarType "text")]-}]
->      ,p "update pg_attrdef set adnum = adnum + 1;"
->         $ Right [Just $ StatementType [] [] {-UpdateInfo "pg_attrdef" [("adnum",ScalarType "int2")]-}]
->      ]]
-
->   ,Group "delete" [ StatementTypes [
->       p "delete from nope;"
->         $ Left [UnrecognisedRelation "nope"]
->      ,p "delete from pg_attrdef where 1=2;"
->         $ Right [Just $ StatementType [] []]
->      ,p "delete from pg_attrdef where 1;"
->         $ Left [ExpressionMustBeBool]
->      ,p "delete from pg_attrdef where adsrc='';"
->         $ Right [Just $ StatementType [] []]
->      ]]
-
-================================================================================
-
-test the catalog updates from creates, etc.
-
->   ,Group "creates" [DdlStatements [
->       p "create table t1 (\n\
->         \   a int,\n\
->         \   b text\n\
->         \);"
->         [[CatCreateTable "t1" [("a",ScalarType "int4")
->                               ,("b",ScalarType "text")]
->                               [("tableoid", ScalarType "oid")
->                               ,("cmax", ScalarType "cid")
->                               ,("xmax", ScalarType "xid")
->                               ,("cmin", ScalarType "cid")
->                               ,("xmin", ScalarType "xid")
->                               ,("ctid", ScalarType "tid")]]]
->      ,p "create type t1 as (\n\
->         \   a int,\n\
->         \   b text\n\
->         \);"
->         [[CatCreateComposite "t1" [("a",ScalarType "int4")
->                                   ,("b",ScalarType "text")]]]
-
->      ,p "create domain t1 as text;"
->         [[CatCreateDomain (DomainType "t1") (ScalarType "text")]]
-
->      ,p "create domain t1 as text check (value in ('a', 'b'));\n\
->         \select 'text'::t1;"
->         [[CatCreateDomain (DomainType "t1") (ScalarType "text")]]
-
-
->      ,p "create view v1 as select * from pg_attrdef;"
->         [[CatCreateView "v1" [("adrelid",ScalarType "oid")
->                              ,("adnum",ScalarType "int2")
->                              ,("adbin",ScalarType "text")
->                              ,("adsrc",ScalarType "text")]]]
-
->      ,p "create function t1(text) returns text as $$\n\
->         \null;\n\
->         \$$ language sql stable;"
->         [[CatCreateFunction FunName "t1" [ScalarType "text"]
->                             (ScalarType "text") False]]
->      ,p "create language plpgsql;"
->         [[CatCreateFunction FunName "plpgsql_call_handler" [] (Pseudo LanguageHandler) False
->          ,CatCreateFunction FunName "plpgsql_validator" [ScalarType "oid"] (Pseudo Void) False]]
->      ]]
-
-
-================================================================================
-
-check the identifier resolution for functions:
-parameters
-variable declarations
-select expressions inside these:
-refer to param
-refer to variable
-override var with var
-override var with select iden
-todo: override var with param, override select iden with param
-
-check var defs:
-check type exists
-check type of initial values
-
->   ,Group "create function identifier resolution" [ StatementTypes [
->       p "create function t1(stuff text) returns text as $$\n\
->         \begin\n\
->         \  return stuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
->      ,p "create function t1(stuff text) returns text as $$\n\
->         \begin\n\
->         \  return badstuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Left [UnrecognisedIdentifier "badstuff"])
->      ,p "create function t1() returns text as $$\n\
->         \declare\n\
->         \  stuff text;\n\
->         \begin\n\
->         \  return stuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
->      ]]
-
-================================================================================
-
->   ,Group "plpgsqlbits" [ StatementTypes [
->       p "create function t1(stuff text) returns text as $$\n\
->         \begin\n\
->         \  return stuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
->      ,p "create function t1(stuff text) returns text as $$\n\
->         \begin\n\
->         \  return badstuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Left [UnrecognisedIdentifier "badstuff"])
->      ,p "create function t1() returns text as $$\n\
->         \declare\n\
->         \  stuff text;\n\
->         \begin\n\
->         \  return stuff || ' and stuff';\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
->      ]]
-
-================================================================================
-
->   ,Group "plpgsqlbits" [ StatementTypes [
->       p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a bool;\n\
->         \begin\n\
->         \  a := 3;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Left [IncompatibleTypes (ScalarType "bool") (ScalarType "int4")])
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a boolean;\n\
->         \begin\n\
->         \  a := true;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
->      ]]
-
-================================================================================
-
->   ,Group "for loops" [ StatementTypes [
->       p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r record;\n\
->         \  t int;\n\
->         \begin\n\
->         \  for r in select * from pg_attrdef loop\n\
->         \    t := r.adnum;\n\
->         \  end loop;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
-
-
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r record;\n\
->         \  t int;\n\
->         \begin\n\
->         \  for r in select adnum from pg_attrdef loop\n\
->         \    t := r;\n\
->         \  end loop;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Right [Nothing])
-
-loop var already declared
-
->      ,p "create function test() returns void as $$\n\
->         \declare\n\
->         \  i int;\n\
->         \  i1 int;\n\
->         \begin\n\
->         \  for i in 0 .. 10 loop\n\
->         \    i1 := i;\n\
->         \  end loop;\n\
->         \end;\n\
->         \$$ language plpgsql volatile;"
->        (Right [Nothing])
-
-implicitly created loop var
-
->      ,p "create function test() returns void as $$\n\
->         \declare\n\
->         \  i1 int;\n\
->         \begin\n\
->         \  for i in 0 .. 10 loop\n\
->         \    i1 := i;\n\
->         \  end loop;\n\
->         \end;\n\
->         \$$ language plpgsql volatile;"
->        (Right [Nothing])
-
-loop var already declared, wrong type
-
->      ,p "create function test() returns void as $$\n\
->         \declare\n\
->         \  i bool;\n\
->         \begin\n\
->         \  for i in 0 .. 10 loop\n\
->         \    null;\n\
->         \  end loop;\n\
->         \end;\n\
->         \$$ language plpgsql volatile;"
->        (Left [IncompatibleTypes (ScalarType "bool") (ScalarType "int4")])
-
-loop var implicit check it's type
-
->      ,p "create function test() returns void as $$\n\
->         \declare\n\
->         \  t bool;\n\
->         \begin\n\
->         \  for i in 0 .. 10 loop\n\
->         \    t := i;\n\
->         \  end loop;\n\
->         \end;\n\
->         \       $$ language plpgsql volatile;"
->         (Left [IncompatibleTypes (ScalarType "bool") (ScalarType "int4")])
->      ]]
-
-================================================================================
-
->   ,Group "check catalog chaining" [ StatementTypes [
-
-create function then select
-select then create function
-then in two separate chained asts
-
->       p "create function t1() returns void as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql stable;\n\
->         \select t1();"
->         (Right [Nothing])
->      ,p "select t1();\n\
->         \create function t1() returns void as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         (Left [NoMatchingOperator "t1" []])
->      ]]
-
->   {-,Group "check catalog chaining2" [ StatementTypes [
->       p ["create function t1() returns void as $$\n\
->          \begin\n\
->          \  null;\n\
->          \end;\n\
->          \$$ language plpgsql stable;"
->         ,"select t1();"]
->         (Right [Just (SelectInfo (Pseudo Void))])
->      ,p ["select t1();"
->         ,"create function t1() returns void as $$\n\
->          \begin\n\
->          \  null;\n\
->          \end;\n\
->          \$$ language plpgsql stable;"]
->         (Left [NoMatchingOperator "t1" []])
->      ]]-}
-
-================================================================================
-
-test some casts
-assign composite to record
-  then assign record to composite
-assign row to composite
- : check wrong cols, wrong types
-check read and write fields in composite->record
-check read and write fields in composite
-check domain <-> base assigns
-check call function with compatible composite, compatible row ctor
-assign comp to comp
-
-todo for chaos sql
-for loop var = scalar, select = setof composite with one scalar
-
-select into
-composite assignment and equality
-autocast from rowctor to composite when calling function
-assignment to composite fields
-read fields of composite
-
-array_contains -> match anyelement
-createtable as cat update
-window functions
-assign domain <-> base
-sql function not working
-
-================================================================================
-
-check insert returning, update returning, delete returning, one check each
-check select into: multiple vars, record (then access fields to check),
-  composite var
-check errors: select into wrong number of vars, wrong types, and into
-  composite wrong number and wrong type
-
->   ,Group "select into" [ StatementTypes [
->       p "insert into pg_attrdef (adrelid,adnum,adbin,adsrc)\n\
->         \values (1,2, 'a', 'b') returning adnum,adbin;"
->         $ Right [Just $ StatementType [] [("adnum", ScalarType "int2")
->                                          ,("adbin", ScalarType "text")]]
->      ,p "update pg_attrdef set adnum = adnum + 1 returning adnum;"
->         $ Right [Just $ StatementType [] [("adnum", ScalarType "int2")]]
->      ,p "delete from pg_attrdef returning adnum,adbin;"
->         $ Right [Just $ StatementType [] [("adnum", ScalarType "int2")
->                                          ,("adbin", ScalarType "text")]]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into a,b from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Right [Nothing]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into b,a from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Left [IncompatibleTypes (ScalarType "text") (ScalarType "int2")
->                ,IncompatibleTypes (ScalarType "int4") (ScalarType "text")]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into a,c from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Left [UnrecognisedIdentifier "c"]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into a from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Left [WrongNumberOfColumns]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r record;\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into r from pg_attrdef;\n\
->         \  a := r.adnum;\n\
->         \  b := r.adbin;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Right [Nothing]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r record;\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  select adnum,adbin into r from pg_attrdef;\n\
->         \  a := r.adnum;\n\
->         \  b := r.adsrc;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Left [UnrecognisedIdentifier "r.adsrc"]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r pg_attrdef;\n\
->         \begin\n\
->         \  select * into r from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Right [Nothing]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r pg_class;\n\
->         \begin\n\
->         \  select adnum,adbin into r from pg_attrdef;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Left [IncompatibleTypes (NamedCompositeType "pg_class") (AnonymousRecordType [ScalarType "int2",ScalarType "text"])]
->      ,p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r record;\n\
->         \begin\n\
->         \  select adnum,adbin into r from pg_attrdef;\n\
->         \  select relname into r from pg_class;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Right [Nothing]
->      ]]
-
->   ,Group "composite elements" [ StatementTypes [
->       p "create function t1() returns void as $$\n\
->         \declare\n\
->         \  r pg_attrdef;\n\
->         \  a int;\n\
->         \  b text;\n\
->         \begin\n\
->         \  b = r.adsrc;\n\
->         \  r.adnum := a;\n\
->         \  b = r.adsrc;\n\
->         \end;\n\
->         \$$ language plpgsql stable;"
->         $ Right [Nothing]
->      ]]
-
->   ,Group "positional args" [ StatementTypes [
->       p "create function distance(int, int, int, int) returns float(24) as $$\n\
->         \  select (point($1, $2) <-> point($3, $4))::float(24) as result;\n\
->         \$$ language sql immutable;"
->         $ Right [Nothing]
->      ,p "create function distance(int, int, int, int) returns float(24) as $$\n\
->         \  select (point($1, $2) <-> point($3, $5))::float(24) as result;\n\
->         \$$ language sql immutable;"
->         $ Left [UnrecognisedIdentifier "$5"]
->      ]]
-
->   ,Group "window fns" [ StatementTypes [
->       p "select *, row_number() over () from pg_attrdef;"
->         $ Right [Just $ StatementType []
->                   [("adrelid",ScalarType "oid")
->                   ,("adnum",ScalarType "int2")
->                   ,("adbin",ScalarType "text")
->                   ,("adsrc",ScalarType "text")
->                   ,("row_number",ScalarType "int8")]]
->      ]]
-
->   ,Group "drop stuff" [ DdlStatementsCat [
->       p "create function test(a int) returns void as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end\n\
->         \$$ language plpgsql;"
->         [CatCreateFunction FunName "test" [typeInt] (Pseudo Void) False]
->      ,p "create function test(a int) returns void as $$\n\
->         \begin\n\
->         \  null;\n\
->         \end\n\
->         \$$ language plpgsql;\n\
->         \drop function test(int);"
->         []
->      ,p "drop function test(int);" -- this should fail but doesn't
->         []
->      ,p "drop function if exists test(int);"
->         []
->      ]]
->   ]
-
-================================================================================
-
-> p :: t -> t1 -> (t, t1)
-> p a b = (a,b)
-
-> t :: t -> u -> v -> (t,u,v)
-> t a b c = (a,b,c)
-
-
-> testExpressionType :: String -> Either [TypeError] Type -> Test.Framework.Test
-> testExpressionType src typ = testCase ("typecheck " ++ src) $
->   let ast = case parseExpression "" src of
->                                      Left e -> error $ show e
->                                      Right l -> l
->       aast = typeCheckExpression defaultTemplate1Catalog ast
->       ty = getTopLevelTypes [aast]
->       er = concatMap snd $ getTypeErrors aast
->   in case (length er, length ty) of
->        (0,0) -> assertFailure "didn't get any types?"
->        (0,1) -> assertEqual ("typecheck " ++ src) typ $ Right $ head ty
->        (0,_) -> assertFailure "got too many types"
->        _ -> assertEqual ("typecheck " ++ src) typ $ Left er
-
-> testStatementType :: String -> Either [TypeError] [Maybe StatementType] -> Test.Framework.Test
-> testStatementType src sis = testCase ("typecheck " ++ src) $
->   let ast = case parseSql "" src of
->                               Left e -> error $ show e
->                               Right l -> l
->       aast = snd $ typeCheck defaultTemplate1Catalog ast
->       is = getTopLevelInfos aast
->       er = concatMap snd $ getTypeErrors aast
->   in {-trace (show aast) $-} case (length er, length is) of
->        (0,0) -> assertFailure "didn't get any infos?"
->        (0,_) -> assertEqual ("typecheck " ++ src) sis $ Right is
->        _ -> assertEqual ("typecheck " ++ src) sis $ Left er
-
-
-> testCatUpStatementType :: String
->                        -> [CatalogUpdate]
->                        -> Either [TypeError] [Maybe StatementType]
->                        -> Test.Framework.Test
-> testCatUpStatementType src eu sis = testCase ("typecheck " ++ src) $
->   let ast = case parseSql "" src of
->                               Left e -> error $ show e
->                               Right l -> l
->       aast = snd $ typeCheck makeCat ast
->       is = getTopLevelInfos aast
->       er = concatMap snd $ getTypeErrors aast
->   in {-trace (show aast) $-} case (length er, length is) of
->        (0,0) -> assertFailure "didn't get any infos?"
->        (0,_) -> assertEqual ("typecheck " ++ src) sis $ Right is
->        _ -> assertEqual ("typecheck " ++ src) sis $ Left er
->   where
->     makeCat = case updateCatalog defaultTemplate1Catalog eu of
->                         Left x -> error $ show x
->                         Right e -> e
-
-> testCatUp :: String -> [[CatalogUpdate]] -> Test.Framework.Test
-> testCatUp src eu = testCase ("typecheck " ++ src) $
->   let ast = case parseSql "" src of
->                               Left e -> error $ show e
->                               Right l -> l
->       aast = snd $ typeCheck defaultTemplate1Catalog ast
->       er = concatMap snd $ getTypeErrors aast
->       eu' = getTopLevelCatUpdates aast
->   in {-trace (show aast) $-} case (length er, length eu') of
->        (0,0) -> assertFailure "didn't get any infos or catupdates?"
->        (0,_) -> assertEqual ("eu " ++ src) eu eu'
->        (_,_) -> assertFailure $ show er
-
-
-> testCat :: String -> [CatalogUpdate] -> Test.Framework.Test
-> testCat src eu = testCase ("check catalog: " ++ src) $
->   let ast = case parseSql "" src of
->                               Left e -> error $ show e
->                               Right l -> l
->       (ncat,aast) = typeCheck defaultTemplate1Catalog ast
->       er = concatMap snd $ getTypeErrors aast
->       neu = deconstructCatalog ncat \\ deconstructCatalog defaultTemplate1Catalog
->   in if not (null er)
->        then assertFailure $ show er
->        else assertEqual "check eus" eu neu
-
-
-> itemToTft :: Item -> [Test.Framework.Test]
-> itemToTft (Expressions es) = map (uncurry testExpressionType) es
-> itemToTft (StatementTypes es) = map (uncurry testStatementType) es
-> itemToTft (CatUpStatementTypes es) = map (\(s,eu,si) -> testCatUpStatementType s eu si) es
-> itemToTft (DdlStatements es) = map (uncurry testCatUp) es
-> itemToTft (DdlStatementsCat es) = map (uncurry testCat) es
-
-> itemToTft (Group s is) = [testGroup s $ concatMap itemToTft is]
diff --git a/Database/HsSqlPpp/Utils.lhs b/Database/HsSqlPpp/Utils.lhs
deleted file mode 100644
--- a/Database/HsSqlPpp/Utils.lhs
+++ /dev/null
@@ -1,109 +0,0 @@
-Copyright 2009 Jake Wheat
-
-This file contains some generic utility stuff
-
-> {-# OPTIONS_HADDOCK hide #-}
-> {-# LANGUAGE FlexibleContexts #-}
-
-
-> module Database.HsSqlPpp.Utils where
-
-> import Data.List
-> import Data.Either
-> import Control.Arrow
-> import Control.Monad.Error
-> import Control.Applicative
-
-
-> errorWhen :: (Error a) => Bool -> a -> Either a ()
-> errorWhen cond = when cond . Left
-
-> returnWhen :: (Monad m) => Bool -> a -> m a -> m a
-> returnWhen c t t1 = if c then return t else t1
-
-> liftME :: a -> Maybe b -> Either a b
-> liftME d m = case m of
->                Nothing -> Left d
->                Just b -> Right b
-
-> both :: (a->b) -> (a,a) -> (b,b)
-> both fn = fn *** fn
-
-> (<:>) :: (Applicative f) =>
->          f a -> f [a] -> f [a]
-> (<:>) a b = (:) <$> a <*> b
-
-> eitherToMaybe :: Either a b -> Maybe b
-> eitherToMaybe (Left _) = Nothing
-> eitherToMaybe (Right b) = Just b
-
-> fromRight :: b -> Either a b -> b
-> fromRight b (Left _) = b
-> fromRight _ (Right r) = r
-
-> fromLeft :: a -> Either a b -> a
-> fromLeft _ (Left l) = l
-> fromLeft a (Right _) = a
-
-> mapEither :: (a->c) -> (b->d) -> Either a b -> Either c d
-> mapEither l _ (Left a) = Left $ l a
-> mapEither _ r (Right b) = Right $ r b
-
-> mapRight :: (b -> c) -> Either a b -> Either a c
-> mapRight = mapEither id
-
-> mapLeft :: (a -> c) -> Either a b -> Either c b
-> mapLeft l = mapEither l id
-
-> isRight :: Either a b -> Bool
-> isRight (Right _) = True
-> isRight (Left _) = False
-
-> leftToEmpty :: (r -> [a]) -> Either l r -> [a]
-> leftToEmpty = either (const [])
-
-> replace :: (Eq a) => [a] -> [a] -> [a] -> [a]
-> replace _ _ [] = []
-> replace old new xs@(y:ys) =
->   case stripPrefix old xs of
->     Nothing -> y : replace old new ys
->     Just ys' -> new ++ replace old new ys'
-
-
-> split :: Char -> String -> [String]
-> split _ ""                =  []
-> split c s                 =  let (l, s') = break (== c) s
->                            in  l : case s' of
->                                            [] -> []
->                                            (_:s'') -> split c s''
-
-> liftThrows :: (MonadError t m) => Either t a -> m a
-> liftThrows (Left err) = throwError err
-> liftThrows (Right val) = return val
-
-run in errort monad, throw error as io error
-
-> wrapET :: (Show e, Monad m) => ErrorT e m a -> m a
-> wrapET c = runErrorT c >>= \x ->
->          case x of
->            Left er -> error $ show er
->            Right l -> return l
-
-error utility - convert either to ErrorT String
-
-> tsl :: (MonadError String m, Show t) => Either t a -> m a
-> tsl x = case x of
->                Left s -> throwError $ show s
->                Right b -> return b
-
-
-> listEither :: [Either a b] -> Either [a] [b]
-> listEither es = let (l,r) = partitionEithers es
->                in if null l
->                   then Right r
->                   else Left l
-
-
-> forceRight :: Show e => Either e a -> a
-> forceRight (Left x) = error $ show x
-> forceRight (Right x) = x
diff --git a/HsSqlSystem.lhs b/HsSqlSystem.lhs
deleted file mode 100644
--- a/HsSqlSystem.lhs
+++ /dev/null
@@ -1,681 +0,0 @@
-#! /usr/bin/env runghc
-
-Copyright 2009 Jake Wheat
-
-Command line access to a bunch of utility functions.
-
-run
-./HsSqlSystem.lhs -?
-to get a list of commands and purpose and usage info
-
-Uses cmdargs to do command line processing and despatch.
-
-The code is a bit messy at the moment, still working out how to use
-ErrorT.
-
-> {-# LANGUAGE DeriveDataTypeable, ScopedTypeVariables,FlexibleContexts #-}
-
-> import System.Console.CmdArgs
-> import System.IO
-> import System.Directory
-> import Control.Monad.Error
-
-> import Text.Show.Pretty
-> import Test.Framework (defaultMainWithArgs)
-
-> import Data.List
-
-> import Database.HsSqlPpp.Tests.ParserTests
-> import Database.HsSqlPpp.Tests.TypeCheckTests
-> import Database.HsSqlPpp.Tests.ExtensionTests
-> import Database.HsSqlPpp.Tests.ParameterizedStatementTests
-> import Database.HsSqlPpp.Tests.RoundtripTests
-> import Database.HsSqlPpp.Tests.LocalBindingsTests
-
-> import Database.HsSqlPpp.Utils
-
-> import Database.HsSqlPpp.Ast.Ast
-> import Database.HsSqlPpp.Ast.Catalog
-> import qualified Database.HsSqlPpp.Ast.TypeChecker as A
-> import Database.HsSqlPpp.Ast.Annotation
-> import Database.HsSqlPpp.Ast.SqlTypes
-
-> import qualified Database.HsSqlPpp.Parsing.Parser as P
-> import Database.HsSqlPpp.Parsing.Lexer
-
-
-> import Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
-> import Database.HsSqlPpp.PrettyPrinter.AnnotateSource
-
-> import Database.HsSqlPpp.Dbms.DatabaseLoader
-> import Database.HsSqlPpp.Dbms.WrapperGen
-> import Database.HsSqlPpp.Dbms.DBUtils
-
-> import Database.HsSqlPpp.Extensions.ChaosExtensions
-
-===============================================================================
-
-> lexA = mode Lex {files = def &= typ "FILES" & args}
->        &= text "lex the files given and output the tokens on separate lines"
-
-> lexFiles :: [FilePath] -> IO ()
-> lexFiles fns = wrapET $
->                forM_ fns (\f ->
->                     (liftIO . putStrLn) ("lexing " ++ f) >>
->                     readInput f >>= tsl . lexSqlText f >>= mapM_ (liftIO . print))
-
-================================================================================
-
-> parseA = mode $ Parse {files = def &= typ "FILES" & args}
->          &= text "Parse files and output the asts"
-
-> showAst :: [String] -> IO ()
-> showAst = wrapET . mapM_ (\f ->
->                (liftIO . putStrLn) ("-- ast of " ++ f) >>
->                readInput f >>= tsl . P.parseSql f >>=
->                return . stripAnnotations >>= return . ppShow >>= liftIO . putStrLn)
-
-================================================================================
-
-> ppppA = mode $ Pppp {files = def &= typ "FILES" & args}
->         &= text "Routine to parse sql from a file, pretty print it then parse it \
->                 \again and check the post pretty printing ast is the same as the \
->                 \initial ast"
-
-> testPppp :: [String] -> IO ()
-> testPppp = wrapET . mapM_ (\f -> do
->             ast1 <- readInput f >>= tsl . P.parseSql f >>= return . stripAnnotations
->             ast2 <- (return . printSql) ast1 >>= tsl . P.parseSql "" >>= return . stripAnnotations
->             if ast1 /= ast2
->                then liftIO $ do
->                       putStrLn "asts are different\n-- original"
->                       putStrLn $ ppShow ast1
->                       putStrLn "-- ppp'd"
->                       putStrLn $ ppShow ast2
->                else (liftIO . putStrLn) "success")
-
-================================================================================
-
-> pppA = mode $ Ppp {files = def &= typ "FILES" & args}
->        &= text "Parse then pretty print some sql so you can check the result \
->               \hasn't mangled the sql."
-
-> ppp :: String -> IO()
-> ppp f = wrapET $ (liftIO . putStrLn) ("--ppp " ++ f) >>
->         readInput f >>= tsl . P.parseSql f >>= return . printSql >>= liftIO . putStrLn
-
-================================================================================
-
-> parseExpressionA = mode $ ParseExpression {files = def &= typ "FILES" & args}
->                    &= text "Parse files each containing one expression \
->                            \and output the asts"
-
-> parseExpression :: [String] -> IO ()
-> parseExpression = wrapET . mapM_ (\f ->
->                (liftIO . putStrLn) ("-- ast of " ++ f) >>
->                readInput f >>= tsl . P.parseExpression f
->                >>= return . stripAnnotations
->                >>= return . ppShow >>= liftIO . putStrLn)
-
-================================================================================
-
-> annotateSourceA = mode $ AnnotateSource {database = def
->                                         ,file = def &= typ "FILE"}
->                   &= text "reads a file, parses, type checks, then outputs info on \
->                           \each statement interspersed with the original source code"
-
-> annotateSourceF :: String -> FilePath -> IO ()
-> annotateSourceF db f =
->   wrapET $ do
->     (liftIO . putStrLn) ("--annotated source of " ++ f)
->     src <- readInput f
->     cat <- liftIO (readCatalog db) >>= tsl
->     tsl (P.parseSql f src) >>= return . A.typeCheck cat >>= return . snd >>=
->       return . annotateSource False src >>= liftIO . putStrLn
-
-================================================================================
-
-> ppCatalogA = mode $ PPCatalog {database = def
->                               ,files = def &= typ "FILES" & args}
->              &= text "reads each file, parses, type checks, then outputs the \
->                      \changes to the catalog that the sql makes"
-
-> ppCatalog :: String -> [FilePath] -> IO ()
-> ppCatalog db fns = wrapET $ do
->   scat <- liftIO (readCatalog db) >>= tsl
->   (ncat, _) <- mapM (\f -> readInput f >>=
->                            tsl . P.parseSql f) fns >>=
->                  return . concat >>= return . A.typeCheck scat
->   return (ppCatDiff $ compareCatalogs scat emptyCatalog ncat) >>= liftIO . putStrLn
-
-================================================================================
-
-> typeCheckA = mode $ TypeCheck {database = def
->                               ,files = def &= typ "FILES" & args}
->              &= text "reads each file, parses, type checks, then outputs any type errors"
-
-
-> typeCheck2 :: String -> [FilePath] -> IO ()
-> typeCheck2 db fns = wrapET $
->   liftIO (readCatalog db) >>= tsl >>= \cat ->
->   mapM (\f -> readInput f >>= tsl . P.parseSql f) fns >>= return . concat >>=
->   return . A.typeCheck cat >>= return . snd >>= return . A.getTypeErrors >>= return . ppTypeErrors >>= mapM_ (liftIO . putStrLn)
-
-================================================================================
-
-> allAnnotationsA = mode $ AllAnnotations {database = def
->                                        ,files = def &= typ "FILES" & args}
->                   &= text "reads each file, parses, type checks, then pretty prints the \
->                           \ast with all annotations except the source positions"
-
-> allAnnotations :: String -> [FilePath] -> IO ()
-> allAnnotations db fns = wrapET $
->   liftIO (readCatalog db) >>= tsl >>= \cat ->
->   mapM (\f -> readInput f >>= tsl . P.parseSql f) fns >>= return . concat >>=
->   return . A.typeCheck cat >>= return . snd >>= return . ppShow >>= liftIO . putStrLn
-
-
-================================================================================
-
-> typeCheckExpressionA = mode $ TypeCheckExpression {database = def
->                               ,files = def &= typ "FILES" & args}
->      &= text "reads each file, parses as expression, \
->              \ type checks, then outputs the type or any type errors"
-
-
-> typeCheckExpression :: String -> [FilePath] -> IO ()
-> typeCheckExpression db fns = wrapET $ do
->   aasts <- liftIO (readCatalog db) >>= tsl >>= \cat ->
->               forM fns (\f -> readInput f >>= tsl . P.parseExpression f
->                                    >>= return . A.typeCheckExpression cat)
->   tes <- mapM (return . A.getTypeErrors) aasts
->   mapM_ (\x -> return (ppTypeErrors x) >>= mapM_ (liftIO . putStrLn)) $ filter (not . null) tes
->   mapM_ (\a -> liftM (show . head) (return $ A.getTopLevelTypes [a]) >>= liftIO . putStrLn) aasts
-
-================================================================================
-
-= small hack utility to help with testing
-
-TODO: use the correct username in this command
-TODO: do something more correct
-
-> clearA = mode $ Clear {database = def}
->          &= text "hacky util to clear a database"
-
-> cleardb :: String -> IO ()
-> cleardb = clearDB
-
-================================================================================
-
-= load sql file
-
-> loadA = mode $ Load {database = def
->                     ,files = def &= typ "FILES" & args}
->         &= text "This takes one or more files with sql source text, \
->            \parses them then loads them into the database given."
-
-> loadSql :: String -> [String] -> IO ()
-> loadSql db fns = wrapET $
->      liftIO (hSetBuffering stdout NoBuffering) >>
->      mapM (\f -> readInput f >>= tsl . P.parseSql f) fns >>= return . concat >>=
->      return . extensionize >>= liftIO . loadIntoDatabase db ""
-
-================================================================================
-
-> loadPsqlA = mode $ LoadPsql {database = def
->                             ,files = def &= typ "FILES" & args}
->             &= text "loads sql into a database using psql."
-
-> loadSqlPsql :: String -> [String] -> IO ()
-> loadSqlPsql db = wrapET .
->   mapM_ (\s -> liftIO (loadSqlUsingPsqlFromFile db s) >>= tsl >>= liftIO . putStrLn)
-
-================================================================================
-
-> pgDumpA = mode $ PgDump {database = def}
->           &= text "run pg dump, used for testing."
-
-> pgDump1 :: String -> IO ()
-> pgDump1 db = pgDump db >>= putStrLn
-
-
-================================================================================
-
-might try to work out a way of running multiple commands in one invoc
-of this exe, then this command will disappear
-
-> clearLoadA = mode $ ClearLoad {database = def
->                               ,files = def &= typ "FILES" & args}
->              &= text "cleardb then loadsql"
-
-> clearAndLoadSql :: String -> [String] -> IO ()
-> clearAndLoadSql db fns = cleardb db >> loadSql db fns
-
-================================================================================
-
-This reads an catalog from a database and writes it out using show.
-
-> catalogA = mode $ DBCatalog {database = def}
->            &= text "read the catalog for the given db and dumps it in source \
->                    \format, used to create the catalog value for template1"
-
-> readCat :: String -> IO ()
-> readCat dbName = do
->   cat <- readCatalogFromDatabase dbName
->   putStrLn preamble
->   putStrLn $ prefixLines $ ppShow cat
->   where
->     preamble = "> {-# OPTIONS_HADDOCK hide  #-}\n\
->                \\n\
->                \> module Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog\n\
->                \>     (defaultTemplate1Catalog\n\
->                \>      ) where\n\
->                \\n\
->                \> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal\n\
->                \> import Database.HsSqlPpp.AstInternals.TypeType\n\
->                \\n\
->                \> defaultTemplate1Catalog :: Catalog\n\
->                \> defaultTemplate1Catalog =\n\
->                \>    (\\l -> case l of\n\
->                \>             Left x -> error $ show x\n\
->                \>             Right e -> e) $\n\
->                \>     updateCatalog defaultCatalog\n"
->     prefixLines = unlines . map (">        " ++) . lines
-
-
-================================================================================
-
-run test battery: run a bunch of tests including consistency on the
-database and sql files given
-
-The idea is to typecheck the sql, load it into pg and dump it via psql
-and via database loader, can then compare asts, catalogs, etc. in a
-lot of different ways
-
-currently:
-parse and type check sql, save the catalog
-load the sql into the db using psql, compare the catalog read from pg
-with the catalog from typechecking
-dump the sql and typecheck the dump, compare the catalog from this
-check with the catalog from the original typecheck
-
-todo: compare asts from initial parse with parsed dump - this is going
-to be a lot of work to get passing since the statements are
-re-ordered, and sometimes changed/ split up by pg
-
-also: load the sql using the extension system and database loader,
-then compare pg catalog with initial catalog, and dump and compare ast
-with original ast
-
-want to run a similar set of tests starting with the dump sql:
-get ast,cat from dump sql, load using psql and using databaseloader
-and check cats and subsequent dump asts.
-
-getting the dump ast comparing with the original ast:
-
-step one: convert tests in parser test to also roundtrip through
-database, see parsertests for details
-
-step two: write an ast conversion routine: assume that the pgdump ast
-is like the ast fed into pg but with a few statements split into
-components (e.g. create table with serial is split into create
-sequence and create table), and then the statements are reordered, so
-write a routine to mirror this - will then have
-(anyast -> rearrange and reorder) == (anyast -> pg->pgdump)
-
-> testBatteryA = mode $ TestBattery {database = def
->                                   ,files = def &= typ "FILES" & args}
->                &= text "runs a load of consistency tests on the sql passed"
-
-> runTestBattery :: String -> [FilePath] -> IO ()
-> runTestBattery dbName fns = wrapET $ do
->     liftIO $ clearDB dbName
->     startingCat <- liftIO (readCatalog dbName) >>= tsl
->     (originalCat :: Catalog,
->      originalAast :: StatementList) <-
->        mapM (\f -> readInput f >>= tsl . P.parseSql f) fns >>= return . concat >>=
->        return . extensionize >>= return . A.typeCheck startingCat
-
->     headerMessage "type errors from initial parse:\n"
->     (return . A.getTypeErrors) originalAast >>= return . ppTypeErrors >>= mapM_ (liftIO . putStrLn)
-
->     mapM_ (\s -> liftIO (loadSqlUsingPsqlFromFile dbName s) >>= tsl >>= liftIO . putStrLn) fns
->     properCat <- liftIO (readCatalog dbName) >>= tsl
->     headerMessage "catalog differences from initial parse and vanilla load:\n"
->     return (ppCatDiff (compareCatalogs startingCat originalCat properCat)) >>= liftIO . putStrLn
-
->     (dumpCat,dumpAast) <-
->       liftIO (pgDump dbName) >>= tsl . P.parseSql "dump" >>= return . A.typeCheck startingCat
-
->     headerMessage "type errors from dump:\n"
->     (return . A.getTypeErrors) dumpAast >>= return . ppTypeErrors >>= mapM_ (liftIO . putStrLn)
-
->     headerMessage "catalog differences from initial parse and rechecked pg dump:\n"
->     return (ppCatDiff (compareCatalogs startingCat originalCat dumpCat)) >>= liftIO . putStrLn
-
->     (liftIO . putStrLn) "complete!"
->     where
->       headerMessage = liftIO . putStrLn . ("-----------------------------\n" ++)
-
-================================================================================
-
-run the test suite
-
-> testA = mode $ Test {extra = def &= typ "ANY" & args & unknownFlags}
->         &= text "run automated tests, uses test.framework can pass arguments \
->                 \to this e.g. HsSqlSystem test -t parserTests"
-
-> runTests :: [String] -> IO ()
-> runTests as =
->   flip defaultMainWithArgs as $
->     parserTests ++
->     typeCheckTests ++
->     parameterizedStatementTests ++
->     roundtripTests ++
->     localBindingsTests ++
->     [extensionTests]
-
-================================================================================
-
-options: nothing -> create/overwrite folders and files
-         clean -> delete generated files
-
-create target folder if doesn't exist
-
-broken at the moment
-
-> buildDocsA = mode $ BuildDocs
->         &= text "build the documention in the docs/ folder"
-
-> buildDocs :: IO ()
-> buildDocs = wrapET $ do
->              liftIO $ createDirectoryIfMissing False "docs/build"
->              inputFiles <- sources
->              let sts = zip (map ("docs/" ++) inputFiles) $
->                        flip map inputFiles
->                             (\f -> "docs/build/" ++ f ++ ".html")
->              forM_ sts $ \(s,t) ->
->                      readInput s >>= pandoc >>= liftIO . writeFile t
->             where
->               sources = liftM (filter (isSuffixOf ".txt"))
->                           (liftIO (getDirectoryContents "docs"))
-
-> -- | Documentation command to produce some hssqlppp docs, takes a
-> --   pandoc source file and converts to html, can run and insert
-> --   commands embedded in the source
-> pandoc :: MonadIO m => String -> ErrorT String m String
-> pandoc txt = return txt
-> {-
->   liftM (writeHtmlString wopt . readMarkdown defaultParserState)
->     (hsTextize txt)
->   where
->     wopt = defaultWriterOptions {
->                writerStandalone = True
->               ,writerTitlePrefix = "HsSqlPpp documentation"
->               ,writerTableOfContents = True
->               ,writerHeader = "<style>\n\
->                               \pre {\n\
->                               \    border: 1px dotted gray;\n\
->                               \    background-color: #ececec;\n\
->                               \    color: #1111111;\n\
->                               \    padding: 0.5em;\n\
->                               \}\n\
->                               \</style>"
->              }-}
-
-
-writerStandalone :: Bool	Include header and footer
-writerHeader :: String	Header for the document
-writerTitlePrefix :: String	Prefix for HTML titles
-writerTabStop :: Int	Tabstop for conversion btw spaces and tabs
-writerTableOfContents :: Bool	Include table of contents
-writerS5 :: Bool	We're writing S5
-writerHTMLMathMethod :: HTMLMathMethod	How to print math in HTML
-writerIgnoreNotes :: Bool	Ignore footnotes (used in making toc)
-writerIncremental :: Bool	Incremental S5 lists
-writerNumberSections :: Bool	Number sections in LaTeX
-writerIncludeBefore :: String	String to include before the body
-writerIncludeAfter :: String	String to include after the body
-writerStrictMarkdown :: Bool	Use strict markdown syntax
-writerReferenceLinks :: Bool	Use reference links in writing markdown, rst
-writerWrapText :: Bool	Wrap text to line length
-writerLiterateHaskell :: Bool	Write as literate haskell
-writerEmailObfuscation :: ObfuscationMethod	How to obfu
-
->   {-ex <- liftIO $ system ("pandoc -s -f markdown -t html "
->                          ++ src ++ " -o " ++ tgt)
->   case ex of
->     ExitFailure e -> throwError $ AEMisc $ "psql failed with " ++ show e
->     ExitSuccess -> return ()-}
-
-process doc commands
-
-> -- | read a text file, and pull out the commands, run them and insert
-> --   the results into the text
-> {-hsTextize :: MonadIO m => String -> ErrorT String m String
-> hsTextize s =
->     liftIO (hsTextify
->              (("hssqlsystem", hsSqlSystemCommand):defaultCommands)
->              "docs/build"
->              s) >>= tsl -- . mapLeft 
-
-> -- | run hssqlsystem using shell
-> hsSqlSystemCommand :: String -> IO String
-> hsSqlSystemCommand s =  shell ("HsSqlSystem " ++ s) >>= \m ->
->                         return $ "$ HsSqlSystem " ++ s
->                                  ++ "\n\n~~~~~~~~~~\n"
->                                  ++ m
->                                  ++ "\n~~~~~~~~~~\n\n" -}
-
-
-================================================================================
-
-> genWrapA = mode $ GenWrap {database = def
->                           ,file = def &= typ "FILE"}
->            &= text "experimental code to generate typesafe haskell wrapper \
->                    \for db access"
-> genWrap :: String -> String -> IO ()
-> genWrap db f =
->   wrapET doit
->     where
->       doit :: (MonadIO m) => ErrorT String m ()
->       doit = liftIO (wrapperGen db f) >>= liftIO . putStrLn
-
-================================================================================
-
-TODOS
-
-command to display all annotation inline in sql source
-better catalog diff, e.g. if two tables differ in one column just show
-that difference
-see if can improve ppshow to use slightly less newlines
-command to show which bits of preexisting catalog are used
-command to list which views/functions/etc. aren't used anywhere
-replace a bunch of commands with composible set:
-parse(expression), ppp, typecheck(expression), allannots
-->
-parse (expression option)
-type check
-annotation filter + options
-output: ast, sql, annotations + options
-
-
-
-
-think of a better name for this command than hssqlsystem
-
-want better options system:
-first set of options get passed around in reader? monad:
-  database name, username, password for pg
-  useextensions
-  annotation control? - when showing values, which annotations to also output?
-these have defaults, can change defaults in ~/.config/hssqlsystem or something,
-and can be overridden using --dbname=...,etc. command line args (make
-these work like psql? then have environment variables also)
-second set of options is for input and output:
-read from file(s), stdin, or from string literal command line arg, e.g.
-HsSqlSystem expressionType --src="3 + 5"
-output to file(s) or stdout
-
-review command names and arguments:
-find a better naming convention: some commands produce haskell values as text,
-some produce non haskell compatible text e.g. lexfile
-some run tests and produce a success/fail result, maybe a list of issues
-
-run multiple commands in one invocation?
-
-check errors passed to user are understandable
-
-command line commands to add:
-
-showAast
-ppCatalog - read from db and print in human readable rather
-            than as haskell value
-showexpressionast
-showexpressionaast
-typecheckexpression
-pppexpression
-showCatalogUpdates - run over some sql files, outputs the catalog changes
-                     made by this sql
-ppCatalogUpdates
-
-graphviz stuff: dependency graph: pass a view name or function and it
-draws a graph of all the views, tables and functions which are used by
-that view or function
-
-run an extension by name over some sql source to view differences: add
-integration with external diff viewers, so can see before and after,
-maybe option to either view pp'd sql, annotated pp'd sql, ast, aast,
-etc.  - can also use this for pppsql and pppexpression to view how the
-pretty printer mangles things, and for testing, etc.
-
-logging/verbosity:
-
-want a way to log to stderr/stdout/ files with different verbosity
-settings
-
-command line arguments:
-options:
---database=xxx
-?
---extensions
---username
---password
-?other connection info
-annotation control?
-
-command name
-other command arguments:
-- on its own is read from stdin
---input='xxx' add literal input rather than from file/stdin
-
-
-================================================================================
-
-> -- | Pretty print list of type errors with optional source position
-> --   in emacs readable format.
-> ppTypeErrors :: [(Maybe AnnotationElement, [TypeError])] -> [String]
-> ppTypeErrors tes =
->   map showSpTe tes
->   where
->     showSpTe (Just (SourcePos fn l c), e) =
->         fn ++ ":" ++ show l ++ ":" ++ show c ++ ":\n" ++ show e
->     showSpTe (_,e) = "unknown:0:0:\n" ++ show e
-
-================================================================================
-
-read file as string - issues are:
-
-want to support reading from stdin, and reading from a string passed
-as an argument to the exe
-
-> -- | read a file as text, will read from stdin if filename is '-'.
-> readInput :: (Error e, MonadIO m) => FilePath -> ErrorT e m String
-> readInput f =
->   liftIO r
->   where
->     r :: IO String
->     r = case f of
->              "-" -> getContents
->              _ | length f >= 2 &&
->                  head f == '"' && last f == '"'
->                    -> return $ drop 1 $ take (length f - 1) f
->                | otherwise -> readFile f
-
-================================================================================
-
-cmdargs stuff and main
-
-> data HsSqlSystem = Lex {files :: [String]}
->                  | Parse {files :: [String]}
->                  | ParseExpression {files :: [String]}
->                  | Pppp {files :: [String]}
->                  | Ppp {files :: [String]}
->                  | TypeCheck {database :: String
->                              ,files :: [String]}
->                  | TypeCheckExpression {database :: String
->                                        ,files :: [String]}
->                  | AllAnnotations {database :: String
->                                   ,files :: [String]}
->                  | AnnotateSource {database :: String
->                                   ,file :: String}
->                  | PPCatalog {database :: String
->                              ,files :: [String]}
->                  | Clear {database :: String}
->                  | Load {database :: String
->                         ,files :: [String]}
->                  | ClearLoad {database :: String
->                              ,files :: [String]}
->                  | DBCatalog {database :: String}
->                  | LoadPsql {database :: String
->                             ,files :: [String]}
->                  | PgDump {database :: String}
->                  | TestBattery {database :: String
->                                ,files :: [String]}
->                  | Test {extra :: [String]}
->                  | GenWrap {database :: String
->                            ,file :: String}
->                  | BuildDocs
->                    deriving (Show, Data, Typeable)
-
-> main :: IO ()
-> main = do
->        cmd <- cmdArgs "HsSqlSystem, Copyright Jake Wheat 2010"
->                       [lexA, parseA, ppppA, pppA,
->                        parseExpressionA, typeCheckExpressionA,
->                        typeCheckA,allAnnotationsA,
->                        annotateSourceA, ppCatalogA,
->                        clearA, loadA, clearLoadA, catalogA, loadPsqlA,
->                        pgDumpA, testBatteryA,
->                        testA,buildDocsA, genWrapA]
-
->        case cmd of
->          Lex fns -> lexFiles fns
->          Parse fns -> showAst fns
->          Pppp fns -> testPppp fns
->          Ppp fns -> showAst fns
->          ParseExpression fns -> parseExpression fns
->          TypeCheck db fns -> typeCheck2 db fns
->          TypeCheckExpression db fns -> typeCheckExpression db fns
->          AllAnnotations db fns -> typeCheck2 db fns
->          AnnotateSource db fn -> annotateSourceF db fn
->          PPCatalog db fns -> ppCatalog db fns
->          Clear db -> cleardb db
->          Load db fns -> loadSql db fns
->          ClearLoad db fns -> clearAndLoadSql db fns
->          DBCatalog db -> readCat db
->          LoadPsql db fns -> loadSqlPsql db fns
->          PgDump db -> pgDump1 db
->          TestBattery db fns -> runTestBattery db fns
->          Test as -> runTests as
->          BuildDocs -> buildDocs
->          GenWrap db f -> genWrap db f
-
-would like to have the database argument be a common arg, don't know
-how to do this
-
-> lexA, parseA, ppppA, pppA, annotateSourceA, clearA, loadA,
->   clearLoadA, catalogA, loadPsqlA, pgDumpA, testBatteryA,
->   typeCheckA, testA, parseExpressionA, typeCheckExpressionA,
->   buildDocsA, allAnnotationsA, ppCatalogA, genWrapA :: Mode HsSqlSystem
-
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright Jake Wheat 2009
+Copyright Jake Wheat 2010
 
 All rights reserved.
 
diff --git a/README b/README
--- a/README
+++ b/README
@@ -1,121 +1,15 @@
-Summary: A parser, pretty printer, and type checker for PostgreSQL SQL
-and PL/pgSQL. BSD licensed.
-
-The current aims of the project is to provide a parser and type
-checker for a substantial portion of PostgreSQL SQL and PL/pgSQL, and
-then hopefully to build on this to make tools and libraries to help
-developing PL/pgSQL code, possibly: macros/ code generation/ custom
-syntax, type safe access from Haskell, Lint-like checking,
-documentation generation.
-
-Status: it successfully parses and accurately pretty prints the three
-moderate sized SQL files from another project of mine, but there are
-lots of missing bits. Coverage of SQL is sort of reasonable - it's
-possible that your SQL files will parse OK, but it's also possible
-that they won't parse at all. Please report any SQL which doesn't
-parse.
-
-It also has the beginnings of a type checker, which currently can type
-check a fair bit of the three files mentioned above. You can run the
-type checker on your SQL in various ways from the command line. Please
-report any SQL which doesn't type check correctly. Coming soon: a
-command to produce a report on how well this code can parse and type
-check your SQL.
-
-It comes with a small test suite.
+A parser, pretty printer, and type checker for SQL written in
+Haskell. Supports PostgreSQL SQL and PL/pgSQL syntax. BSD licensed.
 
-To install, use
+Install with:
 cabal update
-then
 cabal install hssqlppp
 
-It's currently developed on GHC 6.12, but is tested on 6.10 before
-each release so should work there too.
-
-There isn't much in the way of documentation at the moment. See the
-haddock docs locally or on hackage (link below), which also contain
-links to a few example files. The source has a fair bit of comments,
-which are currently OK in some places and poor in others.
-
-The main dependencies of this project are: Parsec 3, HDBC,
-HDBC-postgresql, and UUAGC is needed only for development). You need
-PostgreSQL installed.
-
-================================================================================
-
-Homepage
-
-There isn't really a homepage or website yet, but you can view the
-Launchpad page where the code is hosted, and the HackageDB page.
-
-Launchpad:
-http://launchpad.net/hssqlppp/
-
-HackageDB page:
-http://hackage.haskell.org/package/hssqlppp
-You can also browse the limited Haddock documentation online here.
-
-You can get the latest development code from Launchpad using Bazaar:
-bzr branch lp:~jakewheat/hssqlppp/trunk
-
-================================================================================
-
-Contact
-
-Let me know if you're using/ interesting in using the library, if you
-have any problems or suggestions, etc.. All contributions, comments
-and criticism welcome:
-
-jakewheatmail@gmail.com
-
-You can also report problems on the bug tracker on Launchpad.
-
-================================================================================
-
-Example files:
-
-(remove the prefix
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/
-to get the local relative path)
-
-The test files for parsing and for type checking contain examples of
-what parses/ typechecks and what the asts and annotations look like:
-
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Tests/ParserTests.lhs
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Tests/TypeCheckTests.lhs
-
-The HsSqlSystem command source - HsSqlSystem.lhs.
-
-AST transform code to extend plpgsql without any custom syntax, for
-another project, early days:
-
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Extensions/ChaosExtensions.lhs
-
-Some type safe database access rough example code, all just half
-finished demo ideas at the moment:
-
-Simple idea to work as a preprocess to parse a haskell file and
-convert some declarations into calls to a wrapper around HDBC, with
-the correct type signatures, with the return type as a list of haskell
-tuples:
-
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Dbms/WrapperGen.lhs
-
-Similar to previous idea, but using template haskell to do the
-substitution at compile time, not as a preprocessor:
-
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Dbms/DBAccess2.lhs
-
-example usage:
-
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/testfiles/DBAccess2Test.lhs
-
-Use template haskell again, but type the return values as lists of
-hlists instead of tuples, so that field names in haskell code are also
-checked at compile time:
+Website, with some docs and examples:
+http://jakewheat.github.com/hssqlppp/
 
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/Database/HsSqlPpp/Dbms/DBAccess3.lhs
+Hackage: http://hackage.haskell.org/package/hssqlppp
 
-example usage:
+Repository: https://github.com/JakeWheat/hssqlppp
 
-http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/testfiles/DBAccess3Test.lhs
+Contact: jakewheatmail@gmail.com
diff --git a/THANKS b/THANKS
new file mode 100644
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,2 @@
+Christoph Bauer for testing and feedback on the API
+Hideki Kariya for bug reports and patches
diff --git a/hssqlppp.cabal b/hssqlppp.cabal
--- a/hssqlppp.cabal
+++ b/hssqlppp.cabal
@@ -1,226 +1,78 @@
 Name:                hssqlppp
-Version:             0.2.0
-Synopsis:            Sql parser and type checker
-Description:
-    Sql parser, pretty printer and type checker, targets PostgreSQL SQL
-    and PL/pgSQL.
-    .
-    See the project page
-    <https://launchpad.net/hssqlppp> for more information and
-    documentation links, there are also links to some example usage
-    files there.
-    .
-    Quick module guide:
-    .
-    'Ast' - ast types;
-    .
-    'Parser' - converting strings to asts;
-    .
-    'PrettyPrinter' - converting asts to strings containing valid SQL;
-    .
-    'TypeChecker' - type checking and annotating asts and working
-    with annotated trees;
-    .
-    'SqlTypes' - the data types which represent SQL types, the data
-    type for type errors, and some support functions;
-    .
-    'Annotation' - the annotation data types and utilities;
-    .
-    'Catalog' - read a catalog from a database to type check against,
-    or to generate catalog information.
-    .
-    Also comes with command line access to some functions via a exe called
-    HsSqlSystem, run this file with no arguments to get some help.
-
+Version:             0.3.0
+Synopsis:            SQL parser and type checker
 License:             BSD3
 License-file:        LICENSE
 Author:              Jake Wheat
 Maintainer:          jakewheatmail@gmail.com
 Build-Type:          Simple
-Cabal-Version:       >=1.2.3
-copyright:           Copyright 2010 Jake Wheat
+Cabal-Version:       >=1.6
+copyright:           Copyright 2009-2011 Jake Wheat
 stability:           pre-alpha
-homepage:            https://launchpad.net/hssqlppp
-bug-reports:         mailto:jakewheatmail@gmail.com
+homepage:            http://jakewheat.github.com/hssqlppp/
+bug-reports:         https://github.com/JakeWheat/hssqlppp/issues
 category:            Database
+Description:
+    SQL parser and type checker, targets PostgreSQL SQL and PL/pgSQL.
+    .
+    Documentation, examples on the homepage:
+    <http://jakewheat.github.com/hssqlppp/>.
 
+-- to run haddock use 'cabal configure --ghc-options "-pgmPcpphs -optP--cpp"' first
+
 extra-source-files:  README
                      LICENSE
-                     --find Database/ -type f -a ! -iname '*.o' -a ! -iname '*.hi'
-                     Database/HsSqlPpp/Utils.lhs
-                     Database/HsSqlPpp/Dbms/DBAccess.lhs
-                     Database/HsSqlPpp/Dbms/DBAccess2.lhs
-                     Database/HsSqlPpp/Dbms/DBAccess3.lhs
-                     Database/HsSqlPpp/Dbms/MakeLabels.hs
-                     Database/HsSqlPpp/Dbms/DatabaseLoader.lhs
-                     Database/HsSqlPpp/Dbms/WrapLib.lhs
-                     Database/HsSqlPpp/Dbms/WrapperGen.lhs
-                     Database/HsSqlPpp/Dbms/DBUtils.lhs
-                     Database/HsSqlPpp/Extensions/ChaosExtensions.lhs
-                     Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs
-                     Database/HsSqlPpp/AstInternals/AstAnnotation.lhs
-                     Database/HsSqlPpp/AstInternals/AstInternal.hs
-                     Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs
-                     Database/HsSqlPpp/AstInternals/Catalog/CatalogReader.lhs
-                     Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs
-                     Database/HsSqlPpp/AstInternals/AstInternal.ag
-                     Database/HsSqlPpp/AstInternals/TypeType.lhs
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Dml.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/SelectStatement.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs
-                     Database/HsSqlPpp/AstInternals/TypeChecking/TableRefs.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Plpgsql.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/TypeChecking.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Misc.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs
-                     Database/HsSqlPpp/AstInternals/TypeChecking/CreateTable.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/CreateFunction.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Statements.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/SelectLists.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Expressions.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/Drops.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/MiscCreates.ag
-                     Database/HsSqlPpp/AstInternals/TypeChecking/LocalIdentifierBindings.lhs
-                     Database/HsSqlPpp/Tests/ExtensionTests.lhs
-                     Database/HsSqlPpp/Tests/LocalBindingsTests.lhs
-                     Database/HsSqlPpp/Tests/ParserTests.lhs
-                     Database/HsSqlPpp/Tests/DatabaseLoaderTests.lhs
-                     Database/HsSqlPpp/Tests/RoundtripTests.lhs
-                     Database/HsSqlPpp/Tests/TypeCheckTests.lhs
-                     Database/HsSqlPpp/Tests/ParameterizedStatementTests.lhs
-                     Database/HsSqlPpp/Here.lhs
-                     Database/HsSqlPpp/PrettyPrinter/AnnotateSource.lhs
-                     Database/HsSqlPpp/PrettyPrinter/PrettyPrinter.lhs
-                     Database/HsSqlPpp/HsText/Commands.lhs
-                     Database/HsSqlPpp/HsText/HsText.lhs
-                     Database/HsSqlPpp/Parsing/Lexer.lhs
-                     Database/HsSqlPpp/Parsing/Parser.lhs
-                     Database/HsSqlPpp/Parsing/ParseErrors.lhs
-                     Database/HsSqlPpp/Ast/Ast.lhs
-                     Database/HsSqlPpp/Ast/Annotation.lhs
-                     Database/HsSqlPpp/Ast/Catalog.lhs
-                     Database/HsSqlPpp/Ast/SqlTypes.lhs
-                     Database/HsSqlPpp/Ast/TypeChecker.lhs
+                     THANKS
+                     --find src/ -iname '*.ag' -o -iname '.sql' -o -iname '*.txt' -o -iname '*.hs' -o -iname '*.lhs'
 
+source-repository head
+  type:     git
+  location: https://github.com/JakeWheat/hssqlppp.git
+
 Library
   Build-Depends:     base >= 4 && < 5,
-                     mtl,
-                     parsec >= 3,
-                     pretty,
-                     containers,
-                     regex-posix,
-                     HDBC,
-                     HDBC-postgresql,
-                     directory,
-                     syb,
-                     uniplate,
-                     pretty-show,
-                     Pipe,
-                     process,
-                     --pandoc == 1.2.1,
-                     filepath,
-                     template-haskell,
-                     haskell-src-exts
-                     --HList
+                     mtl >= 2.0.1.0 && < 2.1,
+                     containers >= 0.3.0.0 && < 0.5,
+                     parsec >= 3.1 && < 3.2,
+                     pretty >= 1.0.1.1 && < 1.1,
+                     syb >= 0.1.0.2 && < 0.4,
+                     uniplate >= 1.6 && < 1.7,
+                     transformers >= 0.2.2.0 && < 0.3
+  build-tools:       cpphs
 
-  Exposed-modules:   Database.HsSqlPpp.Ast.Ast
-                     Database.HsSqlPpp.Ast.TypeChecker
-                     Database.HsSqlPpp.Ast.Catalog
-                     Database.HsSqlPpp.Ast.Annotation
-                     Database.HsSqlPpp.Ast.SqlTypes
-                     Database.HsSqlPpp.Parsing.Parser
-                     Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
+  hs-source-dirs:    src
+  Exposed-modules:   Database.HsSqlPpp.Ast
+                     Database.HsSqlPpp.Annotation
+                     Database.HsSqlPpp.Catalog
+                     Database.HsSqlPpp.Parser
+                     Database.HsSqlPpp.Pretty
+                     Database.HsSqlPpp.Types
+                     Database.HsSqlPpp.TypeChecker
 
-  Other-Modules:     Database.HsSqlPpp.Utils
-                     Database.HsSqlPpp.Here
-                     Database.HsSqlPpp.Dbms.DBAccess
-                     --Database.HsSqlPpp.Dbms.MakeLabels
-                     Database.HsSqlPpp.Dbms.DBUtils
-                     Database.HsSqlPpp.AstInternals.AnnotationUtils
-                     Database.HsSqlPpp.AstInternals.AstAnnotation
-                     Database.HsSqlPpp.AstInternals.AstInternal
-                     Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
-                     Database.HsSqlPpp.AstInternals.Catalog.CatalogReader
+                     -- find src/lib -iname '*hs' | sed -e "s@src/@@" | sed -e "s@/@.@g" |sed -e "s/.lhs//" |sed -e "s/.hs//"
+  Other-Modules:     Database.HsSqlPpp.Utils.Utils
+                     Database.HsSqlPpp.Parsing.ParseErrors
+                     Database.HsSqlPpp.Parsing.Lexer
+                     Database.HsSqlPpp.Parsing.ParserInternal
                      Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalIdentifierBindings
-                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
-                     Database.HsSqlPpp.AstInternals.TypeType
+                     Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
+                     Database.HsSqlPpp.AstInternals.AstAnti
                      Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
                      Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
-                     Database.HsSqlPpp.Tests.ExtensionTests
-                     Database.HsSqlPpp.Tests.TypeCheckTests
-                     Database.HsSqlPpp.Tests.ParserTests
-                     Database.HsSqlPpp.Tests.DatabaseLoaderTests
-                     Database.HsSqlPpp.Tests.ParameterizedStatementTests
-                     Database.HsSqlPpp.Tests.LocalBindingsTests
-                     Database.HsSqlPpp.HsText.Commands
-                     Database.HsSqlPpp.HsText.HsText
-                     Database.HsSqlPpp.Parsing.Lexer
-                     Database.HsSqlPpp.Parsing.ParseErrors
-                     Database.HsSqlPpp.Dbms.DatabaseLoader
-                     Database.HsSqlPpp.Dbms.WrapperGen
-                     Database.HsSqlPpp.Dbms.WrapLib
-                     Database.HsSqlPpp.Dbms.DBAccess2
-                     --Database.HsSqlPpp.Dbms.DBAccess3
-                     Database.HsSqlPpp.Extensions.ChaosExtensions
-                     Database.HsSqlPpp.PrettyPrinter.AnnotateSource
-
-  extensions:        DeriveDataTypeable,RankNTypes,ScopedTypeVariables
-
-Executable HsSqlSystem
-  Main-is:           HsSqlSystem.lhs
-
-  Build-Depends:     base,
-                     haskell98,
-                     regex-posix,
-                     HDBC,
-                     HDBC-postgresql,
-                     directory,
-                     test-framework,
-                     test-framework-hunit,
-                     HUnit,
-                     cmdargs
-                     --HList
-
-  Other-Modules:     Database.HsSqlPpp.Utils
-                     Database.HsSqlPpp.Here
-                     Database.HsSqlPpp.Dbms.DBAccess
-                     Database.HsSqlPpp.Dbms.DBAccess2
-                     --Database.HsSqlPpp.Dbms.DBAccess3
-                     --Database.HsSqlPpp.Dbms.MakeLabels
-                     Database.HsSqlPpp.Dbms.WrapperGen
-                     Database.HsSqlPpp.Dbms.WrapLib
-                     Database.HsSqlPpp.Dbms.DatabaseLoader
-                     Database.HsSqlPpp.Dbms.DBUtils
-                     Database.HsSqlPpp.Extensions.ChaosExtensions
-                     Database.HsSqlPpp.AstInternals.AnnotationUtils
+                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
+                     Database.HsSqlPpp.AstInternals.TypeChecking.Utils
+                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindingsInternal
                      Database.HsSqlPpp.AstInternals.AstAnnotation
+                     Database.HsSqlPpp.AstInternals.AnnotationUtils
                      Database.HsSqlPpp.AstInternals.AstInternal
-                     Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
-                     Database.HsSqlPpp.AstInternals.Catalog.CatalogReader
-                     Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
-                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
-                     Database.HsSqlPpp.AstInternals.TypeChecking.LocalIdentifierBindings
                      Database.HsSqlPpp.AstInternals.TypeType
-                     Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
-                     Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
-                     Database.HsSqlPpp.Tests.ExtensionTests
-                     Database.HsSqlPpp.Tests.TypeCheckTests
-                     Database.HsSqlPpp.Tests.ParserTests
-                     Database.HsSqlPpp.Tests.DatabaseLoaderTests
-                     Database.HsSqlPpp.Tests.LocalBindingsTests
-                     Database.HsSqlPpp.PrettyPrinter.AnnotateSource
-                     Database.HsSqlPpp.PrettyPrinter.PrettyPrinter
-                     Database.HsSqlPpp.HsText.Commands
-                     Database.HsSqlPpp.HsText.HsText
-                     Database.HsSqlPpp.Parsing.Lexer
-                     Database.HsSqlPpp.Parsing.Parser
-                     Database.HsSqlPpp.Parsing.ParseErrors
-                     Database.HsSqlPpp.Ast.TypeChecker
-                     Database.HsSqlPpp.Ast.Ast
-                     Database.HsSqlPpp.Ast.Catalog
-                     Database.HsSqlPpp.Ast.Annotation
-                     Database.HsSqlPpp.Ast.SqlTypes
+  ghc-options:       -pgmPcpphs -optP--cpp
 
-  extensions:        DeriveDataTypeable,RankNTypes,ScopedTypeVariables
+  extensions:        DeriveDataTypeable,
+                     RankNTypes,
+                     ScopedTypeVariables,
+                     FlexibleContexts,
+                     ExistentialQuantification,
+                     CPP,
+                     PatternGuards,
+                     TupleSections
diff --git a/src/Database/HsSqlPpp/Annotation.lhs b/src/Database/HsSqlPpp/Annotation.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Annotation.lhs
@@ -0,0 +1,23 @@
+
+This is the public module to the annotation data types and support
+functions (not including those that depend on the ast data types).
+
+> {- | Contains the annotation data types and a few auxiliary functions.
+> -}
+>
+> module Database.HsSqlPpp.Annotation
+>     (
+>      -- * Annotation data types
+>      Annotation(..)
+>     ,SourcePosition
+>     ,StatementType
+>     ,getAnnotation
+>     ,updateAnnotations
+>     ,updateAnnotation
+>     ,getAnnotations
+>     ,emptyAnnotation
+>     ,resetAnnotations
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.AstAnnotation
+> import Database.HsSqlPpp.AstInternals.AnnotationUtils
diff --git a/src/Database/HsSqlPpp/Ast.lhs b/src/Database/HsSqlPpp/Ast.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Ast.lhs
@@ -0,0 +1,97 @@
+
+> {- | This module contains the ast node data types. They are very
+>      permissive, in that they allow a lot of invalid SQL to be
+>      represented. The type checking process should catch all invalid
+>      trees, but doesn't quite manage at the moment.  Sorry about all
+>      the seemingly pointless type synonyms below, they are an
+>      artefact of using UUAGC. You can see labels for the fields by
+>      looking at the ag source here:
+>      <http://jakewheat.github.com/hssqlppp/source/src/Database/HsSqlPpp/AstInternals/AstInternal.ag.html>
+>      -}
+>
+> module Database.HsSqlPpp.Ast
+>     (
+>      -- * Main nodes
+>      StatementList
+>     ,Statement (..)
+>     ,ScalarExpr (..)
+>     ,QueryExpr (..)
+>      -- * Components
+>      -- ** Selects
+>     ,SelectList (..)
+>     ,SelectItem (..)
+>     ,TableRef (..)
+>     ,TableAlias(..)
+>     ,JoinExpr (..)
+>     ,JoinType (..)
+>     ,Natural (..)
+>     ,CombineType (..)
+>     ,Direction (..)
+>     ,Distinct (..)
+>     ,InList (..)
+>     ,LiftFlavour (..)
+>     ,FrameClause(..)
+>     ,WithQueryList
+>     ,WithQuery(..)
+>     ,IntervalField(..)
+>     ,ExtractField(..)
+>     ,SQIdentifier(..)
+>      -- ** dml
+>     ,CopySource (..)
+>     ,RestartIdentity (..)
+>      -- ** ddl
+>     ,AttributeDef (..)
+>     ,RowConstraint (..)
+>     ,Constraint (..)
+>     ,AlterTableAction(..)
+>     ,TypeAttributeDef (..)
+>     ,TypeName (..)
+>     ,DropType (..)
+>     ,IfExists (..)
+>     ,Replace(..)
+>     ,Cascade (..)
+>     ,TriggerWhen(..)
+>     ,TriggerEvent(..)
+>     ,TriggerFire(..)
+>      -- ** functions
+>     ,FnBody (..)
+>     ,ParamDef (..)
+>     ,VarDef (..)
+>     ,RaiseType (..)
+>     ,Volatility (..)
+>     ,Language (..)
+>      -- ** misc
+>     ,SetValue(..)
+>     -- ,Name(..)
+>      -- ** typedefs
+>     ,ScalarExprListStatementListPairList
+>     ,ScalarExprListStatementListPair
+>     ,ScalarExprList
+>     ,MaybeSelectList
+>     --,StringList
+>     ,ParamDefList
+>     ,AttributeDefList
+>     ,ConstraintList
+>     ,TypeAttributeDefList
+>     ,TypeNameList
+>     ,StringTypeNameListPair
+>     ,StringTypeNameListPairList
+>     ,ScalarExprStatementListPairList
+>     ,CaseScalarExprListScalarExprPairList
+>     ,MaybeScalarExpr
+>     ,MaybeBoolExpr
+>     ,TableRefList
+>     ,ScalarExprListList
+>     ,SelectItemList
+>     ,OnExpr
+>     ,RowConstraintList
+>     ,VarDefList
+>     ,ScalarExprStatementListPair
+>     ,CaseScalarExprListScalarExprPair
+>     ,ScalarExprDirectionPair
+>     ,ScalarExprDirectionPairList
+>     ,AlterTableActionList
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.AstInternal
+> --import Database.HsSqlPpp.AstInternals.Name
diff --git a/src/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs b/src/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/AnnotationUtils.lhs
@@ -0,0 +1,28 @@
+
+This module contains some utilities and generic code for working with
+asts and annotations which depend on the ast types.
+
+> {-# LANGUAGE ScopedTypeVariables #-}
+>
+> module Database.HsSqlPpp.AstInternals.AnnotationUtils
+>     (
+>      getStatementAnnotations
+>     ,resetAnnotations
+>     ) where
+>
+> import Data.Data
+> import Data.Generics.Uniplate.Data
+>
+> import Database.HsSqlPpp.AstInternals.AstInternal
+> import Database.HsSqlPpp.AstInternals.AstAnnotation
+>
+> -- | Run through the ast and return all the annotations attached to
+> --   a Statement node.
+> getStatementAnnotations :: Data a => a -> [Annotation]
+> getStatementAnnotations st =
+>     [getAnnotation s | (s::Statement) <- universeBi st]
+
+> -- | Set all the annotations in a tree to be 'emptyAnnotation'.
+> resetAnnotations :: Data a => a -> a
+> resetAnnotations =
+>     updateAnnotations (const emptyAnnotation)
diff --git a/src/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs b/src/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/AstAnnotation.lhs
@@ -0,0 +1,194 @@
+
+The annotation data types and utilities for working with them.
+
+Annotations are used to store source positions, types, errors,
+warnings, catalog deltas, information, and other stuff a client might
+want to use when looking at an ast. Internal annotations which are
+used in the type-checking/ annotation process use the attribute
+grammar code and aren't exposed.
+
+> {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable,ScopedTypeVariables,
+>   RankNTypes,FlexibleContexts #-}
+>
+> module Database.HsSqlPpp.AstInternals.AstAnnotation
+>     (
+>      Annotation(..)
+>     ,SourcePosition
+>     ,StatementType
+>     ,getAnnotation
+>     ,updateAnnotations
+>     ,getAnnotations
+>     ,emptyAnnotation
+>     ,getTypeAnnotation
+>     ,updateAnnotation
+>     ) where
+>
+> import Data.Generics
+> ---import Control.Arrow
+> import Data.Generics.Uniplate.Data
+> --import Debug.Trace
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
+> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+> --import Database.HsSqlPpp.Utils.Utils
+>
+> -- | Represents a source file position, usually set by the parser.
+> type SourcePosition = (String,Int,Int)
+> -- | Statement type is used for getting type information for a parameterized statement.
+> type StatementType = ([Type],[(String,Type)])
+
+> -- | Annotation type - one of these is attached to most of the
+> -- data types used in the ast.
+> data Annotation = Annotation { -- | source position for this node
+>                               asrc :: Maybe SourcePosition
+>                                -- | type of the node, 'Nothing' if the tree hasn't been typechecked or if a type error prevents determining the type
+>                              ,atype :: Maybe Type
+>                                -- | any type errors
+>                              ,errs :: [TypeError]
+>                                -- | 'statement type' - used for getting the in and out types of a parameterized statement
+>                              ,stType :: Maybe StatementType
+>                                -- | any catalog updates that a ddl statement produces
+>                              ,catUpd :: [CatalogUpdate]
+>                                -- | the matched function prototype for a funcall
+>                              ,fnProt :: Maybe FunctionPrototype
+>                                -- | 'inferred' type - fake type inference used for getting the type of ? placeholders in parameterized statements
+>                              ,infType :: Maybe Type}
+>                   deriving (Eq, Show,Typeable,Data)
+>
+> -- | An annotation value with no information.
+> emptyAnnotation :: Annotation
+> emptyAnnotation = Annotation Nothing Nothing [] Nothing [] Nothing Nothing
+
+> -- | get the annotation for the root element of the tree passed
+> getAnnotation :: Data a => a -> Annotation
+> getAnnotation = head . childrenBi
+
+> -- | get all the annotations from a tree
+> getAnnotations :: Data a => a -> [Annotation]
+> getAnnotations = universeBi -- st --[x | x <- universeBi st]
+
+> -- | update all the annotations in a tree
+> updateAnnotations :: Data a => (Annotation -> Annotation) -> a -> a
+> updateAnnotations = transformBi
+
+> getTypeAnnotation :: Data a => a -> Maybe Type
+> getTypeAnnotation = atype . getAnnotation
+
+
+
+
+
+Use syb/uniplate to pull annotation values from an ast.
+
+I like to cut and paste code from the internet which I don't
+understand, then keep changing it till it compiles and passes the tests.
+
+> {- -- | run through the ast, and pull the type annotation from each
+> -- of the top level items.
+> getTypeAnnotation :: (Show a, Data a) => a -> Type
+> getTypeAnnotation st =
+>     typeAnnot $ getTopLevelAnnotation st
+>     where
+>       typeAnnot :: Annotation -> Type
+>       typeAnnot (x:xs) = case x of
+>                                 TypeAnnotation t -> t
+>                                 _ -> typeAnnot xs
+>       typeAnnot [] = TypeCheckFailed -- error "couldn't find type annotation"
+>
+> -- | Run through the ast given and return a list of statementtypes
+> -- from the top level items.
+> getTopLevelInfos :: Data a => [a] -> [Maybe StatementType]
+> getTopLevelInfos = map (getSIAnnotation . getTopLevelAnnotation)
+>
+> getTopLevelCatUpdates ::  Data a => [a] -> [[CatalogUpdate]]
+> getTopLevelCatUpdates = map (getEuAnnotation . getTopLevelAnnotation)
+>
+
+> -- | runs through the ast given and returns a list of all the type errors
+> -- in the ast. Recurses into all ast nodes to find type errors.
+> -- This is the function to use to see if an ast has passed the type checking process.
+> -- Returns a Maybe SourcePos and the list of type errors for each node which has one or
+> -- more type errors.
+> getTypeErrors :: (Data a) => a -> [(Maybe AnnotationElement,[TypeError])]
+> getTypeErrors sts =
+>     filter (\(_,te) -> not $ null te) $ map (gtsp &&& gte) $ getAnnotations sts
+>     where
+>       gte (a:as) = case a of
+>                     TypeErrorA e -> e:gte as
+>                     _ -> gte as
+>       gte _ = []
+>       gtsp (a:as) = case a of
+>                     s@(SourcePos _ _ _) -> Just s
+>                     _ -> gtsp as
+>       gtsp _ = Nothing
+
+~~~~
+question:
+if a node has no source position e.g. the all in select all or select
+   distinct may correspond to a token or may be synthesized as the
+   default if neither all or distinct is present. Should this have the
+   source position of where the token would have appeared, should it
+   inherit it from its parent, should there be a separate ctor to
+   represent a fake node with no source position?
+
+~~~~
+
+hack job, often not interested in the source positions when testing
+the asts produced, so this function will reset all the source
+positions to empty ("", 0, 0) so we can compare them for equality, etc.
+without having to get the positions correct.
+
+> -}
+
+ > -- | strip all the annotations from a tree. E.g. can be used to compare
+ > -- two asts are the same, ignoring any source position annotation differences.
+ > stripAnnotations :: Data a => a -> a
+ > stripAnnotations = filterAnnotations (const False)
+ >
+
+ > filterAnnotations :: Data a => (Annotation -> Bool) -> a -> a
+ > filterAnnotations f = transformBi (filter f)
+
+>
+> -- | Update all the annotations in a tree using the function supplied
+> updateAnnotation :: Data a => (Annotation -> Annotation) -> a -> a
+> updateAnnotation f = gmapT (mkT f)
+>
+
+
+ >   case gmapQ (mkQ [] f) a of
+ >     an:_ -> an
+ >     [] -> []
+ >   where
+ >     f :: Annotation -> Annotation
+ >     f = id
+ >
+
+ >
+ > getAnnotations :: Data a => a -> [Annotation]
+ > getAnnotations = listifyWholeLists (\(_::Annotation) -> True)
+ >
+
+> {-getSIAnnotation :: Annotation -> Maybe StatementType
+> getSIAnnotation (x:xs) = case x of
+>                                 StatementTypeA t -> Just t
+>                                 _ -> getSIAnnotation xs
+> getSIAnnotation []  = Nothing
+>
+> getEuAnnotation :: Annotation -> [CatalogUpdate]
+> getEuAnnotation (x:xs) = case x of
+>                                 CatUpdates t -> t
+>                                 _ -> getEuAnnotation xs
+> getEuAnnotation [] = []-}
+
+-------------------------------------------------------------------------------
+
+utils
+
+ > listifyWholeLists :: Typeable b => ([b] -> Bool) -> GenericQ [[b]]
+ > listifyWholeLists blp = flip (synthesize id (.) (mkQ id (\bl _ -> if blp bl then (bl:) else id))) []
+
+this might need to be maybe and change head?
+
+ > getTopLevelAnnotation :: Data a => a -> Annotation
+ > getTopLevelAnnotation st = head $ childrenBi st
diff --git a/src/Database/HsSqlPpp/AstInternals/AstAnti.hs b/src/Database/HsSqlPpp/AstInternals/AstAnti.hs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/AstAnti.hs
@@ -0,0 +1,967 @@
+{-
+This file is autogenerated, to generate: load this file (MakeAntiNodes.lhs)
+into ghci and run:
+nwriteAntiNodes
+n\nThe path might need tweaking.
+n-}
+{-# LANGUAGE DeriveDataTypeable #-}
+module Database.HsSqlPpp.AstInternals.AstAnti
+       (convertStatements, convertScalarExpr, attributeDef, queryExpr,
+        Statement(..), QueryExpr(..), WithQuery(..), FnBody(..),
+        TableRef(..), TableAlias(..), JoinExpr(..), JoinType(..),
+        SelectList(..), SelectItem(..), CopySource(..), AttributeDef(..),
+        RowConstraint(..), AlterTableAction(..), Constraint(..),
+        TypeAttributeDef(..), ParamDef(..), VarDef(..), RaiseType(..),
+        CombineType(..), Volatility(..), Language(..), TypeName(..),
+        DropType(..), Cascade(..), Direction(..), Distinct(..),
+        Natural(..), IfExists(..), Replace(..), RestartIdentity(..),
+        ScalarExpr(..), SQIdentifier(..), IntervalField(..),
+        ExtractField(..), FrameClause(..), InList(..), LiftFlavour(..),
+        TriggerWhen(..), TriggerEvent(..), TriggerFire(..), SetValue(..),
+        WithQueryList, StatementList, ScalarExprListStatementListPairList,
+        ScalarExprListStatementListPair, ScalarExprList, ParamDefList,
+        AttributeDefList, ConstraintList, TypeAttributeDefList,
+        TypeNameList, StringTypeNameListPair, StringTypeNameListPairList,
+        ScalarExprStatementListPairList,
+        CaseScalarExprListScalarExprPairList, MaybeScalarExpr,
+        TableRefList, ScalarExprListList, SelectItemList, OnExpr,
+        RowConstraintList, VarDefList, ScalarExprStatementListPair,
+        CaseScalarExprListScalarExprPair, ScalarExprDirectionPair,
+        ScalarExprDirectionPairList, MaybeBoolExpr, MaybeSelectList,
+        AlterTableActionList)
+       where
+import Data.Generics
+import Database.HsSqlPpp.AstInternals.AstAnnotation
+import qualified Database.HsSqlPpp.AstInternals.AstInternal as A
+ 
+convertStatements :: [Statement] -> [A.Statement]
+convertStatements = statementList
+ 
+convertScalarExpr :: ScalarExpr -> A.ScalarExpr
+convertScalarExpr = scalarExpr
+ 
+data JoinType = Inner
+              | LeftOuter
+              | RightOuter
+              | FullOuter
+              | Cross
+              deriving (Show, Eq, Typeable, Data)
+ 
+data CopySource = CopyFilename String
+                | Stdin
+                deriving (Show, Eq, Typeable, Data)
+ 
+data SetValue = SetStr Annotation String
+              | SetId Annotation String
+              | SetNum Annotation Double
+              deriving (Show, Eq, Typeable, Data)
+ 
+data TriggerWhen = TriggerBefore
+                 | TriggerAfter
+                 deriving (Show, Eq, Typeable, Data)
+ 
+data TriggerEvent = TInsert
+                  | TUpdate
+                  | TDelete
+                  | AntiTriggerEvent String
+                  deriving (Show, Eq, Typeable, Data)
+ 
+data TriggerFire = EachRow
+                 | EachStatement
+                 deriving (Show, Eq, Typeable, Data)
+ 
+data RaiseType = RNotice
+               | RException
+               | RError
+               deriving (Show, Eq, Typeable, Data)
+ 
+data CombineType = Except
+                 | Union
+                 | Intersect
+                 | UnionAll
+                 deriving (Show, Eq, Typeable, Data)
+ 
+data Volatility = Volatile
+                | Stable
+                | Immutable
+                deriving (Show, Eq, Typeable, Data)
+ 
+data Language = Sql
+              | Plpgsql
+              deriving (Show, Eq, Typeable, Data)
+ 
+data DropType = Table
+              | Domain
+              | View
+              | Type
+              deriving (Show, Eq, Typeable, Data)
+ 
+data Cascade = Cascade
+             | Restrict
+             deriving (Show, Eq, Typeable, Data)
+ 
+data Direction = Asc
+               | Desc
+               deriving (Show, Eq, Typeable, Data)
+ 
+data Distinct = Distinct
+              | Dupes
+              deriving (Show, Eq, Typeable, Data)
+ 
+data Natural = Natural
+             | Unnatural
+             deriving (Show, Eq, Typeable, Data)
+ 
+data IfExists = Require
+              | IfExists
+              deriving (Show, Eq, Typeable, Data)
+ 
+data Replace = Replace
+             | NoReplace
+             deriving (Show, Eq, Typeable, Data)
+ 
+data RestartIdentity = RestartIdentity
+                     | ContinueIdentity
+                     deriving (Show, Eq, Typeable, Data)
+ 
+data LiftFlavour = LiftAny
+                 | LiftAll
+                 deriving (Show, Eq, Typeable, Data)
+ 
+data IntervalField = IntervalYear
+                   | IntervalMonth
+                   | IntervalDay
+                   | IntervalHour
+                   | IntervalMinute
+                   | IntervalSecond
+                   | IntervalYearToMonth
+                   | IntervalDayToHour
+                   | IntervalDayToMinute
+                   | IntervalDayToSecond
+                   | IntervalHourToMinute
+                   | IntervalHourToSecond
+                   | IntervalMinuteToSecond
+                   deriving (Show, Eq, Typeable, Data)
+ 
+data ExtractField = ExtractCentury
+                  | ExtractDay
+                  | ExtractDecade
+                  | ExtractDow
+                  | ExtractDoy
+                  | ExtractEpoch
+                  | ExtractHour
+                  | ExtractIsodow
+                  | ExtractIsoyear
+                  | ExtractMicroseconds
+                  | ExtractMillennium
+                  | ExtractMilliseconds
+                  | ExtractMinute
+                  | ExtractMonth
+                  | ExtractQuarter
+                  | ExtractSecond
+                  | ExtractTimezone
+                  | ExtractTimezoneHour
+                  | ExtractTimezoneMinute
+                  | ExtractWeek
+                  | ExtractYear
+                  deriving (Show, Eq, Typeable, Data)
+ 
+data FrameClause = FrameUnboundedPreceding
+                 | FrameUnboundedFull
+                 | FrameRowsUnboundedPreceding
+                 deriving (Show, Eq, Typeable, Data)
+ 
+data AlterTableAction = AddConstraint Annotation Constraint
+                      | AlterColumnDefault Annotation String ScalarExpr
+                      deriving (Data, Eq, Show, Typeable)
+ 
+data AttributeDef = AttributeDef Annotation String TypeName
+                                 MaybeScalarExpr RowConstraintList
+                  deriving (Data, Eq, Show, Typeable)
+ 
+data Constraint = CheckConstraint Annotation String ScalarExpr
+                | PrimaryKeyConstraint Annotation String [String]
+                | ReferenceConstraint Annotation String [String] String [String]
+                                      Cascade Cascade
+                | UniqueConstraint Annotation String [String]
+                deriving (Data, Eq, Show, Typeable)
+ 
+data FnBody = PlpgsqlFnBody Annotation Statement
+            | SqlFnBody Annotation StatementList
+            deriving (Data, Eq, Show, Typeable)
+ 
+data InList = InList Annotation ScalarExprList
+            | InQueryExpr Annotation QueryExpr
+            deriving (Data, Eq, Show, Typeable)
+ 
+data JoinExpr = JoinOn Annotation ScalarExpr
+              | JoinUsing Annotation [String]
+              deriving (Data, Eq, Show, Typeable)
+ 
+data ParamDef = ParamDef Annotation String TypeName
+              | ParamDefTp Annotation TypeName
+              deriving (Data, Eq, Show, Typeable)
+ 
+data QueryExpr = CombineQueryExpr Annotation CombineType QueryExpr
+                                  QueryExpr
+               | Select Annotation Distinct SelectList TableRefList MaybeBoolExpr
+                        ScalarExprList MaybeBoolExpr ScalarExprDirectionPairList
+                        MaybeScalarExpr MaybeScalarExpr
+               | Values Annotation ScalarExprListList
+               | WithQueryExpr Annotation WithQueryList QueryExpr
+               deriving (Data, Eq, Show, Typeable)
+ 
+data RowConstraint = NotNullConstraint Annotation String
+                   | NullConstraint Annotation String
+                   | RowCheckConstraint Annotation String ScalarExpr
+                   | RowPrimaryKeyConstraint Annotation String
+                   | RowReferenceConstraint Annotation String String (Maybe String)
+                                            Cascade Cascade
+                   | RowUniqueConstraint Annotation String
+                   deriving (Data, Eq, Show, Typeable)
+ 
+data SQIdentifier = SQIdentifier Annotation [String]
+                  deriving (Data, Eq, Show, Typeable)
+ 
+data ScalarExpr = BooleanLit Annotation Bool
+                | Case Annotation CaseScalarExprListScalarExprPairList
+                       MaybeScalarExpr
+                | CaseSimple Annotation ScalarExpr
+                             CaseScalarExprListScalarExprPairList MaybeScalarExpr
+                | Cast Annotation ScalarExpr TypeName
+                | Exists Annotation QueryExpr
+                | Extract Annotation ExtractField ScalarExpr
+                | FunCall Annotation String ScalarExprList
+                | Identifier Annotation String
+                | InPredicate Annotation ScalarExpr Bool InList
+                | Interval Annotation String IntervalField (Maybe Int)
+                | LiftOperator Annotation String LiftFlavour ScalarExprList
+                | NullLit Annotation
+                | NumberLit Annotation String
+                | Placeholder Annotation
+                | PositionalArg Annotation Integer
+                | QIdentifier Annotation ScalarExpr String
+                | ScalarSubQuery Annotation QueryExpr
+                | StringLit Annotation String
+                | TypedStringLit Annotation TypeName String
+                | WindowFn Annotation ScalarExpr ScalarExprList ScalarExprList
+                           Direction FrameClause
+                | AntiScalarExpr String
+                deriving (Data, Eq, Show, Typeable)
+ 
+data SelectItem = SelExp Annotation ScalarExpr
+                | SelectItem Annotation ScalarExpr String
+                deriving (Data, Eq, Show, Typeable)
+ 
+data SelectList = SelectList Annotation SelectItemList
+                deriving (Data, Eq, Show, Typeable)
+ 
+data Statement = AlterSequence Annotation String SQIdentifier
+               | AlterTable Annotation String AlterTableActionList
+               | Assignment Annotation ScalarExpr ScalarExpr
+               | Block Annotation (Maybe String) VarDefList StatementList
+               | CaseStatement Annotation ScalarExprListStatementListPairList
+                               StatementList
+               | CaseStatementSimple Annotation ScalarExpr
+                                     ScalarExprListStatementListPairList StatementList
+               | ContinueStatement Annotation (Maybe String)
+               | Copy Annotation String [String] CopySource
+               | CopyData Annotation String
+               | CreateDomain Annotation String TypeName String MaybeBoolExpr
+               | CreateFunction Annotation String ParamDefList TypeName Replace
+                                Language FnBody Volatility
+               | CreateLanguage Annotation String
+               | CreateSequence Annotation String Integer Integer Integer Integer
+                                Integer
+               | CreateTable Annotation String AttributeDefList ConstraintList
+               | CreateTableAs Annotation String QueryExpr
+               | CreateTrigger Annotation String TriggerWhen [TriggerEvent] String
+                               TriggerFire String ScalarExprList
+               | CreateType Annotation String TypeAttributeDefList
+               | CreateView Annotation String (Maybe [String]) QueryExpr
+               | Delete Annotation SQIdentifier TableRefList MaybeBoolExpr
+                        MaybeSelectList
+               | DropFunction Annotation IfExists StringTypeNameListPairList
+                              Cascade
+               | DropSomething Annotation DropType IfExists [String] Cascade
+               | Execute Annotation ScalarExpr
+               | ExitStatement Annotation (Maybe String)
+               | ForIntegerStatement Annotation (Maybe String) ScalarExpr
+                                     ScalarExpr ScalarExpr StatementList
+               | ForQueryStatement Annotation (Maybe String) ScalarExpr QueryExpr
+                                   StatementList
+               | If Annotation ScalarExprStatementListPairList StatementList
+               | Insert Annotation SQIdentifier [String] QueryExpr MaybeSelectList
+               | Into Annotation Bool ScalarExprList Statement
+               | LoopStatement Annotation (Maybe String) StatementList
+               | Notify Annotation String
+               | NullStatement Annotation
+               | Perform Annotation ScalarExpr
+               | QueryStatement Annotation QueryExpr
+               | Raise Annotation RaiseType String ScalarExprList
+               | Return Annotation MaybeScalarExpr
+               | ReturnNext Annotation ScalarExpr
+               | ReturnQuery Annotation QueryExpr
+               | Set Annotation String [SetValue]
+               | Truncate Annotation [String] RestartIdentity Cascade
+               | Update Annotation SQIdentifier ScalarExprList TableRefList
+                        MaybeBoolExpr MaybeSelectList
+               | WhileStatement Annotation (Maybe String) ScalarExpr StatementList
+               | AntiStatement String
+               deriving (Data, Eq, Show, Typeable)
+ 
+data TableAlias = FullAlias Annotation String [String]
+                | NoAlias Annotation
+                | TableAlias Annotation String
+                deriving (Data, Eq, Show, Typeable)
+ 
+data TableRef = FunTref Annotation ScalarExpr TableAlias
+              | JoinTref Annotation TableRef Natural JoinType TableRef OnExpr
+                         TableAlias
+              | SubTref Annotation QueryExpr TableAlias
+              | Tref Annotation SQIdentifier TableAlias
+              deriving (Data, Eq, Show, Typeable)
+ 
+data TypeAttributeDef = TypeAttDef Annotation String TypeName
+                      deriving (Data, Eq, Show, Typeable)
+ 
+data TypeName = ArrayTypeName Annotation TypeName
+              | Prec2TypeName Annotation String Integer Integer
+              | PrecTypeName Annotation String Integer
+              | SetOfTypeName Annotation TypeName
+              | SimpleTypeName Annotation String
+              deriving (Data, Eq, Show, Typeable)
+ 
+data VarDef = ParamAlias Annotation String Integer
+            | VarAlias Annotation String String
+            | VarDef Annotation String TypeName (Maybe ScalarExpr)
+            deriving (Data, Eq, Show, Typeable)
+ 
+data WithQuery = WithQuery Annotation String (Maybe [String])
+                           QueryExpr
+               deriving (Data, Eq, Show, Typeable)
+ 
+type AlterTableActionList = [AlterTableAction]
+ 
+type AttributeDefList = [AttributeDef]
+ 
+type CaseScalarExprListScalarExprPair =
+     (ScalarExprList, ScalarExpr)
+ 
+type CaseScalarExprListScalarExprPairList =
+     [CaseScalarExprListScalarExprPair]
+ 
+type ConstraintList = [Constraint]
+ 
+type MaybeBoolExpr = Maybe ScalarExpr
+ 
+type MaybeScalarExpr = Maybe ScalarExpr
+ 
+type MaybeSelectList = Maybe SelectList
+ 
+type OnExpr = Maybe JoinExpr
+ 
+type ParamDefList = [ParamDef]
+ 
+type RowConstraintList = [RowConstraint]
+ 
+type ScalarExprDirectionPair = (ScalarExpr, Direction)
+ 
+type ScalarExprDirectionPairList = [ScalarExprDirectionPair]
+ 
+type ScalarExprList = [ScalarExpr]
+ 
+type ScalarExprListList = [ScalarExprList]
+ 
+type ScalarExprListStatementListPair =
+     (ScalarExprList, StatementList)
+ 
+type ScalarExprListStatementListPairList =
+     [ScalarExprListStatementListPair]
+ 
+type ScalarExprStatementListPair = (ScalarExpr, StatementList)
+ 
+type ScalarExprStatementListPairList =
+     [ScalarExprStatementListPair]
+ 
+type SelectItemList = [SelectItem]
+ 
+type StatementList = [Statement]
+ 
+type StringTypeNameListPair = (String, TypeNameList)
+ 
+type StringTypeNameListPairList = [StringTypeNameListPair]
+ 
+type TableRefList = [TableRef]
+ 
+type TypeAttributeDefList = [TypeAttributeDef]
+ 
+type TypeNameList = [TypeName]
+ 
+type VarDefList = [VarDef]
+ 
+type WithQueryList = [WithQuery]
+ 
+joinType :: JoinType -> A.JoinType
+joinType x
+  = case x of
+        Inner -> A.Inner
+        LeftOuter -> A.LeftOuter
+        RightOuter -> A.RightOuter
+        FullOuter -> A.FullOuter
+        Cross -> A.Cross
+ 
+copySource :: CopySource -> A.CopySource
+copySource x
+  = case x of
+        CopyFilename a1 -> A.CopyFilename a1
+        Stdin -> A.Stdin
+ 
+setValue :: SetValue -> A.SetValue
+setValue x
+  = case x of
+        SetStr a1 a2 -> A.SetStr a1 a2
+        SetId a1 a2 -> A.SetId a1 a2
+        SetNum a1 a2 -> A.SetNum a1 a2
+ 
+triggerWhen :: TriggerWhen -> A.TriggerWhen
+triggerWhen x
+  = case x of
+        TriggerBefore -> A.TriggerBefore
+        TriggerAfter -> A.TriggerAfter
+ 
+triggerEvent :: TriggerEvent -> A.TriggerEvent
+triggerEvent x
+  = case x of
+        TInsert -> A.TInsert
+        TUpdate -> A.TUpdate
+        TDelete -> A.TDelete
+        AntiTriggerEvent _ -> error "can't convert anti triggerEvent"
+ 
+triggerFire :: TriggerFire -> A.TriggerFire
+triggerFire x
+  = case x of
+        EachRow -> A.EachRow
+        EachStatement -> A.EachStatement
+ 
+raiseType :: RaiseType -> A.RaiseType
+raiseType x
+  = case x of
+        RNotice -> A.RNotice
+        RException -> A.RException
+        RError -> A.RError
+ 
+combineType :: CombineType -> A.CombineType
+combineType x
+  = case x of
+        Except -> A.Except
+        Union -> A.Union
+        Intersect -> A.Intersect
+        UnionAll -> A.UnionAll
+ 
+volatility :: Volatility -> A.Volatility
+volatility x
+  = case x of
+        Volatile -> A.Volatile
+        Stable -> A.Stable
+        Immutable -> A.Immutable
+ 
+language :: Language -> A.Language
+language x
+  = case x of
+        Sql -> A.Sql
+        Plpgsql -> A.Plpgsql
+ 
+dropType :: DropType -> A.DropType
+dropType x
+  = case x of
+        Table -> A.Table
+        Domain -> A.Domain
+        View -> A.View
+        Type -> A.Type
+ 
+cascade :: Cascade -> A.Cascade
+cascade x
+  = case x of
+        Cascade -> A.Cascade
+        Restrict -> A.Restrict
+ 
+direction :: Direction -> A.Direction
+direction x
+  = case x of
+        Asc -> A.Asc
+        Desc -> A.Desc
+ 
+distinct :: Distinct -> A.Distinct
+distinct x
+  = case x of
+        Distinct -> A.Distinct
+        Dupes -> A.Dupes
+ 
+natural :: Natural -> A.Natural
+natural x
+  = case x of
+        Natural -> A.Natural
+        Unnatural -> A.Unnatural
+ 
+ifExists :: IfExists -> A.IfExists
+ifExists x
+  = case x of
+        Require -> A.Require
+        IfExists -> A.IfExists
+ 
+replace :: Replace -> A.Replace
+replace x
+  = case x of
+        Replace -> A.Replace
+        NoReplace -> A.NoReplace
+ 
+restartIdentity :: RestartIdentity -> A.RestartIdentity
+restartIdentity x
+  = case x of
+        RestartIdentity -> A.RestartIdentity
+        ContinueIdentity -> A.ContinueIdentity
+ 
+liftFlavour :: LiftFlavour -> A.LiftFlavour
+liftFlavour x
+  = case x of
+        LiftAny -> A.LiftAny
+        LiftAll -> A.LiftAll
+ 
+intervalField :: IntervalField -> A.IntervalField
+intervalField x
+  = case x of
+        IntervalYear -> A.IntervalYear
+        IntervalMonth -> A.IntervalMonth
+        IntervalDay -> A.IntervalDay
+        IntervalHour -> A.IntervalHour
+        IntervalMinute -> A.IntervalMinute
+        IntervalSecond -> A.IntervalSecond
+        IntervalYearToMonth -> A.IntervalYearToMonth
+        IntervalDayToHour -> A.IntervalDayToHour
+        IntervalDayToMinute -> A.IntervalDayToMinute
+        IntervalDayToSecond -> A.IntervalDayToSecond
+        IntervalHourToMinute -> A.IntervalHourToMinute
+        IntervalHourToSecond -> A.IntervalHourToSecond
+        IntervalMinuteToSecond -> A.IntervalMinuteToSecond
+ 
+extractField :: ExtractField -> A.ExtractField
+extractField x
+  = case x of
+        ExtractCentury -> A.ExtractCentury
+        ExtractDay -> A.ExtractDay
+        ExtractDecade -> A.ExtractDecade
+        ExtractDow -> A.ExtractDow
+        ExtractDoy -> A.ExtractDoy
+        ExtractEpoch -> A.ExtractEpoch
+        ExtractHour -> A.ExtractHour
+        ExtractIsodow -> A.ExtractIsodow
+        ExtractIsoyear -> A.ExtractIsoyear
+        ExtractMicroseconds -> A.ExtractMicroseconds
+        ExtractMillennium -> A.ExtractMillennium
+        ExtractMilliseconds -> A.ExtractMilliseconds
+        ExtractMinute -> A.ExtractMinute
+        ExtractMonth -> A.ExtractMonth
+        ExtractQuarter -> A.ExtractQuarter
+        ExtractSecond -> A.ExtractSecond
+        ExtractTimezone -> A.ExtractTimezone
+        ExtractTimezoneHour -> A.ExtractTimezoneHour
+        ExtractTimezoneMinute -> A.ExtractTimezoneMinute
+        ExtractWeek -> A.ExtractWeek
+        ExtractYear -> A.ExtractYear
+ 
+frameClause :: FrameClause -> A.FrameClause
+frameClause x
+  = case x of
+        FrameUnboundedPreceding -> A.FrameUnboundedPreceding
+        FrameUnboundedFull -> A.FrameUnboundedFull
+        FrameRowsUnboundedPreceding -> A.FrameRowsUnboundedPreceding
+ 
+alterTableAction :: AlterTableAction -> A.AlterTableAction
+alterTableAction x
+  = case x of
+        AddConstraint a1 a2 -> A.AddConstraint a1 (constraint a2)
+        AlterColumnDefault a1 a2 a3 -> A.AlterColumnDefault a1 a2
+                                         (scalarExpr a3)
+ 
+attributeDef :: AttributeDef -> A.AttributeDef
+attributeDef x
+  = case x of
+        AttributeDef a1 a2 a3 a4 a5 -> A.AttributeDef a1 a2 (typeName a3)
+                                         (maybeScalarExpr a4)
+                                         (rowConstraintList a5)
+ 
+constraint :: Constraint -> A.Constraint
+constraint x
+  = case x of
+        CheckConstraint a1 a2 a3 -> A.CheckConstraint a1 a2 (scalarExpr a3)
+        PrimaryKeyConstraint a1 a2 a3 -> A.PrimaryKeyConstraint a1 a2 a3
+        ReferenceConstraint a1 a2 a3 a4 a5 a6 a7 -> A.ReferenceConstraint
+                                                      a1
+                                                      a2
+                                                      a3
+                                                      a4
+                                                      a5
+                                                      (cascade a6)
+                                                      (cascade a7)
+        UniqueConstraint a1 a2 a3 -> A.UniqueConstraint a1 a2 a3
+ 
+fnBody :: FnBody -> A.FnBody
+fnBody x
+  = case x of
+        PlpgsqlFnBody a1 a2 -> A.PlpgsqlFnBody a1 (statement a2)
+        SqlFnBody a1 a2 -> A.SqlFnBody a1 (statementList a2)
+ 
+inList :: InList -> A.InList
+inList x
+  = case x of
+        InList a1 a2 -> A.InList a1 (scalarExprList a2)
+        InQueryExpr a1 a2 -> A.InQueryExpr a1 (queryExpr a2)
+ 
+joinExpr :: JoinExpr -> A.JoinExpr
+joinExpr x
+  = case x of
+        JoinOn a1 a2 -> A.JoinOn a1 (scalarExpr a2)
+        JoinUsing a1 a2 -> A.JoinUsing a1 a2
+ 
+paramDef :: ParamDef -> A.ParamDef
+paramDef x
+  = case x of
+        ParamDef a1 a2 a3 -> A.ParamDef a1 a2 (typeName a3)
+        ParamDefTp a1 a2 -> A.ParamDefTp a1 (typeName a2)
+ 
+queryExpr :: QueryExpr -> A.QueryExpr
+queryExpr x
+  = case x of
+        CombineQueryExpr a1 a2 a3 a4 -> A.CombineQueryExpr a1
+                                          (combineType a2)
+                                          (queryExpr a3)
+                                          (queryExpr a4)
+        Select a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 -> A.Select a1 (distinct a2)
+                                                   (selectList a3)
+                                                   (tableRefList a4)
+                                                   (maybeBoolExpr a5)
+                                                   (scalarExprList a6)
+                                                   (maybeBoolExpr a7)
+                                                   (scalarExprDirectionPairList a8)
+                                                   (maybeScalarExpr a9)
+                                                   (maybeScalarExpr a10)
+        Values a1 a2 -> A.Values a1 (scalarExprListList a2)
+        WithQueryExpr a1 a2 a3 -> A.WithQueryExpr a1 (withQueryList a2)
+                                    (queryExpr a3)
+ 
+rowConstraint :: RowConstraint -> A.RowConstraint
+rowConstraint x
+  = case x of
+        NotNullConstraint a1 a2 -> A.NotNullConstraint a1 a2
+        NullConstraint a1 a2 -> A.NullConstraint a1 a2
+        RowCheckConstraint a1 a2 a3 -> A.RowCheckConstraint a1 a2
+                                         (scalarExpr a3)
+        RowPrimaryKeyConstraint a1 a2 -> A.RowPrimaryKeyConstraint a1 a2
+        RowReferenceConstraint a1 a2 a3 a4 a5
+          a6 -> A.RowReferenceConstraint a1 a2 a3 a4 (cascade a5)
+                  (cascade a6)
+        RowUniqueConstraint a1 a2 -> A.RowUniqueConstraint a1 a2
+ 
+sQIdentifier :: SQIdentifier -> A.SQIdentifier
+sQIdentifier x
+  = case x of
+        SQIdentifier a1 a2 -> A.SQIdentifier a1 a2
+ 
+scalarExpr :: ScalarExpr -> A.ScalarExpr
+scalarExpr x
+  = case x of
+        BooleanLit a1 a2 -> A.BooleanLit a1 a2
+        Case a1 a2 a3 -> A.Case a1
+                           (caseScalarExprListScalarExprPairList a2)
+                           (maybeScalarExpr a3)
+        CaseSimple a1 a2 a3 a4 -> A.CaseSimple a1 (scalarExpr a2)
+                                    (caseScalarExprListScalarExprPairList a3)
+                                    (maybeScalarExpr a4)
+        Cast a1 a2 a3 -> A.Cast a1 (scalarExpr a2) (typeName a3)
+        Exists a1 a2 -> A.Exists a1 (queryExpr a2)
+        Extract a1 a2 a3 -> A.Extract a1 (extractField a2) (scalarExpr a3)
+        FunCall a1 a2 a3 -> A.FunCall a1 a2 (scalarExprList a3)
+        Identifier a1 a2 -> A.Identifier a1 a2
+        InPredicate a1 a2 a3 a4 -> A.InPredicate a1 (scalarExpr a2) a3
+                                     (inList a4)
+        Interval a1 a2 a3 a4 -> A.Interval a1 a2 (intervalField a3) a4
+        LiftOperator a1 a2 a3 a4 -> A.LiftOperator a1 a2 (liftFlavour a3)
+                                      (scalarExprList a4)
+        NullLit a1 -> A.NullLit a1
+        NumberLit a1 a2 -> A.NumberLit a1 a2
+        Placeholder a1 -> A.Placeholder a1
+        PositionalArg a1 a2 -> A.PositionalArg a1 a2
+        QIdentifier a1 a2 a3 -> A.QIdentifier a1 (scalarExpr a2) a3
+        ScalarSubQuery a1 a2 -> A.ScalarSubQuery a1 (queryExpr a2)
+        StringLit a1 a2 -> A.StringLit a1 a2
+        TypedStringLit a1 a2 a3 -> A.TypedStringLit a1 (typeName a2) a3
+        WindowFn a1 a2 a3 a4 a5 a6 -> A.WindowFn a1 (scalarExpr a2)
+                                        (scalarExprList a3)
+                                        (scalarExprList a4)
+                                        (direction a5)
+                                        (frameClause a6)
+        AntiScalarExpr _ -> error "can't convert anti scalarExpr"
+ 
+selectItem :: SelectItem -> A.SelectItem
+selectItem x
+  = case x of
+        SelExp a1 a2 -> A.SelExp a1 (scalarExpr a2)
+        SelectItem a1 a2 a3 -> A.SelectItem a1 (scalarExpr a2) a3
+ 
+selectList :: SelectList -> A.SelectList
+selectList x
+  = case x of
+        SelectList a1 a2 -> A.SelectList a1 (selectItemList a2)
+ 
+statement :: Statement -> A.Statement
+statement x
+  = case x of
+        AlterSequence a1 a2 a3 -> A.AlterSequence a1 a2 (sQIdentifier a3)
+        AlterTable a1 a2 a3 -> A.AlterTable a1 a2 (alterTableActionList a3)
+        Assignment a1 a2 a3 -> A.Assignment a1 (scalarExpr a2)
+                                 (scalarExpr a3)
+        Block a1 a2 a3 a4 -> A.Block a1 a2 (varDefList a3)
+                               (statementList a4)
+        CaseStatement a1 a2 a3 -> A.CaseStatement a1
+                                    (scalarExprListStatementListPairList a2)
+                                    (statementList a3)
+        CaseStatementSimple a1 a2 a3 a4 -> A.CaseStatementSimple a1
+                                             (scalarExpr a2)
+                                             (scalarExprListStatementListPairList a3)
+                                             (statementList a4)
+        ContinueStatement a1 a2 -> A.ContinueStatement a1 a2
+        Copy a1 a2 a3 a4 -> A.Copy a1 a2 a3 (copySource a4)
+        CopyData a1 a2 -> A.CopyData a1 a2
+        CreateDomain a1 a2 a3 a4 a5 -> A.CreateDomain a1 a2 (typeName a3)
+                                         a4
+                                         (maybeBoolExpr a5)
+        CreateFunction a1 a2 a3 a4 a5 a6 a7 a8 -> A.CreateFunction a1 a2
+                                                    (paramDefList a3)
+                                                    (typeName a4)
+                                                    (replace a5)
+                                                    (language a6)
+                                                    (fnBody a7)
+                                                    (volatility a8)
+        CreateLanguage a1 a2 -> A.CreateLanguage a1 a2
+        CreateSequence a1 a2 a3 a4 a5 a6 a7 -> A.CreateSequence a1 a2 a3 a4
+                                                 a5
+                                                 a6
+                                                 a7
+        CreateTable a1 a2 a3 a4 -> A.CreateTable a1 a2
+                                     (attributeDefList a3)
+                                     (constraintList a4)
+        CreateTableAs a1 a2 a3 -> A.CreateTableAs a1 a2 (queryExpr a3)
+        CreateTrigger a1 a2 a3 a4 a5 a6 a7 a8 -> A.CreateTrigger a1 a2
+                                                   (triggerWhen a3)
+                                                   (fmap triggerEvent a4)
+                                                   a5
+                                                   (triggerFire a6)
+                                                   a7
+                                                   (scalarExprList a8)
+        CreateType a1 a2 a3 -> A.CreateType a1 a2 (typeAttributeDefList a3)
+        CreateView a1 a2 a3 a4 -> A.CreateView a1 a2 a3 (queryExpr a4)
+        Delete a1 a2 a3 a4 a5 -> A.Delete a1 (sQIdentifier a2)
+                                   (tableRefList a3)
+                                   (maybeBoolExpr a4)
+                                   (maybeSelectList a5)
+        DropFunction a1 a2 a3 a4 -> A.DropFunction a1 (ifExists a2)
+                                      (stringTypeNameListPairList a3)
+                                      (cascade a4)
+        DropSomething a1 a2 a3 a4 a5 -> A.DropSomething a1 (dropType a2)
+                                          (ifExists a3)
+                                          a4
+                                          (cascade a5)
+        Execute a1 a2 -> A.Execute a1 (scalarExpr a2)
+        ExitStatement a1 a2 -> A.ExitStatement a1 a2
+        ForIntegerStatement a1 a2 a3 a4 a5 a6 -> A.ForIntegerStatement a1
+                                                   a2
+                                                   (scalarExpr a3)
+                                                   (scalarExpr a4)
+                                                   (scalarExpr a5)
+                                                   (statementList a6)
+        ForQueryStatement a1 a2 a3 a4 a5 -> A.ForQueryStatement a1 a2
+                                              (scalarExpr a3)
+                                              (queryExpr a4)
+                                              (statementList a5)
+        If a1 a2 a3 -> A.If a1 (scalarExprStatementListPairList a2)
+                         (statementList a3)
+        Insert a1 a2 a3 a4 a5 -> A.Insert a1 (sQIdentifier a2) a3
+                                   (queryExpr a4)
+                                   (maybeSelectList a5)
+        Into a1 a2 a3 a4 -> A.Into a1 a2 (scalarExprList a3) (statement a4)
+        LoopStatement a1 a2 a3 -> A.LoopStatement a1 a2 (statementList a3)
+        Notify a1 a2 -> A.Notify a1 a2
+        NullStatement a1 -> A.NullStatement a1
+        Perform a1 a2 -> A.Perform a1 (scalarExpr a2)
+        QueryStatement a1 a2 -> A.QueryStatement a1 (queryExpr a2)
+        Raise a1 a2 a3 a4 -> A.Raise a1 (raiseType a2) a3
+                               (scalarExprList a4)
+        Return a1 a2 -> A.Return a1 (maybeScalarExpr a2)
+        ReturnNext a1 a2 -> A.ReturnNext a1 (scalarExpr a2)
+        ReturnQuery a1 a2 -> A.ReturnQuery a1 (queryExpr a2)
+        Set a1 a2 a3 -> A.Set a1 a2 (fmap setValue a3)
+        Truncate a1 a2 a3 a4 -> A.Truncate a1 a2 (restartIdentity a3)
+                                  (cascade a4)
+        Update a1 a2 a3 a4 a5 a6 -> A.Update a1 (sQIdentifier a2)
+                                      (scalarExprList a3)
+                                      (tableRefList a4)
+                                      (maybeBoolExpr a5)
+                                      (maybeSelectList a6)
+        WhileStatement a1 a2 a3 a4 -> A.WhileStatement a1 a2
+                                        (scalarExpr a3)
+                                        (statementList a4)
+        AntiStatement _ -> error "can't convert anti statement"
+ 
+tableAlias :: TableAlias -> A.TableAlias
+tableAlias x
+  = case x of
+        FullAlias a1 a2 a3 -> A.FullAlias a1 a2 a3
+        NoAlias a1 -> A.NoAlias a1
+        TableAlias a1 a2 -> A.TableAlias a1 a2
+ 
+tableRef :: TableRef -> A.TableRef
+tableRef x
+  = case x of
+        FunTref a1 a2 a3 -> A.FunTref a1 (scalarExpr a2) (tableAlias a3)
+        JoinTref a1 a2 a3 a4 a5 a6 a7 -> A.JoinTref a1 (tableRef a2)
+                                           (natural a3)
+                                           (joinType a4)
+                                           (tableRef a5)
+                                           (onExpr a6)
+                                           (tableAlias a7)
+        SubTref a1 a2 a3 -> A.SubTref a1 (queryExpr a2) (tableAlias a3)
+        Tref a1 a2 a3 -> A.Tref a1 (sQIdentifier a2) (tableAlias a3)
+ 
+typeAttributeDef :: TypeAttributeDef -> A.TypeAttributeDef
+typeAttributeDef x
+  = case x of
+        TypeAttDef a1 a2 a3 -> A.TypeAttDef a1 a2 (typeName a3)
+ 
+typeName :: TypeName -> A.TypeName
+typeName x
+  = case x of
+        ArrayTypeName a1 a2 -> A.ArrayTypeName a1 (typeName a2)
+        Prec2TypeName a1 a2 a3 a4 -> A.Prec2TypeName a1 a2 a3 a4
+        PrecTypeName a1 a2 a3 -> A.PrecTypeName a1 a2 a3
+        SetOfTypeName a1 a2 -> A.SetOfTypeName a1 (typeName a2)
+        SimpleTypeName a1 a2 -> A.SimpleTypeName a1 a2
+ 
+varDef :: VarDef -> A.VarDef
+varDef x
+  = case x of
+        ParamAlias a1 a2 a3 -> A.ParamAlias a1 a2 a3
+        VarAlias a1 a2 a3 -> A.VarAlias a1 a2 a3
+        VarDef a1 a2 a3 a4 -> A.VarDef a1 a2 (typeName a3)
+                                (maybeScalarExpr a4)
+ 
+withQuery :: WithQuery -> A.WithQuery
+withQuery x
+  = case x of
+        WithQuery a1 a2 a3 a4 -> A.WithQuery a1 a2 a3 (queryExpr a4)
+ 
+alterTableActionList ::
+                     AlterTableActionList -> A.AlterTableActionList
+alterTableActionList = fmap alterTableAction
+ 
+attributeDefList :: AttributeDefList -> A.AttributeDefList
+attributeDefList = fmap attributeDef
+ 
+caseScalarExprListScalarExprPair ::
+                                 CaseScalarExprListScalarExprPair ->
+                                   A.CaseScalarExprListScalarExprPair
+caseScalarExprListScalarExprPair (a, b)
+  = (scalarExprList a, scalarExpr b)
+ 
+caseScalarExprListScalarExprPairList ::
+                                     CaseScalarExprListScalarExprPairList ->
+                                       A.CaseScalarExprListScalarExprPairList
+caseScalarExprListScalarExprPairList
+  = fmap caseScalarExprListScalarExprPair
+ 
+constraintList :: ConstraintList -> A.ConstraintList
+constraintList = fmap constraint
+ 
+maybeBoolExpr :: MaybeBoolExpr -> A.MaybeBoolExpr
+maybeBoolExpr = fmap scalarExpr
+ 
+maybeScalarExpr :: MaybeScalarExpr -> A.MaybeScalarExpr
+maybeScalarExpr = fmap scalarExpr
+ 
+maybeSelectList :: MaybeSelectList -> A.MaybeSelectList
+maybeSelectList = fmap selectList
+ 
+onExpr :: OnExpr -> A.OnExpr
+onExpr = fmap joinExpr
+ 
+paramDefList :: ParamDefList -> A.ParamDefList
+paramDefList = fmap paramDef
+ 
+rowConstraintList :: RowConstraintList -> A.RowConstraintList
+rowConstraintList = fmap rowConstraint
+ 
+scalarExprDirectionPair ::
+                        ScalarExprDirectionPair -> A.ScalarExprDirectionPair
+scalarExprDirectionPair (a, b) = (scalarExpr a, direction b)
+ 
+scalarExprDirectionPairList ::
+                            ScalarExprDirectionPairList -> A.ScalarExprDirectionPairList
+scalarExprDirectionPairList = fmap scalarExprDirectionPair
+ 
+scalarExprList :: ScalarExprList -> A.ScalarExprList
+scalarExprList = fmap scalarExpr
+ 
+scalarExprListList :: ScalarExprListList -> A.ScalarExprListList
+scalarExprListList = fmap scalarExprList
+ 
+scalarExprListStatementListPair ::
+                                ScalarExprListStatementListPair ->
+                                  A.ScalarExprListStatementListPair
+scalarExprListStatementListPair (a, b)
+  = (scalarExprList a, statementList b)
+ 
+scalarExprListStatementListPairList ::
+                                    ScalarExprListStatementListPairList ->
+                                      A.ScalarExprListStatementListPairList
+scalarExprListStatementListPairList
+  = fmap scalarExprListStatementListPair
+ 
+scalarExprStatementListPair ::
+                            ScalarExprStatementListPair -> A.ScalarExprStatementListPair
+scalarExprStatementListPair (a, b)
+  = (scalarExpr a, statementList b)
+ 
+scalarExprStatementListPairList ::
+                                ScalarExprStatementListPairList ->
+                                  A.ScalarExprStatementListPairList
+scalarExprStatementListPairList = fmap scalarExprStatementListPair
+ 
+selectItemList :: SelectItemList -> A.SelectItemList
+selectItemList = fmap selectItem
+ 
+statementList :: StatementList -> A.StatementList
+statementList = fmap statement
+ 
+stringTypeNameListPair ::
+                       StringTypeNameListPair -> A.StringTypeNameListPair
+stringTypeNameListPair (a, b) = (a, typeNameList b)
+ 
+stringTypeNameListPairList ::
+                           StringTypeNameListPairList -> A.StringTypeNameListPairList
+stringTypeNameListPairList = fmap stringTypeNameListPair
+ 
+tableRefList :: TableRefList -> A.TableRefList
+tableRefList = fmap tableRef
+ 
+typeAttributeDefList ::
+                     TypeAttributeDefList -> A.TypeAttributeDefList
+typeAttributeDefList = fmap typeAttributeDef
+ 
+typeNameList :: TypeNameList -> A.TypeNameList
+typeNameList = fmap typeName
+ 
+varDefList :: VarDefList -> A.VarDefList
+varDefList = fmap varDef
+ 
+withQueryList :: WithQueryList -> A.WithQueryList
+withQueryList = fmap withQuery
diff --git a/src/Database/HsSqlPpp/AstInternals/AstInternal.hs b/src/Database/HsSqlPpp/AstInternals/AstInternal.hs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/AstInternal.hs
@@ -0,0 +1,14400 @@
+
+
+-- UUAGC 0.9.38.1 (AstInternal.ag)
+module Database.HsSqlPpp.AstInternals.AstInternal(
+    -- {-# LANGUAGE DeriveDataTypeable,RankNTypes,ScopedTypeVariables #-}
+    --from the ag files:
+    --ast nodes
+    Statement (..)
+   ,QueryExpr (..)
+   ,WithQueryList
+   ,WithQuery(..)
+   ,FnBody (..)
+   --,SetClause (..)
+   ,TableRef (..)
+   ,TableAlias(..)
+   ,JoinExpr (..)
+   ,JoinType (..)
+   ,SelectList (..)
+   ,SelectItem (..)
+   ,CopySource (..)
+   ,AttributeDef (..)
+   ,RowConstraint (..)
+   ,AlterTableAction(..)
+   ,Constraint (..)
+   ,TypeAttributeDef (..)
+   ,ParamDef (..)
+   ,VarDef (..)
+   ,RaiseType (..)
+   ,CombineType (..)
+   ,Volatility (..)
+   ,Language (..)
+   ,TypeName (..)
+   ,DropType (..)
+   ,Cascade (..)
+   ,Direction (..)
+   ,Distinct (..)
+   ,Natural (..)
+   ,IfExists (..)
+   ,Replace(..)
+   ,RestartIdentity (..)
+   ,ScalarExpr (..)
+   ,SQIdentifier(..)
+   ,IntervalField(..)
+   ,ExtractField(..)
+   ,FrameClause(..)
+   ,InList (..)
+   ,LiftFlavour(..)
+   ,TriggerWhen(..)
+   ,TriggerEvent(..)
+   ,TriggerFire(..)
+   ,StatementList
+   ,ScalarExprListStatementListPairList
+   ,ScalarExprListStatementListPair
+   ,ScalarExprList
+   ,ParamDefList
+   ,AttributeDefList
+   ,ConstraintList
+   ,TypeAttributeDefList
+   ,TypeNameList
+   ,StringTypeNameListPair
+   ,StringTypeNameListPairList
+   ,ScalarExprStatementListPairList
+   --,SetClauseList
+   ,CaseScalarExprListScalarExprPairList
+   ,MaybeScalarExpr
+   ,TableRefList
+   ,ScalarExprListList
+   ,SelectItemList
+   ,OnExpr
+   ,RowConstraintList
+   ,VarDefList
+   ,ScalarExprStatementListPair
+   ,CaseScalarExprListScalarExprPair
+   ,ScalarExprDirectionPair
+   ,ScalarExprDirectionPairList
+   ,MaybeBoolExpr
+   ,MaybeSelectList
+   ,SetValue(..)
+   ,AlterTableActionList
+   -- typechecking
+   ,typeCheckStatements
+   ,typeCheckParameterizedStatement
+   ,typeCheckScalarExpr
+   ,typeCheckQueryExpr
+   ,fixUpIdentifiers
+   ,fixUpIdentifiersQE
+   ,fixUpIdentifiersSE
+) where
+
+import Data.Maybe
+import Data.List
+import Control.Applicative
+import Data.Data
+import Data.Char
+import Control.Monad.State
+import Control.Arrow
+
+import Data.Generics.PlateData
+import Debug.Trace
+
+
+import Database.HsSqlPpp.AstInternals.TypeType
+import Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
+import Database.HsSqlPpp.AstInternals.AstAnnotation
+import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+import Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
+import Database.HsSqlPpp.Utils.Utils
+import Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
+
+
+
+
+
+-- used for schema qualified identifiers
+-- should be used in more places in the ast
+
+
+data JoinType = Inner | LeftOuter| RightOuter | FullOuter | Cross
+                deriving (Show,Eq,Typeable,Data)
+
+
+data CopySource = CopyFilename String
+                | Stdin
+                  deriving (Show,Eq,Typeable,Data)
+
+
+data SetValue
+    = SetStr Annotation String
+    | SetId Annotation String
+    | SetNum Annotation Double
+      deriving (Show,Eq,Typeable,Data)
+
+
+data TriggerWhen = TriggerBefore | TriggerAfter
+                   deriving (Show,Eq,Typeable,Data)
+data TriggerEvent = TInsert| TUpdate | TDelete
+                    deriving (Show,Eq,Typeable,Data)
+data TriggerFire = EachRow | EachStatement
+                   deriving (Show,Eq,Typeable,Data)
+
+
+data RaiseType = RNotice | RException | RError
+                 deriving (Show,Eq,Typeable,Data)
+
+data CombineType = Except | Union | Intersect | UnionAll
+                   deriving (Show,Eq,Typeable,Data)
+
+data Volatility = Volatile | Stable | Immutable
+                  deriving (Show,Eq,Typeable,Data)
+
+data Language = Sql | Plpgsql
+                deriving (Show,Eq,Typeable,Data)
+
+
+data DropType = Table
+              | Domain
+              | View
+              | Type
+                deriving (Show,Eq,Typeable,Data)
+
+data Cascade = Cascade | Restrict
+               deriving (Show,Eq,Typeable,Data)
+
+data Direction = Asc | Desc
+                 deriving (Show,Eq,Typeable,Data)
+
+data Distinct = Distinct | Dupes
+                deriving (Show,Eq,Typeable,Data)
+
+data Natural = Natural | Unnatural
+               deriving (Show,Eq,Typeable,Data)
+
+data IfExists = Require | IfExists
+                deriving (Show,Eq,Typeable,Data)
+
+data Replace = Replace | NoReplace
+               deriving (Show,Eq,Typeable,Data)
+
+data RestartIdentity = RestartIdentity | ContinueIdentity
+                       deriving (Show,Eq,Typeable,Data)
+
+
+
+data LiftFlavour = LiftAny | LiftAll
+                   deriving (Show,Eq,Typeable,Data)
+
+data IntervalField = IntervalYear
+                   | IntervalMonth
+                   | IntervalDay
+                   | IntervalHour
+                   | IntervalMinute
+                   | IntervalSecond
+                   | IntervalYearToMonth
+                   | IntervalDayToHour
+                   | IntervalDayToMinute
+                   | IntervalDayToSecond
+                   | IntervalHourToMinute
+                   | IntervalHourToSecond
+                   | IntervalMinuteToSecond
+                     deriving (Show,Eq,Typeable,Data)
+
+data ExtractField = ExtractCentury
+                  | ExtractDay
+                  | ExtractDecade
+                  | ExtractDow
+                  | ExtractDoy
+                  | ExtractEpoch
+                  | ExtractHour
+                  | ExtractIsodow
+                  | ExtractIsoyear
+                  | ExtractMicroseconds
+                  | ExtractMillennium
+                  | ExtractMilliseconds
+                  | ExtractMinute
+                  | ExtractMonth
+                  | ExtractQuarter
+                  | ExtractSecond
+                  | ExtractTimezone
+                  | ExtractTimezoneHour
+                  | ExtractTimezoneMinute
+                  | ExtractWeek
+                  | ExtractYear
+                    deriving (Show,Eq,Typeable,Data)
+
+
+
+data FrameClause = FrameUnboundedPreceding
+                 | FrameUnboundedFull
+                 | FrameRowsUnboundedPreceding
+                   deriving (Show,Eq,Typeable,Data)
+
+
+-- | 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.
+typeCheckStatements :: Catalog -> [Statement] -> (Catalog,[Statement])
+typeCheckStatements cat sts =
+    let t = sem_Root (Root $ fixUpIdentifiers cat sts)
+        ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
+                                  ,lib_Inh_Root = emptyBindings
+                                  ,idenv_Inh_Root = emptyIDEnv}
+        tl = annotatedTree_Syn_Root ta
+        cat1 = producedCat_Syn_Root ta
+    in case tl of
+         Root r -> (cat1,r)
+
+typeCheckQueryExpr :: Catalog -> QueryExpr -> QueryExpr
+typeCheckQueryExpr cat qe =
+   let (_,[QueryStatement _ qe']) = typeCheckStatements cat [QueryStatement emptyAnnotation qe]
+   in qe'
+
+-- | 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.
+typeCheckParameterizedStatement :: Catalog -> Statement -> Either String Statement
+typeCheckParameterizedStatement cat st =
+    case st of
+      QueryStatement _ _ -> tc
+      Insert _ _ _ _ _ -> tc
+      Update _ _ _ _ _ _ -> tc
+      Delete _ _ _ _ _ -> tc
+      _ -> Left "requires select, update, insert or delete statement"
+    where
+      tc = let t = sem_Root (Root $ fixUpIdentifiers cat [st])
+               ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
+                                         ,lib_Inh_Root = emptyBindings
+                                         ,idenv_Inh_Root = emptyIDEnv}
+               tl = annotatedTree_Syn_Root ta
+               --cat1 = producedCat_Syn_Root ta
+           in case tl of
+                Root [st1] -> Right st1
+                _ -> error "impossible happened in typeCheckPS!"
+
+
+-- | Testing utility, mainly used to check an expression for type errors
+-- or to get its type.
+typeCheckScalarExpr :: Catalog -> ScalarExpr -> ScalarExpr
+typeCheckScalarExpr cat ex =
+    let t = sem_ScalarExprRoot (ScalarExprRoot $ fixUpIdentifiersSE cat ex)
+        rt = (annotatedTree_Syn_ScalarExprRoot
+              (wrap_ScalarExprRoot t Inh_ScalarExprRoot {cat_Inh_ScalarExprRoot = cat
+                                                        ,lib_Inh_ScalarExprRoot = emptyBindings
+                                                        ,idenv_Inh_ScalarExprRoot = emptyIDEnv}))
+    in case rt of
+         ScalarExprRoot e -> e
+
+
+
+
+data IDEnv = IDEnv [(String, [String])]
+             deriving Show
+emptyIDEnv :: IDEnv
+emptyIDEnv = IDEnv []
+
+qualifyID :: IDEnv -> String -> Maybe (String,String)
+qualifyID (IDEnv env) i =
+  q env i
+  where
+    q [] _ = Nothing
+    q ((t,cs):es) i' =
+       if i' `elem` cs
+       then Just (t,i')
+       else q es i'
+
+makeIDEnv :: String -- range qualifier
+          -> [String] -- attribute names
+          -> IDEnv
+makeIDEnv t c = IDEnv [(t,c)]
+
+makeIDEnvP :: [(String,[String])] -> IDEnv
+makeIDEnvP x  = IDEnv x
+
+unimplementedIDEnv :: IDEnv
+unimplementedIDEnv = IDEnv []
+
+joinIDEnvs :: IDEnv -> IDEnv -> IDEnv
+joinIDEnvs (IDEnv a) (IDEnv b) = IDEnv $ a ++ b
+
+expandStar :: IDEnv -> Maybe String --qualifier
+           -> [(String,String)]
+expandStar (IDEnv es) Nothing =
+  flip concatMap es $ \(t,cs) -> map (t,) cs
+expandStar (IDEnv es) (Just t) =
+  maybe [(t,"*")] (map (t,)) $ lookup t es
+
+
+
+
+
+makeSelExps :: Annotation -> Annotation -> Annotation -> [(String,String)] -> [SelectItem]
+makeSelExps sea a0 a1 is =
+  flip map is $ \(q,c) -> addSIAlias $ SelExp sea $ QIdentifier a0 (Identifier a1 q) c
+
+addSIAlias :: SelectItem -> SelectItem
+addSIAlias s@(SelectItem _ _ _) = s
+addSIAlias (SelExp ann ex) = SelectItem ann ex $ getColName ex
+  where
+    getColName (Identifier _ i) = i
+    getColName (QIdentifier _ _ i) = i
+    getColName (FunCall _ f _) | not (isOperatorName f) = f
+    getColName (Cast _ _ (SimpleTypeName _ tn)) = tn
+    getColName (WindowFn _ (FunCall _ f _) _ _ _ _) = f
+    getColName _ = "?column?"
+
+
+
+
+
+
+
+
+-- | transform the tree by converting * to explicit lists of columns and adding qualifiers to all column references
+fixUpIdentifiers :: Catalog -> [Statement] -> [Statement]
+fixUpIdentifiers cat sts =
+    let t = sem_Root (Root sts)
+        ta = wrap_Root t Inh_Root {cat_Inh_Root = cat
+                                  ,lib_Inh_Root = emptyBindings
+                                  ,idenv_Inh_Root = emptyIDEnv}
+        tl = fixedUpIdentifiersTree_Syn_Root ta
+    in case tl of
+         Root r -> countHack r
+
+fixUpIdentifiersSE :: Catalog -> ScalarExpr -> ScalarExpr
+fixUpIdentifiersSE cat sts =
+    let t = sem_ScalarExprRoot (ScalarExprRoot sts)
+        ta = wrap_ScalarExprRoot t Inh_ScalarExprRoot {cat_Inh_ScalarExprRoot = cat
+                                  ,lib_Inh_ScalarExprRoot = emptyBindings
+                                  ,idenv_Inh_ScalarExprRoot = emptyIDEnv}
+        tl = fixedUpIdentifiersTree_Syn_ScalarExprRoot ta
+    in case tl of
+         ScalarExprRoot r -> countHack r
+
+fixUpIdentifiersQE :: Catalog -> QueryExpr -> QueryExpr
+fixUpIdentifiersQE cat qe =
+    let [QueryStatement _ qe'] = fixUpIdentifiers cat [QueryStatement emptyAnnotation qe]
+    in countHack qe'
+
+-- small hack to convert count(*) into count(True). Should be fixed when
+-- a more general approach to aggregates is written
+
+countHack :: Data a => a -> a
+countHack = transformBi $ \x -> case x of
+              FunCall a "count" [Identifier ia "*"] ->
+                FunCall a "count" [BooleanLit ia True]
+              x1 -> x1
+
+
+
+doAlias :: TableAlias -> [(String,[String])] -> ([(String,[String])],TableAlias)
+doAlias (NoAlias a) [] = ([],NoAlias a)
+doAlias (NoAlias a) cs@((t,_):ts) = if all (==t) $ map fst ts
+                                then (cs,FullAlias a t $ concatMap snd cs)
+                                else (cs,NoAlias a)
+doAlias (TableAlias a t) cs = let cs' = concatMap snd cs
+                              in ([(t, cs')], FullAlias a t cs')
+doAlias f@(FullAlias _ t cs) _ = ([(t,cs)], f)
+
+
+
+addTypeErrors :: Data a => [TypeError] -> a -> a
+addTypeErrors es el = updateAnnotation u el
+                      where
+                        u a = a {errs = errs a ++ es}
+
+setTypeAddErrors :: Data a => Et -> a -> a
+setTypeAddErrors et el = updateAnnotation (setTypeAddErrorsA et) el
+
+setTypeAddErrorsA :: Et -> Annotation -> Annotation
+setTypeAddErrorsA et a =
+    let a1 = a {errs = errs a ++ tes et}
+    in case atype a1 of
+         Just _ -> a1 {errs = errs a
+                             ++ [InternalError $ "tried to set type a second time - " ++ show (etmt et)]}
+         Nothing -> a1 {atype = etmt et}
+
+allJust :: [Maybe a] -> Maybe [a]
+allJust ts = sequence ts
+
+-- bit dogdy, needs some thought
+-- this is just to convert the new approach of using "." as an operator
+-- to construct names, with the old approach which stuck the whole lot
+-- in a string
+getName :: ScalarExpr -> String
+getName (Identifier _ i) = i
+getName (FunCall _ "." [Identifier _ _,Identifier _ i]) = i
+getName (FunCall _ "." [_,a]) = getName a
+getName x = error $ "internal error getName called on: " ++ show x
+
+getTName :: SQIdentifier -> String
+getTName (SQIdentifier _ x@(_:_)) = last x
+getTName x = error $ "internal error getName called on: " ++ show x
+
+
+unwrapLookup :: (String,[String],Type) -> Type
+unwrapLookup (_,_,t) = t
+
+allAtts :: ([(String,Type)],[(String,Type)]) -> [(String,Type)]
+allAtts (a,b) = a ++ b
+
+
+
+typeCheckValuesExpr :: Catalog -> [[Maybe Type]] -> Either [TypeError] Type
+typeCheckValuesExpr cat rowsTs = do
+        rts <- lmt $ allJust $ map allJust rowsTs
+        let colNames = zipWith (++)
+                           (repeat "column")
+                           (map show [1..length $ head rowsTs])
+        unionRelTypes cat rts colNames
+
+
+typeCheckCombineSelect :: Catalog -> Type -> Type -> Either [TypeError] Type
+typeCheckCombineSelect cat v1 v2 = do
+    u1 <- unwrapSetOfComposite v1
+    let colNames = map fst u1
+    u2 <- unwrapSetOfComposite v2
+    let colTypes1 = map snd u1
+    let colTypes2 = map snd u2
+    unionRelTypes cat [colTypes1,colTypes2] colNames
+
+unionRelTypes :: Catalog -> [[Type]] -> [String] -> Either [TypeError] Type
+unionRelTypes cat rowsTs colNames =
+  let lengths = map length rowsTs
+  in case () of
+             _ | null rowsTs ->
+                   Left [NoRowsGivenForValues]
+               | not (all (==head lengths) lengths) ->
+                   Left [ValuesListsMustBeSameLength]
+               | otherwise ->
+                   --i don't think this propagates all the errors, just the first set
+                   mapM (resolveResultSetType cat) (transpose rowsTs) >>=
+                     (return . SetOfType . CompositeType . zip colNames)
+
+
+
+
+
+
+{-
+convert a function call into a [String,[(string,type)]] list for use
+in a tableref context
+first consideration is the alias: if there is an alias in the select,
+e.g. select * from generate_series(1,2) x;  (alias is x)
+we use that, otherwise we use the name of the function
+second consideration is the attributes coming out, roughly speaking
+we have to convert an arbitrary type to a relation type
+if we have a relation valued function, we don't need to do anything
+if we have a setof non composite, we lift the single type to an
+attribute, using the function name for the attribute name
+if we have a non setof, we lift the single type to an attribute and
+then relation, using the function name for the attribute name
+need to check to see what should happen with arrayof
+
+-}
+funIdens :: Catalog -> String -> ScalarExpr -> Maybe Type -> Either [TypeError] (String,[(String,Type)])
+funIdens cat alias fnVal ft = do
+   errorWhen (case fnVal of
+                FunCall _ _ _ -> False
+                _ -> True)
+             [ContextError "FunCall"]
+   let (FunCall _ fnName _) = fnVal
+       cn = if alias /= ""
+                           then alias
+                           else fnName
+   attrs <- do
+     fnt <- lmt ft
+     case fnt of
+       SetOfType (NamedCompositeType t) -> catCompositePublicAttrs cat [] t
+       SetOfType x -> return [(cn,x)]
+       y -> return [(cn,y)]
+   return (cn, attrs)
+
+getAlias :: String -> TableAlias -> String
+getAlias def alias =
+  case alias of
+    NoAlias _ -> def
+    TableAlias _ t -> t
+    FullAlias _ t _ -> t
+
+
+
+{-data SiType = SiType (String,Maybe Type)
+            | SiStarType [(String,Maybe Type)]-}
+
+
+--unwrapSetofs :: [(String,Type)] -> [(String,Type)]
+--unwrapSetofs = map (\(n,t) -> (n, unwrapSetof t))
+
+unwrapSetof :: Type -> Type
+unwrapSetof (SetOfType u) = u
+unwrapSetof v = v
+
+
+
+defaultSystemColumns :: [(String,Type)]
+defaultSystemColumns = [("tableoid", ScalarType "oid")
+                       ,("cmax", ScalarType "cid")
+                       ,("xmax", ScalarType "xid")
+                       ,("cmin", ScalarType "cid")
+                       ,("xmin", ScalarType "xid")
+                       ,("ctid", ScalarType "tid")]
+
+
+data ParamName = NamedParam Int String
+               | UnnamedParam Int
+
+
+getPlaceholderTypes :: Data a => a -> [Maybe Type]
+getPlaceholderTypes ex =
+    [infType (getAnnotation x) | x <- universeBi ex
+                               , isPlaceholder x]
+    where
+      isPlaceholder e = case e of
+                          PositionalArg _ _ -> True
+                          Placeholder _ -> True
+                          _ -> False
+
+-- AlterTableAction --------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative AddConstraint:
+         child ann            : {Annotation}
+         child con            : Constraint 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative AlterColumnDefault:
+         child ann            : {Annotation}
+         child nm             : {String}
+         child def            : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data AlterTableAction  = AddConstraint (Annotation) (Constraint ) 
+                       | AlterColumnDefault (Annotation) (String) (ScalarExpr ) 
+                       deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_AlterTableAction :: AlterTableAction  ->
+                        T_AlterTableAction 
+sem_AlterTableAction (AddConstraint _ann _con )  =
+    (sem_AlterTableAction_AddConstraint _ann (sem_Constraint _con ) )
+sem_AlterTableAction (AlterColumnDefault _ann _nm _def )  =
+    (sem_AlterTableAction_AlterColumnDefault _ann _nm (sem_ScalarExpr _def ) )
+-- semantic domain
+type T_AlterTableAction  = Catalog ->
+                           IDEnv ->
+                           LocalBindings ->
+                           ( AlterTableAction ,AlterTableAction ,AlterTableAction )
+data Inh_AlterTableAction  = Inh_AlterTableAction {cat_Inh_AlterTableAction :: Catalog,idenv_Inh_AlterTableAction :: IDEnv,lib_Inh_AlterTableAction :: LocalBindings}
+data Syn_AlterTableAction  = Syn_AlterTableAction {annotatedTree_Syn_AlterTableAction :: AlterTableAction ,fixedUpIdentifiersTree_Syn_AlterTableAction :: AlterTableAction ,originalTree_Syn_AlterTableAction :: AlterTableAction }
+wrap_AlterTableAction :: T_AlterTableAction  ->
+                         Inh_AlterTableAction  ->
+                         Syn_AlterTableAction 
+wrap_AlterTableAction sem (Inh_AlterTableAction _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_AlterTableAction _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_AlterTableAction_AddConstraint :: Annotation ->
+                                      T_Constraint  ->
+                                      T_AlterTableAction 
+sem_AlterTableAction_AddConstraint ann_ con_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: AlterTableAction 
+              _lhsOfixedUpIdentifiersTree :: AlterTableAction 
+              _lhsOoriginalTree :: AlterTableAction 
+              _conOcat :: Catalog
+              _conOidenv :: IDEnv
+              _conOlib :: LocalBindings
+              _conIannotatedTree :: Constraint 
+              _conIfixedUpIdentifiersTree :: Constraint 
+              _conIoriginalTree :: Constraint 
+              -- self rule
+              _annotatedTree =
+                  AddConstraint ann_ _conIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  AddConstraint ann_ _conIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  AddConstraint ann_ _conIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _conOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _conOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _conOlib =
+                  _lhsIlib
+              ( _conIannotatedTree,_conIfixedUpIdentifiersTree,_conIoriginalTree) =
+                  con_ _conOcat _conOidenv _conOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_AlterTableAction_AlterColumnDefault :: Annotation ->
+                                           String ->
+                                           T_ScalarExpr  ->
+                                           T_AlterTableAction 
+sem_AlterTableAction_AlterColumnDefault ann_ nm_ def_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _defOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: AlterTableAction 
+              _lhsOfixedUpIdentifiersTree :: AlterTableAction 
+              _lhsOoriginalTree :: AlterTableAction 
+              _defOcat :: Catalog
+              _defOidenv :: IDEnv
+              _defOlib :: LocalBindings
+              _defIannotatedTree :: ScalarExpr 
+              _defIfixedUpIdentifiersTree :: ScalarExpr 
+              _defIoriginalTree :: ScalarExpr 
+              _defIuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 72, column 26)
+              _defOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  AlterColumnDefault ann_ nm_ _defIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  AlterColumnDefault ann_ nm_ _defIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  AlterColumnDefault ann_ nm_ _defIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _defOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _defOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _defOlib =
+                  _lhsIlib
+              ( _defIannotatedTree,_defIfixedUpIdentifiersTree,_defIoriginalTree,_defIuType) =
+                  def_ _defOcat _defOexpectedType _defOidenv _defOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- AlterTableActionList ----------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : AlterTableAction 
+         child tl             : AlterTableActionList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type AlterTableActionList  = [AlterTableAction ]
+-- cata
+sem_AlterTableActionList :: AlterTableActionList  ->
+                            T_AlterTableActionList 
+sem_AlterTableActionList list  =
+    (Prelude.foldr sem_AlterTableActionList_Cons sem_AlterTableActionList_Nil (Prelude.map sem_AlterTableAction list) )
+-- semantic domain
+type T_AlterTableActionList  = Catalog ->
+                               IDEnv ->
+                               LocalBindings ->
+                               ( AlterTableActionList ,AlterTableActionList ,AlterTableActionList )
+data Inh_AlterTableActionList  = Inh_AlterTableActionList {cat_Inh_AlterTableActionList :: Catalog,idenv_Inh_AlterTableActionList :: IDEnv,lib_Inh_AlterTableActionList :: LocalBindings}
+data Syn_AlterTableActionList  = Syn_AlterTableActionList {annotatedTree_Syn_AlterTableActionList :: AlterTableActionList ,fixedUpIdentifiersTree_Syn_AlterTableActionList :: AlterTableActionList ,originalTree_Syn_AlterTableActionList :: AlterTableActionList }
+wrap_AlterTableActionList :: T_AlterTableActionList  ->
+                             Inh_AlterTableActionList  ->
+                             Syn_AlterTableActionList 
+wrap_AlterTableActionList sem (Inh_AlterTableActionList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_AlterTableActionList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_AlterTableActionList_Cons :: T_AlterTableAction  ->
+                                 T_AlterTableActionList  ->
+                                 T_AlterTableActionList 
+sem_AlterTableActionList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: AlterTableActionList 
+              _lhsOfixedUpIdentifiersTree :: AlterTableActionList 
+              _lhsOoriginalTree :: AlterTableActionList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: AlterTableAction 
+              _hdIfixedUpIdentifiersTree :: AlterTableAction 
+              _hdIoriginalTree :: AlterTableAction 
+              _tlIannotatedTree :: AlterTableActionList 
+              _tlIfixedUpIdentifiersTree :: AlterTableActionList 
+              _tlIoriginalTree :: AlterTableActionList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_AlterTableActionList_Nil :: T_AlterTableActionList 
+sem_AlterTableActionList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: AlterTableActionList 
+              _lhsOfixedUpIdentifiersTree :: AlterTableActionList 
+              _lhsOoriginalTree :: AlterTableActionList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- AttributeDef ------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         attrName             : String
+         fixedUpIdentifiersTree : SELF 
+         namedType            : Maybe Type
+         originalTree         : SELF 
+   alternatives:
+      alternative AttributeDef:
+         child ann            : {Annotation}
+         child name           : {String}
+         child typ            : TypeName 
+         child def            : MaybeScalarExpr 
+         child cons           : RowConstraintList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data AttributeDef  = AttributeDef (Annotation) (String) (TypeName ) (MaybeScalarExpr ) (RowConstraintList ) 
+                   deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_AttributeDef :: AttributeDef  ->
+                    T_AttributeDef 
+sem_AttributeDef (AttributeDef _ann _name _typ _def _cons )  =
+    (sem_AttributeDef_AttributeDef _ann _name (sem_TypeName _typ ) (sem_MaybeScalarExpr _def ) (sem_RowConstraintList _cons ) )
+-- semantic domain
+type T_AttributeDef  = Catalog ->
+                       IDEnv ->
+                       LocalBindings ->
+                       ( AttributeDef ,String,AttributeDef ,(Maybe Type),AttributeDef )
+data Inh_AttributeDef  = Inh_AttributeDef {cat_Inh_AttributeDef :: Catalog,idenv_Inh_AttributeDef :: IDEnv,lib_Inh_AttributeDef :: LocalBindings}
+data Syn_AttributeDef  = Syn_AttributeDef {annotatedTree_Syn_AttributeDef :: AttributeDef ,attrName_Syn_AttributeDef :: String,fixedUpIdentifiersTree_Syn_AttributeDef :: AttributeDef ,namedType_Syn_AttributeDef :: (Maybe Type),originalTree_Syn_AttributeDef :: AttributeDef }
+wrap_AttributeDef :: T_AttributeDef  ->
+                     Inh_AttributeDef  ->
+                     Syn_AttributeDef 
+wrap_AttributeDef sem (Inh_AttributeDef _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOattrName,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_AttributeDef _lhsOannotatedTree _lhsOattrName _lhsOfixedUpIdentifiersTree _lhsOnamedType _lhsOoriginalTree ))
+sem_AttributeDef_AttributeDef :: Annotation ->
+                                 String ->
+                                 T_TypeName  ->
+                                 T_MaybeScalarExpr  ->
+                                 T_RowConstraintList  ->
+                                 T_AttributeDef 
+sem_AttributeDef_AttributeDef ann_ name_ typ_ def_ cons_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrName :: String
+              _lhsOnamedType :: (Maybe Type)
+              _consOlib :: LocalBindings
+              _lhsOannotatedTree :: AttributeDef 
+              _lhsOfixedUpIdentifiersTree :: AttributeDef 
+              _lhsOoriginalTree :: AttributeDef 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _defOcat :: Catalog
+              _defOidenv :: IDEnv
+              _defOlib :: LocalBindings
+              _consOcat :: Catalog
+              _consOidenv :: IDEnv
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              _defIannotatedTree :: MaybeScalarExpr 
+              _defIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _defIoriginalTree :: MaybeScalarExpr 
+              _defIuType :: (Maybe Type)
+              _consIannotatedTree :: RowConstraintList 
+              _consIfixedUpIdentifiersTree :: RowConstraintList 
+              _consIoriginalTree :: RowConstraintList 
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 83, column 9)
+              _lhsOattrName =
+                  map toLower name_
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 84, column 9)
+              _lhsOnamedType =
+                  _typInamedType
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 98, column 9)
+              _consOlib =
+                  either (const _lhsIlib) id $ do
+                  t <- lmt _typInamedType
+                  lbUpdate _lhsIcat
+                           (LBIds "attribute def" Nothing
+                                  [(name_, t)]) _lhsIlib
+              -- self rule
+              _annotatedTree =
+                  AttributeDef ann_ name_ _typIannotatedTree _defIannotatedTree _consIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  AttributeDef ann_ name_ _typIfixedUpIdentifiersTree _defIfixedUpIdentifiersTree _consIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  AttributeDef ann_ name_ _typIoriginalTree _defIoriginalTree _consIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _defOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _defOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _defOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _consOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _consOidenv =
+                  _lhsIidenv
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+              ( _defIannotatedTree,_defIfixedUpIdentifiersTree,_defIoriginalTree,_defIuType) =
+                  def_ _defOcat _defOidenv _defOlib 
+              ( _consIannotatedTree,_consIfixedUpIdentifiersTree,_consIoriginalTree) =
+                  cons_ _consOcat _consOidenv _consOlib 
+          in  ( _lhsOannotatedTree,_lhsOattrName,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+-- AttributeDefList --------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         attrs                : [(String, Maybe Type)]
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : AttributeDef 
+         child tl             : AttributeDefList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type AttributeDefList  = [AttributeDef ]
+-- cata
+sem_AttributeDefList :: AttributeDefList  ->
+                        T_AttributeDefList 
+sem_AttributeDefList list  =
+    (Prelude.foldr sem_AttributeDefList_Cons sem_AttributeDefList_Nil (Prelude.map sem_AttributeDef list) )
+-- semantic domain
+type T_AttributeDefList  = Catalog ->
+                           IDEnv ->
+                           LocalBindings ->
+                           ( AttributeDefList ,([(String, Maybe Type)]),AttributeDefList ,AttributeDefList )
+data Inh_AttributeDefList  = Inh_AttributeDefList {cat_Inh_AttributeDefList :: Catalog,idenv_Inh_AttributeDefList :: IDEnv,lib_Inh_AttributeDefList :: LocalBindings}
+data Syn_AttributeDefList  = Syn_AttributeDefList {annotatedTree_Syn_AttributeDefList :: AttributeDefList ,attrs_Syn_AttributeDefList :: ([(String, Maybe Type)]),fixedUpIdentifiersTree_Syn_AttributeDefList :: AttributeDefList ,originalTree_Syn_AttributeDefList :: AttributeDefList }
+wrap_AttributeDefList :: T_AttributeDefList  ->
+                         Inh_AttributeDefList  ->
+                         Syn_AttributeDefList 
+wrap_AttributeDefList sem (Inh_AttributeDefList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_AttributeDefList _lhsOannotatedTree _lhsOattrs _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_AttributeDefList_Cons :: T_AttributeDef  ->
+                             T_AttributeDefList  ->
+                             T_AttributeDefList 
+sem_AttributeDefList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrs :: ([(String, Maybe Type)])
+              _lhsOannotatedTree :: AttributeDefList 
+              _lhsOfixedUpIdentifiersTree :: AttributeDefList 
+              _lhsOoriginalTree :: AttributeDefList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: AttributeDef 
+              _hdIattrName :: String
+              _hdIfixedUpIdentifiersTree :: AttributeDef 
+              _hdInamedType :: (Maybe Type)
+              _hdIoriginalTree :: AttributeDef 
+              _tlIannotatedTree :: AttributeDefList 
+              _tlIattrs :: ([(String, Maybe Type)])
+              _tlIfixedUpIdentifiersTree :: AttributeDefList 
+              _tlIoriginalTree :: AttributeDefList 
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 88, column 12)
+              _lhsOattrs =
+                  (_hdIattrName, _hdInamedType) : _tlIattrs
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIattrName,_hdIfixedUpIdentifiersTree,_hdInamedType,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIattrs,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_AttributeDefList_Nil :: T_AttributeDefList 
+sem_AttributeDefList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrs :: ([(String, Maybe Type)])
+              _lhsOannotatedTree :: AttributeDefList 
+              _lhsOfixedUpIdentifiersTree :: AttributeDefList 
+              _lhsOoriginalTree :: AttributeDefList 
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 89, column 11)
+              _lhsOattrs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- CaseScalarExprListScalarExprPair ----------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         thenType             : Maybe Type
+         whenTypes            : [Maybe Type]
+   alternatives:
+      alternative Tuple:
+         child x1             : ScalarExprList 
+         child x2             : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type CaseScalarExprListScalarExprPair  = ( ScalarExprList ,ScalarExpr )
+-- cata
+sem_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair  ->
+                                        T_CaseScalarExprListScalarExprPair 
+sem_CaseScalarExprListScalarExprPair ( x1,x2)  =
+    (sem_CaseScalarExprListScalarExprPair_Tuple (sem_ScalarExprList x1 ) (sem_ScalarExpr x2 ) )
+-- semantic domain
+type T_CaseScalarExprListScalarExprPair  = Catalog ->
+                                           IDEnv ->
+                                           LocalBindings ->
+                                           ( CaseScalarExprListScalarExprPair ,CaseScalarExprListScalarExprPair ,CaseScalarExprListScalarExprPair ,(Maybe Type),([Maybe Type]))
+data Inh_CaseScalarExprListScalarExprPair  = Inh_CaseScalarExprListScalarExprPair {cat_Inh_CaseScalarExprListScalarExprPair :: Catalog,idenv_Inh_CaseScalarExprListScalarExprPair :: IDEnv,lib_Inh_CaseScalarExprListScalarExprPair :: LocalBindings}
+data Syn_CaseScalarExprListScalarExprPair  = Syn_CaseScalarExprListScalarExprPair {annotatedTree_Syn_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair ,fixedUpIdentifiersTree_Syn_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair ,originalTree_Syn_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair ,thenType_Syn_CaseScalarExprListScalarExprPair :: (Maybe Type),whenTypes_Syn_CaseScalarExprListScalarExprPair :: ([Maybe Type])}
+wrap_CaseScalarExprListScalarExprPair :: T_CaseScalarExprListScalarExprPair  ->
+                                         Inh_CaseScalarExprListScalarExprPair  ->
+                                         Syn_CaseScalarExprListScalarExprPair 
+wrap_CaseScalarExprListScalarExprPair sem (Inh_CaseScalarExprListScalarExprPair _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOthenType,_lhsOwhenTypes) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_CaseScalarExprListScalarExprPair _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOthenType _lhsOwhenTypes ))
+sem_CaseScalarExprListScalarExprPair_Tuple :: T_ScalarExprList  ->
+                                              T_ScalarExpr  ->
+                                              T_CaseScalarExprListScalarExprPair 
+sem_CaseScalarExprListScalarExprPair_Tuple x1_ x2_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOwhenTypes :: ([Maybe Type])
+              _lhsOthenType :: (Maybe Type)
+              _x1OexpectedTypes :: ([Maybe Type])
+              _x2OexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: CaseScalarExprListScalarExprPair 
+              _lhsOfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPair 
+              _lhsOoriginalTree :: CaseScalarExprListScalarExprPair 
+              _x1Ocat :: Catalog
+              _x1Oidenv :: IDEnv
+              _x1Olib :: LocalBindings
+              _x2Ocat :: Catalog
+              _x2Oidenv :: IDEnv
+              _x2Olib :: LocalBindings
+              _x1IannotatedTree :: ScalarExprList 
+              _x1IfixedUpIdentifiersTree :: ScalarExprList 
+              _x1IoriginalTree :: ScalarExprList 
+              _x1IuType :: ([Maybe Type])
+              _x2IannotatedTree :: ScalarExpr 
+              _x2IfixedUpIdentifiersTree :: ScalarExpr 
+              _x2IoriginalTree :: ScalarExpr 
+              _x2IuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 270, column 13)
+              _lhsOwhenTypes =
+                  _x1IuType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 271, column 13)
+              _lhsOthenType =
+                  _x2IuType
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 76, column 13)
+              _x1OexpectedTypes =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 77, column 13)
+              _x2OexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  (_x1IannotatedTree,_x2IannotatedTree)
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (_x1IfixedUpIdentifiersTree,_x2IfixedUpIdentifiersTree)
+              -- self rule
+              _originalTree =
+                  (_x1IoriginalTree,_x2IoriginalTree)
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _x1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x1Olib =
+                  _lhsIlib
+              -- copy rule (down)
+              _x2Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x2Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x2Olib =
+                  _lhsIlib
+              ( _x1IannotatedTree,_x1IfixedUpIdentifiersTree,_x1IoriginalTree,_x1IuType) =
+                  x1_ _x1Ocat _x1OexpectedTypes _x1Oidenv _x1Olib 
+              ( _x2IannotatedTree,_x2IfixedUpIdentifiersTree,_x2IoriginalTree,_x2IuType) =
+                  x2_ _x2Ocat _x2OexpectedType _x2Oidenv _x2Olib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOthenType,_lhsOwhenTypes)))
+-- CaseScalarExprListScalarExprPairList ------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         thenTypes            : [Maybe Type]
+         whenTypes            : [[Maybe Type]]
+   alternatives:
+      alternative Cons:
+         child hd             : CaseScalarExprListScalarExprPair 
+         child tl             : CaseScalarExprListScalarExprPairList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type CaseScalarExprListScalarExprPairList  = [CaseScalarExprListScalarExprPair ]
+-- cata
+sem_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList  ->
+                                            T_CaseScalarExprListScalarExprPairList 
+sem_CaseScalarExprListScalarExprPairList list  =
+    (Prelude.foldr sem_CaseScalarExprListScalarExprPairList_Cons sem_CaseScalarExprListScalarExprPairList_Nil (Prelude.map sem_CaseScalarExprListScalarExprPair list) )
+-- semantic domain
+type T_CaseScalarExprListScalarExprPairList  = Catalog ->
+                                               IDEnv ->
+                                               LocalBindings ->
+                                               ( CaseScalarExprListScalarExprPairList ,CaseScalarExprListScalarExprPairList ,CaseScalarExprListScalarExprPairList ,([Maybe Type]),([[Maybe Type]]))
+data Inh_CaseScalarExprListScalarExprPairList  = Inh_CaseScalarExprListScalarExprPairList {cat_Inh_CaseScalarExprListScalarExprPairList :: Catalog,idenv_Inh_CaseScalarExprListScalarExprPairList :: IDEnv,lib_Inh_CaseScalarExprListScalarExprPairList :: LocalBindings}
+data Syn_CaseScalarExprListScalarExprPairList  = Syn_CaseScalarExprListScalarExprPairList {annotatedTree_Syn_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList ,fixedUpIdentifiersTree_Syn_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList ,originalTree_Syn_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList ,thenTypes_Syn_CaseScalarExprListScalarExprPairList :: ([Maybe Type]),whenTypes_Syn_CaseScalarExprListScalarExprPairList :: ([[Maybe Type]])}
+wrap_CaseScalarExprListScalarExprPairList :: T_CaseScalarExprListScalarExprPairList  ->
+                                             Inh_CaseScalarExprListScalarExprPairList  ->
+                                             Syn_CaseScalarExprListScalarExprPairList 
+wrap_CaseScalarExprListScalarExprPairList sem (Inh_CaseScalarExprListScalarExprPairList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOwhenTypes) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_CaseScalarExprListScalarExprPairList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOthenTypes _lhsOwhenTypes ))
+sem_CaseScalarExprListScalarExprPairList_Cons :: T_CaseScalarExprListScalarExprPair  ->
+                                                 T_CaseScalarExprListScalarExprPairList  ->
+                                                 T_CaseScalarExprListScalarExprPairList 
+sem_CaseScalarExprListScalarExprPairList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOwhenTypes :: ([[Maybe Type]])
+              _lhsOthenTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: CaseScalarExprListScalarExprPairList 
+              _lhsOfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPairList 
+              _lhsOoriginalTree :: CaseScalarExprListScalarExprPairList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: CaseScalarExprListScalarExprPair 
+              _hdIfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPair 
+              _hdIoriginalTree :: CaseScalarExprListScalarExprPair 
+              _hdIthenType :: (Maybe Type)
+              _hdIwhenTypes :: ([Maybe Type])
+              _tlIannotatedTree :: CaseScalarExprListScalarExprPairList 
+              _tlIfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPairList 
+              _tlIoriginalTree :: CaseScalarExprListScalarExprPairList 
+              _tlIthenTypes :: ([Maybe Type])
+              _tlIwhenTypes :: ([[Maybe Type]])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 261, column 10)
+              _lhsOwhenTypes =
+                  _hdIwhenTypes : _tlIwhenTypes
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 262, column 10)
+              _lhsOthenTypes =
+                  _hdIthenType : _tlIthenTypes
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree,_hdIthenType,_hdIwhenTypes) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIthenTypes,_tlIwhenTypes) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOwhenTypes)))
+sem_CaseScalarExprListScalarExprPairList_Nil :: T_CaseScalarExprListScalarExprPairList 
+sem_CaseScalarExprListScalarExprPairList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOwhenTypes :: ([[Maybe Type]])
+              _lhsOthenTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: CaseScalarExprListScalarExprPairList 
+              _lhsOfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPairList 
+              _lhsOoriginalTree :: CaseScalarExprListScalarExprPairList 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 263, column 9)
+              _lhsOwhenTypes =
+                  []
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 264, column 9)
+              _lhsOthenTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOwhenTypes)))
+-- Constraint --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative CheckConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative PrimaryKeyConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child x              : {[String]}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ReferenceConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child atts           : {[String]}
+         child table          : {String}
+         child tableAtts      : {[String]}
+         child onUpdate       : {Cascade}
+         child onDelete       : {Cascade}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative UniqueConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child x              : {[String]}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data Constraint  = CheckConstraint (Annotation) (String) (ScalarExpr ) 
+                 | PrimaryKeyConstraint (Annotation) (String) (([String])) 
+                 | ReferenceConstraint (Annotation) (String) (([String])) (String) (([String])) (Cascade) (Cascade) 
+                 | UniqueConstraint (Annotation) (String) (([String])) 
+                 deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_Constraint :: Constraint  ->
+                  T_Constraint 
+sem_Constraint (CheckConstraint _ann _name _expr )  =
+    (sem_Constraint_CheckConstraint _ann _name (sem_ScalarExpr _expr ) )
+sem_Constraint (PrimaryKeyConstraint _ann _name _x )  =
+    (sem_Constraint_PrimaryKeyConstraint _ann _name _x )
+sem_Constraint (ReferenceConstraint _ann _name _atts _table _tableAtts _onUpdate _onDelete )  =
+    (sem_Constraint_ReferenceConstraint _ann _name _atts _table _tableAtts _onUpdate _onDelete )
+sem_Constraint (UniqueConstraint _ann _name _x )  =
+    (sem_Constraint_UniqueConstraint _ann _name _x )
+-- semantic domain
+type T_Constraint  = Catalog ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( Constraint ,Constraint ,Constraint )
+data Inh_Constraint  = Inh_Constraint {cat_Inh_Constraint :: Catalog,idenv_Inh_Constraint :: IDEnv,lib_Inh_Constraint :: LocalBindings}
+data Syn_Constraint  = Syn_Constraint {annotatedTree_Syn_Constraint :: Constraint ,fixedUpIdentifiersTree_Syn_Constraint :: Constraint ,originalTree_Syn_Constraint :: Constraint }
+wrap_Constraint :: T_Constraint  ->
+                   Inh_Constraint  ->
+                   Syn_Constraint 
+wrap_Constraint sem (Inh_Constraint _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_Constraint _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_Constraint_CheckConstraint :: Annotation ->
+                                  String ->
+                                  T_ScalarExpr  ->
+                                  T_Constraint 
+sem_Constraint_CheckConstraint ann_ name_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Constraint 
+              _lhsOfixedUpIdentifiersTree :: Constraint 
+              _lhsOoriginalTree :: Constraint 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 80, column 23)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  CheckConstraint ann_ name_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CheckConstraint ann_ name_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CheckConstraint ann_ name_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_Constraint_PrimaryKeyConstraint :: Annotation ->
+                                       String ->
+                                       ([String]) ->
+                                       T_Constraint 
+sem_Constraint_PrimaryKeyConstraint ann_ name_ x_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Constraint 
+              _lhsOfixedUpIdentifiersTree :: Constraint 
+              _lhsOoriginalTree :: Constraint 
+              -- self rule
+              _annotatedTree =
+                  PrimaryKeyConstraint ann_ name_ x_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  PrimaryKeyConstraint ann_ name_ x_
+              -- self rule
+              _originalTree =
+                  PrimaryKeyConstraint ann_ name_ x_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_Constraint_ReferenceConstraint :: Annotation ->
+                                      String ->
+                                      ([String]) ->
+                                      String ->
+                                      ([String]) ->
+                                      Cascade ->
+                                      Cascade ->
+                                      T_Constraint 
+sem_Constraint_ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Constraint 
+              _lhsOfixedUpIdentifiersTree :: Constraint 
+              _lhsOoriginalTree :: Constraint 
+              -- self rule
+              _annotatedTree =
+                  ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_
+              -- self rule
+              _originalTree =
+                  ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_Constraint_UniqueConstraint :: Annotation ->
+                                   String ->
+                                   ([String]) ->
+                                   T_Constraint 
+sem_Constraint_UniqueConstraint ann_ name_ x_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Constraint 
+              _lhsOfixedUpIdentifiersTree :: Constraint 
+              _lhsOoriginalTree :: Constraint 
+              -- self rule
+              _annotatedTree =
+                  UniqueConstraint ann_ name_ x_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  UniqueConstraint ann_ name_ x_
+              -- self rule
+              _originalTree =
+                  UniqueConstraint ann_ name_ x_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ConstraintList ----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : Constraint 
+         child tl             : ConstraintList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ConstraintList  = [Constraint ]
+-- cata
+sem_ConstraintList :: ConstraintList  ->
+                      T_ConstraintList 
+sem_ConstraintList list  =
+    (Prelude.foldr sem_ConstraintList_Cons sem_ConstraintList_Nil (Prelude.map sem_Constraint list) )
+-- semantic domain
+type T_ConstraintList  = Catalog ->
+                         IDEnv ->
+                         LocalBindings ->
+                         ( ConstraintList ,ConstraintList ,ConstraintList )
+data Inh_ConstraintList  = Inh_ConstraintList {cat_Inh_ConstraintList :: Catalog,idenv_Inh_ConstraintList :: IDEnv,lib_Inh_ConstraintList :: LocalBindings}
+data Syn_ConstraintList  = Syn_ConstraintList {annotatedTree_Syn_ConstraintList :: ConstraintList ,fixedUpIdentifiersTree_Syn_ConstraintList :: ConstraintList ,originalTree_Syn_ConstraintList :: ConstraintList }
+wrap_ConstraintList :: T_ConstraintList  ->
+                       Inh_ConstraintList  ->
+                       Syn_ConstraintList 
+wrap_ConstraintList sem (Inh_ConstraintList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ConstraintList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ConstraintList_Cons :: T_Constraint  ->
+                           T_ConstraintList  ->
+                           T_ConstraintList 
+sem_ConstraintList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ConstraintList 
+              _lhsOfixedUpIdentifiersTree :: ConstraintList 
+              _lhsOoriginalTree :: ConstraintList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: Constraint 
+              _hdIfixedUpIdentifiersTree :: Constraint 
+              _hdIoriginalTree :: Constraint 
+              _tlIannotatedTree :: ConstraintList 
+              _tlIfixedUpIdentifiersTree :: ConstraintList 
+              _tlIoriginalTree :: ConstraintList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_ConstraintList_Nil :: T_ConstraintList 
+sem_ConstraintList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ConstraintList 
+              _lhsOfixedUpIdentifiersTree :: ConstraintList 
+              _lhsOoriginalTree :: ConstraintList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- FnBody ------------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative PlpgsqlFnBody:
+         child ann            : {Annotation}
+         child blk            : Statement 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative SqlFnBody:
+         child ann            : {Annotation}
+         child sts            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data FnBody  = PlpgsqlFnBody (Annotation) (Statement ) 
+             | SqlFnBody (Annotation) (StatementList ) 
+             deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_FnBody :: FnBody  ->
+              T_FnBody 
+sem_FnBody (PlpgsqlFnBody _ann _blk )  =
+    (sem_FnBody_PlpgsqlFnBody _ann (sem_Statement _blk ) )
+sem_FnBody (SqlFnBody _ann _sts )  =
+    (sem_FnBody_SqlFnBody _ann (sem_StatementList _sts ) )
+-- semantic domain
+type T_FnBody  = Catalog ->
+                 IDEnv ->
+                 LocalBindings ->
+                 ( FnBody ,FnBody ,FnBody )
+data Inh_FnBody  = Inh_FnBody {cat_Inh_FnBody :: Catalog,idenv_Inh_FnBody :: IDEnv,lib_Inh_FnBody :: LocalBindings}
+data Syn_FnBody  = Syn_FnBody {annotatedTree_Syn_FnBody :: FnBody ,fixedUpIdentifiersTree_Syn_FnBody :: FnBody ,originalTree_Syn_FnBody :: FnBody }
+wrap_FnBody :: T_FnBody  ->
+               Inh_FnBody  ->
+               Syn_FnBody 
+wrap_FnBody sem (Inh_FnBody _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_FnBody _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_FnBody_PlpgsqlFnBody :: Annotation ->
+                            T_Statement  ->
+                            T_FnBody 
+sem_FnBody_PlpgsqlFnBody ann_ blk_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _blkOinProducedCat :: Catalog
+              _lhsOannotatedTree :: FnBody 
+              _lhsOfixedUpIdentifiersTree :: FnBody 
+              _lhsOoriginalTree :: FnBody 
+              _blkOcat :: Catalog
+              _blkOidenv :: IDEnv
+              _blkOlib :: LocalBindings
+              _blkIannotatedTree :: Statement 
+              _blkIcatUpdates :: ([CatalogUpdate])
+              _blkIfixedUpIdentifiersTree :: Statement 
+              _blkIlibUpdates :: ([LocalBindingsUpdate])
+              _blkIoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 104, column 9)
+              _blkOinProducedCat =
+                  emptyCatalog
+              -- self rule
+              _annotatedTree =
+                  PlpgsqlFnBody ann_ _blkIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  PlpgsqlFnBody ann_ _blkIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  PlpgsqlFnBody ann_ _blkIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _blkOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _blkOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _blkOlib =
+                  _lhsIlib
+              ( _blkIannotatedTree,_blkIcatUpdates,_blkIfixedUpIdentifiersTree,_blkIlibUpdates,_blkIoriginalTree) =
+                  blk_ _blkOcat _blkOidenv _blkOinProducedCat _blkOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_FnBody_SqlFnBody :: Annotation ->
+                        T_StatementList  ->
+                        T_FnBody 
+sem_FnBody_SqlFnBody ann_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: FnBody 
+              _lhsOfixedUpIdentifiersTree :: FnBody 
+              _lhsOoriginalTree :: FnBody 
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _stsOlib :: LocalBindings
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 129, column 9)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 130, column 9)
+              _stsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  SqlFnBody ann_ _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SqlFnBody ann_ _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  SqlFnBody ann_ _stsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _stsOlib =
+                  _lhsIlib
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- InList ------------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         expectedType         : Maybe Type
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         listType             : Either [TypeError] Type
+         originalTree         : SELF 
+   alternatives:
+      alternative InList:
+         child ann            : {Annotation}
+         child exprs          : ScalarExprList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative InQueryExpr:
+         child ann            : {Annotation}
+         child sel            : QueryExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data InList  = InList (Annotation) (ScalarExprList ) 
+             | InQueryExpr (Annotation) (QueryExpr ) 
+             deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_InList :: InList  ->
+              T_InList 
+sem_InList (InList _ann _exprs )  =
+    (sem_InList_InList _ann (sem_ScalarExprList _exprs ) )
+sem_InList (InQueryExpr _ann _sel )  =
+    (sem_InList_InQueryExpr _ann (sem_QueryExpr _sel ) )
+-- semantic domain
+type T_InList  = Catalog ->
+                 (Maybe Type) ->
+                 IDEnv ->
+                 LocalBindings ->
+                 ( InList ,InList ,(Either [TypeError] Type),InList )
+data Inh_InList  = Inh_InList {cat_Inh_InList :: Catalog,expectedType_Inh_InList :: (Maybe Type),idenv_Inh_InList :: IDEnv,lib_Inh_InList :: LocalBindings}
+data Syn_InList  = Syn_InList {annotatedTree_Syn_InList :: InList ,fixedUpIdentifiersTree_Syn_InList :: InList ,listType_Syn_InList :: (Either [TypeError] Type),originalTree_Syn_InList :: InList }
+wrap_InList :: T_InList  ->
+               Inh_InList  ->
+               Syn_InList 
+wrap_InList sem (Inh_InList _lhsIcat _lhsIexpectedType _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree) = sem _lhsIcat _lhsIexpectedType _lhsIidenv _lhsIlib 
+     in  (Syn_InList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOlistType _lhsOoriginalTree ))
+sem_InList_InList :: Annotation ->
+                     T_ScalarExprList  ->
+                     T_InList 
+sem_InList_InList ann_ exprs_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOlistType :: (Either [TypeError] Type)
+              _exprsOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: InList 
+              _lhsOfixedUpIdentifiersTree :: InList 
+              _lhsOoriginalTree :: InList 
+              _exprsOcat :: Catalog
+              _exprsOidenv :: IDEnv
+              _exprsOlib :: LocalBindings
+              _exprsIannotatedTree :: ScalarExprList 
+              _exprsIfixedUpIdentifiersTree :: ScalarExprList 
+              _exprsIoriginalTree :: ScalarExprList 
+              _exprsIuType :: ([Maybe Type])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 409, column 9)
+              _lhsOlistType =
+                  mapM lmt _exprsIuType >>= resolveResultSetType _lhsIcat
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 410, column 9)
+              _exprsOexpectedTypes =
+                  repeat _lhsIexpectedType
+              -- self rule
+              _annotatedTree =
+                  InList ann_ _exprsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  InList ann_ _exprsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  InList ann_ _exprsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprsOlib =
+                  _lhsIlib
+              ( _exprsIannotatedTree,_exprsIfixedUpIdentifiersTree,_exprsIoriginalTree,_exprsIuType) =
+                  exprs_ _exprsOcat _exprsOexpectedTypes _exprsOidenv _exprsOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+sem_InList_InQueryExpr :: Annotation ->
+                          T_QueryExpr  ->
+                          T_InList 
+sem_InList_InQueryExpr ann_ sel_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOlistType :: (Either [TypeError] Type)
+              _selOcsql :: LocalBindings
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: InList 
+              _lhsOfixedUpIdentifiersTree :: InList 
+              _lhsOoriginalTree :: InList 
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 413, column 9)
+              _lhsOlistType =
+                  do
+                  st <- lmt (map snd <$> _selIuType)
+                  case length st of
+                            0 -> Left [InternalError
+                                       "got subquery with no columns? in inselect"]
+                            1 -> Right $ head st
+                            _ -> Right $ AnonymousRecordType st
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 120, column 19)
+              _selOcsql =
+                  emptyBindings
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 173, column 19)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  InQueryExpr ann_ _selIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  InQueryExpr ann_ _selIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  InQueryExpr ann_ _selIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+-- JoinExpr ----------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative JoinOn:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative JoinUsing:
+         child ann            : {Annotation}
+         child x              : {[String]}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data JoinExpr  = JoinOn (Annotation) (ScalarExpr ) 
+               | JoinUsing (Annotation) (([String])) 
+               deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_JoinExpr :: JoinExpr  ->
+                T_JoinExpr 
+sem_JoinExpr (JoinOn _ann _expr )  =
+    (sem_JoinExpr_JoinOn _ann (sem_ScalarExpr _expr ) )
+sem_JoinExpr (JoinUsing _ann _x )  =
+    (sem_JoinExpr_JoinUsing _ann _x )
+-- semantic domain
+type T_JoinExpr  = Catalog ->
+                   IDEnv ->
+                   LocalBindings ->
+                   ( JoinExpr ,JoinExpr ,JoinExpr )
+data Inh_JoinExpr  = Inh_JoinExpr {cat_Inh_JoinExpr :: Catalog,idenv_Inh_JoinExpr :: IDEnv,lib_Inh_JoinExpr :: LocalBindings}
+data Syn_JoinExpr  = Syn_JoinExpr {annotatedTree_Syn_JoinExpr :: JoinExpr ,fixedUpIdentifiersTree_Syn_JoinExpr :: JoinExpr ,originalTree_Syn_JoinExpr :: JoinExpr }
+wrap_JoinExpr :: T_JoinExpr  ->
+                 Inh_JoinExpr  ->
+                 Syn_JoinExpr 
+wrap_JoinExpr sem (Inh_JoinExpr _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_JoinExpr _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_JoinExpr_JoinOn :: Annotation ->
+                       T_ScalarExpr  ->
+                       T_JoinExpr 
+sem_JoinExpr_JoinOn ann_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: JoinExpr 
+              _lhsOfixedUpIdentifiersTree :: JoinExpr 
+              _lhsOoriginalTree :: JoinExpr 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 94, column 14)
+              _exprOexpectedType =
+                  Just typeBool
+              -- self rule
+              _annotatedTree =
+                  JoinOn ann_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  JoinOn ann_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  JoinOn ann_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_JoinExpr_JoinUsing :: Annotation ->
+                          ([String]) ->
+                          T_JoinExpr 
+sem_JoinExpr_JoinUsing ann_ x_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: JoinExpr 
+              _lhsOfixedUpIdentifiersTree :: JoinExpr 
+              _lhsOoriginalTree :: JoinExpr 
+              -- self rule
+              _annotatedTree =
+                  JoinUsing ann_ x_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  JoinUsing ann_ x_
+              -- self rule
+              _originalTree =
+                  JoinUsing ann_ x_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- MaybeBoolExpr -----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Just:
+         child just           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nothing:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type MaybeBoolExpr  = Maybe ScalarExpr 
+-- cata
+sem_MaybeBoolExpr :: MaybeBoolExpr  ->
+                     T_MaybeBoolExpr 
+sem_MaybeBoolExpr (Prelude.Just x )  =
+    (sem_MaybeBoolExpr_Just (sem_ScalarExpr x ) )
+sem_MaybeBoolExpr Prelude.Nothing  =
+    sem_MaybeBoolExpr_Nothing
+-- semantic domain
+type T_MaybeBoolExpr  = Catalog ->
+                        IDEnv ->
+                        LocalBindings ->
+                        ( MaybeBoolExpr ,MaybeBoolExpr ,MaybeBoolExpr )
+data Inh_MaybeBoolExpr  = Inh_MaybeBoolExpr {cat_Inh_MaybeBoolExpr :: Catalog,idenv_Inh_MaybeBoolExpr :: IDEnv,lib_Inh_MaybeBoolExpr :: LocalBindings}
+data Syn_MaybeBoolExpr  = Syn_MaybeBoolExpr {annotatedTree_Syn_MaybeBoolExpr :: MaybeBoolExpr ,fixedUpIdentifiersTree_Syn_MaybeBoolExpr :: MaybeBoolExpr ,originalTree_Syn_MaybeBoolExpr :: MaybeBoolExpr }
+wrap_MaybeBoolExpr :: T_MaybeBoolExpr  ->
+                      Inh_MaybeBoolExpr  ->
+                      Syn_MaybeBoolExpr 
+wrap_MaybeBoolExpr sem (Inh_MaybeBoolExpr _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_MaybeBoolExpr _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_MaybeBoolExpr_Just :: T_ScalarExpr  ->
+                          T_MaybeBoolExpr 
+sem_MaybeBoolExpr_Just just_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: MaybeBoolExpr 
+              _justOexpectedType :: (Maybe Type)
+              _lhsOfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _lhsOoriginalTree :: MaybeBoolExpr 
+              _justOcat :: Catalog
+              _justOidenv :: IDEnv
+              _justOlib :: LocalBindings
+              _justIannotatedTree :: ScalarExpr 
+              _justIfixedUpIdentifiersTree :: ScalarExpr 
+              _justIoriginalTree :: ScalarExpr 
+              _justIuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 132, column 9)
+              _lhsOannotatedTree =
+                  let t = _justIuType
+                  in if t `elem` [Nothing,Just typeBool]
+                     then Just _justIannotatedTree
+                     else Just $ addTypeErrors [ExpressionMustBeBool] _justIannotatedTree
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 97, column 12)
+              _justOexpectedType =
+                  Just typeBool
+              -- self rule
+              _annotatedTree =
+                  Just _justIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Just _justIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Just _justIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _justOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _justOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _justOlib =
+                  _lhsIlib
+              ( _justIannotatedTree,_justIfixedUpIdentifiersTree,_justIoriginalTree,_justIuType) =
+                  just_ _justOcat _justOexpectedType _justOidenv _justOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_MaybeBoolExpr_Nothing :: T_MaybeBoolExpr 
+sem_MaybeBoolExpr_Nothing  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: MaybeBoolExpr 
+              _lhsOfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _lhsOoriginalTree :: MaybeBoolExpr 
+              -- self rule
+              _annotatedTree =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Nothing
+              -- self rule
+              _originalTree =
+                  Nothing
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- MaybeScalarExpr ---------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         uType                : Maybe Type
+   alternatives:
+      alternative Just:
+         child just           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nothing:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type MaybeScalarExpr  = Maybe ScalarExpr 
+-- cata
+sem_MaybeScalarExpr :: MaybeScalarExpr  ->
+                       T_MaybeScalarExpr 
+sem_MaybeScalarExpr (Prelude.Just x )  =
+    (sem_MaybeScalarExpr_Just (sem_ScalarExpr x ) )
+sem_MaybeScalarExpr Prelude.Nothing  =
+    sem_MaybeScalarExpr_Nothing
+-- semantic domain
+type T_MaybeScalarExpr  = Catalog ->
+                          IDEnv ->
+                          LocalBindings ->
+                          ( MaybeScalarExpr ,MaybeScalarExpr ,MaybeScalarExpr ,(Maybe Type))
+data Inh_MaybeScalarExpr  = Inh_MaybeScalarExpr {cat_Inh_MaybeScalarExpr :: Catalog,idenv_Inh_MaybeScalarExpr :: IDEnv,lib_Inh_MaybeScalarExpr :: LocalBindings}
+data Syn_MaybeScalarExpr  = Syn_MaybeScalarExpr {annotatedTree_Syn_MaybeScalarExpr :: MaybeScalarExpr ,fixedUpIdentifiersTree_Syn_MaybeScalarExpr :: MaybeScalarExpr ,originalTree_Syn_MaybeScalarExpr :: MaybeScalarExpr ,uType_Syn_MaybeScalarExpr :: (Maybe Type)}
+wrap_MaybeScalarExpr :: T_MaybeScalarExpr  ->
+                        Inh_MaybeScalarExpr  ->
+                        Syn_MaybeScalarExpr 
+wrap_MaybeScalarExpr sem (Inh_MaybeScalarExpr _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_MaybeScalarExpr _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOuType ))
+sem_MaybeScalarExpr_Just :: T_ScalarExpr  ->
+                            T_MaybeScalarExpr 
+sem_MaybeScalarExpr_Just just_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: (Maybe Type)
+              _justOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: MaybeScalarExpr 
+              _lhsOfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _lhsOoriginalTree :: MaybeScalarExpr 
+              _justOcat :: Catalog
+              _justOidenv :: IDEnv
+              _justOlib :: LocalBindings
+              _justIannotatedTree :: ScalarExpr 
+              _justIfixedUpIdentifiersTree :: ScalarExpr 
+              _justIoriginalTree :: ScalarExpr 
+              _justIuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 124, column 12)
+              _lhsOuType =
+                  _justIuType
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 100, column 12)
+              _justOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Just _justIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Just _justIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Just _justIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _justOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _justOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _justOlib =
+                  _lhsIlib
+              ( _justIannotatedTree,_justIfixedUpIdentifiersTree,_justIoriginalTree,_justIuType) =
+                  just_ _justOcat _justOexpectedType _justOidenv _justOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_MaybeScalarExpr_Nothing :: T_MaybeScalarExpr 
+sem_MaybeScalarExpr_Nothing  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: (Maybe Type)
+              _lhsOannotatedTree :: MaybeScalarExpr 
+              _lhsOfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _lhsOoriginalTree :: MaybeScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 125, column 15)
+              _lhsOuType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Nothing
+              -- self rule
+              _originalTree =
+                  Nothing
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+-- MaybeSelectList ---------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         listType             : [(String,Maybe Type)]
+         originalTree         : SELF 
+   alternatives:
+      alternative Just:
+         child just           : SelectList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nothing:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type MaybeSelectList  = Maybe SelectList 
+-- cata
+sem_MaybeSelectList :: MaybeSelectList  ->
+                       T_MaybeSelectList 
+sem_MaybeSelectList (Prelude.Just x )  =
+    (sem_MaybeSelectList_Just (sem_SelectList x ) )
+sem_MaybeSelectList Prelude.Nothing  =
+    sem_MaybeSelectList_Nothing
+-- semantic domain
+type T_MaybeSelectList  = Catalog ->
+                          IDEnv ->
+                          LocalBindings ->
+                          ( MaybeSelectList ,MaybeSelectList ,([(String,Maybe Type)]),MaybeSelectList )
+data Inh_MaybeSelectList  = Inh_MaybeSelectList {cat_Inh_MaybeSelectList :: Catalog,idenv_Inh_MaybeSelectList :: IDEnv,lib_Inh_MaybeSelectList :: LocalBindings}
+data Syn_MaybeSelectList  = Syn_MaybeSelectList {annotatedTree_Syn_MaybeSelectList :: MaybeSelectList ,fixedUpIdentifiersTree_Syn_MaybeSelectList :: MaybeSelectList ,listType_Syn_MaybeSelectList :: ([(String,Maybe Type)]),originalTree_Syn_MaybeSelectList :: MaybeSelectList }
+wrap_MaybeSelectList :: T_MaybeSelectList  ->
+                        Inh_MaybeSelectList  ->
+                        Syn_MaybeSelectList 
+wrap_MaybeSelectList sem (Inh_MaybeSelectList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_MaybeSelectList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOlistType _lhsOoriginalTree ))
+sem_MaybeSelectList_Just :: T_SelectList  ->
+                            T_MaybeSelectList 
+sem_MaybeSelectList_Just just_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOlistType :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: MaybeSelectList 
+              _lhsOfixedUpIdentifiersTree :: MaybeSelectList 
+              _lhsOoriginalTree :: MaybeSelectList 
+              _justOcat :: Catalog
+              _justOidenv :: IDEnv
+              _justOlib :: LocalBindings
+              _justIannotatedTree :: SelectList 
+              _justIcidenv :: IDEnv
+              _justIfixedUpIdentifiersTree :: SelectList 
+              _justIlibUpdates :: ([LocalBindingsUpdate])
+              _justIlistType :: ([(String,Maybe Type)])
+              _justIoriginalTree :: SelectList 
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 38, column 12)
+              _lhsOlistType =
+                  _justIlistType
+              -- self rule
+              _annotatedTree =
+                  Just _justIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Just _justIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Just _justIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _justOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _justOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _justOlib =
+                  _lhsIlib
+              ( _justIannotatedTree,_justIcidenv,_justIfixedUpIdentifiersTree,_justIlibUpdates,_justIlistType,_justIoriginalTree) =
+                  just_ _justOcat _justOidenv _justOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+sem_MaybeSelectList_Nothing :: T_MaybeSelectList 
+sem_MaybeSelectList_Nothing  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOlistType :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: MaybeSelectList 
+              _lhsOfixedUpIdentifiersTree :: MaybeSelectList 
+              _lhsOoriginalTree :: MaybeSelectList 
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 39, column 15)
+              _lhsOlistType =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Nothing
+              -- self rule
+              _originalTree =
+                  Nothing
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+-- OnExpr ------------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Just:
+         child just           : JoinExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nothing:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type OnExpr  = Maybe JoinExpr 
+-- cata
+sem_OnExpr :: OnExpr  ->
+              T_OnExpr 
+sem_OnExpr (Prelude.Just x )  =
+    (sem_OnExpr_Just (sem_JoinExpr x ) )
+sem_OnExpr Prelude.Nothing  =
+    sem_OnExpr_Nothing
+-- semantic domain
+type T_OnExpr  = Catalog ->
+                 IDEnv ->
+                 LocalBindings ->
+                 ( OnExpr ,OnExpr ,OnExpr )
+data Inh_OnExpr  = Inh_OnExpr {cat_Inh_OnExpr :: Catalog,idenv_Inh_OnExpr :: IDEnv,lib_Inh_OnExpr :: LocalBindings}
+data Syn_OnExpr  = Syn_OnExpr {annotatedTree_Syn_OnExpr :: OnExpr ,fixedUpIdentifiersTree_Syn_OnExpr :: OnExpr ,originalTree_Syn_OnExpr :: OnExpr }
+wrap_OnExpr :: T_OnExpr  ->
+               Inh_OnExpr  ->
+               Syn_OnExpr 
+wrap_OnExpr sem (Inh_OnExpr _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_OnExpr _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_OnExpr_Just :: T_JoinExpr  ->
+                   T_OnExpr 
+sem_OnExpr_Just just_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: OnExpr 
+              _lhsOfixedUpIdentifiersTree :: OnExpr 
+              _lhsOoriginalTree :: OnExpr 
+              _justOcat :: Catalog
+              _justOidenv :: IDEnv
+              _justOlib :: LocalBindings
+              _justIannotatedTree :: JoinExpr 
+              _justIfixedUpIdentifiersTree :: JoinExpr 
+              _justIoriginalTree :: JoinExpr 
+              -- self rule
+              _annotatedTree =
+                  Just _justIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Just _justIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Just _justIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _justOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _justOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _justOlib =
+                  _lhsIlib
+              ( _justIannotatedTree,_justIfixedUpIdentifiersTree,_justIoriginalTree) =
+                  just_ _justOcat _justOidenv _justOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_OnExpr_Nothing :: T_OnExpr 
+sem_OnExpr_Nothing  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: OnExpr 
+              _lhsOfixedUpIdentifiersTree :: OnExpr 
+              _lhsOoriginalTree :: OnExpr 
+              -- self rule
+              _annotatedTree =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Nothing
+              -- self rule
+              _originalTree =
+                  Nothing
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ParamDef ----------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+         pos                  : Int
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         namedType            : Maybe Type
+         originalTree         : SELF 
+         paramName            : ParamName
+   alternatives:
+      alternative ParamDef:
+         child ann            : {Annotation}
+         child name           : {String}
+         child typ            : TypeName 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ParamDefTp:
+         child ann            : {Annotation}
+         child typ            : TypeName 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data ParamDef  = ParamDef (Annotation) (String) (TypeName ) 
+               | ParamDefTp (Annotation) (TypeName ) 
+               deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_ParamDef :: ParamDef  ->
+                T_ParamDef 
+sem_ParamDef (ParamDef _ann _name _typ )  =
+    (sem_ParamDef_ParamDef _ann _name (sem_TypeName _typ ) )
+sem_ParamDef (ParamDefTp _ann _typ )  =
+    (sem_ParamDef_ParamDefTp _ann (sem_TypeName _typ ) )
+-- semantic domain
+type T_ParamDef  = Catalog ->
+                   IDEnv ->
+                   LocalBindings ->
+                   Int ->
+                   ( ParamDef ,ParamDef ,(Maybe Type),ParamDef ,ParamName)
+data Inh_ParamDef  = Inh_ParamDef {cat_Inh_ParamDef :: Catalog,idenv_Inh_ParamDef :: IDEnv,lib_Inh_ParamDef :: LocalBindings,pos_Inh_ParamDef :: Int}
+data Syn_ParamDef  = Syn_ParamDef {annotatedTree_Syn_ParamDef :: ParamDef ,fixedUpIdentifiersTree_Syn_ParamDef :: ParamDef ,namedType_Syn_ParamDef :: (Maybe Type),originalTree_Syn_ParamDef :: ParamDef ,paramName_Syn_ParamDef :: ParamName}
+wrap_ParamDef :: T_ParamDef  ->
+                 Inh_ParamDef  ->
+                 Syn_ParamDef 
+wrap_ParamDef sem (Inh_ParamDef _lhsIcat _lhsIidenv _lhsIlib _lhsIpos )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName) = sem _lhsIcat _lhsIidenv _lhsIlib _lhsIpos 
+     in  (Syn_ParamDef _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOnamedType _lhsOoriginalTree _lhsOparamName ))
+sem_ParamDef_ParamDef :: Annotation ->
+                         String ->
+                         T_TypeName  ->
+                         T_ParamDef 
+sem_ParamDef_ParamDef ann_ name_ typ_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib
+       _lhsIpos ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOparamName :: ParamName
+              _lhsOannotatedTree :: ParamDef 
+              _lhsOfixedUpIdentifiersTree :: ParamDef 
+              _lhsOoriginalTree :: ParamDef 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 45, column 9)
+              _lhsOnamedType =
+                  _typInamedType
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 47, column 9)
+              _lhsOparamName =
+                  NamedParam _lhsIpos name_
+              -- self rule
+              _annotatedTree =
+                  ParamDef ann_ name_ _typIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ParamDef ann_ name_ _typIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ParamDef ann_ name_ _typIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName)))
+sem_ParamDef_ParamDefTp :: Annotation ->
+                           T_TypeName  ->
+                           T_ParamDef 
+sem_ParamDef_ParamDefTp ann_ typ_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib
+       _lhsIpos ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOparamName :: ParamName
+              _lhsOannotatedTree :: ParamDef 
+              _lhsOfixedUpIdentifiersTree :: ParamDef 
+              _lhsOoriginalTree :: ParamDef 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 45, column 9)
+              _lhsOnamedType =
+                  _typInamedType
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 49, column 9)
+              _lhsOparamName =
+                  UnnamedParam _lhsIpos
+              -- self rule
+              _annotatedTree =
+                  ParamDefTp ann_ _typIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ParamDefTp ann_ _typIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ParamDefTp ann_ _typIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree,_lhsOparamName)))
+-- ParamDefList ------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+         pos                  : Int
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         params               : [(ParamName, Maybe Type)]
+   alternatives:
+      alternative Cons:
+         child hd             : ParamDef 
+         child tl             : ParamDefList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ParamDefList  = [ParamDef ]
+-- cata
+sem_ParamDefList :: ParamDefList  ->
+                    T_ParamDefList 
+sem_ParamDefList list  =
+    (Prelude.foldr sem_ParamDefList_Cons sem_ParamDefList_Nil (Prelude.map sem_ParamDef list) )
+-- semantic domain
+type T_ParamDefList  = Catalog ->
+                       IDEnv ->
+                       LocalBindings ->
+                       Int ->
+                       ( ParamDefList ,ParamDefList ,ParamDefList ,([(ParamName, Maybe Type)]))
+data Inh_ParamDefList  = Inh_ParamDefList {cat_Inh_ParamDefList :: Catalog,idenv_Inh_ParamDefList :: IDEnv,lib_Inh_ParamDefList :: LocalBindings,pos_Inh_ParamDefList :: Int}
+data Syn_ParamDefList  = Syn_ParamDefList {annotatedTree_Syn_ParamDefList :: ParamDefList ,fixedUpIdentifiersTree_Syn_ParamDefList :: ParamDefList ,originalTree_Syn_ParamDefList :: ParamDefList ,params_Syn_ParamDefList :: ([(ParamName, Maybe Type)])}
+wrap_ParamDefList :: T_ParamDefList  ->
+                     Inh_ParamDefList  ->
+                     Syn_ParamDefList 
+wrap_ParamDefList sem (Inh_ParamDefList _lhsIcat _lhsIidenv _lhsIlib _lhsIpos )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOparams) = sem _lhsIcat _lhsIidenv _lhsIlib _lhsIpos 
+     in  (Syn_ParamDefList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOparams ))
+sem_ParamDefList_Cons :: T_ParamDef  ->
+                         T_ParamDefList  ->
+                         T_ParamDefList 
+sem_ParamDefList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib
+       _lhsIpos ->
+         (let _lhsOparams :: ([(ParamName, Maybe Type)])
+              _hdOpos :: Int
+              _tlOpos :: Int
+              _lhsOannotatedTree :: ParamDefList 
+              _lhsOfixedUpIdentifiersTree :: ParamDefList 
+              _lhsOoriginalTree :: ParamDefList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ParamDef 
+              _hdIfixedUpIdentifiersTree :: ParamDef 
+              _hdInamedType :: (Maybe Type)
+              _hdIoriginalTree :: ParamDef 
+              _hdIparamName :: ParamName
+              _tlIannotatedTree :: ParamDefList 
+              _tlIfixedUpIdentifiersTree :: ParamDefList 
+              _tlIoriginalTree :: ParamDefList 
+              _tlIparams :: ([(ParamName, Maybe Type)])
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 53, column 13)
+              _lhsOparams =
+                  ((_hdIparamName, _hdInamedType) : _tlIparams)
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 54, column 13)
+              _hdOpos =
+                  _lhsIpos
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 55, column 13)
+              _tlOpos =
+                  _lhsIpos + 1
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdInamedType,_hdIoriginalTree,_hdIparamName) =
+                  hd_ _hdOcat _hdOidenv _hdOlib _hdOpos 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIparams) =
+                  tl_ _tlOcat _tlOidenv _tlOlib _tlOpos 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOparams)))
+sem_ParamDefList_Nil :: T_ParamDefList 
+sem_ParamDefList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib
+       _lhsIpos ->
+         (let _lhsOparams :: ([(ParamName, Maybe Type)])
+              _lhsOannotatedTree :: ParamDefList 
+              _lhsOfixedUpIdentifiersTree :: ParamDefList 
+              _lhsOoriginalTree :: ParamDefList 
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 52, column 12)
+              _lhsOparams =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOparams)))
+-- QueryExpr ---------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         csql                 : LocalBindings
+         expectedTypes        : [Maybe Type]
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         cidenv               : IDEnv
+         fixedUpIdentifiersTree : SELF 
+         libUpdates           : [LocalBindingsUpdate]
+         originalTree         : SELF 
+         uType                : Maybe [(String,Type)]
+   alternatives:
+      alternative CombineQueryExpr:
+         child ann            : {Annotation}
+         child ctype          : {CombineType}
+         child sel1           : QueryExpr 
+         child sel2           : QueryExpr 
+         visit 0:
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Select:
+         child ann            : {Annotation}
+         child selDistinct    : {Distinct}
+         child selSelectList  : SelectList 
+         child selTref        : TableRefList 
+         child selWhere       : MaybeBoolExpr 
+         child selGroupBy     : ScalarExprList 
+         child selHaving      : MaybeBoolExpr 
+         child selOrderBy     : ScalarExprDirectionPairList 
+         child selLimit       : MaybeScalarExpr 
+         child selOffset      : MaybeScalarExpr 
+         visit 0:
+            local trefEnv     : _
+            local includeCorrelations : _
+            local newLib      : _
+            local slTypes     : {LocalBindings}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Values:
+         child ann            : {Annotation}
+         child vll            : ScalarExprListList 
+         visit 0:
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative WithQueryExpr:
+         child ann            : {Annotation}
+         child withs          : WithQueryList 
+         child ex             : QueryExpr 
+         visit 0:
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data QueryExpr  = CombineQueryExpr (Annotation) (CombineType) (QueryExpr ) (QueryExpr ) 
+                | Select (Annotation) (Distinct) (SelectList ) (TableRefList ) (MaybeBoolExpr ) (ScalarExprList ) (MaybeBoolExpr ) (ScalarExprDirectionPairList ) (MaybeScalarExpr ) (MaybeScalarExpr ) 
+                | Values (Annotation) (ScalarExprListList ) 
+                | WithQueryExpr (Annotation) (WithQueryList ) (QueryExpr ) 
+                deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_QueryExpr :: QueryExpr  ->
+                 T_QueryExpr 
+sem_QueryExpr (CombineQueryExpr _ann _ctype _sel1 _sel2 )  =
+    (sem_QueryExpr_CombineQueryExpr _ann _ctype (sem_QueryExpr _sel1 ) (sem_QueryExpr _sel2 ) )
+sem_QueryExpr (Select _ann _selDistinct _selSelectList _selTref _selWhere _selGroupBy _selHaving _selOrderBy _selLimit _selOffset )  =
+    (sem_QueryExpr_Select _ann _selDistinct (sem_SelectList _selSelectList ) (sem_TableRefList _selTref ) (sem_MaybeBoolExpr _selWhere ) (sem_ScalarExprList _selGroupBy ) (sem_MaybeBoolExpr _selHaving ) (sem_ScalarExprDirectionPairList _selOrderBy ) (sem_MaybeScalarExpr _selLimit ) (sem_MaybeScalarExpr _selOffset ) )
+sem_QueryExpr (Values _ann _vll )  =
+    (sem_QueryExpr_Values _ann (sem_ScalarExprListList _vll ) )
+sem_QueryExpr (WithQueryExpr _ann _withs _ex )  =
+    (sem_QueryExpr_WithQueryExpr _ann (sem_WithQueryList _withs ) (sem_QueryExpr _ex ) )
+-- semantic domain
+type T_QueryExpr  = Catalog ->
+                    LocalBindings ->
+                    ([Maybe Type]) ->
+                    IDEnv ->
+                    LocalBindings ->
+                    ( QueryExpr ,IDEnv,QueryExpr ,([LocalBindingsUpdate]),QueryExpr ,(Maybe [(String,Type)]))
+data Inh_QueryExpr  = Inh_QueryExpr {cat_Inh_QueryExpr :: Catalog,csql_Inh_QueryExpr :: LocalBindings,expectedTypes_Inh_QueryExpr :: ([Maybe Type]),idenv_Inh_QueryExpr :: IDEnv,lib_Inh_QueryExpr :: LocalBindings}
+data Syn_QueryExpr  = Syn_QueryExpr {annotatedTree_Syn_QueryExpr :: QueryExpr ,cidenv_Syn_QueryExpr :: IDEnv,fixedUpIdentifiersTree_Syn_QueryExpr :: QueryExpr ,libUpdates_Syn_QueryExpr :: ([LocalBindingsUpdate]),originalTree_Syn_QueryExpr :: QueryExpr ,uType_Syn_QueryExpr :: (Maybe [(String,Type)])}
+wrap_QueryExpr :: T_QueryExpr  ->
+                  Inh_QueryExpr  ->
+                  Syn_QueryExpr 
+wrap_QueryExpr sem (Inh_QueryExpr _lhsIcat _lhsIcsql _lhsIexpectedTypes _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOuType) = sem _lhsIcat _lhsIcsql _lhsIexpectedTypes _lhsIidenv _lhsIlib 
+     in  (Syn_QueryExpr _lhsOannotatedTree _lhsOcidenv _lhsOfixedUpIdentifiersTree _lhsOlibUpdates _lhsOoriginalTree _lhsOuType ))
+sem_QueryExpr_CombineQueryExpr :: Annotation ->
+                                  CombineType ->
+                                  T_QueryExpr  ->
+                                  T_QueryExpr  ->
+                                  T_QueryExpr 
+sem_QueryExpr_CombineQueryExpr ann_ ctype_ sel1_ sel2_  =
+    (\ _lhsIcat
+       _lhsIcsql
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOcidenv :: IDEnv
+              _lhsOannotatedTree :: QueryExpr 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: Et
+              _lhsOuType :: (Maybe [(String,Type)])
+              _lhsOfixedUpIdentifiersTree :: QueryExpr 
+              _lhsOoriginalTree :: QueryExpr 
+              _sel1Ocat :: Catalog
+              _sel1Ocsql :: LocalBindings
+              _sel1OexpectedTypes :: ([Maybe Type])
+              _sel1Oidenv :: IDEnv
+              _sel1Olib :: LocalBindings
+              _sel2Ocat :: Catalog
+              _sel2Ocsql :: LocalBindings
+              _sel2OexpectedTypes :: ([Maybe Type])
+              _sel2Oidenv :: IDEnv
+              _sel2Olib :: LocalBindings
+              _sel1IannotatedTree :: QueryExpr 
+              _sel1Icidenv :: IDEnv
+              _sel1IfixedUpIdentifiersTree :: QueryExpr 
+              _sel1IlibUpdates :: ([LocalBindingsUpdate])
+              _sel1IoriginalTree :: QueryExpr 
+              _sel1IuType :: (Maybe [(String,Type)])
+              _sel2IannotatedTree :: QueryExpr 
+              _sel2Icidenv :: IDEnv
+              _sel2IfixedUpIdentifiersTree :: QueryExpr 
+              _sel2IlibUpdates :: ([LocalBindingsUpdate])
+              _sel2IoriginalTree :: QueryExpr 
+              _sel2IuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 230, column 24)
+              _lhsOcidenv =
+                  _sel1Icidenv
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 29, column 9)
+              _lhsOannotatedTree =
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 141, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 168, column 9)
+              _tpe =
+                  do
+                  sel1t <- lmt ((SetOfType . CompositeType) <$> _sel1IuType)
+                  sel2t <- lmt ((SetOfType . CompositeType) <$> _sel2IuType)
+                  typeCheckCombineSelect _lhsIcat sel1t sel2t
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 174, column 9)
+              _backTree =
+                  CombineQueryExpr ann_ ctype_
+                                _sel1IannotatedTree
+                                _sel2IannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 185, column 9)
+              _lhsOuType =
+                  etmt (_tpe     >>= unwrapSetOfComposite)
+              -- self rule
+              _annotatedTree =
+                  CombineQueryExpr ann_ ctype_ _sel1IannotatedTree _sel2IannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CombineQueryExpr ann_ ctype_ _sel1IfixedUpIdentifiersTree _sel2IfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CombineQueryExpr ann_ ctype_ _sel1IoriginalTree _sel2IoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _sel1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _sel1Ocsql =
+                  _lhsIcsql
+              -- copy rule (down)
+              _sel1OexpectedTypes =
+                  _lhsIexpectedTypes
+              -- copy rule (down)
+              _sel1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _sel1Olib =
+                  _lhsIlib
+              -- copy rule (down)
+              _sel2Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _sel2Ocsql =
+                  _lhsIcsql
+              -- copy rule (down)
+              _sel2OexpectedTypes =
+                  _lhsIexpectedTypes
+              -- copy rule (down)
+              _sel2Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _sel2Olib =
+                  _lhsIlib
+              ( _sel1IannotatedTree,_sel1Icidenv,_sel1IfixedUpIdentifiersTree,_sel1IlibUpdates,_sel1IoriginalTree,_sel1IuType) =
+                  sel1_ _sel1Ocat _sel1Ocsql _sel1OexpectedTypes _sel1Oidenv _sel1Olib 
+              ( _sel2IannotatedTree,_sel2Icidenv,_sel2IfixedUpIdentifiersTree,_sel2IlibUpdates,_sel2IoriginalTree,_sel2IuType) =
+                  sel2_ _sel2Ocat _sel2Ocsql _sel2OexpectedTypes _sel2Oidenv _sel2Olib 
+          in  ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOuType)))
+sem_QueryExpr_Select :: Annotation ->
+                        Distinct ->
+                        T_SelectList  ->
+                        T_TableRefList  ->
+                        T_MaybeBoolExpr  ->
+                        T_ScalarExprList  ->
+                        T_MaybeBoolExpr  ->
+                        T_ScalarExprDirectionPairList  ->
+                        T_MaybeScalarExpr  ->
+                        T_MaybeScalarExpr  ->
+                        T_QueryExpr 
+sem_QueryExpr_Select ann_ selDistinct_ selSelectList_ selTref_ selWhere_ selGroupBy_ selHaving_ selOrderBy_ selLimit_ selOffset_  =
+    (\ _lhsIcat
+       _lhsIcsql
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: QueryExpr 
+              _lhsOcidenv :: IDEnv
+              _selSelectListOidenv :: IDEnv
+              _selWhereOidenv :: IDEnv
+              _selGroupByOidenv :: IDEnv
+              _selHavingOidenv :: IDEnv
+              _selOrderByOidenv :: IDEnv
+              _lhsOannotatedTree :: QueryExpr 
+              _selSelectListOlib :: LocalBindings
+              _selWhereOlib :: LocalBindings
+              _selHavingOlib :: LocalBindings
+              _selGroupByOlib :: LocalBindings
+              _slTypes :: LocalBindings
+              _selOrderByOlib :: LocalBindings
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: Et
+              _lhsOuType :: (Maybe [(String,Type)])
+              _selGroupByOexpectedTypes :: ([Maybe Type])
+              _lhsOoriginalTree :: QueryExpr 
+              _selSelectListOcat :: Catalog
+              _selTrefOcat :: Catalog
+              _selTrefOidenv :: IDEnv
+              _selTrefOlib :: LocalBindings
+              _selWhereOcat :: Catalog
+              _selGroupByOcat :: Catalog
+              _selHavingOcat :: Catalog
+              _selOrderByOcat :: Catalog
+              _selLimitOcat :: Catalog
+              _selLimitOidenv :: IDEnv
+              _selLimitOlib :: LocalBindings
+              _selOffsetOcat :: Catalog
+              _selOffsetOidenv :: IDEnv
+              _selOffsetOlib :: LocalBindings
+              _selSelectListIannotatedTree :: SelectList 
+              _selSelectListIcidenv :: IDEnv
+              _selSelectListIfixedUpIdentifiersTree :: SelectList 
+              _selSelectListIlibUpdates :: ([LocalBindingsUpdate])
+              _selSelectListIlistType :: ([(String,Maybe Type)])
+              _selSelectListIoriginalTree :: SelectList 
+              _selTrefIannotatedTree :: TableRefList 
+              _selTrefIfixedUpIdentifiersTree :: TableRefList 
+              _selTrefIlibUpdates :: ([LocalBindingsUpdate])
+              _selTrefInewLib2 :: LocalBindings
+              _selTrefIoriginalTree :: TableRefList 
+              _selTrefItrefIDs :: ([(String,[String])])
+              _selWhereIannotatedTree :: MaybeBoolExpr 
+              _selWhereIfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _selWhereIoriginalTree :: MaybeBoolExpr 
+              _selGroupByIannotatedTree :: ScalarExprList 
+              _selGroupByIfixedUpIdentifiersTree :: ScalarExprList 
+              _selGroupByIoriginalTree :: ScalarExprList 
+              _selGroupByIuType :: ([Maybe Type])
+              _selHavingIannotatedTree :: MaybeBoolExpr 
+              _selHavingIfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _selHavingIoriginalTree :: MaybeBoolExpr 
+              _selOrderByIannotatedTree :: ScalarExprDirectionPairList 
+              _selOrderByIfixedUpIdentifiersTree :: ScalarExprDirectionPairList 
+              _selOrderByIoriginalTree :: ScalarExprDirectionPairList 
+              _selLimitIannotatedTree :: MaybeScalarExpr 
+              _selLimitIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _selLimitIoriginalTree :: MaybeScalarExpr 
+              _selLimitIuType :: (Maybe Type)
+              _selOffsetIannotatedTree :: MaybeScalarExpr 
+              _selOffsetIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _selOffsetIoriginalTree :: MaybeScalarExpr 
+              _selOffsetIuType :: (Maybe Type)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 187, column 9)
+              _lhsOfixedUpIdentifiersTree =
+                  Select ann_
+                         selDistinct_
+                         _selSelectListIfixedUpIdentifiersTree
+                         _selTrefIfixedUpIdentifiersTree
+                         _selWhereIfixedUpIdentifiersTree
+                         _selGroupByIfixedUpIdentifiersTree
+                         _selHavingIfixedUpIdentifiersTree
+                         _selOrderByIfixedUpIdentifiersTree
+                         _selLimitIfixedUpIdentifiersTree
+                         _selOffsetIfixedUpIdentifiersTree
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 229, column 14)
+              _lhsOcidenv =
+                  _selSelectListIcidenv
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 270, column 14)
+              _trefEnv =
+                  makeIDEnvP _selTrefItrefIDs
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 271, column 14)
+              _includeCorrelations =
+                  joinIDEnvs _lhsIidenv _trefEnv
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 272, column 14)
+              _selSelectListOidenv =
+                  _trefEnv
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 273, column 14)
+              _selWhereOidenv =
+                  _includeCorrelations
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 274, column 14)
+              _selGroupByOidenv =
+                  _trefEnv
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 275, column 14)
+              _selHavingOidenv =
+                  _includeCorrelations
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 276, column 14)
+              _selOrderByOidenv =
+                  _trefEnv
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 29, column 9)
+              _lhsOannotatedTree =
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 101, column 10)
+              _newLib =
+                  _selTrefInewLib2
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 102, column 10)
+              _selSelectListOlib =
+                  _newLib
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 104, column 10)
+              _selWhereOlib =
+                  joinBindings _newLib     _lhsIcsql
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 105, column 10)
+              _selHavingOlib =
+                  joinBindings _newLib     _lhsIcsql
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 106, column 10)
+              _selGroupByOlib =
+                  _newLib
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 111, column 10)
+              _slTypes =
+                  createLocalBindings $ Just [("",_selSelectListIlistType)]
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 112, column 10)
+              _selOrderByOlib =
+                  joinBindings _slTypes     _newLib
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 143, column 9)
+              _lhsOlibUpdates =
+                  _selSelectListIlibUpdates
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 155, column 9)
+              _tpe =
+                  Right $ SetOfType $ CompositeType $ fromMaybe [] $ liftList  _selSelectListIlistType
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 157, column 9)
+              _backTree =
+                  Select ann_
+                         selDistinct_
+                         _selSelectListIannotatedTree
+                         _selTrefIannotatedTree
+                         _selWhereIannotatedTree
+                         _selGroupByIannotatedTree
+                         _selHavingIannotatedTree
+                         _selOrderByIannotatedTree
+                         _selLimitIannotatedTree
+                         _selOffsetIannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 185, column 9)
+              _lhsOuType =
+                  etmt (_tpe     >>= unwrapSetOfComposite)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 150, column 14)
+              _selGroupByOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Select ann_ selDistinct_ _selSelectListIannotatedTree _selTrefIannotatedTree _selWhereIannotatedTree _selGroupByIannotatedTree _selHavingIannotatedTree _selOrderByIannotatedTree _selLimitIannotatedTree _selOffsetIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Select ann_ selDistinct_ _selSelectListIfixedUpIdentifiersTree _selTrefIfixedUpIdentifiersTree _selWhereIfixedUpIdentifiersTree _selGroupByIfixedUpIdentifiersTree _selHavingIfixedUpIdentifiersTree _selOrderByIfixedUpIdentifiersTree _selLimitIfixedUpIdentifiersTree _selOffsetIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Select ann_ selDistinct_ _selSelectListIoriginalTree _selTrefIoriginalTree _selWhereIoriginalTree _selGroupByIoriginalTree _selHavingIoriginalTree _selOrderByIoriginalTree _selLimitIoriginalTree _selOffsetIoriginalTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selSelectListOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selTrefOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selTrefOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selTrefOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _selWhereOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selGroupByOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selHavingOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOrderByOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selLimitOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selLimitOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selLimitOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _selOffsetOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOffsetOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOffsetOlib =
+                  _lhsIlib
+              ( _selSelectListIannotatedTree,_selSelectListIcidenv,_selSelectListIfixedUpIdentifiersTree,_selSelectListIlibUpdates,_selSelectListIlistType,_selSelectListIoriginalTree) =
+                  selSelectList_ _selSelectListOcat _selSelectListOidenv _selSelectListOlib 
+              ( _selTrefIannotatedTree,_selTrefIfixedUpIdentifiersTree,_selTrefIlibUpdates,_selTrefInewLib2,_selTrefIoriginalTree,_selTrefItrefIDs) =
+                  selTref_ _selTrefOcat _selTrefOidenv _selTrefOlib 
+              ( _selWhereIannotatedTree,_selWhereIfixedUpIdentifiersTree,_selWhereIoriginalTree) =
+                  selWhere_ _selWhereOcat _selWhereOidenv _selWhereOlib 
+              ( _selGroupByIannotatedTree,_selGroupByIfixedUpIdentifiersTree,_selGroupByIoriginalTree,_selGroupByIuType) =
+                  selGroupBy_ _selGroupByOcat _selGroupByOexpectedTypes _selGroupByOidenv _selGroupByOlib 
+              ( _selHavingIannotatedTree,_selHavingIfixedUpIdentifiersTree,_selHavingIoriginalTree) =
+                  selHaving_ _selHavingOcat _selHavingOidenv _selHavingOlib 
+              ( _selOrderByIannotatedTree,_selOrderByIfixedUpIdentifiersTree,_selOrderByIoriginalTree) =
+                  selOrderBy_ _selOrderByOcat _selOrderByOidenv _selOrderByOlib 
+              ( _selLimitIannotatedTree,_selLimitIfixedUpIdentifiersTree,_selLimitIoriginalTree,_selLimitIuType) =
+                  selLimit_ _selLimitOcat _selLimitOidenv _selLimitOlib 
+              ( _selOffsetIannotatedTree,_selOffsetIfixedUpIdentifiersTree,_selOffsetIoriginalTree,_selOffsetIuType) =
+                  selOffset_ _selOffsetOcat _selOffsetOidenv _selOffsetOlib 
+          in  ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOuType)))
+sem_QueryExpr_Values :: Annotation ->
+                        T_ScalarExprListList  ->
+                        T_QueryExpr 
+sem_QueryExpr_Values ann_ vll_  =
+    (\ _lhsIcat
+       _lhsIcsql
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOcidenv :: IDEnv
+              _lhsOannotatedTree :: QueryExpr 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: Et
+              _lhsOuType :: (Maybe [(String,Type)])
+              _vllOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: QueryExpr 
+              _lhsOoriginalTree :: QueryExpr 
+              _vllOcat :: Catalog
+              _vllOidenv :: IDEnv
+              _vllOlib :: LocalBindings
+              _vllIannotatedTree :: ScalarExprListList 
+              _vllIfixedUpIdentifiersTree :: ScalarExprListList 
+              _vllIoriginalTree :: ScalarExprListList 
+              _vllIuType :: ([[Maybe Type]])
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 231, column 14)
+              _lhsOcidenv =
+                  unimplementedIDEnv
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 29, column 9)
+              _lhsOannotatedTree =
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 141, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 150, column 9)
+              _tpe =
+                  typeCheckValuesExpr
+                              _lhsIcat
+                              _vllIuType
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 153, column 9)
+              _backTree =
+                  Values ann_ _vllIannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 185, column 9)
+              _lhsOuType =
+                  etmt (_tpe     >>= unwrapSetOfComposite)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 164, column 14)
+              _vllOexpectedTypes =
+                  _lhsIexpectedTypes
+              -- self rule
+              _annotatedTree =
+                  Values ann_ _vllIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Values ann_ _vllIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Values ann_ _vllIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _vllOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _vllOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _vllOlib =
+                  _lhsIlib
+              ( _vllIannotatedTree,_vllIfixedUpIdentifiersTree,_vllIoriginalTree,_vllIuType) =
+                  vll_ _vllOcat _vllOexpectedTypes _vllOidenv _vllOlib 
+          in  ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOuType)))
+sem_QueryExpr_WithQueryExpr :: Annotation ->
+                               T_WithQueryList  ->
+                               T_QueryExpr  ->
+                               T_QueryExpr 
+sem_QueryExpr_WithQueryExpr ann_ withs_ ex_  =
+    (\ _lhsIcat
+       _lhsIcsql
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOcidenv :: IDEnv
+              _lhsOannotatedTree :: QueryExpr 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: Et
+              _exOcat :: Catalog
+              _withsOcatUpdates :: ([CatalogUpdate])
+              _lhsOuType :: (Maybe [(String,Type)])
+              _lhsOfixedUpIdentifiersTree :: QueryExpr 
+              _lhsOoriginalTree :: QueryExpr 
+              _withsOcat :: Catalog
+              _withsOidenv :: IDEnv
+              _withsOlib :: LocalBindings
+              _exOcsql :: LocalBindings
+              _exOexpectedTypes :: ([Maybe Type])
+              _exOidenv :: IDEnv
+              _exOlib :: LocalBindings
+              _withsIannotatedTree :: WithQueryList 
+              _withsIfixedUpIdentifiersTree :: WithQueryList 
+              _withsIoriginalTree :: WithQueryList 
+              _withsIproducedCat :: Catalog
+              _exIannotatedTree :: QueryExpr 
+              _exIcidenv :: IDEnv
+              _exIfixedUpIdentifiersTree :: QueryExpr 
+              _exIlibUpdates :: ([LocalBindingsUpdate])
+              _exIoriginalTree :: QueryExpr 
+              _exIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 232, column 21)
+              _lhsOcidenv =
+                  _exIcidenv
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 29, column 9)
+              _lhsOannotatedTree =
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 145, column 9)
+              _lhsOlibUpdates =
+                  _exIlibUpdates
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 178, column 9)
+              _tpe =
+                  lmt ((SetOfType . CompositeType) <$> _exIuType)
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 179, column 9)
+              _backTree =
+                  WithQueryExpr ann_ _withsIannotatedTree _exIannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 180, column 9)
+              _exOcat =
+                  _withsIproducedCat
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 181, column 9)
+              _withsOcatUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 185, column 9)
+              _lhsOuType =
+                  etmt (_tpe     >>= unwrapSetOfComposite)
+              -- self rule
+              _annotatedTree =
+                  WithQueryExpr ann_ _withsIannotatedTree _exIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  WithQueryExpr ann_ _withsIfixedUpIdentifiersTree _exIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  WithQueryExpr ann_ _withsIoriginalTree _exIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _withsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _withsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _withsOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _exOcsql =
+                  _lhsIcsql
+              -- copy rule (down)
+              _exOexpectedTypes =
+                  _lhsIexpectedTypes
+              -- copy rule (down)
+              _exOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exOlib =
+                  _lhsIlib
+              ( _withsIannotatedTree,_withsIfixedUpIdentifiersTree,_withsIoriginalTree,_withsIproducedCat) =
+                  withs_ _withsOcat _withsOcatUpdates _withsOidenv _withsOlib 
+              ( _exIannotatedTree,_exIcidenv,_exIfixedUpIdentifiersTree,_exIlibUpdates,_exIoriginalTree,_exIuType) =
+                  ex_ _exOcat _exOcsql _exOexpectedTypes _exOidenv _exOlib 
+          in  ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree,_lhsOuType)))
+-- Root --------------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         producedCat          : Catalog
+         producedLib          : LocalBindings
+   alternatives:
+      alternative Root:
+         child statements     : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data Root  = Root (StatementList ) 
+           deriving ( Show)
+-- cata
+sem_Root :: Root  ->
+            T_Root 
+sem_Root (Root _statements )  =
+    (sem_Root_Root (sem_StatementList _statements ) )
+-- semantic domain
+type T_Root  = Catalog ->
+               IDEnv ->
+               LocalBindings ->
+               ( Root ,Root ,Root ,Catalog,LocalBindings)
+data Inh_Root  = Inh_Root {cat_Inh_Root :: Catalog,idenv_Inh_Root :: IDEnv,lib_Inh_Root :: LocalBindings}
+data Syn_Root  = Syn_Root {annotatedTree_Syn_Root :: Root ,fixedUpIdentifiersTree_Syn_Root :: Root ,originalTree_Syn_Root :: Root ,producedCat_Syn_Root :: Catalog,producedLib_Syn_Root :: LocalBindings}
+wrap_Root :: T_Root  ->
+             Inh_Root  ->
+             Syn_Root 
+wrap_Root sem (Inh_Root _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_Root _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOproducedCat _lhsOproducedLib ))
+sem_Root_Root :: T_StatementList  ->
+                 T_Root 
+sem_Root_Root statements_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _statementsOcatUpdates :: ([CatalogUpdate])
+              _statementsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Root 
+              _lhsOfixedUpIdentifiersTree :: Root 
+              _lhsOoriginalTree :: Root 
+              _lhsOproducedCat :: Catalog
+              _lhsOproducedLib :: LocalBindings
+              _statementsOcat :: Catalog
+              _statementsOidenv :: IDEnv
+              _statementsOlib :: LocalBindings
+              _statementsIannotatedTree :: StatementList 
+              _statementsIfixedUpIdentifiersTree :: StatementList 
+              _statementsIoriginalTree :: StatementList 
+              _statementsIproducedCat :: Catalog
+              _statementsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 107, column 12)
+              _statementsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 108, column 12)
+              _statementsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Root _statementsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Root _statementsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Root _statementsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (up)
+              _lhsOproducedCat =
+                  _statementsIproducedCat
+              -- copy rule (up)
+              _lhsOproducedLib =
+                  _statementsIproducedLib
+              -- copy rule (down)
+              _statementsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _statementsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _statementsOlib =
+                  _lhsIlib
+              ( _statementsIannotatedTree,_statementsIfixedUpIdentifiersTree,_statementsIoriginalTree,_statementsIproducedCat,_statementsIproducedLib) =
+                  statements_ _statementsOcat _statementsOcatUpdates _statementsOidenv _statementsOlib _statementsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
+-- RowConstraint -----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative NotNullConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative NullConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative RowCheckConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative RowPrimaryKeyConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative RowReferenceConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         child table          : {String}
+         child att            : {Maybe String}
+         child onUpdate       : {Cascade}
+         child onDelete       : {Cascade}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative RowUniqueConstraint:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data RowConstraint  = NotNullConstraint (Annotation) (String) 
+                    | NullConstraint (Annotation) (String) 
+                    | RowCheckConstraint (Annotation) (String) (ScalarExpr ) 
+                    | RowPrimaryKeyConstraint (Annotation) (String) 
+                    | RowReferenceConstraint (Annotation) (String) (String) ((Maybe String)) (Cascade) (Cascade) 
+                    | RowUniqueConstraint (Annotation) (String) 
+                    deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_RowConstraint :: RowConstraint  ->
+                     T_RowConstraint 
+sem_RowConstraint (NotNullConstraint _ann _name )  =
+    (sem_RowConstraint_NotNullConstraint _ann _name )
+sem_RowConstraint (NullConstraint _ann _name )  =
+    (sem_RowConstraint_NullConstraint _ann _name )
+sem_RowConstraint (RowCheckConstraint _ann _name _expr )  =
+    (sem_RowConstraint_RowCheckConstraint _ann _name (sem_ScalarExpr _expr ) )
+sem_RowConstraint (RowPrimaryKeyConstraint _ann _name )  =
+    (sem_RowConstraint_RowPrimaryKeyConstraint _ann _name )
+sem_RowConstraint (RowReferenceConstraint _ann _name _table _att _onUpdate _onDelete )  =
+    (sem_RowConstraint_RowReferenceConstraint _ann _name _table _att _onUpdate _onDelete )
+sem_RowConstraint (RowUniqueConstraint _ann _name )  =
+    (sem_RowConstraint_RowUniqueConstraint _ann _name )
+-- semantic domain
+type T_RowConstraint  = Catalog ->
+                        IDEnv ->
+                        LocalBindings ->
+                        ( RowConstraint ,RowConstraint ,RowConstraint )
+data Inh_RowConstraint  = Inh_RowConstraint {cat_Inh_RowConstraint :: Catalog,idenv_Inh_RowConstraint :: IDEnv,lib_Inh_RowConstraint :: LocalBindings}
+data Syn_RowConstraint  = Syn_RowConstraint {annotatedTree_Syn_RowConstraint :: RowConstraint ,fixedUpIdentifiersTree_Syn_RowConstraint :: RowConstraint ,originalTree_Syn_RowConstraint :: RowConstraint }
+wrap_RowConstraint :: T_RowConstraint  ->
+                      Inh_RowConstraint  ->
+                      Syn_RowConstraint 
+wrap_RowConstraint sem (Inh_RowConstraint _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_RowConstraint _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_RowConstraint_NotNullConstraint :: Annotation ->
+                                       String ->
+                                       T_RowConstraint 
+sem_RowConstraint_NotNullConstraint ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              -- self rule
+              _annotatedTree =
+                  NotNullConstraint ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NotNullConstraint ann_ name_
+              -- self rule
+              _originalTree =
+                  NotNullConstraint ann_ name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraint_NullConstraint :: Annotation ->
+                                    String ->
+                                    T_RowConstraint 
+sem_RowConstraint_NullConstraint ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              -- self rule
+              _annotatedTree =
+                  NullConstraint ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NullConstraint ann_ name_
+              -- self rule
+              _originalTree =
+                  NullConstraint ann_ name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraint_RowCheckConstraint :: Annotation ->
+                                        String ->
+                                        T_ScalarExpr  ->
+                                        T_RowConstraint 
+sem_RowConstraint_RowCheckConstraint ann_ name_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 103, column 26)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  RowCheckConstraint ann_ name_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  RowCheckConstraint ann_ name_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  RowCheckConstraint ann_ name_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraint_RowPrimaryKeyConstraint :: Annotation ->
+                                             String ->
+                                             T_RowConstraint 
+sem_RowConstraint_RowPrimaryKeyConstraint ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              -- self rule
+              _annotatedTree =
+                  RowPrimaryKeyConstraint ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  RowPrimaryKeyConstraint ann_ name_
+              -- self rule
+              _originalTree =
+                  RowPrimaryKeyConstraint ann_ name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraint_RowReferenceConstraint :: Annotation ->
+                                            String ->
+                                            String ->
+                                            (Maybe String) ->
+                                            Cascade ->
+                                            Cascade ->
+                                            T_RowConstraint 
+sem_RowConstraint_RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              -- self rule
+              _annotatedTree =
+                  RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_
+              -- self rule
+              _originalTree =
+                  RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraint_RowUniqueConstraint :: Annotation ->
+                                         String ->
+                                         T_RowConstraint 
+sem_RowConstraint_RowUniqueConstraint ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraint 
+              _lhsOfixedUpIdentifiersTree :: RowConstraint 
+              _lhsOoriginalTree :: RowConstraint 
+              -- self rule
+              _annotatedTree =
+                  RowUniqueConstraint ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  RowUniqueConstraint ann_ name_
+              -- self rule
+              _originalTree =
+                  RowUniqueConstraint ann_ name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- RowConstraintList -------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : RowConstraint 
+         child tl             : RowConstraintList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type RowConstraintList  = [RowConstraint ]
+-- cata
+sem_RowConstraintList :: RowConstraintList  ->
+                         T_RowConstraintList 
+sem_RowConstraintList list  =
+    (Prelude.foldr sem_RowConstraintList_Cons sem_RowConstraintList_Nil (Prelude.map sem_RowConstraint list) )
+-- semantic domain
+type T_RowConstraintList  = Catalog ->
+                            IDEnv ->
+                            LocalBindings ->
+                            ( RowConstraintList ,RowConstraintList ,RowConstraintList )
+data Inh_RowConstraintList  = Inh_RowConstraintList {cat_Inh_RowConstraintList :: Catalog,idenv_Inh_RowConstraintList :: IDEnv,lib_Inh_RowConstraintList :: LocalBindings}
+data Syn_RowConstraintList  = Syn_RowConstraintList {annotatedTree_Syn_RowConstraintList :: RowConstraintList ,fixedUpIdentifiersTree_Syn_RowConstraintList :: RowConstraintList ,originalTree_Syn_RowConstraintList :: RowConstraintList }
+wrap_RowConstraintList :: T_RowConstraintList  ->
+                          Inh_RowConstraintList  ->
+                          Syn_RowConstraintList 
+wrap_RowConstraintList sem (Inh_RowConstraintList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_RowConstraintList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_RowConstraintList_Cons :: T_RowConstraint  ->
+                              T_RowConstraintList  ->
+                              T_RowConstraintList 
+sem_RowConstraintList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraintList 
+              _lhsOfixedUpIdentifiersTree :: RowConstraintList 
+              _lhsOoriginalTree :: RowConstraintList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: RowConstraint 
+              _hdIfixedUpIdentifiersTree :: RowConstraint 
+              _hdIoriginalTree :: RowConstraint 
+              _tlIannotatedTree :: RowConstraintList 
+              _tlIfixedUpIdentifiersTree :: RowConstraintList 
+              _tlIoriginalTree :: RowConstraintList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_RowConstraintList_Nil :: T_RowConstraintList 
+sem_RowConstraintList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: RowConstraintList 
+              _lhsOfixedUpIdentifiersTree :: RowConstraintList 
+              _lhsOoriginalTree :: RowConstraintList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- SQIdentifier ------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         tbAnnotatedTree      : SQIdentifier 
+         tbUType              : Maybe ([(String,Type)],[(String,Type)])
+   alternatives:
+      alternative SQIdentifier:
+         child ann            : {Annotation}
+         child is             : {[String]}
+         visit 0:
+            local tpe         : {E ([(String,Type)],[(String,Type)])}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data SQIdentifier  = SQIdentifier (Annotation) (([String])) 
+                   deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_SQIdentifier :: SQIdentifier  ->
+                    T_SQIdentifier 
+sem_SQIdentifier (SQIdentifier _ann _is )  =
+    (sem_SQIdentifier_SQIdentifier _ann _is )
+-- semantic domain
+type T_SQIdentifier  = Catalog ->
+                       IDEnv ->
+                       LocalBindings ->
+                       ( SQIdentifier ,SQIdentifier ,SQIdentifier ,SQIdentifier ,(Maybe ([(String,Type)],[(String,Type)])))
+data Inh_SQIdentifier  = Inh_SQIdentifier {cat_Inh_SQIdentifier :: Catalog,idenv_Inh_SQIdentifier :: IDEnv,lib_Inh_SQIdentifier :: LocalBindings}
+data Syn_SQIdentifier  = Syn_SQIdentifier {annotatedTree_Syn_SQIdentifier :: SQIdentifier ,fixedUpIdentifiersTree_Syn_SQIdentifier :: SQIdentifier ,originalTree_Syn_SQIdentifier :: SQIdentifier ,tbAnnotatedTree_Syn_SQIdentifier :: SQIdentifier ,tbUType_Syn_SQIdentifier :: (Maybe ([(String,Type)],[(String,Type)]))}
+wrap_SQIdentifier :: T_SQIdentifier  ->
+                     Inh_SQIdentifier  ->
+                     Syn_SQIdentifier 
+wrap_SQIdentifier sem (Inh_SQIdentifier _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOtbAnnotatedTree,_lhsOtbUType) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_SQIdentifier _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOtbAnnotatedTree _lhsOtbUType ))
+sem_SQIdentifier_SQIdentifier :: Annotation ->
+                                 ([String]) ->
+                                 T_SQIdentifier 
+sem_SQIdentifier_SQIdentifier ann_ is_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _tpe :: (E ([(String,Type)],[(String,Type)]))
+              _lhsOtbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              _lhsOtbAnnotatedTree :: SQIdentifier 
+              _lhsOannotatedTree :: SQIdentifier 
+              _lhsOfixedUpIdentifiersTree :: SQIdentifier 
+              _lhsOoriginalTree :: SQIdentifier 
+              -- "./TypeChecking/Misc.ag"(line 67, column 9)
+              _tpe =
+                  catCompositeAttrsPair _lhsIcat relationComposites (last is_)
+              -- "./TypeChecking/Misc.ag"(line 68, column 9)
+              _lhsOtbUType =
+                  either (const Nothing) Just _tpe
+              -- "./TypeChecking/Misc.ag"(line 69, column 9)
+              _lhsOtbAnnotatedTree =
+                  updateAnnotation
+                    (\a -> a {errs = errs a ++ tes _tpe    }) _backTree
+              -- "./TypeChecking/Misc.ag"(line 72, column 9)
+              _backTree =
+                  SQIdentifier ann_ is_
+              -- self rule
+              _annotatedTree =
+                  SQIdentifier ann_ is_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SQIdentifier ann_ is_
+              -- self rule
+              _originalTree =
+                  SQIdentifier ann_ is_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOtbAnnotatedTree,_lhsOtbUType)))
+-- ScalarExpr --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         expectedType         : Maybe Type
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         uType                : Maybe Type
+   alternatives:
+      alternative BooleanLit:
+         child ann            : {Annotation}
+         child b              : {Bool}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Case:
+         child ann            : {Annotation}
+         child cases          : CaseScalarExprListScalarExprPairList 
+         child els            : MaybeScalarExpr 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local whenTypes   : _
+            local thenTypes   : _
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CaseSimple:
+         child ann            : {Annotation}
+         child value          : ScalarExpr 
+         child cases          : CaseScalarExprListScalarExprPairList 
+         child els            : MaybeScalarExpr 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local whenTypes   : _
+            local thenTypes   : _
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Cast:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         child tn             : TypeName 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Exists:
+         child ann            : {Annotation}
+         child sel            : QueryExpr 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Extract:
+         child ann            : {Annotation}
+         child field          : {ExtractField}
+         child e              : ScalarExpr 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative FunCall:
+         child ann            : {Annotation}
+         child funName        : {String}
+         child args           : ScalarExprList 
+         visit 0:
+            local _tup1       : _
+            local tpe         : {Et}
+            local prototype   : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Identifier:
+         child ann            : {Annotation}
+         child i              : {String}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative InPredicate:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         child i              : {Bool}
+         child list           : InList 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local rt          : {Either [TypeError] Type}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Interval:
+         child ann            : {Annotation}
+         child value          : {String}
+         child field          : {IntervalField}
+         child prec           : {Maybe Int}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative LiftOperator:
+         child ann            : {Annotation}
+         child oper           : {String}
+         child flav           : {LiftFlavour}
+         child args           : ScalarExprList 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative NullLit:
+         child ann            : {Annotation}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative NumberLit:
+         child ann            : {Annotation}
+         child d              : {String}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Placeholder:
+         child ann            : {Annotation}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative PositionalArg:
+         child ann            : {Annotation}
+         child p              : {Integer}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative QIdentifier:
+         child ann            : {Annotation}
+         child qual           : ScalarExpr 
+         child i              : {String}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local qid         : {Maybe String}
+            local backTree    : _
+            local qAnnTreeNoUnrec : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ScalarSubQuery:
+         child ann            : {Annotation}
+         child sel            : QueryExpr 
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative StringLit:
+         child ann            : {Annotation}
+         child value          : {String}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative TypedStringLit:
+         child ann            : {Annotation}
+         child tn             : TypeName 
+         child value          : {String}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative WindowFn:
+         child ann            : {Annotation}
+         child fn             : ScalarExpr 
+         child partitionBy    : ScalarExprList 
+         child orderBy        : ScalarExprList 
+         child dir            : {Direction}
+         child frm            : {FrameClause}
+         visit 0:
+            local prototype   : {Maybe FunctionPrototype}
+            local tpe         : {Et}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data ScalarExpr  = BooleanLit (Annotation) (Bool) 
+                 | Case (Annotation) (CaseScalarExprListScalarExprPairList ) (MaybeScalarExpr ) 
+                 | CaseSimple (Annotation) (ScalarExpr ) (CaseScalarExprListScalarExprPairList ) (MaybeScalarExpr ) 
+                 | Cast (Annotation) (ScalarExpr ) (TypeName ) 
+                 | Exists (Annotation) (QueryExpr ) 
+                 | Extract (Annotation) (ExtractField) (ScalarExpr ) 
+                 | FunCall (Annotation) (String) (ScalarExprList ) 
+                 | Identifier (Annotation) (String) 
+                 | InPredicate (Annotation) (ScalarExpr ) (Bool) (InList ) 
+                 | Interval (Annotation) (String) (IntervalField) ((Maybe Int)) 
+                 | LiftOperator (Annotation) (String) (LiftFlavour) (ScalarExprList ) 
+                 | NullLit (Annotation) 
+                 | NumberLit (Annotation) (String) 
+                 | Placeholder (Annotation) 
+                 | PositionalArg (Annotation) (Integer) 
+                 | QIdentifier (Annotation) (ScalarExpr ) (String) 
+                 | ScalarSubQuery (Annotation) (QueryExpr ) 
+                 | StringLit (Annotation) (String) 
+                 | TypedStringLit (Annotation) (TypeName ) (String) 
+                 | WindowFn (Annotation) (ScalarExpr ) (ScalarExprList ) (ScalarExprList ) (Direction) (FrameClause) 
+                 deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_ScalarExpr :: ScalarExpr  ->
+                  T_ScalarExpr 
+sem_ScalarExpr (BooleanLit _ann _b )  =
+    (sem_ScalarExpr_BooleanLit _ann _b )
+sem_ScalarExpr (Case _ann _cases _els )  =
+    (sem_ScalarExpr_Case _ann (sem_CaseScalarExprListScalarExprPairList _cases ) (sem_MaybeScalarExpr _els ) )
+sem_ScalarExpr (CaseSimple _ann _value _cases _els )  =
+    (sem_ScalarExpr_CaseSimple _ann (sem_ScalarExpr _value ) (sem_CaseScalarExprListScalarExprPairList _cases ) (sem_MaybeScalarExpr _els ) )
+sem_ScalarExpr (Cast _ann _expr _tn )  =
+    (sem_ScalarExpr_Cast _ann (sem_ScalarExpr _expr ) (sem_TypeName _tn ) )
+sem_ScalarExpr (Exists _ann _sel )  =
+    (sem_ScalarExpr_Exists _ann (sem_QueryExpr _sel ) )
+sem_ScalarExpr (Extract _ann _field _e )  =
+    (sem_ScalarExpr_Extract _ann _field (sem_ScalarExpr _e ) )
+sem_ScalarExpr (FunCall _ann _funName _args )  =
+    (sem_ScalarExpr_FunCall _ann _funName (sem_ScalarExprList _args ) )
+sem_ScalarExpr (Identifier _ann _i )  =
+    (sem_ScalarExpr_Identifier _ann _i )
+sem_ScalarExpr (InPredicate _ann _expr _i _list )  =
+    (sem_ScalarExpr_InPredicate _ann (sem_ScalarExpr _expr ) _i (sem_InList _list ) )
+sem_ScalarExpr (Interval _ann _value _field _prec )  =
+    (sem_ScalarExpr_Interval _ann _value _field _prec )
+sem_ScalarExpr (LiftOperator _ann _oper _flav _args )  =
+    (sem_ScalarExpr_LiftOperator _ann _oper _flav (sem_ScalarExprList _args ) )
+sem_ScalarExpr (NullLit _ann )  =
+    (sem_ScalarExpr_NullLit _ann )
+sem_ScalarExpr (NumberLit _ann _d )  =
+    (sem_ScalarExpr_NumberLit _ann _d )
+sem_ScalarExpr (Placeholder _ann )  =
+    (sem_ScalarExpr_Placeholder _ann )
+sem_ScalarExpr (PositionalArg _ann _p )  =
+    (sem_ScalarExpr_PositionalArg _ann _p )
+sem_ScalarExpr (QIdentifier _ann _qual _i )  =
+    (sem_ScalarExpr_QIdentifier _ann (sem_ScalarExpr _qual ) _i )
+sem_ScalarExpr (ScalarSubQuery _ann _sel )  =
+    (sem_ScalarExpr_ScalarSubQuery _ann (sem_QueryExpr _sel ) )
+sem_ScalarExpr (StringLit _ann _value )  =
+    (sem_ScalarExpr_StringLit _ann _value )
+sem_ScalarExpr (TypedStringLit _ann _tn _value )  =
+    (sem_ScalarExpr_TypedStringLit _ann (sem_TypeName _tn ) _value )
+sem_ScalarExpr (WindowFn _ann _fn _partitionBy _orderBy _dir _frm )  =
+    (sem_ScalarExpr_WindowFn _ann (sem_ScalarExpr _fn ) (sem_ScalarExprList _partitionBy ) (sem_ScalarExprList _orderBy ) _dir _frm )
+-- semantic domain
+type T_ScalarExpr  = Catalog ->
+                     (Maybe Type) ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( ScalarExpr ,ScalarExpr ,ScalarExpr ,(Maybe Type))
+data Inh_ScalarExpr  = Inh_ScalarExpr {cat_Inh_ScalarExpr :: Catalog,expectedType_Inh_ScalarExpr :: (Maybe Type),idenv_Inh_ScalarExpr :: IDEnv,lib_Inh_ScalarExpr :: LocalBindings}
+data Syn_ScalarExpr  = Syn_ScalarExpr {annotatedTree_Syn_ScalarExpr :: ScalarExpr ,fixedUpIdentifiersTree_Syn_ScalarExpr :: ScalarExpr ,originalTree_Syn_ScalarExpr :: ScalarExpr ,uType_Syn_ScalarExpr :: (Maybe Type)}
+wrap_ScalarExpr :: T_ScalarExpr  ->
+                   Inh_ScalarExpr  ->
+                   Syn_ScalarExpr 
+wrap_ScalarExpr sem (Inh_ScalarExpr _lhsIcat _lhsIexpectedType _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType) = sem _lhsIcat _lhsIexpectedType _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExpr _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOuType ))
+sem_ScalarExpr_BooleanLit :: Annotation ->
+                             Bool ->
+                             T_ScalarExpr 
+sem_ScalarExpr_BooleanLit ann_ b_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 155, column 19)
+              _tpe =
+                  Right typeBool
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 165, column 9)
+              _backTree =
+                  BooleanLit ann_ b_
+              -- self rule
+              _annotatedTree =
+                  BooleanLit ann_ b_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  BooleanLit ann_ b_
+              -- self rule
+              _originalTree =
+                  BooleanLit ann_ b_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Case :: Annotation ->
+                       T_CaseScalarExprListScalarExprPairList  ->
+                       T_MaybeScalarExpr  ->
+                       T_ScalarExpr 
+sem_ScalarExpr_Case ann_ cases_ els_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _casesOcat :: Catalog
+              _casesOidenv :: IDEnv
+              _casesOlib :: LocalBindings
+              _elsOcat :: Catalog
+              _elsOidenv :: IDEnv
+              _elsOlib :: LocalBindings
+              _casesIannotatedTree :: CaseScalarExprListScalarExprPairList 
+              _casesIfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPairList 
+              _casesIoriginalTree :: CaseScalarExprListScalarExprPairList 
+              _casesIthenTypes :: ([Maybe Type])
+              _casesIwhenTypes :: ([[Maybe Type]])
+              _elsIannotatedTree :: MaybeScalarExpr 
+              _elsIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _elsIoriginalTree :: MaybeScalarExpr 
+              _elsIuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 276, column 9)
+              _whenTypes =
+                  _casesIwhenTypes
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 277, column 9)
+              _thenTypes =
+                  _casesIthenTypes ++ maybe [] ((:[]) . Just) _elsIuType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 281, column 9)
+              _tpe =
+                  do
+                  wt <- mapM lmt $ concat _whenTypes
+                  errorWhen (any (/= typeBool) wt)
+                      [WrongTypes typeBool wt]
+                  tt <- mapM lmt _thenTypes
+                  resolveResultSetType _lhsIcat tt
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 289, column 9)
+              _backTree =
+                  Case ann_ _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  Case ann_ _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Case ann_ _casesIfixedUpIdentifiersTree _elsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Case ann_ _casesIoriginalTree _elsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _casesOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _casesOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _casesOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _elsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _elsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _elsOlib =
+                  _lhsIlib
+              ( _casesIannotatedTree,_casesIfixedUpIdentifiersTree,_casesIoriginalTree,_casesIthenTypes,_casesIwhenTypes) =
+                  cases_ _casesOcat _casesOidenv _casesOlib 
+              ( _elsIannotatedTree,_elsIfixedUpIdentifiersTree,_elsIoriginalTree,_elsIuType) =
+                  els_ _elsOcat _elsOidenv _elsOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_CaseSimple :: Annotation ->
+                             T_ScalarExpr  ->
+                             T_CaseScalarExprListScalarExprPairList  ->
+                             T_MaybeScalarExpr  ->
+                             T_ScalarExpr 
+sem_ScalarExpr_CaseSimple ann_ value_ cases_ els_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _valueOcat :: Catalog
+              _valueOexpectedType :: (Maybe Type)
+              _valueOidenv :: IDEnv
+              _valueOlib :: LocalBindings
+              _casesOcat :: Catalog
+              _casesOidenv :: IDEnv
+              _casesOlib :: LocalBindings
+              _elsOcat :: Catalog
+              _elsOidenv :: IDEnv
+              _elsOlib :: LocalBindings
+              _valueIannotatedTree :: ScalarExpr 
+              _valueIfixedUpIdentifiersTree :: ScalarExpr 
+              _valueIoriginalTree :: ScalarExpr 
+              _valueIuType :: (Maybe Type)
+              _casesIannotatedTree :: CaseScalarExprListScalarExprPairList 
+              _casesIfixedUpIdentifiersTree :: CaseScalarExprListScalarExprPairList 
+              _casesIoriginalTree :: CaseScalarExprListScalarExprPairList 
+              _casesIthenTypes :: ([Maybe Type])
+              _casesIwhenTypes :: ([[Maybe Type]])
+              _elsIannotatedTree :: MaybeScalarExpr 
+              _elsIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _elsIoriginalTree :: MaybeScalarExpr 
+              _elsIuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 276, column 9)
+              _whenTypes =
+                  _casesIwhenTypes
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 277, column 9)
+              _thenTypes =
+                  _casesIthenTypes ++ maybe [] ((:[]) . Just) _elsIuType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 294, column 9)
+              _tpe =
+                  do
+                  wt <- mapM lmt $ concat _whenTypes
+                  vt <- lmt _valueIuType
+                  _ <- resolveResultSetType _lhsIcat (vt : wt)
+                  tt <- mapM lmt _thenTypes
+                  resolveResultSetType _lhsIcat tt
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 301, column 9)
+              _backTree =
+                  CaseSimple ann_
+                             _valueIannotatedTree
+                             _casesIannotatedTree
+                             _elsIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  CaseSimple ann_ _valueIannotatedTree _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CaseSimple ann_ _valueIfixedUpIdentifiersTree _casesIfixedUpIdentifiersTree _elsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CaseSimple ann_ _valueIoriginalTree _casesIoriginalTree _elsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _valueOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _valueOexpectedType =
+                  _lhsIexpectedType
+              -- copy rule (down)
+              _valueOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _valueOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _casesOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _casesOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _casesOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _elsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _elsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _elsOlib =
+                  _lhsIlib
+              ( _valueIannotatedTree,_valueIfixedUpIdentifiersTree,_valueIoriginalTree,_valueIuType) =
+                  value_ _valueOcat _valueOexpectedType _valueOidenv _valueOlib 
+              ( _casesIannotatedTree,_casesIfixedUpIdentifiersTree,_casesIoriginalTree,_casesIthenTypes,_casesIwhenTypes) =
+                  cases_ _casesOcat _casesOidenv _casesOlib 
+              ( _elsIannotatedTree,_elsIfixedUpIdentifiersTree,_elsIoriginalTree,_elsIuType) =
+                  els_ _elsOcat _elsOidenv _elsOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Cast :: Annotation ->
+                       T_ScalarExpr  ->
+                       T_TypeName  ->
+                       T_ScalarExpr 
+sem_ScalarExpr_Cast ann_ expr_ tn_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _exprOcat :: Catalog
+              _exprOexpectedType :: (Maybe Type)
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _tnOcat :: Catalog
+              _tnOidenv :: IDEnv
+              _tnOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              _tnIannotatedTree :: TypeName 
+              _tnIfixedUpIdentifiersTree :: TypeName 
+              _tnInamedType :: (Maybe Type)
+              _tnIoriginalTree :: TypeName 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 182, column 12)
+              _tpe =
+                  lmt _tnInamedType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 183, column 12)
+              _backTree =
+                  Cast ann_ _exprIannotatedTree _tnIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  Cast ann_ _exprIannotatedTree _tnIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Cast ann_ _exprIfixedUpIdentifiersTree _tnIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Cast ann_ _exprIoriginalTree _tnIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOexpectedType =
+                  _lhsIexpectedType
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tnOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tnOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tnOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+              ( _tnIannotatedTree,_tnIfixedUpIdentifiersTree,_tnInamedType,_tnIoriginalTree) =
+                  tn_ _tnOcat _tnOidenv _tnOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Exists :: Annotation ->
+                         T_QueryExpr  ->
+                         T_ScalarExpr 
+sem_ScalarExpr_Exists ann_ sel_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _selOcsql :: LocalBindings
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 355, column 9)
+              _tpe =
+                  Right typeBool
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 356, column 9)
+              _backTree =
+                  Exists ann_ _selIannotatedTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 379, column 9)
+              _selOcsql =
+                  _lhsIlib
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 171, column 29)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Exists ann_ _selIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Exists ann_ _selIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Exists ann_ _selIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Extract :: Annotation ->
+                          ExtractField ->
+                          T_ScalarExpr  ->
+                          T_ScalarExpr 
+sem_ScalarExpr_Extract ann_ field_ e_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _eOcat :: Catalog
+              _eOexpectedType :: (Maybe Type)
+              _eOidenv :: IDEnv
+              _eOlib :: LocalBindings
+              _eIannotatedTree :: ScalarExpr 
+              _eIfixedUpIdentifiersTree :: ScalarExpr 
+              _eIoriginalTree :: ScalarExpr 
+              _eIuType :: (Maybe Type)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 424, column 9)
+              _tpe =
+                  do
+                  x <- lmt _eIuType
+                  if x == typeDate
+                    then Right typeFloat8
+                    else Left [NoMatchingOperator "extract" [x]]
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 429, column 9)
+              _backTree =
+                  Extract ann_ field_ _eIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  Extract ann_ field_ _eIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Extract ann_ field_ _eIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Extract ann_ field_ _eIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _eOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _eOexpectedType =
+                  _lhsIexpectedType
+              -- copy rule (down)
+              _eOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _eOlib =
+                  _lhsIlib
+              ( _eIannotatedTree,_eIfixedUpIdentifiersTree,_eIoriginalTree,_eIuType) =
+                  e_ _eOcat _eOexpectedType _eOidenv _eOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_FunCall :: Annotation ->
+                          String ->
+                          T_ScalarExprList  ->
+                          T_ScalarExpr 
+sem_ScalarExpr_FunCall ann_ funName_ args_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _argsOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _argsOcat :: Catalog
+              _argsOidenv :: IDEnv
+              _argsOlib :: LocalBindings
+              _argsIannotatedTree :: ScalarExprList 
+              _argsIfixedUpIdentifiersTree :: ScalarExprList 
+              _argsIoriginalTree :: ScalarExprList 
+              _argsIuType :: ([Maybe Type])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 196, column 9)
+              __tup1 =
+                  either (\e -> (Left e, Nothing)) id $ do
+                  args <- mapM lmt _argsIuType
+                  efp <- findCallMatch _lhsIcat
+                                       funName_
+                                       args
+                  let (_,_,r,_) = efp
+                  return (Right r, Just efp)
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 196, column 9)
+              (_tpe,_) =
+                  __tup1
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 196, column 9)
+              (_,_prototype) =
+                  __tup1
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 206, column 9)
+              _backTree =
+                  FunCall ann_ funName_ _argsIannotatedTree
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 130, column 9)
+              _argsOexpectedTypes =
+                  maybe [] id $
+                  case (funName_,_lhsIexpectedType) of
+                    ("!rowctor", Just (AnonymousRecordType ts)) -> return $ map Just ts
+                    _ -> do
+                         (_,t,_,_) <- _prototype
+                         return $ map Just t
+              -- self rule
+              _annotatedTree =
+                  FunCall ann_ funName_ _argsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  FunCall ann_ funName_ _argsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  FunCall ann_ funName_ _argsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _argsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _argsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _argsOlib =
+                  _lhsIlib
+              ( _argsIannotatedTree,_argsIfixedUpIdentifiersTree,_argsIoriginalTree,_argsIuType) =
+                  args_ _argsOcat _argsOexpectedTypes _argsOidenv _argsOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Identifier :: Annotation ->
+                             String ->
+                             T_ScalarExpr 
+sem_ScalarExpr_Identifier ann_ i_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 131, column 9)
+              _lhsOfixedUpIdentifiersTree =
+                  case qualifyID _lhsIidenv i_ of
+                    Nothing -> Identifier ann_ i_
+                    Just (t,i) -> QIdentifier ann_ (Identifier ann_ t) i
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 314, column 9)
+              _tpe =
+                  case lookupLocalBinding _lhsIlib "" i_ of
+                                        Right Nothing -> Left []
+                                        Right (Just t) -> Right t
+                                        Left e -> Left e
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 319, column 9)
+              _backTree =
+                  Identifier ann_ i_
+              -- self rule
+              _annotatedTree =
+                  Identifier ann_ i_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Identifier ann_ i_
+              -- self rule
+              _originalTree =
+                  Identifier ann_ i_
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_InPredicate :: Annotation ->
+                              T_ScalarExpr  ->
+                              Bool ->
+                              T_InList  ->
+                              T_ScalarExpr 
+sem_ScalarExpr_InPredicate ann_ expr_ i_ list_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _rt :: (Either [TypeError] Type)
+              _tpe :: Et
+              _listOexpectedType :: (Maybe Type)
+              _exprOexpectedType :: (Maybe Type)
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _listOcat :: Catalog
+              _listOidenv :: IDEnv
+              _listOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              _listIannotatedTree :: InList 
+              _listIfixedUpIdentifiersTree :: InList 
+              _listIlistType :: (Either [TypeError] Type)
+              _listIoriginalTree :: InList 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 388, column 9)
+              _rt =
+                  do
+                  lt <- _listIlistType
+                  expt <- lmt _exprIuType
+                  resolveResultSetType _lhsIcat [expt, lt]
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 392, column 9)
+              _tpe =
+                  do
+                  _ <- _rt
+                  return typeBool
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 395, column 9)
+              _listOexpectedType =
+                  etmt _rt
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 396, column 9)
+              _exprOexpectedType =
+                  etmt _rt
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 397, column 9)
+              _backTree =
+                  InPredicate ann_
+                              _exprIannotatedTree
+                              i_
+                              _listIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  InPredicate ann_ _exprIannotatedTree i_ _listIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  InPredicate ann_ _exprIfixedUpIdentifiersTree i_ _listIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  InPredicate ann_ _exprIoriginalTree i_ _listIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _listOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _listOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _listOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+              ( _listIannotatedTree,_listIfixedUpIdentifiersTree,_listIlistType,_listIoriginalTree) =
+                  list_ _listOcat _listOexpectedType _listOidenv _listOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Interval :: Annotation ->
+                           String ->
+                           IntervalField ->
+                           (Maybe Int) ->
+                           T_ScalarExpr 
+sem_ScalarExpr_Interval ann_ value_ field_ prec_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 170, column 16)
+              _tpe =
+                  Right $ ScalarType "interval"
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 171, column 16)
+              _backTree =
+                  Interval ann_ value_ field_ prec_
+              -- self rule
+              _annotatedTree =
+                  Interval ann_ value_ field_ prec_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Interval ann_ value_ field_ prec_
+              -- self rule
+              _originalTree =
+                  Interval ann_ value_ field_ prec_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_LiftOperator :: Annotation ->
+                               String ->
+                               LiftFlavour ->
+                               T_ScalarExprList  ->
+                               T_ScalarExpr 
+sem_ScalarExpr_LiftOperator ann_ oper_ flav_ args_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _argsOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _argsOcat :: Catalog
+              _argsOidenv :: IDEnv
+              _argsOlib :: LocalBindings
+              _argsIannotatedTree :: ScalarExprList 
+              _argsIfixedUpIdentifiersTree :: ScalarExprList 
+              _argsIoriginalTree :: ScalarExprList 
+              _argsIuType :: ([Maybe Type])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 229, column 9)
+              _tpe =
+                  do
+                  at <- mapM lmt _argsIuType
+                  errorWhen (length at /= 2)
+                            [AnyAllError $ "must have two args, got " ++ show at]
+                  let [aType,bType] = at
+                  errorWhen (not $ isArrayType bType)
+                            [AnyAllError $ "second arg must be array, got " ++ show at]
+                  elemType <- unwrapArray $ bType
+                  resType <- fmap (\(_,_,r,_) -> r) $ findCallMatch _lhsIcat
+                                                                    oper_
+                                                                    [aType,elemType]
+                  errorWhen (resType /= typeBool)
+                            [AnyAllError $ "operator must have bool return, got " ++ show resType]
+                  return resType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 243, column 9)
+              _backTree =
+                  LiftOperator ann_ oper_ flav_ _argsIannotatedTree
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 138, column 9)
+              _argsOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  LiftOperator ann_ oper_ flav_ _argsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  LiftOperator ann_ oper_ flav_ _argsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  LiftOperator ann_ oper_ flav_ _argsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _argsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _argsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _argsOlib =
+                  _lhsIlib
+              ( _argsIannotatedTree,_argsIfixedUpIdentifiersTree,_argsIoriginalTree,_argsIuType) =
+                  args_ _argsOcat _argsOexpectedTypes _argsOidenv _argsOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_NullLit :: Annotation ->
+                          T_ScalarExpr 
+sem_ScalarExpr_NullLit ann_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 157, column 16)
+              _tpe =
+                  Right UnknownType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 167, column 9)
+              _backTree =
+                  NullLit ann_
+              -- self rule
+              _annotatedTree =
+                  NullLit ann_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NullLit ann_
+              -- self rule
+              _originalTree =
+                  NullLit ann_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_NumberLit :: Annotation ->
+                            String ->
+                            T_ScalarExpr 
+sem_ScalarExpr_NumberLit ann_ d_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 149, column 18)
+              _tpe =
+                  if all (`elem` digChars) d_
+                  then Right typeInt
+                  else Right typeNumeric
+                  where
+                    digChars = concatMap show [(0::Int)..9]
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 161, column 9)
+              _backTree =
+                  NumberLit ann_ d_
+              -- self rule
+              _annotatedTree =
+                  NumberLit ann_ d_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NumberLit ann_ d_
+              -- self rule
+              _originalTree =
+                  NumberLit ann_ d_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_Placeholder :: Annotation ->
+                              T_ScalarExpr 
+sem_ScalarExpr_Placeholder ann_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 349, column 9)
+              _tpe =
+                  Right UnknownType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 350, column 9)
+              _backTree =
+                  Placeholder ann_
+              -- self rule
+              _annotatedTree =
+                  Placeholder ann_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Placeholder ann_
+              -- self rule
+              _originalTree =
+                  Placeholder ann_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_PositionalArg :: Annotation ->
+                                Integer ->
+                                T_ScalarExpr 
+sem_ScalarExpr_PositionalArg ann_ p_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 343, column 9)
+              _tpe =
+                  unwrapLookup <$> lbLookupID _lhsIlib ['$':show p_]
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 344, column 9)
+              _backTree =
+                  PositionalArg ann_ p_
+              -- self rule
+              _annotatedTree =
+                  PositionalArg ann_ p_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  PositionalArg ann_ p_
+              -- self rule
+              _originalTree =
+                  PositionalArg ann_ p_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_QIdentifier :: Annotation ->
+                              T_ScalarExpr  ->
+                              String ->
+                              T_ScalarExpr 
+sem_ScalarExpr_QIdentifier ann_ qual_ i_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _qid :: (Maybe String)
+              _lhsOoriginalTree :: ScalarExpr 
+              _qualOcat :: Catalog
+              _qualOexpectedType :: (Maybe Type)
+              _qualOidenv :: IDEnv
+              _qualOlib :: LocalBindings
+              _qualIannotatedTree :: ScalarExpr 
+              _qualIfixedUpIdentifiersTree :: ScalarExpr 
+              _qualIoriginalTree :: ScalarExpr 
+              _qualIuType :: (Maybe Type)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 137, column 9)
+              _lhsOfixedUpIdentifiersTree =
+                  QIdentifier ann_ _qualIoriginalTree i_
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 321, column 9)
+              _tpe =
+                  case _qid     of
+                            Nothing -> Left [InternalError "dot selection not implemented"]
+                            Just q -> case lookupLocalBinding _lhsIlib q i_ of
+                                        Right Nothing -> Left []
+                                        Right (Just t) -> Right t
+                                        Left e -> Left e
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 334, column 9)
+              _qid =
+                  case _backTree     of
+                     QIdentifier _ (Identifier _ q) _ -> Just q
+                     _ -> Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 337, column 9)
+              _backTree =
+                  QIdentifier ann_ _qAnnTreeNoUnrec     i_
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 339, column 9)
+              _qAnnTreeNoUnrec =
+                  updateAnnotation (\a -> a {errs = []}) _qualIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  QIdentifier ann_ _qualIannotatedTree i_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  QIdentifier ann_ _qualIfixedUpIdentifiersTree i_
+              -- self rule
+              _originalTree =
+                  QIdentifier ann_ _qualIoriginalTree i_
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _qualOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _qualOexpectedType =
+                  _lhsIexpectedType
+              -- copy rule (down)
+              _qualOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _qualOlib =
+                  _lhsIlib
+              ( _qualIannotatedTree,_qualIfixedUpIdentifiersTree,_qualIoriginalTree,_qualIuType) =
+                  qual_ _qualOcat _qualOexpectedType _qualOidenv _qualOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_ScalarSubQuery :: Annotation ->
+                                 T_QueryExpr  ->
+                                 T_ScalarExpr 
+sem_ScalarExpr_ScalarSubQuery ann_ sel_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _selOcsql :: LocalBindings
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 367, column 9)
+              _tpe =
+                  do
+                  selType <- lmt (map snd <$> _selIuType)
+                  case length selType of
+                    0 -> Left [InternalError "no columns in scalar subquery?"]
+                    1 -> Right $ head selType
+                    _ -> Right $ AnonymousRecordType selType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 375, column 9)
+              _backTree =
+                  ScalarSubQuery ann_ _selIannotatedTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 377, column 9)
+              _selOcsql =
+                  _lhsIlib
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 171, column 29)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  ScalarSubQuery ann_ _selIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ScalarSubQuery ann_ _selIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ScalarSubQuery ann_ _selIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_StringLit :: Annotation ->
+                            String ->
+                            T_ScalarExpr 
+sem_ScalarExpr_StringLit ann_ value_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 154, column 18)
+              _tpe =
+                  Right UnknownType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 163, column 9)
+              _backTree =
+                  StringLit ann_ value_
+              -- self rule
+              _annotatedTree =
+                  StringLit ann_ value_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  StringLit ann_ value_
+              -- self rule
+              _originalTree =
+                  StringLit ann_ value_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_TypedStringLit :: Annotation ->
+                                 T_TypeName  ->
+                                 String ->
+                                 T_ScalarExpr 
+sem_ScalarExpr_TypedStringLit ann_ tn_ value_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _tnOcat :: Catalog
+              _tnOidenv :: IDEnv
+              _tnOlib :: LocalBindings
+              _tnIannotatedTree :: TypeName 
+              _tnIfixedUpIdentifiersTree :: TypeName 
+              _tnInamedType :: (Maybe Type)
+              _tnIoriginalTree :: TypeName 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 187, column 10)
+              _tpe =
+                  lmt _tnInamedType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 188, column 10)
+              _backTree =
+                  TypedStringLit ann_ _tnIannotatedTree value_
+              -- self rule
+              _annotatedTree =
+                  TypedStringLit ann_ _tnIannotatedTree value_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  TypedStringLit ann_ _tnIfixedUpIdentifiersTree value_
+              -- self rule
+              _originalTree =
+                  TypedStringLit ann_ _tnIoriginalTree value_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tnOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tnOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tnOlib =
+                  _lhsIlib
+              ( _tnIannotatedTree,_tnIfixedUpIdentifiersTree,_tnInamedType,_tnIoriginalTree) =
+                  tn_ _tnOcat _tnOidenv _tnOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExpr_WindowFn :: Annotation ->
+                           T_ScalarExpr  ->
+                           T_ScalarExprList  ->
+                           T_ScalarExprList  ->
+                           Direction ->
+                           FrameClause ->
+                           T_ScalarExpr 
+sem_ScalarExpr_WindowFn ann_ fn_ partitionBy_ orderBy_ dir_ frm_  =
+    (\ _lhsIcat
+       _lhsIexpectedType
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExpr 
+              _prototype :: (Maybe FunctionPrototype)
+              _lhsOuType :: (Maybe Type)
+              _tpe :: Et
+              _partitionByOexpectedTypes :: ([Maybe Type])
+              _orderByOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: ScalarExpr 
+              _lhsOoriginalTree :: ScalarExpr 
+              _fnOcat :: Catalog
+              _fnOexpectedType :: (Maybe Type)
+              _fnOidenv :: IDEnv
+              _fnOlib :: LocalBindings
+              _partitionByOcat :: Catalog
+              _partitionByOidenv :: IDEnv
+              _partitionByOlib :: LocalBindings
+              _orderByOcat :: Catalog
+              _orderByOidenv :: IDEnv
+              _orderByOlib :: LocalBindings
+              _fnIannotatedTree :: ScalarExpr 
+              _fnIfixedUpIdentifiersTree :: ScalarExpr 
+              _fnIoriginalTree :: ScalarExpr 
+              _fnIuType :: (Maybe Type)
+              _partitionByIannotatedTree :: ScalarExprList 
+              _partitionByIfixedUpIdentifiersTree :: ScalarExprList 
+              _partitionByIoriginalTree :: ScalarExprList 
+              _partitionByIuType :: ([Maybe Type])
+              _orderByIannotatedTree :: ScalarExprList 
+              _orderByIfixedUpIdentifiersTree :: ScalarExprList 
+              _orderByIoriginalTree :: ScalarExprList 
+              _orderByIuType :: ([Maybe Type])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 24, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                    (setTypeAddErrorsA _tpe
+                     . \a -> a {fnProt = _prototype
+                               ,infType = msum [_lhsIexpectedType
+                                               ,etmt _tpe
+                                               ,Nothing]}) _backTree
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 46, column 9)
+              _prototype =
+                  Nothing
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 104, column 9)
+              _lhsOuType =
+                  etmt _tpe
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 210, column 9)
+              _tpe =
+                  lmt _fnIuType
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 211, column 9)
+              _backTree =
+                  WindowFn ann_
+                           _fnIannotatedTree
+                           _partitionByIannotatedTree
+                           _orderByIannotatedTree
+                           dir_
+                           frm_
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 140, column 9)
+              _partitionByOexpectedTypes =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 141, column 9)
+              _orderByOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  WindowFn ann_ _fnIannotatedTree _partitionByIannotatedTree _orderByIannotatedTree dir_ frm_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  WindowFn ann_ _fnIfixedUpIdentifiersTree _partitionByIfixedUpIdentifiersTree _orderByIfixedUpIdentifiersTree dir_ frm_
+              -- self rule
+              _originalTree =
+                  WindowFn ann_ _fnIoriginalTree _partitionByIoriginalTree _orderByIoriginalTree dir_ frm_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _fnOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _fnOexpectedType =
+                  _lhsIexpectedType
+              -- copy rule (down)
+              _fnOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _fnOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _partitionByOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _partitionByOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _partitionByOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _orderByOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _orderByOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _orderByOlib =
+                  _lhsIlib
+              ( _fnIannotatedTree,_fnIfixedUpIdentifiersTree,_fnIoriginalTree,_fnIuType) =
+                  fn_ _fnOcat _fnOexpectedType _fnOidenv _fnOlib 
+              ( _partitionByIannotatedTree,_partitionByIfixedUpIdentifiersTree,_partitionByIoriginalTree,_partitionByIuType) =
+                  partitionBy_ _partitionByOcat _partitionByOexpectedTypes _partitionByOidenv _partitionByOlib 
+              ( _orderByIannotatedTree,_orderByIfixedUpIdentifiersTree,_orderByIoriginalTree,_orderByIuType) =
+                  orderBy_ _orderByOcat _orderByOexpectedTypes _orderByOidenv _orderByOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+-- ScalarExprDirectionPair -------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Tuple:
+         child x1             : ScalarExpr 
+         child x2             : {Direction}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprDirectionPair  = ( ScalarExpr ,(Direction))
+-- cata
+sem_ScalarExprDirectionPair :: ScalarExprDirectionPair  ->
+                               T_ScalarExprDirectionPair 
+sem_ScalarExprDirectionPair ( x1,x2)  =
+    (sem_ScalarExprDirectionPair_Tuple (sem_ScalarExpr x1 ) x2 )
+-- semantic domain
+type T_ScalarExprDirectionPair  = Catalog ->
+                                  IDEnv ->
+                                  LocalBindings ->
+                                  ( ScalarExprDirectionPair ,ScalarExprDirectionPair ,ScalarExprDirectionPair )
+data Inh_ScalarExprDirectionPair  = Inh_ScalarExprDirectionPair {cat_Inh_ScalarExprDirectionPair :: Catalog,idenv_Inh_ScalarExprDirectionPair :: IDEnv,lib_Inh_ScalarExprDirectionPair :: LocalBindings}
+data Syn_ScalarExprDirectionPair  = Syn_ScalarExprDirectionPair {annotatedTree_Syn_ScalarExprDirectionPair :: ScalarExprDirectionPair ,fixedUpIdentifiersTree_Syn_ScalarExprDirectionPair :: ScalarExprDirectionPair ,originalTree_Syn_ScalarExprDirectionPair :: ScalarExprDirectionPair }
+wrap_ScalarExprDirectionPair :: T_ScalarExprDirectionPair  ->
+                                Inh_ScalarExprDirectionPair  ->
+                                Syn_ScalarExprDirectionPair 
+wrap_ScalarExprDirectionPair sem (Inh_ScalarExprDirectionPair _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprDirectionPair _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprDirectionPair_Tuple :: T_ScalarExpr  ->
+                                     Direction ->
+                                     T_ScalarExprDirectionPair 
+sem_ScalarExprDirectionPair_Tuple x1_ x2_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _x1OexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: ScalarExprDirectionPair 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprDirectionPair 
+              _lhsOoriginalTree :: ScalarExprDirectionPair 
+              _x1Ocat :: Catalog
+              _x1Oidenv :: IDEnv
+              _x1Olib :: LocalBindings
+              _x1IannotatedTree :: ScalarExpr 
+              _x1IfixedUpIdentifiersTree :: ScalarExpr 
+              _x1IoriginalTree :: ScalarExpr 
+              _x1IuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 83, column 13)
+              _x1OexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  (_x1IannotatedTree,x2_)
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (_x1IfixedUpIdentifiersTree,x2_)
+              -- self rule
+              _originalTree =
+                  (_x1IoriginalTree,x2_)
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _x1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x1Olib =
+                  _lhsIlib
+              ( _x1IannotatedTree,_x1IfixedUpIdentifiersTree,_x1IoriginalTree,_x1IuType) =
+                  x1_ _x1Ocat _x1OexpectedType _x1Oidenv _x1Olib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprDirectionPairList ---------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : ScalarExprDirectionPair 
+         child tl             : ScalarExprDirectionPairList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprDirectionPairList  = [ScalarExprDirectionPair ]
+-- cata
+sem_ScalarExprDirectionPairList :: ScalarExprDirectionPairList  ->
+                                   T_ScalarExprDirectionPairList 
+sem_ScalarExprDirectionPairList list  =
+    (Prelude.foldr sem_ScalarExprDirectionPairList_Cons sem_ScalarExprDirectionPairList_Nil (Prelude.map sem_ScalarExprDirectionPair list) )
+-- semantic domain
+type T_ScalarExprDirectionPairList  = Catalog ->
+                                      IDEnv ->
+                                      LocalBindings ->
+                                      ( ScalarExprDirectionPairList ,ScalarExprDirectionPairList ,ScalarExprDirectionPairList )
+data Inh_ScalarExprDirectionPairList  = Inh_ScalarExprDirectionPairList {cat_Inh_ScalarExprDirectionPairList :: Catalog,idenv_Inh_ScalarExprDirectionPairList :: IDEnv,lib_Inh_ScalarExprDirectionPairList :: LocalBindings}
+data Syn_ScalarExprDirectionPairList  = Syn_ScalarExprDirectionPairList {annotatedTree_Syn_ScalarExprDirectionPairList :: ScalarExprDirectionPairList ,fixedUpIdentifiersTree_Syn_ScalarExprDirectionPairList :: ScalarExprDirectionPairList ,originalTree_Syn_ScalarExprDirectionPairList :: ScalarExprDirectionPairList }
+wrap_ScalarExprDirectionPairList :: T_ScalarExprDirectionPairList  ->
+                                    Inh_ScalarExprDirectionPairList  ->
+                                    Syn_ScalarExprDirectionPairList 
+wrap_ScalarExprDirectionPairList sem (Inh_ScalarExprDirectionPairList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprDirectionPairList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprDirectionPairList_Cons :: T_ScalarExprDirectionPair  ->
+                                        T_ScalarExprDirectionPairList  ->
+                                        T_ScalarExprDirectionPairList 
+sem_ScalarExprDirectionPairList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprDirectionPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprDirectionPairList 
+              _lhsOoriginalTree :: ScalarExprDirectionPairList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ScalarExprDirectionPair 
+              _hdIfixedUpIdentifiersTree :: ScalarExprDirectionPair 
+              _hdIoriginalTree :: ScalarExprDirectionPair 
+              _tlIannotatedTree :: ScalarExprDirectionPairList 
+              _tlIfixedUpIdentifiersTree :: ScalarExprDirectionPairList 
+              _tlIoriginalTree :: ScalarExprDirectionPairList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_ScalarExprDirectionPairList_Nil :: T_ScalarExprDirectionPairList 
+sem_ScalarExprDirectionPairList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprDirectionPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprDirectionPairList 
+              _lhsOoriginalTree :: ScalarExprDirectionPairList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprList ----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         expectedTypes        : [Maybe Type]
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         uType                : [Maybe Type]
+   alternatives:
+      alternative Cons:
+         child hd             : ScalarExpr 
+         child tl             : ScalarExprList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprList  = [ScalarExpr ]
+-- cata
+sem_ScalarExprList :: ScalarExprList  ->
+                      T_ScalarExprList 
+sem_ScalarExprList list  =
+    (Prelude.foldr sem_ScalarExprList_Cons sem_ScalarExprList_Nil (Prelude.map sem_ScalarExpr list) )
+-- semantic domain
+type T_ScalarExprList  = Catalog ->
+                         ([Maybe Type]) ->
+                         IDEnv ->
+                         LocalBindings ->
+                         ( ScalarExprList ,ScalarExprList ,ScalarExprList ,([Maybe Type]))
+data Inh_ScalarExprList  = Inh_ScalarExprList {cat_Inh_ScalarExprList :: Catalog,expectedTypes_Inh_ScalarExprList :: ([Maybe Type]),idenv_Inh_ScalarExprList :: IDEnv,lib_Inh_ScalarExprList :: LocalBindings}
+data Syn_ScalarExprList  = Syn_ScalarExprList {annotatedTree_Syn_ScalarExprList :: ScalarExprList ,fixedUpIdentifiersTree_Syn_ScalarExprList :: ScalarExprList ,originalTree_Syn_ScalarExprList :: ScalarExprList ,uType_Syn_ScalarExprList :: ([Maybe Type])}
+wrap_ScalarExprList :: T_ScalarExprList  ->
+                       Inh_ScalarExprList  ->
+                       Syn_ScalarExprList 
+wrap_ScalarExprList sem (Inh_ScalarExprList _lhsIcat _lhsIexpectedTypes _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType) = sem _lhsIcat _lhsIexpectedTypes _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOuType ))
+sem_ScalarExprList_Cons :: T_ScalarExpr  ->
+                           T_ScalarExprList  ->
+                           T_ScalarExprList 
+sem_ScalarExprList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: ([Maybe Type])
+              _hdOexpectedType :: (Maybe Type)
+              _tlOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: ScalarExprList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprList 
+              _lhsOoriginalTree :: ScalarExprList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ScalarExpr 
+              _hdIfixedUpIdentifiersTree :: ScalarExpr 
+              _hdIoriginalTree :: ScalarExpr 
+              _hdIuType :: (Maybe Type)
+              _tlIannotatedTree :: ScalarExprList 
+              _tlIfixedUpIdentifiersTree :: ScalarExprList 
+              _tlIoriginalTree :: ScalarExprList 
+              _tlIuType :: ([Maybe Type])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 107, column 12)
+              _lhsOuType =
+                  _hdIuType : _tlIuType
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 86, column 12)
+              _hdOexpectedType =
+                  case _lhsIexpectedTypes of
+                    (t:_) -> t
+                    _ -> Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 89, column 12)
+              _tlOexpectedTypes =
+                  case _lhsIexpectedTypes of
+                   (_:ts) -> ts
+                   _ -> []
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree,_hdIuType) =
+                  hd_ _hdOcat _hdOexpectedType _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIuType) =
+                  tl_ _tlOcat _tlOexpectedTypes _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExprList_Nil :: T_ScalarExprList 
+sem_ScalarExprList_Nil  =
+    (\ _lhsIcat
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: ([Maybe Type])
+              _lhsOannotatedTree :: ScalarExprList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprList 
+              _lhsOoriginalTree :: ScalarExprList 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 108, column 11)
+              _lhsOuType =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+-- ScalarExprListList ------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         expectedTypes        : [Maybe Type]
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         uType                : [[Maybe Type]]
+   alternatives:
+      alternative Cons:
+         child hd             : ScalarExprList 
+         child tl             : ScalarExprListList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprListList  = [ScalarExprList ]
+-- cata
+sem_ScalarExprListList :: ScalarExprListList  ->
+                          T_ScalarExprListList 
+sem_ScalarExprListList list  =
+    (Prelude.foldr sem_ScalarExprListList_Cons sem_ScalarExprListList_Nil (Prelude.map sem_ScalarExprList list) )
+-- semantic domain
+type T_ScalarExprListList  = Catalog ->
+                             ([Maybe Type]) ->
+                             IDEnv ->
+                             LocalBindings ->
+                             ( ScalarExprListList ,ScalarExprListList ,ScalarExprListList ,([[Maybe Type]]))
+data Inh_ScalarExprListList  = Inh_ScalarExprListList {cat_Inh_ScalarExprListList :: Catalog,expectedTypes_Inh_ScalarExprListList :: ([Maybe Type]),idenv_Inh_ScalarExprListList :: IDEnv,lib_Inh_ScalarExprListList :: LocalBindings}
+data Syn_ScalarExprListList  = Syn_ScalarExprListList {annotatedTree_Syn_ScalarExprListList :: ScalarExprListList ,fixedUpIdentifiersTree_Syn_ScalarExprListList :: ScalarExprListList ,originalTree_Syn_ScalarExprListList :: ScalarExprListList ,uType_Syn_ScalarExprListList :: ([[Maybe Type]])}
+wrap_ScalarExprListList :: T_ScalarExprListList  ->
+                           Inh_ScalarExprListList  ->
+                           Syn_ScalarExprListList 
+wrap_ScalarExprListList sem (Inh_ScalarExprListList _lhsIcat _lhsIexpectedTypes _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType) = sem _lhsIcat _lhsIexpectedTypes _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprListList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOuType ))
+sem_ScalarExprListList_Cons :: T_ScalarExprList  ->
+                               T_ScalarExprListList  ->
+                               T_ScalarExprListList 
+sem_ScalarExprListList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: ([[Maybe Type]])
+              _hdOexpectedTypes :: ([Maybe Type])
+              _tlOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: ScalarExprListList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprListList 
+              _lhsOoriginalTree :: ScalarExprListList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ScalarExprList 
+              _hdIfixedUpIdentifiersTree :: ScalarExprList 
+              _hdIoriginalTree :: ScalarExprList 
+              _hdIuType :: ([Maybe Type])
+              _tlIannotatedTree :: ScalarExprListList 
+              _tlIfixedUpIdentifiersTree :: ScalarExprListList 
+              _tlIoriginalTree :: ScalarExprListList 
+              _tlIuType :: ([[Maybe Type]])
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 117, column 12)
+              _lhsOuType =
+                  _hdIuType : _tlIuType
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 167, column 12)
+              _hdOexpectedTypes =
+                  _lhsIexpectedTypes
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 168, column 12)
+              _tlOexpectedTypes =
+                  _lhsIexpectedTypes
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree,_hdIuType) =
+                  hd_ _hdOcat _hdOexpectedTypes _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIuType) =
+                  tl_ _tlOcat _tlOexpectedTypes _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+sem_ScalarExprListList_Nil :: T_ScalarExprListList 
+sem_ScalarExprListList_Nil  =
+    (\ _lhsIcat
+       _lhsIexpectedTypes
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOuType :: ([[Maybe Type]])
+              _lhsOannotatedTree :: ScalarExprListList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprListList 
+              _lhsOoriginalTree :: ScalarExprListList 
+              -- "./TypeChecking/ScalarExprs/ScalarExprs.ag"(line 118, column 11)
+              _lhsOuType =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOuType)))
+-- ScalarExprListStatementListPair -----------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Tuple:
+         child x1             : ScalarExprList 
+         child x2             : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprListStatementListPair  = ( ScalarExprList ,StatementList )
+-- cata
+sem_ScalarExprListStatementListPair :: ScalarExprListStatementListPair  ->
+                                       T_ScalarExprListStatementListPair 
+sem_ScalarExprListStatementListPair ( x1,x2)  =
+    (sem_ScalarExprListStatementListPair_Tuple (sem_ScalarExprList x1 ) (sem_StatementList x2 ) )
+-- semantic domain
+type T_ScalarExprListStatementListPair  = Catalog ->
+                                          IDEnv ->
+                                          LocalBindings ->
+                                          ( ScalarExprListStatementListPair ,ScalarExprListStatementListPair ,ScalarExprListStatementListPair )
+data Inh_ScalarExprListStatementListPair  = Inh_ScalarExprListStatementListPair {cat_Inh_ScalarExprListStatementListPair :: Catalog,idenv_Inh_ScalarExprListStatementListPair :: IDEnv,lib_Inh_ScalarExprListStatementListPair :: LocalBindings}
+data Syn_ScalarExprListStatementListPair  = Syn_ScalarExprListStatementListPair {annotatedTree_Syn_ScalarExprListStatementListPair :: ScalarExprListStatementListPair ,fixedUpIdentifiersTree_Syn_ScalarExprListStatementListPair :: ScalarExprListStatementListPair ,originalTree_Syn_ScalarExprListStatementListPair :: ScalarExprListStatementListPair }
+wrap_ScalarExprListStatementListPair :: T_ScalarExprListStatementListPair  ->
+                                        Inh_ScalarExprListStatementListPair  ->
+                                        Syn_ScalarExprListStatementListPair 
+wrap_ScalarExprListStatementListPair sem (Inh_ScalarExprListStatementListPair _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprListStatementListPair _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprListStatementListPair_Tuple :: T_ScalarExprList  ->
+                                             T_StatementList  ->
+                                             T_ScalarExprListStatementListPair 
+sem_ScalarExprListStatementListPair_Tuple x1_ x2_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _x2OcatUpdates :: ([CatalogUpdate])
+              _x2OlibUpdates :: ([LocalBindingsUpdate])
+              _x1OexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: ScalarExprListStatementListPair 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprListStatementListPair 
+              _lhsOoriginalTree :: ScalarExprListStatementListPair 
+              _x1Ocat :: Catalog
+              _x1Oidenv :: IDEnv
+              _x1Olib :: LocalBindings
+              _x2Ocat :: Catalog
+              _x2Oidenv :: IDEnv
+              _x2Olib :: LocalBindings
+              _x1IannotatedTree :: ScalarExprList 
+              _x1IfixedUpIdentifiersTree :: ScalarExprList 
+              _x1IoriginalTree :: ScalarExprList 
+              _x1IuType :: ([Maybe Type])
+              _x2IannotatedTree :: StatementList 
+              _x2IfixedUpIdentifiersTree :: StatementList 
+              _x2IoriginalTree :: StatementList 
+              _x2IproducedCat :: Catalog
+              _x2IproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 121, column 9)
+              _x2OcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 122, column 9)
+              _x2OlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 144, column 13)
+              _x1OexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  (_x1IannotatedTree,_x2IannotatedTree)
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (_x1IfixedUpIdentifiersTree,_x2IfixedUpIdentifiersTree)
+              -- self rule
+              _originalTree =
+                  (_x1IoriginalTree,_x2IoriginalTree)
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _x1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x1Olib =
+                  _lhsIlib
+              -- copy rule (down)
+              _x2Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x2Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x2Olib =
+                  _lhsIlib
+              ( _x1IannotatedTree,_x1IfixedUpIdentifiersTree,_x1IoriginalTree,_x1IuType) =
+                  x1_ _x1Ocat _x1OexpectedTypes _x1Oidenv _x1Olib 
+              ( _x2IannotatedTree,_x2IfixedUpIdentifiersTree,_x2IoriginalTree,_x2IproducedCat,_x2IproducedLib) =
+                  x2_ _x2Ocat _x2OcatUpdates _x2Oidenv _x2Olib _x2OlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprListStatementListPairList -------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : ScalarExprListStatementListPair 
+         child tl             : ScalarExprListStatementListPairList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprListStatementListPairList  = [ScalarExprListStatementListPair ]
+-- cata
+sem_ScalarExprListStatementListPairList :: ScalarExprListStatementListPairList  ->
+                                           T_ScalarExprListStatementListPairList 
+sem_ScalarExprListStatementListPairList list  =
+    (Prelude.foldr sem_ScalarExprListStatementListPairList_Cons sem_ScalarExprListStatementListPairList_Nil (Prelude.map sem_ScalarExprListStatementListPair list) )
+-- semantic domain
+type T_ScalarExprListStatementListPairList  = Catalog ->
+                                              IDEnv ->
+                                              LocalBindings ->
+                                              ( ScalarExprListStatementListPairList ,ScalarExprListStatementListPairList ,ScalarExprListStatementListPairList )
+data Inh_ScalarExprListStatementListPairList  = Inh_ScalarExprListStatementListPairList {cat_Inh_ScalarExprListStatementListPairList :: Catalog,idenv_Inh_ScalarExprListStatementListPairList :: IDEnv,lib_Inh_ScalarExprListStatementListPairList :: LocalBindings}
+data Syn_ScalarExprListStatementListPairList  = Syn_ScalarExprListStatementListPairList {annotatedTree_Syn_ScalarExprListStatementListPairList :: ScalarExprListStatementListPairList ,fixedUpIdentifiersTree_Syn_ScalarExprListStatementListPairList :: ScalarExprListStatementListPairList ,originalTree_Syn_ScalarExprListStatementListPairList :: ScalarExprListStatementListPairList }
+wrap_ScalarExprListStatementListPairList :: T_ScalarExprListStatementListPairList  ->
+                                            Inh_ScalarExprListStatementListPairList  ->
+                                            Syn_ScalarExprListStatementListPairList 
+wrap_ScalarExprListStatementListPairList sem (Inh_ScalarExprListStatementListPairList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprListStatementListPairList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprListStatementListPairList_Cons :: T_ScalarExprListStatementListPair  ->
+                                                T_ScalarExprListStatementListPairList  ->
+                                                T_ScalarExprListStatementListPairList 
+sem_ScalarExprListStatementListPairList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprListStatementListPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprListStatementListPairList 
+              _lhsOoriginalTree :: ScalarExprListStatementListPairList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ScalarExprListStatementListPair 
+              _hdIfixedUpIdentifiersTree :: ScalarExprListStatementListPair 
+              _hdIoriginalTree :: ScalarExprListStatementListPair 
+              _tlIannotatedTree :: ScalarExprListStatementListPairList 
+              _tlIfixedUpIdentifiersTree :: ScalarExprListStatementListPairList 
+              _tlIoriginalTree :: ScalarExprListStatementListPairList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_ScalarExprListStatementListPairList_Nil :: T_ScalarExprListStatementListPairList 
+sem_ScalarExprListStatementListPairList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprListStatementListPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprListStatementListPairList 
+              _lhsOoriginalTree :: ScalarExprListStatementListPairList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprRoot ----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative ScalarExprRoot:
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data ScalarExprRoot  = ScalarExprRoot (ScalarExpr ) 
+                     deriving ( Show)
+-- cata
+sem_ScalarExprRoot :: ScalarExprRoot  ->
+                      T_ScalarExprRoot 
+sem_ScalarExprRoot (ScalarExprRoot _expr )  =
+    (sem_ScalarExprRoot_ScalarExprRoot (sem_ScalarExpr _expr ) )
+-- semantic domain
+type T_ScalarExprRoot  = Catalog ->
+                         IDEnv ->
+                         LocalBindings ->
+                         ( ScalarExprRoot ,ScalarExprRoot ,ScalarExprRoot )
+data Inh_ScalarExprRoot  = Inh_ScalarExprRoot {cat_Inh_ScalarExprRoot :: Catalog,idenv_Inh_ScalarExprRoot :: IDEnv,lib_Inh_ScalarExprRoot :: LocalBindings}
+data Syn_ScalarExprRoot  = Syn_ScalarExprRoot {annotatedTree_Syn_ScalarExprRoot :: ScalarExprRoot ,fixedUpIdentifiersTree_Syn_ScalarExprRoot :: ScalarExprRoot ,originalTree_Syn_ScalarExprRoot :: ScalarExprRoot }
+wrap_ScalarExprRoot :: T_ScalarExprRoot  ->
+                       Inh_ScalarExprRoot  ->
+                       Syn_ScalarExprRoot 
+wrap_ScalarExprRoot sem (Inh_ScalarExprRoot _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprRoot _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprRoot_ScalarExprRoot :: T_ScalarExpr  ->
+                                     T_ScalarExprRoot 
+sem_ScalarExprRoot_ScalarExprRoot expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: ScalarExprRoot 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprRoot 
+              _lhsOoriginalTree :: ScalarExprRoot 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 123, column 22)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  ScalarExprRoot _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ScalarExprRoot _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ScalarExprRoot _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprStatementListPair ---------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Tuple:
+         child x1             : ScalarExpr 
+         child x2             : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprStatementListPair  = ( ScalarExpr ,StatementList )
+-- cata
+sem_ScalarExprStatementListPair :: ScalarExprStatementListPair  ->
+                                   T_ScalarExprStatementListPair 
+sem_ScalarExprStatementListPair ( x1,x2)  =
+    (sem_ScalarExprStatementListPair_Tuple (sem_ScalarExpr x1 ) (sem_StatementList x2 ) )
+-- semantic domain
+type T_ScalarExprStatementListPair  = Catalog ->
+                                      IDEnv ->
+                                      LocalBindings ->
+                                      ( ScalarExprStatementListPair ,ScalarExprStatementListPair ,ScalarExprStatementListPair )
+data Inh_ScalarExprStatementListPair  = Inh_ScalarExprStatementListPair {cat_Inh_ScalarExprStatementListPair :: Catalog,idenv_Inh_ScalarExprStatementListPair :: IDEnv,lib_Inh_ScalarExprStatementListPair :: LocalBindings}
+data Syn_ScalarExprStatementListPair  = Syn_ScalarExprStatementListPair {annotatedTree_Syn_ScalarExprStatementListPair :: ScalarExprStatementListPair ,fixedUpIdentifiersTree_Syn_ScalarExprStatementListPair :: ScalarExprStatementListPair ,originalTree_Syn_ScalarExprStatementListPair :: ScalarExprStatementListPair }
+wrap_ScalarExprStatementListPair :: T_ScalarExprStatementListPair  ->
+                                    Inh_ScalarExprStatementListPair  ->
+                                    Syn_ScalarExprStatementListPair 
+wrap_ScalarExprStatementListPair sem (Inh_ScalarExprStatementListPair _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprStatementListPair _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprStatementListPair_Tuple :: T_ScalarExpr  ->
+                                         T_StatementList  ->
+                                         T_ScalarExprStatementListPair 
+sem_ScalarExprStatementListPair_Tuple x1_ x2_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _x2OcatUpdates :: ([CatalogUpdate])
+              _x2OlibUpdates :: ([LocalBindingsUpdate])
+              _x1OexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: ScalarExprStatementListPair 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprStatementListPair 
+              _lhsOoriginalTree :: ScalarExprStatementListPair 
+              _x1Ocat :: Catalog
+              _x1Oidenv :: IDEnv
+              _x1Olib :: LocalBindings
+              _x2Ocat :: Catalog
+              _x2Oidenv :: IDEnv
+              _x2Olib :: LocalBindings
+              _x1IannotatedTree :: ScalarExpr 
+              _x1IfixedUpIdentifiersTree :: ScalarExpr 
+              _x1IoriginalTree :: ScalarExpr 
+              _x1IuType :: (Maybe Type)
+              _x2IannotatedTree :: StatementList 
+              _x2IfixedUpIdentifiersTree :: StatementList 
+              _x2IoriginalTree :: StatementList 
+              _x2IproducedCat :: Catalog
+              _x2IproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 125, column 9)
+              _x2OcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 126, column 9)
+              _x2OlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 126, column 13)
+              _x1OexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  (_x1IannotatedTree,_x2IannotatedTree)
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (_x1IfixedUpIdentifiersTree,_x2IfixedUpIdentifiersTree)
+              -- self rule
+              _originalTree =
+                  (_x1IoriginalTree,_x2IoriginalTree)
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _x1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x1Olib =
+                  _lhsIlib
+              -- copy rule (down)
+              _x2Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x2Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x2Olib =
+                  _lhsIlib
+              ( _x1IannotatedTree,_x1IfixedUpIdentifiersTree,_x1IoriginalTree,_x1IuType) =
+                  x1_ _x1Ocat _x1OexpectedType _x1Oidenv _x1Olib 
+              ( _x2IannotatedTree,_x2IfixedUpIdentifiersTree,_x2IoriginalTree,_x2IproducedCat,_x2IproducedLib) =
+                  x2_ _x2Ocat _x2OcatUpdates _x2Oidenv _x2Olib _x2OlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- ScalarExprStatementListPairList -----------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : ScalarExprStatementListPair 
+         child tl             : ScalarExprStatementListPairList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type ScalarExprStatementListPairList  = [ScalarExprStatementListPair ]
+-- cata
+sem_ScalarExprStatementListPairList :: ScalarExprStatementListPairList  ->
+                                       T_ScalarExprStatementListPairList 
+sem_ScalarExprStatementListPairList list  =
+    (Prelude.foldr sem_ScalarExprStatementListPairList_Cons sem_ScalarExprStatementListPairList_Nil (Prelude.map sem_ScalarExprStatementListPair list) )
+-- semantic domain
+type T_ScalarExprStatementListPairList  = Catalog ->
+                                          IDEnv ->
+                                          LocalBindings ->
+                                          ( ScalarExprStatementListPairList ,ScalarExprStatementListPairList ,ScalarExprStatementListPairList )
+data Inh_ScalarExprStatementListPairList  = Inh_ScalarExprStatementListPairList {cat_Inh_ScalarExprStatementListPairList :: Catalog,idenv_Inh_ScalarExprStatementListPairList :: IDEnv,lib_Inh_ScalarExprStatementListPairList :: LocalBindings}
+data Syn_ScalarExprStatementListPairList  = Syn_ScalarExprStatementListPairList {annotatedTree_Syn_ScalarExprStatementListPairList :: ScalarExprStatementListPairList ,fixedUpIdentifiersTree_Syn_ScalarExprStatementListPairList :: ScalarExprStatementListPairList ,originalTree_Syn_ScalarExprStatementListPairList :: ScalarExprStatementListPairList }
+wrap_ScalarExprStatementListPairList :: T_ScalarExprStatementListPairList  ->
+                                        Inh_ScalarExprStatementListPairList  ->
+                                        Syn_ScalarExprStatementListPairList 
+wrap_ScalarExprStatementListPairList sem (Inh_ScalarExprStatementListPairList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_ScalarExprStatementListPairList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_ScalarExprStatementListPairList_Cons :: T_ScalarExprStatementListPair  ->
+                                            T_ScalarExprStatementListPairList  ->
+                                            T_ScalarExprStatementListPairList 
+sem_ScalarExprStatementListPairList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprStatementListPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprStatementListPairList 
+              _lhsOoriginalTree :: ScalarExprStatementListPairList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: ScalarExprStatementListPair 
+              _hdIfixedUpIdentifiersTree :: ScalarExprStatementListPair 
+              _hdIoriginalTree :: ScalarExprStatementListPair 
+              _tlIannotatedTree :: ScalarExprStatementListPairList 
+              _tlIfixedUpIdentifiersTree :: ScalarExprStatementListPairList 
+              _tlIoriginalTree :: ScalarExprStatementListPairList 
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_ScalarExprStatementListPairList_Nil :: T_ScalarExprStatementListPairList 
+sem_ScalarExprStatementListPairList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: ScalarExprStatementListPairList 
+              _lhsOfixedUpIdentifiersTree :: ScalarExprStatementListPairList 
+              _lhsOoriginalTree :: ScalarExprStatementListPairList 
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- SelectItem --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         itemType             : (String,Maybe Type)
+         originalTree         : SELF 
+         seIdTree             : [SelectItem]
+   alternatives:
+      alternative SelExp:
+         child ann            : {Annotation}
+         child ex             : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative SelectItem:
+         child ann            : {Annotation}
+         child ex             : ScalarExpr 
+         child name           : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data SelectItem  = SelExp (Annotation) (ScalarExpr ) 
+                 | SelectItem (Annotation) (ScalarExpr ) (String) 
+                 deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_SelectItem :: SelectItem  ->
+                  T_SelectItem 
+sem_SelectItem (SelExp _ann _ex )  =
+    (sem_SelectItem_SelExp _ann (sem_ScalarExpr _ex ) )
+sem_SelectItem (SelectItem _ann _ex _name )  =
+    (sem_SelectItem_SelectItem _ann (sem_ScalarExpr _ex ) _name )
+-- semantic domain
+type T_SelectItem  = Catalog ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( SelectItem ,SelectItem ,((String,Maybe Type)),SelectItem ,([SelectItem]))
+data Inh_SelectItem  = Inh_SelectItem {cat_Inh_SelectItem :: Catalog,idenv_Inh_SelectItem :: IDEnv,lib_Inh_SelectItem :: LocalBindings}
+data Syn_SelectItem  = Syn_SelectItem {annotatedTree_Syn_SelectItem :: SelectItem ,fixedUpIdentifiersTree_Syn_SelectItem :: SelectItem ,itemType_Syn_SelectItem :: ((String,Maybe Type)),originalTree_Syn_SelectItem :: SelectItem ,seIdTree_Syn_SelectItem :: ([SelectItem])}
+wrap_SelectItem :: T_SelectItem  ->
+                   Inh_SelectItem  ->
+                   Syn_SelectItem 
+wrap_SelectItem sem (Inh_SelectItem _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOitemType,_lhsOoriginalTree,_lhsOseIdTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_SelectItem _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOitemType _lhsOoriginalTree _lhsOseIdTree ))
+sem_SelectItem_SelExp :: Annotation ->
+                         T_ScalarExpr  ->
+                         T_SelectItem 
+sem_SelectItem_SelExp ann_ ex_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOseIdTree :: ([SelectItem])
+              _lhsOitemType :: ((String,Maybe Type))
+              _exOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: SelectItem 
+              _lhsOfixedUpIdentifiersTree :: SelectItem 
+              _lhsOoriginalTree :: SelectItem 
+              _exOcat :: Catalog
+              _exOidenv :: IDEnv
+              _exOlib :: LocalBindings
+              _exIannotatedTree :: ScalarExpr 
+              _exIfixedUpIdentifiersTree :: ScalarExpr 
+              _exIoriginalTree :: ScalarExpr 
+              _exIuType :: (Maybe Type)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 150, column 14)
+              _lhsOseIdTree =
+                  case _exIfixedUpIdentifiersTree of
+                    Identifier a "*" -> let s = expandStar _lhsIidenv Nothing
+                                            in if null s
+                                               then [addSIAlias $ SelExp ann_ _exIfixedUpIdentifiersTree]
+                                               else makeSelExps ann_ a a s
+                    QIdentifier a0 (Identifier a1 q) "*" ->
+                       let s = expandStar _lhsIidenv $ Just q
+                       in if null s
+                          then [addSIAlias $ SelExp ann_ _exIfixedUpIdentifiersTree]
+                          else makeSelExps ann_ a0 a1 s
+                    _ -> [addSIAlias $ SelExp ann_ _exIfixedUpIdentifiersTree]
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 32, column 9)
+              _annotatedTree =
+                  SelExp ann_ _exIannotatedTree
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 60, column 9)
+              _lhsOitemType =
+                  ("", Nothing)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 106, column 25)
+              _exOexpectedType =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SelExp ann_ _exIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  SelExp ann_ _exIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exOlib =
+                  _lhsIlib
+              ( _exIannotatedTree,_exIfixedUpIdentifiersTree,_exIoriginalTree,_exIuType) =
+                  ex_ _exOcat _exOexpectedType _exOidenv _exOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOitemType,_lhsOoriginalTree,_lhsOseIdTree)))
+sem_SelectItem_SelectItem :: Annotation ->
+                             T_ScalarExpr  ->
+                             String ->
+                             T_SelectItem 
+sem_SelectItem_SelectItem ann_ ex_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOseIdTree :: ([SelectItem])
+              _lhsOitemType :: ((String,Maybe Type))
+              _exOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: SelectItem 
+              _lhsOfixedUpIdentifiersTree :: SelectItem 
+              _lhsOoriginalTree :: SelectItem 
+              _exOcat :: Catalog
+              _exOidenv :: IDEnv
+              _exOlib :: LocalBindings
+              _exIannotatedTree :: ScalarExpr 
+              _exIfixedUpIdentifiersTree :: ScalarExpr 
+              _exIoriginalTree :: ScalarExpr 
+              _exIuType :: (Maybe Type)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 163, column 18)
+              _lhsOseIdTree =
+                  [SelectItem ann_ _exIfixedUpIdentifiersTree name_]
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 34, column 9)
+              _annotatedTree =
+                  SelectItem ann_ _exIannotatedTree name_
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 62, column 9)
+              _lhsOitemType =
+                  (name_, unwrapSetof `fmap` _exIuType)
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 106, column 25)
+              _exOexpectedType =
+                  Nothing
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SelectItem ann_ _exIfixedUpIdentifiersTree name_
+              -- self rule
+              _originalTree =
+                  SelectItem ann_ _exIoriginalTree name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exOlib =
+                  _lhsIlib
+              ( _exIannotatedTree,_exIfixedUpIdentifiersTree,_exIoriginalTree,_exIuType) =
+                  ex_ _exOcat _exOexpectedType _exOidenv _exOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOitemType,_lhsOoriginalTree,_lhsOseIdTree)))
+-- SelectItemList ----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         listType             : [(String,Maybe Type)]
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : SelectItem 
+         child tl             : SelectItemList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type SelectItemList  = [SelectItem ]
+-- cata
+sem_SelectItemList :: SelectItemList  ->
+                      T_SelectItemList 
+sem_SelectItemList list  =
+    (Prelude.foldr sem_SelectItemList_Cons sem_SelectItemList_Nil (Prelude.map sem_SelectItem list) )
+-- semantic domain
+type T_SelectItemList  = Catalog ->
+                         IDEnv ->
+                         LocalBindings ->
+                         ( SelectItemList ,SelectItemList ,([(String,Maybe Type)]),SelectItemList )
+data Inh_SelectItemList  = Inh_SelectItemList {cat_Inh_SelectItemList :: Catalog,idenv_Inh_SelectItemList :: IDEnv,lib_Inh_SelectItemList :: LocalBindings}
+data Syn_SelectItemList  = Syn_SelectItemList {annotatedTree_Syn_SelectItemList :: SelectItemList ,fixedUpIdentifiersTree_Syn_SelectItemList :: SelectItemList ,listType_Syn_SelectItemList :: ([(String,Maybe Type)]),originalTree_Syn_SelectItemList :: SelectItemList }
+wrap_SelectItemList :: T_SelectItemList  ->
+                       Inh_SelectItemList  ->
+                       Syn_SelectItemList 
+wrap_SelectItemList sem (Inh_SelectItemList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_SelectItemList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOlistType _lhsOoriginalTree ))
+sem_SelectItemList_Cons :: T_SelectItem  ->
+                           T_SelectItemList  ->
+                           T_SelectItemList 
+sem_SelectItemList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: SelectItemList 
+              _lhsOlistType :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: SelectItemList 
+              _lhsOoriginalTree :: SelectItemList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: SelectItem 
+              _hdIfixedUpIdentifiersTree :: SelectItem 
+              _hdIitemType :: ((String,Maybe Type))
+              _hdIoriginalTree :: SelectItem 
+              _hdIseIdTree :: ([SelectItem])
+              _tlIannotatedTree :: SelectItemList 
+              _tlIfixedUpIdentifiersTree :: SelectItemList 
+              _tlIlistType :: ([(String,Maybe Type)])
+              _tlIoriginalTree :: SelectItemList 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 141, column 12)
+              _lhsOfixedUpIdentifiersTree =
+                  _hdIseIdTree ++ _tlIfixedUpIdentifiersTree
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 12)
+              _lhsOlistType =
+                  _hdIitemType : _tlIlistType
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIitemType,_hdIoriginalTree,_hdIseIdTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIlistType,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+sem_SelectItemList_Nil :: T_SelectItemList 
+sem_SelectItemList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: SelectItemList 
+              _lhsOlistType :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: SelectItemList 
+              _lhsOoriginalTree :: SelectItemList 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 142, column 11)
+              _lhsOfixedUpIdentifiersTree =
+                  []
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 43, column 11)
+              _lhsOlistType =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlistType,_lhsOoriginalTree)))
+-- SelectList --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         cidenv               : IDEnv
+         fixedUpIdentifiersTree : SELF 
+         libUpdates           : [LocalBindingsUpdate]
+         listType             : [(String,Maybe Type)]
+         originalTree         : SELF 
+   alternatives:
+      alternative SelectList:
+         child ann            : {Annotation}
+         child items          : SelectItemList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data SelectList  = SelectList (Annotation) (SelectItemList ) 
+                 deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_SelectList :: SelectList  ->
+                  T_SelectList 
+sem_SelectList (SelectList _ann _items )  =
+    (sem_SelectList_SelectList _ann (sem_SelectItemList _items ) )
+-- semantic domain
+type T_SelectList  = Catalog ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( SelectList ,IDEnv,SelectList ,([LocalBindingsUpdate]),([(String,Maybe Type)]),SelectList )
+data Inh_SelectList  = Inh_SelectList {cat_Inh_SelectList :: Catalog,idenv_Inh_SelectList :: IDEnv,lib_Inh_SelectList :: LocalBindings}
+data Syn_SelectList  = Syn_SelectList {annotatedTree_Syn_SelectList :: SelectList ,cidenv_Syn_SelectList :: IDEnv,fixedUpIdentifiersTree_Syn_SelectList :: SelectList ,libUpdates_Syn_SelectList :: ([LocalBindingsUpdate]),listType_Syn_SelectList :: ([(String,Maybe Type)]),originalTree_Syn_SelectList :: SelectList }
+wrap_SelectList :: T_SelectList  ->
+                   Inh_SelectList  ->
+                   Syn_SelectList 
+wrap_SelectList sem (Inh_SelectList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOlistType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_SelectList _lhsOannotatedTree _lhsOcidenv _lhsOfixedUpIdentifiersTree _lhsOlibUpdates _lhsOlistType _lhsOoriginalTree ))
+sem_SelectList_SelectList :: Annotation ->
+                             T_SelectItemList  ->
+                             T_SelectList 
+sem_SelectList_SelectList ann_ items_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOcidenv :: IDEnv
+              _lhsOlistType :: ([(String,Maybe Type)])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: SelectList 
+              _lhsOfixedUpIdentifiersTree :: SelectList 
+              _lhsOoriginalTree :: SelectList 
+              _itemsOcat :: Catalog
+              _itemsOidenv :: IDEnv
+              _itemsOlib :: LocalBindings
+              _itemsIannotatedTree :: SelectItemList 
+              _itemsIfixedUpIdentifiersTree :: SelectItemList 
+              _itemsIlistType :: ([(String,Maybe Type)])
+              _itemsIoriginalTree :: SelectItemList 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 124, column 18)
+              _lhsOcidenv =
+                  makeIDEnv "" $ flip map _itemsIfixedUpIdentifiersTree
+                                   $ \(SelectItem _ _ n) -> n
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 77, column 9)
+              _lhsOlistType =
+                  _itemsIlistType
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 97, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/SelectLists.ag"(line 131, column 9)
+              _lhsOannotatedTree =
+                  SelectList ann_
+                             _itemsIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  SelectList ann_ _itemsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SelectList ann_ _itemsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  SelectList ann_ _itemsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _itemsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _itemsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _itemsOlib =
+                  _lhsIlib
+              ( _itemsIannotatedTree,_itemsIfixedUpIdentifiersTree,_itemsIlistType,_itemsIoriginalTree) =
+                  items_ _itemsOcat _itemsOidenv _itemsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcidenv,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOlistType,_lhsOoriginalTree)))
+-- Statement ---------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         inProducedCat        : Catalog
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         catUpdates           : [CatalogUpdate]
+         fixedUpIdentifiersTree : SELF 
+         libUpdates           : [LocalBindingsUpdate]
+         originalTree         : SELF 
+   alternatives:
+      alternative AlterSequence:
+         child ann            : {Annotation}
+         child name           : {String}
+         child ownedBy        : SQIdentifier 
+         visit 0:
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative AlterTable:
+         child ann            : {Annotation}
+         child name           : {String}
+         child actions        : AlterTableActionList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Assignment:
+         child ann            : {Annotation}
+         child target         : ScalarExpr 
+         child value          : ScalarExpr 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Block:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         child vars           : VarDefList 
+         child sts            : StatementList 
+         visit 0:
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CaseStatement:
+         child ann            : {Annotation}
+         child cases          : ScalarExprListStatementListPairList 
+         child els            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CaseStatementSimple:
+         child ann            : {Annotation}
+         child val            : ScalarExpr 
+         child cases          : ScalarExprListStatementListPairList 
+         child els            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ContinueStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Copy:
+         child ann            : {Annotation}
+         child table          : {String}
+         child targetCols     : {[String]}
+         child source         : {CopySource}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CopyData:
+         child ann            : {Annotation}
+         child insData        : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateDomain:
+         child ann            : {Annotation}
+         child name           : {String}
+         child typ            : TypeName 
+         child checkName      : {String}
+         child check          : MaybeBoolExpr 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local statementType : {Maybe StatementType}
+            local catUpdates  : {[CatalogUpdate]}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateFunction:
+         child ann            : {Annotation}
+         child name           : {String}
+         child params         : ParamDefList 
+         child rettype        : TypeName 
+         child rep            : {Replace}
+         child lang           : {Language}
+         child body           : FnBody 
+         child vol            : {Volatility}
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local catUpdates  : {[CatalogUpdate]}
+            local backTree    : _
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateLanguage:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local statementType : {Maybe StatementType}
+            local catUpdates  : {[CatalogUpdate]}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateSequence:
+         child ann            : {Annotation}
+         child name           : {String}
+         child incr           : {Integer}
+         child min            : {Integer}
+         child max            : {Integer}
+         child start          : {Integer}
+         child cache          : {Integer}
+         visit 0:
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateTable:
+         child ann            : {Annotation}
+         child name           : {String}
+         child atts           : AttributeDefList 
+         child cons           : ConstraintList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local catUpdates  : {[CatalogUpdate]}
+            local attrs       : {[(String,Type)]}
+            local statementType : {Maybe StatementType}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateTableAs:
+         child ann            : {Annotation}
+         child name           : {String}
+         child expr           : QueryExpr 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local catUpdates  : {[CatalogUpdate]}
+            local attrs       : {Either [TypeError] [(String,Type)]}
+            local backTree    : _
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateTrigger:
+         child ann            : {Annotation}
+         child name           : {String}
+         child wh             : {TriggerWhen}
+         child events         : {[TriggerEvent]}
+         child tbl            : {String}
+         child firing         : {TriggerFire}
+         child fnName         : {String}
+         child fnArgs         : ScalarExprList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateType:
+         child ann            : {Annotation}
+         child name           : {String}
+         child atts           : TypeAttributeDefList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local attrs       : _
+            local backTree    : _
+            local statementType : {Maybe StatementType}
+            local catUpdates  : {[CatalogUpdate]}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative CreateView:
+         child ann            : {Annotation}
+         child name           : {String}
+         child colNames       : {Maybe [String]}
+         child expr           : QueryExpr 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Delete:
+         child ann            : {Annotation}
+         child table          : SQIdentifier 
+         child using          : TableRefList 
+         child whr            : MaybeBoolExpr 
+         child returning      : MaybeSelectList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local statementType : {Maybe StatementType}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local lib         : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative DropFunction:
+         child ann            : {Annotation}
+         child ifE            : {IfExists}
+         child sigs           : StringTypeNameListPairList 
+         child cascade        : {Cascade}
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative DropSomething:
+         child ann            : {Annotation}
+         child dropType       : {DropType}
+         child ifE            : {IfExists}
+         child names          : {[String]}
+         child cascade        : {Cascade}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Execute:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ExitStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ForIntegerStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         child var            : ScalarExpr 
+         child from           : ScalarExpr 
+         child to             : ScalarExpr 
+         child sts            : StatementList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local implicitVar : _
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ForQueryStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         child var            : ScalarExpr 
+         child sel            : QueryExpr 
+         child sts            : StatementList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative If:
+         child ann            : {Annotation}
+         child cases          : ScalarExprStatementListPairList 
+         child els            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Insert:
+         child ann            : {Annotation}
+         child table          : SQIdentifier 
+         child targetCols     : {[String]}
+         child insData        : QueryExpr 
+         child returning      : MaybeSelectList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local statementType : {Maybe StatementType}
+            local columnTypes : {Either [TypeError] [(String,Type)]}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Into:
+         child ann            : {Annotation}
+         child strict         : {Bool}
+         child into           : ScalarExprList 
+         child stmt           : Statement 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative LoopStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         child sts            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Notify:
+         child ann            : {Annotation}
+         child name           : {String}
+         visit 0:
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative NullStatement:
+         child ann            : {Annotation}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Perform:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative QueryStatement:
+         child ann            : {Annotation}
+         child ex             : QueryExpr 
+         visit 0:
+            local tpe         : {Either [TypeError] Type}
+            local statementType : {Maybe StatementType}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Raise:
+         child ann            : {Annotation}
+         child level          : {RaiseType}
+         child message        : {String}
+         child args           : ScalarExprList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Return:
+         child ann            : {Annotation}
+         child value          : MaybeScalarExpr 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local statementType : {Maybe StatementType}
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ReturnNext:
+         child ann            : {Annotation}
+         child expr           : ScalarExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative ReturnQuery:
+         child ann            : {Annotation}
+         child sel            : QueryExpr 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Set:
+         child ann            : {Annotation}
+         child name           : {String}
+         child values         : {[SetValue]}
+         visit 0:
+            local libUpdates  : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Truncate:
+         child ann            : {Annotation}
+         child tables         : {[String]}
+         child restartIdentity : {RestartIdentity}
+         child cascade        : {Cascade}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Update:
+         child ann            : {Annotation}
+         child table          : SQIdentifier 
+         child assigns        : ScalarExprList 
+         child fromList       : TableRefList 
+         child whr            : MaybeBoolExpr 
+         child returning      : MaybeSelectList 
+         visit 0:
+            local libUpdates  : _
+            local tpe         : {Either [TypeError] Type}
+            local statementType : {Maybe StatementType}
+            local backTree    : _
+            local catUpdates  : {[CatalogUpdate]}
+            local lib         : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative WhileStatement:
+         child ann            : {Annotation}
+         child lb             : {Maybe String}
+         child expr           : ScalarExpr 
+         child sts            : StatementList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data Statement  = AlterSequence (Annotation) (String) (SQIdentifier ) 
+                | AlterTable (Annotation) (String) (AlterTableActionList ) 
+                | Assignment (Annotation) (ScalarExpr ) (ScalarExpr ) 
+                | Block (Annotation) ((Maybe String)) (VarDefList ) (StatementList ) 
+                | CaseStatement (Annotation) (ScalarExprListStatementListPairList ) (StatementList ) 
+                | CaseStatementSimple (Annotation) (ScalarExpr ) (ScalarExprListStatementListPairList ) (StatementList ) 
+                | ContinueStatement (Annotation) ((Maybe String)) 
+                | Copy (Annotation) (String) (([String])) (CopySource) 
+                | CopyData (Annotation) (String) 
+                | CreateDomain (Annotation) (String) (TypeName ) (String) (MaybeBoolExpr ) 
+                | CreateFunction (Annotation) (String) (ParamDefList ) (TypeName ) (Replace) (Language) (FnBody ) (Volatility) 
+                | CreateLanguage (Annotation) (String) 
+                | CreateSequence (Annotation) (String) (Integer) (Integer) (Integer) (Integer) (Integer) 
+                | CreateTable (Annotation) (String) (AttributeDefList ) (ConstraintList ) 
+                | CreateTableAs (Annotation) (String) (QueryExpr ) 
+                | CreateTrigger (Annotation) (String) (TriggerWhen) (([TriggerEvent])) (String) (TriggerFire) (String) (ScalarExprList ) 
+                | CreateType (Annotation) (String) (TypeAttributeDefList ) 
+                | CreateView (Annotation) (String) ((Maybe [String])) (QueryExpr ) 
+                | Delete (Annotation) (SQIdentifier ) (TableRefList ) (MaybeBoolExpr ) (MaybeSelectList ) 
+                | DropFunction (Annotation) (IfExists) (StringTypeNameListPairList ) (Cascade) 
+                | DropSomething (Annotation) (DropType) (IfExists) (([String])) (Cascade) 
+                | Execute (Annotation) (ScalarExpr ) 
+                | ExitStatement (Annotation) ((Maybe String)) 
+                | ForIntegerStatement (Annotation) ((Maybe String)) (ScalarExpr ) (ScalarExpr ) (ScalarExpr ) (StatementList ) 
+                | ForQueryStatement (Annotation) ((Maybe String)) (ScalarExpr ) (QueryExpr ) (StatementList ) 
+                | If (Annotation) (ScalarExprStatementListPairList ) (StatementList ) 
+                | Insert (Annotation) (SQIdentifier ) (([String])) (QueryExpr ) (MaybeSelectList ) 
+                | Into (Annotation) (Bool) (ScalarExprList ) (Statement ) 
+                | LoopStatement (Annotation) ((Maybe String)) (StatementList ) 
+                | Notify (Annotation) (String) 
+                | NullStatement (Annotation) 
+                | Perform (Annotation) (ScalarExpr ) 
+                | QueryStatement (Annotation) (QueryExpr ) 
+                | Raise (Annotation) (RaiseType) (String) (ScalarExprList ) 
+                | Return (Annotation) (MaybeScalarExpr ) 
+                | ReturnNext (Annotation) (ScalarExpr ) 
+                | ReturnQuery (Annotation) (QueryExpr ) 
+                | Set (Annotation) (String) (([SetValue])) 
+                | Truncate (Annotation) (([String])) (RestartIdentity) (Cascade) 
+                | Update (Annotation) (SQIdentifier ) (ScalarExprList ) (TableRefList ) (MaybeBoolExpr ) (MaybeSelectList ) 
+                | WhileStatement (Annotation) ((Maybe String)) (ScalarExpr ) (StatementList ) 
+                deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_Statement :: Statement  ->
+                 T_Statement 
+sem_Statement (AlterSequence _ann _name _ownedBy )  =
+    (sem_Statement_AlterSequence _ann _name (sem_SQIdentifier _ownedBy ) )
+sem_Statement (AlterTable _ann _name _actions )  =
+    (sem_Statement_AlterTable _ann _name (sem_AlterTableActionList _actions ) )
+sem_Statement (Assignment _ann _target _value )  =
+    (sem_Statement_Assignment _ann (sem_ScalarExpr _target ) (sem_ScalarExpr _value ) )
+sem_Statement (Block _ann _lb _vars _sts )  =
+    (sem_Statement_Block _ann _lb (sem_VarDefList _vars ) (sem_StatementList _sts ) )
+sem_Statement (CaseStatement _ann _cases _els )  =
+    (sem_Statement_CaseStatement _ann (sem_ScalarExprListStatementListPairList _cases ) (sem_StatementList _els ) )
+sem_Statement (CaseStatementSimple _ann _val _cases _els )  =
+    (sem_Statement_CaseStatementSimple _ann (sem_ScalarExpr _val ) (sem_ScalarExprListStatementListPairList _cases ) (sem_StatementList _els ) )
+sem_Statement (ContinueStatement _ann _lb )  =
+    (sem_Statement_ContinueStatement _ann _lb )
+sem_Statement (Copy _ann _table _targetCols _source )  =
+    (sem_Statement_Copy _ann _table _targetCols _source )
+sem_Statement (CopyData _ann _insData )  =
+    (sem_Statement_CopyData _ann _insData )
+sem_Statement (CreateDomain _ann _name _typ _checkName _check )  =
+    (sem_Statement_CreateDomain _ann _name (sem_TypeName _typ ) _checkName (sem_MaybeBoolExpr _check ) )
+sem_Statement (CreateFunction _ann _name _params _rettype _rep _lang _body _vol )  =
+    (sem_Statement_CreateFunction _ann _name (sem_ParamDefList _params ) (sem_TypeName _rettype ) _rep _lang (sem_FnBody _body ) _vol )
+sem_Statement (CreateLanguage _ann _name )  =
+    (sem_Statement_CreateLanguage _ann _name )
+sem_Statement (CreateSequence _ann _name _incr _min _max _start _cache )  =
+    (sem_Statement_CreateSequence _ann _name _incr _min _max _start _cache )
+sem_Statement (CreateTable _ann _name _atts _cons )  =
+    (sem_Statement_CreateTable _ann _name (sem_AttributeDefList _atts ) (sem_ConstraintList _cons ) )
+sem_Statement (CreateTableAs _ann _name _expr )  =
+    (sem_Statement_CreateTableAs _ann _name (sem_QueryExpr _expr ) )
+sem_Statement (CreateTrigger _ann _name _wh _events _tbl _firing _fnName _fnArgs )  =
+    (sem_Statement_CreateTrigger _ann _name _wh _events _tbl _firing _fnName (sem_ScalarExprList _fnArgs ) )
+sem_Statement (CreateType _ann _name _atts )  =
+    (sem_Statement_CreateType _ann _name (sem_TypeAttributeDefList _atts ) )
+sem_Statement (CreateView _ann _name _colNames _expr )  =
+    (sem_Statement_CreateView _ann _name _colNames (sem_QueryExpr _expr ) )
+sem_Statement (Delete _ann _table _using _whr _returning )  =
+    (sem_Statement_Delete _ann (sem_SQIdentifier _table ) (sem_TableRefList _using ) (sem_MaybeBoolExpr _whr ) (sem_MaybeSelectList _returning ) )
+sem_Statement (DropFunction _ann _ifE _sigs _cascade )  =
+    (sem_Statement_DropFunction _ann _ifE (sem_StringTypeNameListPairList _sigs ) _cascade )
+sem_Statement (DropSomething _ann _dropType _ifE _names _cascade )  =
+    (sem_Statement_DropSomething _ann _dropType _ifE _names _cascade )
+sem_Statement (Execute _ann _expr )  =
+    (sem_Statement_Execute _ann (sem_ScalarExpr _expr ) )
+sem_Statement (ExitStatement _ann _lb )  =
+    (sem_Statement_ExitStatement _ann _lb )
+sem_Statement (ForIntegerStatement _ann _lb _var _from _to _sts )  =
+    (sem_Statement_ForIntegerStatement _ann _lb (sem_ScalarExpr _var ) (sem_ScalarExpr _from ) (sem_ScalarExpr _to ) (sem_StatementList _sts ) )
+sem_Statement (ForQueryStatement _ann _lb _var _sel _sts )  =
+    (sem_Statement_ForQueryStatement _ann _lb (sem_ScalarExpr _var ) (sem_QueryExpr _sel ) (sem_StatementList _sts ) )
+sem_Statement (If _ann _cases _els )  =
+    (sem_Statement_If _ann (sem_ScalarExprStatementListPairList _cases ) (sem_StatementList _els ) )
+sem_Statement (Insert _ann _table _targetCols _insData _returning )  =
+    (sem_Statement_Insert _ann (sem_SQIdentifier _table ) _targetCols (sem_QueryExpr _insData ) (sem_MaybeSelectList _returning ) )
+sem_Statement (Into _ann _strict _into _stmt )  =
+    (sem_Statement_Into _ann _strict (sem_ScalarExprList _into ) (sem_Statement _stmt ) )
+sem_Statement (LoopStatement _ann _lb _sts )  =
+    (sem_Statement_LoopStatement _ann _lb (sem_StatementList _sts ) )
+sem_Statement (Notify _ann _name )  =
+    (sem_Statement_Notify _ann _name )
+sem_Statement (NullStatement _ann )  =
+    (sem_Statement_NullStatement _ann )
+sem_Statement (Perform _ann _expr )  =
+    (sem_Statement_Perform _ann (sem_ScalarExpr _expr ) )
+sem_Statement (QueryStatement _ann _ex )  =
+    (sem_Statement_QueryStatement _ann (sem_QueryExpr _ex ) )
+sem_Statement (Raise _ann _level _message _args )  =
+    (sem_Statement_Raise _ann _level _message (sem_ScalarExprList _args ) )
+sem_Statement (Return _ann _value )  =
+    (sem_Statement_Return _ann (sem_MaybeScalarExpr _value ) )
+sem_Statement (ReturnNext _ann _expr )  =
+    (sem_Statement_ReturnNext _ann (sem_ScalarExpr _expr ) )
+sem_Statement (ReturnQuery _ann _sel )  =
+    (sem_Statement_ReturnQuery _ann (sem_QueryExpr _sel ) )
+sem_Statement (Set _ann _name _values )  =
+    (sem_Statement_Set _ann _name _values )
+sem_Statement (Truncate _ann _tables _restartIdentity _cascade )  =
+    (sem_Statement_Truncate _ann _tables _restartIdentity _cascade )
+sem_Statement (Update _ann _table _assigns _fromList _whr _returning )  =
+    (sem_Statement_Update _ann (sem_SQIdentifier _table ) (sem_ScalarExprList _assigns ) (sem_TableRefList _fromList ) (sem_MaybeBoolExpr _whr ) (sem_MaybeSelectList _returning ) )
+sem_Statement (WhileStatement _ann _lb _expr _sts )  =
+    (sem_Statement_WhileStatement _ann _lb (sem_ScalarExpr _expr ) (sem_StatementList _sts ) )
+-- semantic domain
+type T_Statement  = Catalog ->
+                    IDEnv ->
+                    Catalog ->
+                    LocalBindings ->
+                    ( Statement ,([CatalogUpdate]),Statement ,([LocalBindingsUpdate]),Statement )
+data Inh_Statement  = Inh_Statement {cat_Inh_Statement :: Catalog,idenv_Inh_Statement :: IDEnv,inProducedCat_Inh_Statement :: Catalog,lib_Inh_Statement :: LocalBindings}
+data Syn_Statement  = Syn_Statement {annotatedTree_Syn_Statement :: Statement ,catUpdates_Syn_Statement :: ([CatalogUpdate]),fixedUpIdentifiersTree_Syn_Statement :: Statement ,libUpdates_Syn_Statement :: ([LocalBindingsUpdate]),originalTree_Syn_Statement :: Statement }
+wrap_Statement :: T_Statement  ->
+                  Inh_Statement  ->
+                  Syn_Statement 
+wrap_Statement sem (Inh_Statement _lhsIcat _lhsIidenv _lhsIinProducedCat _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIinProducedCat _lhsIlib 
+     in  (Syn_Statement _lhsOannotatedTree _lhsOcatUpdates _lhsOfixedUpIdentifiersTree _lhsOlibUpdates _lhsOoriginalTree ))
+sem_Statement_AlterSequence :: Annotation ->
+                               String ->
+                               T_SQIdentifier  ->
+                               T_Statement 
+sem_Statement_AlterSequence ann_ name_ ownedBy_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _ownedByOcat :: Catalog
+              _ownedByOidenv :: IDEnv
+              _ownedByOlib :: LocalBindings
+              _ownedByIannotatedTree :: SQIdentifier 
+              _ownedByIfixedUpIdentifiersTree :: SQIdentifier 
+              _ownedByIoriginalTree :: SQIdentifier 
+              _ownedByItbAnnotatedTree :: SQIdentifier 
+              _ownedByItbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  AlterSequence ann_ name_ _ownedByIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  AlterSequence ann_ name_ _ownedByIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  AlterSequence ann_ name_ _ownedByIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _ownedByOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _ownedByOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _ownedByOlib =
+                  _lhsIlib
+              ( _ownedByIannotatedTree,_ownedByIfixedUpIdentifiersTree,_ownedByIoriginalTree,_ownedByItbAnnotatedTree,_ownedByItbUType) =
+                  ownedBy_ _ownedByOcat _ownedByOidenv _ownedByOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_AlterTable :: Annotation ->
+                            String ->
+                            T_AlterTableActionList  ->
+                            T_Statement 
+sem_Statement_AlterTable ann_ name_ actions_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _actionsOcat :: Catalog
+              _actionsOidenv :: IDEnv
+              _actionsOlib :: LocalBindings
+              _actionsIannotatedTree :: AlterTableActionList 
+              _actionsIfixedUpIdentifiersTree :: AlterTableActionList 
+              _actionsIoriginalTree :: AlterTableActionList 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  AlterTable ann_ name_ _actionsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  AlterTable ann_ name_ _actionsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  AlterTable ann_ name_ _actionsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _actionsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _actionsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _actionsOlib =
+                  _lhsIlib
+              ( _actionsIannotatedTree,_actionsIfixedUpIdentifiersTree,_actionsIoriginalTree) =
+                  actions_ _actionsOcat _actionsOidenv _actionsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Assignment :: Annotation ->
+                            T_ScalarExpr  ->
+                            T_ScalarExpr  ->
+                            T_Statement 
+sem_Statement_Assignment ann_ target_ value_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _valueOexpectedType :: (Maybe Type)
+              _targetOexpectedType :: (Maybe Type)
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _targetOcat :: Catalog
+              _targetOidenv :: IDEnv
+              _targetOlib :: LocalBindings
+              _valueOcat :: Catalog
+              _valueOidenv :: IDEnv
+              _valueOlib :: LocalBindings
+              _targetIannotatedTree :: ScalarExpr 
+              _targetIfixedUpIdentifiersTree :: ScalarExpr 
+              _targetIoriginalTree :: ScalarExpr 
+              _targetIuType :: (Maybe Type)
+              _valueIannotatedTree :: ScalarExpr 
+              _valueIfixedUpIdentifiersTree :: ScalarExpr 
+              _valueIoriginalTree :: ScalarExpr 
+              _valueIuType :: (Maybe Type)
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 20, column 9)
+              _tpe =
+                  do
+                  fromType <- lmt _valueIuType
+                  toType <- lmt _targetIuType
+                  checkAssignmentValid _lhsIcat fromType toType
+                  return $ Pseudo Void
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 26, column 9)
+              _backTree =
+                  Assignment ann_ _targetIannotatedTree _valueIannotatedTree
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 27, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 28, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 109, column 18)
+              _valueOexpectedType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 115, column 18)
+              _targetOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Assignment ann_ _targetIannotatedTree _valueIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Assignment ann_ _targetIfixedUpIdentifiersTree _valueIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Assignment ann_ _targetIoriginalTree _valueIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _targetOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _targetOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _targetOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _valueOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _valueOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _valueOlib =
+                  _lhsIlib
+              ( _targetIannotatedTree,_targetIfixedUpIdentifiersTree,_targetIoriginalTree,_targetIuType) =
+                  target_ _targetOcat _targetOexpectedType _targetOidenv _targetOlib 
+              ( _valueIannotatedTree,_valueIfixedUpIdentifiersTree,_valueIoriginalTree,_valueIuType) =
+                  value_ _valueOcat _valueOexpectedType _valueOidenv _valueOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Block :: Annotation ->
+                       (Maybe String) ->
+                       T_VarDefList  ->
+                       T_StatementList  ->
+                       T_Statement 
+sem_Statement_Block ann_ lb_ vars_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlib :: LocalBindings
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _varsOcat :: Catalog
+              _varsOidenv :: IDEnv
+              _varsOlib :: LocalBindings
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _varsIannotatedTree :: VarDefList 
+              _varsIdefs :: ([(String,Maybe Type)])
+              _varsIfixedUpIdentifiersTree :: VarDefList 
+              _varsIoriginalTree :: VarDefList 
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 100, column 13)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 101, column 13)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 22, column 9)
+              _stsOlib =
+                  fromRight _lhsIlib $
+                  lbUpdate _lhsIcat
+                           (LBIds "declarations" lb_ $ mapMaybe lv _varsIdefs)
+                           _lhsIlib
+                  where
+                    lv (_,Nothing) = Nothing
+                    lv (s,Just t) = Just (s,t)
+              -- self rule
+              _annotatedTree =
+                  Block ann_ lb_ _varsIannotatedTree _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Block ann_ lb_ _varsIfixedUpIdentifiersTree _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Block ann_ lb_ _varsIoriginalTree _stsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (from local)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- copy rule (down)
+              _varsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _varsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _varsOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              -- copy rule (from local)
+              _stsOlibUpdates =
+                  _libUpdates
+              ( _varsIannotatedTree,_varsIdefs,_varsIfixedUpIdentifiersTree,_varsIoriginalTree) =
+                  vars_ _varsOcat _varsOidenv _varsOlib 
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CaseStatement :: Annotation ->
+                               T_ScalarExprListStatementListPairList  ->
+                               T_StatementList  ->
+                               T_Statement 
+sem_Statement_CaseStatement ann_ cases_ els_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _elsOcatUpdates :: ([CatalogUpdate])
+              _elsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _casesOcat :: Catalog
+              _casesOidenv :: IDEnv
+              _casesOlib :: LocalBindings
+              _elsOcat :: Catalog
+              _elsOidenv :: IDEnv
+              _elsOlib :: LocalBindings
+              _casesIannotatedTree :: ScalarExprListStatementListPairList 
+              _casesIfixedUpIdentifiersTree :: ScalarExprListStatementListPairList 
+              _casesIoriginalTree :: ScalarExprListStatementListPairList 
+              _elsIannotatedTree :: StatementList 
+              _elsIfixedUpIdentifiersTree :: StatementList 
+              _elsIoriginalTree :: StatementList 
+              _elsIproducedCat :: Catalog
+              _elsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 134, column 9)
+              _elsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 135, column 9)
+              _elsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CaseStatement ann_ _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CaseStatement ann_ _casesIfixedUpIdentifiersTree _elsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CaseStatement ann_ _casesIoriginalTree _elsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _casesOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _casesOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _casesOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _elsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _elsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _elsOlib =
+                  _lhsIlib
+              ( _casesIannotatedTree,_casesIfixedUpIdentifiersTree,_casesIoriginalTree) =
+                  cases_ _casesOcat _casesOidenv _casesOlib 
+              ( _elsIannotatedTree,_elsIfixedUpIdentifiersTree,_elsIoriginalTree,_elsIproducedCat,_elsIproducedLib) =
+                  els_ _elsOcat _elsOcatUpdates _elsOidenv _elsOlib _elsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CaseStatementSimple :: Annotation ->
+                                     T_ScalarExpr  ->
+                                     T_ScalarExprListStatementListPairList  ->
+                                     T_StatementList  ->
+                                     T_Statement 
+sem_Statement_CaseStatementSimple ann_ val_ cases_ els_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _elsOcatUpdates :: ([CatalogUpdate])
+              _elsOlibUpdates :: ([LocalBindingsUpdate])
+              _valOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _valOcat :: Catalog
+              _valOidenv :: IDEnv
+              _valOlib :: LocalBindings
+              _casesOcat :: Catalog
+              _casesOidenv :: IDEnv
+              _casesOlib :: LocalBindings
+              _elsOcat :: Catalog
+              _elsOidenv :: IDEnv
+              _elsOlib :: LocalBindings
+              _valIannotatedTree :: ScalarExpr 
+              _valIfixedUpIdentifiersTree :: ScalarExpr 
+              _valIoriginalTree :: ScalarExpr 
+              _valIuType :: (Maybe Type)
+              _casesIannotatedTree :: ScalarExprListStatementListPairList 
+              _casesIfixedUpIdentifiersTree :: ScalarExprListStatementListPairList 
+              _casesIoriginalTree :: ScalarExprListStatementListPairList 
+              _elsIannotatedTree :: StatementList 
+              _elsIfixedUpIdentifiersTree :: StatementList 
+              _elsIoriginalTree :: StatementList 
+              _elsIproducedCat :: Catalog
+              _elsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 134, column 9)
+              _elsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 135, column 9)
+              _elsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 110, column 27)
+              _valOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  CaseStatementSimple ann_ _valIannotatedTree _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CaseStatementSimple ann_ _valIfixedUpIdentifiersTree _casesIfixedUpIdentifiersTree _elsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CaseStatementSimple ann_ _valIoriginalTree _casesIoriginalTree _elsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _valOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _valOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _valOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _casesOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _casesOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _casesOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _elsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _elsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _elsOlib =
+                  _lhsIlib
+              ( _valIannotatedTree,_valIfixedUpIdentifiersTree,_valIoriginalTree,_valIuType) =
+                  val_ _valOcat _valOexpectedType _valOidenv _valOlib 
+              ( _casesIannotatedTree,_casesIfixedUpIdentifiersTree,_casesIoriginalTree) =
+                  cases_ _casesOcat _casesOidenv _casesOlib 
+              ( _elsIannotatedTree,_elsIfixedUpIdentifiersTree,_elsIoriginalTree,_elsIproducedCat,_elsIproducedLib) =
+                  els_ _elsOcat _elsOcatUpdates _elsOidenv _elsOlib _elsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ContinueStatement :: Annotation ->
+                                   (Maybe String) ->
+                                   T_Statement 
+sem_Statement_ContinueStatement ann_ lb_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  ContinueStatement ann_ lb_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ContinueStatement ann_ lb_
+              -- self rule
+              _originalTree =
+                  ContinueStatement ann_ lb_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Copy :: Annotation ->
+                      String ->
+                      ([String]) ->
+                      CopySource ->
+                      T_Statement 
+sem_Statement_Copy ann_ table_ targetCols_ source_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Copy ann_ table_ targetCols_ source_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Copy ann_ table_ targetCols_ source_
+              -- self rule
+              _originalTree =
+                  Copy ann_ table_ targetCols_ source_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CopyData :: Annotation ->
+                          String ->
+                          T_Statement 
+sem_Statement_CopyData ann_ insData_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CopyData ann_ insData_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CopyData ann_ insData_
+              -- self rule
+              _originalTree =
+                  CopyData ann_ insData_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateDomain :: Annotation ->
+                              String ->
+                              T_TypeName  ->
+                              String ->
+                              T_MaybeBoolExpr  ->
+                              T_Statement 
+sem_Statement_CreateDomain ann_ name_ typ_ checkName_ check_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _checkOlib :: LocalBindings
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _checkOcat :: Catalog
+              _checkOidenv :: IDEnv
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              _checkIannotatedTree :: MaybeBoolExpr 
+              _checkIfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _checkIoriginalTree :: MaybeBoolExpr 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 65, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 66, column 9)
+              _backTree =
+                  CreateDomain ann_ name_ _typIannotatedTree checkName_ _checkIannotatedTree
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 67, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 68, column 9)
+              _catUpdates =
+                  maybe [] (\t -> [CatCreateDomain (DomainType name_) t]) _typInamedType
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 70, column 9)
+              _checkOlib =
+                  either (const _lhsIlib) id $ do
+                  nt <- lmt _typInamedType
+                  lbUpdate _lhsIcat
+                    (LBIds "domain check value" Nothing [("value", nt)])
+                    _lhsIlib
+              -- self rule
+              _annotatedTree =
+                  CreateDomain ann_ name_ _typIannotatedTree checkName_ _checkIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateDomain ann_ name_ _typIfixedUpIdentifiersTree checkName_ _checkIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateDomain ann_ name_ _typIoriginalTree checkName_ _checkIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _checkOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _checkOidenv =
+                  _lhsIidenv
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+              ( _checkIannotatedTree,_checkIfixedUpIdentifiersTree,_checkIoriginalTree) =
+                  check_ _checkOcat _checkOidenv _checkOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateFunction :: Annotation ->
+                                String ->
+                                T_ParamDefList  ->
+                                T_TypeName  ->
+                                Replace ->
+                                Language ->
+                                T_FnBody  ->
+                                Volatility ->
+                                T_Statement 
+sem_Statement_CreateFunction ann_ name_ params_ rettype_ rep_ lang_ body_ vol_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _bodyOlib :: LocalBindings
+              _paramsOpos :: Int
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _bodyOcat :: Catalog
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _paramsOcat :: Catalog
+              _paramsOidenv :: IDEnv
+              _paramsOlib :: LocalBindings
+              _rettypeOcat :: Catalog
+              _rettypeOidenv :: IDEnv
+              _rettypeOlib :: LocalBindings
+              _bodyOidenv :: IDEnv
+              _paramsIannotatedTree :: ParamDefList 
+              _paramsIfixedUpIdentifiersTree :: ParamDefList 
+              _paramsIoriginalTree :: ParamDefList 
+              _paramsIparams :: ([(ParamName, Maybe Type)])
+              _rettypeIannotatedTree :: TypeName 
+              _rettypeIfixedUpIdentifiersTree :: TypeName 
+              _rettypeInamedType :: (Maybe Type)
+              _rettypeIoriginalTree :: TypeName 
+              _bodyIannotatedTree :: FnBody 
+              _bodyIfixedUpIdentifiersTree :: FnBody 
+              _bodyIoriginalTree :: FnBody 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 63, column 9)
+              _bodyOlib =
+                  either (const _lhsIlib) id $ do
+                  _ <- lmt _rettypeInamedType
+                  lbUpdate _lhsIcat (LBIds (name_ ++ " parameters") (Just name_) paramsNoPos) _lhsIlib
+                  >>= lbUpdate _lhsIcat (LBIds (name_ ++ " parameters") Nothing paramsPosOnly)
+                  where
+                    paramsPosOnly :: [(String,Type)]
+                    paramsPosOnly = mapMaybe prm _paramsIparams
+                    prm :: (ParamName,Maybe Type) -> Maybe (String,Type)
+                    prm (NamedParam p _,Just t) = Just ("$" ++ show p, t)
+                    prm (UnnamedParam p,Just t) = Just ("$" ++ show p, t)
+                    prm _ = Nothing
+                    paramsNoPos :: [(String,Type)]
+                    paramsNoPos = mapMaybe pnp _paramsIparams
+                    pnp :: (ParamName,Maybe Type) -> Maybe (String,Type)
+                    pnp (NamedParam _ n,Just t) = Just (n,t)
+                    pnp _ = Nothing
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 79, column 9)
+              _paramsOpos =
+                  1
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 88, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 89, column 9)
+              _catUpdates =
+                  either (const []) id $ do
+                  let ps = mapMaybe lpt _paramsIparams
+                  rt <- lmt _rettypeInamedType
+                  return [CatCreateFunction FunName
+                                            (map toLower name_)
+                                            ps
+                                            rt
+                                            False]
+                  where
+                    lpt (_,Just t) = Just t
+                    lpt _ = Nothing
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 101, column 9)
+              _backTree =
+                  CreateFunction ann_
+                                 name_
+                                 _paramsIannotatedTree
+                                 _rettypeIannotatedTree
+                                 rep_
+                                 lang_
+                                 _bodyIannotatedTree
+                                 vol_
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 109, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/Ddl/CreateFunction.ag"(line 110, column 9)
+              _bodyOcat =
+                  _lhsIinProducedCat
+              -- self rule
+              _annotatedTree =
+                  CreateFunction ann_ name_ _paramsIannotatedTree _rettypeIannotatedTree rep_ lang_ _bodyIannotatedTree vol_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateFunction ann_ name_ _paramsIfixedUpIdentifiersTree _rettypeIfixedUpIdentifiersTree rep_ lang_ _bodyIfixedUpIdentifiersTree vol_
+              -- self rule
+              _originalTree =
+                  CreateFunction ann_ name_ _paramsIoriginalTree _rettypeIoriginalTree rep_ lang_ _bodyIoriginalTree vol_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _paramsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _paramsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _paramsOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _rettypeOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _rettypeOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _rettypeOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _bodyOidenv =
+                  _lhsIidenv
+              ( _paramsIannotatedTree,_paramsIfixedUpIdentifiersTree,_paramsIoriginalTree,_paramsIparams) =
+                  params_ _paramsOcat _paramsOidenv _paramsOlib _paramsOpos 
+              ( _rettypeIannotatedTree,_rettypeIfixedUpIdentifiersTree,_rettypeInamedType,_rettypeIoriginalTree) =
+                  rettype_ _rettypeOcat _rettypeOidenv _rettypeOlib 
+              ( _bodyIannotatedTree,_bodyIfixedUpIdentifiersTree,_bodyIoriginalTree) =
+                  body_ _bodyOcat _bodyOidenv _bodyOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateLanguage :: Annotation ->
+                                String ->
+                                T_Statement 
+sem_Statement_CreateLanguage ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 78, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 79, column 9)
+              _backTree =
+                  CreateLanguage ann_ name_
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 80, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 81, column 9)
+              _catUpdates =
+                  [CatCreateFunction FunName "plpgsql_call_handler" [] (Pseudo LanguageHandler) False
+                  ,CatCreateFunction FunName "plpgsql_validator" [ScalarType "oid"] (Pseudo Void) False]
+              -- self rule
+              _annotatedTree =
+                  CreateLanguage ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateLanguage ann_ name_
+              -- self rule
+              _originalTree =
+                  CreateLanguage ann_ name_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateSequence :: Annotation ->
+                                String ->
+                                Integer ->
+                                Integer ->
+                                Integer ->
+                                Integer ->
+                                Integer ->
+                                T_Statement 
+sem_Statement_CreateSequence ann_ name_ incr_ min_ max_ start_ cache_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CreateSequence ann_ name_ incr_ min_ max_ start_ cache_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateSequence ann_ name_ incr_ min_ max_ start_ cache_
+              -- self rule
+              _originalTree =
+                  CreateSequence ann_ name_ incr_ min_ max_ start_ cache_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateTable :: Annotation ->
+                             String ->
+                             T_AttributeDefList  ->
+                             T_ConstraintList  ->
+                             T_Statement 
+sem_Statement_CreateTable ann_ name_ atts_ cons_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _attrs :: ([(String,Type)])
+              _statementType :: (Maybe StatementType)
+              _consOlib :: LocalBindings
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _attsOcat :: Catalog
+              _attsOidenv :: IDEnv
+              _attsOlib :: LocalBindings
+              _consOcat :: Catalog
+              _consOidenv :: IDEnv
+              _attsIannotatedTree :: AttributeDefList 
+              _attsIattrs :: ([(String, Maybe Type)])
+              _attsIfixedUpIdentifiersTree :: AttributeDefList 
+              _attsIoriginalTree :: AttributeDefList 
+              _consIannotatedTree :: ConstraintList 
+              _consIfixedUpIdentifiersTree :: ConstraintList 
+              _consIoriginalTree :: ConstraintList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 31, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 32, column 9)
+              _catUpdates =
+                  [CatCreateTable name_ _attrs     defaultSystemColumns]
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 35, column 9)
+              _attrs =
+                  mapMaybe okAt _attsIattrs
+                  where
+                    okAt (s, Just t) = Just (s,t)
+                    okAt (_,Nothing) = Nothing
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 40, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 41, column 9)
+              _backTree =
+                  CreateTable ann_
+                              name_
+                              _attsIannotatedTree
+                              _consIannotatedTree
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 45, column 9)
+              _consOlib =
+                  case lbUpdate _lhsIcat
+                         (LBIds "attributedefs" Nothing _attrs    )
+                         _lhsIlib of
+                     Left x -> error $ "statement-createtable-cons.lib " ++ show x
+                     Right e -> e
+              -- self rule
+              _annotatedTree =
+                  CreateTable ann_ name_ _attsIannotatedTree _consIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateTable ann_ name_ _attsIfixedUpIdentifiersTree _consIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateTable ann_ name_ _attsIoriginalTree _consIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _attsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _attsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _attsOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _consOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _consOidenv =
+                  _lhsIidenv
+              ( _attsIannotatedTree,_attsIattrs,_attsIfixedUpIdentifiersTree,_attsIoriginalTree) =
+                  atts_ _attsOcat _attsOidenv _attsOlib 
+              ( _consIannotatedTree,_consIfixedUpIdentifiersTree,_consIoriginalTree) =
+                  cons_ _consOcat _consOidenv _consOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateTableAs :: Annotation ->
+                               String ->
+                               T_QueryExpr  ->
+                               T_Statement 
+sem_Statement_CreateTableAs ann_ name_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOcsql :: LocalBindings
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _attrs :: (Either [TypeError] [(String,Type)])
+              _statementType :: (Maybe StatementType)
+              _exprOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: QueryExpr 
+              _exprIcidenv :: IDEnv
+              _exprIfixedUpIdentifiersTree :: QueryExpr 
+              _exprIlibUpdates :: ([LocalBindingsUpdate])
+              _exprIoriginalTree :: QueryExpr 
+              _exprIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 122, column 21)
+              _exprOcsql =
+                  emptyBindings
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 64, column 9)
+              _tpe =
+                  CompositeType <$> lmt _exprIuType
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 65, column 9)
+              _catUpdates =
+                  either (const []) id $ do
+                  ats <- _attrs
+                  return [CatCreateTable name_ ats defaultSystemColumns]
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 71, column 9)
+              _attrs =
+                  lmt _exprIuType
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 73, column 9)
+              _backTree =
+                  CreateTableAs ann_ name_ _exprIannotatedTree
+              -- "./TypeChecking/Ddl/CreateTable.ag"(line 74, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 175, column 32)
+              _exprOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CreateTableAs ann_ name_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateTableAs ann_ name_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateTableAs ann_ name_ _exprIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIcidenv,_exprIfixedUpIdentifiersTree,_exprIlibUpdates,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOcsql _exprOexpectedTypes _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateTrigger :: Annotation ->
+                               String ->
+                               TriggerWhen ->
+                               ([TriggerEvent]) ->
+                               String ->
+                               TriggerFire ->
+                               String ->
+                               T_ScalarExprList  ->
+                               T_Statement 
+sem_Statement_CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ fnArgs_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _fnArgsOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _fnArgsOcat :: Catalog
+              _fnArgsOidenv :: IDEnv
+              _fnArgsOlib :: LocalBindings
+              _fnArgsIannotatedTree :: ScalarExprList 
+              _fnArgsIfixedUpIdentifiersTree :: ScalarExprList 
+              _fnArgsIoriginalTree :: ScalarExprList 
+              _fnArgsIuType :: ([Maybe Type])
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 153, column 21)
+              _fnArgsOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ _fnArgsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ _fnArgsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ _fnArgsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _fnArgsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _fnArgsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _fnArgsOlib =
+                  _lhsIlib
+              ( _fnArgsIannotatedTree,_fnArgsIfixedUpIdentifiersTree,_fnArgsIoriginalTree,_fnArgsIuType) =
+                  fnArgs_ _fnArgsOcat _fnArgsOexpectedTypes _fnArgsOidenv _fnArgsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateType :: Annotation ->
+                            String ->
+                            T_TypeAttributeDefList  ->
+                            T_Statement 
+sem_Statement_CreateType ann_ name_ atts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _attsOcat :: Catalog
+              _attsOidenv :: IDEnv
+              _attsOlib :: LocalBindings
+              _attsIannotatedTree :: TypeAttributeDefList 
+              _attsIattrs :: ([(String, Maybe Type)])
+              _attsIfixedUpIdentifiersTree :: TypeAttributeDefList 
+              _attsIoriginalTree :: TypeAttributeDefList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 48, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 49, column 9)
+              _attrs =
+                  mapMaybe okAt _attsIattrs
+                  where
+                    okAt (s, Just t) = Just (s,t)
+                    okAt (_,Nothing) = Nothing
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 53, column 9)
+              _backTree =
+                  CreateType ann_ name_ _attsIannotatedTree
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 54, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 55, column 9)
+              _catUpdates =
+                  [CatCreateComposite name_ _attrs    ]
+              -- self rule
+              _annotatedTree =
+                  CreateType ann_ name_ _attsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateType ann_ name_ _attsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateType ann_ name_ _attsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _attsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _attsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _attsOlib =
+                  _lhsIlib
+              ( _attsIannotatedTree,_attsIattrs,_attsIfixedUpIdentifiersTree,_attsIoriginalTree) =
+                  atts_ _attsOcat _attsOidenv _attsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_CreateView :: Annotation ->
+                            String ->
+                            (Maybe [String]) ->
+                            T_QueryExpr  ->
+                            T_Statement 
+sem_Statement_CreateView ann_ name_ colNames_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOcsql :: LocalBindings
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _exprOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: QueryExpr 
+              _exprIcidenv :: IDEnv
+              _exprIfixedUpIdentifiersTree :: QueryExpr 
+              _exprIlibUpdates :: ([LocalBindingsUpdate])
+              _exprIoriginalTree :: QueryExpr 
+              _exprIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 123, column 18)
+              _exprOcsql =
+                  emptyBindings
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 15, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 16, column 9)
+              _backTree =
+                  CreateView ann_ name_ colNames_ _exprIannotatedTree
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 17, column 9)
+              _catUpdates =
+                  maybe [] (\a -> [CatCreateView name_ a]) _exprIuType
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 19, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 175, column 32)
+              _exprOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  CreateView ann_ name_ colNames_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  CreateView ann_ name_ colNames_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  CreateView ann_ name_ colNames_ _exprIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIcidenv,_exprIfixedUpIdentifiersTree,_exprIlibUpdates,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOcsql _exprOexpectedTypes _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Delete :: Annotation ->
+                        T_SQIdentifier  ->
+                        T_TableRefList  ->
+                        T_MaybeBoolExpr  ->
+                        T_MaybeSelectList  ->
+                        T_Statement 
+sem_Statement_Delete ann_ table_ using_ whr_ returning_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _whrOlib :: LocalBindings
+              _returningOlib :: LocalBindings
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _tableOcat :: Catalog
+              _tableOidenv :: IDEnv
+              _tableOlib :: LocalBindings
+              _usingOcat :: Catalog
+              _usingOidenv :: IDEnv
+              _usingOlib :: LocalBindings
+              _whrOcat :: Catalog
+              _whrOidenv :: IDEnv
+              _returningOcat :: Catalog
+              _returningOidenv :: IDEnv
+              _tableIannotatedTree :: SQIdentifier 
+              _tableIfixedUpIdentifiersTree :: SQIdentifier 
+              _tableIoriginalTree :: SQIdentifier 
+              _tableItbAnnotatedTree :: SQIdentifier 
+              _tableItbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              _usingIannotatedTree :: TableRefList 
+              _usingIfixedUpIdentifiersTree :: TableRefList 
+              _usingIlibUpdates :: ([LocalBindingsUpdate])
+              _usingInewLib2 :: LocalBindings
+              _usingIoriginalTree :: TableRefList 
+              _usingItrefIDs :: ([(String,[String])])
+              _whrIannotatedTree :: MaybeBoolExpr 
+              _whrIfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _whrIoriginalTree :: MaybeBoolExpr 
+              _returningIannotatedTree :: MaybeSelectList 
+              _returningIfixedUpIdentifiersTree :: MaybeSelectList 
+              _returningIlistType :: ([(String,Maybe Type)])
+              _returningIoriginalTree :: MaybeSelectList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Dml/Delete.ag"(line 13, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Dml/Delete.ag"(line 14, column 9)
+              _statementType =
+                  do
+                  pt <- sequence $ getPlaceholderTypes _whrIannotatedTree
+                  lt <- liftList _returningIlistType
+                  return (pt,lt)
+              -- "./TypeChecking/Dml/Delete.ag"(line 19, column 9)
+              _backTree =
+                  Delete ann_ _tableItbAnnotatedTree _usingIannotatedTree _whrIannotatedTree _returningIannotatedTree
+              -- "./TypeChecking/Dml/Delete.ag"(line 20, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Dml/Delete.ag"(line 22, column 9)
+              _lib =
+                  either (const _lhsIlib) id $ do
+                  a <- lmt (allAtts <$> _tableItbUType)
+                  lbUpdate _lhsIcat (LBIds "delete table attrs" (Just $ getTName _tableIannotatedTree) a) _lhsIlib
+              -- "./TypeChecking/Dml/Delete.ag"(line 26, column 9)
+              _whrOlib =
+                  _lib
+              -- "./TypeChecking/Dml/Delete.ag"(line 27, column 9)
+              _returningOlib =
+                  _lib
+              -- self rule
+              _annotatedTree =
+                  Delete ann_ _tableIannotatedTree _usingIannotatedTree _whrIannotatedTree _returningIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Delete ann_ _tableIfixedUpIdentifiersTree _usingIfixedUpIdentifiersTree _whrIfixedUpIdentifiersTree _returningIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Delete ann_ _tableIoriginalTree _usingIoriginalTree _whrIoriginalTree _returningIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tableOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tableOidenv =
+                  _lhsIidenv
+              -- copy rule (from local)
+              _tableOlib =
+                  _lib
+              -- copy rule (down)
+              _usingOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _usingOidenv =
+                  _lhsIidenv
+              -- copy rule (from local)
+              _usingOlib =
+                  _lib
+              -- copy rule (down)
+              _whrOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _whrOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _returningOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _returningOidenv =
+                  _lhsIidenv
+              ( _tableIannotatedTree,_tableIfixedUpIdentifiersTree,_tableIoriginalTree,_tableItbAnnotatedTree,_tableItbUType) =
+                  table_ _tableOcat _tableOidenv _tableOlib 
+              ( _usingIannotatedTree,_usingIfixedUpIdentifiersTree,_usingIlibUpdates,_usingInewLib2,_usingIoriginalTree,_usingItrefIDs) =
+                  using_ _usingOcat _usingOidenv _usingOlib 
+              ( _whrIannotatedTree,_whrIfixedUpIdentifiersTree,_whrIoriginalTree) =
+                  whr_ _whrOcat _whrOidenv _whrOlib 
+              ( _returningIannotatedTree,_returningIfixedUpIdentifiersTree,_returningIlistType,_returningIoriginalTree) =
+                  returning_ _returningOcat _returningOidenv _returningOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_DropFunction :: Annotation ->
+                              IfExists ->
+                              T_StringTypeNameListPairList  ->
+                              Cascade ->
+                              T_Statement 
+sem_Statement_DropFunction ann_ ifE_ sigs_ cascade_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _sigsOcat :: Catalog
+              _sigsOidenv :: IDEnv
+              _sigsOlib :: LocalBindings
+              _sigsIannotatedTree :: StringTypeNameListPairList 
+              _sigsIfixedUpIdentifiersTree :: StringTypeNameListPairList 
+              _sigsIfnSigs :: ([(String,[Maybe Type])])
+              _sigsIoriginalTree :: StringTypeNameListPairList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Ddl/Drops.ag"(line 10, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Ddl/Drops.ag"(line 11, column 9)
+              _backTree =
+                  DropFunction ann_ ifE_ _sigsIannotatedTree cascade_
+              -- "./TypeChecking/Ddl/Drops.ag"(line 12, column 9)
+              _catUpdates =
+                  either (const []) id $
+                  Right $ map mcu $ mapMaybe goodSig _sigsIfnSigs
+                  where
+                    mcu :: (String,[Type]) -> CatalogUpdate
+                    mcu (nm,args) = CatDropFunction ifE nm args
+                    ifE = ifE_ == IfExists
+                    goodSig :: (String,[Maybe Type]) -> Maybe (String,[Type])
+                    goodSig (s, ts) = do
+                                  ts1 <- sequence ts
+                                  return (s,ts1)
+              -- "./TypeChecking/Ddl/Drops.ag"(line 23, column 9)
+              _statementType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  DropFunction ann_ ifE_ _sigsIannotatedTree cascade_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  DropFunction ann_ ifE_ _sigsIfixedUpIdentifiersTree cascade_
+              -- self rule
+              _originalTree =
+                  DropFunction ann_ ifE_ _sigsIoriginalTree cascade_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _sigsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _sigsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _sigsOlib =
+                  _lhsIlib
+              ( _sigsIannotatedTree,_sigsIfixedUpIdentifiersTree,_sigsIfnSigs,_sigsIoriginalTree) =
+                  sigs_ _sigsOcat _sigsOidenv _sigsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_DropSomething :: Annotation ->
+                               DropType ->
+                               IfExists ->
+                               ([String]) ->
+                               Cascade ->
+                               T_Statement 
+sem_Statement_DropSomething ann_ dropType_ ifE_ names_ cascade_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  DropSomething ann_ dropType_ ifE_ names_ cascade_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  DropSomething ann_ dropType_ ifE_ names_ cascade_
+              -- self rule
+              _originalTree =
+                  DropSomething ann_ dropType_ ifE_ names_ cascade_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Execute :: Annotation ->
+                         T_ScalarExpr  ->
+                         T_Statement 
+sem_Statement_Execute ann_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 112, column 9)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Execute ann_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Execute ann_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Execute ann_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ExitStatement :: Annotation ->
+                               (Maybe String) ->
+                               T_Statement 
+sem_Statement_ExitStatement ann_ lb_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  ExitStatement ann_ lb_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ExitStatement ann_ lb_
+              -- self rule
+              _originalTree =
+                  ExitStatement ann_ lb_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ForIntegerStatement :: Annotation ->
+                                     (Maybe String) ->
+                                     T_ScalarExpr  ->
+                                     T_ScalarExpr  ->
+                                     T_ScalarExpr  ->
+                                     T_StatementList  ->
+                                     T_Statement 
+sem_Statement_ForIntegerStatement ann_ lb_ var_ from_ to_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _stsOlib :: LocalBindings
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _fromOexpectedType :: (Maybe Type)
+              _toOexpectedType :: (Maybe Type)
+              _varOexpectedType :: (Maybe Type)
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _varOcat :: Catalog
+              _varOidenv :: IDEnv
+              _varOlib :: LocalBindings
+              _fromOcat :: Catalog
+              _fromOidenv :: IDEnv
+              _fromOlib :: LocalBindings
+              _toOcat :: Catalog
+              _toOidenv :: IDEnv
+              _toOlib :: LocalBindings
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _varIannotatedTree :: ScalarExpr 
+              _varIfixedUpIdentifiersTree :: ScalarExpr 
+              _varIoriginalTree :: ScalarExpr 
+              _varIuType :: (Maybe Type)
+              _fromIannotatedTree :: ScalarExpr 
+              _fromIfixedUpIdentifiersTree :: ScalarExpr 
+              _fromIoriginalTree :: ScalarExpr 
+              _fromIuType :: (Maybe Type)
+              _toIannotatedTree :: ScalarExpr 
+              _toIfixedUpIdentifiersTree :: ScalarExpr 
+              _toIoriginalTree :: ScalarExpr 
+              _toIuType :: (Maybe Type)
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 138, column 9)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 139, column 9)
+              _stsOlibUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 32, column 9)
+              _tpe =
+                  do
+                  fromType <- lmt _fromIuType
+                  toType <- lmt _toIuType
+                  errorWhen (fromType /= toType) [FromToTypesNotSame fromType toType]
+                  case _varIuType of
+                    Just t -> checkAssignmentValid _lhsIcat fromType t
+                    Nothing -> return ()
+                  return $ Pseudo Void
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 41, column 9)
+              _implicitVar =
+                  case _varIannotatedTree of
+                      Identifier a i | errs a == [UnrecognisedIdentifier i] -> True
+                      _ -> False
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 44, column 9)
+              _stsOlib =
+                  if _implicitVar
+                  then either (const _lhsIlib) id $ do
+                       ft <- lmt _fromIuType
+                       lbUpdate _lhsIcat
+                          (LBIds "local for loop variable" Nothing [((getName _varIannotatedTree),ft)]) _lhsIlib
+                  else _lhsIlib
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 52, column 9)
+              _backTree =
+                  let i = if _implicitVar
+                          then let (Identifier a i') = _varIannotatedTree
+                               in Identifier a { errs = []} i'
+                          else _varIannotatedTree
+                  in ForIntegerStatement ann_ lb_ i _fromIannotatedTree _toIannotatedTree _stsIannotatedTree
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 58, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 59, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 113, column 27)
+              _fromOexpectedType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 114, column 27)
+              _toOexpectedType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 116, column 45)
+              _varOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  ForIntegerStatement ann_ lb_ _varIannotatedTree _fromIannotatedTree _toIannotatedTree _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ForIntegerStatement ann_ lb_ _varIfixedUpIdentifiersTree _fromIfixedUpIdentifiersTree _toIfixedUpIdentifiersTree _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ForIntegerStatement ann_ lb_ _varIoriginalTree _fromIoriginalTree _toIoriginalTree _stsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _varOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _varOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _varOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _fromOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _fromOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _fromOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _toOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _toOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _toOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              ( _varIannotatedTree,_varIfixedUpIdentifiersTree,_varIoriginalTree,_varIuType) =
+                  var_ _varOcat _varOexpectedType _varOidenv _varOlib 
+              ( _fromIannotatedTree,_fromIfixedUpIdentifiersTree,_fromIoriginalTree,_fromIuType) =
+                  from_ _fromOcat _fromOexpectedType _fromOidenv _fromOlib 
+              ( _toIannotatedTree,_toIfixedUpIdentifiersTree,_toIoriginalTree,_toIuType) =
+                  to_ _toOcat _toOexpectedType _toOidenv _toOlib 
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ForQueryStatement :: Annotation ->
+                                   (Maybe String) ->
+                                   T_ScalarExpr  ->
+                                   T_QueryExpr  ->
+                                   T_StatementList  ->
+                                   T_Statement 
+sem_Statement_ForQueryStatement ann_ lb_ var_ sel_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _selOcsql :: LocalBindings
+              _tpe :: (Either [TypeError] Type)
+              _stsOlib :: LocalBindings
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _varOexpectedType :: (Maybe Type)
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _varOcat :: Catalog
+              _varOidenv :: IDEnv
+              _varOlib :: LocalBindings
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _varIannotatedTree :: ScalarExpr 
+              _varIfixedUpIdentifiersTree :: ScalarExpr 
+              _varIoriginalTree :: ScalarExpr 
+              _varIuType :: (Maybe Type)
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 138, column 9)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 139, column 9)
+              _stsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 124, column 25)
+              _selOcsql =
+                  emptyBindings
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 64, column 9)
+              _tpe =
+                  do
+                  st <- lmt (CompositeType <$> _selIuType)
+                  toType <- lmt _varIuType
+                  checkAssignmentValid _lhsIcat st toType
+                  return $ Pseudo Void
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 74, column 9)
+              _stsOlib =
+                  either (const _lhsIlib) id $ do
+                  _ <- _tpe
+                  st <- lmt (CompositeType <$> _selIuType)
+                  lbUpdate _lhsIcat (LBIds "for loop record type" Nothing [(getName _varIannotatedTree,st)]) _lhsIlib
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 80, column 9)
+              _backTree =
+                  ForQueryStatement ann_ lb_ _varIannotatedTree _selIannotatedTree _stsIannotatedTree
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 81, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 82, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 116, column 45)
+              _varOexpectedType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 177, column 9)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  ForQueryStatement ann_ lb_ _varIannotatedTree _selIannotatedTree _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ForQueryStatement ann_ lb_ _varIfixedUpIdentifiersTree _selIfixedUpIdentifiersTree _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ForQueryStatement ann_ lb_ _varIoriginalTree _selIoriginalTree _stsIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _varOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _varOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _varOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              ( _varIannotatedTree,_varIfixedUpIdentifiersTree,_varIoriginalTree,_varIuType) =
+                  var_ _varOcat _varOexpectedType _varOidenv _varOlib 
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_If :: Annotation ->
+                    T_ScalarExprStatementListPairList  ->
+                    T_StatementList  ->
+                    T_Statement 
+sem_Statement_If ann_ cases_ els_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _elsOcatUpdates :: ([CatalogUpdate])
+              _elsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _casesOcat :: Catalog
+              _casesOidenv :: IDEnv
+              _casesOlib :: LocalBindings
+              _elsOcat :: Catalog
+              _elsOidenv :: IDEnv
+              _elsOlib :: LocalBindings
+              _casesIannotatedTree :: ScalarExprStatementListPairList 
+              _casesIfixedUpIdentifiersTree :: ScalarExprStatementListPairList 
+              _casesIoriginalTree :: ScalarExprStatementListPairList 
+              _elsIannotatedTree :: StatementList 
+              _elsIfixedUpIdentifiersTree :: StatementList 
+              _elsIoriginalTree :: StatementList 
+              _elsIproducedCat :: Catalog
+              _elsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 134, column 9)
+              _elsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 135, column 9)
+              _elsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  If ann_ _casesIannotatedTree _elsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  If ann_ _casesIfixedUpIdentifiersTree _elsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  If ann_ _casesIoriginalTree _elsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _casesOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _casesOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _casesOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _elsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _elsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _elsOlib =
+                  _lhsIlib
+              ( _casesIannotatedTree,_casesIfixedUpIdentifiersTree,_casesIoriginalTree) =
+                  cases_ _casesOcat _casesOidenv _casesOlib 
+              ( _elsIannotatedTree,_elsIfixedUpIdentifiersTree,_elsIoriginalTree,_elsIproducedCat,_elsIproducedLib) =
+                  els_ _elsOcat _elsOcatUpdates _elsOidenv _elsOlib _elsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Insert :: Annotation ->
+                        T_SQIdentifier  ->
+                        ([String]) ->
+                        T_QueryExpr  ->
+                        T_MaybeSelectList  ->
+                        T_Statement 
+sem_Statement_Insert ann_ table_ targetCols_ insData_ returning_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _insDataOcsql :: LocalBindings
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _columnTypes :: (Either [TypeError] [(String,Type)])
+              _catUpdates :: ([CatalogUpdate])
+              _insDataOexpectedTypes :: ([Maybe Type])
+              _returningOlib :: LocalBindings
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _tableOcat :: Catalog
+              _tableOidenv :: IDEnv
+              _tableOlib :: LocalBindings
+              _insDataOcat :: Catalog
+              _insDataOidenv :: IDEnv
+              _insDataOlib :: LocalBindings
+              _returningOcat :: Catalog
+              _returningOidenv :: IDEnv
+              _tableIannotatedTree :: SQIdentifier 
+              _tableIfixedUpIdentifiersTree :: SQIdentifier 
+              _tableIoriginalTree :: SQIdentifier 
+              _tableItbAnnotatedTree :: SQIdentifier 
+              _tableItbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              _insDataIannotatedTree :: QueryExpr 
+              _insDataIcidenv :: IDEnv
+              _insDataIfixedUpIdentifiersTree :: QueryExpr 
+              _insDataIlibUpdates :: ([LocalBindingsUpdate])
+              _insDataIoriginalTree :: QueryExpr 
+              _insDataIuType :: (Maybe [(String,Type)])
+              _returningIannotatedTree :: MaybeSelectList 
+              _returningIfixedUpIdentifiersTree :: MaybeSelectList 
+              _returningIlistType :: ([(String,Maybe Type)])
+              _returningIoriginalTree :: MaybeSelectList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 125, column 14)
+              _insDataOcsql =
+                  emptyBindings
+              -- "./TypeChecking/Dml/Insert.ag"(line 14, column 9)
+              _tpe =
+                  either Left (const $ Right $ Pseudo Void) _columnTypes
+              -- "./TypeChecking/Dml/Insert.ag"(line 15, column 9)
+              _statementType =
+                  Just (catMaybes $ getPlaceholderTypes _insDataIannotatedTree
+                       ,fromMaybe [] $ liftList _returningIlistType)
+              -- "./TypeChecking/Dml/Insert.ag"(line 20, column 9)
+              _columnTypes =
+                  do
+                  atts <- lmt (allAtts <$> _tableItbUType)
+                  pAtts <- lmt (fst <$> _tableItbUType)
+                  tAtts <- case targetCols_ of
+                                [] -> return pAtts
+                                _ -> mapM (lkpA atts) targetCols_
+                  expAtts <- lmt _insDataIuType
+                  checkAssignmentsValid _lhsIcat (map snd expAtts) (map snd tAtts)
+                  return tAtts
+                  where
+                    lkpA :: [(String,Type)] -> String -> E (String,Type)
+                    lkpA m n = maybe (Left [UnrecognisedIdentifier n])
+                                     (\t -> Right (n,t))
+                                     $ lookup n m
+              -- "./TypeChecking/Dml/Insert.ag"(line 36, column 9)
+              _backTree =
+                  Insert ann_ _tableItbAnnotatedTree
+                         targetCols_
+                         _insDataIannotatedTree
+                         _returningIannotatedTree
+              -- "./TypeChecking/Dml/Insert.ag"(line 40, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Dml/Insert.ag"(line 41, column 9)
+              _insDataOexpectedTypes =
+                  maybe [] id $ do
+                  ts <- etmt $ _columnTypes
+                  return $ map (Just . snd) ts
+              -- "./TypeChecking/Dml/Insert.ag"(line 45, column 9)
+              _returningOlib =
+                  either (const _lhsIlib) id $ do
+                    atts <- lmt (allAtts <$> _tableItbUType)
+                    lbUpdate _lhsIcat (LBIds "insert target table" (Just $ getTName _tableIannotatedTree) atts) _lhsIlib
+              -- self rule
+              _annotatedTree =
+                  Insert ann_ _tableIannotatedTree targetCols_ _insDataIannotatedTree _returningIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Insert ann_ _tableIfixedUpIdentifiersTree targetCols_ _insDataIfixedUpIdentifiersTree _returningIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Insert ann_ _tableIoriginalTree targetCols_ _insDataIoriginalTree _returningIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tableOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tableOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tableOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _insDataOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _insDataOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _insDataOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _returningOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _returningOidenv =
+                  _lhsIidenv
+              ( _tableIannotatedTree,_tableIfixedUpIdentifiersTree,_tableIoriginalTree,_tableItbAnnotatedTree,_tableItbUType) =
+                  table_ _tableOcat _tableOidenv _tableOlib 
+              ( _insDataIannotatedTree,_insDataIcidenv,_insDataIfixedUpIdentifiersTree,_insDataIlibUpdates,_insDataIoriginalTree,_insDataIuType) =
+                  insData_ _insDataOcat _insDataOcsql _insDataOexpectedTypes _insDataOidenv _insDataOlib 
+              ( _returningIannotatedTree,_returningIfixedUpIdentifiersTree,_returningIlistType,_returningIoriginalTree) =
+                  returning_ _returningOcat _returningOidenv _returningOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Into :: Annotation ->
+                      Bool ->
+                      T_ScalarExprList  ->
+                      T_Statement  ->
+                      T_Statement 
+sem_Statement_Into ann_ strict_ into_ stmt_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _intoOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _intoOcat :: Catalog
+              _intoOidenv :: IDEnv
+              _intoOlib :: LocalBindings
+              _stmtOcat :: Catalog
+              _stmtOidenv :: IDEnv
+              _stmtOinProducedCat :: Catalog
+              _stmtOlib :: LocalBindings
+              _intoIannotatedTree :: ScalarExprList 
+              _intoIfixedUpIdentifiersTree :: ScalarExprList 
+              _intoIoriginalTree :: ScalarExprList 
+              _intoIuType :: ([Maybe Type])
+              _stmtIannotatedTree :: Statement 
+              _stmtIcatUpdates :: ([CatalogUpdate])
+              _stmtIfixedUpIdentifiersTree :: Statement 
+              _stmtIlibUpdates :: ([LocalBindingsUpdate])
+              _stmtIoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 117, column 12)
+              _intoOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Into ann_ strict_ _intoIannotatedTree _stmtIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Into ann_ strict_ _intoIfixedUpIdentifiersTree _stmtIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Into ann_ strict_ _intoIoriginalTree _stmtIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _intoOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _intoOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _intoOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _stmtOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stmtOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _stmtOinProducedCat =
+                  _lhsIinProducedCat
+              -- copy rule (down)
+              _stmtOlib =
+                  _lhsIlib
+              ( _intoIannotatedTree,_intoIfixedUpIdentifiersTree,_intoIoriginalTree,_intoIuType) =
+                  into_ _intoOcat _intoOexpectedTypes _intoOidenv _intoOlib 
+              ( _stmtIannotatedTree,_stmtIcatUpdates,_stmtIfixedUpIdentifiersTree,_stmtIlibUpdates,_stmtIoriginalTree) =
+                  stmt_ _stmtOcat _stmtOidenv _stmtOinProducedCat _stmtOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_LoopStatement :: Annotation ->
+                               (Maybe String) ->
+                               T_StatementList  ->
+                               T_Statement 
+sem_Statement_LoopStatement ann_ lb_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _stsOlib :: LocalBindings
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 138, column 9)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 139, column 9)
+              _stsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  LoopStatement ann_ lb_ _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  LoopStatement ann_ lb_ _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  LoopStatement ann_ lb_ _stsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _stsOlib =
+                  _lhsIlib
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Notify :: Annotation ->
+                        String ->
+                        T_Statement 
+sem_Statement_Notify ann_ name_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Notify ann_ name_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Notify ann_ name_
+              -- self rule
+              _originalTree =
+                  Notify ann_ name_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_NullStatement :: Annotation ->
+                               T_Statement 
+sem_Statement_NullStatement ann_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  NullStatement ann_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NullStatement ann_
+              -- self rule
+              _originalTree =
+                  NullStatement ann_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Perform :: Annotation ->
+                         T_ScalarExpr  ->
+                         T_Statement 
+sem_Statement_Perform ann_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 112, column 9)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Perform ann_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Perform ann_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Perform ann_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_QueryStatement :: Annotation ->
+                                T_QueryExpr  ->
+                                T_Statement 
+sem_Statement_QueryStatement ann_ ex_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _exOcsql :: LocalBindings
+              _exOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exOcat :: Catalog
+              _exOidenv :: IDEnv
+              _exOlib :: LocalBindings
+              _exIannotatedTree :: QueryExpr 
+              _exIcidenv :: IDEnv
+              _exIfixedUpIdentifiersTree :: QueryExpr 
+              _exIlibUpdates :: ([LocalBindingsUpdate])
+              _exIoriginalTree :: QueryExpr 
+              _exIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 14, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 15, column 9)
+              _statementType =
+                  do
+                  pt <- sequence $ getPlaceholderTypes _exIannotatedTree
+                  st <- _exIuType
+                  return (pt
+                         ,case st of
+                            [(_,(Pseudo Void))] -> []
+                            t -> t)
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 23, column 9)
+              _backTree =
+                  QueryStatement ann_ _exIannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 24, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 126, column 22)
+              _exOcsql =
+                  emptyBindings
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 137, column 9)
+              _libUpdates =
+                  _exIlibUpdates
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 178, column 22)
+              _exOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  QueryStatement ann_ _exIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  QueryStatement ann_ _exIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  QueryStatement ann_ _exIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exOlib =
+                  _lhsIlib
+              ( _exIannotatedTree,_exIcidenv,_exIfixedUpIdentifiersTree,_exIlibUpdates,_exIoriginalTree,_exIuType) =
+                  ex_ _exOcat _exOcsql _exOexpectedTypes _exOidenv _exOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Raise :: Annotation ->
+                       RaiseType ->
+                       String ->
+                       T_ScalarExprList  ->
+                       T_Statement 
+sem_Statement_Raise ann_ level_ message_ args_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _argsOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _argsOcat :: Catalog
+              _argsOidenv :: IDEnv
+              _argsOlib :: LocalBindings
+              _argsIannotatedTree :: ScalarExprList 
+              _argsIfixedUpIdentifiersTree :: ScalarExprList 
+              _argsIoriginalTree :: ScalarExprList 
+              _argsIuType :: ([Maybe Type])
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 154, column 13)
+              _argsOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Raise ann_ level_ message_ _argsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Raise ann_ level_ message_ _argsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Raise ann_ level_ message_ _argsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _argsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _argsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _argsOlib =
+                  _lhsIlib
+              ( _argsIannotatedTree,_argsIfixedUpIdentifiersTree,_argsIoriginalTree,_argsIuType) =
+                  args_ _argsOcat _argsOexpectedTypes _argsOidenv _argsOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Return :: Annotation ->
+                        T_MaybeScalarExpr  ->
+                        T_Statement 
+sem_Statement_Return ann_ value_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _catUpdates :: ([CatalogUpdate])
+              _statementType :: (Maybe StatementType)
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _valueOcat :: Catalog
+              _valueOidenv :: IDEnv
+              _valueOlib :: LocalBindings
+              _valueIannotatedTree :: MaybeScalarExpr 
+              _valueIfixedUpIdentifiersTree :: MaybeScalarExpr 
+              _valueIoriginalTree :: MaybeScalarExpr 
+              _valueIuType :: (Maybe Type)
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 12, column 9)
+              _tpe =
+                  maybe (Right $ Pseudo Void) Right _valueIuType
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 13, column 9)
+              _backTree =
+                  Return ann_ _valueIannotatedTree
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 14, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Plpgsql/Plpgsql.ag"(line 15, column 9)
+              _statementType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  Return ann_ _valueIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Return ann_ _valueIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Return ann_ _valueIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _valueOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _valueOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _valueOlib =
+                  _lhsIlib
+              ( _valueIannotatedTree,_valueIfixedUpIdentifiersTree,_valueIoriginalTree,_valueIuType) =
+                  value_ _valueOcat _valueOidenv _valueOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ReturnNext :: Annotation ->
+                            T_ScalarExpr  ->
+                            T_Statement 
+sem_Statement_ReturnNext ann_ expr_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 112, column 9)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  ReturnNext ann_ _exprIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ReturnNext ann_ _exprIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ReturnNext ann_ _exprIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_ReturnQuery :: Annotation ->
+                             T_QueryExpr  ->
+                             T_Statement 
+sem_Statement_ReturnQuery ann_ sel_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _selOcsql :: LocalBindings
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 127, column 19)
+              _selOcsql =
+                  emptyBindings
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 177, column 9)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  ReturnQuery ann_ _selIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ReturnQuery ann_ _selIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ReturnQuery ann_ _selIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Set :: Annotation ->
+                     String ->
+                     ([SetValue]) ->
+                     T_Statement 
+sem_Statement_Set ann_ name_ values_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Set ann_ name_ values_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Set ann_ name_ values_
+              -- self rule
+              _originalTree =
+                  Set ann_ name_ values_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Truncate :: Annotation ->
+                          ([String]) ->
+                          RestartIdentity ->
+                          Cascade ->
+                          T_Statement 
+sem_Statement_Truncate ann_ tables_ restartIdentity_ cascade_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Truncate ann_ tables_ restartIdentity_ cascade_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Truncate ann_ tables_ restartIdentity_ cascade_
+              -- self rule
+              _originalTree =
+                  Truncate ann_ tables_ restartIdentity_ cascade_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_Update :: Annotation ->
+                        T_SQIdentifier  ->
+                        T_ScalarExprList  ->
+                        T_TableRefList  ->
+                        T_MaybeBoolExpr  ->
+                        T_MaybeSelectList  ->
+                        T_Statement 
+sem_Statement_Update ann_ table_ assigns_ fromList_ whr_ returning_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: Statement 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _tpe :: (Either [TypeError] Type)
+              _statementType :: (Maybe StatementType)
+              _catUpdates :: ([CatalogUpdate])
+              _whrOlib :: LocalBindings
+              _assignsOlib :: LocalBindings
+              _returningOlib :: LocalBindings
+              _assignsOexpectedTypes :: ([Maybe Type])
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _tableOcat :: Catalog
+              _tableOidenv :: IDEnv
+              _tableOlib :: LocalBindings
+              _assignsOcat :: Catalog
+              _assignsOidenv :: IDEnv
+              _fromListOcat :: Catalog
+              _fromListOidenv :: IDEnv
+              _fromListOlib :: LocalBindings
+              _whrOcat :: Catalog
+              _whrOidenv :: IDEnv
+              _returningOcat :: Catalog
+              _returningOidenv :: IDEnv
+              _tableIannotatedTree :: SQIdentifier 
+              _tableIfixedUpIdentifiersTree :: SQIdentifier 
+              _tableIoriginalTree :: SQIdentifier 
+              _tableItbAnnotatedTree :: SQIdentifier 
+              _tableItbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              _assignsIannotatedTree :: ScalarExprList 
+              _assignsIfixedUpIdentifiersTree :: ScalarExprList 
+              _assignsIoriginalTree :: ScalarExprList 
+              _assignsIuType :: ([Maybe Type])
+              _fromListIannotatedTree :: TableRefList 
+              _fromListIfixedUpIdentifiersTree :: TableRefList 
+              _fromListIlibUpdates :: ([LocalBindingsUpdate])
+              _fromListInewLib2 :: LocalBindings
+              _fromListIoriginalTree :: TableRefList 
+              _fromListItrefIDs :: ([(String,[String])])
+              _whrIannotatedTree :: MaybeBoolExpr 
+              _whrIfixedUpIdentifiersTree :: MaybeBoolExpr 
+              _whrIoriginalTree :: MaybeBoolExpr 
+              _returningIannotatedTree :: MaybeSelectList 
+              _returningIfixedUpIdentifiersTree :: MaybeSelectList 
+              _returningIlistType :: ([(String,Maybe Type)])
+              _returningIoriginalTree :: MaybeSelectList 
+              -- "./TypeChecking/Statements.ag"(line 82, column 9)
+              _lhsOannotatedTree =
+                  updateAnnotation
+                      (\a -> a {stType = _statementType
+                               ,catUpd = _catUpdates    }) $
+                  setTypeAddErrors _tpe     _backTree
+              -- "./TypeChecking/Statements.ag"(line 88, column 9)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- "./TypeChecking/Statements.ag"(line 89, column 9)
+              _lhsOlibUpdates =
+                  _libUpdates
+              -- "./TypeChecking/Statements.ag"(line 94, column 9)
+              _libUpdates =
+                  []
+              -- "./TypeChecking/Dml/Update.ag"(line 13, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/Dml/Update.ag"(line 18, column 9)
+              _statementType =
+                  do
+                  pt <- sequence $ getPlaceholderTypes _assignsIannotatedTree
+                                   ++ getPlaceholderTypes _whrIannotatedTree
+                  return (pt,fromMaybe [] $ liftList _returningIlistType)
+              -- "./TypeChecking/Dml/Update.ag"(line 24, column 9)
+              _backTree =
+                  Update ann_
+                         _tableItbAnnotatedTree
+                         _assignsIannotatedTree
+                         _fromListIannotatedTree
+                         _whrIannotatedTree
+                         _returningIannotatedTree
+              -- "./TypeChecking/Dml/Update.ag"(line 30, column 9)
+              _catUpdates =
+                  []
+              -- "./TypeChecking/Dml/Update.ag"(line 35, column 9)
+              _lib =
+                  either (const _lhsIlib) id $ do
+                  a <- lmt (allAtts <$> _tableItbUType)
+                  lbUpdate _lhsIcat (LBIds "updated table attrs" (Just $ getTName _tableIannotatedTree) a) _lhsIlib
+              -- "./TypeChecking/Dml/Update.ag"(line 39, column 9)
+              _whrOlib =
+                  _lib
+              -- "./TypeChecking/Dml/Update.ag"(line 40, column 9)
+              _assignsOlib =
+                  _lib
+              -- "./TypeChecking/Dml/Update.ag"(line 41, column 9)
+              _returningOlib =
+                  _lib
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 155, column 14)
+              _assignsOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  Update ann_ _tableIannotatedTree _assignsIannotatedTree _fromListIannotatedTree _whrIannotatedTree _returningIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Update ann_ _tableIfixedUpIdentifiersTree _assignsIfixedUpIdentifiersTree _fromListIfixedUpIdentifiersTree _whrIfixedUpIdentifiersTree _returningIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Update ann_ _tableIoriginalTree _assignsIoriginalTree _fromListIoriginalTree _whrIoriginalTree _returningIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tableOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tableOidenv =
+                  _lhsIidenv
+              -- copy rule (from local)
+              _tableOlib =
+                  _lib
+              -- copy rule (down)
+              _assignsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _assignsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _fromListOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _fromListOidenv =
+                  _lhsIidenv
+              -- copy rule (from local)
+              _fromListOlib =
+                  _lib
+              -- copy rule (down)
+              _whrOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _whrOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _returningOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _returningOidenv =
+                  _lhsIidenv
+              ( _tableIannotatedTree,_tableIfixedUpIdentifiersTree,_tableIoriginalTree,_tableItbAnnotatedTree,_tableItbUType) =
+                  table_ _tableOcat _tableOidenv _tableOlib 
+              ( _assignsIannotatedTree,_assignsIfixedUpIdentifiersTree,_assignsIoriginalTree,_assignsIuType) =
+                  assigns_ _assignsOcat _assignsOexpectedTypes _assignsOidenv _assignsOlib 
+              ( _fromListIannotatedTree,_fromListIfixedUpIdentifiersTree,_fromListIlibUpdates,_fromListInewLib2,_fromListIoriginalTree,_fromListItrefIDs) =
+                  fromList_ _fromListOcat _fromListOidenv _fromListOlib 
+              ( _whrIannotatedTree,_whrIfixedUpIdentifiersTree,_whrIoriginalTree) =
+                  whr_ _whrOcat _whrOidenv _whrOlib 
+              ( _returningIannotatedTree,_returningIfixedUpIdentifiersTree,_returningIlistType,_returningIoriginalTree) =
+                  returning_ _returningOcat _returningOidenv _returningOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+sem_Statement_WhileStatement :: Annotation ->
+                                (Maybe String) ->
+                                T_ScalarExpr  ->
+                                T_StatementList  ->
+                                T_Statement 
+sem_Statement_WhileStatement ann_ lb_ expr_ sts_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIinProducedCat
+       _lhsIlib ->
+         (let _lhsOcatUpdates :: ([CatalogUpdate])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _stsOcatUpdates :: ([CatalogUpdate])
+              _stsOlibUpdates :: ([LocalBindingsUpdate])
+              _exprOexpectedType :: (Maybe Type)
+              _lhsOannotatedTree :: Statement 
+              _lhsOfixedUpIdentifiersTree :: Statement 
+              _lhsOoriginalTree :: Statement 
+              _exprOcat :: Catalog
+              _exprOidenv :: IDEnv
+              _exprOlib :: LocalBindings
+              _stsOcat :: Catalog
+              _stsOidenv :: IDEnv
+              _stsOlib :: LocalBindings
+              _exprIannotatedTree :: ScalarExpr 
+              _exprIfixedUpIdentifiersTree :: ScalarExpr 
+              _exprIoriginalTree :: ScalarExpr 
+              _exprIuType :: (Maybe Type)
+              _stsIannotatedTree :: StatementList 
+              _stsIfixedUpIdentifiersTree :: StatementList 
+              _stsIoriginalTree :: StatementList 
+              _stsIproducedCat :: Catalog
+              _stsIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 116, column 9)
+              _lhsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 117, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 138, column 9)
+              _stsOcatUpdates =
+                  []
+              -- "./TypeChecking/Statements.ag"(line 139, column 9)
+              _stsOlibUpdates =
+                  []
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 112, column 9)
+              _exprOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  WhileStatement ann_ lb_ _exprIannotatedTree _stsIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  WhileStatement ann_ lb_ _exprIfixedUpIdentifiersTree _stsIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  WhileStatement ann_ lb_ _exprIoriginalTree _stsIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _exprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exprOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exprOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _stsOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _stsOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _stsOlib =
+                  _lhsIlib
+              ( _exprIannotatedTree,_exprIfixedUpIdentifiersTree,_exprIoriginalTree,_exprIuType) =
+                  expr_ _exprOcat _exprOexpectedType _exprOidenv _exprOlib 
+              ( _stsIannotatedTree,_stsIfixedUpIdentifiersTree,_stsIoriginalTree,_stsIproducedCat,_stsIproducedLib) =
+                  sts_ _stsOcat _stsOcatUpdates _stsOidenv _stsOlib _stsOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOoriginalTree)))
+-- StatementList -----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         catUpdates           : [CatalogUpdate]
+         idenv                : IDEnv
+         lib                  : LocalBindings
+         libUpdates           : [LocalBindingsUpdate]
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         producedCat          : Catalog
+         producedLib          : LocalBindings
+   alternatives:
+      alternative Cons:
+         child hd             : Statement 
+         child tl             : StatementList 
+         visit 0:
+            local newCat      : _
+            local newLib      : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local newCat      : _
+            local newLib      : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type StatementList  = [Statement ]
+-- cata
+sem_StatementList :: StatementList  ->
+                     T_StatementList 
+sem_StatementList list  =
+    (Prelude.foldr sem_StatementList_Cons sem_StatementList_Nil (Prelude.map sem_Statement list) )
+-- semantic domain
+type T_StatementList  = Catalog ->
+                        ([CatalogUpdate]) ->
+                        IDEnv ->
+                        LocalBindings ->
+                        ([LocalBindingsUpdate]) ->
+                        ( StatementList ,StatementList ,StatementList ,Catalog,LocalBindings)
+data Inh_StatementList  = Inh_StatementList {cat_Inh_StatementList :: Catalog,catUpdates_Inh_StatementList :: ([CatalogUpdate]),idenv_Inh_StatementList :: IDEnv,lib_Inh_StatementList :: LocalBindings,libUpdates_Inh_StatementList :: ([LocalBindingsUpdate])}
+data Syn_StatementList  = Syn_StatementList {annotatedTree_Syn_StatementList :: StatementList ,fixedUpIdentifiersTree_Syn_StatementList :: StatementList ,originalTree_Syn_StatementList :: StatementList ,producedCat_Syn_StatementList :: Catalog,producedLib_Syn_StatementList :: LocalBindings}
+wrap_StatementList :: T_StatementList  ->
+                      Inh_StatementList  ->
+                      Syn_StatementList 
+wrap_StatementList sem (Inh_StatementList _lhsIcat _lhsIcatUpdates _lhsIidenv _lhsIlib _lhsIlibUpdates )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib) = sem _lhsIcat _lhsIcatUpdates _lhsIidenv _lhsIlib _lhsIlibUpdates 
+     in  (Syn_StatementList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOproducedCat _lhsOproducedLib ))
+sem_StatementList_Cons :: T_Statement  ->
+                          T_StatementList  ->
+                          T_StatementList 
+sem_StatementList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIcatUpdates
+       _lhsIidenv
+       _lhsIlib
+       _lhsIlibUpdates ->
+         (let _hdOcat :: Catalog
+              _tlOcat :: Catalog
+              _hdOlib :: LocalBindings
+              _tlOlib :: LocalBindings
+              _lhsOproducedCat :: Catalog
+              _lhsOproducedLib :: LocalBindings
+              _tlOcatUpdates :: ([CatalogUpdate])
+              _tlOlibUpdates :: ([LocalBindingsUpdate])
+              _hdOinProducedCat :: Catalog
+              _lhsOannotatedTree :: StatementList 
+              _lhsOfixedUpIdentifiersTree :: StatementList 
+              _lhsOoriginalTree :: StatementList 
+              _hdOidenv :: IDEnv
+              _tlOidenv :: IDEnv
+              _hdIannotatedTree :: Statement 
+              _hdIcatUpdates :: ([CatalogUpdate])
+              _hdIfixedUpIdentifiersTree :: Statement 
+              _hdIlibUpdates :: ([LocalBindingsUpdate])
+              _hdIoriginalTree :: Statement 
+              _tlIannotatedTree :: StatementList 
+              _tlIfixedUpIdentifiersTree :: StatementList 
+              _tlIoriginalTree :: StatementList 
+              _tlIproducedCat :: Catalog
+              _tlIproducedLib :: LocalBindings
+              -- "./TypeChecking/Statements.ag"(line 56, column 9)
+              _newCat =
+                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
+              -- "./TypeChecking/Statements.ag"(line 57, column 9)
+              _newLib =
+                  fromRight _lhsIlib $ foldM (flip $ lbUpdate _lhsIcat) _lhsIlib _lhsIlibUpdates
+              -- "./TypeChecking/Statements.ag"(line 59, column 9)
+              _hdOcat =
+                  _newCat
+              -- "./TypeChecking/Statements.ag"(line 60, column 9)
+              _tlOcat =
+                  _newCat
+              -- "./TypeChecking/Statements.ag"(line 61, column 9)
+              _hdOlib =
+                  _newLib
+              -- "./TypeChecking/Statements.ag"(line 62, column 9)
+              _tlOlib =
+                  _newLib
+              -- "./TypeChecking/Statements.ag"(line 66, column 9)
+              _lhsOproducedCat =
+                  _tlIproducedCat
+              -- "./TypeChecking/Statements.ag"(line 67, column 9)
+              _lhsOproducedLib =
+                  _tlIproducedLib
+              -- "./TypeChecking/Statements.ag"(line 70, column 9)
+              _tlOcatUpdates =
+                  _hdIcatUpdates
+              -- "./TypeChecking/Statements.ag"(line 71, column 9)
+              _tlOlibUpdates =
+                  _hdIlibUpdates
+              -- "./TypeChecking/Statements.ag"(line 97, column 12)
+              _hdOinProducedCat =
+                  _tlIproducedCat
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              ( _hdIannotatedTree,_hdIcatUpdates,_hdIfixedUpIdentifiersTree,_hdIlibUpdates,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOinProducedCat _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIproducedCat,_tlIproducedLib) =
+                  tl_ _tlOcat _tlOcatUpdates _tlOidenv _tlOlib _tlOlibUpdates 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
+sem_StatementList_Nil :: T_StatementList 
+sem_StatementList_Nil  =
+    (\ _lhsIcat
+       _lhsIcatUpdates
+       _lhsIidenv
+       _lhsIlib
+       _lhsIlibUpdates ->
+         (let _lhsOproducedCat :: Catalog
+              _lhsOproducedLib :: LocalBindings
+              _lhsOannotatedTree :: StatementList 
+              _lhsOfixedUpIdentifiersTree :: StatementList 
+              _lhsOoriginalTree :: StatementList 
+              -- "./TypeChecking/Statements.ag"(line 56, column 9)
+              _newCat =
+                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
+              -- "./TypeChecking/Statements.ag"(line 57, column 9)
+              _newLib =
+                  fromRight _lhsIlib $ foldM (flip $ lbUpdate _lhsIcat) _lhsIlib _lhsIlibUpdates
+              -- "./TypeChecking/Statements.ag"(line 73, column 9)
+              _lhsOproducedCat =
+                  _newCat
+              -- "./TypeChecking/Statements.ag"(line 74, column 9)
+              _lhsOproducedLib =
+                  _newLib
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat,_lhsOproducedLib)))
+-- StringTypeNameListPair --------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         fnSig                : (String,[Maybe Type])
+         originalTree         : SELF 
+   alternatives:
+      alternative Tuple:
+         child x1             : {String}
+         child x2             : TypeNameList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type StringTypeNameListPair  = ( (String),TypeNameList )
+-- cata
+sem_StringTypeNameListPair :: StringTypeNameListPair  ->
+                              T_StringTypeNameListPair 
+sem_StringTypeNameListPair ( x1,x2)  =
+    (sem_StringTypeNameListPair_Tuple x1 (sem_TypeNameList x2 ) )
+-- semantic domain
+type T_StringTypeNameListPair  = Catalog ->
+                                 IDEnv ->
+                                 LocalBindings ->
+                                 ( StringTypeNameListPair ,StringTypeNameListPair ,((String,[Maybe Type])),StringTypeNameListPair )
+data Inh_StringTypeNameListPair  = Inh_StringTypeNameListPair {cat_Inh_StringTypeNameListPair :: Catalog,idenv_Inh_StringTypeNameListPair :: IDEnv,lib_Inh_StringTypeNameListPair :: LocalBindings}
+data Syn_StringTypeNameListPair  = Syn_StringTypeNameListPair {annotatedTree_Syn_StringTypeNameListPair :: StringTypeNameListPair ,fixedUpIdentifiersTree_Syn_StringTypeNameListPair :: StringTypeNameListPair ,fnSig_Syn_StringTypeNameListPair :: ((String,[Maybe Type])),originalTree_Syn_StringTypeNameListPair :: StringTypeNameListPair }
+wrap_StringTypeNameListPair :: T_StringTypeNameListPair  ->
+                               Inh_StringTypeNameListPair  ->
+                               Syn_StringTypeNameListPair 
+wrap_StringTypeNameListPair sem (Inh_StringTypeNameListPair _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOfnSig,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_StringTypeNameListPair _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOfnSig _lhsOoriginalTree ))
+sem_StringTypeNameListPair_Tuple :: String ->
+                                    T_TypeNameList  ->
+                                    T_StringTypeNameListPair 
+sem_StringTypeNameListPair_Tuple x1_ x2_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfnSig :: ((String,[Maybe Type]))
+              _lhsOannotatedTree :: StringTypeNameListPair 
+              _lhsOfixedUpIdentifiersTree :: StringTypeNameListPair 
+              _lhsOoriginalTree :: StringTypeNameListPair 
+              _x2Ocat :: Catalog
+              _x2Oidenv :: IDEnv
+              _x2Olib :: LocalBindings
+              _x2IannotatedTree :: TypeNameList 
+              _x2IfixedUpIdentifiersTree :: TypeNameList 
+              _x2InamedTypes :: ([Maybe Type])
+              _x2IoriginalTree :: TypeNameList 
+              -- "./TypeChecking/Ddl/Drops.ag"(line 32, column 13)
+              _lhsOfnSig =
+                  (x1_, _x2InamedTypes)
+              -- self rule
+              _annotatedTree =
+                  (x1_,_x2IannotatedTree)
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (x1_,_x2IfixedUpIdentifiersTree)
+              -- self rule
+              _originalTree =
+                  (x1_,_x2IoriginalTree)
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _x2Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _x2Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _x2Olib =
+                  _lhsIlib
+              ( _x2IannotatedTree,_x2IfixedUpIdentifiersTree,_x2InamedTypes,_x2IoriginalTree) =
+                  x2_ _x2Ocat _x2Oidenv _x2Olib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOfnSig,_lhsOoriginalTree)))
+-- StringTypeNameListPairList ----------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         fnSigs               : [(String,[Maybe Type])]
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : StringTypeNameListPair 
+         child tl             : StringTypeNameListPairList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type StringTypeNameListPairList  = [StringTypeNameListPair ]
+-- cata
+sem_StringTypeNameListPairList :: StringTypeNameListPairList  ->
+                                  T_StringTypeNameListPairList 
+sem_StringTypeNameListPairList list  =
+    (Prelude.foldr sem_StringTypeNameListPairList_Cons sem_StringTypeNameListPairList_Nil (Prelude.map sem_StringTypeNameListPair list) )
+-- semantic domain
+type T_StringTypeNameListPairList  = Catalog ->
+                                     IDEnv ->
+                                     LocalBindings ->
+                                     ( StringTypeNameListPairList ,StringTypeNameListPairList ,([(String,[Maybe Type])]),StringTypeNameListPairList )
+data Inh_StringTypeNameListPairList  = Inh_StringTypeNameListPairList {cat_Inh_StringTypeNameListPairList :: Catalog,idenv_Inh_StringTypeNameListPairList :: IDEnv,lib_Inh_StringTypeNameListPairList :: LocalBindings}
+data Syn_StringTypeNameListPairList  = Syn_StringTypeNameListPairList {annotatedTree_Syn_StringTypeNameListPairList :: StringTypeNameListPairList ,fixedUpIdentifiersTree_Syn_StringTypeNameListPairList :: StringTypeNameListPairList ,fnSigs_Syn_StringTypeNameListPairList :: ([(String,[Maybe Type])]),originalTree_Syn_StringTypeNameListPairList :: StringTypeNameListPairList }
+wrap_StringTypeNameListPairList :: T_StringTypeNameListPairList  ->
+                                   Inh_StringTypeNameListPairList  ->
+                                   Syn_StringTypeNameListPairList 
+wrap_StringTypeNameListPairList sem (Inh_StringTypeNameListPairList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOfnSigs,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_StringTypeNameListPairList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOfnSigs _lhsOoriginalTree ))
+sem_StringTypeNameListPairList_Cons :: T_StringTypeNameListPair  ->
+                                       T_StringTypeNameListPairList  ->
+                                       T_StringTypeNameListPairList 
+sem_StringTypeNameListPairList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfnSigs :: ([(String,[Maybe Type])])
+              _lhsOannotatedTree :: StringTypeNameListPairList 
+              _lhsOfixedUpIdentifiersTree :: StringTypeNameListPairList 
+              _lhsOoriginalTree :: StringTypeNameListPairList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: StringTypeNameListPair 
+              _hdIfixedUpIdentifiersTree :: StringTypeNameListPair 
+              _hdIfnSig :: ((String,[Maybe Type]))
+              _hdIoriginalTree :: StringTypeNameListPair 
+              _tlIannotatedTree :: StringTypeNameListPairList 
+              _tlIfixedUpIdentifiersTree :: StringTypeNameListPairList 
+              _tlIfnSigs :: ([(String,[Maybe Type])])
+              _tlIoriginalTree :: StringTypeNameListPairList 
+              -- "./TypeChecking/Ddl/Drops.ag"(line 27, column 12)
+              _lhsOfnSigs =
+                  _hdIfnSig : _tlIfnSigs
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIfnSig,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIfnSigs,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOfnSigs,_lhsOoriginalTree)))
+sem_StringTypeNameListPairList_Nil :: T_StringTypeNameListPairList 
+sem_StringTypeNameListPairList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfnSigs :: ([(String,[Maybe Type])])
+              _lhsOannotatedTree :: StringTypeNameListPairList 
+              _lhsOfixedUpIdentifiersTree :: StringTypeNameListPairList 
+              _lhsOoriginalTree :: StringTypeNameListPairList 
+              -- "./TypeChecking/Ddl/Drops.ag"(line 28, column 11)
+              _lhsOfnSigs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOfnSigs,_lhsOoriginalTree)))
+-- TableAlias --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         expectedNumCols      : Maybe Int
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative FullAlias:
+         child ann            : {Annotation}
+         child tb             : {String}
+         child cols           : {[String]}
+         visit 0:
+            local errs        : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative NoAlias:
+         child ann            : {Annotation}
+         visit 0:
+            local backTree    : _
+            local errs        : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative TableAlias:
+         child ann            : {Annotation}
+         child tb             : {String}
+         visit 0:
+            local backTree    : _
+            local errs        : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data TableAlias  = FullAlias (Annotation) (String) (([String])) 
+                 | NoAlias (Annotation) 
+                 | TableAlias (Annotation) (String) 
+                 deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_TableAlias :: TableAlias  ->
+                  T_TableAlias 
+sem_TableAlias (FullAlias _ann _tb _cols )  =
+    (sem_TableAlias_FullAlias _ann _tb _cols )
+sem_TableAlias (NoAlias _ann )  =
+    (sem_TableAlias_NoAlias _ann )
+sem_TableAlias (TableAlias _ann _tb )  =
+    (sem_TableAlias_TableAlias _ann _tb )
+-- semantic domain
+type T_TableAlias  = Catalog ->
+                     (Maybe Int) ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( TableAlias ,TableAlias ,TableAlias )
+data Inh_TableAlias  = Inh_TableAlias {cat_Inh_TableAlias :: Catalog,expectedNumCols_Inh_TableAlias :: (Maybe Int),idenv_Inh_TableAlias :: IDEnv,lib_Inh_TableAlias :: LocalBindings}
+data Syn_TableAlias  = Syn_TableAlias {annotatedTree_Syn_TableAlias :: TableAlias ,fixedUpIdentifiersTree_Syn_TableAlias :: TableAlias ,originalTree_Syn_TableAlias :: TableAlias }
+wrap_TableAlias :: T_TableAlias  ->
+                   Inh_TableAlias  ->
+                   Syn_TableAlias 
+wrap_TableAlias sem (Inh_TableAlias _lhsIcat _lhsIexpectedNumCols _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIexpectedNumCols _lhsIidenv _lhsIlib 
+     in  (Syn_TableAlias _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_TableAlias_FullAlias :: Annotation ->
+                            String ->
+                            ([String]) ->
+                            T_TableAlias 
+sem_TableAlias_FullAlias ann_ tb_ cols_  =
+    (\ _lhsIcat
+       _lhsIexpectedNumCols
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: TableAlias 
+              _lhsOfixedUpIdentifiersTree :: TableAlias 
+              _lhsOoriginalTree :: TableAlias 
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 286, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 288, column 9)
+              _errs =
+                  case _lhsIexpectedNumCols of
+                        Nothing -> []
+                        Just n -> if n == length cols_
+                                  then []
+                                  else [WrongNumberOfAliasCols n $ length cols_]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 293, column 9)
+              _backTree =
+                  FullAlias ann_ tb_ cols_
+              -- self rule
+              _annotatedTree =
+                  FullAlias ann_ tb_ cols_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  FullAlias ann_ tb_ cols_
+              -- self rule
+              _originalTree =
+                  FullAlias ann_ tb_ cols_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_TableAlias_NoAlias :: Annotation ->
+                          T_TableAlias 
+sem_TableAlias_NoAlias ann_  =
+    (\ _lhsIcat
+       _lhsIexpectedNumCols
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: TableAlias 
+              _lhsOfixedUpIdentifiersTree :: TableAlias 
+              _lhsOoriginalTree :: TableAlias 
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 286, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 296, column 15)
+              _backTree =
+                  NoAlias ann_
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 297, column 15)
+              _errs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  NoAlias ann_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  NoAlias ann_
+              -- self rule
+              _originalTree =
+                  NoAlias ann_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_TableAlias_TableAlias :: Annotation ->
+                             String ->
+                             T_TableAlias 
+sem_TableAlias_TableAlias ann_ tb_  =
+    (\ _lhsIcat
+       _lhsIexpectedNumCols
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOannotatedTree :: TableAlias 
+              _lhsOfixedUpIdentifiersTree :: TableAlias 
+              _lhsOoriginalTree :: TableAlias 
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 286, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 294, column 18)
+              _backTree =
+                  TableAlias ann_ tb_
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 295, column 18)
+              _errs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  TableAlias ann_ tb_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  TableAlias ann_ tb_
+              -- self rule
+              _originalTree =
+                  TableAlias ann_ tb_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- TableRef ----------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         libUpdates           : [LocalBindingsUpdate]
+         newLib2              : LocalBindings
+         originalTree         : SELF 
+         trefIDs              : [(String,[String])]
+   alternatives:
+      alternative FunTref:
+         child ann            : {Annotation}
+         child fn             : ScalarExpr 
+         child alias          : TableAlias 
+         visit 0:
+            local _tup2       : {([(String,[String])],TableRef)}
+            local errs        : _
+            local eqfunIdens  : {Either [TypeError] (String,[(String,Type)])}
+            local qfunIdens   : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative JoinTref:
+         child ann            : {Annotation}
+         child tbl            : TableRef 
+         child nat            : {Natural}
+         child joinType       : {JoinType}
+         child tbl1           : TableRef 
+         child onExpr         : OnExpr 
+         child alias          : TableAlias 
+         visit 0:
+            local _tup3       : _
+            local trefIDs     : _
+            local errs        : _
+            local joinErrors  : _
+            local libUpdates  : _
+            local newLib      : {Either [TypeError] LocalBindings}
+            local newLib2     : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative SubTref:
+         child ann            : {Annotation}
+         child sel            : QueryExpr 
+         child alias          : TableAlias 
+         visit 0:
+            local _tup4       : {([(String,[String])],TableRef)}
+            local errs        : _
+            local selectAttrs : {Either [TypeError] [(String,Type)]}
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Tref:
+         child ann            : {Annotation}
+         child tbl            : SQIdentifier 
+         child alias          : TableAlias 
+         visit 0:
+            local _tup5       : {([(String,[String])],TableRef)}
+            local errs        : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data TableRef  = FunTref (Annotation) (ScalarExpr ) (TableAlias ) 
+               | JoinTref (Annotation) (TableRef ) (Natural) (JoinType) (TableRef ) (OnExpr ) (TableAlias ) 
+               | SubTref (Annotation) (QueryExpr ) (TableAlias ) 
+               | Tref (Annotation) (SQIdentifier ) (TableAlias ) 
+               deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_TableRef :: TableRef  ->
+                T_TableRef 
+sem_TableRef (FunTref _ann _fn _alias )  =
+    (sem_TableRef_FunTref _ann (sem_ScalarExpr _fn ) (sem_TableAlias _alias ) )
+sem_TableRef (JoinTref _ann _tbl _nat _joinType _tbl1 _onExpr _alias )  =
+    (sem_TableRef_JoinTref _ann (sem_TableRef _tbl ) _nat _joinType (sem_TableRef _tbl1 ) (sem_OnExpr _onExpr ) (sem_TableAlias _alias ) )
+sem_TableRef (SubTref _ann _sel _alias )  =
+    (sem_TableRef_SubTref _ann (sem_QueryExpr _sel ) (sem_TableAlias _alias ) )
+sem_TableRef (Tref _ann _tbl _alias )  =
+    (sem_TableRef_Tref _ann (sem_SQIdentifier _tbl ) (sem_TableAlias _alias ) )
+-- semantic domain
+type T_TableRef  = Catalog ->
+                   IDEnv ->
+                   LocalBindings ->
+                   ( TableRef ,TableRef ,([LocalBindingsUpdate]),LocalBindings,TableRef ,([(String,[String])]))
+data Inh_TableRef  = Inh_TableRef {cat_Inh_TableRef :: Catalog,idenv_Inh_TableRef :: IDEnv,lib_Inh_TableRef :: LocalBindings}
+data Syn_TableRef  = Syn_TableRef {annotatedTree_Syn_TableRef :: TableRef ,fixedUpIdentifiersTree_Syn_TableRef :: TableRef ,libUpdates_Syn_TableRef :: ([LocalBindingsUpdate]),newLib2_Syn_TableRef :: LocalBindings,originalTree_Syn_TableRef :: TableRef ,trefIDs_Syn_TableRef :: ([(String,[String])])}
+wrap_TableRef :: T_TableRef  ->
+                 Inh_TableRef  ->
+                 Syn_TableRef 
+wrap_TableRef sem (Inh_TableRef _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TableRef _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOlibUpdates _lhsOnewLib2 _lhsOoriginalTree _lhsOtrefIDs ))
+sem_TableRef_FunTref :: Annotation ->
+                        T_ScalarExpr  ->
+                        T_TableAlias  ->
+                        T_TableRef 
+sem_TableRef_FunTref ann_ fn_ alias_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let __tup2 :: (([(String,[String])],TableRef))
+              _lhsOtrefIDs :: ([(String,[String])])
+              _lhsOfixedUpIdentifiersTree :: TableRef 
+              _lhsOannotatedTree :: TableRef 
+              _eqfunIdens :: (Either [TypeError] (String,[(String,Type)]))
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOnewLib2 :: LocalBindings
+              _aliasOexpectedNumCols :: (Maybe Int)
+              _fnOexpectedType :: (Maybe Type)
+              _lhsOoriginalTree :: TableRef 
+              _fnOcat :: Catalog
+              _fnOidenv :: IDEnv
+              _fnOlib :: LocalBindings
+              _aliasOcat :: Catalog
+              _aliasOidenv :: IDEnv
+              _aliasOlib :: LocalBindings
+              _fnIannotatedTree :: ScalarExpr 
+              _fnIfixedUpIdentifiersTree :: ScalarExpr 
+              _fnIoriginalTree :: ScalarExpr 
+              _fnIuType :: (Maybe Type)
+              _aliasIannotatedTree :: TableAlias 
+              _aliasIfixedUpIdentifiersTree :: TableAlias 
+              _aliasIoriginalTree :: TableAlias 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 382, column 15)
+              __tup2 =
+                  let (FunCall _ f _) = _fnIfixedUpIdentifiersTree
+                      (trs,al) = doAlias _aliasIannotatedTree [(f,[f])]
+                  in (trs,FunTref ann_ _fnIfixedUpIdentifiersTree al)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 382, column 15)
+              (_lhsOtrefIDs,_) =
+                  __tup2
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 382, column 15)
+              (_,_lhsOfixedUpIdentifiersTree) =
+                  __tup2
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 55, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 102, column 9)
+              _errs =
+                  case _eqfunIdens of
+                    Left e -> e
+                    Right _ -> []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 108, column 9)
+              _eqfunIdens =
+                  funIdens _lhsIcat (getAlias "" _aliasIoriginalTree) _fnIannotatedTree _fnIuType
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 109, column 9)
+              _lhsOlibUpdates =
+                  [LBTref "fn"
+                                  (fst _qfunIdens    )
+                                  (snd _qfunIdens    )
+                                  []]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 113, column 9)
+              _qfunIdens =
+                  fromRight ("",[]) _eqfunIdens
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 247, column 9)
+              _lhsOnewLib2 =
+                  emptyBindings
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 260, column 9)
+              _backTree =
+                  FunTref ann_ _fnIannotatedTree _aliasIannotatedTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 281, column 9)
+              _aliasOexpectedNumCols =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 120, column 15)
+              _fnOexpectedType =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  FunTref ann_ _fnIannotatedTree _aliasIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  FunTref ann_ _fnIfixedUpIdentifiersTree _aliasIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  FunTref ann_ _fnIoriginalTree _aliasIoriginalTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _fnOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _fnOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _fnOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _aliasOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _aliasOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _aliasOlib =
+                  _lhsIlib
+              ( _fnIannotatedTree,_fnIfixedUpIdentifiersTree,_fnIoriginalTree,_fnIuType) =
+                  fn_ _fnOcat _fnOexpectedType _fnOidenv _fnOlib 
+              ( _aliasIannotatedTree,_aliasIfixedUpIdentifiersTree,_aliasIoriginalTree) =
+                  alias_ _aliasOcat _aliasOexpectedNumCols _aliasOidenv _aliasOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+sem_TableRef_JoinTref :: Annotation ->
+                         T_TableRef  ->
+                         Natural ->
+                         JoinType ->
+                         T_TableRef  ->
+                         T_OnExpr  ->
+                         T_TableAlias  ->
+                         T_TableRef 
+sem_TableRef_JoinTref ann_ tbl_ nat_ joinType_ tbl1_ onExpr_ alias_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOfixedUpIdentifiersTree :: TableRef 
+              _lhsOtrefIDs :: ([(String,[String])])
+              _onExprOidenv :: IDEnv
+              _lhsOannotatedTree :: TableRef 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _newLib :: (Either [TypeError] LocalBindings)
+              _lhsOnewLib2 :: LocalBindings
+              _onExprOlib :: LocalBindings
+              _aliasOexpectedNumCols :: (Maybe Int)
+              _lhsOoriginalTree :: TableRef 
+              _tblOcat :: Catalog
+              _tblOidenv :: IDEnv
+              _tblOlib :: LocalBindings
+              _tbl1Ocat :: Catalog
+              _tbl1Oidenv :: IDEnv
+              _tbl1Olib :: LocalBindings
+              _onExprOcat :: Catalog
+              _aliasOcat :: Catalog
+              _aliasOidenv :: IDEnv
+              _aliasOlib :: LocalBindings
+              _tblIannotatedTree :: TableRef 
+              _tblIfixedUpIdentifiersTree :: TableRef 
+              _tblIlibUpdates :: ([LocalBindingsUpdate])
+              _tblInewLib2 :: LocalBindings
+              _tblIoriginalTree :: TableRef 
+              _tblItrefIDs :: ([(String,[String])])
+              _tbl1IannotatedTree :: TableRef 
+              _tbl1IfixedUpIdentifiersTree :: TableRef 
+              _tbl1IlibUpdates :: ([LocalBindingsUpdate])
+              _tbl1InewLib2 :: LocalBindings
+              _tbl1IoriginalTree :: TableRef 
+              _tbl1ItrefIDs :: ([(String,[String])])
+              _onExprIannotatedTree :: OnExpr 
+              _onExprIfixedUpIdentifiersTree :: OnExpr 
+              _onExprIoriginalTree :: OnExpr 
+              _aliasIannotatedTree :: TableAlias 
+              _aliasIfixedUpIdentifiersTree :: TableAlias 
+              _aliasIoriginalTree :: TableAlias 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 388, column 9)
+              __tup3 =
+                  let (trs,al) = doAlias _aliasIannotatedTree $ _tblItrefIDs ++ _tbl1ItrefIDs
+                  in (trs, JoinTref ann_ _tblIfixedUpIdentifiersTree
+                                    nat_ joinType_ _tbl1IfixedUpIdentifiersTree
+                                    _onExprIfixedUpIdentifiersTree al)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 388, column 9)
+              (_trefIDs,_) =
+                  __tup3
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 388, column 9)
+              (_,_lhsOfixedUpIdentifiersTree) =
+                  __tup3
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 394, column 9)
+              _lhsOtrefIDs =
+                  _trefIDs
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 395, column 9)
+              _onExprOidenv =
+                  IDEnv _trefIDs
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 55, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 118, column 9)
+              _errs =
+                  fromLeft [] _newLib
+                  ++ _joinErrors
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 120, column 9)
+              _lhsOlibUpdates =
+                  if _joinErrors     == []
+                  then _libUpdates
+                  else []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 125, column 9)
+              _joinErrors =
+                  fromLeft [] (foldM (flip $ lbUpdate _lhsIcat) _lhsIlib _libUpdates    )
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 126, column 9)
+              _libUpdates =
+                  case (_tblIlibUpdates, _tbl1IlibUpdates) of
+                    ([u1], [u2]) -> [LBJoinTref "join" u1 u2 jids
+                                                    (case _aliasIoriginalTree of
+                                                             NoAlias _ -> Nothing
+                                                             TableAlias _ t -> Just t
+                                                             FullAlias _ t _ -> Just t)]
+                    _ -> []
+                  where
+                    jids = case (nat_, _onExprIoriginalTree) of
+                                (Natural, _) -> Left ()
+                                (_,Just (JoinUsing _ s)) -> Right s
+                                _ -> Right []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 140, column 9)
+              _newLib =
+                  case (_tblIlibUpdates, _tbl1IlibUpdates) of
+                    ([u1],[u2]) -> lbUpdate _lhsIcat
+                                     (LBJoinTref "join" u1 u2 (Right []) Nothing) _lhsIlib
+                    _ -> Right _lhsIlib
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 220, column 9)
+              _newLib2 =
+                  let t0t :: [(String,Maybe Type)]
+                      t0t = getUnqualifiedBindings _tblInewLib2
+                      t1t = getUnqualifiedBindings _tbl1InewLib2
+                  in case _aliasIoriginalTree of
+                    (FullAlias _ n cs) ->
+                        createLocalBindings $ Just [(n,zip cs $ map snd (t0t ++ t1t))]
+                    (TableAlias _ n) ->
+                        createLocalBindings $ Just [(n, t0t ++ t1t)]
+                    NoAlias _ ->
+                        joinBindings _tblInewLib2 _tbl1InewLib2
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 233, column 9)
+              _lhsOnewLib2 =
+                  _newLib2
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 234, column 9)
+              _onExprOlib =
+                  _newLib2
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 262, column 9)
+              _backTree =
+                  JoinTref ann_
+                             _tblIannotatedTree
+                             nat_
+                             joinType_
+                             _tbl1IannotatedTree
+                             _onExprIannotatedTree
+                             _aliasIannotatedTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 281, column 9)
+              _aliasOexpectedNumCols =
+                  Nothing
+              -- self rule
+              _annotatedTree =
+                  JoinTref ann_ _tblIannotatedTree nat_ joinType_ _tbl1IannotatedTree _onExprIannotatedTree _aliasIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  JoinTref ann_ _tblIfixedUpIdentifiersTree nat_ joinType_ _tbl1IfixedUpIdentifiersTree _onExprIfixedUpIdentifiersTree _aliasIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  JoinTref ann_ _tblIoriginalTree nat_ joinType_ _tbl1IoriginalTree _onExprIoriginalTree _aliasIoriginalTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tblOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tblOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tblOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tbl1Ocat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tbl1Oidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tbl1Olib =
+                  _lhsIlib
+              -- copy rule (down)
+              _onExprOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _aliasOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _aliasOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _aliasOlib =
+                  _lhsIlib
+              ( _tblIannotatedTree,_tblIfixedUpIdentifiersTree,_tblIlibUpdates,_tblInewLib2,_tblIoriginalTree,_tblItrefIDs) =
+                  tbl_ _tblOcat _tblOidenv _tblOlib 
+              ( _tbl1IannotatedTree,_tbl1IfixedUpIdentifiersTree,_tbl1IlibUpdates,_tbl1InewLib2,_tbl1IoriginalTree,_tbl1ItrefIDs) =
+                  tbl1_ _tbl1Ocat _tbl1Oidenv _tbl1Olib 
+              ( _onExprIannotatedTree,_onExprIfixedUpIdentifiersTree,_onExprIoriginalTree) =
+                  onExpr_ _onExprOcat _onExprOidenv _onExprOlib 
+              ( _aliasIannotatedTree,_aliasIfixedUpIdentifiersTree,_aliasIoriginalTree) =
+                  alias_ _aliasOcat _aliasOexpectedNumCols _aliasOidenv _aliasOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+sem_TableRef_SubTref :: Annotation ->
+                        T_QueryExpr  ->
+                        T_TableAlias  ->
+                        T_TableRef 
+sem_TableRef_SubTref ann_ sel_ alias_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let __tup4 :: (([(String,[String])],TableRef))
+              _lhsOtrefIDs :: ([(String,[String])])
+              _lhsOfixedUpIdentifiersTree :: TableRef 
+              _selOcsql :: LocalBindings
+              _lhsOannotatedTree :: TableRef 
+              _selectAttrs :: (Either [TypeError] [(String,Type)])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOnewLib2 :: LocalBindings
+              _aliasOexpectedNumCols :: (Maybe Int)
+              _selOexpectedTypes :: ([Maybe Type])
+              _lhsOoriginalTree :: TableRef 
+              _selOcat :: Catalog
+              _selOidenv :: IDEnv
+              _selOlib :: LocalBindings
+              _aliasOcat :: Catalog
+              _aliasOidenv :: IDEnv
+              _aliasOlib :: LocalBindings
+              _selIannotatedTree :: QueryExpr 
+              _selIcidenv :: IDEnv
+              _selIfixedUpIdentifiersTree :: QueryExpr 
+              _selIlibUpdates :: ([LocalBindingsUpdate])
+              _selIoriginalTree :: QueryExpr 
+              _selIuType :: (Maybe [(String,Type)])
+              _aliasIannotatedTree :: TableAlias 
+              _aliasIfixedUpIdentifiersTree :: TableAlias 
+              _aliasIoriginalTree :: TableAlias 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 377, column 15)
+              __tup4 =
+                  let IDEnv x = _selIcidenv
+                      (trs,al) = doAlias _aliasIannotatedTree x
+                  in (trs, SubTref ann_ _selIfixedUpIdentifiersTree al)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 377, column 15)
+              (_lhsOtrefIDs,_) =
+                  __tup4
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 377, column 15)
+              (_,_lhsOfixedUpIdentifiersTree) =
+                  __tup4
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 129, column 15)
+              _selOcsql =
+                  emptyBindings
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 55, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 72, column 9)
+              _errs =
+                  case _selectAttrs     of
+                          Left e -> e
+                          Right _ -> []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 76, column 9)
+              _selectAttrs =
+                  lmt _selIuType
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 77, column 9)
+              _lhsOlibUpdates =
+                  [LBTref "sub query" (getAlias "" _aliasIoriginalTree)
+                                  (fromRight [] _selectAttrs    ) []]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 237, column 9)
+              _lhsOnewLib2 =
+                  createLocalBindings $ do
+                  pu <- _selIuType
+                  let (n,cs) = case _aliasIoriginalTree of
+                                 (FullAlias _ n cs) -> (n,cs)
+                                 _ -> (n, [])
+                  return [(n,zip cs $ map (Just . snd) pu)]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 256, column 9)
+              _backTree =
+                  SubTref ann_ _selIannotatedTree _aliasIannotatedTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 281, column 9)
+              _aliasOexpectedNumCols =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 180, column 15)
+              _selOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  SubTref ann_ _selIannotatedTree _aliasIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SubTref ann_ _selIfixedUpIdentifiersTree _aliasIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  SubTref ann_ _selIoriginalTree _aliasIoriginalTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _selOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _selOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _selOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _aliasOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _aliasOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _aliasOlib =
+                  _lhsIlib
+              ( _selIannotatedTree,_selIcidenv,_selIfixedUpIdentifiersTree,_selIlibUpdates,_selIoriginalTree,_selIuType) =
+                  sel_ _selOcat _selOcsql _selOexpectedTypes _selOidenv _selOlib 
+              ( _aliasIannotatedTree,_aliasIfixedUpIdentifiersTree,_aliasIoriginalTree) =
+                  alias_ _aliasOcat _aliasOexpectedNumCols _aliasOidenv _aliasOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+sem_TableRef_Tref :: Annotation ->
+                     T_SQIdentifier  ->
+                     T_TableAlias  ->
+                     T_TableRef 
+sem_TableRef_Tref ann_ tbl_ alias_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let __tup5 :: (([(String,[String])],TableRef))
+              _lhsOtrefIDs :: ([(String,[String])])
+              _lhsOfixedUpIdentifiersTree :: TableRef 
+              _lhsOannotatedTree :: TableRef 
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOnewLib2 :: LocalBindings
+              _aliasOexpectedNumCols :: (Maybe Int)
+              _lhsOoriginalTree :: TableRef 
+              _tblOcat :: Catalog
+              _tblOidenv :: IDEnv
+              _tblOlib :: LocalBindings
+              _aliasOcat :: Catalog
+              _aliasOidenv :: IDEnv
+              _aliasOlib :: LocalBindings
+              _tblIannotatedTree :: SQIdentifier 
+              _tblIfixedUpIdentifiersTree :: SQIdentifier 
+              _tblIoriginalTree :: SQIdentifier 
+              _tblItbAnnotatedTree :: SQIdentifier 
+              _tblItbUType :: (Maybe ([(String,Type)],[(String,Type)]))
+              _aliasIannotatedTree :: TableAlias 
+              _aliasIfixedUpIdentifiersTree :: TableAlias 
+              _aliasIoriginalTree :: TableAlias 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 369, column 12)
+              __tup5 =
+                  let tn = getTName _tblIfixedUpIdentifiersTree
+                      ids = case catCompositePublicAttrs _lhsIcat relationComposites tn of
+                               Right attrs -> [(tn, map fst attrs)]
+                               Left _ -> [(tn,[])]
+                      (trs,al) = doAlias _aliasIannotatedTree ids
+                  in (trs,Tref ann_ _tblIfixedUpIdentifiersTree al)
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 369, column 12)
+              (_lhsOtrefIDs,_) =
+                  __tup5
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 369, column 12)
+              (_,_lhsOfixedUpIdentifiersTree) =
+                  __tup5
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 55, column 9)
+              _lhsOannotatedTree =
+                  addTypeErrors _errs     _backTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 85, column 9)
+              _errs =
+                  []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 86, column 9)
+              _lhsOlibUpdates =
+                  maybe [] id $ do
+                  let n = getTName _tblIannotatedTree
+                  (pu,pr) <- _tblItbUType
+                  return [LBTref ("tref: " ++ n)
+                            (getAlias n _aliasIoriginalTree)
+                            pu
+                            pr]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 208, column 9)
+              _lhsOnewLib2 =
+                  createLocalBindings $ do
+                  let n = getTName _tblIannotatedTree
+                  (pu,pr) <- _tblItbUType
+                  let (n,cs) = case _aliasIoriginalTree of
+                                 (FullAlias _ n cs) -> (n,cs)
+                                 _ -> (n, [])
+                  return [(n,zip cs $ map (Just . snd) pu)
+                         ,(n,map (second Just) pr)]
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 258, column 9)
+              _backTree =
+                  Tref ann_ _tblItbAnnotatedTree _aliasIannotatedTree
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 275, column 9)
+              _aliasOexpectedNumCols =
+                  do
+                  let n = getTName _tblIannotatedTree
+                  (pu,_) <- _tblItbUType
+                  return $ length pu
+              -- self rule
+              _annotatedTree =
+                  Tref ann_ _tblIannotatedTree _aliasIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Tref ann_ _tblIfixedUpIdentifiersTree _aliasIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  Tref ann_ _tblIoriginalTree _aliasIoriginalTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _tblOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tblOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tblOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _aliasOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _aliasOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _aliasOlib =
+                  _lhsIlib
+              ( _tblIannotatedTree,_tblIfixedUpIdentifiersTree,_tblIoriginalTree,_tblItbAnnotatedTree,_tblItbUType) =
+                  tbl_ _tblOcat _tblOidenv _tblOlib 
+              ( _aliasIannotatedTree,_aliasIfixedUpIdentifiersTree,_aliasIoriginalTree) =
+                  alias_ _aliasOcat _aliasOexpectedNumCols _aliasOidenv _aliasOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+-- TableRefList ------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         libUpdates           : [LocalBindingsUpdate]
+         newLib2              : LocalBindings
+         originalTree         : SELF 
+         trefIDs              : [(String,[String])]
+   alternatives:
+      alternative Cons:
+         child hd             : TableRef 
+         child tl             : TableRefList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type TableRefList  = [TableRef ]
+-- cata
+sem_TableRefList :: TableRefList  ->
+                    T_TableRefList 
+sem_TableRefList list  =
+    (Prelude.foldr sem_TableRefList_Cons sem_TableRefList_Nil (Prelude.map sem_TableRef list) )
+-- semantic domain
+type T_TableRefList  = Catalog ->
+                       IDEnv ->
+                       LocalBindings ->
+                       ( TableRefList ,TableRefList ,([LocalBindingsUpdate]),LocalBindings,TableRefList ,([(String,[String])]))
+data Inh_TableRefList  = Inh_TableRefList {cat_Inh_TableRefList :: Catalog,idenv_Inh_TableRefList :: IDEnv,lib_Inh_TableRefList :: LocalBindings}
+data Syn_TableRefList  = Syn_TableRefList {annotatedTree_Syn_TableRefList :: TableRefList ,fixedUpIdentifiersTree_Syn_TableRefList :: TableRefList ,libUpdates_Syn_TableRefList :: ([LocalBindingsUpdate]),newLib2_Syn_TableRefList :: LocalBindings,originalTree_Syn_TableRefList :: TableRefList ,trefIDs_Syn_TableRefList :: ([(String,[String])])}
+wrap_TableRefList :: T_TableRefList  ->
+                     Inh_TableRefList  ->
+                     Syn_TableRefList 
+wrap_TableRefList sem (Inh_TableRefList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TableRefList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOlibUpdates _lhsOnewLib2 _lhsOoriginalTree _lhsOtrefIDs ))
+sem_TableRefList_Cons :: T_TableRef  ->
+                         T_TableRefList  ->
+                         T_TableRefList 
+sem_TableRefList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOtrefIDs :: ([(String,[String])])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOnewLib2 :: LocalBindings
+              _lhsOannotatedTree :: TableRefList 
+              _lhsOfixedUpIdentifiersTree :: TableRefList 
+              _lhsOoriginalTree :: TableRefList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: TableRef 
+              _hdIfixedUpIdentifiersTree :: TableRef 
+              _hdIlibUpdates :: ([LocalBindingsUpdate])
+              _hdInewLib2 :: LocalBindings
+              _hdIoriginalTree :: TableRef 
+              _hdItrefIDs :: ([(String,[String])])
+              _tlIannotatedTree :: TableRefList 
+              _tlIfixedUpIdentifiersTree :: TableRefList 
+              _tlIlibUpdates :: ([LocalBindingsUpdate])
+              _tlInewLib2 :: LocalBindings
+              _tlIoriginalTree :: TableRefList 
+              _tlItrefIDs :: ([(String,[String])])
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 365, column 12)
+              _lhsOtrefIDs =
+                  _hdItrefIDs ++ _tlItrefIDs
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 61, column 9)
+              _lhsOlibUpdates =
+                  _hdIlibUpdates
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 204, column 9)
+              _lhsOnewLib2 =
+                  joinBindings _hdInewLib2 _tlInewLib2
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdIlibUpdates,_hdInewLib2,_hdIoriginalTree,_hdItrefIDs) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIlibUpdates,_tlInewLib2,_tlIoriginalTree,_tlItrefIDs) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+sem_TableRefList_Nil :: T_TableRefList 
+sem_TableRefList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOtrefIDs :: ([(String,[String])])
+              _lhsOlibUpdates :: ([LocalBindingsUpdate])
+              _lhsOnewLib2 :: LocalBindings
+              _lhsOannotatedTree :: TableRefList 
+              _lhsOfixedUpIdentifiersTree :: TableRefList 
+              _lhsOoriginalTree :: TableRefList 
+              -- "./TypeChecking/FixUpIdentifiers.ag"(line 366, column 11)
+              _lhsOtrefIDs =
+                  []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 59, column 9)
+              _lhsOlibUpdates =
+                  []
+              -- "./TypeChecking/QueryExprs/TableRefs.ag"(line 202, column 9)
+              _lhsOnewLib2 =
+                  createLocalBindings $ Just []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOlibUpdates,_lhsOnewLib2,_lhsOoriginalTree,_lhsOtrefIDs)))
+-- TypeAttributeDef --------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         attrName             : String
+         fixedUpIdentifiersTree : SELF 
+         namedType            : Maybe Type
+         originalTree         : SELF 
+   alternatives:
+      alternative TypeAttDef:
+         child ann            : {Annotation}
+         child name           : {String}
+         child typ            : TypeName 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data TypeAttributeDef  = TypeAttDef (Annotation) (String) (TypeName ) 
+                       deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_TypeAttributeDef :: TypeAttributeDef  ->
+                        T_TypeAttributeDef 
+sem_TypeAttributeDef (TypeAttDef _ann _name _typ )  =
+    (sem_TypeAttributeDef_TypeAttDef _ann _name (sem_TypeName _typ ) )
+-- semantic domain
+type T_TypeAttributeDef  = Catalog ->
+                           IDEnv ->
+                           LocalBindings ->
+                           ( TypeAttributeDef ,String,TypeAttributeDef ,(Maybe Type),TypeAttributeDef )
+data Inh_TypeAttributeDef  = Inh_TypeAttributeDef {cat_Inh_TypeAttributeDef :: Catalog,idenv_Inh_TypeAttributeDef :: IDEnv,lib_Inh_TypeAttributeDef :: LocalBindings}
+data Syn_TypeAttributeDef  = Syn_TypeAttributeDef {annotatedTree_Syn_TypeAttributeDef :: TypeAttributeDef ,attrName_Syn_TypeAttributeDef :: String,fixedUpIdentifiersTree_Syn_TypeAttributeDef :: TypeAttributeDef ,namedType_Syn_TypeAttributeDef :: (Maybe Type),originalTree_Syn_TypeAttributeDef :: TypeAttributeDef }
+wrap_TypeAttributeDef :: T_TypeAttributeDef  ->
+                         Inh_TypeAttributeDef  ->
+                         Syn_TypeAttributeDef 
+wrap_TypeAttributeDef sem (Inh_TypeAttributeDef _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOattrName,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TypeAttributeDef _lhsOannotatedTree _lhsOattrName _lhsOfixedUpIdentifiersTree _lhsOnamedType _lhsOoriginalTree ))
+sem_TypeAttributeDef_TypeAttDef :: Annotation ->
+                                   String ->
+                                   T_TypeName  ->
+                                   T_TypeAttributeDef 
+sem_TypeAttributeDef_TypeAttDef ann_ name_ typ_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrName :: String
+              _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeAttributeDef 
+              _lhsOfixedUpIdentifiersTree :: TypeAttributeDef 
+              _lhsOoriginalTree :: TypeAttributeDef 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 37, column 9)
+              _lhsOattrName =
+                  name_
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 38, column 9)
+              _lhsOnamedType =
+                  _typInamedType
+              -- self rule
+              _annotatedTree =
+                  TypeAttDef ann_ name_ _typIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  TypeAttDef ann_ name_ _typIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  TypeAttDef ann_ name_ _typIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOattrName,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+-- TypeAttributeDefList ----------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         attrs                : [(String, Maybe Type)]
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : TypeAttributeDef 
+         child tl             : TypeAttributeDefList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type TypeAttributeDefList  = [TypeAttributeDef ]
+-- cata
+sem_TypeAttributeDefList :: TypeAttributeDefList  ->
+                            T_TypeAttributeDefList 
+sem_TypeAttributeDefList list  =
+    (Prelude.foldr sem_TypeAttributeDefList_Cons sem_TypeAttributeDefList_Nil (Prelude.map sem_TypeAttributeDef list) )
+-- semantic domain
+type T_TypeAttributeDefList  = Catalog ->
+                               IDEnv ->
+                               LocalBindings ->
+                               ( TypeAttributeDefList ,([(String, Maybe Type)]),TypeAttributeDefList ,TypeAttributeDefList )
+data Inh_TypeAttributeDefList  = Inh_TypeAttributeDefList {cat_Inh_TypeAttributeDefList :: Catalog,idenv_Inh_TypeAttributeDefList :: IDEnv,lib_Inh_TypeAttributeDefList :: LocalBindings}
+data Syn_TypeAttributeDefList  = Syn_TypeAttributeDefList {annotatedTree_Syn_TypeAttributeDefList :: TypeAttributeDefList ,attrs_Syn_TypeAttributeDefList :: ([(String, Maybe Type)]),fixedUpIdentifiersTree_Syn_TypeAttributeDefList :: TypeAttributeDefList ,originalTree_Syn_TypeAttributeDefList :: TypeAttributeDefList }
+wrap_TypeAttributeDefList :: T_TypeAttributeDefList  ->
+                             Inh_TypeAttributeDefList  ->
+                             Syn_TypeAttributeDefList 
+wrap_TypeAttributeDefList sem (Inh_TypeAttributeDefList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TypeAttributeDefList _lhsOannotatedTree _lhsOattrs _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_TypeAttributeDefList_Cons :: T_TypeAttributeDef  ->
+                                 T_TypeAttributeDefList  ->
+                                 T_TypeAttributeDefList 
+sem_TypeAttributeDefList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrs :: ([(String, Maybe Type)])
+              _lhsOannotatedTree :: TypeAttributeDefList 
+              _lhsOfixedUpIdentifiersTree :: TypeAttributeDefList 
+              _lhsOoriginalTree :: TypeAttributeDefList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: TypeAttributeDef 
+              _hdIattrName :: String
+              _hdIfixedUpIdentifiersTree :: TypeAttributeDef 
+              _hdInamedType :: (Maybe Type)
+              _hdIoriginalTree :: TypeAttributeDef 
+              _tlIannotatedTree :: TypeAttributeDefList 
+              _tlIattrs :: ([(String, Maybe Type)])
+              _tlIfixedUpIdentifiersTree :: TypeAttributeDefList 
+              _tlIoriginalTree :: TypeAttributeDefList 
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 43, column 12)
+              _lhsOattrs =
+                  (_hdIattrName, _hdInamedType) : _tlIattrs
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIattrName,_hdIfixedUpIdentifiersTree,_hdInamedType,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIattrs,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_TypeAttributeDefList_Nil :: T_TypeAttributeDefList 
+sem_TypeAttributeDefList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOattrs :: ([(String, Maybe Type)])
+              _lhsOannotatedTree :: TypeAttributeDefList 
+              _lhsOfixedUpIdentifiersTree :: TypeAttributeDefList 
+              _lhsOoriginalTree :: TypeAttributeDefList 
+              -- "./TypeChecking/Ddl/MiscCreates.ag"(line 44, column 11)
+              _lhsOattrs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOattrs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- TypeName ----------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         namedType            : Maybe Type
+         originalTree         : SELF 
+   alternatives:
+      alternative ArrayTypeName:
+         child ann            : {Annotation}
+         child typ            : TypeName 
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Prec2TypeName:
+         child ann            : {Annotation}
+         child tn             : {String}
+         child prec           : {Integer}
+         child prec1          : {Integer}
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative PrecTypeName:
+         child ann            : {Annotation}
+         child tn             : {String}
+         child prec           : {Integer}
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative SetOfTypeName:
+         child ann            : {Annotation}
+         child typ            : TypeName 
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative SimpleTypeName:
+         child ann            : {Annotation}
+         child tn             : {String}
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data TypeName  = ArrayTypeName (Annotation) (TypeName ) 
+               | Prec2TypeName (Annotation) (String) (Integer) (Integer) 
+               | PrecTypeName (Annotation) (String) (Integer) 
+               | SetOfTypeName (Annotation) (TypeName ) 
+               | SimpleTypeName (Annotation) (String) 
+               deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_TypeName :: TypeName  ->
+                T_TypeName 
+sem_TypeName (ArrayTypeName _ann _typ )  =
+    (sem_TypeName_ArrayTypeName _ann (sem_TypeName _typ ) )
+sem_TypeName (Prec2TypeName _ann _tn _prec _prec1 )  =
+    (sem_TypeName_Prec2TypeName _ann _tn _prec _prec1 )
+sem_TypeName (PrecTypeName _ann _tn _prec )  =
+    (sem_TypeName_PrecTypeName _ann _tn _prec )
+sem_TypeName (SetOfTypeName _ann _typ )  =
+    (sem_TypeName_SetOfTypeName _ann (sem_TypeName _typ ) )
+sem_TypeName (SimpleTypeName _ann _tn )  =
+    (sem_TypeName_SimpleTypeName _ann _tn )
+-- semantic domain
+type T_TypeName  = Catalog ->
+                   IDEnv ->
+                   LocalBindings ->
+                   ( TypeName ,TypeName ,(Maybe Type),TypeName )
+data Inh_TypeName  = Inh_TypeName {cat_Inh_TypeName :: Catalog,idenv_Inh_TypeName :: IDEnv,lib_Inh_TypeName :: LocalBindings}
+data Syn_TypeName  = Syn_TypeName {annotatedTree_Syn_TypeName :: TypeName ,fixedUpIdentifiersTree_Syn_TypeName :: TypeName ,namedType_Syn_TypeName :: (Maybe Type),originalTree_Syn_TypeName :: TypeName }
+wrap_TypeName :: T_TypeName  ->
+                 Inh_TypeName  ->
+                 Syn_TypeName 
+wrap_TypeName sem (Inh_TypeName _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TypeName _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOnamedType _lhsOoriginalTree ))
+sem_TypeName_ArrayTypeName :: Annotation ->
+                              T_TypeName  ->
+                              T_TypeName 
+sem_TypeName_ArrayTypeName ann_ typ_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeName 
+              _lhsOfixedUpIdentifiersTree :: TypeName 
+              _lhsOoriginalTree :: TypeName 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Misc.ag"(line 19, column 10)
+              _lhsOnamedType =
+                  etmt _tpe
+              -- "./TypeChecking/Misc.ag"(line 20, column 10)
+              _lhsOannotatedTree =
+                  addTypeErrors (tes _tpe    ) _backTree
+              -- "./TypeChecking/Misc.ag"(line 27, column 9)
+              _tpe =
+                  lmt _typInamedType >>=  Right . ArrayType
+              -- "./TypeChecking/Misc.ag"(line 28, column 9)
+              _backTree =
+                  ArrayTypeName ann_ _typIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  ArrayTypeName ann_ _typIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ArrayTypeName ann_ _typIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  ArrayTypeName ann_ _typIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+sem_TypeName_Prec2TypeName :: Annotation ->
+                              String ->
+                              Integer ->
+                              Integer ->
+                              T_TypeName 
+sem_TypeName_Prec2TypeName ann_ tn_ prec_ prec1_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeName 
+              _lhsOfixedUpIdentifiersTree :: TypeName 
+              _lhsOoriginalTree :: TypeName 
+              -- "./TypeChecking/Misc.ag"(line 19, column 10)
+              _lhsOnamedType =
+                  etmt _tpe
+              -- "./TypeChecking/Misc.ag"(line 20, column 10)
+              _lhsOannotatedTree =
+                  addTypeErrors (tes _tpe    ) _backTree
+              -- "./TypeChecking/Misc.ag"(line 36, column 9)
+              _tpe =
+                  catLookupType _lhsIcat $ canonicalizeTypeName tn_
+              -- "./TypeChecking/Misc.ag"(line 37, column 9)
+              _backTree =
+                  Prec2TypeName ann_ tn_ prec_ prec1_
+              -- self rule
+              _annotatedTree =
+                  Prec2TypeName ann_ tn_ prec_ prec1_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  Prec2TypeName ann_ tn_ prec_ prec1_
+              -- self rule
+              _originalTree =
+                  Prec2TypeName ann_ tn_ prec_ prec1_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+sem_TypeName_PrecTypeName :: Annotation ->
+                             String ->
+                             Integer ->
+                             T_TypeName 
+sem_TypeName_PrecTypeName ann_ tn_ prec_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeName 
+              _lhsOfixedUpIdentifiersTree :: TypeName 
+              _lhsOoriginalTree :: TypeName 
+              -- "./TypeChecking/Misc.ag"(line 19, column 10)
+              _lhsOnamedType =
+                  etmt _tpe
+              -- "./TypeChecking/Misc.ag"(line 20, column 10)
+              _lhsOannotatedTree =
+                  addTypeErrors (tes _tpe    ) _backTree
+              -- "./TypeChecking/Misc.ag"(line 33, column 9)
+              _tpe =
+                  catLookupType _lhsIcat $ canonicalizeTypeName tn_
+              -- "./TypeChecking/Misc.ag"(line 34, column 9)
+              _backTree =
+                  PrecTypeName ann_ tn_ prec_
+              -- self rule
+              _annotatedTree =
+                  PrecTypeName ann_ tn_ prec_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  PrecTypeName ann_ tn_ prec_
+              -- self rule
+              _originalTree =
+                  PrecTypeName ann_ tn_ prec_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+sem_TypeName_SetOfTypeName :: Annotation ->
+                              T_TypeName  ->
+                              T_TypeName 
+sem_TypeName_SetOfTypeName ann_ typ_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeName 
+              _lhsOfixedUpIdentifiersTree :: TypeName 
+              _lhsOoriginalTree :: TypeName 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Misc.ag"(line 19, column 10)
+              _lhsOnamedType =
+                  etmt _tpe
+              -- "./TypeChecking/Misc.ag"(line 20, column 10)
+              _lhsOannotatedTree =
+                  addTypeErrors (tes _tpe    ) _backTree
+              -- "./TypeChecking/Misc.ag"(line 30, column 9)
+              _tpe =
+                  lmt _typInamedType >>=  Right . SetOfType
+              -- "./TypeChecking/Misc.ag"(line 31, column 9)
+              _backTree =
+                  SetOfTypeName ann_ _typIannotatedTree
+              -- self rule
+              _annotatedTree =
+                  SetOfTypeName ann_ _typIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SetOfTypeName ann_ _typIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  SetOfTypeName ann_ _typIoriginalTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+sem_TypeName_SimpleTypeName :: Annotation ->
+                               String ->
+                               T_TypeName 
+sem_TypeName_SimpleTypeName ann_ tn_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedType :: (Maybe Type)
+              _lhsOannotatedTree :: TypeName 
+              _lhsOfixedUpIdentifiersTree :: TypeName 
+              _lhsOoriginalTree :: TypeName 
+              -- "./TypeChecking/Misc.ag"(line 19, column 10)
+              _lhsOnamedType =
+                  etmt _tpe
+              -- "./TypeChecking/Misc.ag"(line 20, column 10)
+              _lhsOannotatedTree =
+                  addTypeErrors (tes _tpe    ) _backTree
+              -- "./TypeChecking/Misc.ag"(line 24, column 9)
+              _tpe =
+                  catLookupType _lhsIcat $ canonicalizeTypeName tn_
+              -- "./TypeChecking/Misc.ag"(line 25, column 9)
+              _backTree =
+                  SimpleTypeName ann_ tn_
+              -- self rule
+              _annotatedTree =
+                  SimpleTypeName ann_ tn_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  SimpleTypeName ann_ tn_
+              -- self rule
+              _originalTree =
+                  SimpleTypeName ann_ tn_
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedType,_lhsOoriginalTree)))
+-- TypeNameList ------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         namedTypes           : [Maybe Type]
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : TypeName 
+         child tl             : TypeNameList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type TypeNameList  = [TypeName ]
+-- cata
+sem_TypeNameList :: TypeNameList  ->
+                    T_TypeNameList 
+sem_TypeNameList list  =
+    (Prelude.foldr sem_TypeNameList_Cons sem_TypeNameList_Nil (Prelude.map sem_TypeName list) )
+-- semantic domain
+type T_TypeNameList  = Catalog ->
+                       IDEnv ->
+                       LocalBindings ->
+                       ( TypeNameList ,TypeNameList ,([Maybe Type]),TypeNameList )
+data Inh_TypeNameList  = Inh_TypeNameList {cat_Inh_TypeNameList :: Catalog,idenv_Inh_TypeNameList :: IDEnv,lib_Inh_TypeNameList :: LocalBindings}
+data Syn_TypeNameList  = Syn_TypeNameList {annotatedTree_Syn_TypeNameList :: TypeNameList ,fixedUpIdentifiersTree_Syn_TypeNameList :: TypeNameList ,namedTypes_Syn_TypeNameList :: ([Maybe Type]),originalTree_Syn_TypeNameList :: TypeNameList }
+wrap_TypeNameList :: T_TypeNameList  ->
+                     Inh_TypeNameList  ->
+                     Syn_TypeNameList 
+wrap_TypeNameList sem (Inh_TypeNameList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedTypes,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_TypeNameList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOnamedTypes _lhsOoriginalTree ))
+sem_TypeNameList_Cons :: T_TypeName  ->
+                         T_TypeNameList  ->
+                         T_TypeNameList 
+sem_TypeNameList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: TypeNameList 
+              _lhsOfixedUpIdentifiersTree :: TypeNameList 
+              _lhsOoriginalTree :: TypeNameList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: TypeName 
+              _hdIfixedUpIdentifiersTree :: TypeName 
+              _hdInamedType :: (Maybe Type)
+              _hdIoriginalTree :: TypeName 
+              _tlIannotatedTree :: TypeNameList 
+              _tlIfixedUpIdentifiersTree :: TypeNameList 
+              _tlInamedTypes :: ([Maybe Type])
+              _tlIoriginalTree :: TypeNameList 
+              -- "./TypeChecking/Ddl/Drops.ag"(line 37, column 12)
+              _lhsOnamedTypes =
+                  _hdInamedType : _tlInamedTypes
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIfixedUpIdentifiersTree,_hdInamedType,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlInamedTypes,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedTypes,_lhsOoriginalTree)))
+sem_TypeNameList_Nil :: T_TypeNameList 
+sem_TypeNameList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOnamedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: TypeNameList 
+              _lhsOfixedUpIdentifiersTree :: TypeNameList 
+              _lhsOoriginalTree :: TypeNameList 
+              -- "./TypeChecking/Ddl/Drops.ag"(line 38, column 11)
+              _lhsOnamedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOnamedTypes,_lhsOoriginalTree)))
+-- VarDef ------------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         def                  : (String,Maybe Type)
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative ParamAlias:
+         child ann            : {Annotation}
+         child name           : {String}
+         child i              : {Integer}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative VarAlias:
+         child ann            : {Annotation}
+         child name           : {String}
+         child aliased        : {String}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative VarDef:
+         child ann            : {Annotation}
+         child name           : {String}
+         child typ            : TypeName 
+         child value          : {Maybe ScalarExpr}
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data VarDef  = ParamAlias (Annotation) (String) (Integer) 
+             | VarAlias (Annotation) (String) (String) 
+             | VarDef (Annotation) (String) (TypeName ) ((Maybe ScalarExpr)) 
+             deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_VarDef :: VarDef  ->
+              T_VarDef 
+sem_VarDef (ParamAlias _ann _name _i )  =
+    (sem_VarDef_ParamAlias _ann _name _i )
+sem_VarDef (VarAlias _ann _name _aliased )  =
+    (sem_VarDef_VarAlias _ann _name _aliased )
+sem_VarDef (VarDef _ann _name _typ _value )  =
+    (sem_VarDef_VarDef _ann _name (sem_TypeName _typ ) _value )
+-- semantic domain
+type T_VarDef  = Catalog ->
+                 IDEnv ->
+                 LocalBindings ->
+                 ( VarDef ,((String,Maybe Type)),VarDef ,VarDef )
+data Inh_VarDef  = Inh_VarDef {cat_Inh_VarDef :: Catalog,idenv_Inh_VarDef :: IDEnv,lib_Inh_VarDef :: LocalBindings}
+data Syn_VarDef  = Syn_VarDef {annotatedTree_Syn_VarDef :: VarDef ,def_Syn_VarDef :: ((String,Maybe Type)),fixedUpIdentifiersTree_Syn_VarDef :: VarDef ,originalTree_Syn_VarDef :: VarDef }
+wrap_VarDef :: T_VarDef  ->
+               Inh_VarDef  ->
+               Syn_VarDef 
+wrap_VarDef sem (Inh_VarDef _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOdef,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_VarDef _lhsOannotatedTree _lhsOdef _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_VarDef_ParamAlias :: Annotation ->
+                         String ->
+                         Integer ->
+                         T_VarDef 
+sem_VarDef_ParamAlias ann_ name_ i_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOdef :: ((String,Maybe Type))
+              _lhsOannotatedTree :: VarDef 
+              _lhsOfixedUpIdentifiersTree :: VarDef 
+              _lhsOoriginalTree :: VarDef 
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 14, column 18)
+              _lhsOdef =
+                  (name_, Nothing)
+              -- self rule
+              _annotatedTree =
+                  ParamAlias ann_ name_ i_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  ParamAlias ann_ name_ i_
+              -- self rule
+              _originalTree =
+                  ParamAlias ann_ name_ i_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOdef,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_VarDef_VarAlias :: Annotation ->
+                       String ->
+                       String ->
+                       T_VarDef 
+sem_VarDef_VarAlias ann_ name_ aliased_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOdef :: ((String,Maybe Type))
+              _lhsOannotatedTree :: VarDef 
+              _lhsOfixedUpIdentifiersTree :: VarDef 
+              _lhsOoriginalTree :: VarDef 
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 13, column 16)
+              _lhsOdef =
+                  (name_, Nothing)
+              -- self rule
+              _annotatedTree =
+                  VarAlias ann_ name_ aliased_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  VarAlias ann_ name_ aliased_
+              -- self rule
+              _originalTree =
+                  VarAlias ann_ name_ aliased_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOdef,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_VarDef_VarDef :: Annotation ->
+                     String ->
+                     T_TypeName  ->
+                     (Maybe ScalarExpr) ->
+                     T_VarDef 
+sem_VarDef_VarDef ann_ name_ typ_ value_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOdef :: ((String,Maybe Type))
+              _lhsOannotatedTree :: VarDef 
+              _lhsOfixedUpIdentifiersTree :: VarDef 
+              _lhsOoriginalTree :: VarDef 
+              _typOcat :: Catalog
+              _typOidenv :: IDEnv
+              _typOlib :: LocalBindings
+              _typIannotatedTree :: TypeName 
+              _typIfixedUpIdentifiersTree :: TypeName 
+              _typInamedType :: (Maybe Type)
+              _typIoriginalTree :: TypeName 
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 10, column 14)
+              _lhsOdef =
+                  (name_, if _typInamedType == Just (Pseudo Record)
+                          then Just (PgRecord Nothing)
+                          else _typInamedType)
+              -- self rule
+              _annotatedTree =
+                  VarDef ann_ name_ _typIannotatedTree value_
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  VarDef ann_ name_ _typIfixedUpIdentifiersTree value_
+              -- self rule
+              _originalTree =
+                  VarDef ann_ name_ _typIoriginalTree value_
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _typOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _typOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _typOlib =
+                  _lhsIlib
+              ( _typIannotatedTree,_typIfixedUpIdentifiersTree,_typInamedType,_typIoriginalTree) =
+                  typ_ _typOcat _typOidenv _typOlib 
+          in  ( _lhsOannotatedTree,_lhsOdef,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- VarDefList --------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         defs                 : [(String,Maybe Type)]
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative Cons:
+         child hd             : VarDef 
+         child tl             : VarDefList 
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type VarDefList  = [VarDef ]
+-- cata
+sem_VarDefList :: VarDefList  ->
+                  T_VarDefList 
+sem_VarDefList list  =
+    (Prelude.foldr sem_VarDefList_Cons sem_VarDefList_Nil (Prelude.map sem_VarDef list) )
+-- semantic domain
+type T_VarDefList  = Catalog ->
+                     IDEnv ->
+                     LocalBindings ->
+                     ( VarDefList ,([(String,Maybe Type)]),VarDefList ,VarDefList )
+data Inh_VarDefList  = Inh_VarDefList {cat_Inh_VarDefList :: Catalog,idenv_Inh_VarDefList :: IDEnv,lib_Inh_VarDefList :: LocalBindings}
+data Syn_VarDefList  = Syn_VarDefList {annotatedTree_Syn_VarDefList :: VarDefList ,defs_Syn_VarDefList :: ([(String,Maybe Type)]),fixedUpIdentifiersTree_Syn_VarDefList :: VarDefList ,originalTree_Syn_VarDefList :: VarDefList }
+wrap_VarDefList :: T_VarDefList  ->
+                   Inh_VarDefList  ->
+                   Syn_VarDefList 
+wrap_VarDefList sem (Inh_VarDefList _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOdefs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_VarDefList _lhsOannotatedTree _lhsOdefs _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_VarDefList_Cons :: T_VarDef  ->
+                       T_VarDefList  ->
+                       T_VarDefList 
+sem_VarDefList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOdefs :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: VarDefList 
+              _lhsOfixedUpIdentifiersTree :: VarDefList 
+              _lhsOoriginalTree :: VarDefList 
+              _hdOcat :: Catalog
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOcat :: Catalog
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: VarDef 
+              _hdIdef :: ((String,Maybe Type))
+              _hdIfixedUpIdentifiersTree :: VarDef 
+              _hdIoriginalTree :: VarDef 
+              _tlIannotatedTree :: VarDefList 
+              _tlIdefs :: ([(String,Maybe Type)])
+              _tlIfixedUpIdentifiersTree :: VarDefList 
+              _tlIoriginalTree :: VarDefList 
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 17, column 12)
+              _lhsOdefs =
+                  _hdIdef : _tlIdefs
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIdef,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIdefs,_tlIfixedUpIdentifiersTree,_tlIoriginalTree) =
+                  tl_ _tlOcat _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOdefs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+sem_VarDefList_Nil :: T_VarDefList 
+sem_VarDefList_Nil  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOdefs :: ([(String,Maybe Type)])
+              _lhsOannotatedTree :: VarDefList 
+              _lhsOfixedUpIdentifiersTree :: VarDefList 
+              _lhsOoriginalTree :: VarDefList 
+              -- "./TypeChecking/Plpgsql/Block.ag"(line 18, column 11)
+              _lhsOdefs =
+                  []
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOdefs,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- WithQuery ---------------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         catUpdates           : [CatalogUpdate]
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+   alternatives:
+      alternative WithQuery:
+         child ann            : {Annotation}
+         child name           : {String}
+         child colAliases     : {Maybe [String]}
+         child ex             : QueryExpr 
+         visit 0:
+            local tpe         : _
+            local backTree    : _
+            local attrs       : _
+            local catUpdates  : _
+            local statementType : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+data WithQuery  = WithQuery (Annotation) (String) ((Maybe [String])) (QueryExpr ) 
+                deriving ( Data,Eq,Show,Typeable)
+-- cata
+sem_WithQuery :: WithQuery  ->
+                 T_WithQuery 
+sem_WithQuery (WithQuery _ann _name _colAliases _ex )  =
+    (sem_WithQuery_WithQuery _ann _name _colAliases (sem_QueryExpr _ex ) )
+-- semantic domain
+type T_WithQuery  = Catalog ->
+                    IDEnv ->
+                    LocalBindings ->
+                    ( WithQuery ,([CatalogUpdate]),WithQuery ,WithQuery )
+data Inh_WithQuery  = Inh_WithQuery {cat_Inh_WithQuery :: Catalog,idenv_Inh_WithQuery :: IDEnv,lib_Inh_WithQuery :: LocalBindings}
+data Syn_WithQuery  = Syn_WithQuery {annotatedTree_Syn_WithQuery :: WithQuery ,catUpdates_Syn_WithQuery :: ([CatalogUpdate]),fixedUpIdentifiersTree_Syn_WithQuery :: WithQuery ,originalTree_Syn_WithQuery :: WithQuery }
+wrap_WithQuery :: T_WithQuery  ->
+                  Inh_WithQuery  ->
+                  Syn_WithQuery 
+wrap_WithQuery sem (Inh_WithQuery _lhsIcat _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIidenv _lhsIlib 
+     in  (Syn_WithQuery _lhsOannotatedTree _lhsOcatUpdates _lhsOfixedUpIdentifiersTree _lhsOoriginalTree ))
+sem_WithQuery_WithQuery :: Annotation ->
+                           String ->
+                           (Maybe [String]) ->
+                           T_QueryExpr  ->
+                           T_WithQuery 
+sem_WithQuery_WithQuery ann_ name_ colAliases_ ex_  =
+    (\ _lhsIcat
+       _lhsIidenv
+       _lhsIlib ->
+         (let _exOcsql :: LocalBindings
+              _exOexpectedTypes :: ([Maybe Type])
+              _lhsOannotatedTree :: WithQuery 
+              _lhsOfixedUpIdentifiersTree :: WithQuery 
+              _lhsOoriginalTree :: WithQuery 
+              _lhsOcatUpdates :: ([CatalogUpdate])
+              _exOcat :: Catalog
+              _exOidenv :: IDEnv
+              _exOlib :: LocalBindings
+              _exIannotatedTree :: QueryExpr 
+              _exIcidenv :: IDEnv
+              _exIfixedUpIdentifiersTree :: QueryExpr 
+              _exIlibUpdates :: ([LocalBindingsUpdate])
+              _exIoriginalTree :: QueryExpr 
+              _exIuType :: (Maybe [(String,Type)])
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 131, column 17)
+              _exOcsql =
+                  emptyBindings
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 272, column 9)
+              _tpe =
+                  Right $ Pseudo Void
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 273, column 9)
+              _backTree =
+                  WithQuery ann_ name_ colAliases_ _exIannotatedTree
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 274, column 9)
+              _attrs =
+                  maybe [] id $ _exIuType
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 275, column 9)
+              _catUpdates =
+                  [CatCreateView name_ _attrs    ]
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 276, column 9)
+              _statementType =
+                  Nothing
+              -- "./TypeChecking/ParameterizedStatements.ag"(line 182, column 17)
+              _exOexpectedTypes =
+                  []
+              -- self rule
+              _annotatedTree =
+                  WithQuery ann_ name_ colAliases_ _exIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  WithQuery ann_ name_ colAliases_ _exIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  WithQuery ann_ name_ colAliases_ _exIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (from local)
+              _lhsOcatUpdates =
+                  _catUpdates
+              -- copy rule (down)
+              _exOcat =
+                  _lhsIcat
+              -- copy rule (down)
+              _exOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _exOlib =
+                  _lhsIlib
+              ( _exIannotatedTree,_exIcidenv,_exIfixedUpIdentifiersTree,_exIlibUpdates,_exIoriginalTree,_exIuType) =
+                  ex_ _exOcat _exOcsql _exOexpectedTypes _exOidenv _exOlib 
+          in  ( _lhsOannotatedTree,_lhsOcatUpdates,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree)))
+-- WithQueryList -----------------------------------------------
+{-
+   visit 0:
+      inherited attributes:
+         cat                  : Catalog
+         catUpdates           : [CatalogUpdate]
+         idenv                : IDEnv
+         lib                  : LocalBindings
+      synthesized attributes:
+         annotatedTree        : SELF 
+         fixedUpIdentifiersTree : SELF 
+         originalTree         : SELF 
+         producedCat          : Catalog
+   alternatives:
+      alternative Cons:
+         child hd             : WithQuery 
+         child tl             : WithQueryList 
+         visit 0:
+            local newCat      : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+      alternative Nil:
+         visit 0:
+            local newCat      : _
+            local annotatedTree : _
+            local fixedUpIdentifiersTree : _
+            local originalTree : _
+-}
+type WithQueryList  = [WithQuery ]
+-- cata
+sem_WithQueryList :: WithQueryList  ->
+                     T_WithQueryList 
+sem_WithQueryList list  =
+    (Prelude.foldr sem_WithQueryList_Cons sem_WithQueryList_Nil (Prelude.map sem_WithQuery list) )
+-- semantic domain
+type T_WithQueryList  = Catalog ->
+                        ([CatalogUpdate]) ->
+                        IDEnv ->
+                        LocalBindings ->
+                        ( WithQueryList ,WithQueryList ,WithQueryList ,Catalog)
+data Inh_WithQueryList  = Inh_WithQueryList {cat_Inh_WithQueryList :: Catalog,catUpdates_Inh_WithQueryList :: ([CatalogUpdate]),idenv_Inh_WithQueryList :: IDEnv,lib_Inh_WithQueryList :: LocalBindings}
+data Syn_WithQueryList  = Syn_WithQueryList {annotatedTree_Syn_WithQueryList :: WithQueryList ,fixedUpIdentifiersTree_Syn_WithQueryList :: WithQueryList ,originalTree_Syn_WithQueryList :: WithQueryList ,producedCat_Syn_WithQueryList :: Catalog}
+wrap_WithQueryList :: T_WithQueryList  ->
+                      Inh_WithQueryList  ->
+                      Syn_WithQueryList 
+wrap_WithQueryList sem (Inh_WithQueryList _lhsIcat _lhsIcatUpdates _lhsIidenv _lhsIlib )  =
+    (let ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat) = sem _lhsIcat _lhsIcatUpdates _lhsIidenv _lhsIlib 
+     in  (Syn_WithQueryList _lhsOannotatedTree _lhsOfixedUpIdentifiersTree _lhsOoriginalTree _lhsOproducedCat ))
+sem_WithQueryList_Cons :: T_WithQuery  ->
+                          T_WithQueryList  ->
+                          T_WithQueryList 
+sem_WithQueryList_Cons hd_ tl_  =
+    (\ _lhsIcat
+       _lhsIcatUpdates
+       _lhsIidenv
+       _lhsIlib ->
+         (let _hdOcat :: Catalog
+              _tlOcat :: Catalog
+              _lhsOproducedCat :: Catalog
+              _tlOcatUpdates :: ([CatalogUpdate])
+              _lhsOannotatedTree :: WithQueryList 
+              _lhsOfixedUpIdentifiersTree :: WithQueryList 
+              _lhsOoriginalTree :: WithQueryList 
+              _hdOidenv :: IDEnv
+              _hdOlib :: LocalBindings
+              _tlOidenv :: IDEnv
+              _tlOlib :: LocalBindings
+              _hdIannotatedTree :: WithQuery 
+              _hdIcatUpdates :: ([CatalogUpdate])
+              _hdIfixedUpIdentifiersTree :: WithQuery 
+              _hdIoriginalTree :: WithQuery 
+              _tlIannotatedTree :: WithQueryList 
+              _tlIfixedUpIdentifiersTree :: WithQueryList 
+              _tlIoriginalTree :: WithQueryList 
+              _tlIproducedCat :: Catalog
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 256, column 9)
+              _newCat =
+                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 258, column 9)
+              _hdOcat =
+                  _newCat
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 259, column 9)
+              _tlOcat =
+                  _newCat
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 263, column 9)
+              _lhsOproducedCat =
+                  _tlIproducedCat
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 266, column 9)
+              _tlOcatUpdates =
+                  _hdIcatUpdates
+              -- self rule
+              _annotatedTree =
+                  (:) _hdIannotatedTree _tlIannotatedTree
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  (:) _hdIfixedUpIdentifiersTree _tlIfixedUpIdentifiersTree
+              -- self rule
+              _originalTree =
+                  (:) _hdIoriginalTree _tlIoriginalTree
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+              -- copy rule (down)
+              _hdOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _hdOlib =
+                  _lhsIlib
+              -- copy rule (down)
+              _tlOidenv =
+                  _lhsIidenv
+              -- copy rule (down)
+              _tlOlib =
+                  _lhsIlib
+              ( _hdIannotatedTree,_hdIcatUpdates,_hdIfixedUpIdentifiersTree,_hdIoriginalTree) =
+                  hd_ _hdOcat _hdOidenv _hdOlib 
+              ( _tlIannotatedTree,_tlIfixedUpIdentifiersTree,_tlIoriginalTree,_tlIproducedCat) =
+                  tl_ _tlOcat _tlOcatUpdates _tlOidenv _tlOlib 
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat)))
+sem_WithQueryList_Nil :: T_WithQueryList 
+sem_WithQueryList_Nil  =
+    (\ _lhsIcat
+       _lhsIcatUpdates
+       _lhsIidenv
+       _lhsIlib ->
+         (let _lhsOproducedCat :: Catalog
+              _lhsOannotatedTree :: WithQueryList 
+              _lhsOfixedUpIdentifiersTree :: WithQueryList 
+              _lhsOoriginalTree :: WithQueryList 
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 256, column 9)
+              _newCat =
+                  fromRight _lhsIcat $ updateCatalog _lhsIcat _lhsIcatUpdates
+              -- "./TypeChecking/QueryExprs/QueryStatement.ag"(line 268, column 9)
+              _lhsOproducedCat =
+                  _newCat
+              -- self rule
+              _annotatedTree =
+                  []
+              -- self rule
+              _fixedUpIdentifiersTree =
+                  []
+              -- self rule
+              _originalTree =
+                  []
+              -- self rule
+              _lhsOannotatedTree =
+                  _annotatedTree
+              -- self rule
+              _lhsOfixedUpIdentifiersTree =
+                  _fixedUpIdentifiersTree
+              -- self rule
+              _lhsOoriginalTree =
+                  _originalTree
+          in  ( _lhsOannotatedTree,_lhsOfixedUpIdentifiersTree,_lhsOoriginalTree,_lhsOproducedCat)))
diff --git a/src/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs b/src/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/Catalog/CatalogInternal.lhs
@@ -0,0 +1,531 @@
+
+This module contains the implementation of the Catalog data types
+and functions, and provides the api for the other type checking
+modules.
+
+> {-# LANGUAGE DeriveDataTypeable #-}
+>
+> module Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+>     (
+>      Catalog
+>     ,CastContext(..)
+>     ,CompositeFlavour(..)
+>     ,relationComposites
+>     ,CompositeDef
+>     ,FunctionPrototype
+>     ,DomainDefinition
+>     ,FunFlav(..)
+>     ,emptyCatalog
+>     ,defaultCatalog
+>     ,CatalogUpdate(..)
+>     ,ppCatUpdate
+>     ,updateCatalog
+>     ,deconstructCatalog
+>     -- type checker stuff
+>     ,catCompositeDef
+>     ,catCompositeAttrsPair
+>     ,catCompositeAttrs
+>     ,catCompositePublicAttrs
+>     ,catTypeCategory
+>     ,catPreferredType
+>     ,catCast
+>     ,catDomainBaseType
+>     ,catLookupFns
+>     ,catTypeExists
+>     ,catLookupType
+>     ,OperatorType(..)
+>     ,getOperatorType
+>     ,isOperatorName
+>     -- comparing catalogs
+>     ,CatalogDiff(..)
+>     ,compareCatalogs
+>     ,ppCatDiff
+>     ) where
+>
+> import Control.Monad
+> import Data.List
+> import Data.Data
+> -- import Debug.Trace
+> import Data.Char
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
+> import Database.HsSqlPpp.Utils.Utils
+>
+> -- | The main datatype, this holds the catalog and context
+> -- information to type check against.
+> data Catalog = Catalog
+>                    {catTypeNames :: [(String, Type)]
+>                    ,catDomainDefs :: [DomainDefinition]
+>                    ,catCasts :: [(Type,Type,CastContext)]
+>                    ,catTypeCategories :: [(Type,String,Bool)]
+>                    ,catPrefixOperators :: [FunctionPrototype]
+>                    ,catPostfixOperators :: [FunctionPrototype]
+>                    ,catBinaryOperators :: [FunctionPrototype]
+>                    ,catFunctions :: [FunctionPrototype]
+>                    ,catAggregates :: [FunctionPrototype]
+>                    ,catWindowFunctions :: [FunctionPrototype]
+>                    ,catAttrDefs :: [CompositeDef]
+>                    ,catUpdates :: [CatalogUpdate]}
+>                    deriving Show
+>
+> -- | Represents an empty catalog. This doesn't contain things
+> -- like the \'and\' operator, 'defaultCatalog' contains these.
+> emptyCatalog :: Catalog
+> emptyCatalog = Catalog [] [] [] [] [] [] [] [] [] [] [] []
+>
+> -- | 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..
+> defaultCatalog :: Catalog
+> defaultCatalog =
+>   emptyCatalog {catTypeNames = pseudoTypes
+>                ,catBinaryOperators = pe : keywordOperatorTypes
+>                ,catFunctions = specialFunctionTypes}
+>   where
+>     pe = ("=", [Pseudo AnyElement, Pseudo AnyElement], typeBool, False)
+>
+> -- | Use to note what the flavour of a cast is, i.e. if/when it can
+> -- be used implicitly.
+> data CastContext = ImplicitCastContext
+>                  | AssignmentCastContext
+>                  | ExplicitCastContext
+>                    deriving (Eq,Show,Ord,Typeable,Data)
+>
+> -- | Used to distinguish between standalone composite types, and
+> -- automatically generated ones, generated from a table or view
+> -- respectively.
+> data CompositeFlavour = Composite | TableComposite | ViewComposite
+>                         deriving (Eq,Ord,Show)
+>
+> relationComposites :: [CompositeFlavour]
+> relationComposites = [TableComposite,ViewComposite]
+>
+> -- | 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 'CompositeType's).
+> type CompositeDef = (String, CompositeFlavour, Type, Type)
+>
+> -- | The components are: function (or operator) name, argument
+> -- types, return type and is variadic.
+> type FunctionPrototype = (String, [Type], Type, Bool)
+>
+> -- | The components are domain type, base type (todo: add check
+> -- constraint).
+> type DomainDefinition = (Type,Type)
+>
+> data CatalogUpdate =
+>     -- | add a new scalar type with the name given, also creates
+>     -- an array type automatically
+>     CatCreateScalar Type String Bool
+>     -- | add a new domain to the catalog
+>   | CatCreateDomain Type Type
+>     -- | add a new composite type to the catalog
+>   | CatCreateComposite String [(String,Type)]
+>     -- | add a new cast to the catalog
+>   | CatCreateCast Type Type CastContext
+>     -- | add a new table to the catalog with the given public and private columns
+>     -- also creates the composite type to go with this table
+>   | CatCreateTable String [(String,Type)] [(String,Type)]
+>     -- | add the view to the catalog, using the column names and types supplied
+>   | CatCreateView String [(String,Type)]
+>     -- | add a new function to the catalog
+>   | CatCreateFunction FunFlav String [Type] Type Bool
+>     -- | drop a function from the catalog
+>   | CatDropFunction Bool String [Type]
+>     deriving (Eq,Ord,Typeable,Data,Show)
+>
+> -- | attempt to show a readable representation of a 'CatalogUpdate' value
+> ppCatUpdate :: CatalogUpdate -> String
+> ppCatUpdate (CatCreateScalar t c p) =
+>   "CatCreateScalar " ++ show t ++ "(" ++ c ++ "," ++ show p ++ ")"
+> ppCatUpdate (CatCreateDomain t b) =
+>   "CatCreateDomain " ++ show t ++ " as " ++ show b
+> ppCatUpdate (CatCreateComposite nm flds) =
+>   "CatCreateComposite " ++ nm ++ showFlds flds
+> ppCatUpdate (CatCreateCast s t ctx) =
+>   "CatCreateCast " ++ show s ++ "->" ++ show t ++ " " ++ show ctx
+> ppCatUpdate (CatCreateTable nm flds1 flds2) =
+>   "CatCreateTable " ++ nm ++ showFlds flds1 ++ showFlds flds2
+> ppCatUpdate (CatCreateView nm flds) =
+>   "CatCreateView " ++ nm ++ showFlds flds
+> ppCatUpdate (CatCreateFunction flav nm args ret vdc) =
+>   "CatCreateFunction " ++ show flav ++ " " ++ nm
+>   ++ " returns " ++ show ret
+>   ++ "(" ++ intercalate "," (map show args) ++ ")"
+>   ++ if vdc then " variadic" else ""
+> ppCatUpdate (CatDropFunction _ nm args) =
+>   "CatDropFunction " ++ nm ++ "(" ++ show args ++ ")"
+>
+> showFlds :: [(String,Type)] -> String
+> showFlds flds = "(\n" ++ sfs flds ++ ")"
+>                 where
+>                   sfs ((nm,t):fs) = "    " ++ show nm
+>                                     ++ " " ++ show t ++ "\n" ++ sfs fs
+>                   sfs [] = ""
+>
+> data FunFlav = FunPrefix | FunPostfix | FunBinary
+>              | FunName | FunAgg | FunWindow
+>                deriving (Eq,Show,Ord,Typeable,Data)
+>
+> -- | Applies a list of 'CatalogUpdate's to an 'Catalog' value
+> -- to produce a new Catalog value.
+> updateCatalog :: Catalog
+>                   -> [CatalogUpdate]
+>                   -> Either [TypeError] Catalog
+> updateCatalog cat' eus =
+>   foldM updateCat' (cat' {catUpdates = catUpdates cat' ++ eus}) eus
+>   where
+>     updateCat' cat (CatCreateScalar ty catl pref) = do
+>       errorWhen (not allowed)
+>         [BadCatalogUpdate $ "can only add scalar types\
+>                             \this way, got " ++ show ty]
+>       let ScalarType nm = ty
+>       return $ addTypeWithArray cat nm ty catl pref
+>       where
+>         allowed = case ty of
+>                           ScalarType _ -> True
+>                           _ -> False
+>
+>     updateCat' cat (CatCreateDomain ty baseTy) = do
+>       errorWhen (not allowed)
+>         [BadCatalogUpdate $ "can only add domain types\
+>                             \this way, got " ++ show ty]
+>       errorWhen (not baseAllowed)
+>         [BadCatalogUpdate $ "can only add domain types\
+>                                 \based on scalars, got "
+>                                 ++ show baseTy]
+>       let DomainType nm = ty
+>       catl <- catTypeCategory cat baseTy
+>       return (addTypeWithArray cat nm ty catl False) {
+>                              catDomainDefs =
+>                                (ty,baseTy):catDomainDefs cat
+>                              ,catCasts =
+>                                (ty,baseTy,ImplicitCastContext):catCasts cat}
+>       where
+>         allowed = case ty of
+>                           DomainType _ -> True
+>                           _ -> False
+>         baseAllowed = case baseTy of
+>                                   ScalarType _ -> True
+>                                   _ -> False
+>     updateCat' cat (CatCreateComposite nm flds) =
+>       return $ (addTypeWithArray cat nm (NamedCompositeType nm) "C" False) {
+>                   catAttrDefs =
+>                     (nm,Composite,CompositeType flds, CompositeType [])
+>                     : catAttrDefs cat}
+>
+>     updateCat' cat (CatCreateCast src tgt ctx) =
+>       return $ cat {catCasts = (src,tgt,ctx):catCasts cat}
+>
+>     updateCat' cat (CatCreateTable nm attrs sysAttrs) = do
+>       checkTypeDoesntExist cat nm (NamedCompositeType nm)
+>       return $ (addTypeWithArray cat nm
+>                   (NamedCompositeType nm) "C" False) {
+>                   catAttrDefs =
+>                     (nm,TableComposite
+>                     ,CompositeType attrs
+>                     , CompositeType sysAttrs)
+>                     : catAttrDefs cat}
+>
+>     updateCat' cat (CatCreateView nm attrs) = do
+>       checkTypeDoesntExist cat nm (NamedCompositeType nm)
+>       return $ (addTypeWithArray cat nm
+>                   (NamedCompositeType nm) "C" False) {
+>                   catAttrDefs =
+>                     (nm,ViewComposite,CompositeType attrs, CompositeType [])
+>                     : catAttrDefs cat}
+>
+>     updateCat' cat (CatCreateFunction f nm args ret vdc) =
+>         return $ case f of
+>           FunPrefix -> cat {catPrefixOperators =
+>                               fp : catPrefixOperators cat}
+>           FunPostfix -> cat {catPostfixOperators =
+>                                fp : catPostfixOperators cat}
+>           FunBinary -> cat {catBinaryOperators =
+>                               fp : catBinaryOperators cat}
+>           FunAgg -> cat {catAggregates =
+>                            fp : catAggregates cat}
+>           FunWindow -> cat {catWindowFunctions =
+>                               fp : catWindowFunctions cat}
+>           FunName -> cat {catFunctions =
+>                             fp : catFunctions cat}
+>         where fp = (nm,args,ret,vdc)
+>
+>     updateCat' cat (CatDropFunction _ifexists nm args) = do
+>         let matches =  filter matchingFn (catFunctions cat)
+>         errorWhen (null matches)
+>                   [BadCatalogUpdate
+>                    $ "couldn't find function to drop "
+>                      ++ show nm ++ "(" ++ show args++")"]
+>         errorWhen (length matches > 1)
+>                   [BadCatalogUpdate
+>                    $ "multiple matching functions to drop "
+>                      ++ show nm ++ "(" ++ show args++")"]
+>         return cat {catFunctions = filter (not . matchingFn)
+>                                           (catFunctions cat)
+>                    ,catUpdates = filter (not.matchingUpdate)
+>                                         (catUpdates cat)}
+>         where
+>           matchingFn (nm1,a1,_,_) =
+>             map toLower nm == map toLower nm1 && args == a1
+>           matchingUpdate (CatDropFunction _ nm2 a2)
+>                          | map toLower nm2 == map toLower nm
+>                            && a2 == args = True
+>           matchingUpdate (CatCreateFunction _ nm2 a2 _ _)
+>                          | map toLower nm2 == map toLower nm
+>                            && a2 == args = True
+>           matchingUpdate _ = False
+
+todo:
+look for matching function in list, if not found then error
+remove from list, and remove from update list
+
+>     addTypeWithArray cat nm ty catl pref =
+>       cat {catTypeNames =
+>                ('_':nm,ArrayType ty)
+>                : (nm,ty)
+>                : catTypeNames cat
+>           ,catTypeCategories =
+>                (ArrayType ty,"A",False)
+>                : (ty,catl,pref)
+>                : catTypeCategories cat}
+>     checkTypeDoesntExist cat nm ty = do
+>         errorWhen (any (==nm) $ map fst $ catTypeNames cat)
+>             [TypeAlreadyExists ty]
+>         errorWhen (any (==ty) $ map snd $ catTypeNames cat)
+>             [TypeAlreadyExists ty]
+>         return ()
+> {-
+>  | Takes part an 'Catalog' value to produce a list of 'CatalogUpdate's.
+>  You can use this to look inside the Catalog data type e.g. if you want to
+>  examine a catalog. It should be the case that:
+>  @
+>   updateCatalog emptyCatalog (deconstructCatalog cat) = cat
+>  @ -}
+> deconstructCatalog :: Catalog -> [CatalogUpdate]
+> deconstructCatalog = catUpdates
+
+--------------------------------------------------------------------------------
+
+= type checking stuff
+
+> catCompositeDef :: Catalog -> [CompositeFlavour] -> String
+>                 -> Either [TypeError] CompositeDef
+> catCompositeDef cat flvs nm = do
+>   let c = filter m $ catAttrDefs cat
+>   errorWhen (null c)
+>             [UnrecognisedRelation nm]
+>   case c of
+>     (_,fl1,r,s):[] -> return (nm,fl1,r,s)
+>     _ -> Left [InternalError $ "problem getting attributes for: "
+>                                ++ show nm ++ ", " ++ show c]
+>   where
+>     m (n,t,_,_) = n == nm && (null flvs || t `elem` flvs)
+>
+> catCompositeAttrsPair :: Catalog -> [CompositeFlavour] -> String
+>                       -> Either [TypeError] ([(String,Type)],[(String,Type)])
+> catCompositeAttrsPair cat flvs ty = do
+>    (_,_,CompositeType a,CompositeType b) <- catCompositeDef cat flvs ty
+>    return (a,b)
+>
+> catCompositeAttrs :: Catalog -> [CompositeFlavour] -> String
+>                   -> Either [TypeError] [(String,Type)]
+> catCompositeAttrs cat flvs ty = do
+>   (a,b) <- catCompositeAttrsPair cat flvs ty
+>   return $ a ++ b
+>
+> catCompositePublicAttrs :: Catalog -> [CompositeFlavour] -> String
+>                   -> Either [TypeError] [(String,Type)]
+> catCompositePublicAttrs cat flvs ty = do
+>   (a,_) <- catCompositeAttrsPair cat flvs ty
+>   return a
+>
+> catTypeCategory :: Catalog -> Type -> Either [TypeError] String
+> catTypeCategory cat ty =
+>   fmap fst $ catGetCategoryInfo cat ty
+>
+> catPreferredType :: Catalog -> Type -> Either [TypeError] Bool
+> catPreferredType cat ty =
+>   fmap snd $ catGetCategoryInfo cat ty
+>
+> catCast :: Catalog -> CastContext -> Type -> Type -> Either [TypeError] Bool
+> catCast cat ctx from to = {-trace ("check cast " ++ show from ++ show to) $-}
+>     case from of
+>       t@(DomainType _) -> do
+>                 baseType <- catDomainBaseType cat t
+>                 cc <- catCast cat ctx baseType to
+>                 return $ (baseType == to) ||
+>                                (cc ||
+>                                   any (== (from, to, ctx)) (catCasts cat))
+>       _ -> Right $ any (==(from,to,ctx)) (catCasts cat)
+>
+> catDomainBaseType :: Catalog -> Type -> Either [TypeError] Type
+> catDomainBaseType cat ty =
+>   --check type is domain, check it exists in main list
+>   case lookup ty (catDomainDefs cat) of
+>       Nothing -> Left [DomainDefNotFound ty]
+>       Just t -> Right t
+>
+> catLookupFns :: Catalog -> String -> [FunctionPrototype]
+> catLookupFns cat name =
+>     filter (\(nm,_,_,_) -> map toLower nm == map toLower name) catGetAllFns
+>     where
+>     catGetAllFns =
+>         concat [catPrefixOperators cat
+>                ,catPostfixOperators cat
+>                ,catBinaryOperators cat
+>                ,catFunctions cat
+>                ,catAggregates cat
+>                ,catWindowFunctions cat]
+
+== internal support for type checker fns above
+
+> catGetCategoryInfo :: Catalog -> Type -> Either [TypeError] (String, Bool)
+> catGetCategoryInfo cat ty =
+>   case ty of
+>     SetOfType _ -> Right ("", False)
+>     AnonymousRecordType _ -> Right ("", False)
+>     ArrayType (Pseudo _) -> Right ("A",False)
+>     Pseudo _ -> Right ("P",False)
+>     _ -> let l = filter (\(t,_,_) -> ty == t) $ catTypeCategories cat
+>          in if null l
+>               then Left [InternalError $ "no type category for " ++ show ty]
+>               else let (_,c,p):_ =l
+>                    in Right (c,p)
+>
+> catTypeExists :: Catalog -> Type -> Either [TypeError] Type
+> catTypeExists cat t =
+>     errorWhen (t `notElem` map snd (catTypeNames cat))
+>               [UnknownTypeError t] >>
+>     Right t
+>
+> catLookupType :: Catalog -> String -> Either [TypeError] Type
+> catLookupType cat name =
+>     liftME [UnknownTypeName name] $
+>       lookup name (catTypeNames cat)
+>
+
+================================================================================
+
+= built in stuff
+
+keyword operators, all of these are built in and don't appear in any
+postgresql catalog
+
+This is wrong, these need to be separated into prefix, postfix, binary
+
+> keywordOperatorTypes :: [FunctionPrototype]
+> keywordOperatorTypes = [
+>   ("!and", [typeBool, typeBool], typeBool, False)
+>  ,("!or", [typeBool, typeBool], typeBool, False)
+>  ,("!like", [ScalarType "text", ScalarType "text"], typeBool, False)
+>  ,("!like", [ScalarType "char", ScalarType "char"], typeBool, False)
+>  ,("!like", [ScalarType "varchar", ScalarType "varchar"], typeBool, False)
+>  ,("!notlike", [ScalarType "text", ScalarType "text"], typeBool, False)
+>  ,("!notlike", [ScalarType "char", ScalarType "char"], typeBool, False)
+>  ,("!notlike", [ScalarType "varchar", ScalarType "varchar"], typeBool, False)
+>  ,("!not", [typeBool], typeBool, False)
+>  ,("!isnull", [Pseudo AnyElement], typeBool, False)
+>  ,("!isnotnull", [Pseudo AnyElement], typeBool, False)
+>  ,("!arrayctor", [ArrayType $ Pseudo AnyElement], Pseudo AnyArray, True)
+>  ,("!between", [Pseudo AnyElement
+>                ,Pseudo AnyElement
+>                ,Pseudo AnyElement], typeBool, False)
+>  ,("!substring",[ScalarType "text",typeInt,typeInt],ScalarType "text",False)
+>  ,("!substring",[ScalarType "varchar",typeInt,typeInt],ScalarType "varchar",False)
+>  ,("!substring",[ScalarType "char",typeInt,typeInt],ScalarType "char",False)
+>  ,("!arraysub", [Pseudo AnyArray,typeInt], Pseudo AnyElement, False)
+>  ]
+>
+> -- these look like functions, but don't appear in the postgresql catalog.
+>
+> specialFunctionTypes :: [FunctionPrototype]
+> specialFunctionTypes = [
+>   ("coalesce", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement, True)
+>  ,("nullif", [Pseudo AnyElement, Pseudo AnyElement], Pseudo AnyElement,False)
+>  ,("greatest", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement,True)
+>  ,("least", [ArrayType $ Pseudo AnyElement], Pseudo AnyElement,True)
+>  ]
+>
+> pseudoTypes :: [(String, Type)]
+> pseudoTypes =
+>     [("any",Pseudo Any)
+>     ,("anyarray",Pseudo AnyArray)
+>     ,("anyelement",Pseudo AnyElement)
+>     ,("anyenum",Pseudo AnyEnum)
+>     ,("anynonarray",Pseudo AnyNonArray)
+>     ,("cstring",Pseudo Cstring)
+>     ,("record",Pseudo Record)
+>     ,("trigger",Pseudo Trigger)
+>     ,("void",Pseudo Void)
+>     ,("_cstring",ArrayType $ Pseudo Cstring)
+>     ,("_record",ArrayType $ Pseudo Record)
+>     --,Pseudo Internal
+>     --,Pseudo LanguageHandler
+>     --,Pseudo Opaque
+>     ]
+
+================================================================================
+
+= getOperatorType
+
+used by the pretty printer, not sure this is a very good design
+
+for now, assume that all the overloaded operators that have the
+same name are all either binary, prefix or postfix, otherwise the
+getoperatortype would need the types of the arguments to determine
+the operator type, and the parser would have to be a lot cleverer
+although, parsec handles - being unary and binary without breaking
+a sweat, so maybe this isn't too difficult?
+
+this is why binary @ operator isn't currently supported
+
+> data OperatorType = BinaryOp | PrefixOp | PostfixOp
+>                   deriving (Eq,Show)
+>
+> getOperatorType :: Catalog -> String -> Either [TypeError] OperatorType
+> getOperatorType cat s =
+>   case () of
+>           _ | s `elem` ["!and", "!or","!like","!notlike","."] -> Right BinaryOp
+>             | s `elem` ["!not"] -> Right PrefixOp
+>             | s `elem` ["!isnull", "!isnotnull"] -> Right PostfixOp
+>             | any (\(x,_,_,_) -> x == s) (catBinaryOperators cat) ->
+>                       Right BinaryOp
+>             | any (\(x,_,_,_) -> x == s || (x=="-" && s=="u-"))
+>                   (catPrefixOperators cat) ->
+>                       Right PrefixOp
+>             | any (\(x,_,_,_) -> x == s) (catPostfixOperators cat) ->
+>                       Right PostfixOp
+>             | otherwise ->
+>                 Left [InternalError $ "don't know flavour of operator " ++ s]
+>
+> isOperatorName :: String -> Bool
+> isOperatorName = any (`elem` "+-*/<>=~!@#%^&|`?.")
+
+================================================================================
+
+> -- | items in first catalog and not second, items in second and not first.
+> data CatalogDiff = CatalogDiff [CatalogUpdate] [CatalogUpdate]
+>                deriving Show
+>
+> -- | find differences between two catalogs
+> compareCatalogs :: Catalog -> Catalog -> Catalog -> CatalogDiff
+> compareCatalogs base start end =
+>         let baseCatBits = deconstructCatalog base
+>             startCatBits = deconstructCatalog start \\ baseCatBits
+>             endCatBits = deconstructCatalog end \\ baseCatBits
+>             missing = sort $ endCatBits \\ startCatBits
+>             extras = sort $ startCatBits \\ endCatBits
+>         in CatalogDiff missing extras
+>
+> -- | print a catdiff in a more human readable way than show.
+> ppCatDiff :: CatalogDiff -> String
+> ppCatDiff (CatalogDiff missing extr) =
+>     "\nmissing:\n"
+>     ++ intercalate "\n" (map ppCatUpdate missing)
+>     ++ "\nextra:\n"
+>     ++ intercalate "\n" (map ppCatUpdate extr)
diff --git a/src/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs b/src/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/Catalog/DefaultTemplate1Catalog.lhs
@@ -0,0 +1,13044 @@
+
+
+
+
+This file is auto generated, to regenerate run
+MUMBLE MUMBLE SOMETHING
+
+from the project root (i.e. where the cabal file is located).
+
+> module Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
+>      (defaultTemplate1Catalog) where
+>
+> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+> import Database.HsSqlPpp.AstInternals.TypeType
+>
+> defaultTemplate1Catalog :: Catalog
+> defaultTemplate1Catalog =
+>     (\l -> case l of
+>              Left x -> error $ show x
+>              Right e -> e) $
+>      updateCatalog defaultCatalog
+
+ 
+>        [CatCreateScalar (ScalarType "bool") "B" True,
+>         CatCreateScalar (ScalarType "bytea") "U" False,
+>         CatCreateScalar (ScalarType "char") "S" False,
+>         CatCreateScalar (ScalarType "name") "S" False,
+>         CatCreateScalar (ScalarType "int8") "N" False,
+>         CatCreateScalar (ScalarType "int2") "N" False,
+>         CatCreateScalar (ScalarType "int2vector") "A" False,
+>         CatCreateScalar (ScalarType "int4") "N" False,
+>         CatCreateScalar (ScalarType "regproc") "N" False,
+>         CatCreateScalar (ScalarType "text") "S" True,
+>         CatCreateScalar (ScalarType "oid") "N" True,
+>         CatCreateScalar (ScalarType "tid") "U" False,
+>         CatCreateScalar (ScalarType "xid") "U" False,
+>         CatCreateScalar (ScalarType "cid") "U" False,
+>         CatCreateScalar (ScalarType "oidvector") "A" False,
+>         CatCreateScalar (ScalarType "xml") "U" False,
+>         CatCreateScalar (ScalarType "point") "G" False,
+>         CatCreateScalar (ScalarType "lseg") "G" False,
+>         CatCreateScalar (ScalarType "path") "G" False,
+>         CatCreateScalar (ScalarType "box") "G" False,
+>         CatCreateScalar (ScalarType "polygon") "G" False,
+>         CatCreateScalar (ScalarType "line") "G" False,
+>         CatCreateScalar (ScalarType "float4") "N" False,
+>         CatCreateScalar (ScalarType "float8") "N" True,
+>         CatCreateScalar (ScalarType "abstime") "D" False,
+>         CatCreateScalar (ScalarType "reltime") "T" False,
+>         CatCreateScalar (ScalarType "tinterval") "T" False,
+>         CatCreateScalar (ScalarType "circle") "G" False,
+>         CatCreateScalar (ScalarType "money") "N" False,
+>         CatCreateScalar (ScalarType "macaddr") "U" False,
+>         CatCreateScalar (ScalarType "inet") "I" True,
+>         CatCreateScalar (ScalarType "cidr") "I" False,
+>         CatCreateScalar (ScalarType "aclitem") "U" False,
+>         CatCreateScalar (ScalarType "bpchar") "S" False,
+>         CatCreateScalar (ScalarType "varchar") "S" False,
+>         CatCreateScalar (ScalarType "date") "D" False,
+>         CatCreateScalar (ScalarType "time") "D" False,
+>         CatCreateScalar (ScalarType "timestamp") "D" False,
+>         CatCreateScalar (ScalarType "timestamptz") "D" True,
+>         CatCreateScalar (ScalarType "interval") "T" True,
+>         CatCreateScalar (ScalarType "timetz") "D" False,
+>         CatCreateScalar (ScalarType "bit") "V" False,
+>         CatCreateScalar (ScalarType "varbit") "V" True,
+>         CatCreateScalar (ScalarType "numeric") "N" False,
+>         CatCreateScalar (ScalarType "refcursor") "U" False,
+>         CatCreateScalar (ScalarType "regprocedure") "N" False,
+>         CatCreateScalar (ScalarType "regoper") "N" False,
+>         CatCreateScalar (ScalarType "regoperator") "N" False,
+>         CatCreateScalar (ScalarType "regclass") "N" False,
+>         CatCreateScalar (ScalarType "regtype") "N" False,
+>         CatCreateScalar (ScalarType "uuid") "U" False,
+>         CatCreateScalar (ScalarType "tsvector") "U" False,
+>         CatCreateScalar (ScalarType "gtsvector") "U" False,
+>         CatCreateScalar (ScalarType "tsquery") "U" False,
+>         CatCreateScalar (ScalarType "regconfig") "N" False,
+>         CatCreateScalar (ScalarType "regdictionary") "N" False,
+>         CatCreateScalar (ScalarType "txid_snapshot") "U" False,
+>         CatCreateDomain (DomainType "information_schema.cardinal_number")
+>           (ScalarType "int4"),
+>         CatCreateDomain (DomainType "information_schema.character_data")
+>           (ScalarType "varchar"),
+>         CatCreateDomain (DomainType "information_schema.sql_identifier")
+>           (ScalarType "varchar"),
+>         CatCreateDomain (DomainType "information_schema.time_stamp")
+>           (ScalarType "timestamptz"),
+>         CatCreateCast (ScalarType "int8") (ScalarType "int2")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "float4")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "float8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "numeric")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "int8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "int4")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "float4")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "float8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "numeric")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "int8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "int2")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "float4")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "float8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "numeric")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "float4") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float4") (ScalarType "int2")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float4") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float4") (ScalarType "float8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "float4") (ScalarType "numeric")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float8") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float8") (ScalarType "int2")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float8") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float8") (ScalarType "float4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "float8") (ScalarType "numeric")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "int2")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "float4")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "float8")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "bool")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "bool") (ScalarType "int4")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regproc")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regproc") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regproc")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regproc")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regproc")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regproc") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regproc") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regproc") (ScalarType "regprocedure")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regprocedure") (ScalarType "regproc")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regprocedure")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regprocedure") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regprocedure")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regprocedure")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regprocedure")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regprocedure") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regprocedure") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regoper")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regoper") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regoper")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regoper")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regoper")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regoper") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regoper") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regoper") (ScalarType "regoperator")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regoperator") (ScalarType "regoper")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regoperator")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regoperator") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regoperator")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regoperator")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regoperator")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regoperator") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regoperator") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regclass") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regclass") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regclass") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regtype")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regtype") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regtype")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regtype")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regtype")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regtype") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regtype") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regconfig")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regconfig") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regconfig")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regconfig")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regconfig")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regconfig") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regconfig") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "oid") (ScalarType "regdictionary")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regdictionary") (ScalarType "oid")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "regdictionary")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int2") (ScalarType "regdictionary")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "regdictionary")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "regdictionary") (ScalarType "int8")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "regdictionary") (ScalarType "int4")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "regclass")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "bpchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "varchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "text")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "varchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "text")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "bpchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "char") (ScalarType "text")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "char") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "char") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "name") (ScalarType "text")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "name") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "name") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "char")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "char")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "char")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "name")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "name")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "name")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "char") (ScalarType "int4")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "char")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "abstime") (ScalarType "date")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "abstime") (ScalarType "time")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "abstime") (ScalarType "timestamp")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "abstime") (ScalarType "timestamptz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "reltime") (ScalarType "interval")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "date") (ScalarType "timestamp")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "date") (ScalarType "timestamptz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "time") (ScalarType "interval")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "time") (ScalarType "timetz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "timestamp") (ScalarType "abstime")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamp") (ScalarType "date")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamp") (ScalarType "time")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamp") (ScalarType "timestamptz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "abstime")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "date")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "time")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "timestamp")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "timetz")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "interval") (ScalarType "reltime")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "interval") (ScalarType "time")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "timetz") (ScalarType "time")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "abstime")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "abstime") (ScalarType "int4")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "reltime")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "reltime") (ScalarType "int4")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "lseg") (ScalarType "point")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "path") (ScalarType "point")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "path") (ScalarType "polygon")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "box") (ScalarType "point")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "box") (ScalarType "lseg")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "box") (ScalarType "polygon")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "box") (ScalarType "circle")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "polygon") (ScalarType "point")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "polygon") (ScalarType "path")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "polygon") (ScalarType "box")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "polygon") (ScalarType "circle")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "circle") (ScalarType "point")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "circle") (ScalarType "box")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "circle") (ScalarType "polygon")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "cidr") (ScalarType "inet")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "inet") (ScalarType "cidr")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bit") (ScalarType "varbit")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varbit") (ScalarType "bit")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "int8") (ScalarType "bit")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "int4") (ScalarType "bit")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "bit") (ScalarType "int8")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "bit") (ScalarType "int4")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "cidr") (ScalarType "text")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "inet") (ScalarType "text")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bool") (ScalarType "text")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "xml") (ScalarType "text")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "text") (ScalarType "xml")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "cidr") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "inet") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bool") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "xml") (ScalarType "varchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "xml")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "cidr") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "inet") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bool") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "xml") (ScalarType "bpchar")
+>           AssignmentCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "xml")
+>           ExplicitCastContext,
+>         CatCreateCast (ScalarType "bpchar") (ScalarType "bpchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varchar") (ScalarType "varchar")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "time") (ScalarType "time")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "timestamp") (ScalarType "timestamp")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "timestamptz") (ScalarType "timestamptz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "interval") (ScalarType "interval")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "timetz") (ScalarType "timetz")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "bit") (ScalarType "bit")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "varbit") (ScalarType "varbit")
+>           ImplicitCastContext,
+>         CatCreateCast (ScalarType "numeric") (ScalarType "numeric")
+>           ImplicitCastContext,
+>         CatCreateFunction FunPrefix "~" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunPrefix "~" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "~" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunPrefix "~" [ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunPrefix "~" [ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunPrefix "||/" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "|/" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "|" [ScalarType "tinterval"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunPrefix "@@" [ScalarType "circle"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunPrefix "@@" [ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunPrefix "@@" [ScalarType "path"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunPrefix "@@" [ScalarType "polygon"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunPrefix "@@" [ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunPrefix "@-@" [ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "@-@" [ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunPrefix "@" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunPrefix "?|" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunPrefix "?|" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunPrefix "?-" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunPrefix "?-" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "-" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunPrefix "+" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "#" [ScalarType "path"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "#" [ScalarType "polygon"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunPrefix "!!" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunPrefix "!!" [ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunPostfix "!" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "~~*"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~*"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~*"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~>~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~>~"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~>=~"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~>=~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~="
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~="
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~="
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~="
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~="
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~<~"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~<~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~<=~"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~<=~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~*"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~*"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~*"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "polygon", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "~"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "||" [Pseudo AnyArray, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "varbit")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [Pseudo AnyElement, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [Pseudo AnyNonArray, ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [Pseudo AnyArray, Pseudo AnyElement]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunBinary "||"
+>           [ScalarType "text", Pseudo AnyNonArray]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunBinary "|>>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|>>"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|>>"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|&>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|&>"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|&>"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "|"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "|"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "|"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "|"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunBinary "|"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunBinary "^"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "^"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "@@@"
+>           [ScalarType "tsquery", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@@@"
+>           [ScalarType "tsvector", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@@"
+>           [ScalarType "text", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@@"
+>           [ScalarType "tsquery", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@@"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@@"
+>           [ScalarType "tsvector", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "polygon", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "@>"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?||"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?||"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?|"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?-|"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?-|"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?-"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "?#"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">^"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">^"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>="
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">>"
+>           [ScalarType "bit", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">=" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">=" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">=" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">="
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary ">"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "aclitem", ScalarType "aclitem"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int2vector", ScalarType "int2vector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "=" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "cid", ScalarType "cid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "xid", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "=" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "=" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "xid", ScalarType "xid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "="
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<^"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<^"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<@"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<?>"
+>           [ScalarType "abstime", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<>"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<=" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<=" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<=" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<="
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<|"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<|"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<|"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<="
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "bit", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "<<"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "circle", ScalarType "polygon"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<->"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "<#>"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "tinterval")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<" [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<" [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "<"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "money", ScalarType "float4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "money", ScalarType "int4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "interval", ScalarType "float8"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "money", ScalarType "int2"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "money", ScalarType "float8"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "/"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "date", ScalarType "int4"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "date", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ArrayType (ScalarType "aclitem"))
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "inet", ScalarType "int8"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "time", ScalarType "interval"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "timetz", ScalarType "interval"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "abstime", ScalarType "reltime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "-"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "date", ScalarType "time"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "timetz", ScalarType "interval"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "time", ScalarType "interval"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "time", ScalarType "date"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "date", ScalarType "timetz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int8", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ArrayType (ScalarType "aclitem"))
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "inet", ScalarType "int8"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "date"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "date", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "timetz", ScalarType "date"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "date", ScalarType "int4"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "int4", ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "abstime", ScalarType "reltime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunBinary "+"
+>           [ScalarType "interval", ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "money", ScalarType "float4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float4", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "money", ScalarType "float8"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "money", ScalarType "int4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "money", ScalarType "int2"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float8", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int4", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int2", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float8", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "interval", ScalarType "float8"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "*"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunBinary "&>"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&>"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&>"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<|"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<|"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<|"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&<"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&" [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "&&"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunBinary "&"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunBinary "&"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunBinary "&"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "&"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "&"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "%"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "%"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunBinary "%"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "%"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "#>="
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "#>"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "#="
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "#<>"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "#<="
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "#<"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "line", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "##"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunBinary "#"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunBinary "!~~*"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~*"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~*"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~~"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~*"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~*"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~*"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunBinary "!~"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "RI_FKey_cascade_del" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_cascade_upd" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_check_ins" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_check_upd" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_noaction_del" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_noaction_upd" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_restrict_del" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_restrict_upd" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_setdefault_del" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_setdefault_upd" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_setnull_del" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "RI_FKey_setnull_upd" [] (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "abbrev" [ScalarType "cidr"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "abbrev" [ScalarType "inet"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "abs" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "abstime" [ScalarType "timestamp"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "abstime" [ScalarType "timestamptz"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "abstimeeq"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimege"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimegt"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimein" [Pseudo Cstring]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "abstimele"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimelt"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimene"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "abstimeout" [ScalarType "abstime"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "abstimerecv" [Pseudo Internal]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "abstimesend" [ScalarType "abstime"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "aclcontains"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "aclinsert"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ArrayType (ScalarType "aclitem"))
+>           False,
+>         CatCreateFunction FunName "aclitemeq"
+>           [ScalarType "aclitem", ScalarType "aclitem"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "aclitemin" [Pseudo Cstring]
+>           (ScalarType "aclitem")
+>           False,
+>         CatCreateFunction FunName "aclitemout" [ScalarType "aclitem"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "aclremove"
+>           [ArrayType (ScalarType "aclitem"), ScalarType "aclitem"]
+>           (ArrayType (ScalarType "aclitem"))
+>           False,
+>         CatCreateFunction FunName "acos" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "age" [ScalarType "xid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "age" [ScalarType "timestamp"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "age" [ScalarType "timestamptz"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "age"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "age"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "any_in" [Pseudo Cstring] (Pseudo Any)
+>           False,
+>         CatCreateFunction FunName "any_out" [Pseudo Any] (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "anyarray_in" [Pseudo Cstring]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "anyarray_out" [Pseudo AnyArray]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "anyarray_recv" [Pseudo Internal]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "anyarray_send" [Pseudo AnyArray]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "anyelement_in" [Pseudo Cstring]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunName "anyelement_out" [Pseudo AnyElement]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "anyenum_in" [Pseudo Cstring]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "anyenum_out" [Pseudo AnyEnum]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "anynonarray_in" [Pseudo Cstring]
+>           (Pseudo AnyNonArray)
+>           False,
+>         CatCreateFunction FunName "anynonarray_out" [Pseudo AnyNonArray]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "anytextcat"
+>           [Pseudo AnyNonArray, ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "area" [ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "area" [ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "area" [ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "areajoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "areasel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "array_agg_finalfn" [Pseudo Internal]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_agg_transfn"
+>           [Pseudo Internal, Pseudo AnyElement]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "array_append"
+>           [Pseudo AnyArray, Pseudo AnyElement]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_cat"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_dims" [Pseudo AnyArray]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "array_eq"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_fill"
+>           [Pseudo AnyElement, ArrayType (ScalarType "int4")]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_fill"
+>           [Pseudo AnyElement, ArrayType (ScalarType "int4"),
+>            ArrayType (ScalarType "int4")]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_ge"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_gt"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_larger"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_le"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_length"
+>           [Pseudo AnyArray, ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "array_lower"
+>           [Pseudo AnyArray, ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "array_lt"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_ndims" [Pseudo AnyArray]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "array_ne"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "array_out" [Pseudo AnyArray]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "array_prepend"
+>           [Pseudo AnyElement, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_send" [Pseudo AnyArray]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "array_smaller"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "array_to_string"
+>           [Pseudo AnyArray, ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "array_upper"
+>           [Pseudo AnyArray, ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "arraycontained"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "arraycontains"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "arrayoverlap"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ascii" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "ascii_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "ascii_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "asin" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "atan" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "atan2"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "big5_to_euc_tw"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "big5_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "big5_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "bit"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bit"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bit"
+>           [ScalarType "bit", ScalarType "int4", ScalarType "bool"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bit_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bit_length" [ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bit_length" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bit_length" [ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bit_out" [ScalarType "bit"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "bit_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bit_send" [ScalarType "bit"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "bitand"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bitcat"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "varbit")
+>           False,
+>         CatCreateFunction FunName "bitcmp"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "biteq"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitge"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitgt"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitle"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitlt"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitne"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bitnot" [ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bitor"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bitshiftleft"
+>           [ScalarType "bit", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bitshiftright"
+>           [ScalarType "bit", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bittypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bittypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "bitxor"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "bool" [ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "booland_statefunc"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "booleq"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolge"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolgt"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolin" [Pseudo Cstring]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolle"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boollt"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolne"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolor_statefunc"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolout" [ScalarType "bool"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "boolrecv" [Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "boolsend" [ScalarType "bool"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "box" [ScalarType "polygon"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box" [ScalarType "circle"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_above"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_above_eq"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_add"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_below"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_below_eq"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_center" [ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "box_contain"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_contained"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_distance"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "box_div"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_eq"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_ge"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_gt"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_in" [Pseudo Cstring]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_intersect"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_le"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_left"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_lt"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_mul"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_out" [ScalarType "box"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "box_overabove"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_overbelow"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_overlap"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_overleft"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_overright"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_recv" [Pseudo Internal]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "box_right"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_same"
+>           [ScalarType "box", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "box_send" [ScalarType "box"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "box_sub"
+>           [ScalarType "box", ScalarType "point"]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "bpchar" [ScalarType "char"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpchar" [ScalarType "name"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpchar"
+>           [ScalarType "bpchar", ScalarType "int4", ScalarType "bool"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpchar_larger"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpchar_pattern_ge"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchar_pattern_gt"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchar_pattern_le"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchar_pattern_lt"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchar_smaller"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpcharcmp"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bpchareq"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharge"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchargt"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpchariclike"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharicnlike"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharicregexeq"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharicregexne"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharin"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpcharle"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharlike"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharlt"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharne"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharnlike"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharout" [ScalarType "bpchar"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "bpcharrecv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunName "bpcharregexeq"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharregexne"
+>           [ScalarType "bpchar", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bpcharsend" [ScalarType "bpchar"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "bpchartypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bpchartypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "broadcast" [ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "btabstimecmp"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btarraycmp"
+>           [Pseudo AnyArray, Pseudo AnyArray]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btbeginscan"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "btboolcmp"
+>           [ScalarType "bool", ScalarType "bool"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btbpchar_pattern_cmp"
+>           [ScalarType "bpchar", ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btbuild"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "btbulkdelete"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "btcharcmp"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btcostestimate"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "btendscan" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "btfloat48cmp"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btfloat4cmp"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btfloat84cmp"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btfloat8cmp"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btgetbitmap"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "btgettuple"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "btinsert"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "btint24cmp"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint28cmp"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint2cmp"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint42cmp"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint48cmp"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint4cmp"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint82cmp"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint84cmp"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btint8cmp"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btmarkpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "btnamecmp"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btoidcmp"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btoidvectorcmp"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btoptions"
+>           [ArrayType (ScalarType "text"), ScalarType "bool"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "btrecordcmp"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btreltimecmp"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btrescan"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "btrestrpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "btrim" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "btrim"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "btrim"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "bttext_pattern_cmp"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bttextcmp"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bttidcmp"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "bttintervalcmp"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "btvacuumcleanup"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "byteacat"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "byteacmp"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "byteaeq"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteage"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteagt"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteain" [Pseudo Cstring]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "byteale"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bytealike"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "bytealt"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteane"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteanlike"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "byteaout" [ScalarType "bytea"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "bytearecv" [Pseudo Internal]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "byteasend" [ScalarType "bytea"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "cash_cmp"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "cash_div_flt4"
+>           [ScalarType "money", ScalarType "float4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_div_flt8"
+>           [ScalarType "money", ScalarType "float8"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_div_int2"
+>           [ScalarType "money", ScalarType "int2"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_div_int4"
+>           [ScalarType "money", ScalarType "int4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_eq"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_ge"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_gt"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_in" [Pseudo Cstring]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_le"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_lt"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_mi"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_mul_flt4"
+>           [ScalarType "money", ScalarType "float4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_mul_flt8"
+>           [ScalarType "money", ScalarType "float8"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_mul_int2"
+>           [ScalarType "money", ScalarType "int2"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_mul_int4"
+>           [ScalarType "money", ScalarType "int4"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_ne"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cash_out" [ScalarType "money"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cash_pl"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_recv" [Pseudo Internal]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cash_send" [ScalarType "money"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "cash_words" [ScalarType "money"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "cashlarger"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cashsmaller"
+>           [ScalarType "money", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "cbrt" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "ceil" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "ceil" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "ceiling" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "ceiling" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "center" [ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "center" [ScalarType "circle"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "char" [ScalarType "int4"]
+>           (ScalarType "char")
+>           False,
+>         CatCreateFunction FunName "char" [ScalarType "text"]
+>           (ScalarType "char")
+>           False,
+>         CatCreateFunction FunName "char_length" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "char_length" [ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "character_length" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "character_length" [ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "chareq"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "charge"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "chargt"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "charin" [Pseudo Cstring]
+>           (ScalarType "char")
+>           False,
+>         CatCreateFunction FunName "charle"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "charlt"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "charne"
+>           [ScalarType "char", ScalarType "char"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "charout" [ScalarType "char"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "charrecv" [Pseudo Internal]
+>           (ScalarType "char")
+>           False,
+>         CatCreateFunction FunName "charsend" [ScalarType "char"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "chr" [ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "cideq"
+>           [ScalarType "cid", ScalarType "cid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "cidin" [Pseudo Cstring]
+>           (ScalarType "cid")
+>           False,
+>         CatCreateFunction FunName "cidout" [ScalarType "cid"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cidr" [ScalarType "inet"]
+>           (ScalarType "cidr")
+>           False,
+>         CatCreateFunction FunName "cidr_in" [Pseudo Cstring]
+>           (ScalarType "cidr")
+>           False,
+>         CatCreateFunction FunName "cidr_out" [ScalarType "cidr"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cidr_recv" [Pseudo Internal]
+>           (ScalarType "cidr")
+>           False,
+>         CatCreateFunction FunName "cidr_send" [ScalarType "cidr"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "cidrecv" [Pseudo Internal]
+>           (ScalarType "cid")
+>           False,
+>         CatCreateFunction FunName "cidsend" [ScalarType "cid"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "circle" [ScalarType "box"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle" [ScalarType "polygon"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle"
+>           [ScalarType "point", ScalarType "float8"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_above"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_add_pt"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_below"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_center" [ScalarType "circle"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "circle_contain"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_contain_pt"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_contained"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_distance"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "circle_div_pt"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_eq"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_ge"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_gt"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_in" [Pseudo Cstring]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_le"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_left"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_lt"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_mul_pt"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_ne"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_out" [ScalarType "circle"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "circle_overabove"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_overbelow"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_overlap"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_overleft"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_overright"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_recv" [Pseudo Internal]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "circle_right"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_same"
+>           [ScalarType "circle", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "circle_send" [ScalarType "circle"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "circle_sub_pt"
+>           [ScalarType "circle", ScalarType "point"]
+>           (ScalarType "circle")
+>           False,
+>         CatCreateFunction FunName "clock_timestamp" []
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "close_lb"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_ls"
+>           [ScalarType "line", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_lseg"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_pb"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_pl"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_ps"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_sb"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "close_sl"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "col_description"
+>           [ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "contjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "contsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "convert"
+>           [ScalarType "bytea", ScalarType "name", ScalarType "name"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "convert_from"
+>           [ScalarType "bytea", ScalarType "name"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "convert_to"
+>           [ScalarType "text", ScalarType "name"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "cos" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "cot" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "cstring_in" [Pseudo Cstring]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cstring_out" [Pseudo Cstring]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cstring_recv" [Pseudo Internal]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "cstring_send" [Pseudo Cstring]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "current_database" [] (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "current_query" [] (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "current_schema" [] (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "current_schemas" [ScalarType "bool"]
+>           (ArrayType (ScalarType "name"))
+>           False,
+>         CatCreateFunction FunName "current_setting" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "current_user" [] (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "currtid"
+>           [ScalarType "oid", ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "currtid2"
+>           [ScalarType "text", ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "currval" [ScalarType "regclass"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "cursor_to_xml"
+>           [ScalarType "refcursor", ScalarType "int4", ScalarType "bool",
+>            ScalarType "bool", ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "cursor_to_xmlschema"
+>           [ScalarType "refcursor", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "database_to_xml"
+>           [ScalarType "bool", ScalarType "bool", ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "database_to_xml_and_xmlschema"
+>           [ScalarType "bool", ScalarType "bool", ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "database_to_xmlschema"
+>           [ScalarType "bool", ScalarType "bool", ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "date" [ScalarType "abstime"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date" [ScalarType "timestamp"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date" [ScalarType "timestamptz"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_cmp"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "date_cmp_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "date_cmp_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "date_eq"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_eq_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_eq_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_ge"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_ge_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_ge_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_gt"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_gt_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_gt_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_in" [Pseudo Cstring]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_larger"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_le"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_le_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_le_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_lt"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_lt_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_lt_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_mi"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "date_mi_interval"
+>           [ScalarType "date", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "date_mii"
+>           [ScalarType "date", ScalarType "int4"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_ne"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_ne_timestamp"
+>           [ScalarType "date", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_ne_timestamptz"
+>           [ScalarType "date", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "date_out" [ScalarType "date"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "abstime"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "reltime"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "date"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "time"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "timestamp"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "timestamptz"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "interval"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_part"
+>           [ScalarType "text", ScalarType "timetz"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "date_pl_interval"
+>           [ScalarType "date", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "date_pli"
+>           [ScalarType "date", ScalarType "int4"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_recv" [Pseudo Internal]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_send" [ScalarType "date"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "date_smaller"
+>           [ScalarType "date", ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "date_trunc"
+>           [ScalarType "text", ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "date_trunc"
+>           [ScalarType "text", ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "date_trunc"
+>           [ScalarType "text", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "datetime_pl"
+>           [ScalarType "date", ScalarType "time"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "datetimetz_pl"
+>           [ScalarType "date", ScalarType "timetz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "dcbrt" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "decode"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "degrees" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dexp" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "diagonal" [ScalarType "box"]
+>           (ScalarType "lseg")
+>           False,
+>         CatCreateFunction FunName "diameter" [ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dispell_init" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dispell_lexize"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dist_cpoly"
+>           [ScalarType "circle", ScalarType "polygon"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_lb"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_pb"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_pc"
+>           [ScalarType "point", ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_pl"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_ppath"
+>           [ScalarType "point", ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_ps"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_sb"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dist_sl"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "div"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "dlog1" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dlog10" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "domain_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo Any)
+>           False,
+>         CatCreateFunction FunName "domain_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo Any)
+>           False,
+>         CatCreateFunction FunName "dpow"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dround" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dsimple_init" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dsimple_lexize"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dsnowball_init" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dsnowball_lexize"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dsqrt" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "dsynonym_init" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dsynonym_lexize"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "dtrunc" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "encode"
+>           [ScalarType "bytea", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "enum_cmp"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "enum_eq"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_first" [Pseudo AnyEnum]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "enum_ge"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_gt"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_in"
+>           [Pseudo Cstring, ScalarType "oid"]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "enum_larger"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "enum_last" [Pseudo AnyEnum]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "enum_le"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_lt"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_ne"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "enum_out" [Pseudo AnyEnum]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "enum_range" [Pseudo AnyEnum]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "enum_range"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunName "enum_recv"
+>           [Pseudo Cstring, ScalarType "oid"]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "enum_send" [Pseudo AnyEnum]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "enum_smaller"
+>           [Pseudo AnyEnum, Pseudo AnyEnum]
+>           (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunName "eqjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "eqsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "euc_cn_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_cn_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_jis_2004_to_shift_jis_2004"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_jis_2004_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_jp_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_jp_to_sjis"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_jp_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_kr_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_kr_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_tw_to_big5"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_tw_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "euc_tw_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "exp" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "exp" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "factorial" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "family" [ScalarType "inet"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "flatfile_update_trigger" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "float4" [ScalarType "int8"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4" [ScalarType "int2"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4" [ScalarType "int4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4" [ScalarType "float8"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4" [ScalarType "numeric"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float48div"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float48eq"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48ge"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48gt"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48le"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48lt"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48mi"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float48mul"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float48ne"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float48pl"
+>           [ScalarType "float4", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float4_accum"
+>           [ArrayType (ScalarType "float8"), ScalarType "float4"]
+>           (ArrayType (ScalarType "float8"))
+>           False,
+>         CatCreateFunction FunName "float4abs" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4div"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4eq"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4ge"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4gt"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4in" [Pseudo Cstring]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4larger"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4le"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4lt"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4mi"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4mul"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4ne"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float4out" [ScalarType "float4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "float4pl"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4recv" [Pseudo Internal]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4send" [ScalarType "float4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "float4smaller"
+>           [ScalarType "float4", ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4um" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float4up" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "float8" [ScalarType "int8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8" [ScalarType "int2"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8" [ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8" [ScalarType "numeric"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float84div"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float84eq"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84ge"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84gt"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84le"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84lt"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84mi"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float84mul"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float84ne"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float84pl"
+>           [ScalarType "float8", ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_accum"
+>           [ArrayType (ScalarType "float8"), ScalarType "float8"]
+>           (ArrayType (ScalarType "float8"))
+>           False,
+>         CatCreateFunction FunName "float8_avg"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_corr"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_covar_pop"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_covar_samp"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_accum"
+>           [ArrayType (ScalarType "float8"), ScalarType "float8",
+>            ScalarType "float8"]
+>           (ArrayType (ScalarType "float8"))
+>           False,
+>         CatCreateFunction FunName "float8_regr_avgx"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_avgy"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_intercept"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_r2"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_slope"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_sxx"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_sxy"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_regr_syy"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_stddev_pop"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_stddev_samp"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_var_pop"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8_var_samp"
+>           [ArrayType (ScalarType "float8")]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8abs" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8div"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8eq"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8ge"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8gt"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8in" [Pseudo Cstring]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8larger"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8le"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8lt"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8mi"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8mul"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8ne"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "float8out" [ScalarType "float8"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "float8pl"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8recv" [Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8send" [ScalarType "float8"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "float8smaller"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8um" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "float8up" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "floor" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "floor" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "flt4_mul_cash"
+>           [ScalarType "float4", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "flt8_mul_cash"
+>           [ScalarType "float8", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "fmgr_c_validator" [ScalarType "oid"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "fmgr_internal_validator"
+>           [ScalarType "oid"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "fmgr_sql_validator" [ScalarType "oid"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "format_type"
+>           [ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "gb18030_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gbk_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (SetOfType (ScalarType "int8"))
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (SetOfType (ScalarType "int4"))
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "int8", ScalarType "int8", ScalarType "int8"]
+>           (SetOfType (ScalarType "int8"))
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "int4", ScalarType "int4", ScalarType "int4"]
+>           (SetOfType (ScalarType "int4"))
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "timestamp", ScalarType "timestamp",
+>            ScalarType "interval"]
+>           (SetOfType (ScalarType "timestamp"))
+>           False,
+>         CatCreateFunction FunName "generate_series"
+>           [ScalarType "timestamptz", ScalarType "timestamptz",
+>            ScalarType "interval"]
+>           (SetOfType (ScalarType "timestamptz"))
+>           False,
+>         CatCreateFunction FunName "generate_subscripts"
+>           [Pseudo AnyArray, ScalarType "int4"]
+>           (SetOfType (ScalarType "int4"))
+>           False,
+>         CatCreateFunction FunName "generate_subscripts"
+>           [Pseudo AnyArray, ScalarType "int4", ScalarType "bool"]
+>           (SetOfType (ScalarType "int4"))
+>           False,
+>         CatCreateFunction FunName "get_bit"
+>           [ScalarType "bytea", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "get_byte"
+>           [ScalarType "bytea", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "get_current_ts_config" []
+>           (ScalarType "regconfig")
+>           False,
+>         CatCreateFunction FunName "getdatabaseencoding" []
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "getpgusername" [] (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "gin_cmp_prefix"
+>           [ScalarType "text", ScalarType "text", ScalarType "int2",
+>            Pseudo Internal]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "gin_cmp_tslexeme"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "gin_extract_tsquery"
+>           [ScalarType "tsquery", Pseudo Internal, ScalarType "int2",
+>            Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gin_extract_tsvector"
+>           [ScalarType "tsvector", Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gin_tsquery_consistent"
+>           [Pseudo Internal, ScalarType "int2", ScalarType "tsquery",
+>            ScalarType "int4", Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ginarrayconsistent"
+>           [Pseudo Internal, ScalarType "int2", Pseudo AnyArray,
+>            ScalarType "int4", Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ginarrayextract"
+>           [Pseudo AnyArray, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "ginbeginscan"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "ginbuild"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "ginbulkdelete"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gincostestimate"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "ginendscan" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gingetbitmap"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "gininsert"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ginmarkpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "ginoptions"
+>           [ArrayType (ScalarType "text"), ScalarType "bool"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "ginqueryarrayextract"
+>           [Pseudo AnyArray, Pseudo Internal, ScalarType "int2",
+>            Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "ginrescan"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "ginrestrpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "ginvacuumcleanup"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_compress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_consistent"
+>           [Pseudo Internal, ScalarType "box", ScalarType "int4",
+>            ScalarType "oid", Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gist_box_decompress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_penalty"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_picksplit"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_same"
+>           [ScalarType "box", ScalarType "box", Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_box_union"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "box")
+>           False,
+>         CatCreateFunction FunName "gist_circle_compress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_circle_consistent"
+>           [Pseudo Internal, ScalarType "circle", ScalarType "int4",
+>            ScalarType "oid", Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gist_poly_compress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gist_poly_consistent"
+>           [Pseudo Internal, ScalarType "polygon", ScalarType "int4",
+>            ScalarType "oid", Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gistbeginscan"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gistbuild"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gistbulkdelete"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gistcostestimate"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gistendscan" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gistgetbitmap"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "gistgettuple"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gistinsert"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gistmarkpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gistoptions"
+>           [ArrayType (ScalarType "text"), ScalarType "bool"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "gistrescan"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gistrestrpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "gistvacuumcleanup"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_compress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_consistent"
+>           [Pseudo Internal, Pseudo Internal, ScalarType "int4",
+>            ScalarType "oid", Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gtsquery_decompress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_penalty"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_picksplit"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_same"
+>           [ScalarType "int8", ScalarType "int8", Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsquery_union"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_compress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_consistent"
+>           [Pseudo Internal, ScalarType "gtsvector", ScalarType "int4",
+>            ScalarType "oid", Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "gtsvector_decompress" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_penalty"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_picksplit"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_same"
+>           [ScalarType "gtsvector", ScalarType "gtsvector", Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvector_union"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "gtsvectorin" [Pseudo Cstring]
+>           (ScalarType "gtsvector")
+>           False,
+>         CatCreateFunction FunName "gtsvectorout" [ScalarType "gtsvector"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_any_column_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "text", ScalarType "int2", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "int2", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "int2",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "int2",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "int2",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "int2",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_column_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text",
+>            ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_database_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_foreign_data_wrapper_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_function_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_language_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_schema_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_server_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_table_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "name", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "oid", ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "has_tablespace_privilege"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "hash_aclitem" [ScalarType "aclitem"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hash_numeric" [ScalarType "numeric"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashbeginscan"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "hashbpchar" [ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashbuild"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "hashbulkdelete"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "hashchar" [ScalarType "char"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashcostestimate"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "hashendscan" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "hashenum" [Pseudo AnyEnum]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashfloat4" [ScalarType "float4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashfloat8" [ScalarType "float8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashgetbitmap"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "hashgettuple"
+>           [Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "hashinet" [ScalarType "inet"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashinsert"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "hashint2" [ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashint2vector"
+>           [ScalarType "int2vector"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashint4" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashint8" [ScalarType "int8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashmacaddr" [ScalarType "macaddr"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashmarkpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "hashname" [ScalarType "name"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashoid" [ScalarType "oid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashoidvector" [ScalarType "oidvector"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashoptions"
+>           [ArrayType (ScalarType "text"), ScalarType "bool"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "hashrescan"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "hashrestrpos" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "hashtext" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "hashvacuumcleanup"
+>           [Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "hashvarlena" [Pseudo Internal]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "height" [ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "host" [ScalarType "inet"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "hostmask" [ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "iclikejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "iclikesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icnlikejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icnlikesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icregexeqjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icregexeqsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icregexnejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "icregexnesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "inet_client_addr" [] (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inet_client_port" [] (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "inet_in" [Pseudo Cstring]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inet_out" [ScalarType "inet"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "inet_recv" [Pseudo Internal]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inet_send" [ScalarType "inet"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "inet_server_addr" [] (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inet_server_port" [] (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "inetand"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inetmi"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "inetmi_int8"
+>           [ScalarType "inet", ScalarType "int8"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inetnot" [ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inetor"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "inetpl"
+>           [ScalarType "inet", ScalarType "int8"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "initcap" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "int2" [ScalarType "int8"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2" [ScalarType "int4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2" [ScalarType "float4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2" [ScalarType "float8"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2" [ScalarType "numeric"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int24div"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int24eq"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24ge"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24gt"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24le"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24lt"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24mi"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int24mul"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int24ne"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int24pl"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int28div"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int28eq"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28ge"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28gt"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28le"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28lt"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28mi"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int28mul"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int28ne"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int28pl"
+>           [ScalarType "int2", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int2_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "int2"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "int2_avg_accum"
+>           [ArrayType (ScalarType "int8"), ScalarType "int2"]
+>           (ArrayType (ScalarType "int8"))
+>           False,
+>         CatCreateFunction FunName "int2_mul_cash"
+>           [ScalarType "int2", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "int2_sum"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int2abs" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2and"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2div"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2eq"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2ge"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2gt"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2in" [Pseudo Cstring]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2larger"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2le"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2lt"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2mi"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2mod"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2mul"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2ne"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2not" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2or"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2out" [ScalarType "int2"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "int2pl"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2recv" [Pseudo Internal]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2send" [ScalarType "int2"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "int2shl"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2shr"
+>           [ScalarType "int2", ScalarType "int4"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2smaller"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2um" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2up" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int2vectoreq"
+>           [ScalarType "int2vector", ScalarType "int2vector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int2vectorin" [Pseudo Cstring]
+>           (ScalarType "int2vector")
+>           False,
+>         CatCreateFunction FunName "int2vectorout" [ScalarType "int2vector"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "int2vectorrecv" [Pseudo Internal]
+>           (ScalarType "int2vector")
+>           False,
+>         CatCreateFunction FunName "int2vectorsend"
+>           [ScalarType "int2vector"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "int2xor"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "bool"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "char"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "int8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "float4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "float8"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4" [ScalarType "numeric"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int42div"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int42eq"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42ge"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42gt"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42le"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42lt"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42mi"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int42mul"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int42ne"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int42pl"
+>           [ScalarType "int4", ScalarType "int2"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int48div"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int48eq"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48ge"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48gt"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48le"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48lt"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48mi"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int48mul"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int48ne"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int48pl"
+>           [ScalarType "int4", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int4_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "int4"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "int4_avg_accum"
+>           [ArrayType (ScalarType "int8"), ScalarType "int4"]
+>           (ArrayType (ScalarType "int8"))
+>           False,
+>         CatCreateFunction FunName "int4_mul_cash"
+>           [ScalarType "int4", ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunName "int4_sum"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int4abs" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4and"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4div"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4eq"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4ge"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4gt"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4in" [Pseudo Cstring]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4inc" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4larger"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4le"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4lt"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4mi"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4mod"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4mul"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4ne"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int4not" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4or"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4out" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "int4pl"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4recv" [Pseudo Internal]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4send" [ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "int4shl"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4shr"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4smaller"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4um" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4up" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int4xor"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "float4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "float8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "bit"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8" [ScalarType "numeric"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int82div"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int82eq"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82ge"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82gt"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82le"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82lt"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82mi"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int82mul"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int82ne"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int82pl"
+>           [ScalarType "int8", ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int84div"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int84eq"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84ge"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84gt"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84le"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84lt"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84mi"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int84mul"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int84ne"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int84pl"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "int8"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "int8_avg"
+>           [ArrayType (ScalarType "int8")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "int8_avg_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "int8"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "int8_sum"
+>           [ScalarType "numeric", ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "int8abs" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8and"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8div"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8eq"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8ge"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8gt"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8in" [Pseudo Cstring]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8inc" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8inc_any"
+>           [ScalarType "int8", Pseudo Any]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8inc_float8_float8"
+>           [ScalarType "int8", ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8larger"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8le"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8lt"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8mi"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8mod"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8mul"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8ne"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "int8not" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8or"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8out" [ScalarType "int8"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "int8pl"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8pl_inet"
+>           [ScalarType "int8", ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "int8recv" [Pseudo Internal]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8send" [ScalarType "int8"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "int8shl"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8shr"
+>           [ScalarType "int8", ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8smaller"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8um" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8up" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "int8xor"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "integer_pl_date"
+>           [ScalarType "int4", ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "inter_lb"
+>           [ScalarType "line", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "inter_sb"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "inter_sl"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "internal_in" [Pseudo Cstring]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "internal_out" [Pseudo Internal]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "interval" [ScalarType "reltime"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval" [ScalarType "time"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval"
+>           [ScalarType "interval", ScalarType "int4"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_accum"
+>           [ArrayType (ScalarType "interval"), ScalarType "interval"]
+>           (ArrayType (ScalarType "interval"))
+>           False,
+>         CatCreateFunction FunName "interval_avg"
+>           [ArrayType (ScalarType "interval")]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_cmp"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "interval_div"
+>           [ScalarType "interval", ScalarType "float8"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_eq"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_ge"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_gt"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_hash" [ScalarType "interval"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "interval_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_larger"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_le"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_lt"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_mi"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_mul"
+>           [ScalarType "interval", ScalarType "float8"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_ne"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "interval_out" [ScalarType "interval"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "interval_pl"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_pl_date"
+>           [ScalarType "interval", ScalarType "date"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "interval_pl_time"
+>           [ScalarType "interval", ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "interval_pl_timestamp"
+>           [ScalarType "interval", ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "interval_pl_timestamptz"
+>           [ScalarType "interval", ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "interval_pl_timetz"
+>           [ScalarType "interval", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "interval_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_send" [ScalarType "interval"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "interval_smaller"
+>           [ScalarType "interval", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "interval_um" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "intervaltypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "intervaltypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "intinterval"
+>           [ScalarType "abstime", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isclosed" [ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isfinite" [ScalarType "abstime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isfinite" [ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isfinite" [ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isfinite" [ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isfinite" [ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ishorizontal" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ishorizontal" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ishorizontal"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "iso8859_1_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "iso8859_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "iso_to_koi8r"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "iso_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "iso_to_win1251"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "iso_to_win866"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "isopen" [ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isparallel"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isparallel"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isperp"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isperp"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isvertical" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isvertical" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "isvertical"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "johab_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "justify_days" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "justify_hours" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "justify_interval"
+>           [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "koi8r_to_iso"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "koi8r_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "koi8r_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "koi8r_to_win1251"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "koi8r_to_win866"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "koi8u_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "language_handler_in" [Pseudo Cstring]
+>           (Pseudo LanguageHandler)
+>           False,
+>         CatCreateFunction FunName "language_handler_out"
+>           [Pseudo LanguageHandler]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "lastval" [] (ScalarType "int8") False,
+>         CatCreateFunction FunName "latin1_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "latin2_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "latin2_to_win1250"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "latin3_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "latin4_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "length" [ScalarType "tsvector"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "length"
+>           [ScalarType "bytea", ScalarType "name"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "like"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "like"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "like"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "like_escape"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "like_escape"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "likejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "likesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "line"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "line")
+>           False,
+>         CatCreateFunction FunName "line_distance"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "line_eq"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "line_horizontal" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "line_in" [Pseudo Cstring]
+>           (ScalarType "line")
+>           False,
+>         CatCreateFunction FunName "line_interpt"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "line_intersect"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "line_out" [ScalarType "line"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "line_parallel"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "line_perp"
+>           [ScalarType "line", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "line_recv" [Pseudo Internal]
+>           (ScalarType "line")
+>           False,
+>         CatCreateFunction FunName "line_send" [ScalarType "line"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "line_vertical" [ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ln" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "ln" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "lo_close" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_creat" [ScalarType "int4"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "lo_create" [ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "lo_export"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_import" [ScalarType "text"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "lo_import"
+>           [ScalarType "text", ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "lo_lseek"
+>           [ScalarType "int4", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_open"
+>           [ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_tell" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_truncate"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lo_unlink" [ScalarType "oid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "log" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "log" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "log"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "loread"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "lower" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "lowrite"
+>           [ScalarType "int4", ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "lpad"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "lpad"
+>           [ScalarType "text", ScalarType "int4", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "lseg" [ScalarType "box"]
+>           (ScalarType "lseg")
+>           False,
+>         CatCreateFunction FunName "lseg"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "lseg")
+>           False,
+>         CatCreateFunction FunName "lseg_center" [ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "lseg_distance"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "lseg_eq"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_ge"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_gt"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_horizontal" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_in" [Pseudo Cstring]
+>           (ScalarType "lseg")
+>           False,
+>         CatCreateFunction FunName "lseg_interpt"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "lseg_intersect"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_le"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_length" [ScalarType "lseg"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "lseg_lt"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_ne"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_out" [ScalarType "lseg"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "lseg_parallel"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_perp"
+>           [ScalarType "lseg", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "lseg_recv" [Pseudo Internal]
+>           (ScalarType "lseg")
+>           False,
+>         CatCreateFunction FunName "lseg_send" [ScalarType "lseg"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "lseg_vertical" [ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ltrim" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "ltrim"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "macaddr_cmp"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "macaddr_eq"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_ge"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_gt"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_in" [Pseudo Cstring]
+>           (ScalarType "macaddr")
+>           False,
+>         CatCreateFunction FunName "macaddr_le"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_lt"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_ne"
+>           [ScalarType "macaddr", ScalarType "macaddr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "macaddr_out" [ScalarType "macaddr"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "macaddr_recv" [Pseudo Internal]
+>           (ScalarType "macaddr")
+>           False,
+>         CatCreateFunction FunName "macaddr_send" [ScalarType "macaddr"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "makeaclitem"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text",
+>            ScalarType "bool"]
+>           (ScalarType "aclitem")
+>           False,
+>         CatCreateFunction FunName "masklen" [ScalarType "inet"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "md5" [ScalarType "bytea"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "md5" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "mic_to_ascii"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_big5"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_euc_cn"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_euc_jp"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_euc_kr"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_euc_tw"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_iso"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_koi8r"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_latin1"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_latin2"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_latin3"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_latin4"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_sjis"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_win1250"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_win1251"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mic_to_win866"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "mktinterval"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "tinterval")
+>           False,
+>         CatCreateFunction FunName "mod"
+>           [ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "mod"
+>           [ScalarType "int2", ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunName "mod"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "mod"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "mul_d_interval"
+>           [ScalarType "float8", ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "name" [ScalarType "text"]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "name" [ScalarType "bpchar"]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "name" [ScalarType "varchar"]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "nameeq"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namege"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namegt"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameiclike"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameicnlike"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameicregexeq"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameicregexne"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namein" [Pseudo Cstring]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "namele"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namelike"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namelt"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namene"
+>           [ScalarType "name", ScalarType "name"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namenlike"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameout" [ScalarType "name"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "namerecv" [Pseudo Internal]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "nameregexeq"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nameregexne"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "namesend" [ScalarType "name"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "neqjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "neqsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "netmask" [ScalarType "inet"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "network" [ScalarType "inet"]
+>           (ScalarType "cidr")
+>           False,
+>         CatCreateFunction FunName "network_cmp"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "network_eq"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_ge"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_gt"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_le"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_lt"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_ne"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_sub"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_subeq"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_sup"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "network_supeq"
+>           [ScalarType "inet", ScalarType "inet"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "nextval" [ScalarType "regclass"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "nlikejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "nlikesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "notlike"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "notlike"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "notlike"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "now" [] (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "npoints" [ScalarType "path"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "npoints" [ScalarType "polygon"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "numeric" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric" [ScalarType "float4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric" [ScalarType "float8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric"
+>           [ScalarType "numeric", ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_abs" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "numeric"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "numeric_add"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_avg"
+>           [ArrayType (ScalarType "numeric")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_avg_accum"
+>           [ArrayType (ScalarType "numeric"), ScalarType "numeric"]
+>           (ArrayType (ScalarType "numeric"))
+>           False,
+>         CatCreateFunction FunName "numeric_cmp"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "numeric_div"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_div_trunc"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_eq"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_exp" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_fac" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_ge"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_gt"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_inc" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_larger"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_le"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_ln" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_log"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_lt"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_mod"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_mul"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_ne"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "numeric_out" [ScalarType "numeric"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "numeric_power"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_send" [ScalarType "numeric"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "numeric_smaller"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_sqrt" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_stddev_pop"
+>           [ArrayType (ScalarType "numeric")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_stddev_samp"
+>           [ArrayType (ScalarType "numeric")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_sub"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_uminus" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_uplus" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_var_pop"
+>           [ArrayType (ScalarType "numeric")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numeric_var_samp"
+>           [ArrayType (ScalarType "numeric")]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "numerictypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "numerictypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "numnode" [ScalarType "tsquery"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "obj_description" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "obj_description"
+>           [ScalarType "oid", ScalarType "name"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "octet_length" [ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "octet_length" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "octet_length" [ScalarType "bpchar"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "octet_length" [ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "oid" [ScalarType "int8"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "oideq"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidge"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidgt"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidin" [Pseudo Cstring]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "oidlarger"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "oidle"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidlt"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidne"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidout" [ScalarType "oid"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "oidrecv" [Pseudo Internal]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "oidsend" [ScalarType "oid"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "oidsmaller"
+>           [ScalarType "oid", ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "oidvectoreq"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorge"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorgt"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorin" [Pseudo Cstring]
+>           (ScalarType "oidvector")
+>           False,
+>         CatCreateFunction FunName "oidvectorle"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorlt"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorne"
+>           [ScalarType "oidvector", ScalarType "oidvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "oidvectorout" [ScalarType "oidvector"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "oidvectorrecv" [Pseudo Internal]
+>           (ScalarType "oidvector")
+>           False,
+>         CatCreateFunction FunName "oidvectorsend" [ScalarType "oidvector"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "oidvectortypes" [ScalarType "oidvector"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "on_pb"
+>           [ScalarType "point", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "on_pl"
+>           [ScalarType "point", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "on_ppath"
+>           [ScalarType "point", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "on_ps"
+>           [ScalarType "point", ScalarType "lseg"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "on_sb"
+>           [ScalarType "lseg", ScalarType "box"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "on_sl"
+>           [ScalarType "lseg", ScalarType "line"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "opaque_in" [Pseudo Cstring]
+>           (Pseudo Opaque)
+>           False,
+>         CatCreateFunction FunName "opaque_out" [Pseudo Opaque]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "time", ScalarType "time", ScalarType "time",
+>            ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "time", ScalarType "time", ScalarType "time",
+>            ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "time", ScalarType "interval", ScalarType "time",
+>            ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "time", ScalarType "interval", ScalarType "time",
+>            ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamp", ScalarType "timestamp",
+>            ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamp", ScalarType "timestamp",
+>            ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamp", ScalarType "interval",
+>            ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamp", ScalarType "interval",
+>            ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamptz", ScalarType "timestamptz",
+>            ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamptz", ScalarType "timestamptz",
+>            ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamptz", ScalarType "interval",
+>            ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timestamptz", ScalarType "interval",
+>            ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlaps"
+>           [ScalarType "timetz", ScalarType "timetz", ScalarType "timetz",
+>            ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "overlay"
+>           [ScalarType "text", ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "overlay"
+>           [ScalarType "text", ScalarType "text", ScalarType "int4",
+>            ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "path" [ScalarType "polygon"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_add"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_add_pt"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_center" [ScalarType "path"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "path_contain_pt"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_distance"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "path_div_pt"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_in" [Pseudo Cstring]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_inter"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_length" [ScalarType "path"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "path_mul_pt"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_n_eq"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_n_ge"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_n_gt"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_n_le"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_n_lt"
+>           [ScalarType "path", ScalarType "path"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "path_npoints" [ScalarType "path"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "path_out" [ScalarType "path"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "path_recv" [Pseudo Internal]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "path_send" [ScalarType "path"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "path_sub_pt"
+>           [ScalarType "path", ScalarType "point"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "pclose" [ScalarType "path"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "pg_advisory_lock" [ScalarType "int8"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_advisory_lock"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_advisory_lock_shared"
+>           [ScalarType "int8"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_advisory_lock_shared"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_advisory_unlock" [ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_advisory_unlock"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_advisory_unlock_all" [] (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_advisory_unlock_shared"
+>           [ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_advisory_unlock_shared"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_backend_pid" [] (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_cancel_backend" [ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_char_to_encoding" [ScalarType "name"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_client_encoding" []
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "pg_column_size" [Pseudo Any]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_conf_load_time" []
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_conversion_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_current_xlog_insert_location" []
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_current_xlog_location" []
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_cursor" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_database_size" [ScalarType "name"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_database_size" [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_encoding_to_char" [ScalarType "int4"]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "pg_function_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_get_constraintdef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_constraintdef"
+>           [ScalarType "oid", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_expr"
+>           [ScalarType "text", ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_expr"
+>           [ScalarType "text", ScalarType "oid", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_function_arguments"
+>           [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_function_identity_arguments"
+>           [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_function_result"
+>           [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_functiondef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_indexdef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_indexdef"
+>           [ScalarType "oid", ScalarType "int4", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_keywords" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_get_ruledef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_ruledef"
+>           [ScalarType "oid", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_serial_sequence"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_triggerdef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_userbyid" [ScalarType "oid"]
+>           (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "pg_get_viewdef" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_viewdef" [ScalarType "oid"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_viewdef"
+>           [ScalarType "text", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_get_viewdef"
+>           [ScalarType "oid", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "name", ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "name", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "oid", ScalarType "name", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_has_role"
+>           [ScalarType "oid", ScalarType "oid", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_is_other_temp_schema"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_lock_status" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_ls_dir" [ScalarType "text"]
+>           (SetOfType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "pg_my_temp_schema" [] (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "pg_opclass_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_operator_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_options_to_table"
+>           [ArrayType (ScalarType "text")]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_postmaster_start_time" []
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_prepared_statement" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_prepared_xact" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_read_file"
+>           [ScalarType "text", ScalarType "int8", ScalarType "int8"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_relation_size"
+>           [ScalarType "regclass"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_relation_size"
+>           [ScalarType "regclass", ScalarType "text"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_reload_conf" [] (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_rotate_logfile" []
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_show_all_settings" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_size_pretty" [ScalarType "int8"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_sleep" [ScalarType "float8"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_start_backup"
+>           [ScalarType "text", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_stat_clear_snapshot" [] (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "pg_stat_file" [ScalarType "text"]
+>           (Pseudo Record)
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_activity"
+>           [ScalarType "int4"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_activity"
+>           [ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_activity_start"
+>           [ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_client_addr"
+>           [ScalarType "int4"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_client_port"
+>           [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_dbid"
+>           [ScalarType "int4"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_idset" []
+>           (SetOfType (ScalarType "int4"))
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_pid"
+>           [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_start"
+>           [ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_userid"
+>           [ScalarType "int4"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_waiting"
+>           [ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_backend_xact_start"
+>           [ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName
+>           "pg_stat_get_bgwriter_buf_written_checkpoints"
+>           []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_bgwriter_buf_written_clean"
+>           []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_bgwriter_maxwritten_clean"
+>           []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName
+>           "pg_stat_get_bgwriter_requested_checkpoints"
+>           []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_bgwriter_timed_checkpoints"
+>           []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_blocks_fetched"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_blocks_hit"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_buf_alloc" []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_buf_written_backend" []
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_blocks_fetched"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_blocks_hit"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_numbackends"
+>           [ScalarType "oid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_tuples_deleted"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_tuples_fetched"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_tuples_inserted"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_tuples_returned"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_tuples_updated"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_xact_commit"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_db_xact_rollback"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_dead_tuples"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_function_calls"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_function_self_time"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_function_time"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_last_analyze_time"
+>           [ScalarType "oid"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_last_autoanalyze_time"
+>           [ScalarType "oid"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_last_autovacuum_time"
+>           [ScalarType "oid"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_last_vacuum_time"
+>           [ScalarType "oid"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_live_tuples"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_numscans" [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_deleted"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_fetched"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_hot_updated"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_inserted"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_returned"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_get_tuples_updated"
+>           [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_stat_reset" [] (Pseudo Void) False,
+>         CatCreateFunction FunName "pg_stop_backup" [] (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_switch_xlog" [] (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_table_is_visible" [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_tablespace_databases"
+>           [ScalarType "oid"]
+>           (SetOfType (ScalarType "oid"))
+>           False,
+>         CatCreateFunction FunName "pg_tablespace_size" [ScalarType "name"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_tablespace_size" [ScalarType "oid"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_terminate_backend"
+>           [ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_timezone_abbrevs" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_timezone_names" []
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "pg_total_relation_size"
+>           [ScalarType "regclass"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "pg_try_advisory_lock"
+>           [ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_try_advisory_lock"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_try_advisory_lock_shared"
+>           [ScalarType "int8"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_try_advisory_lock_shared"
+>           [ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_ts_config_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_ts_dict_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_ts_parser_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_ts_template_is_visible"
+>           [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_type_is_visible" [ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pg_typeof" [Pseudo Any]
+>           (ScalarType "regtype")
+>           False,
+>         CatCreateFunction FunName "pg_xlogfile_name" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "pg_xlogfile_name_offset"
+>           [ScalarType "text"]
+>           (Pseudo Record)
+>           False,
+>         CatCreateFunction FunName "pi" [] (ScalarType "float8") False,
+>         CatCreateFunction FunName "plainto_tsquery" [ScalarType "text"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "plainto_tsquery"
+>           [ScalarType "regconfig", ScalarType "text"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "point" [ScalarType "lseg"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point" [ScalarType "path"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point" [ScalarType "box"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point" [ScalarType "polygon"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point" [ScalarType "circle"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_above"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_add"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_below"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_distance"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "point_div"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_eq"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_horiz"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_in" [Pseudo Cstring]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_left"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_mul"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_ne"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_out" [ScalarType "point"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "point_recv" [Pseudo Internal]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_right"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "point_send" [ScalarType "point"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "point_sub"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "point_vert"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_above"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_below"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_center" [ScalarType "polygon"]
+>           (ScalarType "point")
+>           False,
+>         CatCreateFunction FunName "poly_contain"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_contain_pt"
+>           [ScalarType "polygon", ScalarType "point"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_contained"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_distance"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "poly_in" [Pseudo Cstring]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "poly_left"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_npoints" [ScalarType "polygon"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "poly_out" [ScalarType "polygon"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "poly_overabove"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_overbelow"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_overlap"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_overleft"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_overright"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_recv" [Pseudo Internal]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "poly_right"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_same"
+>           [ScalarType "polygon", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "poly_send" [ScalarType "polygon"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "polygon" [ScalarType "path"]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "polygon" [ScalarType "box"]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "polygon" [ScalarType "circle"]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "polygon"
+>           [ScalarType "int4", ScalarType "circle"]
+>           (ScalarType "polygon")
+>           False,
+>         CatCreateFunction FunName "popen" [ScalarType "path"]
+>           (ScalarType "path")
+>           False,
+>         CatCreateFunction FunName "position"
+>           [ScalarType "bytea", ScalarType "bytea"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "position"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "position"
+>           [ScalarType "bit", ScalarType "bit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "positionjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "positionsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "postgresql_fdw_validator"
+>           [ArrayType (ScalarType "text"), ScalarType "oid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pow"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "pow"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "power"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "power"
+>           [ScalarType "numeric", ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "prsd_end" [Pseudo Internal]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "prsd_headline"
+>           [Pseudo Internal, Pseudo Internal, ScalarType "tsquery"]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "prsd_lextype" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "prsd_nexttoken"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "prsd_start"
+>           [Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "pt_contained_circle"
+>           [ScalarType "point", ScalarType "circle"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "pt_contained_poly"
+>           [ScalarType "point", ScalarType "polygon"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "query_to_xml"
+>           [ScalarType "text", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "query_to_xml_and_xmlschema"
+>           [ScalarType "text", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "query_to_xmlschema"
+>           [ScalarType "text", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "querytree" [ScalarType "tsquery"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "quote_ident" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "quote_literal" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "quote_literal" [Pseudo AnyElement]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "quote_nullable" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "quote_nullable" [Pseudo AnyElement]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "radians" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "radius" [ScalarType "circle"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "random" [] (ScalarType "float8") False,
+>         CatCreateFunction FunName "record_eq"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_ge"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_gt"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo Record)
+>           False,
+>         CatCreateFunction FunName "record_le"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_lt"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_ne"
+>           [Pseudo Record, Pseudo Record]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "record_out" [Pseudo Record]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "record_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (Pseudo Record)
+>           False,
+>         CatCreateFunction FunName "record_send" [Pseudo Record]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regclass" [ScalarType "text"]
+>           (ScalarType "regclass")
+>           False,
+>         CatCreateFunction FunName "regclassin" [Pseudo Cstring]
+>           (ScalarType "regclass")
+>           False,
+>         CatCreateFunction FunName "regclassout" [ScalarType "regclass"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regclassrecv" [Pseudo Internal]
+>           (ScalarType "regclass")
+>           False,
+>         CatCreateFunction FunName "regclasssend" [ScalarType "regclass"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regconfigin" [Pseudo Cstring]
+>           (ScalarType "regconfig")
+>           False,
+>         CatCreateFunction FunName "regconfigout" [ScalarType "regconfig"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regconfigrecv" [Pseudo Internal]
+>           (ScalarType "regconfig")
+>           False,
+>         CatCreateFunction FunName "regconfigsend" [ScalarType "regconfig"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regdictionaryin" [Pseudo Cstring]
+>           (ScalarType "regdictionary")
+>           False,
+>         CatCreateFunction FunName "regdictionaryout"
+>           [ScalarType "regdictionary"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regdictionaryrecv" [Pseudo Internal]
+>           (ScalarType "regdictionary")
+>           False,
+>         CatCreateFunction FunName "regdictionarysend"
+>           [ScalarType "regdictionary"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regexeqjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "regexeqsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "regexnejoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "regexnesel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "regexp_matches"
+>           [ScalarType "text", ScalarType "text"]
+>           (SetOfType (ArrayType (ScalarType "text")))
+>           False,
+>         CatCreateFunction FunName "regexp_matches"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (SetOfType (ArrayType (ScalarType "text")))
+>           False,
+>         CatCreateFunction FunName "regexp_replace"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "regexp_replace"
+>           [ScalarType "text", ScalarType "text", ScalarType "text",
+>            ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "regexp_split_to_array"
+>           [ScalarType "text", ScalarType "text"]
+>           (ArrayType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "regexp_split_to_array"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ArrayType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "regexp_split_to_table"
+>           [ScalarType "text", ScalarType "text"]
+>           (SetOfType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "regexp_split_to_table"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (SetOfType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "regoperatorin" [Pseudo Cstring]
+>           (ScalarType "regoperator")
+>           False,
+>         CatCreateFunction FunName "regoperatorout"
+>           [ScalarType "regoperator"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regoperatorrecv" [Pseudo Internal]
+>           (ScalarType "regoperator")
+>           False,
+>         CatCreateFunction FunName "regoperatorsend"
+>           [ScalarType "regoperator"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regoperin" [Pseudo Cstring]
+>           (ScalarType "regoper")
+>           False,
+>         CatCreateFunction FunName "regoperout" [ScalarType "regoper"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regoperrecv" [Pseudo Internal]
+>           (ScalarType "regoper")
+>           False,
+>         CatCreateFunction FunName "regopersend" [ScalarType "regoper"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regprocedurein" [Pseudo Cstring]
+>           (ScalarType "regprocedure")
+>           False,
+>         CatCreateFunction FunName "regprocedureout"
+>           [ScalarType "regprocedure"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regprocedurerecv" [Pseudo Internal]
+>           (ScalarType "regprocedure")
+>           False,
+>         CatCreateFunction FunName "regproceduresend"
+>           [ScalarType "regprocedure"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regprocin" [Pseudo Cstring]
+>           (ScalarType "regproc")
+>           False,
+>         CatCreateFunction FunName "regprocout" [ScalarType "regproc"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regprocrecv" [Pseudo Internal]
+>           (ScalarType "regproc")
+>           False,
+>         CatCreateFunction FunName "regprocsend" [ScalarType "regproc"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "regtypein" [Pseudo Cstring]
+>           (ScalarType "regtype")
+>           False,
+>         CatCreateFunction FunName "regtypeout" [ScalarType "regtype"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "regtyperecv" [Pseudo Internal]
+>           (ScalarType "regtype")
+>           False,
+>         CatCreateFunction FunName "regtypesend" [ScalarType "regtype"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "reltime" [ScalarType "interval"]
+>           (ScalarType "reltime")
+>           False,
+>         CatCreateFunction FunName "reltimeeq"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimege"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimegt"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimein" [Pseudo Cstring]
+>           (ScalarType "reltime")
+>           False,
+>         CatCreateFunction FunName "reltimele"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimelt"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimene"
+>           [ScalarType "reltime", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "reltimeout" [ScalarType "reltime"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "reltimerecv" [Pseudo Internal]
+>           (ScalarType "reltime")
+>           False,
+>         CatCreateFunction FunName "reltimesend" [ScalarType "reltime"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "repeat"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "replace"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "round" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "round" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "round"
+>           [ScalarType "numeric", ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "rpad"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "rpad"
+>           [ScalarType "text", ScalarType "int4", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "rtrim" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "rtrim"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "scalargtjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "scalargtsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "scalarltjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "scalarltsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "schema_to_xml"
+>           [ScalarType "name", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "schema_to_xml_and_xmlschema"
+>           [ScalarType "name", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "schema_to_xmlschema"
+>           [ScalarType "name", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "session_user" [] (ScalarType "name")
+>           False,
+>         CatCreateFunction FunName "set_bit"
+>           [ScalarType "bytea", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "set_byte"
+>           [ScalarType "bytea", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "set_config"
+>           [ScalarType "text", ScalarType "text", ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "set_masklen"
+>           [ScalarType "cidr", ScalarType "int4"]
+>           (ScalarType "cidr")
+>           False,
+>         CatCreateFunction FunName "set_masklen"
+>           [ScalarType "inet", ScalarType "int4"]
+>           (ScalarType "inet")
+>           False,
+>         CatCreateFunction FunName "setseed" [ScalarType "float8"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "setval"
+>           [ScalarType "regclass", ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "setval"
+>           [ScalarType "regclass", ScalarType "int8", ScalarType "bool"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "setweight"
+>           [ScalarType "tsvector", ScalarType "char"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "shell_in" [Pseudo Cstring]
+>           (Pseudo Opaque)
+>           False,
+>         CatCreateFunction FunName "shell_out" [Pseudo Opaque]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "shift_jis_2004_to_euc_jis_2004"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "shift_jis_2004_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "shobj_description"
+>           [ScalarType "oid", ScalarType "name"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "sign" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "sign" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "similar_escape"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "sin" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "sjis_to_euc_jp"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "sjis_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "sjis_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "slope"
+>           [ScalarType "point", ScalarType "point"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "smgreq"
+>           [ScalarType "smgr", ScalarType "smgr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "smgrin" [Pseudo Cstring]
+>           (ScalarType "smgr")
+>           False,
+>         CatCreateFunction FunName "smgrne"
+>           [ScalarType "smgr", ScalarType "smgr"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "smgrout" [ScalarType "smgr"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "split_part"
+>           [ScalarType "text", ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "sqrt" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "sqrt" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "statement_timestamp" []
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "string_to_array"
+>           [ScalarType "text", ScalarType "text"]
+>           (ArrayType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "strip" [ScalarType "tsvector"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "strpos"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "substr"
+>           [ScalarType "bytea", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "substr"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substr"
+>           [ScalarType "bytea", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "substr"
+>           [ScalarType "text", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "bytea", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "bit", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "bytea", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "text", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "substring"
+>           [ScalarType "bit", ScalarType "int4", ScalarType "int4"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunName "suppress_redundant_updates_trigger" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "table_to_xml"
+>           [ScalarType "regclass", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "table_to_xml_and_xmlschema"
+>           [ScalarType "regclass", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "table_to_xmlschema"
+>           [ScalarType "regclass", ScalarType "bool", ScalarType "bool",
+>            ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "tan" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "bool"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "char"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "name"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "xml"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "inet"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text" [ScalarType "bpchar"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text_ge"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_gt"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_larger"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "text_le"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_lt"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_pattern_ge"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_pattern_gt"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_pattern_le"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_pattern_lt"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "text_smaller"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "textanycat"
+>           [ScalarType "text", Pseudo AnyNonArray]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "textcat"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "texteq"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "texticlike"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "texticnlike"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "texticregexeq"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "texticregexne"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textin" [Pseudo Cstring]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "textlen" [ScalarType "text"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "textlike"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textne"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textnlike"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textout" [ScalarType "text"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "textrecv" [Pseudo Internal]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "textregexeq"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textregexne"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "textsend" [ScalarType "text"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "thesaurus_init" [Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "thesaurus_lexize"
+>           [Pseudo Internal, Pseudo Internal, Pseudo Internal,
+>            Pseudo Internal]
+>           (Pseudo Internal)
+>           False,
+>         CatCreateFunction FunName "tideq"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidge"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidgt"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidin" [Pseudo Cstring]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "tidlarger"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "tidle"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidlt"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidne"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tidout" [ScalarType "tid"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "tidrecv" [Pseudo Internal]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "tidsend" [ScalarType "tid"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "tidsmaller"
+>           [ScalarType "tid", ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunName "time" [ScalarType "abstime"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time" [ScalarType "timestamp"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time" [ScalarType "timestamptz"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time" [ScalarType "interval"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time" [ScalarType "timetz"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time"
+>           [ScalarType "time", ScalarType "int4"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_cmp"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "time_eq"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_ge"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_gt"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_hash" [ScalarType "time"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "time_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_larger"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_le"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_lt"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_mi_interval"
+>           [ScalarType "time", ScalarType "interval"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_mi_time"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "time_ne"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "time_out" [ScalarType "time"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "time_pl_interval"
+>           [ScalarType "time", ScalarType "interval"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "time_send" [ScalarType "time"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "time_smaller"
+>           [ScalarType "time", ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunName "timedate_pl"
+>           [ScalarType "time", ScalarType "date"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timemi"
+>           [ScalarType "abstime", ScalarType "reltime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "timenow" [] (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "timeofday" [] (ScalarType "text") False,
+>         CatCreateFunction FunName "timepl"
+>           [ScalarType "abstime", ScalarType "reltime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "timestamp" [ScalarType "abstime"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp" [ScalarType "date"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp" [ScalarType "timestamptz"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp"
+>           [ScalarType "date", ScalarType "time"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp"
+>           [ScalarType "timestamp", ScalarType "int4"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_cmp"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamp_cmp_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamp_cmp_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamp_eq"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_eq_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_eq_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_ge"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_ge_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_ge_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_gt"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_gt_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_gt_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_hash" [ScalarType "timestamp"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamp_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_larger"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_le"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_le_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_le_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_lt"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_lt_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_lt_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_mi"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "timestamp_mi_interval"
+>           [ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_ne"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_ne_date"
+>           [ScalarType "timestamp", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_ne_timestamptz"
+>           [ScalarType "timestamp", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamp_out" [ScalarType "timestamp"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timestamp_pl_interval"
+>           [ScalarType "timestamp", ScalarType "interval"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamp_send" [ScalarType "timestamp"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "timestamp_smaller"
+>           [ScalarType "timestamp", ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timestamptypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamptypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timestamptz" [ScalarType "abstime"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz" [ScalarType "date"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz" [ScalarType "timestamp"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz"
+>           [ScalarType "date", ScalarType "time"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz"
+>           [ScalarType "date", ScalarType "timetz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz"
+>           [ScalarType "timestamptz", ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_cmp"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamptz_cmp_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamptz_cmp_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamptz_eq"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_eq_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_eq_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ge"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ge_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ge_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_gt"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_gt_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_gt_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_larger"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_le"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_le_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_le_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_lt"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_lt_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_lt_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_mi"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunName "timestamptz_mi_interval"
+>           [ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ne"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ne_date"
+>           [ScalarType "timestamptz", ScalarType "date"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_ne_timestamp"
+>           [ScalarType "timestamptz", ScalarType "timestamp"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timestamptz_out"
+>           [ScalarType "timestamptz"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timestamptz_pl_interval"
+>           [ScalarType "timestamptz", ScalarType "interval"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptz_send"
+>           [ScalarType "timestamptz"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "timestamptz_smaller"
+>           [ScalarType "timestamptz", ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timestamptztypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timestamptztypmodout"
+>           [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timetypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timetypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timetz" [ScalarType "time"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz" [ScalarType "timestamptz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz"
+>           [ScalarType "timetz", ScalarType "int4"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_cmp"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timetz_eq"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_ge"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_gt"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_hash" [ScalarType "timetz"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timetz_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_larger"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_le"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_lt"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_mi_interval"
+>           [ScalarType "timetz", ScalarType "interval"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_ne"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "timetz_out" [ScalarType "timetz"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timetz_pl_interval"
+>           [ScalarType "timetz", ScalarType "interval"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetz_send" [ScalarType "timetz"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "timetz_smaller"
+>           [ScalarType "timetz", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timetzdate_pl"
+>           [ScalarType "timetz", ScalarType "date"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timetztypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "timetztypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "text", ScalarType "timestamp"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "text", ScalarType "timestamptz"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "text", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "interval", ScalarType "timestamp"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "interval", ScalarType "timestamptz"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunName "timezone"
+>           [ScalarType "interval", ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunName "tinterval"
+>           [ScalarType "abstime", ScalarType "abstime"]
+>           (ScalarType "tinterval")
+>           False,
+>         CatCreateFunction FunName "tintervalct"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalend" [ScalarType "tinterval"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "tintervaleq"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalge"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalgt"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalin" [Pseudo Cstring]
+>           (ScalarType "tinterval")
+>           False,
+>         CatCreateFunction FunName "tintervalle"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalleneq"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallenge"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallengt"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallenle"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallenlt"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallenne"
+>           [ScalarType "tinterval", ScalarType "reltime"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervallt"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalne"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalout" [ScalarType "tinterval"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "tintervalov"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalrecv" [Pseudo Internal]
+>           (ScalarType "tinterval")
+>           False,
+>         CatCreateFunction FunName "tintervalrel" [ScalarType "tinterval"]
+>           (ScalarType "reltime")
+>           False,
+>         CatCreateFunction FunName "tintervalsame"
+>           [ScalarType "tinterval", ScalarType "tinterval"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tintervalsend" [ScalarType "tinterval"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "tintervalstart" [ScalarType "tinterval"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunName "to_ascii" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_ascii"
+>           [ScalarType "text", ScalarType "name"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_ascii"
+>           [ScalarType "text", ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "int8", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "int4", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "float4", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "float8", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "timestamp", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "timestamptz", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "interval", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_char"
+>           [ScalarType "numeric", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_date"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunName "to_hex" [ScalarType "int8"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_hex" [ScalarType "int4"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "to_number"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "to_timestamp" [ScalarType "float8"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "to_timestamp"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "to_tsquery" [ScalarType "text"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "to_tsquery"
+>           [ScalarType "regconfig", ScalarType "text"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "to_tsvector" [ScalarType "text"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "to_tsvector"
+>           [ScalarType "regconfig", ScalarType "text"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "transaction_timestamp" []
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunName "translate"
+>           [ScalarType "text", ScalarType "text", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "trigger_in" [Pseudo Cstring]
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "trigger_out" [Pseudo Trigger]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "trunc" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "trunc" [ScalarType "macaddr"]
+>           (ScalarType "macaddr")
+>           False,
+>         CatCreateFunction FunName "trunc" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "trunc"
+>           [ScalarType "numeric", ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunName "ts_debug" [ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_debug"
+>           [ScalarType "regconfig", ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_headline"
+>           [ScalarType "text", ScalarType "tsquery"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "ts_headline"
+>           [ScalarType "text", ScalarType "tsquery", ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "ts_headline"
+>           [ScalarType "regconfig", ScalarType "text", ScalarType "tsquery"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "ts_headline"
+>           [ScalarType "regconfig", ScalarType "text", ScalarType "tsquery",
+>            ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "ts_lexize"
+>           [ScalarType "regdictionary", ScalarType "text"]
+>           (ArrayType (ScalarType "text"))
+>           False,
+>         CatCreateFunction FunName "ts_match_qv"
+>           [ScalarType "tsquery", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ts_match_tq"
+>           [ScalarType "text", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ts_match_tt"
+>           [ScalarType "text", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ts_match_vq"
+>           [ScalarType "tsvector", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "ts_parse"
+>           [ScalarType "text", ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_parse"
+>           [ScalarType "oid", ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_rank"
+>           [ScalarType "tsvector", ScalarType "tsquery"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank"
+>           [ArrayType (ScalarType "float4"), ScalarType "tsvector",
+>            ScalarType "tsquery"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank"
+>           [ScalarType "tsvector", ScalarType "tsquery", ScalarType "int4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank"
+>           [ArrayType (ScalarType "float4"), ScalarType "tsvector",
+>            ScalarType "tsquery", ScalarType "int4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank_cd"
+>           [ScalarType "tsvector", ScalarType "tsquery"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank_cd"
+>           [ArrayType (ScalarType "float4"), ScalarType "tsvector",
+>            ScalarType "tsquery"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank_cd"
+>           [ScalarType "tsvector", ScalarType "tsquery", ScalarType "int4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rank_cd"
+>           [ArrayType (ScalarType "float4"), ScalarType "tsvector",
+>            ScalarType "tsquery", ScalarType "int4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunName "ts_rewrite"
+>           [ScalarType "tsquery", ScalarType "text"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "ts_rewrite"
+>           [ScalarType "tsquery", ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "ts_stat" [ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_stat"
+>           [ScalarType "text", ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_token_type" [ScalarType "text"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_token_type" [ScalarType "oid"]
+>           (SetOfType (Pseudo Record))
+>           False,
+>         CatCreateFunction FunName "ts_typanalyze" [Pseudo Internal]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsmatchjoinsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int2", Pseudo Internal]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "tsmatchsel"
+>           [Pseudo Internal, ScalarType "oid", Pseudo Internal,
+>            ScalarType "int4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "tsq_mcontained"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsq_mcontains"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_and"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "tsquery_cmp"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "tsquery_eq"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_ge"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_gt"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_le"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_lt"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_ne"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsquery_not" [ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "tsquery_or"
+>           [ScalarType "tsquery", ScalarType "tsquery"]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "tsqueryin" [Pseudo Cstring]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "tsqueryout" [ScalarType "tsquery"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "tsqueryrecv" [Pseudo Internal]
+>           (ScalarType "tsquery")
+>           False,
+>         CatCreateFunction FunName "tsquerysend" [ScalarType "tsquery"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "tsvector_cmp"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "tsvector_concat"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "tsvector_eq"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_ge"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_gt"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_le"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_lt"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_ne"
+>           [ScalarType "tsvector", ScalarType "tsvector"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "tsvector_update_trigger" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "tsvector_update_trigger_column" []
+>           (Pseudo Trigger)
+>           False,
+>         CatCreateFunction FunName "tsvectorin" [Pseudo Cstring]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "tsvectorout" [ScalarType "tsvector"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "tsvectorrecv" [Pseudo Internal]
+>           (ScalarType "tsvector")
+>           False,
+>         CatCreateFunction FunName "tsvectorsend" [ScalarType "tsvector"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "txid_current" [] (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "txid_current_snapshot" []
+>           (ScalarType "txid_snapshot")
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_in" [Pseudo Cstring]
+>           (ScalarType "txid_snapshot")
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_out"
+>           [ScalarType "txid_snapshot"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_recv" [Pseudo Internal]
+>           (ScalarType "txid_snapshot")
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_send"
+>           [ScalarType "txid_snapshot"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_xip"
+>           [ScalarType "txid_snapshot"]
+>           (SetOfType (ScalarType "int8"))
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_xmax"
+>           [ScalarType "txid_snapshot"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "txid_snapshot_xmin"
+>           [ScalarType "txid_snapshot"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunName "txid_visible_in_snapshot"
+>           [ScalarType "int8", ScalarType "txid_snapshot"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uhc_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "unknownin" [Pseudo Cstring]
+>           (ScalarType "unknown")
+>           False,
+>         CatCreateFunction FunName "unknownout" [ScalarType "unknown"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "unknownrecv" [Pseudo Internal]
+>           (ScalarType "unknown")
+>           False,
+>         CatCreateFunction FunName "unknownsend" [ScalarType "unknown"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "unnest" [Pseudo AnyArray]
+>           (SetOfType (Pseudo AnyElement))
+>           False,
+>         CatCreateFunction FunName "upper" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunName "utf8_to_ascii"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_big5"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_euc_cn"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_euc_jis_2004"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_euc_jp"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_euc_kr"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_euc_tw"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_gb18030"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_gbk"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_iso8859"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_iso8859_1"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_johab"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_koi8r"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_koi8u"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_shift_jis_2004"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_sjis"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_uhc"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "utf8_to_win"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "uuid_cmp"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "uuid_eq"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_ge"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_gt"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_hash" [ScalarType "uuid"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "uuid_in" [Pseudo Cstring]
+>           (ScalarType "uuid")
+>           False,
+>         CatCreateFunction FunName "uuid_le"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_lt"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_ne"
+>           [ScalarType "uuid", ScalarType "uuid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "uuid_out" [ScalarType "uuid"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "uuid_recv" [Pseudo Internal]
+>           (ScalarType "uuid")
+>           False,
+>         CatCreateFunction FunName "uuid_send" [ScalarType "uuid"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "varbit"
+>           [ScalarType "varbit", ScalarType "int4", ScalarType "bool"]
+>           (ScalarType "varbit")
+>           False,
+>         CatCreateFunction FunName "varbit_in"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "varbit")
+>           False,
+>         CatCreateFunction FunName "varbit_out" [ScalarType "varbit"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "varbit_recv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "varbit")
+>           False,
+>         CatCreateFunction FunName "varbit_send" [ScalarType "varbit"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "varbitcmp"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "varbiteq"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbitge"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbitgt"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbitle"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbitlt"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbitne"
+>           [ScalarType "varbit", ScalarType "varbit"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "varbittypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "varbittypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "varchar" [ScalarType "name"]
+>           (ScalarType "varchar")
+>           False,
+>         CatCreateFunction FunName "varchar"
+>           [ScalarType "varchar", ScalarType "int4", ScalarType "bool"]
+>           (ScalarType "varchar")
+>           False,
+>         CatCreateFunction FunName "varcharin"
+>           [Pseudo Cstring, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "varchar")
+>           False,
+>         CatCreateFunction FunName "varcharout" [ScalarType "varchar"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "varcharrecv"
+>           [Pseudo Internal, ScalarType "oid", ScalarType "int4"]
+>           (ScalarType "varchar")
+>           False,
+>         CatCreateFunction FunName "varcharsend" [ScalarType "varchar"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "varchartypmodin"
+>           [ArrayType (Pseudo Cstring)]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "varchartypmodout" [ScalarType "int4"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "version" [] (ScalarType "text") False,
+>         CatCreateFunction FunName "void_in" [Pseudo Cstring] (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "void_out" [Pseudo Void] (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "width" [ScalarType "box"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunName "width_bucket"
+>           [ScalarType "float8", ScalarType "float8", ScalarType "float8",
+>            ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "width_bucket"
+>           [ScalarType "numeric", ScalarType "numeric", ScalarType "numeric",
+>            ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunName "win1250_to_latin2"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win1250_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win1251_to_iso"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win1251_to_koi8r"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win1251_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win1251_to_win866"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win866_to_iso"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win866_to_koi8r"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win866_to_mic"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win866_to_win1251"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "win_to_utf8"
+>           [ScalarType "int4", ScalarType "int4", Pseudo Cstring,
+>            Pseudo Internal, ScalarType "int4"]
+>           (Pseudo Void)
+>           False,
+>         CatCreateFunction FunName "xideq"
+>           [ScalarType "xid", ScalarType "xid"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "xideqint4"
+>           [ScalarType "xid", ScalarType "int4"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "xidin" [Pseudo Cstring]
+>           (ScalarType "xid")
+>           False,
+>         CatCreateFunction FunName "xidout" [ScalarType "xid"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "xidrecv" [Pseudo Internal]
+>           (ScalarType "xid")
+>           False,
+>         CatCreateFunction FunName "xidsend" [ScalarType "xid"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "xml" [ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "xml_in" [Pseudo Cstring]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "xml_out" [ScalarType "xml"]
+>           (Pseudo Cstring)
+>           False,
+>         CatCreateFunction FunName "xml_recv" [Pseudo Internal]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "xml_send" [ScalarType "xml"]
+>           (ScalarType "bytea")
+>           False,
+>         CatCreateFunction FunName "xmlcomment" [ScalarType "text"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "xmlconcat2"
+>           [ScalarType "xml", ScalarType "xml"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunName "xmlvalidate"
+>           [ScalarType "xml", ScalarType "text"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunName "xpath"
+>           [ScalarType "text", ScalarType "xml"]
+>           (ArrayType (ScalarType "xml"))
+>           False,
+>         CatCreateFunction FunName "xpath"
+>           [ScalarType "text", ScalarType "xml",
+>            ArrayType (ScalarType "text")]
+>           (ArrayType (ScalarType "xml"))
+>           False,
+>         CatCreateFunction FunAgg "array_agg" [Pseudo AnyElement]
+>           (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunAgg "avg" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "bit_and" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "bit_and" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunAgg "bit_and" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunAgg "bit_and" [ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunAgg "bit_or" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "bit_or" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunAgg "bit_or" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunAgg "bit_or" [ScalarType "bit"]
+>           (ScalarType "bit")
+>           False,
+>         CatCreateFunction FunAgg "bool_and" [ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunAgg "bool_or" [ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunAgg "corr"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "count" [] (ScalarType "int8") False,
+>         CatCreateFunction FunAgg "count" [Pseudo Any] (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "covar_pop"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "covar_samp"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "every" [ScalarType "bool"]
+>           (ScalarType "bool")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "abstime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "bpchar"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunAgg "max" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "max" [Pseudo AnyArray] (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunAgg "max" [Pseudo AnyEnum] (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "int8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "int2"]
+>           (ScalarType "int2")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "text"]
+>           (ScalarType "text")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "oid"]
+>           (ScalarType "oid")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "tid"]
+>           (ScalarType "tid")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "abstime"]
+>           (ScalarType "abstime")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "bpchar"]
+>           (ScalarType "bpchar")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "date"]
+>           (ScalarType "date")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "time"]
+>           (ScalarType "time")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "timestamp"]
+>           (ScalarType "timestamp")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "timestamptz"]
+>           (ScalarType "timestamptz")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "timetz"]
+>           (ScalarType "timetz")
+>           False,
+>         CatCreateFunction FunAgg "min" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "min" [Pseudo AnyArray] (Pseudo AnyArray)
+>           False,
+>         CatCreateFunction FunAgg "min" [Pseudo AnyEnum] (Pseudo AnyEnum)
+>           False,
+>         CatCreateFunction FunAgg "regr_avgx"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_avgy"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_count"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "regr_intercept"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_r2"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_slope"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_sxx"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_sxy"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "regr_syy"
+>           [ScalarType "float8", ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev_pop" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "stddev_samp" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "int2"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "int4"]
+>           (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "float4"]
+>           (ScalarType "float4")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "money"]
+>           (ScalarType "money")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "interval"]
+>           (ScalarType "interval")
+>           False,
+>         CatCreateFunction FunAgg "sum" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "var_pop" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "var_samp" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "int8"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "int2"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "int4"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "float4"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "float8"]
+>           (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunAgg "variance" [ScalarType "numeric"]
+>           (ScalarType "numeric")
+>           False,
+>         CatCreateFunction FunAgg "xmlagg" [ScalarType "xml"]
+>           (ScalarType "xml")
+>           False,
+>         CatCreateFunction FunWindow "cume_dist" [] (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunWindow "dense_rank" [] (ScalarType "int8")
+>           False,
+>         CatCreateFunction FunWindow "first_value" [Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lag" [Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lag"
+>           [Pseudo AnyElement, ScalarType "int4"]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lag"
+>           [Pseudo AnyElement, ScalarType "int4", Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "last_value" [Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lead" [Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lead"
+>           [Pseudo AnyElement, ScalarType "int4"]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "lead"
+>           [Pseudo AnyElement, ScalarType "int4", Pseudo AnyElement]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "nth_value"
+>           [Pseudo AnyElement, ScalarType "int4"]
+>           (Pseudo AnyElement)
+>           False,
+>         CatCreateFunction FunWindow "ntile" [ScalarType "int4"]
+>           (ScalarType "int4")
+>           False,
+>         CatCreateFunction FunWindow "percent_rank" [] (ScalarType "float8")
+>           False,
+>         CatCreateFunction FunWindow "rank" [] (ScalarType "int8") False,
+>         CatCreateFunction FunWindow "row_number" [] (ScalarType "int8")
+>           False,
+>         CatCreateTable "pg_aggregate"
+>           [("aggfnoid", ScalarType "regproc"),
+>            ("aggtransfn", ScalarType "regproc"),
+>            ("aggfinalfn", ScalarType "regproc"),
+>            ("aggsortop", ScalarType "oid"),
+>            ("aggtranstype", ScalarType "oid"),
+>            ("agginitval", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_am"
+>           [("amname", ScalarType "name"),
+>            ("amstrategies", ScalarType "int2"),
+>            ("amsupport", ScalarType "int2"),
+>            ("amcanorder", ScalarType "bool"),
+>            ("amcanbackward", ScalarType "bool"),
+>            ("amcanunique", ScalarType "bool"),
+>            ("amcanmulticol", ScalarType "bool"),
+>            ("amoptionalkey", ScalarType "bool"),
+>            ("amindexnulls", ScalarType "bool"),
+>            ("amsearchnulls", ScalarType "bool"),
+>            ("amstorage", ScalarType "bool"),
+>            ("amclusterable", ScalarType "bool"),
+>            ("amkeytype", ScalarType "oid"),
+>            ("aminsert", ScalarType "regproc"),
+>            ("ambeginscan", ScalarType "regproc"),
+>            ("amgettuple", ScalarType "regproc"),
+>            ("amgetbitmap", ScalarType "regproc"),
+>            ("amrescan", ScalarType "regproc"),
+>            ("amendscan", ScalarType "regproc"),
+>            ("ammarkpos", ScalarType "regproc"),
+>            ("amrestrpos", ScalarType "regproc"),
+>            ("ambuild", ScalarType "regproc"),
+>            ("ambulkdelete", ScalarType "regproc"),
+>            ("amvacuumcleanup", ScalarType "regproc"),
+>            ("amcostestimate", ScalarType "regproc"),
+>            ("amoptions", ScalarType "regproc")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_amop"
+>           [("amopfamily", ScalarType "oid"),
+>            ("amoplefttype", ScalarType "oid"),
+>            ("amoprighttype", ScalarType "oid"),
+>            ("amopstrategy", ScalarType "int2"), ("amopopr", ScalarType "oid"),
+>            ("amopmethod", ScalarType "oid")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_amproc"
+>           [("amprocfamily", ScalarType "oid"),
+>            ("amproclefttype", ScalarType "oid"),
+>            ("amprocrighttype", ScalarType "oid"),
+>            ("amprocnum", ScalarType "int2"), ("amproc", ScalarType "regproc")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_attrdef"
+>           [("adrelid", ScalarType "oid"), ("adnum", ScalarType "int2"),
+>            ("adbin", ScalarType "text"), ("adsrc", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_attribute"
+>           [("attrelid", ScalarType "oid"), ("attname", ScalarType "name"),
+>            ("atttypid", ScalarType "oid"),
+>            ("attstattarget", ScalarType "int4"),
+>            ("attlen", ScalarType "int2"), ("attnum", ScalarType "int2"),
+>            ("attndims", ScalarType "int4"),
+>            ("attcacheoff", ScalarType "int4"),
+>            ("atttypmod", ScalarType "int4"), ("attbyval", ScalarType "bool"),
+>            ("attstorage", ScalarType "char"), ("attalign", ScalarType "char"),
+>            ("attnotnull", ScalarType "bool"),
+>            ("atthasdef", ScalarType "bool"),
+>            ("attisdropped", ScalarType "bool"),
+>            ("attislocal", ScalarType "bool"),
+>            ("attinhcount", ScalarType "int4"),
+>            ("attacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_auth_members"
+>           [("roleid", ScalarType "oid"), ("member", ScalarType "oid"),
+>            ("grantor", ScalarType "oid"), ("admin_option", ScalarType "bool")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_authid"
+>           [("rolname", ScalarType "name"), ("rolsuper", ScalarType "bool"),
+>            ("rolinherit", ScalarType "bool"),
+>            ("rolcreaterole", ScalarType "bool"),
+>            ("rolcreatedb", ScalarType "bool"),
+>            ("rolcatupdate", ScalarType "bool"),
+>            ("rolcanlogin", ScalarType "bool"),
+>            ("rolconnlimit", ScalarType "int4"),
+>            ("rolpassword", ScalarType "text"),
+>            ("rolvaliduntil", ScalarType "timestamptz"),
+>            ("rolconfig", ArrayType (ScalarType "text"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_cast"
+>           [("castsource", ScalarType "oid"),
+>            ("casttarget", ScalarType "oid"), ("castfunc", ScalarType "oid"),
+>            ("castcontext", ScalarType "char"),
+>            ("castmethod", ScalarType "char")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_class"
+>           [("relname", ScalarType "name"),
+>            ("relnamespace", ScalarType "oid"), ("reltype", ScalarType "oid"),
+>            ("relowner", ScalarType "oid"), ("relam", ScalarType "oid"),
+>            ("relfilenode", ScalarType "oid"),
+>            ("reltablespace", ScalarType "oid"),
+>            ("relpages", ScalarType "int4"),
+>            ("reltuples", ScalarType "float4"),
+>            ("reltoastrelid", ScalarType "oid"),
+>            ("reltoastidxid", ScalarType "oid"),
+>            ("relhasindex", ScalarType "bool"),
+>            ("relisshared", ScalarType "bool"),
+>            ("relistemp", ScalarType "bool"), ("relkind", ScalarType "char"),
+>            ("relnatts", ScalarType "int2"), ("relchecks", ScalarType "int2"),
+>            ("relhasoids", ScalarType "bool"),
+>            ("relhaspkey", ScalarType "bool"),
+>            ("relhasrules", ScalarType "bool"),
+>            ("relhastriggers", ScalarType "bool"),
+>            ("relhassubclass", ScalarType "bool"),
+>            ("relfrozenxid", ScalarType "xid"),
+>            ("relacl", ArrayType (ScalarType "aclitem")),
+>            ("reloptions", ArrayType (ScalarType "text"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_constraint"
+>           [("conname", ScalarType "name"),
+>            ("connamespace", ScalarType "oid"), ("contype", ScalarType "char"),
+>            ("condeferrable", ScalarType "bool"),
+>            ("condeferred", ScalarType "bool"), ("conrelid", ScalarType "oid"),
+>            ("contypid", ScalarType "oid"), ("confrelid", ScalarType "oid"),
+>            ("confupdtype", ScalarType "char"),
+>            ("confdeltype", ScalarType "char"),
+>            ("confmatchtype", ScalarType "char"),
+>            ("conislocal", ScalarType "bool"),
+>            ("coninhcount", ScalarType "int4"),
+>            ("conkey", ArrayType (ScalarType "int2")),
+>            ("confkey", ArrayType (ScalarType "int2")),
+>            ("conpfeqop", ArrayType (ScalarType "oid")),
+>            ("conppeqop", ArrayType (ScalarType "oid")),
+>            ("conffeqop", ArrayType (ScalarType "oid")),
+>            ("conbin", ScalarType "text"), ("consrc", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_conversion"
+>           [("conname", ScalarType "name"),
+>            ("connamespace", ScalarType "oid"), ("conowner", ScalarType "oid"),
+>            ("conforencoding", ScalarType "int4"),
+>            ("contoencoding", ScalarType "int4"),
+>            ("conproc", ScalarType "regproc"),
+>            ("condefault", ScalarType "bool")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_database"
+>           [("datname", ScalarType "name"), ("datdba", ScalarType "oid"),
+>            ("encoding", ScalarType "int4"), ("datcollate", ScalarType "name"),
+>            ("datctype", ScalarType "name"),
+>            ("datistemplate", ScalarType "bool"),
+>            ("datallowconn", ScalarType "bool"),
+>            ("datconnlimit", ScalarType "int4"),
+>            ("datlastsysoid", ScalarType "oid"),
+>            ("datfrozenxid", ScalarType "xid"),
+>            ("dattablespace", ScalarType "oid"),
+>            ("datconfig", ArrayType (ScalarType "text")),
+>            ("datacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_depend"
+>           [("classid", ScalarType "oid"), ("objid", ScalarType "oid"),
+>            ("objsubid", ScalarType "int4"), ("refclassid", ScalarType "oid"),
+>            ("refobjid", ScalarType "oid"), ("refobjsubid", ScalarType "int4"),
+>            ("deptype", ScalarType "char")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_description"
+>           [("objoid", ScalarType "oid"), ("classoid", ScalarType "oid"),
+>            ("objsubid", ScalarType "int4"),
+>            ("description", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_enum"
+>           [("enumtypid", ScalarType "oid"), ("enumlabel", ScalarType "name")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_foreign_data_wrapper"
+>           [("fdwname", ScalarType "name"), ("fdwowner", ScalarType "oid"),
+>            ("fdwvalidator", ScalarType "oid"),
+>            ("fdwacl", ArrayType (ScalarType "aclitem")),
+>            ("fdwoptions", ArrayType (ScalarType "text"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_foreign_server"
+>           [("srvname", ScalarType "name"), ("srvowner", ScalarType "oid"),
+>            ("srvfdw", ScalarType "oid"), ("srvtype", ScalarType "text"),
+>            ("srvversion", ScalarType "text"),
+>            ("srvacl", ArrayType (ScalarType "aclitem")),
+>            ("srvoptions", ArrayType (ScalarType "text"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_index"
+>           [("indexrelid", ScalarType "oid"), ("indrelid", ScalarType "oid"),
+>            ("indnatts", ScalarType "int2"),
+>            ("indisunique", ScalarType "bool"),
+>            ("indisprimary", ScalarType "bool"),
+>            ("indisclustered", ScalarType "bool"),
+>            ("indisvalid", ScalarType "bool"),
+>            ("indcheckxmin", ScalarType "bool"),
+>            ("indisready", ScalarType "bool"),
+>            ("indkey", ScalarType "int2vector"),
+>            ("indclass", ScalarType "oidvector"),
+>            ("indoption", ScalarType "int2vector"),
+>            ("indexprs", ScalarType "text"), ("indpred", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_inherits"
+>           [("inhrelid", ScalarType "oid"), ("inhparent", ScalarType "oid"),
+>            ("inhseqno", ScalarType "int4")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_language"
+>           [("lanname", ScalarType "name"), ("lanowner", ScalarType "oid"),
+>            ("lanispl", ScalarType "bool"),
+>            ("lanpltrusted", ScalarType "bool"),
+>            ("lanplcallfoid", ScalarType "oid"),
+>            ("lanvalidator", ScalarType "oid"),
+>            ("lanacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_largeobject"
+>           [("loid", ScalarType "oid"), ("pageno", ScalarType "int4"),
+>            ("data", ScalarType "bytea")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_listener"
+>           [("relname", ScalarType "name"),
+>            ("listenerpid", ScalarType "int4"),
+>            ("notification", ScalarType "int4")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_namespace"
+>           [("nspname", ScalarType "name"), ("nspowner", ScalarType "oid"),
+>            ("nspacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_opclass"
+>           [("opcmethod", ScalarType "oid"), ("opcname", ScalarType "name"),
+>            ("opcnamespace", ScalarType "oid"), ("opcowner", ScalarType "oid"),
+>            ("opcfamily", ScalarType "oid"), ("opcintype", ScalarType "oid"),
+>            ("opcdefault", ScalarType "bool"),
+>            ("opckeytype", ScalarType "oid")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_operator"
+>           [("oprname", ScalarType "name"),
+>            ("oprnamespace", ScalarType "oid"), ("oprowner", ScalarType "oid"),
+>            ("oprkind", ScalarType "char"), ("oprcanmerge", ScalarType "bool"),
+>            ("oprcanhash", ScalarType "bool"), ("oprleft", ScalarType "oid"),
+>            ("oprright", ScalarType "oid"), ("oprresult", ScalarType "oid"),
+>            ("oprcom", ScalarType "oid"), ("oprnegate", ScalarType "oid"),
+>            ("oprcode", ScalarType "regproc"),
+>            ("oprrest", ScalarType "regproc"),
+>            ("oprjoin", ScalarType "regproc")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_opfamily"
+>           [("opfmethod", ScalarType "oid"), ("opfname", ScalarType "name"),
+>            ("opfnamespace", ScalarType "oid"), ("opfowner", ScalarType "oid")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_pltemplate"
+>           [("tmplname", ScalarType "name"),
+>            ("tmpltrusted", ScalarType "bool"),
+>            ("tmpldbacreate", ScalarType "bool"),
+>            ("tmplhandler", ScalarType "text"),
+>            ("tmplvalidator", ScalarType "text"),
+>            ("tmpllibrary", ScalarType "text"),
+>            ("tmplacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_proc"
+>           [("proname", ScalarType "name"),
+>            ("pronamespace", ScalarType "oid"), ("proowner", ScalarType "oid"),
+>            ("prolang", ScalarType "oid"), ("procost", ScalarType "float4"),
+>            ("prorows", ScalarType "float4"),
+>            ("provariadic", ScalarType "oid"), ("proisagg", ScalarType "bool"),
+>            ("proiswindow", ScalarType "bool"),
+>            ("prosecdef", ScalarType "bool"),
+>            ("proisstrict", ScalarType "bool"),
+>            ("proretset", ScalarType "bool"),
+>            ("provolatile", ScalarType "char"),
+>            ("pronargs", ScalarType "int2"),
+>            ("pronargdefaults", ScalarType "int2"),
+>            ("prorettype", ScalarType "oid"),
+>            ("proargtypes", ScalarType "oidvector"),
+>            ("proallargtypes", ArrayType (ScalarType "oid")),
+>            ("proargmodes", ArrayType (ScalarType "char")),
+>            ("proargnames", ArrayType (ScalarType "text")),
+>            ("proargdefaults", ScalarType "text"),
+>            ("prosrc", ScalarType "text"), ("probin", ScalarType "bytea"),
+>            ("proconfig", ArrayType (ScalarType "text")),
+>            ("proacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_rewrite"
+>           [("rulename", ScalarType "name"), ("ev_class", ScalarType "oid"),
+>            ("ev_attr", ScalarType "int2"), ("ev_type", ScalarType "char"),
+>            ("ev_enabled", ScalarType "char"),
+>            ("is_instead", ScalarType "bool"), ("ev_qual", ScalarType "text"),
+>            ("ev_action", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_shdepend"
+>           [("dbid", ScalarType "oid"), ("classid", ScalarType "oid"),
+>            ("objid", ScalarType "oid"), ("objsubid", ScalarType "int4"),
+>            ("refclassid", ScalarType "oid"), ("refobjid", ScalarType "oid"),
+>            ("deptype", ScalarType "char")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_shdescription"
+>           [("objoid", ScalarType "oid"), ("classoid", ScalarType "oid"),
+>            ("description", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_statistic"
+>           [("starelid", ScalarType "oid"), ("staattnum", ScalarType "int2"),
+>            ("stanullfrac", ScalarType "float4"),
+>            ("stawidth", ScalarType "int4"),
+>            ("stadistinct", ScalarType "float4"),
+>            ("stakind1", ScalarType "int2"), ("stakind2", ScalarType "int2"),
+>            ("stakind3", ScalarType "int2"), ("stakind4", ScalarType "int2"),
+>            ("staop1", ScalarType "oid"), ("staop2", ScalarType "oid"),
+>            ("staop3", ScalarType "oid"), ("staop4", ScalarType "oid"),
+>            ("stanumbers1", ArrayType (ScalarType "float4")),
+>            ("stanumbers2", ArrayType (ScalarType "float4")),
+>            ("stanumbers3", ArrayType (ScalarType "float4")),
+>            ("stanumbers4", ArrayType (ScalarType "float4")),
+>            ("stavalues1", Pseudo AnyArray), ("stavalues2", Pseudo AnyArray),
+>            ("stavalues3", Pseudo AnyArray), ("stavalues4", Pseudo AnyArray)]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_tablespace"
+>           [("spcname", ScalarType "name"), ("spcowner", ScalarType "oid"),
+>            ("spclocation", ScalarType "text"),
+>            ("spcacl", ArrayType (ScalarType "aclitem"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_trigger"
+>           [("tgrelid", ScalarType "oid"), ("tgname", ScalarType "name"),
+>            ("tgfoid", ScalarType "oid"), ("tgtype", ScalarType "int2"),
+>            ("tgenabled", ScalarType "char"),
+>            ("tgisconstraint", ScalarType "bool"),
+>            ("tgconstrname", ScalarType "name"),
+>            ("tgconstrrelid", ScalarType "oid"),
+>            ("tgconstraint", ScalarType "oid"),
+>            ("tgdeferrable", ScalarType "bool"),
+>            ("tginitdeferred", ScalarType "bool"),
+>            ("tgnargs", ScalarType "int2"),
+>            ("tgattr", ScalarType "int2vector"),
+>            ("tgargs", ScalarType "bytea")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_ts_config"
+>           [("cfgname", ScalarType "name"),
+>            ("cfgnamespace", ScalarType "oid"), ("cfgowner", ScalarType "oid"),
+>            ("cfgparser", ScalarType "oid")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_ts_config_map"
+>           [("mapcfg", ScalarType "oid"), ("maptokentype", ScalarType "int4"),
+>            ("mapseqno", ScalarType "int4"), ("mapdict", ScalarType "oid")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_ts_dict"
+>           [("dictname", ScalarType "name"),
+>            ("dictnamespace", ScalarType "oid"),
+>            ("dictowner", ScalarType "oid"),
+>            ("dicttemplate", ScalarType "oid"),
+>            ("dictinitoption", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_ts_parser"
+>           [("prsname", ScalarType "name"),
+>            ("prsnamespace", ScalarType "oid"),
+>            ("prsstart", ScalarType "regproc"),
+>            ("prstoken", ScalarType "regproc"),
+>            ("prsend", ScalarType "regproc"),
+>            ("prsheadline", ScalarType "regproc"),
+>            ("prslextype", ScalarType "regproc")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_ts_template"
+>           [("tmplname", ScalarType "name"),
+>            ("tmplnamespace", ScalarType "oid"),
+>            ("tmplinit", ScalarType "regproc"),
+>            ("tmpllexize", ScalarType "regproc")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_type"
+>           [("typname", ScalarType "name"),
+>            ("typnamespace", ScalarType "oid"), ("typowner", ScalarType "oid"),
+>            ("typlen", ScalarType "int2"), ("typbyval", ScalarType "bool"),
+>            ("typtype", ScalarType "char"), ("typcategory", ScalarType "char"),
+>            ("typispreferred", ScalarType "bool"),
+>            ("typisdefined", ScalarType "bool"),
+>            ("typdelim", ScalarType "char"), ("typrelid", ScalarType "oid"),
+>            ("typelem", ScalarType "oid"), ("typarray", ScalarType "oid"),
+>            ("typinput", ScalarType "regproc"),
+>            ("typoutput", ScalarType "regproc"),
+>            ("typreceive", ScalarType "regproc"),
+>            ("typsend", ScalarType "regproc"),
+>            ("typmodin", ScalarType "regproc"),
+>            ("typmodout", ScalarType "regproc"),
+>            ("typanalyze", ScalarType "regproc"),
+>            ("typalign", ScalarType "char"), ("typstorage", ScalarType "char"),
+>            ("typnotnull", ScalarType "bool"),
+>            ("typbasetype", ScalarType "oid"),
+>            ("typtypmod", ScalarType "int4"), ("typndims", ScalarType "int4"),
+>            ("typdefaultbin", ScalarType "text"),
+>            ("typdefault", ScalarType "text")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "pg_user_mapping"
+>           [("umuser", ScalarType "oid"), ("umserver", ScalarType "oid"),
+>            ("umoptions", ArrayType (ScalarType "text"))]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("oid", ScalarType "oid"),
+>            ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_features"
+>           [("feature_id", DomainType "information_schema.character_data"),
+>            ("feature_name", DomainType "information_schema.character_data"),
+>            ("sub_feature_id", DomainType "information_schema.character_data"),
+>            ("sub_feature_name",
+>             DomainType "information_schema.character_data"),
+>            ("is_supported", DomainType "information_schema.character_data"),
+>            ("is_verified_by", DomainType "information_schema.character_data"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_implementation_info"
+>           [("implementation_info_id",
+>             DomainType "information_schema.character_data"),
+>            ("implementation_info_name",
+>             DomainType "information_schema.character_data"),
+>            ("integer_value", DomainType "information_schema.cardinal_number"),
+>            ("character_value",
+>             DomainType "information_schema.character_data"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_languages"
+>           [("sql_language_source",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_year",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_conformance",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_integrity",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_implementation",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_binding_style",
+>             DomainType "information_schema.character_data"),
+>            ("sql_language_programming_language",
+>             DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_packages"
+>           [("feature_id", DomainType "information_schema.character_data"),
+>            ("feature_name", DomainType "information_schema.character_data"),
+>            ("is_supported", DomainType "information_schema.character_data"),
+>            ("is_verified_by", DomainType "information_schema.character_data"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_parts"
+>           [("feature_id", DomainType "information_schema.character_data"),
+>            ("feature_name", DomainType "information_schema.character_data"),
+>            ("is_supported", DomainType "information_schema.character_data"),
+>            ("is_verified_by", DomainType "information_schema.character_data"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_sizing"
+>           [("sizing_id", DomainType "information_schema.cardinal_number"),
+>            ("sizing_name", DomainType "information_schema.character_data"),
+>            ("supported_value",
+>             DomainType "information_schema.cardinal_number"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateTable "information_schema.sql_sizing_profiles"
+>           [("sizing_id", DomainType "information_schema.cardinal_number"),
+>            ("sizing_name", DomainType "information_schema.character_data"),
+>            ("profile_id", DomainType "information_schema.character_data"),
+>            ("required_value",
+>             DomainType "information_schema.cardinal_number"),
+>            ("comments", DomainType "information_schema.character_data")]
+>           [("tableoid", ScalarType "oid"), ("cmax", ScalarType "cid"),
+>            ("xmax", ScalarType "xid"), ("cmin", ScalarType "cid"),
+>            ("xmin", ScalarType "xid"), ("ctid", ScalarType "tid")],
+>         CatCreateView "information_schema._pg_foreign_data_wrappers"
+>           [("oid", ScalarType "oid"), ("fdwowner", ScalarType "oid"),
+>            ("fdwoptions", ArrayType (ScalarType "text")),
+>            ("foreign_data_wrapper_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("authorization_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_language",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema._pg_foreign_servers"
+>           [("oid", ScalarType "oid"),
+>            ("srvoptions", ArrayType (ScalarType "text")),
+>            ("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_type",
+>             DomainType "information_schema.character_data"),
+>            ("foreign_server_version",
+>             DomainType "information_schema.character_data"),
+>            ("authorization_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema._pg_user_mappings"
+>           [("oid", ScalarType "oid"),
+>            ("umoptions", ArrayType (ScalarType "text")),
+>            ("umuser", ScalarType "oid"),
+>            ("authorization_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("srvowner", DomainType "information_schema.sql_identifier")],
+>         CatCreateView
+>           "information_schema.administrable_role_authorizations"
+>           [("grantee", DomainType "information_schema.sql_identifier"),
+>            ("role_name", DomainType "information_schema.sql_identifier"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.applicable_roles"
+>           [("grantee", DomainType "information_schema.sql_identifier"),
+>            ("role_name", DomainType "information_schema.sql_identifier"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.attributes"
+>           [("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("attribute_name", DomainType "information_schema.sql_identifier"),
+>            ("ordinal_position",
+>             DomainType "information_schema.cardinal_number"),
+>            ("attribute_default",
+>             DomainType "information_schema.character_data"),
+>            ("is_nullable", DomainType "information_schema.character_data"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("attribute_udt_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("attribute_udt_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("attribute_udt_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier", DomainType "information_schema.sql_identifier"),
+>            ("is_derived_reference_attribute",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.check_constraint_routine_usage"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.check_constraints"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("check_clause", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.column_domain_usage"
+>           [("domain_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("domain_schema", DomainType "information_schema.sql_identifier"),
+>            ("domain_name", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.column_privileges"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.column_udt_usage"
+>           [("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.columns"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier"),
+>            ("ordinal_position",
+>             DomainType "information_schema.cardinal_number"),
+>            ("column_default", DomainType "information_schema.character_data"),
+>            ("is_nullable", DomainType "information_schema.character_data"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("domain_catalog", DomainType "information_schema.sql_identifier"),
+>            ("domain_schema", DomainType "information_schema.sql_identifier"),
+>            ("domain_name", DomainType "information_schema.sql_identifier"),
+>            ("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier", DomainType "information_schema.sql_identifier"),
+>            ("is_self_referencing",
+>             DomainType "information_schema.character_data"),
+>            ("is_identity", DomainType "information_schema.character_data"),
+>            ("identity_generation",
+>             DomainType "information_schema.character_data"),
+>            ("identity_start", DomainType "information_schema.character_data"),
+>            ("identity_increment",
+>             DomainType "information_schema.character_data"),
+>            ("identity_maximum",
+>             DomainType "information_schema.character_data"),
+>            ("identity_minimum",
+>             DomainType "information_schema.character_data"),
+>            ("identity_cycle", DomainType "information_schema.character_data"),
+>            ("is_generated", DomainType "information_schema.character_data"),
+>            ("generation_expression",
+>             DomainType "information_schema.character_data"),
+>            ("is_updatable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.constraint_column_usage"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier"),
+>            ("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.constraint_table_usage"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.data_type_privileges"
+>           [("object_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("object_schema", DomainType "information_schema.sql_identifier"),
+>            ("object_name", DomainType "information_schema.sql_identifier"),
+>            ("object_type", DomainType "information_schema.character_data"),
+>            ("dtd_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.domain_constraints"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("domain_catalog", DomainType "information_schema.sql_identifier"),
+>            ("domain_schema", DomainType "information_schema.sql_identifier"),
+>            ("domain_name", DomainType "information_schema.sql_identifier"),
+>            ("is_deferrable", DomainType "information_schema.character_data"),
+>            ("initially_deferred",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.domain_udt_usage"
+>           [("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("domain_catalog", DomainType "information_schema.sql_identifier"),
+>            ("domain_schema", DomainType "information_schema.sql_identifier"),
+>            ("domain_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.domains"
+>           [("domain_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("domain_schema", DomainType "information_schema.sql_identifier"),
+>            ("domain_name", DomainType "information_schema.sql_identifier"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("domain_default", DomainType "information_schema.character_data"),
+>            ("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.element_types"
+>           [("object_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("object_schema", DomainType "information_schema.sql_identifier"),
+>            ("object_name", DomainType "information_schema.sql_identifier"),
+>            ("object_type", DomainType "information_schema.character_data"),
+>            ("collection_type_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("domain_default", DomainType "information_schema.character_data"),
+>            ("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.enabled_roles"
+>           [("role_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.foreign_data_wrapper_options"
+>           [("foreign_data_wrapper_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("option_name", DomainType "information_schema.sql_identifier"),
+>            ("option_value", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.foreign_data_wrappers"
+>           [("foreign_data_wrapper_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("authorization_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("library_name", DomainType "information_schema.character_data"),
+>            ("foreign_data_wrapper_language",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.foreign_server_options"
+>           [("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("option_name", DomainType "information_schema.sql_identifier"),
+>            ("option_value", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.foreign_servers"
+>           [("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_data_wrapper_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_type",
+>             DomainType "information_schema.character_data"),
+>            ("foreign_server_version",
+>             DomainType "information_schema.character_data"),
+>            ("authorization_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.information_schema_catalog_name"
+>           [("catalog_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.key_column_usage"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier"),
+>            ("ordinal_position",
+>             DomainType "information_schema.cardinal_number"),
+>            ("position_in_unique_constraint",
+>             DomainType "information_schema.cardinal_number")],
+>         CatCreateView "information_schema.parameters"
+>           [("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier"),
+>            ("ordinal_position",
+>             DomainType "information_schema.cardinal_number"),
+>            ("parameter_mode", DomainType "information_schema.character_data"),
+>            ("is_result", DomainType "information_schema.character_data"),
+>            ("as_locator", DomainType "information_schema.character_data"),
+>            ("parameter_name", DomainType "information_schema.sql_identifier"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "pg_cursors"
+>           [("name", ScalarType "text"), ("statement", ScalarType "text"),
+>            ("is_holdable", ScalarType "bool"),
+>            ("is_binary", ScalarType "bool"),
+>            ("is_scrollable", ScalarType "bool"),
+>            ("creation_time", ScalarType "timestamptz")],
+>         CatCreateView "pg_group"
+>           [("groname", ScalarType "name"), ("grosysid", ScalarType "oid"),
+>            ("grolist", ArrayType (ScalarType "oid"))],
+>         CatCreateView "pg_indexes"
+>           [("schemaname", ScalarType "name"),
+>            ("tablename", ScalarType "name"), ("indexname", ScalarType "name"),
+>            ("tablespace", ScalarType "name"),
+>            ("indexdef", ScalarType "text")],
+>         CatCreateView "pg_locks"
+>           [("locktype", ScalarType "text"), ("database", ScalarType "oid"),
+>            ("relation", ScalarType "oid"), ("page", ScalarType "int4"),
+>            ("tuple", ScalarType "int2"), ("virtualxid", ScalarType "text"),
+>            ("transactionid", ScalarType "xid"), ("classid", ScalarType "oid"),
+>            ("objid", ScalarType "oid"), ("objsubid", ScalarType "int2"),
+>            ("virtualtransaction", ScalarType "text"),
+>            ("pid", ScalarType "int4"), ("mode", ScalarType "text"),
+>            ("granted", ScalarType "bool")],
+>         CatCreateView "pg_prepared_statements"
+>           [("name", ScalarType "text"), ("statement", ScalarType "text"),
+>            ("prepare_time", ScalarType "timestamptz"),
+>            ("parameter_types", ArrayType (ScalarType "regtype")),
+>            ("from_sql", ScalarType "bool")],
+>         CatCreateView "pg_prepared_xacts"
+>           [("transaction", ScalarType "xid"), ("gid", ScalarType "text"),
+>            ("prepared", ScalarType "timestamptz"),
+>            ("owner", ScalarType "name"), ("database", ScalarType "name")],
+>         CatCreateView "pg_roles"
+>           [("rolname", ScalarType "name"), ("rolsuper", ScalarType "bool"),
+>            ("rolinherit", ScalarType "bool"),
+>            ("rolcreaterole", ScalarType "bool"),
+>            ("rolcreatedb", ScalarType "bool"),
+>            ("rolcatupdate", ScalarType "bool"),
+>            ("rolcanlogin", ScalarType "bool"),
+>            ("rolconnlimit", ScalarType "int4"),
+>            ("rolpassword", ScalarType "text"),
+>            ("rolvaliduntil", ScalarType "timestamptz"),
+>            ("rolconfig", ArrayType (ScalarType "text")),
+>            ("oid", ScalarType "oid")],
+>         CatCreateView "pg_rules"
+>           [("schemaname", ScalarType "name"),
+>            ("tablename", ScalarType "name"), ("rulename", ScalarType "name"),
+>            ("definition", ScalarType "text")],
+>         CatCreateView "pg_settings"
+>           [("name", ScalarType "text"), ("setting", ScalarType "text"),
+>            ("unit", ScalarType "text"), ("category", ScalarType "text"),
+>            ("short_desc", ScalarType "text"),
+>            ("extra_desc", ScalarType "text"), ("context", ScalarType "text"),
+>            ("vartype", ScalarType "text"), ("source", ScalarType "text"),
+>            ("min_val", ScalarType "text"), ("max_val", ScalarType "text"),
+>            ("enumvals", ArrayType (ScalarType "text")),
+>            ("boot_val", ScalarType "text"), ("reset_val", ScalarType "text"),
+>            ("sourcefile", ScalarType "text"),
+>            ("sourceline", ScalarType "int4")],
+>         CatCreateView "pg_shadow"
+>           [("usename", ScalarType "name"), ("usesysid", ScalarType "oid"),
+>            ("usecreatedb", ScalarType "bool"),
+>            ("usesuper", ScalarType "bool"), ("usecatupd", ScalarType "bool"),
+>            ("passwd", ScalarType "text"), ("valuntil", ScalarType "abstime"),
+>            ("useconfig", ArrayType (ScalarType "text"))],
+>         CatCreateView "pg_stat_activity"
+>           [("datid", ScalarType "oid"), ("datname", ScalarType "name"),
+>            ("procpid", ScalarType "int4"), ("usesysid", ScalarType "oid"),
+>            ("usename", ScalarType "name"),
+>            ("current_query", ScalarType "text"),
+>            ("waiting", ScalarType "bool"),
+>            ("xact_start", ScalarType "timestamptz"),
+>            ("query_start", ScalarType "timestamptz"),
+>            ("backend_start", ScalarType "timestamptz"),
+>            ("client_addr", ScalarType "inet"),
+>            ("client_port", ScalarType "int4")],
+>         CatCreateView "pg_stat_all_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_read", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8")],
+>         CatCreateView "pg_stat_all_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("seq_scan", ScalarType "int8"),
+>            ("seq_tup_read", ScalarType "int8"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8"),
+>            ("n_tup_ins", ScalarType "int8"), ("n_tup_upd", ScalarType "int8"),
+>            ("n_tup_del", ScalarType "int8"),
+>            ("n_tup_hot_upd", ScalarType "int8"),
+>            ("n_live_tup", ScalarType "int8"),
+>            ("n_dead_tup", ScalarType "int8"),
+>            ("last_vacuum", ScalarType "timestamptz"),
+>            ("last_autovacuum", ScalarType "timestamptz"),
+>            ("last_analyze", ScalarType "timestamptz"),
+>            ("last_autoanalyze", ScalarType "timestamptz")],
+>         CatCreateView "pg_stat_bgwriter"
+>           [("checkpoints_timed", ScalarType "int8"),
+>            ("checkpoints_req", ScalarType "int8"),
+>            ("buffers_checkpoint", ScalarType "int8"),
+>            ("buffers_clean", ScalarType "int8"),
+>            ("maxwritten_clean", ScalarType "int8"),
+>            ("buffers_backend", ScalarType "int8"),
+>            ("buffers_alloc", ScalarType "int8")],
+>         CatCreateView "pg_stat_database"
+>           [("datid", ScalarType "oid"), ("datname", ScalarType "name"),
+>            ("numbackends", ScalarType "int4"),
+>            ("xact_commit", ScalarType "int8"),
+>            ("xact_rollback", ScalarType "int8"),
+>            ("blks_read", ScalarType "int8"), ("blks_hit", ScalarType "int8"),
+>            ("tup_returned", ScalarType "int8"),
+>            ("tup_fetched", ScalarType "int8"),
+>            ("tup_inserted", ScalarType "int8"),
+>            ("tup_updated", ScalarType "int8"),
+>            ("tup_deleted", ScalarType "int8")],
+>         CatCreateView "pg_stat_sys_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_read", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8")],
+>         CatCreateView "pg_stat_sys_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("seq_scan", ScalarType "int8"),
+>            ("seq_tup_read", ScalarType "int8"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8"),
+>            ("n_tup_ins", ScalarType "int8"), ("n_tup_upd", ScalarType "int8"),
+>            ("n_tup_del", ScalarType "int8"),
+>            ("n_tup_hot_upd", ScalarType "int8"),
+>            ("n_live_tup", ScalarType "int8"),
+>            ("n_dead_tup", ScalarType "int8"),
+>            ("last_vacuum", ScalarType "timestamptz"),
+>            ("last_autovacuum", ScalarType "timestamptz"),
+>            ("last_analyze", ScalarType "timestamptz"),
+>            ("last_autoanalyze", ScalarType "timestamptz")],
+>         CatCreateView "pg_stat_user_functions"
+>           [("funcid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("funcname", ScalarType "name"), ("calls", ScalarType "int8"),
+>            ("total_time", ScalarType "int8"),
+>            ("self_time", ScalarType "int8")],
+>         CatCreateView "pg_stat_user_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_read", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8")],
+>         CatCreateView "pg_stat_user_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("seq_scan", ScalarType "int8"),
+>            ("seq_tup_read", ScalarType "int8"),
+>            ("idx_scan", ScalarType "int8"),
+>            ("idx_tup_fetch", ScalarType "int8"),
+>            ("n_tup_ins", ScalarType "int8"), ("n_tup_upd", ScalarType "int8"),
+>            ("n_tup_del", ScalarType "int8"),
+>            ("n_tup_hot_upd", ScalarType "int8"),
+>            ("n_live_tup", ScalarType "int8"),
+>            ("n_dead_tup", ScalarType "int8"),
+>            ("last_vacuum", ScalarType "timestamptz"),
+>            ("last_autovacuum", ScalarType "timestamptz"),
+>            ("last_analyze", ScalarType "timestamptz"),
+>            ("last_autoanalyze", ScalarType "timestamptz")],
+>         CatCreateView "pg_statio_all_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_all_sequences"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("blks_read", ScalarType "int8"),
+>            ("blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_all_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"),
+>            ("heap_blks_read", ScalarType "int8"),
+>            ("heap_blks_hit", ScalarType "int8"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8"),
+>            ("toast_blks_read", ScalarType "int8"),
+>            ("toast_blks_hit", ScalarType "int8"),
+>            ("tidx_blks_read", ScalarType "int8"),
+>            ("tidx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_sys_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_sys_sequences"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("blks_read", ScalarType "int8"),
+>            ("blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_sys_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"),
+>            ("heap_blks_read", ScalarType "int8"),
+>            ("heap_blks_hit", ScalarType "int8"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8"),
+>            ("toast_blks_read", ScalarType "int8"),
+>            ("toast_blks_hit", ScalarType "int8"),
+>            ("tidx_blks_read", ScalarType "int8"),
+>            ("tidx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_user_indexes"
+>           [("relid", ScalarType "oid"), ("indexrelid", ScalarType "oid"),
+>            ("schemaname", ScalarType "name"), ("relname", ScalarType "name"),
+>            ("indexrelname", ScalarType "name"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_user_sequences"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"), ("blks_read", ScalarType "int8"),
+>            ("blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_statio_user_tables"
+>           [("relid", ScalarType "oid"), ("schemaname", ScalarType "name"),
+>            ("relname", ScalarType "name"),
+>            ("heap_blks_read", ScalarType "int8"),
+>            ("heap_blks_hit", ScalarType "int8"),
+>            ("idx_blks_read", ScalarType "int8"),
+>            ("idx_blks_hit", ScalarType "int8"),
+>            ("toast_blks_read", ScalarType "int8"),
+>            ("toast_blks_hit", ScalarType "int8"),
+>            ("tidx_blks_read", ScalarType "int8"),
+>            ("tidx_blks_hit", ScalarType "int8")],
+>         CatCreateView "pg_stats"
+>           [("schemaname", ScalarType "name"),
+>            ("tablename", ScalarType "name"), ("attname", ScalarType "name"),
+>            ("null_frac", ScalarType "float4"),
+>            ("avg_width", ScalarType "int4"),
+>            ("n_distinct", ScalarType "float4"),
+>            ("most_common_vals", Pseudo AnyArray),
+>            ("most_common_freqs", ArrayType (ScalarType "float4")),
+>            ("histogram_bounds", Pseudo AnyArray),
+>            ("correlation", ScalarType "float4")],
+>         CatCreateView "pg_tables"
+>           [("schemaname", ScalarType "name"),
+>            ("tablename", ScalarType "name"),
+>            ("tableowner", ScalarType "name"),
+>            ("tablespace", ScalarType "name"),
+>            ("hasindexes", ScalarType "bool"), ("hasrules", ScalarType "bool"),
+>            ("hastriggers", ScalarType "bool")],
+>         CatCreateView "pg_timezone_abbrevs"
+>           [("abbrev", ScalarType "text"),
+>            ("utc_offset", ScalarType "interval"),
+>            ("is_dst", ScalarType "bool")],
+>         CatCreateView "pg_timezone_names"
+>           [("name", ScalarType "text"), ("abbrev", ScalarType "text"),
+>            ("utc_offset", ScalarType "interval"),
+>            ("is_dst", ScalarType "bool")],
+>         CatCreateView "pg_user"
+>           [("usename", ScalarType "name"), ("usesysid", ScalarType "oid"),
+>            ("usecreatedb", ScalarType "bool"),
+>            ("usesuper", ScalarType "bool"), ("usecatupd", ScalarType "bool"),
+>            ("passwd", ScalarType "text"), ("valuntil", ScalarType "abstime"),
+>            ("useconfig", ArrayType (ScalarType "text"))],
+>         CatCreateView "pg_user_mappings"
+>           [("umid", ScalarType "oid"), ("srvid", ScalarType "oid"),
+>            ("srvname", ScalarType "name"), ("umuser", ScalarType "oid"),
+>            ("usename", ScalarType "name"),
+>            ("umoptions", ArrayType (ScalarType "text"))],
+>         CatCreateView "pg_views"
+>           [("schemaname", ScalarType "name"),
+>            ("viewname", ScalarType "name"), ("viewowner", ScalarType "name"),
+>            ("definition", ScalarType "text")],
+>         CatCreateView "information_schema.referential_constraints"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("unique_constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("unique_constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("unique_constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("match_option", DomainType "information_schema.character_data"),
+>            ("update_rule", DomainType "information_schema.character_data"),
+>            ("delete_rule", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.role_column_grants"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.role_routine_grants"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier"),
+>            ("routine_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("routine_schema", DomainType "information_schema.sql_identifier"),
+>            ("routine_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.role_table_grants"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data"),
+>            ("with_hierarchy",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.role_usage_grants"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("object_catalog", DomainType "information_schema.sql_identifier"),
+>            ("object_schema", DomainType "information_schema.sql_identifier"),
+>            ("object_name", DomainType "information_schema.sql_identifier"),
+>            ("object_type", DomainType "information_schema.character_data"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.routine_privileges"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier"),
+>            ("routine_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("routine_schema", DomainType "information_schema.sql_identifier"),
+>            ("routine_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.routines"
+>           [("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier"),
+>            ("routine_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("routine_schema", DomainType "information_schema.sql_identifier"),
+>            ("routine_name", DomainType "information_schema.sql_identifier"),
+>            ("routine_type", DomainType "information_schema.character_data"),
+>            ("module_catalog", DomainType "information_schema.sql_identifier"),
+>            ("module_schema", DomainType "information_schema.sql_identifier"),
+>            ("module_name", DomainType "information_schema.sql_identifier"),
+>            ("udt_catalog", DomainType "information_schema.sql_identifier"),
+>            ("udt_schema", DomainType "information_schema.sql_identifier"),
+>            ("udt_name", DomainType "information_schema.sql_identifier"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("character_maximum_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("collation_name", DomainType "information_schema.sql_identifier"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("interval_type", DomainType "information_schema.character_data"),
+>            ("interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("type_udt_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("type_udt_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("type_udt_name", DomainType "information_schema.sql_identifier"),
+>            ("scope_catalog", DomainType "information_schema.sql_identifier"),
+>            ("scope_schema", DomainType "information_schema.sql_identifier"),
+>            ("scope_name", DomainType "information_schema.sql_identifier"),
+>            ("maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("dtd_identifier", DomainType "information_schema.sql_identifier"),
+>            ("routine_body", DomainType "information_schema.character_data"),
+>            ("routine_definition",
+>             DomainType "information_schema.character_data"),
+>            ("external_name", DomainType "information_schema.character_data"),
+>            ("external_language",
+>             DomainType "information_schema.character_data"),
+>            ("parameter_style",
+>             DomainType "information_schema.character_data"),
+>            ("is_deterministic",
+>             DomainType "information_schema.character_data"),
+>            ("sql_data_access",
+>             DomainType "information_schema.character_data"),
+>            ("is_null_call", DomainType "information_schema.character_data"),
+>            ("sql_path", DomainType "information_schema.character_data"),
+>            ("schema_level_routine",
+>             DomainType "information_schema.character_data"),
+>            ("max_dynamic_result_sets",
+>             DomainType "information_schema.cardinal_number"),
+>            ("is_user_defined_cast",
+>             DomainType "information_schema.character_data"),
+>            ("is_implicitly_invocable",
+>             DomainType "information_schema.character_data"),
+>            ("security_type", DomainType "information_schema.character_data"),
+>            ("to_sql_specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("to_sql_specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("to_sql_specific_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("as_locator", DomainType "information_schema.character_data"),
+>            ("created", DomainType "information_schema.time_stamp"),
+>            ("last_altered", DomainType "information_schema.time_stamp"),
+>            ("new_savepoint_level",
+>             DomainType "information_schema.character_data"),
+>            ("is_udt_dependent",
+>             DomainType "information_schema.character_data"),
+>            ("result_cast_from_data_type",
+>             DomainType "information_schema.character_data"),
+>            ("result_cast_as_locator",
+>             DomainType "information_schema.character_data"),
+>            ("result_cast_char_max_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_char_octet_length",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_char_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_char_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_collation_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_collation_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_collation_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_numeric_scale",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_datetime_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_interval_type",
+>             DomainType "information_schema.character_data"),
+>            ("result_cast_interval_precision",
+>             DomainType "information_schema.character_data"),
+>            ("result_cast_type_udt_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_type_udt_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_type_udt_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_scope_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_scope_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_scope_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("result_cast_maximum_cardinality",
+>             DomainType "information_schema.cardinal_number"),
+>            ("result_cast_dtd_identifier",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.schemata"
+>           [("catalog_name", DomainType "information_schema.sql_identifier"),
+>            ("schema_name", DomainType "information_schema.sql_identifier"),
+>            ("schema_owner", DomainType "information_schema.sql_identifier"),
+>            ("default_character_set_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("default_character_set_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("default_character_set_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("sql_path", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.sequences"
+>           [("sequence_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("sequence_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("sequence_name", DomainType "information_schema.sql_identifier"),
+>            ("data_type", DomainType "information_schema.character_data"),
+>            ("numeric_precision",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_precision_radix",
+>             DomainType "information_schema.cardinal_number"),
+>            ("numeric_scale", DomainType "information_schema.cardinal_number"),
+>            ("maximum_value", DomainType "information_schema.cardinal_number"),
+>            ("minimum_value", DomainType "information_schema.cardinal_number"),
+>            ("increment", DomainType "information_schema.cardinal_number"),
+>            ("cycle_option", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.table_constraints"
+>           [("constraint_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("constraint_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("constraint_type",
+>             DomainType "information_schema.character_data"),
+>            ("is_deferrable", DomainType "information_schema.character_data"),
+>            ("initially_deferred",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.table_privileges"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data"),
+>            ("with_hierarchy",
+>             DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.tables"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("table_type", DomainType "information_schema.character_data"),
+>            ("self_referencing_column_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("reference_generation",
+>             DomainType "information_schema.character_data"),
+>            ("user_defined_type_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("user_defined_type_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("user_defined_type_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("is_insertable_into",
+>             DomainType "information_schema.character_data"),
+>            ("is_typed", DomainType "information_schema.character_data"),
+>            ("commit_action", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.triggered_update_columns"
+>           [("trigger_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("trigger_schema", DomainType "information_schema.sql_identifier"),
+>            ("trigger_name", DomainType "information_schema.sql_identifier"),
+>            ("event_object_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("event_object_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("event_object_table",
+>             DomainType "information_schema.sql_identifier"),
+>            ("event_object_column",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.triggers"
+>           [("trigger_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("trigger_schema", DomainType "information_schema.sql_identifier"),
+>            ("trigger_name", DomainType "information_schema.sql_identifier"),
+>            ("event_manipulation",
+>             DomainType "information_schema.character_data"),
+>            ("event_object_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("event_object_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("event_object_table",
+>             DomainType "information_schema.sql_identifier"),
+>            ("action_order", DomainType "information_schema.cardinal_number"),
+>            ("action_condition",
+>             DomainType "information_schema.character_data"),
+>            ("action_statement",
+>             DomainType "information_schema.character_data"),
+>            ("action_orientation",
+>             DomainType "information_schema.character_data"),
+>            ("condition_timing",
+>             DomainType "information_schema.character_data"),
+>            ("condition_reference_old_table",
+>             DomainType "information_schema.sql_identifier"),
+>            ("condition_reference_new_table",
+>             DomainType "information_schema.sql_identifier"),
+>            ("condition_reference_old_row",
+>             DomainType "information_schema.sql_identifier"),
+>            ("condition_reference_new_row",
+>             DomainType "information_schema.sql_identifier"),
+>            ("created", DomainType "information_schema.time_stamp")],
+>         CatCreateView "information_schema.usage_privileges"
+>           [("grantor", DomainType "information_schema.sql_identifier"),
+>            ("grantee", DomainType "information_schema.sql_identifier"),
+>            ("object_catalog", DomainType "information_schema.sql_identifier"),
+>            ("object_schema", DomainType "information_schema.sql_identifier"),
+>            ("object_name", DomainType "information_schema.sql_identifier"),
+>            ("object_type", DomainType "information_schema.character_data"),
+>            ("privilege_type", DomainType "information_schema.character_data"),
+>            ("is_grantable", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.user_mapping_options"
+>           [("authorization_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier"),
+>            ("option_name", DomainType "information_schema.sql_identifier"),
+>            ("option_value", DomainType "information_schema.character_data")],
+>         CatCreateView "information_schema.user_mappings"
+>           [("authorization_identifier",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("foreign_server_name",
+>             DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.view_column_usage"
+>           [("view_catalog", DomainType "information_schema.sql_identifier"),
+>            ("view_schema", DomainType "information_schema.sql_identifier"),
+>            ("view_name", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("column_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.view_routine_usage"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("specific_catalog",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_schema",
+>             DomainType "information_schema.sql_identifier"),
+>            ("specific_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.view_table_usage"
+>           [("view_catalog", DomainType "information_schema.sql_identifier"),
+>            ("view_schema", DomainType "information_schema.sql_identifier"),
+>            ("view_name", DomainType "information_schema.sql_identifier"),
+>            ("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier")],
+>         CatCreateView "information_schema.views"
+>           [("table_catalog", DomainType "information_schema.sql_identifier"),
+>            ("table_schema", DomainType "information_schema.sql_identifier"),
+>            ("table_name", DomainType "information_schema.sql_identifier"),
+>            ("view_definition",
+>             DomainType "information_schema.character_data"),
+>            ("check_option", DomainType "information_schema.character_data"),
+>            ("is_updatable", DomainType "information_schema.character_data"),
+>            ("is_insertable_into",
+>             DomainType "information_schema.character_data")]]
+
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs b/src/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeChecking/ErrorUtils.lhs
@@ -0,0 +1,30 @@
+
+This file contains a bunch of small low level utilities to help with
+type checking.
+
+> module Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
+>     where
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
+> import Debug.Trace
+
+> type E a = Either [TypeError] a
+> type Et = E Type
+>
+> lmt :: Maybe a -> E a
+> lmt = maybe (Left []) Right
+>
+> tes :: E a -> [TypeError]
+> tes = either id (const [])
+>
+> etmt :: E a -> Maybe a
+> etmt = either (const Nothing) Just
+>
+
+> liftList :: [(a,Maybe b)] -> Maybe [(a,b)]
+> liftList is = sequence $ flip map is $ \(a,b) -> case b of
+>                                                    Just b' -> Just (a,b')
+>                                                    Nothing -> Nothing
+
+> showIt :: Show a => String -> a -> a
+> showIt m a = trace (m ++ " " ++ show a) a
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs b/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindings.lhs
@@ -0,0 +1,20 @@
+
+Forwarder for the interface to LocalBindingsInternal used by the rest
+of the system.
+
+> module Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindings
+>     (
+>      LocalBindingsUpdate(..)
+>     ,LocalBindings
+>     ,emptyBindings
+>     ,lbUpdate
+>     ,lbLookupID
+>     ,lbLookupIDInType
+>     ,ppLocalBindings
+>     ,createLocalBindings
+>     ,getUnqualifiedBindings
+>     ,joinBindings
+>     ,lookupLocalBinding
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindingsInternal
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindingsInternal.lhs b/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindingsInternal.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeChecking/LocalBindingsInternal.lhs
@@ -0,0 +1,740 @@
+
+This module contains the code to manage local identifier bindings
+during the type checking process. This is used for e.g. looking up the
+types of parameter and variable references in plpgsql functions, and
+for looking up the types of identifiers in select expressions.
+
+This module exposes the internals of the localbindings datatype for
+testing.
+
+The lookups to support are a single identifier, or to give a star
+expansion.
+
+
+Some notes on lookups
+all lookups are case insensitive
+start by searching the head of the lookup update list and working down
+the code here handles resolving the types of join columns when they
+are not the same, and the update routine returns error if the join columns are not compatible
+the code here handles expanding record types so that the components can be looked up
+
+The local bindings is arranged as a stack. To append to this stack,
+you use the LocalBindingsUpdate type. This is designed to be as easy as
+possible for clients to use, so as much logic as possible is pushed
+into the innards of this module, in particular most of the logic for
+working with joins is in here.
+
+The basic idea of the stack is at each level, there is a list of
+qualified and unqualified names and types, to look up individual
+ids. Some of the lookups map to ambiguous identifier errors. Also at
+each level is a list of star expansions, one for each correlation name
+in scope, and one for an unqualified star.
+
+> {-# LANGUAGE ScopedTypeVariables,TupleSections #-}
+>
+> module Database.HsSqlPpp.AstInternals.TypeChecking.LocalBindingsInternal
+>     (
+>      LocalBindingsUpdate(..)
+>     ,LocalBindings(..)
+>     ,Source
+>     ,FullId
+>     ,SimpleId
+>     ,IDLookup
+>     -- ,StarExpand
+>     ,LocalBindingsLookup(..)
+>     ,emptyBindings
+>     ,lbUpdate
+>     -- ,lbExpandStar
+>     ,lbLookupID
+>     ,lbLookupIDInType
+>     --,lbUpdateDot
+>     ,ppLocalBindings
+>     ,ppLbls
+>     ,createLocalBindings
+>     ,getUnqualifiedBindings
+>     ,joinBindings
+>     ,lookupLocalBinding
+>     ) where
+>
+> --import Control.Monad as M
+> --import Control.Applicative
+> --import Debug.Trace
+> import Data.List
+> --import Data.Maybe
+> import Data.Char
+> --import Data.Either
+> --import qualified Data.Map as M
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
+> --import Database.HsSqlPpp.Utils.Utils
+> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+> --import Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion
+> import Database.HsSqlPpp.AstInternals.TypeChecking.ErrorUtils
+>
+
+
+
+> data LocalBindings = LocalBindingsError
+>                    | LocalBindings [((String,String),Maybe Type)]
+
+> createLocalBindings :: Maybe [(String,[(String,Maybe Type)])] -> LocalBindings
+> createLocalBindings i =
+>   maybe LocalBindingsError mb i
+>   where
+>     mb b = LocalBindings
+>             $ flip concatMap b $ \(qn,cs) -> flip map cs $ \(c,t) -> ((qn,c), t)
+
+> getUnqualifiedBindings :: LocalBindings -> [(String,Maybe Type)]
+> getUnqualifiedBindings (LocalBindings ls) =
+>   map unwrap ls
+>   where
+>     unwrap ((_,n),t) = (n,t)
+> getUnqualifiedBindings LocalBindingsError = []
+
+> joinBindings :: LocalBindings -> LocalBindings -> LocalBindings
+> joinBindings (LocalBindings a) (LocalBindings b) = LocalBindings $ a ++ b
+> joinBindings LocalBindingsError _ = LocalBindingsError
+> joinBindings _ LocalBindingsError = LocalBindingsError
+
+> lookupLocalBinding :: LocalBindings -> String -> String -> E (Maybe Type)
+> lookupLocalBinding LocalBindingsError _ _ = Right Nothing
+> lookupLocalBinding (LocalBindings lb) q i =
+>   case lookup (q,i) lb of
+>     Just t -> Right t
+>     Nothing -> if (q == "") || any (==q) (map (fst . fst) lb)
+>                then Left [UnrecognisedIdentifier i]
+>                else Left [UnrecognisedCorrelationName q]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+---------------------------------------------
+
+
+
+The data type to represent a set of local bindings in scope. The list
+of updates used to create the local bindings is saved for debugging/
+information.
+
+> {-data LocalBindings = LocalBindings [LocalBindingsUpdate]
+>                                    [LocalBindingsLookup]
+>                      deriving Show-}
+
+Each layer of the local bindings stack is
+a map from (correlation name, id name) to source,correlation name, id
+name, type tuple, or a type error, used e.g. to represent ambigious
+ids, etc.;
+and a map from correlation name to a list of these tuples to handle
+star expansions.
+
+Missing correlation names are represented by an empty string for the
+correlation name.
+
+> type Source = String
+>
+> type FullId = (Source,[String],Type) -- source,fully qualified name components,type
+> type SimpleId = (String,Type)
+> type IDLookup = ([String], E FullId)
+> --type StarExpand = E [FullId] --the order of the [FullId] part is important
+>
+> data LocalBindingsLookup = LocalBindingsLookup [IDLookup]
+>                            deriving (Eq,Show)
+
+This is the local bindings update that users of this module use.
+
+> data LocalBindingsUpdate = LBIds {source :: Source
+>                                  ,correlationName :: Maybe String
+>                                  ,lbids :: [SimpleId]}
+>                          | LBTref {source :: Source
+>                                   ,talias :: String
+>                                   ,lbids :: [SimpleId]
+>                                   ,lbsysids :: [SimpleId]}
+>                          | LBJoinTref {source :: Source
+>                                       ,jtref1 :: LocalBindingsUpdate
+>                                       ,jtref2 :: LocalBindingsUpdate
+>                                       ,joinIds :: Either () [String] -- left () represents natural join
+>                                                            -- right [] represents no join ids
+>                                       ,jalias :: Maybe String}
+>                            deriving Show
+>
+> emptyBindings :: LocalBindings
+> emptyBindings = LocalBindings [] -- undefined --LocalBindings [] []
+
+================================================================================
+
+> ppLocalBindings :: LocalBindings -> String
+> ppLocalBindings = error "ppLocalBindings" -- (LocalBindings lbus lbls) =
+>   -- "LocalBindings\n" ++ doList show lbus ++ doList ppLbls lbls-}
+>
+> ppLbls :: LocalBindingsLookup -> String
+> ppLbls = error "ppLbls" {- (LocalBindingsLookup is) =
+>        "LocalBindingsLookup\n" ++ doList show is -}
+>
+> --doList :: (a -> String) -> [a] -> String
+> --doList m l = "[\n" ++ intercalate "\n," (map m l) ++ "\n]\n"
+
+================================================================================
+
+> lbUpdate :: Catalog -> LocalBindingsUpdate -> LocalBindings -> E LocalBindings
+> lbUpdate _ _ lb = return lb {- cat u1 (LocalBindings us s) = do
+>   ids <- updateStuff cat u1
+>   return $ LocalBindings (u1 : us) (LocalBindingsLookup ids : s)-}
+
+
+
+> --updateStuff :: Catalog -> LocalBindingsUpdate -> E [IDLookup]
+
+> --updateStuff _ _ = error "updateStuff"
+
+LBIds doesn't support any star expansion, and doesn't support
+accessing the whole set of ids as a composite via cn
+
+> {-updateStuff _ (LBIds src cn ids) =
+>     return (unQuals ++ quals)
+>     where
+>       unQuals = map (\(n,t) -> ([n], Right (src,maybe [n] (: [n]) cn, t))) ids
+>       quals = maybe [] (\cn' -> map (\(n,t) -> ([cn',n], Right (src,[cn',n], t))) ids) cn
+
+tref - used for a non join table reference, supports accessing public
+fields under the alias name as a composite, and also supports system
+id lookups. The star expansions are all the non system ids qualified and unqualified
+
+> updateStuff _ (LBTref src al ids sids) =
+>     -- comp has to come after unquals because an unqualified reference which could refer
+>     -- to a column or the composite resolves as the column
+>     return (unQuals ++ quals ++ [comp])
+>            -- ,[("",Right pids),(al,Right pids)])
+>     where
+>       allIds = ids ++ sids
+>       unQuals = map (\(n,t) -> ([n], Right (src,[al,n], t))) allIds
+>       quals = map (\(n,t) -> ([al,n], Right (src,[al,n], t))) allIds
+>       comp = ([al], Right (src, [al], CompositeType ids))
+>       pids = map (\(n,t) -> (src,[al,n],t)) ids
+
+
+LBJoinTref {source :: Source
+            ,jtref1 :: LocalBindingsUpdate
+            ,jtref2 :: LocalBindingsUpdate
+            ,joinIds :: Either () [String] -- left () represents natural join
+                  -- right [] represents no join ids
+            ,jalias :: Maybe String}
+
+> {-updateStuff cat (LBJoinTref _src u1 u2 jnames' _al) = do
+
+How to get the lbs for a join:
+
+First get the info for the two sub trefs:
+
+>   ids1 <- updateStuff cat u1
+>   ids2 <- updateStuff cat u2
+
+split these apart so we have the unqualified lookups and star expands
+separately
+
+>   let (uids1,qids1) = splitLkps ids1
+>       (uids2,qids2) = splitLkps ids2
+
+We need some information: the names and types of the join ids, and the
+names of any remaining ambiguous identifiers:
+
+>   let jnames :: [String]
+>       jnames = case jnames' of
+>                          Right ns -> ns
+>                          Left () -> intersect (map fst uids1)
+>                                               (map fst uids2)
+>   --todo: resolve these properly
+>   let jids = flip map jnames $ \i -> (i,fromJust $ lookup [i] ids1)
+
+
+First: get the names of the join ids: this is the explicit list in the
+case of a using join, or the commonly named fields in a natural
+join. We get the commonly named fields from the unqualified star
+expansions so we don't include system attributes in a natural join.
+
+Then check: make sure explicit join id list is in both trefs, and
+resolve the types of the join ids.
+
+If there is no alias:
+
+work out the lookups: the qualified lookups stay the same (doesn't
+properly deal with the same correlation names coming from 2 trefs at
+the moment).
+
+get the list of duplicate ids: uses the same code as getting the
+natural join id list, - there will be none if this is a natural
+join. Otherwise, get the list of common ids and remove any using ids
+from this list. TODO?: system attributes can't be referenced through a
+join unqualified?
+
+The unqualified lookups: start with the join ids and types, then add
+all the ids from each subtref except the ones which match the
+duplicate ids. Add these dups which now lookup to left ambiguous
+reference.
+
+work out the star expansion: the qualified star expansions stay the
+same
+
+for the unqualified star expansion: similar to lookups. Start with the
+join ids, but then add all the non join ids from each table - so we
+might have more than one column with the same name.
+
+If there is an alias:
+
+do the same as above for the unqualified ids/starexpand, add these
+again under the given alias, and don't pass through qualified lookups
+or star expands.
+
+
+>   {-let plainIds1 = pl ids1
+>       plainIds2 = pl ids2
+>   let jnames :: [String]
+>       jnames = case jids of
+>                          Right ns -> ns
+>                          Left () -> intersect (map fst plainIds1) (map fst plainIds2)
+>   -- make the lookups
+>       isJ :: IDLookup -> Bool
+>       isJ (ii,_) = case ii of
+>                        [i] | i `elem` jnames -> True
+>                        _ -> False
+>       nj :: [IDLookup] -> [IDLookup]
+>       nj = filter (not . isJ)
+>       joinLkps = filter isJ ids1
+>       nonJoinLkps1 = nj ids1
+>       nonJoinLkps2 = nj ids2-}
+>   {-let jids1 :: [(String,E FullId)]
+>       jids1 = flip map jnames $ \i -> (i,fromJust $ lookup i ids1)
+>       rj :: [(String,E FullId)] -> [(String,E FullId)]
+>       rj = filter $ \e -> fst e `notElem` jnames
+>       ids :: [(String,E FullId)]
+>       ids = jids1 ++ rj ids1 ++ rj ids2-}
+>   --make the star expansion
+>   --se1' <- se1
+>   --se2' <- se2
+>   {-let (us1',qs1) = splitSe se1'
+>       (us2',qs2) = splitSe se2'
+>   us1 <- us1'
+>   us2 <- us2'-}
+>   {-    rj1 :: [FullId] -> [FullId]
+>       rj1 = filter $ \(_,n,_t) -> last n `notElem` jnames
+>       se = map snd jids1 ++ map return (rj1 se1) ++ map return (rj1 se2)
+>   return (ids, sequence se)-}
+>   --let x = joinLkps ++ nonJoinLkps1 ++ nonJoinLkps2
+>   --trace ("join stuff: " ++ doList show x) $ return ()
+>   return (ids1 ++ ids1, se1 ++ se2) --(joinLkps ++ nonJoinLkps1 ++ nonJoinLkps2, ("", Right (us1 ++ us2)) : qs1 ++ qs2)
+>   where
+>     {-splitSe :: [(String,StarExpand)] -> (StarExpand,[(String,StarExpand)])
+>     splitSe se = (uq, nuq)
+>                  where
+>                    uq = maybe [] snd $ find isUq se
+>                    nuq = filter (not . isUq) se
+>                    isUq (Right (a,_)) = a == ""-}
+>     splitLkps :: [([String], E FullId)]
+>               -> ([(String, E FullId)],[([String], E FullId)])
+>     splitLkps = partitionEithers . (map $ \x -> case x of
+>                                                       ([n],t) -> Left (n,t)
+>                                                       z -> Right z)-} -}
+
+================================================================================
+
+> {-lbExpandStar :: LocalBindings -> String -> E [FullId]
+> lbExpandStar (LocalBindings _ (LocalBindingsLookup _ x : _)) c =
+>   maybe (case c of
+>            "" -> Left [BadStarExpand]
+>            y -> Left [UnrecognisedCorrelationName y])
+>            id $ lookup c x
+> lbExpandStar _ _ = Left [BadStarExpand]-}
+
+================================================================================
+
+> lbLookupID :: LocalBindings -> [String] -> E FullId
+> lbLookupID  = error "lbLookupID" {-(LocalBindings _ lbl) i =
+>     let ls :: [[([String],E FullId)]]
+>         ls = map getLbIdl lbl
+>     in lkp1 ls $ map mtl i
+>     where
+>       lkp1 :: [[IDLookup]] -> [String] -> E FullId
+>       lkp1 (l:ls) i1 = fromMaybe (lkp1 ls i1) (lookup i1 l)
+>       lkp1 [] _ = if corMatch
+>                   then Left [UnrecognisedIdentifier (intercalate "." i)]
+>                   else Left [UnrecognisedCorrelationName (head i)]
+>       getLbIdl (LocalBindingsLookup x ) = x
+>       corMatch = case i of
+>                    [q,_] -> q `elem` cors
+>                    _ -> True
+>       cors :: [String]
+>       cors = let ls = map getLbIdl lbl
+>              in catMaybes $ concatMap (map getQ) ls
+>       getQ :: ([String], E FullId) -> Maybe String
+>       getQ ([q,_], _) = Just q
+>       getQ _ = Nothing -}
+
+
+> lbLookupIDInType :: Catalog -> LocalBindings -> Type -> String -> E FullId
+> lbLookupIDInType = error "lbLookupIDInType" {-cat _ ty i = do
+>   t <- lmt $ getNamedCompositeTypes ty
+>   maybe (Left [UnrecognisedIdentifier i]) (fmap Right ("",[i],)) $ lookup i t
+>  where
+>    getNamedCompositeTypes :: Type -> Maybe [(String,Type)]
+>    getNamedCompositeTypes (NamedCompositeType n) =
+>         Just $ either (const []) id $ catCompositePublicAttrs cat [] n
+>    getNamedCompositeTypes (CompositeType t) = Just t
+>    getNamedCompositeTypes (PgRecord (Just t)) = getNamedCompositeTypes t
+>    getNamedCompositeTypes _ = Nothing -}
+
+================================================================================
+
+ > lbUpdateDot :: Catalog -> String -> LocalBindings -> E LocalBindings
+ > lbUpdateDot cat i lb = do
+ >     (_,_,c) <- lbLookupID lb i
+ >     f <- lmt $ expandComposite cat True c
+ >     lbUpdate cat (LBIds "dot qual" Nothing f) emptyBindings
+
+>     {-f <- lmt $ expandComposite cat True c
+>     let u1 = (LBIds "dot qual" Nothing f)
+>     (ids,_) <- updateStuff cat u1
+>     pf <- lmt $ expandComposite cat False c
+>     let se = Right $ map (\(n,t) -> ("dot qual", [i,n], t)) pf
+>     return $ LocalBindings [u1] [LocalBindingsLookup ids se]-}
+
+(Source, [String], Type)'
+           against inferred type `(String, Type)'
+
+ > expandComposite :: Catalog -> Bool -> Type -> Maybe [(String,Type)]
+ > expandComposite cat b (SetOfType t) = expandComposite cat b t
+ > expandComposite cat b (PgRecord (Just t)) = expandComposite cat b t
+ > expandComposite _ _ (CompositeType fs) = Just fs
+ > expandComposite cat b (NamedCompositeType n) = etmt $ (if b
+ >                                                        then catCompositeAttrs
+ >                                                        else catCompositePublicAttrs) cat [] n
+ > expandComposite _ _ _ = Nothing
+
+
+================================================================================
+
+> --mtl :: String -> String
+> --mtl = map toLower
+
+
+
+
+
+
+------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+wrapper for the proper lookupid function, this is for backwards
+compatibility with the old lookup code
+
+> {-lbLookupID :: LocalBindings
+>            -> String -- identifier name
+>            -> E Type
+> lbLookupID lb ci = let (cor,i) = splitIdentifier ci
+>                    in fmap extractType $ lbLookupID1 lb cor i
+>                    where
+>                      extractType (_,_,_,t) = t
+>                      splitIdentifier s = let (a,b) = span (/= '.') s
+>                                          in if b == ""
+>                                             then ("", a)
+>                                             else (a,tail b)
+>
+> lbLookupID1 :: LocalBindings
+>            -> String -- correlation name
+>            -> String -- identifier name
+>            -> E FullId -- type error or source, corr, type
+> lbLookupID1 (LocalBindings _ lkps) cor' i' =
+>   --trace ("lookup: " ++ showID cor' i'
+>   --       ++ "in " ++ concatMap ppLbls lkps) $
+>   -- hack for triggers
+>   case cor of
+>     "new" | isTrigRec -> Right ("", "new", i, UnknownType)
+>     "old" | isTrigRec -> Right ("", "old", i, UnknownType)
+>     _ -> lkId lkps
+>   where
+>     isTrigRec = case lbLookupID1 (LocalBindings undefined lkps) "" cor of
+>                   Right (_,_,_,Pseudo TriggerRecord) -> True
+>                   _ -> False
+>     cor = mtl cor'
+>     i = mtl i'
+>     lkId ((LocalBindingsLookup idmap _):ls) =
+>       case lookup (cor,i) idmap of
+>         Just s -> s
+>         Nothing -> if cor /= "" && any ((==cor) . fst . fst) idmap
+>                    then Left [UnrecognisedIdentifier $ showID cor i']
+>                    else lkId ls
+>     lkId [] = if cor' == "" --todo: need to throw unrecognised identifier, if the correlation name isn't "", a id isn't found, and there are other ids with that correlation name
+>               then Left [UnrecognisedIdentifier $ showID cor i']
+>               else Left [UnrecognisedCorrelationName cor']
+
+================================================================================
+
+wrapped for the proper expand star routine, for compatibility with the
+old implementation of local bindings
+
+> lbExpandStar :: LocalBindings -> String -> E [SimpleId]
+> lbExpandStar lb cor =
+>   fmap stripAll $ lbExpandStar1 lb cor
+>   where
+>     strip (_,_,n,t) = (n,t)
+>     stripAll = map strip
+>
+> lbExpandStar1 :: LocalBindings -> String -> E [FullId]
+> lbExpandStar1 (LocalBindings _ lkps) cor' =
+>   exSt lkps
+>   where
+>     cor = mtl cor'
+>     exSt ((LocalBindingsLookup _ lst):ls) =
+>         case lookup cor lst of
+>           Just s -> s
+>           Nothing -> exSt ls
+>     exSt [] = Left [UnrecognisedCorrelationName cor]
+
+================================================================================
+
+This is where constructing the local bindings lookup stacks is done
+
+> lbUpdate :: Catalog -> LocalBindingsUpdate -> LocalBindings -> E LocalBindings
+> lbUpdate cat lbu' (LocalBindings lbus lkps) = do
+>    lbl <- makeStack cat lbu
+>    lbl1 <- expandComposites cat lbl
+>    --trace ("update: " ++ ppLbls lbl1) $ return ()
+>    return $ LocalBindings (lbu':lbus) (lbl1:lkps)
+>    where
+>      lbu = lowerise lbu'
+>      -- make correlation names and id names case insensitive
+>      -- by making them all lowercase
+>      lowerise (LBIds src ids) =
+>        LBIds src (mtll ids)
+>      lowerise (LBJoinIds t1 t2 ji a) =
+>        LBJoinIds (lowerise t1) (lowerise t2) (fmap mtll1 ji) (mtl a)
+>      lowerise (LBParallel lbu1 lbu2) =
+>        LBParallel (lowerise lbu1) (lowerise lbu2)
+>      mtll = map (\(n,t) -> (mtl n, t))
+>      mtll1 = map (\l -> mtl l)
+>
+> makeStack :: Catalog -> LocalBindingsUpdate -> E LocalBindingsLookup
+> makeStack _ (LBIds src ids) =
+>   Right $ LocalBindingsLookup doIds doStar
+>   where
+>     doIds :: [((String,String)
+>               ,E FullId)]
+>     doIds = -- add unqualified if cor isn't empty string
+>             map (makeLookup "")
+>                    (case cor of
+>                             "" -> []
+>                             _ -> map addDetails ids ++ map addDetails iids)
+>             ++ map (makeLookup cor) (map addDetails ids ++ map addDetails iids)
+>             where
+>               makeLookup c1 (s,_,n,t)= ((c1,n), Right (s,cor,n,t))
+>     doStar :: [(String, E [FullId])]
+>     doStar = case cor of
+>                       "" -> []
+>                       _ -> [("",Right $ map addDetails ids)]
+>              ++ [(cor,Right $ map addDetails ids)]
+>     addDetails (n,t) = (src,cor,n,t)
+>
+> makeStack cat (LBJoinIds t1 t2 jns a) = do
+>   --first get the stacks from t1 and t2
+>   --combine the elements of these filtering out the join ids
+>   --
+>   (LocalBindingsLookup i1 s1) <- makeStack cat t1
+>   (LocalBindingsLookup i2 s2) <- makeStack cat t2
+>   -- get the names and types of the join columns
+>   let jns' = case jns of
+>              Left () -> -- natural join, so we have to work out the names
+>                         -- by looking at the common attributes
+>                         -- we do this by getting the star expansion
+>                         -- with no correlation name, and then finding
+>                         -- the ids which appear in both lists
+>                         -- (so this ignores internal ids)
+>                  let ic1 :: [FullId]
+>                      ic1 = fromRight [] $ maybe (Right []) id $ lookup "" s1
+>                      ic2 = fromRight [] $ maybe (Right []) id $ lookup "" s2
+>                      third (_,_,n,_) = n
+>                      ii1 :: [String]
+>                      ii1 = map third ic1
+>                      ii2 = map third ic2
+>                  in intersect ii1 ii2
+>              Right x -> x
+>       -- first prepare for the id lookups
+>       -- remove the join ids from the id lookups
+>       isJid ((_,n),_) = (n `elem` jns')
+>       removeJids = filter (not . isJid)
+>       i1' = removeJids i1
+>       i2' = removeJids i2
+>   jids <- M.sequence $ joinIDTypes i1 i2 jns'
+>   {-trace ("joinids: " ++ show jids
+>          ++ "\ni1 " ++ show i1
+>          ++ "\ni2 " ++ show i2
+>          ++ "\ni1' " ++ show i1'
+>          ++ "\ni2' " ++ show i2'
+>         ) $ return ()-}
+>   let jidsLk :: [IDLookup]
+>       jidsLk = if null i1 || null i2
+>                then [] --error?
+>                else let (_,Right (sc1,c1,_,_)) = head i1
+>                         (_,Right (sc2,c2,_,_)) = head i2
+>                     in flip concatMap jids $ \(n,t) -> [(("",n), Right (sc1,c1,n,t))
+>                                                        ,((c1,n), Right (sc1,c1,n,t))
+>                                                        ,((c2,n), Right (sc2,c2,n,t))
+>                                                        ]
+>       --jidsF :: [FullId]
+>       --jidsF = rights $ map snd jidsLk
+>       newIdLookups = (jidsLk ++ (combineAddAmbiguousErrors i1' i2'))
+>       -- now do the star expansions
+>       -- for each correlation name, remove any ids which match a join id
+>       -- then prepend the join ids to that list
+>       se = combineStarExpansions s1 s2 -- don't know if this is quite right
+>       removeJids1 :: StarLookup -> StarLookup
+>       removeJids1 (k,ids) = (k, fmap (filter (\(_,_,n,_) -> n `notElem` jns')) ids)
+>       prependJids :: StarLookup -> StarLookup
+>       prependJids (c, lkps) = case lkps of
+>                                 Left _ -> (c,lkps)
+>                                 Right r | null r -> (c,lkps)
+>                                 Right r -> let (s,c1,_,_) = head r
+>                                                ids = map (\(n,t) -> (s,c1,n,t)) jids
+>                                            in (c, fmap (ids++) lkps)
+>       newStarExpansion = map (prependJids . removeJids1) se
+>       -- if we have an alias then we just want unqualified ids, then
+>       -- the same ids with a t3 alias for both ids and star expansion
+>       -- with all the correlation names replaced with the alias
+>   if a == ""
+>     then return $ LocalBindingsLookup newIdLookups newStarExpansion
+>     else return $ LocalBindingsLookup (aliasIds newIdLookups) (aliasExps newStarExpansion)
+>   where
+>     aliasIds :: [IDLookup] -> [IDLookup]
+>     aliasIds lkps = let trimmed = filter (\((c,_),_) -> c == "") lkps
+>                         aliased = map (\(c,i) -> (c, fmap replaceCName i)) trimmed
+>                     in aliased ++ map (\((_,n),i) -> ((a,n),i)) aliased
+>     aliasExps :: [StarLookup] -> [StarLookup]
+>     aliasExps lkps = let is = fromMaybe (error "localbindingsinternal.makestack : fromJust") $
+>                               lookup "" lkps
+>                          aliased = fmap (map replaceCName) is
+>                      in [("",aliased), (a, aliased)]
+>     replaceCName (s,_,n,t) = (s,a,n,t)
+>     joinIDTypes :: [IDLookup] -> [IDLookup] -> [String] -> [E (String,Type)]
+>     joinIDTypes i1 i2 = map (joinIDType i1 i2)
+>     joinIDType :: [IDLookup] -> [IDLookup] -> String -> E (String,Type)
+>     joinIDType i1 i2 s = do
+>       (_,_,_,ty1) <- fromMaybe (Left [MissingJoinAttribute]) $
+>                      lookup ("",s) i1
+>       (_,_,_,ty2) <- fromMaybe (Left [MissingJoinAttribute]) $
+>                      lookup ("",s) i2
+>       ty <- resolveResultSetType cat [ty1,ty2]
+>       return (s,ty)
+>
+> makeStack cat (LBParallel u1 u2) = do
+>   -- get the two stacks,
+>   -- for any keys that appear in both respective lookups, replace with ambigious error
+>   -- and concatenate the lot
+>   (LocalBindingsLookup i1 s1) <- makeStack cat u1
+>   (LocalBindingsLookup i2 s2) <- makeStack cat u2
+>   return $ LocalBindingsLookup (combineAddAmbiguousErrors i1 i2) $ combineStarExpansions s1 s2
+>
+> combineStarExpansions :: [StarLookup] -> [StarLookup] -> [StarLookup]
+> combineStarExpansions s1 s2 =
+>   let p :: [(String, [(String, E [FullId])])]
+>       p = npartition fst (s1 ++ s2)
+>   in flip map p $ \(a,b) -> (a,concat <$> M.sequence (map snd b))
+>
+> combineAddAmbiguousErrors :: [IDLookup] -> [IDLookup] -> [IDLookup]
+> combineAddAmbiguousErrors i1 i2 =
+>   let commonIds = intersect (map fst i1) (map fst i2)
+>       removeCommonIds = filter (\a -> fst a `notElem` commonIds)
+>       fi1 = removeCommonIds i1
+>       fi2 = removeCommonIds i2
+>       errors = map (\(c,n) -> ((c,n),Left [AmbiguousIdentifier $ showID c n])) commonIds
+>   in fi1 ++ fi2 ++ errors
+
+===============================================================================
+
+> mtl :: String -> String
+> mtl = map toLower
+>
+> showID :: String -> String -> String
+> showID cor i = if cor == "" then i else cor ++ "." ++ i
+
+================================================================================
+
+expand composites
+
+slightly dodgy - run through all the unqualified ids in the idlookups, and if any
+have a composite type, add each element of that composite under the
+correlation name of the idlookup itself, and add a star expansion for
+that name also. This pretends that using a correlation name, composite
+name and id name as a three part id isn't possible
+
+> expandComposites :: Catalog -> LocalBindingsLookup -> E LocalBindingsLookup
+> expandComposites cat (LocalBindingsLookup idlkp stlkp) = do
+>   let unqids = filter (\((a,_),_) -> a == "") idlkp
+>       strip = map snd unqids
+>       getComposites = filter (\(_,_,_,t) -> isCt t) $ rights strip
+>   comps <- mapM compExp getComposites
+>   let sts = map toStarLookup comps
+>   Right (LocalBindingsLookup (idlkp ++ (concat comps)) (stlkp ++ sts))
+>   where
+>     isCt (SetOfType t) = isCompositeType t
+>     isCt t = isCompositeType t
+>     getCompFields :: Type -> E [(String,Type)]
+>     getCompFields (SetOfType t) = getCompFields t
+>     getCompFields (PgRecord Nothing) = Right []
+>     getCompFields (PgRecord (Just t)) = getCompFields t
+>     getCompFields (CompositeType f) = return f
+>     getCompFields (NamedCompositeType s) = catCompositePublicAttrs cat [] s
+>     getCompFields (AnonymousRecordType _) = Right [] -- ??
+>     getCompFields _ = Right []
+>     compExp :: FullId -> E [IDLookup]
+>     compExp (s,_,n,t) = do
+>       f <- getCompFields t
+>       return $ flip map f $ \(n1,t1) -> ((n,n1),Right (s,n,n1,t1))
+>     toStarLookup :: [IDLookup] -> StarLookup
+>     toStarLookup ids =
+>       let fids::[FullId]
+>           fids = rights $ map snd ids
+>           (_,c,_,_) = if null fids then (undefined,"ERROR",undefined,undefined) else head fids
+>       in (c,Right fids)-}
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs b/src/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeChecking/TypeConversion.lhs
@@ -0,0 +1,668 @@
+
+
+This file contains the functions for resolving types and
+function/operator resolution. See the pg manual chapter 10:
+
+http://www.postgresql.org/docs/8.4/interactive/typeconv.html
+
+This code is really spaghettified.
+
+findCallMatch - pass in a name and a list of arguments, and it returns
+the matching function. (pg manual 10.2,10.3)
+
+resolveResultSetType - pass in a set of types, and it tries to find
+the common type they can all be cast to. (pg manual 10.5)
+
+checkAssignmentValid - pass in source type and target type, returns
+                typelist[] if ok, otherwise error, pg manual 10.4
+                Value Storage
+
+> {-# LANGUAGE PatternGuards #-}
+> module Database.HsSqlPpp.AstInternals.TypeChecking.TypeConversion (
+>                        findCallMatch
+>                       ,resolveResultSetType
+>                       ,checkAssignmentValid
+>                       ,checkAssignmentsValid
+>                       ) where
+>
+> import Data.Maybe
+> import Data.List
+> import Data.Either
+> --import Debug.Trace
+> import Data.Char
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
+> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+> import Database.HsSqlPpp.Utils.Utils
+
+ > traceIt :: Show a => String -> a -> a
+ > traceIt s t = trace (s ++ ": " ++ show t) t
+
+= findCallMatch
+
+~~~~
+
+findCallMatch - partially implements the type conversion rules for
+finding an operator or function match given a name and list of
+arguments with partial or fully specified types
+
+TODO:, qualifiers
+namespaces
+function style casts not in catalog
+variadic args
+default args
+domains -> base type
+what about aggregates and window functions?
+
+Algo:
+
+cands = all fns with matching names
+        and same number of args
+
+if exact match on types in this list, use it
+  (if binary operator being matched, and one arg is typed and one is
+  unknown, also match an operator by assuming the unknown is the same
+  as the typed arg)
+
+best match part:
+
+filter cands with args which don't exactly match input args, and input
+args cannot be converted by an implicit cast. unknowns count as
+matching anything
+if one left: use it
+
+filter for preferred types:
+
+for each cand, count each arg at each position which needs conversion,
+and the cand type is a preferred type at that position.
+if there are cands with count>0, keep only cands with the max count,
+if one return it
+if there are no cands with count>0, keep them all
+
+check unknowns:
+if any input args are unknown, and any cand accepts string at that
+position, fix that arg's category as string, otherwise if all cands
+accept same category at that position, fix that input args as that
+category.
+if we still have unknowns, then fail
+
+discard cands which don't match the new input arg/category list
+
+for each categorised input arg, if any cand accepts preferred type at
+that position, get rid of cands which don't accept preferred type at
+that position
+
+if one left: use
+else fail
+
+polymorphic matching:
+want to create a set of matches to insert into the cast pairs list
+so:
+
+find all matches on name, num args and have polymorphic parameters
+
+for each one, check the polymorphic categories - eliminate fns that
+have params in wrong category - array, non array, enum.
+work out the base types for the polymorphic args at each spot based on
+the args passed - so each arg is unchanged except arrays which have
+the array part stripped off
+
+now we have a list of types to match against the polymorphic params,
+use resolveResultSetType to see if we can produce a match, if so,
+create a new prototype which is the same as the polymorphic function
+but with this matching arg swapped in, work out the casts and add it
+into cand cast pairs, after exact match has been run.
+
+
+findCallMatch is a bit of a mess
+
+todos:
+
+rewrite this to try to make it a bit clearer
+
+find some way to draw a data flow diagram of the code easily
+
+add a logging facility so the function can explain what has happened
+at each state, so you can provide a detailed explanation e.g. if the
+code can't find an operator match to see what it has tried to match
+against.
+
+~~~~
+
+> type ProtArgCast = (FunctionPrototype, [ArgCastFlavour])
+
+>       {-
+>         between, greatest and least are treated as syntactic sugar so we
+>         delegate the function lookups to the <=/>= operators.
+>         the row comparison should be more general than this, since it supports
+>         any operator satisfying some properties
+> -}
+> findCallMatch :: Catalog -> String -> [Type] ->  Either [TypeError] FunctionPrototype
+> findCallMatch cat fnName' argsType =
+>     --trace ("typecheckfncall " ++ fnName' ++ show argsType) $
+>     --dependsOnRTpe argsType $
+>       case fnName of
+>               "count" -> -- not quite sure how this is suppose to work,
+>                          -- the counts in the pg catalog accept either
+>                          -- no args, or one arg of type any, but you can call
+>                          -- count with multiple arguments?
+>                          return ("count", argsType, typeBigInt, False)
+>               "!between" | as@[_,_,_] <- argsType -> do
+>                     -- not sure if this is correct - use the result set resolution
+>                     -- to make the argument types compatible
+>                     -- then just check there is a >=, <= returning a pair
+>                     -- of somethings which can be anded
+>                     t <- resolveResultSetType cat as
+>                     f1 <- lookupReturnType ">=" [t,t]
+>                     f2 <- lookupReturnType "<=" [t,t]
+>                     _ <- lookupFn "!and" [f1,f2]
+>                     return ("!between", [t,t,t], typeBool, False)
+>               "greatest" -> do
+>                     (_,a,t,x) <- lookupFn fnName argsType
+>                     _ <- lookupFn ">=" [t,t]
+>                     return ("greatest",a,t,x)
+>               "least" -> do
+>                     (_,a,t,x) <- lookupFn fnName argsType
+>                     _ <- lookupFn "<=" [t,t]
+>                     return ("greatest",a,t,x)
+>               "!rowctor" -> return ("!rowCtor", argsType, AnonymousRecordType argsType, False)
+>                     -- special case the row comparison ops
+>                     -- this needs to be fixed: we want to match
+>                     -- any implicit casts to functions on composite types
+>                     -- first, then we can use the anonymous record type on
+>                     -- any composite
+>               "." | [_,b] <- argsType -> Right (".", argsType, b, False)
+>               _ | fnName `elem` ["=", "<>", "<=", ">=", "<", ">"]
+>                          && length argsType == 2
+>                          && all isCompositeOrSetOfCompositeType argsType,
+>                          Just a1 <- matchCompTypes argsType ->
+>                          -- && compositesCompatible cat (head argsType) (head $ tail argsType) ->
+>                              return (fnName, a1, typeBool, False)
+>               --checked for all special cases, so run general case now
+>               s -> lookupFn s argsType
+>     where
+>       lookupReturnType :: String -> [Type] -> Either [TypeError] Type
+>       lookupReturnType s1 args = fmap (\(_,_,r,_) -> r) $ lookupFn s1 args
+>       lookupFn :: String -> [Type] -> Either [TypeError] FunctionPrototype
+>       lookupFn s1 = findCallMatch1 cat
+>                              (if s1 == "u-" then "-" else s1)
+>       fnName = map toLower fnName'
+>       -- help the type inference for rowCtors. pretty unfinished. If we compare
+>       -- two compatible row constructors, then replace any unknown types with the
+>       -- pair type
+>       matchCompTypes :: [Type] -> Maybe [Type]
+>       matchCompTypes [a@(AnonymousRecordType as),b@(AnonymousRecordType bs)] =
+>         if not (compositesCompatible cat a b)
+>         then Nothing
+>         else let (nt1,nt2) = unzip $ map (\(t,t1) -> case (t,t1) of
+>                                          (UnknownType, u) -> (u,u)
+>                                          (u, UnknownType) -> (u,u)
+>                                          _ -> (t,t1)) $ zip as bs
+>              in Just [AnonymousRecordType nt1,AnonymousRecordType nt2]
+>       matchCompTypes [a,b] =
+>         if not (compositesCompatible cat a b)
+>         then Nothing
+>         else Just [a,b]
+>       matchCompTypes _ = Nothing
+
+
+>
+> findCallMatch1 :: Catalog -> String -> [Type] ->  Either [TypeError] FunctionPrototype
+> findCallMatch1 cat f inArgs =
+>     returnIfOnne [
+>        exactMatch
+>       ,binOp1UnknownMatch
+>       ,polymorpicExactMatches
+>       ,reachable
+>       ,mostExactMatches
+>       ,filteredForPreferred
+>       ,unknownMatchesByCat]
+>       [NoMatchingOperator f inArgs]
+>     where
+>       -- basic lists which roughly mirror algo
+>       -- get the possibly matching candidates
+>       initialCandList :: [FunctionPrototype]
+>       initialCandList = filter (\(_,candArgs,_,_) ->
+>                                   length candArgs == length inArgs) $
+>                                map expandVariadic $ catLookupFns cat f
+>
+>       expandVariadic fp@(fn,a,r,v) =
+>         if v
+>           then case last a of
+>                  ArrayType t -> (fn, na,r,v)
+>                                 where na = init a ++ replicate (length inArgs - length a + 1) t
+>                  _ -> fp --should be error
+>           else fp
+>
+>       -- record what casts are needed for each candidate
+>       castPairs :: [[ArgCastFlavour]]
+>       castPairs = map (listCastPairs . getFnArgs) initialCandList
+>
+>       candCastPairs :: [ProtArgCast]
+>       candCastPairs = {-traceIt "candCastPairs" $-} zip initialCandList castPairs
+>
+>       -- see if we have an exact match
+>       exactMatch :: [ProtArgCast]
+>       exactMatch = filterCandCastPairs (all (==ExactMatch)) candCastPairs
+>
+>       -- implement the one known, one unknown resolution for binary operators
+>       binOp1UnknownMatch :: [ProtArgCast]
+>       binOp1UnknownMatch = getBinOp1UnknownMatch candCastPairs
+>
+>       --collect possible polymorphic matches
+>       polymorphicMatches :: [ProtArgCast]
+>       polymorphicMatches = filterPolymorphics candCastPairs
+>
+>       polymorpicExactMatches :: [ProtArgCast]
+>       polymorpicExactMatches = filterCandCastPairs (all (==ExactMatch)) polymorphicMatches
+>
+>       -- eliminate candidates for which the inargs cannot be casted to
+>       reachable :: [ProtArgCast]
+>       reachable = mergePolys (filterCandCastPairs (none (==CannotCast)) candCastPairs)
+>                     polymorphicMatches
+>
+>       mostExactMatches :: [ProtArgCast]
+>       mostExactMatches =
+>         let inArgsBase = map (replaceWithBase cat) inArgs
+>             exactCounts :: [Int]
+>             exactCounts =
+>               map ((length
+>                       . filter (\(a1,a2) -> a1==replaceWithBase cat a2)
+>                       . zip inArgsBase)
+>                 . (\((_,a,_,_),_) -> a)) reachable
+>             pairs = zip reachable exactCounts
+>             maxm = maximum exactCounts
+>         in case () of
+>              _ | null reachable -> []
+>                | maxm > 0 -> map fst $ filter (\(_,b) -> b == maxm) pairs
+>                | otherwise -> []
+>
+>       -- keep the cands with the most casts to preferred types
+>       preferredTypesCounts = countPreferredTypeCasts reachable
+>       keepCounts = maximum preferredTypesCounts
+>       itemCountPairs :: [(ProtArgCast,Int)]
+>       itemCountPairs = zip reachable preferredTypesCounts
+>       filteredForPreferred :: [ProtArgCast]
+>       filteredForPreferred = map fst $ filter (\(_,i) -> i == keepCounts) itemCountPairs
+>
+>       -- collect the inArg type categories to do unknown inArg resolution
+>       argCats :: [Either () String]
+>       argCats = getCastCategoriesForUnknowns filteredForPreferred
+>       unknownMatchesByCat :: [ProtArgCast]
+>       unknownMatchesByCat = getCandCatMatches filteredForPreferred argCats
+>
+>       -------------
+>
+>       listCastPairs :: [Type] -> [ArgCastFlavour]
+>       listCastPairs l = listCastPairs' inArgs l
+>                         where
+>                           listCastPairs' :: [Type] -> [Type] -> [ArgCastFlavour]
+>                           listCastPairs' (ia:ias) (ca:cas) =
+>                               (case () of
+>                                  _ | ia == ca -> ExactMatch
+>                                    | castableFromTo cat ImplicitCastContext ia ca ->
+>                                        if forceRight (catPreferredType cat ca)
+>                                          then ImplicitToPreferred
+>                                          else ImplicitToNonPreferred
+>                                    | otherwise -> CannotCast
+>                               ) : listCastPairs' ias cas
+>                           listCastPairs' [] [] = []
+>                           listCastPairs' _ _ = error "internal error: mismatched num args in implicit cast algorithm"
+>
+>
+>       getBinOp1UnknownMatch :: [ProtArgCast] -> [ProtArgCast]
+>       getBinOp1UnknownMatch cands =
+>           if not (isOperatorName f &&
+>                   length inArgs == 2 &&
+>                   count (==UnknownType) inArgs == 1)
+>             then []
+>             else let newInArgs =
+>                          replicate 2 (if head inArgs == UnknownType
+>                                         then inArgs !! 1
+>                                         else head inArgs)
+>                  in filter (\((_,a,_,_),_) -> a == newInArgs) cands
+>
+>       filterPolymorphics :: [ProtArgCast] -> [ProtArgCast]
+>       filterPolymorphics cl =
+>           let ms :: [ProtArgCast]
+>               ms = filter canMatch polys
+>               polyTypes :: [Maybe Type]
+>               polyTypes = map resolvePolyType ms
+>               polyTypePairs :: [(Maybe Type, ProtArgCast)]
+>               polyTypePairs = zip polyTypes ms
+>               keepPolyTypePairs :: [(Type, ProtArgCast)]
+>               keepPolyTypePairs =
+>                 mapMaybe (\(t,p) -> case t of
+>                                            Nothing -> Nothing
+>                                            Just t' -> Just (t',p))
+>                               polyTypePairs
+>               finalRows = map (\(t,p) -> instantiatePolyType p t)
+>                               keepPolyTypePairs
+>               --create the new cast lists
+>               cps :: [[ArgCastFlavour]]
+>               cps = map (listCastPairs . getFnArgs . fst) finalRows
+>           in zip (map fst finalRows) cps
+>           where
+>             polys :: [ProtArgCast]
+>             polys = filter (\((_,a,_,_),_) -> any (`elem`
+>                                               -- bit hacky
+>                                              [Pseudo Any
+>                                              ,Pseudo AnyArray
+>                                              ,Pseudo AnyElement
+>                                              ,Pseudo AnyEnum
+>                                              ,Pseudo AnyNonArray]) a) cl
+>             canMatch :: ProtArgCast -> Bool
+>             canMatch pac =
+>                let ((_,fnArgs,_,_),_) = pac
+>                in canMatch' inArgs fnArgs
+>                where
+>                  canMatch' [] [] = True
+>                  canMatch' (ia:ias) (pa:pas) =
+>                    case pa of
+>                      Pseudo Any -> nextMatch
+>                      Pseudo AnyArray -> isArrayType ia && nextMatch
+>                      Pseudo AnyElement -> nextMatch
+>                      Pseudo AnyEnum -> False
+>                      Pseudo AnyNonArray -> if isArrayType ia
+>                                              then False
+>                                              else nextMatch
+>                      _ -> True
+>                    where
+>                      nextMatch = canMatch' ias pas
+>                  canMatch' _ _ = error "internal error: mismatched lists in canMatch'"
+>             resolvePolyType :: ProtArgCast -> Maybe Type
+>             resolvePolyType ((_,fnArgs,_,_),_) =
+>                 {-trace ("\nresolving " ++ show fnArgs ++ " against " ++ show inArgs ++ "\n") $-}
+>                 let argPairs = zip inArgs fnArgs
+>                     typeList :: [Type]
+>                     typeList = catMaybes $ flip map argPairs
+>                                  $ \(ia,fa) -> case fa of
+>                                                   Pseudo Any -> if isArrayType ia
+>                                                                 then eitherToMaybe $ unwrapArray ia
+>                                                                 else Just ia
+>                                                   Pseudo AnyArray -> eitherToMaybe $ unwrapArray ia
+>                                                   Pseudo AnyElement -> if isArrayType ia
+>                                                                        then eitherToMaybe $ unwrapArray ia
+>                                                                        else Just ia
+>                                                   Pseudo AnyEnum -> Nothing
+>                                                   Pseudo AnyNonArray -> Just ia
+>                                                   _ -> Nothing
+>                 in {-trace ("\nresolve types: " ++ show typeList ++ "\n") $-}
+>                    case resolveResultSetType cat typeList of
+>                      Left _ -> Nothing
+>                      Right t -> Just t
+>             instantiatePolyType :: ProtArgCast -> Type -> ProtArgCast
+>             instantiatePolyType pac t =
+>               let ((fn,a,r,v),_) = pac
+>                   instArgs = swapPolys t a
+>                   p1 = (fn, instArgs, swapPoly t r,v)
+>               in let x = (p1,listCastPairs instArgs)
+>                  in {-trace ("\nfixed:" ++ show x ++ "\n")-} x
+>               where
+>                 swapPolys :: Type -> [Type] -> [Type]
+>                 swapPolys = map . swapPoly
+>                 swapPoly :: Type -> Type -> Type
+>                 swapPoly pit at =
+>                   case at of
+>                     Pseudo Any -> if isArrayType at
+>                                     then ArrayType pit
+>                                     else pit
+>                     Pseudo AnyArray -> ArrayType pit
+>                     Pseudo AnyElement -> if isArrayType at
+>                                            then ArrayType pit
+>                                            else pit
+>                     Pseudo AnyEnum -> pit
+>                     Pseudo AnyNonArray -> pit
+>                     SetOfType (Pseudo AnyElement) -> if isArrayType at
+>                                                      then SetOfType (ArrayType pit)
+>                                                      else SetOfType pit
+>                     _ -> at
+>       --merge in the instantiated poly functions, with a twist:
+>       -- if we already have the exact same set of args in the non poly list
+>       -- as a poly, then don't include that poly
+>       mergePolys :: [ProtArgCast] -> [ProtArgCast] -> [ProtArgCast]
+>       mergePolys orig polys =
+>           let origArgs = map (\((_,a,_,_),_) -> a) orig
+>               filteredPolys = filter (\((_,a,_,_),_) -> a `notElem` origArgs) polys
+>           in orig ++ filteredPolys
+>
+>       countPreferredTypeCasts :: [ProtArgCast] -> [Int]
+>       countPreferredTypeCasts =
+>           map (\(_,cp) -> count (==ImplicitToPreferred) cp)
+>
+>       -- Left () is used for inArgs which aren't unknown,
+>       --                      and for unknowns which we don't have a
+>       --                      unique category
+>       -- Right s -> s is the single letter category at
+>       --                           that position
+>       getCastCategoriesForUnknowns :: [ProtArgCast] -> [Either () String]
+>       getCastCategoriesForUnknowns cands =
+>           filterArgN 0
+>           where
+>             candArgLists :: [[Type]]
+>             candArgLists = map (\((_,a,_,_), _) -> a) cands
+>             filterArgN :: Int -> [Either () String]
+>             filterArgN n =
+>                 if n == length inArgs
+>                   then []
+>                   else let targType = inArgs !! n
+>                        in ((if targType /= UnknownType
+>                               then Left ()
+>                               else getCandsCatAt n) : filterArgN (n+1))
+>                 where
+>                   getCandsCatAt :: Int -> Either () String
+>                   getCandsCatAt n' =
+>                       let typesAtN = map (!!n') candArgLists
+>                           catsAtN = map (forceRight . catTypeCategory cat) typesAtN
+>                       in case () of
+>                            --if any are string choose string
+>                            _ | any (== "S") catsAtN -> Right "S"
+>                              -- if all are same cat choose that
+>                              | all (== head catsAtN) catsAtN -> Right $ head catsAtN
+>                              -- otherwise no match, this will be
+>                              -- picked up as complete failure to match
+>                              -- later on
+>                              | otherwise -> Left ()
+>
+>       getCandCatMatches :: [ProtArgCast] -> [Either () String] -> [ProtArgCast]
+>       getCandCatMatches candsA cats = getMatches candsA 0
+>          where
+>            getMatches :: [ProtArgCast] -> Int -> [ProtArgCast]
+>            getMatches cands n =
+>                case () of
+>                  _ | n == length inArgs -> cands
+>                    | (inArgs !! n) /= UnknownType -> getMatches cands (n + 1)
+>                    | otherwise ->
+>                        let catMatches :: [ProtArgCast]
+>                            catMatches = filter (\c -> Right (getCatForArgN n c) ==
+>                                                      (cats !! n)) cands
+>                            prefMatches :: [ProtArgCast]
+>                            prefMatches = filter (forceRight . catPreferredType cat .
+>                                                    getTypeForArgN n) catMatches
+>                            keepMatches :: [ProtArgCast]
+>                            keepMatches = if length prefMatches > 0
+>                                            then prefMatches
+>                                            else catMatches
+>                        in getMatches keepMatches (n + 1)
+>            getTypeForArgN :: Int -> ProtArgCast -> Type
+>            getTypeForArgN n ((_,a,_,_),_) = a !! n
+>            getCatForArgN :: Int -> ProtArgCast -> String
+>            getCatForArgN n = forceRight . catTypeCategory cat . getTypeForArgN n
+>
+>       -- utils
+>       -- filter a candidate/cast flavours pair by a predicate on each
+>       -- individual cast flavour
+>       filterCandCastPairs :: ([ArgCastFlavour] -> Bool)
+>                           -> [ProtArgCast]
+>                           -> [ProtArgCast]
+>       filterCandCastPairs predi = filter (\(_,cp) -> predi cp)
+>
+>       getFnArgs :: FunctionPrototype -> [Type]
+>       getFnArgs (_,a,_,_) = a
+>       returnIfOnne [] e = Left e
+>       returnIfOnne (l:ls) e = if length l == 1
+>                               then Right $ getHeadFn l
+>                               else returnIfOnne ls e
+>
+>       getHeadFn :: [ProtArgCast] -> FunctionPrototype
+>       getHeadFn l =  let ((hdFn, _):_) = l
+>                      in hdFn
+>       none p = not . any p
+>       count p = length . filter p
+>
+> data ArgCastFlavour = ExactMatch
+>                     | CannotCast
+>                     | ImplicitToPreferred
+>                     | ImplicitToNonPreferred
+>                       deriving (Eq,Show)
+>
+
+~~~~
+resolveResultSetType -
+partially implement the typing of results sets where the types aren't
+all the same and not unknown
+used in union,except,intersect columns, case, array ctor, values, greatest and least
+
+algo:
+if all inputs are same and not unknown -> that type
+replace domains with base types
+if all inputs are unknown then text
+if the non unknown types aren't all in same category then fail
+choose first input type that is a preferred type if there is one
+choose last non unknown type that has implicit casts from all preceding inputs
+check all can convert to selected type else fail
+
+code is not as much of a mess as findCallMatch
+~~~~
+
+> resolveResultSetType :: Catalog -> [Type] -> Either [TypeError] Type
+> resolveResultSetType cat inArgs = do
+>   errorWhen (null inArgs) [TypelessEmptyArray]
+>   returnWhen allSameType (head inArgs) $ do
+>   returnWhen allSameBaseType (head inArgsBase) $ do
+>   --returnWhen allUnknown (UnknownType) $ do
+>   errorWhen (not allSameCat) [IncompatibleTypeSet inArgs]
+>   returnWhen (isJust targetType &&
+>               allConvertibleToFrom (fromMaybe (error "TypeConversion.resolveresultsettype 1: fromJust") targetType) inArgs)
+>               (fromMaybe (error "TypeConversion.resolveresultsettype 2: fromJust") targetType) $ do
+>   Left [IncompatibleTypeSet inArgs]
+>   where
+>      allSameType = all (== head inArgs) inArgs -- &&
+>                      --head inArgs /= UnknownType
+>      allSameBaseType = all (== head inArgsBase) inArgsBase &&
+>                      head inArgsBase /= UnknownType
+>      inArgsBase = map (replaceWithBase cat) inArgs
+>      --allUnknown = all (==UnknownType) inArgsBase
+>      allSameCat = let firstCat = catTypeCategory cat (head knownTypes)
+>                   in all (\t -> catTypeCategory cat t == firstCat)
+>                          knownTypes
+>      targetType = case catMaybes [firstPreferred, lastAllConvertibleTo] of
+>                     [] -> Nothing
+>                     (x:_) -> Just x
+>      firstPreferred = find (forceRight . catPreferredType cat) knownTypes
+>      lastAllConvertibleTo = firstAllConvertibleTo (reverse knownTypes)
+>      firstAllConvertibleTo (x:xs) = if allConvertibleToFrom x xs
+>                                       then Just x
+>                                       else firstAllConvertibleTo xs
+>      firstAllConvertibleTo [] = Nothing
+>      knownTypes = filter (/=UnknownType) inArgsBase
+>      allConvertibleToFrom = all . flip (castableFromTo cat ImplicitCastContext)
+
+todo:
+cast empty array, where else can an empty array work?
+
+================================================================================
+
+= checkAssignmentValue
+
+> checkAssignmentValid :: Catalog -> Type -> Type -> Either [TypeError] ()
+> checkAssignmentValid cat from to =
+>     if castableFromTo cat AssignmentCastContext from to
+>     then Right ()
+>     else Left [IncompatibleTypes to from]
+>
+> compositesCompatible :: Catalog -> Type -> Type -> Bool
+> compositesCompatible cat =
+>     castableFromTo cat ImplicitCastContext
+
+> checkAssignmentsValid :: Catalog -> [Type] -> [Type] -> Either [TypeError] ()
+> checkAssignmentsValid cat from to = do
+>     -- special case for assigning to composite
+>     let f = case to of
+>                    [t] | isCompositeType t -> [AnonymousRecordType from]
+>                    _ -> from
+>     errorWhen (length f /= length to)
+>               [WrongNumberOfColumns]
+>     let ls = concat $ lefts $ zipWith (checkAssignmentValid cat) f to
+>     errorWhen (not (null ls)) ls
+
+
+================================================================================
+
+= castable function
+
+wrapper around the catalog to add a bunch of extra valid casts
+
+> castableFromTo :: Catalog -> CastContext -> Type -> Type -> Bool
+> castableFromTo cat cc from to =
+>   --trace ("check cast " ++ show from ++ "->" ++ show to) $
+>   -- put this here to avoid having to write it everywhere else
+>   from == to
+>   -- unknown can be implicitly cast to anything (is this completely true?)
+>   || from == UnknownType
+>   --hack?
+>   || to == UnknownType
+>   -- check base types of domains
+>   || ((isDomainType from || isDomainType to)
+>       && castableFromTo cat cc (replaceWithBase cat from)
+>                                (replaceWithBase cat to))
+>   -- check the casts listed in the catalog
+>   || forceRight (catCast cat cc from to)
+>   -- implicitcast => assignment cast
+>   || (cc == AssignmentCastContext
+>       && forceRight (catCast cat ImplicitCastContext from to))
+>   -- can assign composite to record
+>   || (cc == AssignmentCastContext
+>       && isCompOrSetoOfComp from
+>       && case to of
+>            PgRecord _ -> True
+>            _ -> False)
+>   -- check unboxing: wrapped single attribute
+>   || recurseTransFrom (unboxedSingleType from)
+>   || recurseTransTo (unboxedSingleType to)
+>   -- check unboxing: wrapped composite
+>   || recurseTransFrom (unboxedSetOfType from)
+>   || recurseTransTo (unboxedSetOfType to)
+>   -- check composites compatible by comparing attribute types
+>   || case (getCompositeTypes from
+>           ,getCompositeTypes to) of
+>        -- zip almost does the right thing here, needs a bit of tweaking
+>        (Just ft, Just tt) | length ft == length tt -> all (uncurry $ castableFromTo cat cc) $ zip ft tt
+>        _ -> False
+>   where
+>
+>     getCompositeTypes (NamedCompositeType n) =
+>         Just $ map snd $ fromRight [] $ catCompositePublicAttrs cat [] n
+>     getCompositeTypes (CompositeType t) = Just $ map snd t
+>     getCompositeTypes (AnonymousRecordType t) = Just t
+>     getCompositeTypes (PgRecord Nothing) = Nothing
+>     getCompositeTypes (PgRecord (Just t)) = getCompositeTypes t
+>     getCompositeTypes _ = Nothing
+>
+>     isCompOrSetoOfComp (SetOfType c) = isCompositeType c
+>     isCompOrSetoOfComp c = isCompositeType c
+>
+>     unboxedSingleType (SetOfType (CompositeType [(_,t)])) = Just t
+>     unboxedSingleType (PgRecord (Just t)) = unboxedSingleType t
+>     unboxedSingleType _ = Nothing
+>
+>     unboxedSetOfType (SetOfType a) = Just a
+>     unboxedSetOfType (PgRecord (Just t)) = unboxedSetOfType t
+>     unboxedSetOfType _ = Nothing
+>
+>     recurseTransFrom = maybe False (flip (castableFromTo cat cc) to)
+>     recurseTransTo = maybe False (castableFromTo cat cc from)
+>
+> replaceWithBase :: Catalog -> Type -> Type
+> replaceWithBase cat t@(DomainType _) = forceRight $ catDomainBaseType cat t
+> replaceWithBase _ t = t
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeChecking/Utils.lhs b/src/Database/HsSqlPpp/AstInternals/TypeChecking/Utils.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeChecking/Utils.lhs
@@ -0,0 +1,127 @@
+
+For extra utility functions to help with asts
+
+> module Database.HsSqlPpp.AstInternals.TypeChecking.Utils
+>     (addExplicitCasts
+>     ,canonicalizeTypeNames) where
+
+> import Data.Data
+> import Database.HsSqlPpp.AstInternals.AstInternal
+> import Data.Generics.PlateData
+> import Database.HsSqlPpp.AstInternals.AstAnnotation
+> import Database.HsSqlPpp.AstInternals.TypeType
+> import Control.Monad
+
+
+
+> -- | 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
+> addExplicitCasts :: Data a => a -> a
+> addExplicitCasts =
+>   refix . tr . canonicalizeTypeNames
+>   where
+>     tr = transformBi $ \x -> case x of
+>            FunCall a f as | Just p <- getProtoATys a
+>                           , Just ats <- getTys as
+>                           , p /= ats
+>              -> FunCall a f $ zipWith3 addCastIfNeeded p ats as
+>            Case a cs els | (Just f) <- doCase a cs els -> f
+>            CaseSimple a v cs els | (Just f) <- doCaseSimple a v cs els -> f
+>            i@(NumberLit a _) | Just t <- infType a -> castToT t i
+>            i@(StringLit a _) | Just t <- infType a -> castToT t i
+>            x1 -> x1
+>     -- need to put the type annotation in the created cast to allow
+>     -- adding explicit casts to continue up the tree
+>     castToT t e = Cast ea {atype = Just t,infType = Just t} e $ typeName 1 t
+>     getProtoATys :: Annotation -> Maybe [Type]
+>     getProtoATys a = let p = fnProt a
+>                      in flip fmap p $ \(_,t,_,_) -> t
+>     getTys :: [ScalarExpr] -> Maybe [Type]
+>     getTys = mapM $ atype . getAnnotation
+>     addCastIfNeeded :: Type -> Type -> ScalarExpr -> ScalarExpr
+>     addCastIfNeeded nt ot e =
+>       if ot == nt
+>       then e
+>       else Cast ea e $ typeName 2 nt
+>     -- not sure how to avoid inserting a cast for a literal which is
+>     -- already being cast when using transformBi, so run through and
+>     -- remove the suplerfluous casts in a second sweep
+>     -- spot them when there is a cast of a cast of a literal
+>     -- and the type of the inner cast is the same as the type of the literal
+>     -- not sure if this pass can cause other problems
+>     refix = transformBi $ \x -> case x of
+>               Cast ca (Cast _ l t) t1 | isLiteral l
+>                                       , Just lt <- infType $ getAnnotation l
+>                                       , t == typeName 3 lt
+>                 -> Cast ca l t1
+>               x1 -> x1
+>     isLiteral (NumberLit _ _) = True
+>     isLiteral (StringLit _ _) = True
+>     isLiteral _ = False
+
+
+> typeName :: Int -> Type -> TypeName
+> typeName _ (ScalarType t) = SimpleTypeName ea t
+> typeName i e = error $ "don't know how to convert " ++ show e ++ " to typename " ++ show i
+
+> ea :: Annotation
+> ea = emptyAnnotation
+
+> doCase :: Annotation -> [([ScalarExpr],ScalarExpr)] -> Maybe ScalarExpr -> Maybe ScalarExpr
+> doCase a whths els = do
+>   (whths',els') <- doCaseStuff a whths els
+>   return $ Case a whths' els'
+
+> doCaseSimple :: Annotation -> ScalarExpr -> [([ScalarExpr],ScalarExpr)] -> Maybe ScalarExpr -> Maybe ScalarExpr
+> doCaseSimple a v whths els = do
+>   (whths',els') <- doCaseStuff a whths els
+>   return $ CaseSimple a v whths' els'
+
+> doCaseStuff :: Annotation -> [([ScalarExpr],ScalarExpr)] -> Maybe ScalarExpr -> Maybe ([([ScalarExpr],ScalarExpr)],Maybe ScalarExpr)
+> doCaseStuff a whths els = do
+>   --trace (show $ atype a) $ return ()
+>   expectedType <- atype a
+>   --trace (show $ map (atype . getAnnotation . snd) whths) $ return ()
+>   thenTypes <- mapM (atype . getAnnotation . snd) whths
+>   --trace (show els) $ return ()
+>   thenAndElseTypes <- case els of
+>                         Nothing -> return thenTypes
+>                         Just els' -> fmap (:thenTypes) $ atype $ getAnnotation els'
+>   --trace ("checking cast: " ++ show expectedType ++ " " ++ show thenAndElseTypes)
+>   when (all (==expectedType) thenAndElseTypes) Nothing
+>   return (map (fixWhTh expectedType) whths
+>          ,castElse expectedType)
+>   where
+>     castElse et = case els of
+>                     Nothing -> Nothing
+>                     Just els' | Just t' <- atype $ getAnnotation els
+>                               , t' /= et
+>                       -> Just (Cast ea els' $ typeName 4 et)
+>                               | otherwise -> els
+>     fixWhTh :: Type -> ([ScalarExpr],ScalarExpr) -> ([ScalarExpr],ScalarExpr)
+>     fixWhTh et (whs,th) | Just t' <- atype $ getAnnotation th
+>                         , t' /= et = (whs, Cast ea th $ typeName 5 et)
+>                         | otherwise = (whs,th)
+
+> -- bit crap, this function is called canonicalizeTypeNames
+> -- and it uses a function called canonicalizeTypeName
+
+> -- | Convert all the typenames in the ast to canonical form
+> -- e.g. int -> int4
+> canonicalizeTypeNames :: Data a => a -> a
+> canonicalizeTypeNames = fixTypes . fixTypeNames
+>   where
+>     fixTypes =
+>       transformBi $ \x -> case x of
+>         ScalarType t -> ScalarType $ ct t
+>         x1 -> x1
+>     fixTypeNames =
+>       transformBi $ \x -> case x of
+>         SimpleTypeName a t -> SimpleTypeName a $ ct t
+>         PrecTypeName a t i -> PrecTypeName a (ct t) i
+>         Prec2TypeName a t i0 i1 -> Prec2TypeName a (ct t) i0 i1
+>         x1 -> x1
+>     ct = canonicalizeTypeName
+
diff --git a/src/Database/HsSqlPpp/AstInternals/TypeType.lhs b/src/Database/HsSqlPpp/AstInternals/TypeType.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/AstInternals/TypeType.lhs
@@ -0,0 +1,421 @@
+
+This file contains the data type Type. It is kept separate so we can
+compile the types and function information from the database
+separately to AstInternal.ag.
+
+Types overview:
+
+Regular types: scalarType, arrayType, composite type, domaintype
+we can use these anywhere.
+
+~~~~
+semi first class types: row, unknownstringlit (called unknown in pg) -
+these can be used in some places, but not others, in particular an
+expression can have this type or select can have a row with these
+type, but a view can't have a column with this type (so a select can
+be valid on it's own but not as a view. Not sure if Row types can be
+variables, unknownstringlit definitely can't. (Update, seems a view
+can have a column with type unknown.)
+
+pseudo types - mirror pg pseudo types
+Internal, LanguageHandler, Opaque probably won't ever be properly supported
+Not sure exactly what Any is, can't use it in functions like the other any types?
+ - update: seems that Any is like AnyElement, but multiple Anys don't
+   have to have the same type.
+AnyElement, AnyArray, AnyEnum, AnyNonArray - used to implement polymorphic functions,
+  can only be used in these functions as params, return type (and local vars?).
+Cstring - treated as variant of text?
+record -dynamically typed, depends where it is used, i think is used
+for type inference in function return types (so you don't have to
+write the correct type, the compiler fills it in), and as a dynamically
+typed variable in functions, where it can take any composite typed
+value.
+void is used for functions which return nothing
+trigger is a tag to say a function is used in triggers, used as a
+return type only
+typecheckfailed is used to represent the type of anything which the code
+is currently unable to type check, this usage should disappear at some
+point, and then it will only represent code which doesn't type check
+because of a mistake.
+
+The Type type identifies the type of a node, but doesn't necessarily
+describe the type.
+
+Typing relational valued expressions:
+use SetOfType combined with composite type for now, see if it works
+out. If not, will have to add another type.
+~~~~
+
+> {-# LANGUAGE FlexibleInstances,DeriveDataTypeable #-}
+>
+> module Database.HsSqlPpp.AstInternals.TypeType where
+>
+> import Control.Monad.Trans.Error
+> --import Control.Monad.Error
+>
+> import Data.Data
+> import Data.Generics.PlateData
+> import Data.Char
+
+> data Type = ScalarType String
+>           | ArrayType Type
+>           | SetOfType Type
+>             --three variations, choose better name for rowctor
+>             --refer to composite type in catalog
+>           | NamedCompositeType String
+>             --refer to composite type either in catalog or one generated on fly
+>           | CompositeType [(String,Type)]
+>             --refer to anonymous composite type: the fields have no names
+>             --these three types are equality and assign compatible if the fields
+>             --are ignoring the names, so the fields have to be in the same order.
+>           | AnonymousRecordType [Type] -- was rowctor
+>           | PgRecord (Maybe Type) -- can only hold namedcomposite, composite or anonymousrecord
+>           | DomainType String
+>           | EnumType String
+>           | Pseudo PseudoType
+>           | UnknownType -- represents a string literal
+>                              -- token whose type isn't yet
+>                              -- determined
+>             deriving (Eq,Show,Ord,Typeable,Data)
+>
+> data PseudoType = Any
+>                 | AnyArray
+>                 | AnyElement
+>                 | AnyEnum
+>                 | AnyNonArray
+>                 | Cstring
+>                 | Record
+>                 | TriggerRecord
+>                 | Trigger
+>                 | Void
+>                 | Internal
+>                 | LanguageHandler
+>                 | Opaque
+>                   deriving (Eq,Show,Ord,Typeable,Data)
+
+this list will need reviewing, probably refactor to a completely
+different set of infos, also will want to add more information to
+these, and to provide a way of converting into a user friendly
+string. It is intended for this code to produce highly useful errors
+later on down the line.
+
+>                    -- mostly expected,got
+> data TypeError = WrongTypes Type [Type]
+>                | UnknownTypeError Type
+>                | UnknownTypeName String
+>                | NoMatchingOperator String [Type]
+>                | TypelessEmptyArray
+>                | IncompatibleTypeSet [Type]
+>                | IncompatibleTypes Type Type
+>                | ValuesListsMustBeSameLength
+>                | NoRowsGivenForValues
+>                | UnrecognisedIdentifier String
+>                | UnrecognisedRelation String
+>                | UnrecognisedCorrelationName String
+>                | BadStarExpand
+>                | AmbiguousIdentifier String
+>                | ContextError String
+>                | MissingJoinAttribute
+>                | ExpressionMustBeBool
+>                | WrongNumberOfColumns
+>                | ExpectedDomainType Type
+>                | DomainDefNotFound Type
+>                | BadCatalogUpdate String
+>                | TypeAlreadyExists Type
+>                | AnyAllError String
+>                | InternalError String
+>                | FromToTypesNotSame Type Type
+>                | WrongNumberOfAliasCols Int Int
+>                 --shoved in to humour the Either Monad
+>                | MiscError String
+>                  deriving (Eq,Show,Ord,Typeable,Data)
+>
+
+ > instance Error ([TypeError]) where
+ >   noMsg = [MiscError "Unknown error"]
+ >   strMsg str = [MiscError str]
+
+> instance ErrorList TypeError where
+>    listMsg s = [MiscError s]
+
+
+=== canonical type name support
+
+Introduce some aliases to protect client code if/when the ast
+canonical names are changed:
+
+> typeSmallInt,typeBigInt,typeInt,typeNumeric,typeFloat4,
+>   typeFloat8,typeVarChar,typeChar,typeBool,typeDate,
+>   typeInterval :: Type
+> typeSmallInt = ScalarType "int2"
+> typeBigInt = ScalarType "int8"
+> typeInt = ScalarType "int4"
+> typeNumeric = ScalarType "numeric"
+> typeFloat4 = ScalarType "float4"
+> typeFloat8 = ScalarType "float8"
+> typeVarChar = ScalarType "varchar"
+> typeChar = ScalarType "char"
+> typeBool = ScalarType "bool"
+> typeDate = ScalarType "date"
+> typeInterval = ScalarType "interval"
+
+this converts the name of a type to its canonical name:
+try to follow the names that pg uses in a dump
+this converts the name of a type to its canonical name:
+try to follow the names that pg uses in a dump
+
+> canonicalizeTypeName :: String -> String
+> canonicalizeTypeName s' =
+>   case () of
+>                   _ | s `elem` smallIntNames -> "int2"
+>                     | s `elem` intNames -> "int4"
+>                     | s `elem` bigIntNames -> "int8"
+>                     | s `elem` numericNames -> "numeric"
+>                     | s `elem` float4Names -> "float4"
+>                     | s `elem` float8Names -> "float8"
+>                     | s `elem` varcharNames -> "varchar"
+>                     | s `elem` charNames -> "char"
+>                     | s `elem` boolNames -> "bool"
+>                     | otherwise -> s
+>   where
+>       smallIntNames = ["int2", "smallint"]
+>       intNames = ["int4", "integer", "int", "serial"]
+>       bigIntNames = ["int8", "bigint"]
+>       numericNames = ["numeric", "decimal"]
+>       float4Names = ["real", "float4"]
+>       float8Names = ["double precision", "float"]
+>       varcharNames = ["character varying", "varchar"]
+>       charNames = ["character", "char"]
+>       boolNames = ["boolean", "bool"]
+>       s = map toLower s'
+>
+> canonicalizeTypes :: Data a => a -> a
+> canonicalizeTypes =
+>   transformBi $ \x ->
+>       case x of
+>         ScalarType s -> ScalarType $ canonicalizeTypeName s
+>         x1 -> x1
+
+random notes on pg types:
+
+~~~~
+
+== domains:
+the point of domains is you can't put constraints on types, but you
+can wrap a type up in a domain and put a constraint on it there.
+
+== literals/selectors
+
+source strings are parsed as unknown type: they can be implicitly cast
+to almost any type in the right context.
+
+rows ctors can also be implicitly cast to any composite type matching
+the elements (now sure how exactly are they matched? - number of
+elements, type compatibility of elements, just by context?).
+
+string literals are not checked for valid syntax currently, but this
+will probably change so we can type check string literals statically.
+Postgres defers all checking to runtime, because it has to cope with
+custom data types. This code will allow adding a grammar checker for
+each type so you can optionally check the string lits statically.
+
+== notes on type checking types
+
+=== basic type checking
+Currently can lookup type names against a default template1 list of
+types, or against the current list in a database (which is read before
+processing and sql code).
+
+todo: collect type names from current source file to check against
+A lot of the infrastructure to do this is already in place. We also
+need to do this for all other definitions, etc.
+
+=== Type aliases
+
+Some types in postgresql have multiple names. I think this is
+hardcoded in the pg parser.
+
+For the canonical name in this code, we use the name given in the
+postgresql pg_type catalog relvar.
+
+TODO: Change the ast canonical names: where there is a choice, prefer
+the sql standard name, where there are multiple sql standard names,
+choose the most concise or common one, so the ast will use different
+canonical names to postgresql.
+
+planned ast canonical names:
+numbers:
+int2, int4/integer, int8 -> smallint, int, bigint
+numeric, decimal -> numeric
+float(1) to float(24), real -> float(24)
+float, float(25) to float(53), double precision -> float
+serial, serial4 -> int
+bigserial, serial8 -> bigint
+character varying(n), varchar(n)-> varchar(n)
+character(n), char(n) -> char(n)
+
+TODO:
+
+what about PrecTypeName? - need to fix the ast and parser (found out
+these are called type modifiers in pg)
+
+also, what can setof be applied to - don't know if it can apply to an
+array or setof type
+
+array types have to match an exact array type in the catalog, so we
+can't create an arbitrary array of any type. Not sure if this is
+handled quite correctly in this code.
+
+~~~~
+
+--------------------------------------------------------------------------------
+
+utilities for working with Types
+
+These may indicate that the haskell type system isn't being used very well.
+
+> isArrayType :: Type -> Bool
+> isArrayType (ArrayType _) = True
+> isArrayType _ = False
+>
+> isDomainType :: Type -> Bool
+> isDomainType (DomainType _) = True
+> isDomainType _ = False
+>
+> isCompositeType :: Type -> Bool
+> isCompositeType (CompositeType _) = True
+> isCompositeType (NamedCompositeType _) = True
+> isCompositeType (AnonymousRecordType _) = True
+> isCompositeType (PgRecord _) = True
+> isCompositeType _ = False
+>
+> isCompositeOrSetOfCompositeType :: Type -> Bool
+> isCompositeOrSetOfCompositeType (SetOfType a) = isCompositeType a
+> isCompositeOrSetOfCompositeType a = isCompositeType a
+>
+> unwrapArray :: Type -> Either [TypeError] Type
+> unwrapArray (ArrayType t) = Right t
+> unwrapArray x = Left [InternalError $ "can't get types from non array " ++ show x]
+>
+> unwrapSetOfWhenComposite :: Type -> Either [TypeError] Type
+> unwrapSetOfWhenComposite (SetOfType a@(CompositeType _)) = Right a
+> unwrapSetOfWhenComposite x = Left [InternalError $ "tried to unwrapSetOfWhenComposite on " ++ show x]
+>
+> unwrapSetOfComposite :: Type -> Either [TypeError]  [(String,Type)]
+> unwrapSetOfComposite (SetOfType (CompositeType a)) = Right a
+> unwrapSetOfComposite x = Left [InternalError $ "tried to unwrapSetOfComposite on " ++ show x]
+>
+> unwrapSetOf :: Type -> Either [TypeError] Type
+> unwrapSetOf (SetOfType a) = Right a
+> unwrapSetOf x = Left [InternalError $ "tried to unwrapSetOf on " ++ show x]
+>
+> unwrapComposite :: Type -> Either [TypeError] [(String,Type)]
+> unwrapComposite (CompositeType a) = Right a
+> unwrapComposite x = Left [InternalError $ "cannot unwrapComposite on " ++ show x]
+>
+> consComposite :: (String,Type) -> Type -> Either [TypeError] Type
+> consComposite l (CompositeType a) = Right $ CompositeType (l:a)
+> consComposite a b = Left [InternalError $ "called consComposite on " ++ show (a,b)]
+>
+> unwrapRowCtor :: Type -> Either [TypeError] [Type]
+> unwrapRowCtor (AnonymousRecordType a) = Right a
+> unwrapRowCtor x = Left [InternalError $ "cannot unwrapRowCtor on " ++ show x]
+
+--------------------------------------------------------------------------------
+
+~~~~
+new plan for types:
+
+The type annotations attached to nodes will be either typecheckfailed 'type'
+this will allow chaining type check failed more robustly. Type errors don't change.
+
+the sql type type will be changed so we can track the different
+contexts where different sql types can be used, split to use different
+sets of types so we can use the haskell type system to enforce these
+contexts.
+
+rename type to sqltype, too confusing otherwise
+new set of sqltypes: (these aren't in one haskell type anymore)
+scalar type - corresponds to sqltypes in pg which aren't one of the
+  other types (no easy way to define this)
+array type
+setof type : can be applied to scalar, domain, ... but not all types
+composite types are changed:
+namedcomposite string
+composite [(string,type)] -> what types can appear in the attribute list?
+anonymousrecord [type] -> what types can appear here? -> this
+represents a row expression type, which can be returned in select
+expressions (but not as a column in a view), and is used in other places
+domaintype : what types are allowable as the base type?
+pseudo types: these are used for arguments and return values for function prototypes only
+any*, record - just means pg infers the return type which will be a composite type (namedcomposite, composite or anonymousrecord), trigger: just a tag, void: just a tag, any*: polymorphic functions, ignore cstring, internal, language handler and opaque.
+issue: a variable declaration can be a polymorphic type in a polymorphic function, but we can't use the other pseudo types so need to split these
+a variable declared as type record IS NOT the same thing as the pseudo record type, I've finally worked out.
+so our plpgsqlrecordtype is plpgsqlrecordtype (Nothing|one of the three composite types)
+
+typechecking polymorphic functions: will have to relax the type
+checking to some degree. want to check against each usage of the
+polymorphic function in the source, so substitute in the actual types
+and check the function.
+
+contexts:
+function prototypes: args and return type
+function calls: args and return
+variable declaration in plpgsql
+attribute in a select expression
+attribute in a view (less permissive than a select expression), also create table as?
+attribute in a table, type (is this the same list as for composite and anonymous records? - can nest anonymous records)
+base type for domain
+cast expression
+insert: targetatts are same set of types as attributes in a table
+update: targets can be attr types or anonymous records of attr types for rowset style assign (x,y) = selectexp
+assignment statement: type on left same set as type in a for, types in select into, etc?
+return statement
+return query statement
+expressions in a raise statement
+expressions in execute, anything else?
+types used inside select expression checking:
+  selectlist, trefs, groupby, orderby, limit, offset, where, having
+expressions:
+what can an identifiers type be?
+what can the type of an Expression node be?
+  scalar: integerlit,floatlit
+  stringlit: what can an unknown resolve to (not quite everything)
+  booleanlit: scalar
+  nulllit: same as stringlit?
+  positionalarg: any type that a function arg can have
+  cast: any type you can cast to
+  identifier: ?
+  case, casesimple: any type in the rhs expressions, what are these?
+  exists: scalar
+  funcall: any type a function return type can have
+  inpredicate: scalar
+  windowfn: ?
+  liftoperator: booleans only?
+
+problem: can't get types using gettypeannotation function and support
+different valid combinations of types
+
+
+new notes
+type contexts - these all have different possible types
+function return type
+function parameter type
+OLD & NEW
+declared variable
+attribute in create table
+attribute create type
+column in select expression
+column in view
+column in insert
+item in set in update: includes row type with contained types restricted
+placeholder
+id lookups in local bindings
+typenames??
+
+create list of each type for each context
+create wrapper types which convert from other types to either
+  typeerror type for bad type for context
+
+~~~~
+
diff --git a/src/Database/HsSqlPpp/Catalog.lhs b/src/Database/HsSqlPpp/Catalog.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Catalog.lhs
@@ -0,0 +1,59 @@
+
+Forward the public part of CatalogInternal.
+
+> {- | 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 - 'defaultTemplate1Catalog'.
+>
+>  * 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 'CatalogUpdate' type.
+>
+> -}
+>
+> module Database.HsSqlPpp.Catalog
+>     (
+>      -- * Data types
+>      Catalog
+>      -- ** Updates
+>     ,CatalogUpdate(..)
+>     ,ppCatUpdate
+>      -- ** bits and pieces
+>     ,CastContext(..)
+>     ,CompositeFlavour(..)
+>     ,CompositeDef
+>     ,FunctionPrototype
+>     ,DomainDefinition
+>     ,FunFlav(..)
+>      -- * Catalog values
+>     ,emptyCatalog
+>     ,defaultCatalog
+>     ,defaultTemplate1Catalog
+>      -- * Catalog comparison
+>     ,CatalogDiff(..)
+>     ,compareCatalogs
+>     ,ppCatDiff
+>      -- * Functions
+>     ,updateCatalog
+>     ,deconstructCatalog
+>      -- * operator utils
+>     ,OperatorType(..)
+>     ,getOperatorType
+>     ,isOperatorName
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.Catalog.CatalogInternal
+> import Database.HsSqlPpp.AstInternals.Catalog.DefaultTemplate1Catalog
diff --git a/src/Database/HsSqlPpp/Parser.lhs b/src/Database/HsSqlPpp/Parser.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Parser.lhs
@@ -0,0 +1,19 @@
+
+Forward the public part of ParserInternal
+
+> -- | Functions to parse SQL.
+> module Database.HsSqlPpp.Parser (
+>              -- * Main
+>               parseStatements
+>              ,parseStatementsWithPosition
+>              ,parseStatementsFromFile
+>              ,parseQueryExpr
+>              ,parseSqlServerQueryExpr
+>              -- * Testing
+>              ,parseScalarExpr
+>              ,parsePlpgsql
+>              -- * errors
+>              ,ParseErrorExtra(..)
+>              )
+>     where
+> import Database.HsSqlPpp.Parsing.ParserInternal
diff --git a/src/Database/HsSqlPpp/Parsing/Lexer.lhs b/src/Database/HsSqlPpp/Parsing/Lexer.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Parsing/Lexer.lhs
@@ -0,0 +1,347 @@
+
+This file contains the lexer for sql source text.
+
+Lexicon:
+
+~~~~
+string
+identifier or keyword
+symbols - operators and ;,()[]
+positional arg
+int
+float
+copy payload (used to lex copy from stdin data)
+~~~~
+
+> module Database.HsSqlPpp.Parsing.Lexer (
+>               Token
+>              ,Tok(..)
+>              ,lexSqlFile
+>              ,lexSqlText
+>              ,lexSqlTextWithPosition
+>              ,identifierString
+>              ,LexState
+>              ) where
+> import Text.Parsec hiding(many, optional, (<|>))
+> import qualified Text.Parsec.Token as P
+> import Text.Parsec.Language
+> --import Text.Parsec.String
+> import Text.Parsec.Pos
+>
+> import Control.Applicative
+> import Control.Monad.Identity
+
+> import Data.Maybe
+>
+> import Database.HsSqlPpp.Parsing.ParseErrors
+> import Database.HsSqlPpp.Utils.Utils
+> -- import Database.HsSqlPpp.Ast.Name
+
+================================================================================
+
+= data types
+
+> type Token = (SourcePos, Tok)
+>
+> data Tok = StringTok String String --delim, value (delim will one of
+>                                    --', $$, $[stuff]$
+
+>          | IdStringTok String -- either a identifier component (without .) or a *
+
+>          | SymbolTok String -- operators, and ()[],;: and also .
+>                             -- '*' is currently always lexed as an id
+>                             --   rather than an operator
+>                             -- this gets fixed in the parsing stage
+
+>          | PositionalArgTok Integer -- used for $1, etc.
+
+Use a numbertok with a string to parse numbers. This is mainly so that
+numeric constants can be parsed accurately - if they are parsed to
+floats in the ast then converted back to numeric, then the accuracy
+can be lost (e.g. something like "0.2" parsing to 0.199999999 float.
+
+>          | NumberTok String
+
+>          | CopyPayloadTok String -- support copy from stdin; with inline data
+>            deriving (Eq,Show)
+>
+> type LexState = [Tok]
+> type Parser = ParsecT String LexState Identity
+>
+> lexSqlFile :: FilePath -> IO (Either ParseErrorExtra [Token])
+> lexSqlFile f = do
+>   te <- readFile f
+>   let x = runParser sqlTokens [] f te
+>   return $ toParseErrorExtra x Nothing te
+>
+> lexSqlText :: String -> String -> Either ParseErrorExtra [Token]
+> lexSqlText f s = toParseErrorExtra (runParser sqlTokens [] f s) Nothing s
+>
+> lexSqlTextWithPosition :: String -> Int -> Int -> String
+>                        -> Either ParseErrorExtra [Token]
+> lexSqlTextWithPosition f l c s =
+>   toParseErrorExtra (runParser (do
+>                                 setPosition (newPos f l c)
+>                                 sqlTokens) [] f s) (Just (l,c)) s
+
+================================================================================
+
+= lexers
+
+lexer for tokens, contains a hack for copy from stdin with inline
+table data.
+
+> sqlTokens :: Parser [Token]
+> sqlTokens =
+>   setState [] >>
+>   whiteSpace >>
+>   many sqlToken <* eof
+
+Lexer for an individual token.
+
+Could lex lazily and when the lexer reads a copy from stdin statement,
+it switches lexers to lex the inline table data, then switches
+back. Don't know how to do this in parsec, or even if it is possible,
+so as a work around, we use the state to trap if we've just seen 'from
+stdin;', if so, we read the copy payload as one big token, otherwise
+we read a normal token.
+
+> sqlToken :: Parser Token
+> sqlToken = do
+>            sp <- getPosition
+>            sta <- getState
+>            t <- if sta == [ft,st,mt]
+>                 then copyPayload
+>                 else try sqlNumber
+>                  <|> try sqlString
+>                  <|> try idString
+>                  <|> try positionalArg
+>                  <|> try sqlSymbol
+>            updateState $ \stt ->
+>              case () of
+>                      _ | stt == [] && t == ft -> [ft]
+>                        | stt == [ft] && t == st -> [ft,st]
+>                        | stt == [ft,st] && t == mt -> [ft,st,mt]
+>                        | otherwise -> []
+>
+>            return (sp,t)
+>            where
+>              ft = IdStringTok "from"
+>              st = IdStringTok "stdin"
+>              mt = SymbolTok ";"
+
+== specialized token parsers
+
+> sqlString :: Parser Tok
+> sqlString = stringQuotes <|> stringLD
+>   where
+>     --parse a string delimited by single quotes
+>     stringQuotes = StringTok "\'" <$> stringPar
+>     stringPar = optional (char 'E') *> char '\''
+>                 *> readQuoteEscape <* whiteSpace
+>     --(readquoteescape reads the trailing ')
+
+have to read two consecutive single quotes as a quote character
+instead of the end of the string, probably an easier way to do this
+
+other escapes (e.g. \n \t) are left unprocessed
+
+>     readQuoteEscape = do
+>                       x <- anyChar
+>                       if x == '\''
+>                         then try ((x:) <$> (char '\'' *> readQuoteEscape))
+>                              <|> return ""
+>                         else (x:) <$> readQuoteEscape
+
+parse a dollar quoted string
+
+>     stringLD = do
+>                -- cope with $$ as well as $[identifier]$
+>                tag <- try (char '$' *> ((char '$' *> return "")
+>                                    <|> (identifierString <* char '$')))
+>                s <- lexeme $ manyTill anyChar
+>                       (try $ char '$' <* string tag <* char '$')
+>                return $ StringTok ("$" ++ tag ++ "$") s
+>
+> idString :: Parser Tok
+> idString = IdStringTok <$> identifierString
+>
+> positionalArg :: Parser Tok
+> positionalArg = char '$' >> PositionalArgTok <$> integer
+
+
+Lexing symbols:
+
+~~~~
+approach 1:
+try to keep multi symbol operators as single lexical items
+(e.g. "==", "~=="
+
+approach 2:
+make each character a separate element
+e.g. == lexes to ['=', '=']
+then the parser sorts this out
+
+Sort of using approach 1 at the moment, see below
+
+== notes on symbols in pg operators
+pg symbols can be made from:
+
+=_*/<>=~!@#%^&|`?
+
+no --, /* in symbols
+
+can't end in + or - unless contains
+~!@#%^&|?
+
+Most of this isn't relevant for the current lexer.
+
+== sql symbols for this lexer:
+
+sql symbol is one of
+()[],; - single character
++-*/<>=~!@#%^&|`? string - one or more of these, parsed until hit char
+which isn't one of these (including whitespace). This will parse some
+standard sql expressions wrongly at the moment, work around is to add
+whitespace e.g. i think 3*-4 is valid sql, should lex as '3' '*' '-'
+'4', but will currently lex as '3' '*-' '4'. This is planned to be
+fixed in the parser.
+.. := :: : - other special cases
+A single * will lex as an identifier rather than a symbol, the parser
+deals with this.
+
+~~~~
+
+> sqlSymbol :: Parser Tok
+> sqlSymbol =
+>   SymbolTok <$> lexeme (choice [
+>                          replicate 1 <$> oneOf "()[],;"
+>                         ,try $ string ".."
+>                         ,string "."
+>                         ,try $ string "::"
+>                         ,try $ string ":="
+>                         ,string ":"
+>                         ,try $ string "$(" -- antiquote standard splice
+>                         ,try $ string "$s(" -- antiquote string splice
+>                         ,string "$i(" -- antiquote identifier splice
+>                         ,many1 (oneOf "+-*/<>=~!@#%^&|`?")
+>                         ])
+>
+
+parse a number:
+digits
+digits.[digits][e[+-]digits]
+[digits].digits[e[+-]digits]
+digitse[+-]digits
+
+I'm sure the implementation can be simpler than this
+
+> sqlNumber :: Parser Tok
+> sqlNumber = NumberTok <$> lexeme (
+>   choice [do
+>           -- starts with digits
+>           d <- digits
+>           suff <- choice [-- complete fractional part
+>                           try fracPart
+>                          ,-- dot followed by optional exp
+>                           do
+>                           _ <- char '.'
+>                           e <- optionMaybe expn
+>                           return $ concat $ catMaybes
+>                             [Just "."
+>                             ,e]
+>                          ,--no dot then expn
+>                           expn
+>                           -- just an integer
+>                          ,return ""
+>                          ]
+>           return $ d ++ suff
+>          ,fracPart
+>          ])
+>   where
+>      fracPart = do
+>           _ <- char '.'
+>           d <- digits
+>           e <- optionMaybe expn
+>           return $ concat $ catMaybes
+>             [Just "."
+>             ,Just d
+>             ,e]
+>      expn = do
+>        _ <- char 'e'
+>        s <- optionMaybe (char '+' <|> char '-')
+>        d <- digits
+>        return $ concat $ catMaybes [Just "e"
+>                                    ,fmap (:[]) s
+>                                    ,Just d]
+>      digits = many1 digit
+
+================================================================================
+
+additional parser bits and pieces
+
+include dots, * in all identifier strings during lexing. This parser
+is also used for keywords, so identifiers and keywords aren't
+distinguished until during proper parsing, and * and qualifiers aren't
+really examined until type checking
+
+> identifierString :: Parser String
+> identifierString = lexeme $ choice [
+>                     "*" <$ symbol "*"
+>                    ,nonStarPart]
+>   where
+>     nonStarPart = idpart <|> (char '"' *> many (noneOf "\"") <* char '"')
+>                   where idpart = (letter <|> char '_') <:> secondOnwards
+>     secondOnwards = many (alphaNum <|> char '_')
+
+parse the block of inline data for a copy from stdin, ends with \. on
+its own on a line
+
+> copyPayload :: Parser Tok
+> copyPayload = CopyPayloadTok <$> lexeme (getLinesTillMatches "\\.\n")
+>   where
+>     getLinesTillMatches s = do
+>                             x <- getALine
+>                             if x == s
+>                               then return ""
+>                               else (x++) <$> getLinesTillMatches s
+>     getALine = (++"\n") <$> manyTill anyChar (try newline)
+>
+
+================================================================================
+
+= parsec pass throughs
+
+> symbol :: String -> Parser String
+> symbol = P.symbol lexer
+>
+
+> integer :: Parser Integer
+> integer = lexeme $ P.integer lexer
+
+> whiteSpace :: Parser ()
+> whiteSpace = P.whiteSpace lexer
+>
+> lexeme :: Parser a -> Parser a
+> lexeme = P.lexeme lexer
+
+this lexer isn't really used as much as it could be, probably some of
+the fields are not used at all (like identifier and operator stuff)
+
+> lexer :: P.GenTokenParser String LexState Identity
+> lexer = P.makeTokenParser (emptyDef {
+>                             P.commentStart = "/*"
+>                            ,P.commentEnd = "*/"
+>                            ,P.commentLine = "--"
+>                            ,P.nestedComments = False
+>                            ,P.identStart = letter <|> char '_'
+>                            ,P.identLetter    = alphaNum <|> oneOf "_"
+>                            ,P.opStart        = P.opLetter emptyDef
+>                            ,P.opLetter       = oneOf opLetters
+>                            ,P.reservedOpNames= []
+>                            ,P.reservedNames  = []
+>                            ,P.caseSensitive  = False
+>                            })
+>
+> opLetters :: String
+> opLetters = ".:^*/%+-<>=|!"
diff --git a/src/Database/HsSqlPpp/Parsing/ParseErrors.lhs b/src/Database/HsSqlPpp/Parsing/ParseErrors.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Parsing/ParseErrors.lhs
@@ -0,0 +1,76 @@
+
+convert error messages to show source text fragment with little hat,
+plus output error location in emacs friendly format.
+
+>
+> module Database.HsSqlPpp.Parsing.ParseErrors
+>     (toParseErrorExtra
+>     ,ParseErrorExtra(..)) where
+>
+> import Text.Parsec
+> import Control.Monad.Error
+>
+> showPE :: ParseError -> Maybe (Int,Int) -> String -> String
+> showPE pe sp src = show pe ++ "\n" ++ pePosToEmacs pe
+>                    ++ "\n" ++ peToContext pe sp src
+>
+> pePosToEmacs :: ParseError -> String
+> pePosToEmacs pe = let p = errorPos pe
+>                       f = sourceName p
+>                       l = sourceLine p
+>                       c = sourceColumn p
+>                   in f ++ ":" ++ show l ++ ":" ++ show c ++ ":"
+>
+> peToContext :: ParseError -> Maybe (Int,Int) -> String -> String
+> peToContext pe sp src =
+>      let ls = lines src
+>          line = safeGet ls(lineNo - 1)
+>          prelines = map (safeGet ls) [(lineNo - 5) .. (lineNo - 2)]
+>          postlines = map (safeGet ls) [lineNo .. (lineNo + 5)]
+>          caretLine = replicate (colNo - 1) ' ' ++ "^"
+>          errorHighlightText = prelines
+>                               ++ [line, caretLine, "ERROR HERE"]
+>                               ++ postlines
+>     in "\nContext:\n"
+>        ++ unlines (trimLines errorHighlightText) ++ "\n"
+>     where
+>       safeGet a i = if i < 0 || i >= length a
+>                       then ""
+>                       else a !! i
+>       trimLines = trimStartLines . reverse . trimStartLines . reverse
+>       trimStartLines = dropWhile (=="")
+>       pos = errorPos pe
+>       lineNo = sourceLine pos - adjLine
+>       colNo = sourceColumn pos
+>       adjLine = case sp of
+>                         Just (l, _) -> l - 1
+>                         Nothing -> 0
+>
+> -- | Simple wrapper to allow showing the source context of a ParseError
+> data ParseErrorExtra =
+>        ParseErrorExtra {
+>                        -- | wrapped error
+>                        parseErrorError :: ParseError
+>                        -- | source position
+>                        -- adjustment to get the
+>                        -- context bit in error
+>                        -- messages right - this is
+>                        -- the same as what is passed
+>                        -- into parseSqlWithPosition
+>                        ,parseErrorPosition :: Maybe (Int, Int)
+>                        -- | sql source
+>                        ,parseErrorSqlSource :: String
+>                        }
+>
+> instance Show ParseErrorExtra where
+>     show (ParseErrorExtra pe sp src) = showPE pe sp src
+>
+> instance Error ParseErrorExtra where
+>   noMsg = ParseErrorExtra (error "instance Error ParseErrorExtra") Nothing "unknown"
+>   strMsg = ParseErrorExtra (error "instance Error ParseErrorExtra") Nothing
+>
+> toParseErrorExtra :: Either ParseError b -> Maybe (Int,Int) -> String
+>                   -> Either ParseErrorExtra b
+> toParseErrorExtra a sp src = case a of
+>                                Left pe -> Left $ ParseErrorExtra pe sp src
+>                                Right x -> Right x
diff --git a/src/Database/HsSqlPpp/Parsing/ParserInternal.lhs b/src/Database/HsSqlPpp/Parsing/ParserInternal.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Parsing/ParserInternal.lhs
@@ -0,0 +1,1968 @@
+
+The main file for parsing sql, uses parsec. Not sure if parsec is the
+right choice, but it seems to do the job pretty well at the moment.
+
+> {-# LANGUAGE RankNTypes,FlexibleContexts #-}
+>
+> -- | Functions to parse SQL.
+> module Database.HsSqlPpp.Parsing.ParserInternal
+>     (-- * Main
+>      parseStatements
+>     ,parseStatementsWithPosition
+>     ,parseStatementsFromFile
+>     ,parseQueryExpr
+>     ,parseSqlServerQueryExpr
+>      -- * Testing
+>     ,parseScalarExpr
+>     ,parsePlpgsql
+>      -- * errors
+>     ,ParseErrorExtra(..)
+>      -- * quasiquotation support
+>     ,parseAntiSql
+>     ,parseAntiPlpgsql
+>     ,parseAntiScalarExpr
+>      -- other helpers for internal use
+>     ,tableAttribute
+>     ,keyword
+>     ,parens
+>     ,symbol
+>     ,idString
+>     ,commaSep1
+>     ,commaSep
+>     ) where
+>
+> import Text.Parsec hiding(many, optional, (<|>), string, label)
+> import Text.Parsec.Expr
+> import Text.Parsec.String
+> import Text.Parsec.Perm
+>
+> import Control.Applicative
+> import Control.Monad.Identity
+>
+> import Data.Maybe
+> import Data.Char
+>
+> import Data.Generics.PlateData
+> import Data.Data hiding (Prefix,Infix)
+>
+> import Database.HsSqlPpp.Parsing.Lexer
+> import Database.HsSqlPpp.Parsing.ParseErrors
+> import Database.HsSqlPpp.AstInternals.AstAnti
+> --import Database.HsSqlPpp.Ast
+> import qualified Database.HsSqlPpp.Ast as A
+> import Database.HsSqlPpp.Annotation as A
+> import Database.HsSqlPpp.Utils.Utils
+> import Database.HsSqlPpp.Catalog
+> --import Debug.Trace
+
+--------------------------------------------------------------------------------
+
+Top level parsing functions
+===========================
+
+To support antiquotation, the following approach is used:
+
+* makeantinodes processes the generated astinternal.hs, and extracts
+  the ast node types.
+* it modifies these to add anti ctors to the appropriate types,
+  creates a set of trivial conversion functions to convert between anti
+  nodes and regular nodes, and this is written to astanti.hs.
+* astanti then contains exactly the same set of ast nodes as
+  astinternal, but with a few additions to support antiquotes.
+* this parsing code parses to the antinodes, then converts to regular
+  nodes for the public api, and returns antinodes for the sql
+  quasiquoter to use.
+* todo: add a flag so that if we are not parsing for the quasiquoter,
+  any splice syntax is rejected as a parse error.
+
+> parseStatements :: String -- ^ filename to use in errors
+>                 -> String -- ^ a string containing the sql to parse
+>                 -> Either ParseErrorExtra [A.Statement]
+> parseStatements f s =
+>   deAS $ parseIt l sqlStatements f Nothing s startState
+>   where l = lexSqlText f s
+>
+> parseStatementsWithPosition :: FilePath -- ^ filename to use in errors
+>                             -> Int -- ^ adjust line number in errors by adding this
+>                             -> Int -- ^ adjust column in errors by adding this
+>                             -> String -- ^ a string containing the sql to parse
+>                             -> Either ParseErrorExtra [A.Statement]
+> parseStatementsWithPosition f l c s = deAS $ parseAntiSql f l c s
+>
+> parseStatementsFromFile :: FilePath -- ^ file name of file containing sql
+>                         -> IO (Either ParseErrorExtra [A.Statement])
+> parseStatementsFromFile fn = do
+>   sc <- readFile fn
+>   x <- lexSqlFile fn
+>   return $ deAS $ parseIt x sqlStatements fn Nothing sc startState
+>
+
+> parseQueryExpr :: String -- ^ filename to use in errors
+>                -> String -- ^ a string containing the sql to parse
+>                -> Either ParseErrorExtra A.QueryExpr
+> parseQueryExpr f s =
+>   deQE $ parseIt l pqe f Nothing s startState
+>   where
+>     l = lexSqlText f s
+>     pqe :: SParser QueryExpr
+>     pqe = do
+>           (QueryStatement _ q) <- queryStatement
+>           _ <- optional (symbol ";")
+>           eof
+>           return q
+
+> -- | Hacky wrapper to parse a query statement in the form:
+> -- | select expr;
+> -- | optionally 'set rowcount N'
+> -- | GO
+> parseSqlServerQueryExpr :: String -- ^ filename to use in errors
+>                         -> String -- ^ a string containing the sql to parse
+>                         -> Either ParseErrorExtra A.QueryExpr
+> parseSqlServerQueryExpr f s =
+>   deQE $ parseIt l pqe f Nothing s startState
+>   where
+>     l = lexSqlText f s
+>     pqe :: SParser QueryExpr
+>     pqe = do
+>           (QueryStatement _ q) <- queryStatement
+>           _ <- optional $ symbol ";"
+>           rc <- tryOptionMaybe rowcount
+>           keyword "go"
+>           eof
+>           return $ case rc of
+>                      Nothing -> q
+>                      Just (-1) -> q
+>                      Just n -> updateLimit n q
+>     rowcount = --trace "try set" $
+>       keyword "set"
+>       *> keyword "rowcount"
+>       *> choice [
+>            symbol "-" *> (((* (-1)) . fromInteger) <$> integer)
+>           ,integer]
+>     updateLimit n (Select a di sl tr wh gb hv ob _l o) =
+>       Select a di sl tr wh gb hv ob (Just $ NumberLit emptyAnnotation (show n)) o
+>     updateLimit _ x = error $ "query style not supported for sql server style: " ++ show x
+
+
+> -- | Parse expression fragment, used for testing purposes
+> parseScalarExpr :: String -- ^ filename for error messages
+>                 -> String -- ^ sql string containing a single expression,
+>                           -- with no trailing ';'
+>                 -> Either ParseErrorExtra A.ScalarExpr
+> parseScalarExpr f s =
+>   deAE $ parseIt l (expr <* eof) f Nothing s startState
+>   where l = lexSqlText f s
+>
+> -- | Parse plpgsql statements, used for testing purposes -
+> -- this can be used to parse a list of plpgsql statements which
+> -- aren't contained in a create function.
+> -- (The produced ast won't pass a type check.)
+> parsePlpgsql :: String
+>              -> String
+>              -> Either ParseErrorExtra [A.Statement]
+> parsePlpgsql f s =
+>   deAS $ parseIt l p f Nothing s startState
+>   where
+>     l = lexSqlText f s
+>     p = many plPgsqlStatement <* eof
+>
+> parseAntiSql :: FilePath
+>              -> Int
+>              -> Int
+>              -> String
+>              -> Either ParseErrorExtra [Statement]
+> parseAntiSql f l c s =
+>   parseIt lx sqlStatements f ps s startState
+>   where
+>     lx = lexSqlTextWithPosition f l c s
+>     ps = Just (l,c)
+>
+> parseAntiPlpgsql :: String
+>                  -> Int
+>                  -> Int
+>                  -> String
+>                  -> Either ParseErrorExtra [Statement]
+> parseAntiPlpgsql f l c s =
+>   parseIt lx p f ps s startState
+>   where
+>     lx = lexSqlText f s
+>     p = many plPgsqlStatement <* eof
+>     ps = Just (l,c)
+>
+> parseAntiScalarExpr :: String
+>                     -> Int
+>                     -> Int
+>                     -> String
+>                     -> Either ParseErrorExtra ScalarExpr
+> parseAntiScalarExpr f l c s =
+>   parseIt lx p f ps s startState
+>   where
+>     lx = lexSqlText f s
+>     p = expr <* eof
+>     ps = Just (l,c)
+>
+> --utility function to do error handling in one place
+> parseIt :: forall t s u b.(Stream s Identity t, Data b) =>
+>            Either ParseErrorExtra s
+>         -> Parsec s u b
+>         -> SourceName
+>         -> Maybe (Int,Int)
+>         -> String
+>         -> u
+>         -> Either ParseErrorExtra b
+> parseIt lexed parser fn sp src ss =
+>     case lexed of
+>                Left er -> Left er
+>                Right toks -> let r1 = runParser parser ss fn toks
+>                              in case toParseErrorExtra r1 sp src of
+>                                   Left er -> Left er
+>                                   Right t -> Right $ fixupTree t
+>
+> deAE :: Either ParseErrorExtra ScalarExpr
+>      -> Either ParseErrorExtra A.ScalarExpr
+> deAE x = case x of
+>                 Left e -> Left e
+>                 Right ex -> Right $ convertScalarExpr ex
+> deAS :: Either ParseErrorExtra [Statement]
+>      -> Either ParseErrorExtra [A.Statement]
+> deAS x = case x of
+>                 Left e -> Left e
+>                 Right ex -> Right $ convertStatements ex
+
+> deQE :: Either ParseErrorExtra QueryExpr
+>      -> Either ParseErrorExtra A.QueryExpr
+> deQE x = case x of
+>                 Left e -> Left e
+>                 Right ex -> Right $ queryExpr ex
+
+
+--------------------------------------------------------------------------------
+
+> type SParser =  GenParser Token ParseState
+
+Parsing top level statements
+============================
+
+> sqlStatements :: SParser [Statement]
+> sqlStatements = many (sqlStatement True) <* eof
+>
+> sqlStatement :: Bool -> SParser Statement
+> sqlStatement reqSemi =
+>    (choice [
+>      antiStatement
+>     ,queryStatement
+>     ,insert
+>     ,update
+>     ,delete
+>     ,truncateSt
+>     ,copy
+>     ,set
+>     ,notify
+>     ,keyword "create" *>
+>              choice [
+>                 createTable
+>                ,createSequence
+>                ,createType
+>                ,createFunction
+>                ,createView
+>                ,createDomain
+>                ,createLanguage
+>                ,createTrigger]
+>     ,keyword "alter" *>
+>              choice [
+>                 alterSequence
+>                ,alterTable]
+>     ,keyword "drop" *>
+>              choice [
+>                 dropSomething
+>                ,dropFunction]]
+>     <* (if reqSemi
+>           then symbol ";" >> return ()
+>           else optional (symbol ";") >> return ()))
+>    <|> copyData
+
+--------------------------------------------------------------------------------
+
+statement flavour parsers
+=========================
+
+top level/sql statements first
+
+select
+------
+
+select parser, parses things starting with the keyword 'select'
+
+supports plpgsql 'select into' only for the variants which look like
+'select into ([targets]) [columnNames] from ...
+or
+'select [columnNames] into ([targets]) from ...
+This should be changed so it can only parse an into clause when
+expecting a plpgsql statement.
+
+recurses to support parsing excepts, unions, etc.
+this recursion needs refactoring cos it's a mess
+
+> queryStatement :: SParser Statement
+> queryStatement = QueryStatement <$> pos <*> pQueryExpr
+>
+> into :: SParser (Statement -> Statement)
+> into = do
+>   p <- pos <* keyword "into"
+>   st <- option False (True <$ keyword "strict")
+>   is <- commaSep1 qName
+>   return $ \s -> Into p st is s
+
+> intoQueryStatement :: SParser Statement
+> intoQueryStatement = do
+>   p <- pos
+>   (i,q) <- pQueryExprX True
+>   return $ i $ QueryStatement p q
+
+> pQueryExpr :: SParser QueryExpr
+> pQueryExpr = snd <$> pQueryExprX False
+
+> pQueryExprX :: Bool -> SParser (Statement -> Statement, QueryExpr)
+> pQueryExprX allowInto = (id,) <$>
+>   (with <|>
+>    buildExpressionParser combTable selFactor)
+>   where
+>         selFactor = try (parens pQueryExpr) <|> selQuerySpec <|> values
+>         with = WithQueryExpr <$> (pos <* keyword "with")
+>                              <*> commaSep1 withQuery
+>                              <*> pQueryExpr
+>         withQuery = WithQuery <$> pos
+>                               <*> idString
+>                               <*> tryOptionMaybe (parens $ commaSep idString)
+>                               <*> (keyword "as" *> parens pQueryExpr)
+>         combTable = [map (\(c,p) -> Infix (CombineQueryExpr
+>                                            <$> pos
+>                                            <*> (c <$ p)) AssocLeft)
+>                         [(Except, keyword "except")
+>                         ,(Intersect, keyword "intersect")
+>                         ,(UnionAll, try (keyword "union" *> keyword "all"))
+>                         ,(Union, keyword "union")]]
+>         selQuerySpec = do
+>           p <- pos <* keyword "select"
+>           d <- option Dupes (Distinct <$ keyword "distinct")
+>           -- todo: work out how to make this work properly - need to return
+>           -- the into
+>           (sl,_intoBit) <- if allowInto
+>                           then permute ((,)
+>                                         <$$> try selectList
+>                                         <|?> (Nothing, Just <$> into))
+>                          else (,Nothing) <$> selectList
+>           Select p d sl
+>                    <$> option [] from
+>                    <*> optionMaybe whereClause
+>                    <*> option [] groupBy
+>                    <*> optionMaybe having
+>                    <*> option [] orderBy
+>                    <*> optionMaybe limit
+>                    <*> optionMaybe offset
+>         from = keyword "from" *> commaSep1 tableRef
+>         groupBy = keyword "group" *> keyword "by"
+>                   *> commaSep1 expr
+>         having = keyword "having" *> expr
+>         orderBy = keyword "order" *> keyword "by"
+>                     *> commaSep1 oneOrder
+>         oneOrder = (,) <$> expr
+>                        <*> option Asc (choice [
+>                                         Asc <$ keyword "asc"
+>                                        ,Desc <$ keyword "desc"])
+>         limit = keyword "limit" *> expr
+>         offset = keyword "offset" *> expr
+>         values = Values <$> (pos <* keyword "values")
+>                         <*> commaSep1 (parens $ commaSep1 expr)
+
+
+table refs
+have to cope with:
+a simple tableref i.e just a name
+an aliased table ref e.g. select a.b from tbl as a
+a sub select e.g. select a from (select b from c)
+ - these are handled in nonJoinTref
+then we combine by seeing if there is a join looking prefix
+
+> tableRef :: SParser TableRef
+> tableRef =
+>   trefTerm >>= maybeParseAnotherJoin
+>   where
+>         maybeParseAnotherJoin tr1 =
+>           choice [
+>                 do
+>                   p2 <- pos
+>                   (nat,jt) <- joinKw
+>                   JoinTref p2 tr1 nat jt
+>                                    <$> trefTerm
+>                                    <*> onExpr
+>                                    <*> palias
+>                     >>= maybeParseAnotherJoin
+>                ,return tr1]
+>         trefTerm = nonJoinTref
+>                    <|> try (parens tableRef)
+>         nonJoinTref = try $ optParens $ do
+>                   p2 <- pos
+>                   choice [
+>                          SubTref p2
+>                          <$> parens pQueryExpr
+>                          <*> palias
+>                         ,FunTref p2
+>                          <$> try (identifier >>= functionCallSuffix)
+>                          <*> palias
+>                         ,Tref p2
+>                          <$> nkwidn
+>                          <*> palias]
+>         joinKw :: SParser (Natural, JoinType)
+>         joinKw = do
+>              --look for the join flavour first
+>              n <- option Unnatural (Natural <$ keyword "natural")
+>              jt <- choice [
+>                     LeftOuter <$ try (keyword "left"
+>                                       *> optional (keyword "outer"))
+>                    ,RightOuter <$ try (keyword "right"
+>                                        *> optional (keyword "outer"))
+>                    ,FullOuter <$ try (keyword "full"
+>                                       *> optional (keyword "outer"))
+>                    ,Cross <$ keyword "cross"
+>                    ,Inner <$ optional (keyword "inner")]
+>              --recurse back to tref to read the table
+>              keyword "join"
+>              return (n,jt)
+>         onExpr = choice [
+>                  Just <$> (JoinOn <$> pos <*> (keyword "on" *> expr))
+>                 ,Just <$> (JoinUsing <$> pos
+>                            <*> (keyword "using" *> columnNameList))
+>                 ,return Nothing]
+>         palias = do
+>            p <- pos
+>            option (NoAlias p)
+>                    (optionalSuffix
+>                       (TableAlias p) (optional (keyword "as") *> nkwid)
+>                       (FullAlias p) () (parens $ commaSep1 idString))
+>         badNames = ["as"
+>                    ,"where"
+>                    ,"except"
+>                    ,"union"
+>                    ,"intersect"
+>                    ,"loop"
+>                    ,"inner"
+>                    ,"on"
+>                    ,"left"
+>                    ,"right"
+>                    ,"full"
+>                    ,"cross"
+>                    ,"join"
+>                    ,"natural"
+>                    ,"order"
+>                    ,"group"
+>                    ,"limit"
+>                    ,"using"
+>                    ,"from"]
+>         nkwidn = do
+>                  i <- dqi
+>                  case i of
+>                    SQIdentifier _ [n] | n `elem` badNames
+>                        -> fail "not keyword"
+>                    _ -> return i
+>         nkwid = try $ do
+>                  x <- idString
+>                  --avoid all these keywords as aliases since they can
+>                  --appear immediately following a tableref as the next
+>                  --part of the statement, if we don't do this then lots
+>                  --of things don't parse. Seems a bit inelegant but
+>                  --works for the tests and the test sql files don't know
+>                  --if these should be allowed as aliases without "" or
+>                  --[]
+>                  -- TODO find out what the correct behaviour here is.
+>                  if map toLower x `elem` badNames
+>                    then fail "not keyword"
+>                    else return x
+>
+> optParens :: SParser a
+>           -> SParser a
+> optParens p = try (parens p) <|> p
+
+insert, update and delete
+-------------------------
+
+insert statement: supports option column name list,
+multiple rows to insert and insert from select statements
+
+> insert :: SParser Statement
+> insert = Insert
+>          <$> pos <* keyword "insert" <* keyword "into"
+>          <*> dqi
+>          <*> option [] (try columnNameList)
+>          <*> pQueryExpr
+>          <*> tryOptionMaybe returning
+>
+> update :: SParser Statement
+> update = Update
+>          <$> pos <* keyword "update"
+>          <*> dqi
+>          <*> (keyword "set" *> commaSep1 setClause)
+>          <*> option [] (keyword "from" *> commaSep1 tableRef)
+>          <*> tryOptionMaybe whereClause
+>          <*> tryOptionMaybe returning
+>     where
+>       setClause =
+>         choice [do
+>           p <- pos
+>           l <- parens (commaSep1 idString)
+>           symbol "="
+>           r <- parens (commaSep1 expr)
+>           return $ FunCall p "=" [FunCall p "!rowctor" $ map (Identifier p) l
+>                                  ,FunCall p "!rowctor" r]
+>         ,do
+>           p <- pos
+>           l <- idString
+>           symbol "="
+>           r <- expr
+>           return $ FunCall p "=" [Identifier p l,r]]
+
+> delete :: SParser Statement
+> delete = Delete
+>          <$> pos <* keyword "delete" <* keyword "from"
+>          <*> dqi
+>          <*> option [] (keyword "using" *> commaSep1 tableRef)
+>          <*> tryOptionMaybe whereClause
+>          <*> tryOptionMaybe returning
+>
+
+other dml-type stuff
+--------------------
+
+> truncateSt :: SParser Statement
+> truncateSt =
+>            Truncate
+>            <$> pos <* keyword "truncate" <* optional (keyword "table")
+>            <*> commaSep1 idString
+>            <*> option ContinueIdentity (choice [
+>                                 ContinueIdentity <$ (keyword "continue"
+>                                                      <* keyword "identity")
+>                                ,RestartIdentity <$ (keyword "restart"
+>                                                     <* keyword "identity")])
+>            <*> cascade
+>
+> copy :: SParser Statement
+> copy = do
+>        p <- pos
+>        keyword "copy"
+>        tableName <- idString
+>        cols <- option [] (parens $ commaSep1 idString)
+>        keyword "from"
+>        src <- choice [
+>                CopyFilename <$> extrStr <$> stringLit
+>               ,Stdin <$ keyword "stdin"]
+>        return $ Copy p tableName cols src
+>
+> copyData :: SParser Statement
+> copyData = CopyData <$> pos <*> mytoken (\tok ->
+>                                         case tok of
+>                                                  CopyPayloadTok n -> Just n
+>                                                  _ -> Nothing)
+>
+
+--------------------------------------------------------------------------------
+
+misc
+====
+
+> set :: SParser Statement
+> set = Set <$> pos
+>           <*> (keyword "set" *> idString)
+>           <*> ((keyword "to" <|> symbol "=") *>
+>               commaSep1 sv)
+>       where
+>         sv = choice [
+>               SetStr <$> pos <*> stringN
+>              ,SetId <$> pos <*> idString
+>              ,SetNum <$> pos <*> (try (fromInteger <$> integer)
+>                                   <|> (read <$> numString))]
+>
+> notify :: SParser Statement
+> notify = Notify <$> pos
+>                 <*> (keyword "notify" *> idString)
+
+--------------------------------------------------------------------------------
+
+ddl
+===
+
+> createTable :: SParser Statement
+> createTable = do
+>   p <- pos
+>   keyword "table"
+>   tname <- idString
+>   choice [
+>      CreateTableAs p tname <$> (keyword "as" *> pQueryExpr)
+>     ,uncurry (CreateTable p tname) <$> readAttsAndCons]
+>   where
+>     --parse our unordered list of attribute defs or constraints, for
+>     --each line want to try the constraint parser first, then the
+>     --attribute parser, so we need the swap to feed them in the
+>     --right order into createtable
+>     readAttsAndCons = parens (swap <$> multiPerm
+>                                          (try tableConstraint)
+>                                          tableAttribute
+>                                          (symbol ","))
+>                       where swap (a,b) = (b,a)
+>
+> tableAttribute :: SParser AttributeDef
+> tableAttribute = AttributeDef
+>                <$> pos
+>                <*> idString
+>                <*> typeName
+>                <*> tryOptionMaybe (keyword "default" *> expr)
+>                <*> many rowConstraint
+>   where
+>     rowConstraint = do
+>        p <- pos
+>        cn <- option "" (keyword "constraint" *> idString)
+>        choice [
+>           RowUniqueConstraint p cn <$ keyword "unique"
+>          ,RowPrimaryKeyConstraint p cn <$ keyword "primary" <* keyword "key"
+>          ,RowCheckConstraint p cn <$> (keyword "check" *> parens expr)
+>          ,NullConstraint p cn <$ keyword "null"
+>          ,NotNullConstraint p cn <$ (keyword "not" <* keyword "null")
+>          ,RowReferenceConstraint p cn
+>          <$> (keyword "references" *> idString)
+>          <*> option Nothing (try $ parens $ Just <$> idString)
+>          <*> onDelete
+>          <*> onUpdate
+>          ]
+
+
+>
+> onDelete,onUpdate :: SParser Cascade
+> onDelete = onSomething "delete"
+> onUpdate = onSomething "update"
+>
+> onSomething :: String -> SParser Cascade
+> onSomething k = option Restrict $ try $ keyword "on"
+>                 *> keyword k *> cascade
+>
+> tableConstraint :: SParser Constraint
+> tableConstraint = do
+>                 p <- pos
+>                 cn <- option "" (keyword "constraint" *> option "" conName)
+>                 choice [
+>                    UniqueConstraint p cn
+>                    <$> try (keyword "unique" *> optParens columnNameList)
+>                    ,PrimaryKeyConstraint p cn
+>                    <$> try (keyword "primary" *> keyword "key"
+>                                     *> choice [
+>                                             (:[]) <$> idString
+>                                            ,parens (commaSep1 idString)])
+>                    ,CheckConstraint p cn
+>                    <$>try (keyword "check" *> parens expr)
+>                    ,ReferenceConstraint p cn
+>                    <$> try (keyword "foreign" *> keyword "key"
+>                             *> parens (commaSep1 idString))
+>                    <*> (keyword "references" *> idString)
+>                    <*> option [] (parens $ commaSep1 idString)
+>                    <*> onUpdate
+>                    <*> onDelete]
+>                 where
+>                   conName = try $ do
+>                             x <- idString
+>                             if map toLower x `elem` [
+>                                     "unique"
+>                                    ,"primary"
+>                                    ,"check"
+>                                    ,"foreign"
+>                                    ,"references"]
+>                               then fail "not keyword"
+>                               else return x
+>
+> alterTable :: SParser Statement
+> alterTable = AlterTable <$> (pos <* keyword "table"
+>                              <* optional (keyword "only"))
+>                         <*> idString
+>                         <*> many1 action
+>              where action = choice [
+>                              AlterColumnDefault
+>                              <$> (pos <* keyword "alter" <* keyword "column")
+>                              <*> idString
+>                              <*> (keyword "set" *> keyword "default" *> expr)
+>                             ,AddConstraint
+>                              <$> (pos <* keyword "add")
+>                              <*> tableConstraint]
+>
+> createType :: SParser Statement
+> createType = CreateType
+>              <$> pos <* keyword "type"
+>              <*> idString
+>              <*> (keyword "as" *> parens (commaSep1 typeAtt))
+>   where
+>     typeAtt = TypeAttDef <$> pos <*> idString <*> typeName
+>
+> createSequence :: SParser Statement
+> createSequence = do
+>   p <- pos
+>   keyword "sequence"
+>   nm <- idString
+>   (stw, incr, mx, mn, c) <-
+>      permute ((,,,,) <$?> (1,startWith)
+>                      <|?> (1,increment)
+>                      <|?> ((2::Integer) ^ (63::Integer) - 1, maxi)
+>                      <|?> (1, mini)
+>                      <|?> (1, cache))
+>   return $ CreateSequence p nm incr mn mx stw c
+>   where
+>     startWith = keyword "start" *> optional (keyword "with") *> integer
+>     increment = keyword "increment" *> optional (keyword "by") *> integer
+>     maxi = (2::Integer) ^ (63::Integer) - 1
+>            <$ try (keyword "no" <* keyword "maxvalue")
+>     mini = 1 <$ try (keyword "no" <* keyword "minvalue")
+>     cache = keyword "cache" *> integer
+>
+> alterSequence :: SParser Statement
+> alterSequence = AlterSequence <$> pos
+>                               <*> (keyword "sequence" *> idString)
+>                               <*> (keyword "owned"
+>                                    *> keyword "by"
+>                                    *> dqi)
+
+create function, support sql functions and plpgsql functions. Parses
+the body in both cases and provides a statement list for the body
+rather than just a string.
+
+> createFunction :: SParser Statement
+> createFunction = do
+>   p <- pos
+>   rep <- choice [NoReplace <$ keyword "function"
+>                 ,Replace <$ mapM_ keyword ["or", "replace", "function"]
+>                 ]
+>   fnName <- idString
+>   params <- parens $ commaSep param
+>   retType <- keyword "returns" *> typeName
+>   ((bodypos,body), lang,vol) <-
+>     permute ((,,) <$$> parseAs
+>                   <||> readLang
+>                   <|?> (Volatile,pVol))
+>   case parseBody lang body bodypos of
+>        Left er -> fail er
+>        Right b ->
+>          return $ CreateFunction p fnName params retType rep lang b vol
+>     where
+>         parseAs = do
+>                    keyword "as"
+>                    bodypos <- toMySp <$> getPosition
+>                    body <- stringLit
+>                    return (bodypos,body)
+>         pVol = matchAKeyword [("volatile", Volatile)
+>                              ,("stable", Stable)
+>                              ,("immutable", Immutable)]
+>         readLang = keyword "language" *> matchAKeyword [("plpgsql", Plpgsql)
+>                                                        ,("sql",Sql)]
+>         parseBody :: Language -> ScalarExpr -> MySourcePos
+>                   -> Either String FnBody
+>         parseBody lang body (fileName,line,col) =
+>             case parseIt
+>                   (lexSqlTextWithPosition fileName line col (extrStr body))
+>                   (functionBody lang)
+>                   fileName
+>                   (Just (line,col))
+>                   (extrStr body)
+>                   () of
+>                      Left er@(ParseErrorExtra _ _ _) -> Left $ show er
+>                      Right body' -> Right body'
+>         -- sql function is just a list of statements, the last one
+>         -- has the trailing semicolon optional
+>         functionBody Sql = do
+>            p <- pos
+>            a <- many (try $ sqlStatement True)
+>            -- this makes my head hurt, should probably write out
+>            -- more longhand
+>            SqlFnBody p <$> option a ((\b -> a++[b]) <$> sqlStatement False)
+>         -- plpgsql function has an optional declare section, plus
+>         -- the statements are enclosed in begin ... end; (semi colon
+>         -- after end is optional)
+>         functionBody Plpgsql =
+>             PlpgsqlFnBody <$> pos <*> do
+>                    p <- pos
+>                    l <- label
+>                    block p l <* optional (symbol ";") <* eof
+
+params to a function
+
+> param :: SParser ParamDef
+> param = choice [
+>          try (ParamDef <$> pos <*> idString <*> typeName)
+>         ,ParamDefTp <$> pos <*> typeName]
+
+variable declarations in a plpgsql function
+
+> varDef :: SParser VarDef
+> varDef = do
+>   p <- pos
+>   a <- idString
+>   choice [do
+>           keyword "alias"
+>           keyword "for"
+>           choice [
+>             VarAlias p a <$> idString
+>            ,ParamAlias p a <$> liftPositionalArgTok]
+>          ,VarDef p a
+>           <$> typeName
+>           <*> tryOptionMaybe ((symbol ":=" <|> symbol "=")*> expr)
+>           ]
+>     <* symbol ";"
+>
+> createView :: SParser Statement
+> createView = CreateView
+>              <$> pos <* keyword "view"
+>              <*> idString
+>              <*> tryOptionMaybe (parens $ commaSep idString)
+>              <*> (keyword "as" *> pQueryExpr)
+
+>
+> createDomain :: SParser Statement
+> createDomain = CreateDomain
+>                <$> pos <* keyword "domain"
+>                <*> idString
+>                <*> (tryOptionMaybe (keyword "as") *> typeName)
+>                <*> option "" (keyword "constraint" *> idString)
+>                <*> tryOptionMaybe (keyword "check" *> parens expr)
+>
+> dropSomething :: SParser Statement
+> dropSomething = do
+>   p <- pos
+>   x <- try (choice [
+>                  Domain <$ keyword "domain"
+>                 ,Type <$ keyword "type"
+>                 ,Table <$ keyword "table"
+>                 ,View <$ keyword "view"
+>             ])
+>   (i,e,r) <- parseDrop idString
+>   return $ DropSomething p x i e r
+>
+> dropFunction :: SParser Statement
+> dropFunction = do
+>                p <- pos
+>                keyword "function"
+>                (i,e,r) <- parseDrop pFun
+>                return $ DropFunction p i e r
+>                where
+>                  pFun = (,) <$> idString
+>                             <*> parens (commaSep typeName)
+>
+> parseDrop :: SParser a
+>           -> SParser (IfExists, [a], Cascade)
+> parseDrop p = (,,)
+>               <$> ifExists
+>               <*> commaSep1 p
+>               <*> cascade
+>     where
+>       ifExists = option Require
+>                  (try $ IfExists <$ (keyword "if"
+>                                      *> keyword "exists"))
+>
+> createLanguage :: SParser Statement
+> createLanguage =
+>   CreateLanguage <$> pos
+>                  <*> (optional (keyword "procedural") *>
+>                       keyword "language" *>
+>                       idString)
+>
+> createTrigger :: SParser Statement
+> createTrigger =
+>   CreateTrigger <$> pos
+>                 <*> (keyword "trigger" *> idString)
+>                 <*> twhen
+>                 <*> tevents
+>                 <*> (keyword "on" *> idString)
+>                 <*> tfiring
+>                 <*> (keyword "execute" *> keyword "procedure"
+>                      *> idString)
+>                 <*> parens (commaSep expr)
+>   where
+>     twhen = choice [TriggerBefore <$ keyword "before"
+>                    ,TriggerAfter <$ keyword "after"]
+>     tevents :: SParser [TriggerEvent]
+>     tevents = sepBy1 (choice [
+>                          AntiTriggerEvent <$> splice
+>                         ,TInsert <$ keyword "insert"
+>                         ,TUpdate <$ keyword "update"
+>                         ,TDelete <$ keyword "delete"]) (keyword "or")
+>     tfiring = option EachStatement
+>                 (keyword "for" *> optional (keyword "each") *>
+>                 choice [
+>                   EachRow <$ keyword "row"
+>                  ,EachStatement <$ keyword "statement"])
+
+anti statement
+--------------
+
+> antiStatement :: SParser Statement
+> antiStatement = AntiStatement <$> splice
+
+--------------------------------------------------------------------------------
+
+component parsers for sql statements
+====================================
+
+> whereClause :: SParser ScalarExpr
+> whereClause = keyword "where" *> expr
+
+selectlist and selectitem: the bit between select and from
+check for into either before the whole list of select columns
+or after the whole list
+
+> selectList :: SParser SelectList
+> selectList = SelectList <$> pos
+>              <*> itemList
+>     {-pos >>= \p ->
+>     choice [
+>         --flip (SelectList p) <$> readInto <*> itemList
+>        SelectList p <$> itemList] -- <*> option [] readInto]-}
+>   where
+>     --readInto = keyword "into" *> commaSep1 qName
+>     itemList = commaSep1 selectItem
+>     selectItem = pos >>= \p ->
+>                  optionalSuffix
+>                    (SelExp p) expr
+>                    (SelectItem p) () (keyword "as" *> idString)
+>
+> returning :: SParser SelectList
+> returning = keyword "returning" *> selectList
+>
+> columnNameList :: SParser [String]
+> columnNameList = parens $ commaSep1 idString
+>
+> typeName :: SParser TypeName
+> typeName =
+>   choice [
+>      SetOfTypeName <$> pos <*> (keyword "setof" *> typeName)
+>     ,otherTypeName]
+>   where
+>     otherTypeName = do
+>        p <- pos
+>        s <- map toLower <$> pTypeNameString
+>        choice [try (Prec2TypeName p s
+>                     <$> (symbol "(" *> integer)
+>                     <*> (symbol "," *> integer <* symbol ")"))
+>               ,PrecTypeName p s <$> parens integer
+>               ,arrayTypeName p s
+>               ,return $ SimpleTypeName p s]
+>     arrayTypeName p s = ArrayTypeName p (SimpleTypeName p s)
+>                         <$ symbol "[" <* symbol "]"
+>     --todo: add special cases for the other type names with spaces in them
+>     pTypeNameString = ("double precision" <$ try (keyword "double"
+>                                                   <* keyword "precision"))
+>                       <|> idString
+>
+> cascade :: SParser Cascade
+> cascade = option Restrict (choice [
+>                             Restrict <$ keyword "restrict"
+>                            ,Cascade <$ keyword "cascade"])
+
+--------------------------------------------------------------------------------
+
+plpgsql statements
+==================
+
+> plPgsqlStatement :: SParser Statement
+> plPgsqlStatement =
+>    choice [
+>      -- modified sql statements
+>      choice [
+>         try intoQueryStatement
+>        ,choice [insert
+>                ,update
+>                ,delete] >>= intoSuffix
+>        ] <* symbol ";"
+>     -- regular sql statements
+>     ,sqlStatement True
+>     -- regular plpgsql statements
+>     ,choice [
+>           continue
+>          ,execute >>= intoSuffix
+>          ,caseStatement
+>          ,assignment
+>          ,ifStatement
+>          ,returnSt
+>          ,raise
+>          ,perform
+>          ,labelPrefixed
+>          ,nullStatement
+>          ,exitStatement]
+>          <* symbol ";"
+>     ]
+>    where
+>      intoSuffix e =
+>        option e (try $ do
+>                  i <- into
+>                  return $ i e)
+>      labelPrefixed = do
+>        p <- pos
+>        l <- label
+>        choice [block p l
+>               ,forStatement p l
+>               ,whileStatement p l
+>               ,loopStatement p l]
+
+> label :: SParser (Maybe String)
+> label = optional (symbol "<<" *> idString <* symbol ">>")
+>
+> block :: Annotation -> Maybe String -> SParser Statement
+> block p l = Block p l
+>             <$> option [] declarePart
+>             <*> statementPart
+>         where
+>           statementPart = keyword "begin"
+>                     *> many plPgsqlStatement
+>                     <* keyword "end"
+>           declarePart = keyword "declare"
+>                         *> manyTill (try varDef) (lookAhead $ keyword "begin")
+>
+>
+> nullStatement :: SParser Statement
+> nullStatement = NullStatement <$> (pos <* keyword "null")
+>
+> exitStatement :: SParser Statement
+> exitStatement = ExitStatement <$> (pos <* keyword "exit")
+>                               <*> optional idString
+>
+>
+> continue :: SParser Statement
+> continue = ContinueStatement <$> (pos <* keyword "continue")
+>                              <*> optional idString
+>
+> perform :: SParser Statement
+> perform = Perform <$> (pos <* keyword "perform") <*> expr
+>
+> execute :: SParser Statement
+> execute = Execute <$> (pos <* keyword "execute")
+>          <*> expr
+>          {-pos >>= \p ->  >>
+>           optionalSuffix
+>             (Execute p) expr
+>             (ExecuteInto p) () readInto
+>     where
+>       readInto = keyword "into" *> commaSep1 idString-}
+>
+> assignment :: SParser Statement
+> assignment = Assignment
+>              <$> pos
+>              -- put the := in the first try to attempt to get a
+>              -- better error if the code looks like malformed
+>              -- assignment statement
+>              <*> try (qName <* (symbol ":=" <|> symbol "="))
+>              <*> expr
+>
+> returnSt :: SParser Statement
+> returnSt = pos >>= \p -> keyword "return" >>
+>            choice [
+>             ReturnNext p <$> (keyword "next" *> expr)
+>            ,ReturnQuery p <$> (keyword "query" *> pQueryExpr)
+>            ,Return p <$> tryOptionMaybe expr]
+>
+> raise :: SParser Statement
+> raise = pos >>= \p -> keyword "raise" >>
+>         Raise p
+>         <$> raiseType
+>         <*> (extrStr <$> stringLit)
+>         <*> option [] (symbol "," *> commaSep1 expr)
+>         where
+>           raiseType = matchAKeyword [("notice", RNotice)
+>                                      ,("exception", RException)
+>                                      ,("error", RError)]
+>
+> forStatement :: Annotation -> Maybe String -> SParser Statement
+> forStatement p l = do
+>                keyword "for"
+>                start <- qName
+>                keyword "in"
+>                choice [ForQueryStatement p l start
+>                        <$> try pQueryExpr <*> theRest
+>                       ,ForIntegerStatement p l start
+>                               <$> expr
+>                               <*> (symbol ".." *> expr)
+>                               <*> theRest]
+>   where
+>     theRest = keyword "loop" *> many plPgsqlStatement
+>               <* keyword "end" <* keyword "loop"
+>
+> whileStatement :: Annotation -> Maybe String -> SParser Statement
+> whileStatement p l = WhileStatement p l
+>                      <$> (keyword "while" *> expr <* keyword "loop")
+>                      <*> many plPgsqlStatement <* keyword "end" <* keyword "loop"
+> loopStatement :: Annotation -> Maybe String -> SParser Statement
+> loopStatement p l = LoopStatement p l
+>                     <$> (keyword "loop" *> many plPgsqlStatement <* keyword "end" <* keyword "loop")
+>
+
+>
+> ifStatement :: SParser Statement
+> ifStatement = If
+>               <$> (pos <* keyword "if")
+>               <*> (ifPart <:> elseifParts)
+>               <*> (elsePart <* endIf)
+>   where
+>     ifPart = expr <.> (thn *> many plPgsqlStatement)
+>     elseifParts = many ((elseif *> expr) <.> (thn *> many plPgsqlStatement))
+>     elsePart = option [] (keyword "else" *> many plPgsqlStatement)
+>     endIf = keyword "end" <* keyword "if"
+>     thn = keyword "then"
+>     elseif = keyword "elseif" <|> keyword "elsif"
+>     --might as well throw this in as well after all that
+>     -- can't do <,> unfortunately, so use <.> instead
+>     (<.>) a b = (,) <$> a <*> b
+>
+> caseStatement :: SParser Statement
+> caseStatement = do
+>     p <- pos
+>     keyword "case"
+>     choice [try (CaseStatementSimple p
+>                  <$> expr
+>                  <*> many whenSt
+>                  <*> option [] (keyword "else" *> many plPgsqlStatement)
+>                         <* keyword "end" <* keyword "case")
+>            ,CaseStatement p
+>                  <$> many whenSt
+>                  <*> option [] (keyword "else" *> many plPgsqlStatement)
+>                         <* keyword "end" <* keyword "case"]
+>     where
+>       whenSt = keyword "when" >>
+>                (,) <$> commaSep1 expr
+>                    <*> (keyword "then" *> many plPgsqlStatement)
+
+--------------------------------------------------------------------------------
+
+expressions
+===========
+
+This is the bit that makes it the most obvious that I don't really
+know haskell, parsing theory or parsec ... robbed a parsing example
+from haskell-cafe and mainly just kept changing it until it seemed to
+work
+
+> expr :: SParser ScalarExpr
+> expr = buildExpressionParser table factor
+>        <?> "expression"
+>
+> factor :: SParser ScalarExpr
+> factor =
+
+First job is to take care of forms which start like a vanilla
+expression, and then add a suffix on
+
+>   fct >>= tryExprSuffix
+>   where
+>     tryExprSuffix e =
+>       option e (choice (map (\f -> f e)
+>                                  [inPredicateSuffix
+>                                  ,functionCallSuffix
+>                                  ,windowFnSuffix
+>                                  ,castSuffix
+>                                  ,betweenSuffix
+>                                  ,arraySubSuffix
+>                                  ,qualIdSuffix])
+>                 >>= tryExprSuffix)
+>     fct = choice [
+
+order these so the ones which can be valid prefixes of others appear
+further down the list (used to be a lot more important when there
+wasn't a separate lexer), probably want to refactor this to use the
+optionalsuffix parsers to improve speed.
+
+One little speed optimisation, to help with pretty printed code which
+can contain a lot of parens - check for nested ((
+This little addition speeds up ./ParseFile.lhs sqltestfiles/system.sql
+on my system from ~4 minutes to ~4 seconds (most of the 4s is probably
+compilation overhead).
+
+>        --try (lookAhead (symbol "(" >> symbol "(")) >> parens expr
+
+start with the factors which start with parens - eliminate scalar
+subqueries since they're easy to distinguish from the others then do in
+predicate before row constructor, since an in predicate can start with
+a row constructor looking thing, then finally vanilla parens
+
+>       --,
+>        scalarSubQuery
+>       ,try rowCtor
+>       ,parens expr
+
+try a few random things which can't start a different expression
+
+>       ,positionalArg
+>       ,placeholder
+>       ,stringLit
+>       ,numberLit
+
+put the factors which start with keywords before the ones which start
+with a function, so we don't try an parse a keyword as a function name
+
+>       ,caseScalarExpr
+>       ,exists
+>       ,booleanLit
+>       ,nullLit
+>       ,arrayLit
+>       ,castKeyword
+>       ,substring
+>       ,extract
+
+now do identifiers, functions, and window functions (each is a prefix
+to the next one)
+
+want to allow splices in e.g. function calls: $(fnname)(). To do this,
+don't want to parse anti expression above, but need to parse these
+following suffixes starting with a splice, but if there is no suffix,
+want to parse as an antiexpression rather than an antiidentifier
+
+>       ,try $ do
+>              i <- antiIdentifier
+>              choice [inPredicateSuffix i
+>                     ,threadOptionalSuffix (functionCallSuffix i)
+>                                           windowFnSuffix]
+
+>       ,antiScalarExpr
+>       ,antiIdentifier1
+>       ,try interval
+>       ,try typedStringLit
+>       ,identifier
+>       ]
+
+operator table
+--------------
+
+proper hacky, but sort of does the job
+the 'missing' notes refer to pg operators which aren't yet supported,
+or supported in a different way (e.g. cast uses the type name parser
+for one of it's argument, not the expression parser - I don't know if
+there is a better way of doing this but there usually is in parsec)
+
+pg's operator table is on this page:
+http://www.postgresql.org/docs/8.4/interactive/sql-syntax-lexical.html#SQL-SYNTAX-OPERATORS
+
+will probably need something more custom to handle full range of sql
+syntactical novelty, in particular the precedence rules mix these
+operators up with irregular syntax operators, you can create new
+operators during parsing, and some operators are prefix/postfix or
+binary depending on the types of their operands (how do you parse
+something like this?)
+
+The full list of operators from a standard template1 database should
+be used here.
+
+> tableAB :: Bool -> [[Operator [Token] ParseState Identity ScalarExpr]]
+> tableAB isB = [[{-binary "." AssocLeft-}]
+>          --[binary "::" (BinOpCall Cast) AssocLeft]
+>          --missing [] for array element select
+>         ,[prefix "-" "u-"]
+>         ,[binary "^" AssocLeft]
+>         ,[binary "*" AssocLeft
+>          ,idHackBinary "*" AssocLeft
+>          ,binary "/" AssocLeft
+>          ,binary "%" AssocLeft]
+>         ,[binary "+" AssocLeft
+>          ,binary "-" AssocLeft]
+>          --should be is isnull and notnull
+>         ,[postfixks ["is", "not", "null"] "!isnotnull"
+>          ,postfixks ["is", "null"] "!isnull"]
+>          --other operators all added in this list according to the pg docs:
+>         ,[binary "<->" AssocNone
+>          ,binary "<=" AssocRight
+>          ,binary ">=" AssocRight
+>          ,binary "||" AssocLeft
+>          ,prefix "@" "@"
+>          ]
+>          --in should be here, but is treated as a factor instead
+>          --between
+>          --overlaps
+>         ,[binaryk "like" "!like" AssocNone
+>          ,binaryks ["not","like"] "!notlike" AssocNone
+>          ,binarycust (symbol "!=") "<>" AssocNone]
+>          --(also ilike similar)
+>         ,[binary "<" AssocNone
+>          ,binary ">" AssocNone]
+>         ,[binary "=" AssocRight
+>          ,binary "<>" AssocNone]
+>         ,[notNot
+>          ,prefixk "not" "!not"
+>          ]
+>         ,let x = [binaryk "or" "!or" AssocLeft]
+>          in if isB
+>             then x
+>             else binaryk "and" "!and" AssocLeft : x
+>          ]
+>     where
+>       binary s = binarycust (symbol s) s
+>       -- '*' is lexed as an id token rather than a symbol token, so
+>       -- work around here
+>       idHackBinary s = binarycust (keyword s) s
+>       binaryk = binarycust . keyword
+>       binaryks = binarycust . mapM_ keyword
+>       prefix = unaryCust Prefix . symbol
+>       prefixk = unaryCust Prefix . keyword
+>       postfixks = unaryCust Postfix . mapM_ keyword
+>       binarycust opParse t =
+>         Infix $ try $ do
+>              f <- FunCall <$> pos <*> (t <$ opParse)
+>              return (\l m -> f [l,m])
+>       unaryCust ctor opParse t =
+>         ctor $ try $ do
+>           f <- FunCall <$> pos <*> (t <$ opParse)
+>           return (\l -> f [l])
+>       -- hack - haven't worked out why parsec buildexpression parser won't
+>       -- parse something like "not not EXPR" without parens so hack here
+>       notNot =
+>         Prefix (try $ do
+>                       p1 <- pos
+>                       keyword "not"
+>                       p2 <- pos
+>                       keyword "not"
+>                       return (\l -> FunCall p1 "!not"
+>                                       [FunCall p2 "!not" [l]]))
+
+From postgresql src/backend/parser/gram.y
+
+~~~~~
+
+ * We have two expression types: a_expr is the unrestricted kind, and
+ * b_expr is a subset that must be used in some places to avoid shift/reduce
+ * conflicts.  For example, we can't do BETWEEN as "BETWEEN a_expr AND a_expr"
+ * because that use of AND conflicts with AND as a boolean operator.  So,
+ * b_expr is used in BETWEEN and we remove boolean keywords from b_expr.
+ *
+ * Note that '(' a_expr ')' is a b_expr, so an unrestricted expression can
+ * always be used by surrounding it with parens.
+
+~~~~~
+
+> table :: [[Operator [Token] ParseState Identity ScalarExpr]]
+> table = tableAB False
+
+> tableB :: [[Operator [Token] ParseState Identity ScalarExpr]]
+> tableB = tableAB True
+
+use the same factors
+
+> b_expr :: SParser ScalarExpr
+> b_expr = buildExpressionParser tableB factor
+>        <?> "expression"
+>
+
+factor parsers
+--------------
+
+I think the lookahead is used in an attempt to help the error messages.
+
+> scalarSubQuery :: SParser ScalarExpr
+> scalarSubQuery = try (symbol "(" *> lookAhead (keyword "select"
+>                                                <|> keyword "with")) >>
+>                  ScalarSubQuery
+>                  <$> pos
+>                  <*> pQueryExpr <* symbol ")"
+
+in predicate - an identifier or row constructor followed by 'in'
+then a list of expressions or a subselect
+
+> inPredicateSuffix :: ScalarExpr -> SParser ScalarExpr
+> inPredicateSuffix e = try $
+>   InPredicate
+>   <$> pos
+>   <*> return e
+>   <*> option True (False <$ keyword "not")
+>   <*> (keyword "in" *> parens ((InQueryExpr <$> pos <*> pQueryExpr)
+>                                <|>
+>                                (InList <$> pos <*> commaSep1 expr)))
+
+row ctor: one of
+
+* row ()
+* row (expr)
+* row (expr, expr1, ...)
+* (expr, expr2,...) [implicit (no row keyword) version, at least two elements
+                   must be present]
+
+* (expr) parses to just expr rather than row(expr)
+* and () is a syntax error.
+
+> rowCtor :: SParser ScalarExpr
+> rowCtor = FunCall
+>           <$> pos
+>           <*> return "!rowctor"
+>           <*> choice [
+>            keyword "row" *> parens (commaSep expr)
+>           ,parens $ commaSep2 expr]
+>
+> numberLit :: SParser ScalarExpr
+> numberLit = NumberLit <$> pos <*> numString
+>
+
+> integer :: SParser Integer
+> integer = do
+>   l <- numString
+>   guard (all (`elem` digChars) l)
+>   return $ read l
+>   where
+>     digChars = concatMap show [(0::Int)..9]
+
+ > integerLit :: SParser ScalarExpr
+ > integerLit = do
+ >   p <- pos
+ >   (IntegerLit p) <$> integer
+
+ IntegerLit <$> pos <*> integer
+
+>
+> caseScalarExpr :: SParser ScalarExpr
+> caseScalarExpr = do
+>   p <- pos
+>   keyword "case"
+>   choice [
+>              try $ CaseSimple p <$> expr
+>                                 <*> many whenParse
+>                                 <*> tryOptionMaybe (keyword "else" *> expr)
+>                                         <* keyword "end"
+>             ,Case p <$> many whenParse
+>                     <*> tryOptionMaybe (keyword "else" *> expr)
+>                             <* keyword "end"]
+>   where
+>     whenParse = (,) <$> (keyword "when" *> commaSep1 expr)
+>                     <*> (keyword "then" *> expr)
+>
+> exists :: SParser ScalarExpr
+> exists = Exists <$> pos <* keyword "exists" <*> parens pQueryExpr
+>
+
+> booleanLit :: SParser ScalarExpr
+> booleanLit = BooleanLit <$> pos <*> (True <$ keyword "true"
+>                                      <|> False <$ keyword "false")
+
+>
+> nullLit :: SParser ScalarExpr
+> nullLit = NullLit <$> pos <* keyword "null"
+>
+> arrayLit :: SParser ScalarExpr
+> arrayLit = FunCall <$> pos <* keyword "array"
+>                    <*> return "!arrayctor"
+>                    <*> squares (commaSep expr)
+>
+> arraySubSuffix :: ScalarExpr -> SParser ScalarExpr
+> arraySubSuffix e = case e of
+>                      Identifier _ "array" -> fail "can't use array as \
+>                                                   \identifier name"
+>                      _ -> FunCall <$> pos
+>                                   <*> return "!arraysub"
+>                                   <*> ((e:) <$> squares (commaSep1 expr))
+>
+> windowFnSuffix :: ScalarExpr -> SParser ScalarExpr
+> windowFnSuffix e = WindowFn <$> pos <*> return e
+>                    <*> (keyword "over"
+>                         *> (symbol "(" *> option [] partitionBy))
+>                    <*> option [] orderBy1
+>                    <*> option Asc (try $ choice [
+>                                             Asc <$ keyword "asc"
+>                                            ,Desc <$ keyword "desc"])
+>                    <*> frm
+>                    <* symbol ")"
+>   where
+>     orderBy1 = keyword "order" *> keyword "by" *> commaSep1 expr
+>     partitionBy = keyword "partition" *> keyword "by" *> commaSep1 expr
+>     frm = option FrameUnboundedPreceding $ choice
+>                                          $ map (\(a,b) -> a <$ try (ks b)) [
+>            (FrameUnboundedPreceding, ["range","unbounded","preceding"])
+>           ,(FrameUnboundedPreceding, ["range"
+>                                      ,"between"
+>                                      ,"unbounded"
+>                                      ,"preceding"
+>                                      ,"and"
+>                                      ,"current"
+>                                      ,"row"])
+>           ,(FrameUnboundedFull, ["range"
+>                                 ,"between"
+>                                 ,"unbounded"
+>                                 ,"preceding"
+>                                 ,"and"
+>                                 ,"unbounded"
+>                                 ,"following"])
+>           ,(FrameUnboundedFull, ["rows"
+>                                 ,"between"
+>                                 ,"unbounded"
+>                                 ,"preceding"
+>                                 ,"and"
+>                                 ,"unbounded"
+>                                 ,"following"])
+>           ,(FrameRowsUnboundedPreceding, ["rows","unbounded","preceding"])
+>           ,(FrameRowsUnboundedPreceding, ["rows"
+>                                          ,"between"
+>                                          ,"unbounded"
+>                                          ,"preceding"
+>                                          ,"and"
+>                                          ,"current"
+>                                          ,"row"])]
+>     ks = mapM keyword
+>
+> betweenSuffix :: ScalarExpr -> SParser ScalarExpr
+> betweenSuffix a = do
+>   p <- pos
+>   keyword "between"
+>   b <- b_expr --dodgyParseElement
+>   keyword "and"
+>   c <- b_expr -- dodgyParseElement
+>   return $ FunCall p "!between" [a,b,c]
+>              --can't use the full expression parser at this time
+>              --because of a conflict between the operator 'and' and
+>              --the 'and' part of a between
+>   --where
+>   --  dodgyParseElement = factor
+
+
+> functionCallSuffix :: ScalarExpr -> SParser ScalarExpr
+> functionCallSuffix (Identifier _ fnName) =
+>   pos >>= \p -> FunCall p fnName
+>                 <$> parens (optional (keyword "all"
+>                                       <|> keyword "distinct")
+>                             *> commaSep expr)
+> functionCallSuffix s =
+>   fail $ "cannot make functioncall from " ++ show s
+>
+> castKeyword :: SParser ScalarExpr
+> castKeyword = Cast
+>               <$> pos <* keyword "cast" <* symbol "("
+>               <*> expr
+>               <*> (keyword "as" *> typeName <* symbol ")")
+>
+> castSuffix :: ScalarExpr -> SParser ScalarExpr
+> castSuffix ex = pos >>= \p -> Cast p ex <$> (symbol "::" *> typeName)
+
+> typedStringLit :: SParser ScalarExpr
+> typedStringLit = TypedStringLit
+>                  <$> pos
+>                  <*> typeName
+>                  <*> (extrStr <$> stringLit)
+
+> extract :: SParser ScalarExpr
+> extract = try $ do
+>   p <- pos
+>   _ <- keyword "extract"
+>   _ <- symbol "("
+>   f <- extractField
+>   _ <- keyword "from"
+>   e <- expr
+>   _ <- symbol ")"
+>   return $ Extract p f e
+>   where
+>     extractField =
+>       choice [ExtractCentury <$ keyword "century"
+>              ,ExtractDay <$ keyword "day"
+>              ,ExtractDecade <$ keyword "decade"
+>              ,ExtractDow <$ keyword "dow"
+>              ,ExtractDoy <$ keyword "doy"
+>              ,ExtractEpoch <$ keyword "epoch"
+>              ,ExtractHour <$ keyword "hour"
+>              ,ExtractIsodow <$ keyword "isodow"
+>              ,ExtractIsoyear <$ keyword "isoyear"
+>              ,ExtractMicroseconds <$ keyword "microseconds"
+>              ,ExtractMillennium <$ keyword "millennium"
+>              ,ExtractMilliseconds <$ keyword "milliseconds"
+>              ,ExtractMinute <$ keyword "minute"
+>              ,ExtractMonth <$ keyword "month"
+>              ,ExtractQuarter <$ keyword "quarter"
+>              ,ExtractSecond <$ keyword "second"
+>              ,ExtractTimezone <$ keyword "timezone"
+>              ,ExtractTimezoneHour <$ keyword "timezone_hour"
+>              ,ExtractTimezoneMinute <$ keyword "timezone_minute"
+>              ,ExtractWeek <$ keyword "week"
+>              ,ExtractYear <$ keyword "year"]
+
+> interval :: SParser ScalarExpr
+> interval = Interval
+>            <$> pos
+>            <*> (keyword "interval" *> (extrStr <$> stringLit))
+>            <*> intervalField
+>            <*> tryOptionMaybe (parens (fromInteger <$> integer))
+>   where
+>     intervalField =
+>         choice [IntervalYear <$ keyword "year"
+>                ,IntervalMonth <$ keyword "month"
+>                ,IntervalDay <$ keyword "day"
+>                ,IntervalHour <$ keyword "hour"
+>                ,IntervalMinute <$ keyword "minut"
+>                ,IntervalSecond <$ keyword "second"
+>                {-,IntervalYearToMonth <$ keyword "day"
+>                ,IntervalDayToHour <$ keyword "day"
+>                ,IntervalDayToMinute <$ keyword "day"
+>                ,IntervalDayToSecond <$ keyword "day"
+>                ,IntervalHourToMinute <$ keyword "day"
+>                ,IntervalHourToSecond <$ keyword "day"
+>                ,IntervalMinuteToSecond <$ keyword "day"-}]
+>
+> substring :: SParser ScalarExpr
+> substring = do
+>             p <- pos
+>             keyword "substring"
+>             symbol "("
+>             a <- expr
+>             keyword "from"
+>             b <- expr
+>             keyword "for"
+>             c <- expr
+>             symbol ")"
+>             return $ FunCall p "!substring" [a,b,c]
+>
+> identifier :: SParser ScalarExpr
+> identifier = Identifier <$> pos <*> (idString <|> splice)
+>
+> qualIdSuffix :: ScalarExpr -> SParser ScalarExpr
+> qualIdSuffix ex = pos >>= \p -> QIdentifier p ex <$> (symbol "." *> idString)
+
+> antiIdentifier :: SParser ScalarExpr
+> antiIdentifier = Identifier <$> pos <*> spliceD
+
+> antiIdentifier1 :: SParser ScalarExpr
+> antiIdentifier1 = Identifier <$> pos <*> ssplice
+>                   where
+>                     ssplice = (\s -> "$i(" ++ s ++ ")") <$>
+>                               (symbol "$i(" *> idString <* symbol ")")
+
+qualified names are parsed using "." as an operator so they become
+FunCall nodes. But we don't want to parse any expression when we are
+expecting a qualified name only, so create a specialized parser just
+for that
+
+> qName :: SParser ScalarExpr
+> qName = do
+>   i <- identifier
+>   choice [do
+>            p <- pos
+>            symbol "."
+>            i1 <- idString
+>            return $ QIdentifier p i i1 --FunCall p "." [i,i1]
+>          ,return i]
+
+> dqi :: SParser SQIdentifier
+> dqi = do
+>   p <- pos
+>   i <- idString
+>   choice [do
+>           is <- suffix
+>           return $ SQIdentifier p (i:is)
+>          ,return $ SQIdentifier p [i]
+>          ]
+>   where
+>     suffix = do
+>         symbol "."
+>         i1 <- idString
+>         choice [do
+>                 is <- suffix
+>                 return (i1:is)
+>                ,return [i1]
+>                ]
+
+
+--------------------------------------------------------------------------------
+
+Utility parsers
+===============
+
+tokeny things
+-------------
+
+keyword has to not be immediately followed by letters or numbers
+(symbols and whitespace are ok) so we know that we aren't reading an
+identifier which happens to start with a complete keyword
+
+> keyword :: String -> SParser ()
+> keyword k = mytoken (\tok ->
+>                                case tok of
+>                                IdStringTok i | lcase k == lcase i -> Just ()
+>                                _ -> Nothing)
+>                       where
+>                         lcase = map toLower
+>
+> idString :: SParser String
+> idString =
+>     choice [(\l -> "$(" ++ l ++ ")")
+>             <$> (symbol "$(" *> idString <* symbol ")")
+>            ,ids
+>            ]
+>   where
+>     ids = mytoken (\tok -> case tok of
+>                                      IdStringTok "not" -> Nothing
+>                                      IdStringTok i -> Just i
+>                                      _ -> Nothing)
+>
+> spliceD :: SParser String
+> spliceD = (\x -> "$(" ++ x ++ ")") <$> splice
+>
+> splice :: SParser String
+> splice = symbol "$(" *> idString <* symbol ")"
+>
+> symbol :: String -> SParser ()
+> symbol c = mytoken (\tok -> case tok of
+>                                    SymbolTok s | c==s -> Just ()
+>                                    _           -> Nothing)
+>
+> {-integer :: SParser Integer
+> integer = mytoken (\tok -> case tok of
+>                                     IntegerTok n -> Just n
+>                                     _ -> Nothing)-}
+>
+> liftPositionalArgTok :: SParser Integer
+> liftPositionalArgTok =
+>   mytoken (\tok -> case tok of
+>                    PositionalArgTok n -> Just n
+>                    _ -> Nothing)
+
+> positionalArg :: SParser ScalarExpr
+> positionalArg = PositionalArg <$> pos <*> liftPositionalArgTok
+>
+> antiScalarExpr :: SParser ScalarExpr
+> antiScalarExpr = AntiScalarExpr <$> splice
+>
+> placeholder :: SParser ScalarExpr
+> placeholder = (Placeholder <$> pos) <* symbol "?"
+>
+> numString :: SParser String
+> numString = mytoken (\tok -> case tok of
+>                                     NumberTok n -> Just n
+>                                     _ -> Nothing)
+
+>
+> liftStringTok :: SParser String
+> liftStringTok = mytoken (\tok ->
+>                   case tok of
+>                            StringTok _ s -> Just s
+>                            _ -> Nothing)
+
+> stringLit :: SParser ScalarExpr
+> stringLit = (StringLit <$> pos <*> liftStringTok)
+>             <|>
+>             (StringLit <$> pos <*> ssplice)
+>              where
+>                ssplice = (\s -> "$s(" ++ s ++ ")") <$>
+>                            (symbol "$s(" *> idString <* symbol ")")
+>
+> stringN :: SParser String
+> stringN = mytoken (\tok ->
+>                   case tok of
+>                            StringTok _ s -> Just s
+>                            _ -> Nothing)
+
+> extrStr :: ScalarExpr -> String
+> extrStr (StringLit _ s) = s
+> extrStr x =
+>   error $ "internal error: extrStr not supported for this type " ++ show x
+
+== combinatory things
+
+> parens :: SParser a
+>        -> SParser a
+> parens = between (symbol "(") (symbol ")")
+>
+> squares :: SParser a
+>        -> SParser a
+> squares = between (symbol "[") (symbol "]")
+>
+> tryOptionMaybe :: (Stream s m t) =>
+>              ParsecT s u m a -> ParsecT s u m (Maybe a)
+> tryOptionMaybe p = try (optionMaybe p) <|> return Nothing
+>
+> commaSep2 :: SParser a
+>           -> SParser [a]
+> commaSep2 p = sepBy2 p (symbol ",")
+>
+> sepBy2 :: (Stream s m t) =>
+>           ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m [a]
+> sepBy2 p sep = (p <* sep) <:> sepBy1 p sep
+>
+> commaSep :: SParser a
+>          -> SParser [a]
+> commaSep p = sepBy p (symbol ",")
+>
+> commaSep1 :: SParser a
+>           -> SParser [a]
+> commaSep1 p = sepBy1 p (symbol ",")
+
+pass a list of pairs of strings and values
+try each pair k,v in turn,
+if keyword k matches then return v
+doesn't really add a lot of value
+
+> matchAKeyword :: [(String, a)] -> SParser a
+> matchAKeyword [] = fail "no matches"
+> matchAKeyword ((k,v):kvs) = v <$ keyword k <|> matchAKeyword kvs
+
+parseOptionalSuffix
+
+parse the start of something -> parseResultA,
+then parse an optional suffix -> parseResultB
+if this second parser succeeds, return fn2 parseResultA parseResultB
+else return fn1 parseResultA
+
+e.g.
+parsing an identifier in a select list can be
+fieldName
+or
+fieldName as alias
+so we can pass
+* IdentifierCtor
+* identifier (returns aval)
+* AliasedIdentifierCtor
+* () - looks like a place holder, probably a crap idea
+* parser for (as b) (returns bval)
+as the args, which I like to ident like:
+parseOptionalSuffix
+  IdentifierCtor identifierParser
+  AliasedIdentifierCtor () asAliasParser
+and we get either
+* IdentifierCtor identifierValue
+or
+* AliasedIdentifierCtor identifierValue aliasValue
+as the result depending on whether the asAliasParser
+succeeds or not.
+
+probably this concept already exists under a better name in parsing
+theory
+
+> optionalSuffix :: (Stream s m t2) =>
+>                   (t1 -> b)
+>                -> ParsecT s u m t1
+>                -> (t1 -> a -> b)
+>                -> ()
+>                -> ParsecT s u m a
+>                -> ParsecT s u m b
+> optionalSuffix c1 p1 c2 _ p2 = do
+>   x <- p1
+>   option (c1 x) (c2 x <$> try p2)
+
+threadOptionalSuffix
+
+parse the start of something -> parseResultA,
+then parse an optional suffix, passing parseResultA
+  to this parser -> parseResultB
+return parseResultB is it succeeds, else return parseResultA
+
+sort of like a suffix operator parser where the suffixisable part
+is parsed, then if the suffix is there it wraps the suffixisable
+part in an enclosing tree node.
+
+parser1 -> tree1
+(parser2 tree1) -> maybe tree2
+tree2 isnothing ? tree1 : tree2
+
+> threadOptionalSuffix :: ParsecT [tok] st Identity a
+>                      -> (a -> GenParser tok st a)
+>                      -> ParsecT [tok] st Identity a
+> threadOptionalSuffix p1 p2 = do
+>   x <- p1
+>   option x (try $ p2 x)
+
+I'm pretty sure this is some standard monad operation but I don't know
+what. It's a bit like the maybe monad but when you get nothing it
+returns the previous result instead of nothing
+- if you take the parsing specific stuff out you get:
+
+p1 :: (Monad m) =>
+      m b -> (b -> m (Maybe b)) -> m b
+p1 = do
+   x <- p1
+   y <- p2 x
+   case y of
+     Nothing -> return x
+     Just z -> return z
+=====
+
+like thread optional suffix, but we pass a list of suffixes in, not
+much of a shorthand
+
+> {- threadOptionalSuffixes :: ParsecT [tok] st Identity a
+>                        -> [a -> GenParser tok st a]
+>                        -> ParsecT [tok] st Identity a
+> threadOptionalSuffixes p1 p2s = do
+>   x <- p1
+>   option x (try $ choice (map (\l -> l x) p2s))-}
+
+couldn't work how to to perms so just did this hack instead
+e.g.
+a1,a2,b1,b2,a2,b3,b4 parses to ([a1,a2,a3],[b1,b2,b3,b4])
+
+> multiPerm :: (Stream s m t) =>
+>                ParsecT s u m a1
+>             -> ParsecT s u m a
+>             -> ParsecT s u m sep
+>             -> ParsecT s u m ([a1], [a])
+>
+> multiPerm p1 p2 sep = do
+>   (r1, r2) <- unzip <$> sepBy1 parseAorB sep
+>   return (catMaybes r1, catMaybes r2)
+>   where
+>     parseAorB = choice [
+>                   (\x -> (Just x,Nothing)) <$> p1
+>                  ,(\y -> (Nothing, Just y)) <$> p2]
+
+== position stuff
+
+simple wrapper for parsec source positions, probably not really useful
+
+> type MySourcePos = (String,Int,Int)
+>
+> toMySp :: SourcePos -> MySourcePos
+> toMySp sp = (sourceName sp,sourceLine sp,sourceColumn sp)
+
+parser combinator to return the current position as an ast annotation
+
+> pos :: SParser Annotation
+> pos =
+>   (\a -> emptyAnnotation {asrc=Just a}) <$> toMySp <$> getPosition
+
+== lexer stuff
+
+> mytoken :: (Tok -> Maybe a) -> SParser a
+> mytoken test
+>   = token showToken posToken testToken
+>   where
+>   showToken (_,tok)   = show tok
+>   posToken  (posi,_)  = posi
+>   testToken (_,tok)   = test tok
+
+--------------------------------------------------------------------------------
+
+= fixup tree
+
+this is where some generics code is used to transform the parse trees
+to alter the nodes used where it's too difficult to do whilst
+parsing. The only item at the moment that needs this treatment is the
+any/some/all construct which looks like this:
+expr operator [any|some|all] (expr)
+
+This gets parsed as
+funcall operator [expr1,funcall [any|some|all] [expr2,...]]
+and we want to transform it to
+liftoperator operator any|some|all [expr1, expr2,...]
+not doing anything if the funcall name isn't any,some,all
+any other checks are left to the type checking stage
+(e.g. there can only be one expression in the expr2 part, and it must
+be an array or subselect, etc)
+
+> fixupTree :: Data a => a -> a
+> fixupTree =
+>     transformBi $ \x ->
+>       case x of
+>              FunCall an op (expr1:FunCall _ nm expr2s:expr3s)
+>                | isOperatorName op
+>                  && map toLower nm `elem` ["any", "some", "all"]
+>                -> LiftOperator an op flav (expr1:expr2s ++ expr3s)
+>                   where flav = case map toLower nm of
+>                                  "any" -> LiftAny
+>                                  "some" -> LiftAny
+>                                  "all" -> LiftAll
+>                                  z -> error $ "internal error in parsing \
+>                                               \lift transform: " ++ z
+>              x1 -> x1
+
+--------------------------------------------------------------------------------
+
+Parse state not currently used. Use these placeholders to add some.
+
+> type ParseState = ()
+>
+> startState :: ()
+> startState = ()
diff --git a/src/Database/HsSqlPpp/Pretty.lhs b/src/Database/HsSqlPpp/Pretty.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Pretty.lhs
@@ -0,0 +1,897 @@
+
+
+> {- | Functions to convert sql asts to valid SQL source code. Includes
+>    a function - 'printSqlAnn' - to output the annotations from a tree
+>    in comments in the outputted SQL source.
+>
+>    Produces sort of readable code, but mainly just written to produce
+>    reparsable text. Could do with some work to make the outputted text
+>    layout better.
+> -}
+> {-# LANGUAGE PatternGuards #-}
+> module Database.HsSqlPpp.Pretty (
+>                       --convert a sql ast to text
+>                       printStatements
+>                      ,printStatementsAnn
+>                      ,printQueryExpr
+>                       --convert a single expression parse node to text
+>                      ,printScalarExpr
+>                      ,printQueryExprNice
+>                      )
+>     where
+>
+> import Text.PrettyPrint
+> import Data.Char
+> --import Data.List
+> import Data.Maybe
+>
+> import Database.HsSqlPpp.Ast
+> import Database.HsSqlPpp.Annotation
+> import Database.HsSqlPpp.Catalog
+> import Database.HsSqlPpp.Utils.Utils
+
+--------------------------------------------------------------------------------
+
+Public functions
+
+> -- | convert an ast back to valid SQL source, it's also almost human readable.
+> printStatements :: StatementList -> String
+> printStatements = printStatementsAnn (const "")
+>
+> -- | convert the ast back to valid source, and convert any annotations to
+> -- text using the function provided and interpolate the output of
+> -- this function(inside comments) with the SQL source.
+> printStatementsAnn :: (Annotation -> String) -> StatementList -> String
+> printStatementsAnn f ast = render $ vcat (map (convStatement False True f) ast) <> text "\n"
+>
+
+> printQueryExpr :: QueryExpr -> String
+> printQueryExpr ast = render (convQueryExpr False True True ast <> statementEnd True)
+
+> -- | Testing function, pretty print an expression
+> printScalarExpr :: ScalarExpr -> String
+> printScalarExpr = render . convExp False
+
+
+> -- | Try harder to make the output human readable, not necessary correct
+> -- sql output at the moment
+> printQueryExprNice :: QueryExpr -> String
+> printQueryExprNice ast = render (convQueryExpr True True True ast <> statementEnd True)
+
+
+-------------------------------------------------------------------------------
+
+Conversion routines - convert Sql asts into Docs
+
+> -- Statements
+>
+> convStatement :: Bool -> Bool -> (Annotation -> String) -> Statement -> Doc
+>
+> -- selects
+>
+> convStatement nice se ca (QueryStatement ann s) =
+>   convPa ca ann <+>
+>   convQueryExpr nice True True s <> statementEnd se
+>
+> --dml
+>
+> convStatement nice se pa (Insert ann tb atts idata rt) =
+>   convPa pa ann <+>
+>   text "insert into" <+> convDqi tb
+>   <+> ifNotEmpty (parens . sepCsvMap text) atts
+>   $+$ convQueryExpr nice True True idata
+>   $+$ convReturning nice rt
+>   <> statementEnd se
+>
+> convStatement nice se ca (Update ann tb scs fr wh rt) =
+>    convPa ca ann <+>
+>    text "update" <+> convDqi tb <+> text "set"
+>    <+> sepCsvMap (convSet nice) scs
+>    <+> ifNotEmpty (\_ -> text "from" <+> sepCsvMap (convTref nice) fr) fr
+>    <+> convWhere nice wh
+>    $+$ convReturning nice rt <> statementEnd se
+>
+> convStatement nice se ca (Delete ann tbl us wh rt) =
+>    convPa ca ann <+>
+>    text "delete from" <+> convDqi tbl
+>    <+> ifNotEmpty (\_ -> text "using" <+> sepCsvMap (convTref nice) us) us
+>    <+> convWhere nice wh
+>    $+$ convReturning nice rt
+>    <> statementEnd se
+>
+> convStatement _nice se ca (Truncate ann names ri casc) =
+>     convPa ca ann <+>
+>     text "truncate"
+>     <+> sepCsvMap text names
+>     <+> text (case ri of
+>                       RestartIdentity -> "restart identity"
+>                       ContinueIdentity -> "continue identity")
+>     <+> convCasc casc
+>     <> statementEnd se
+>
+> -- ddl
+>
+> convStatement nice se ca (CreateTable ann tbl atts cns) =
+>     convPa ca ann <+>
+>     text "create table"
+>     <+> text tbl <+> lparen
+>     $+$ nest 2 (vcat (csv (map convAttDef atts ++ map (convCon nice) cns)))
+>     $+$ rparen <> statementEnd se
+>     where
+>       convAttDef (AttributeDef _ n t def cons) =
+>         text n <+> convTypeName t
+>         <+> maybeConv (\e -> text "default" <+> convExp nice e) def
+>         <+> hsep (map cCons cons)
+>       cCons (NullConstraint _ cn) =
+>         mname cn <+> text "null"
+>       cCons (NotNullConstraint _ cn) =
+>         mname cn <+> text "not null"
+>       cCons (RowCheckConstraint _ cn ew) =
+>         mname cn <+> text "check" <+> parens (convExp nice ew)
+>       cCons (RowUniqueConstraint _ cn) =
+>         mname cn <+> text "unique"
+>       cCons (RowPrimaryKeyConstraint _ cn) =
+>         mname cn <+> text "primary key"
+>       cCons (RowReferenceConstraint _ cn tb att ondel onupd) =
+>         mname cn <+> text "references" <+> text tb
+>         <+> maybeConv (parens . text) att
+>         <+> text "on delete" <+> convCasc ondel
+>         <+> text "on update" <+> convCasc onupd
+>
+> convStatement nice se ca (AlterTable ann name act) =
+>     convPa ca ann <+>
+>     text "alter table" <+> text name
+>     <+> hcatCsvMap convAct act <> statementEnd se
+>     where
+>       convAct (AlterColumnDefault _ nm def) =
+>           text "alter column" <+> text nm
+>           <+> text "set default" <+> convExp nice def
+>       convAct (AddConstraint _ con) =
+>           text "add " <+> convCon nice con
+>
+> convStatement _nice se ca (CreateSequence ann nm incr _ _ start cache) =
+>     convPa ca ann <+>
+>     text "create sequence" <+> text nm <+>
+>     text "increment" <+> text (show incr) <+>
+>     text "no minvalue" <+>
+>     text "no maxvalue" <+>
+>     text "start" <+> text (show start) <+>
+>     text "cache" <+> text (show cache) <> statementEnd se
+>
+> convStatement _nice se ca (AlterSequence ann nm o) =
+>     convPa ca ann <+>
+>     text "alter sequence" <+> text nm
+>     <+> text "owned by" <+> convDqi o <> statementEnd se
+>
+> convStatement nice se ca (CreateTableAs ann t sel) =
+>     convPa ca ann <+>
+>     text "create table"
+>     <+> text t <+> text "as"
+>     $+$ convQueryExpr nice True True sel
+>     <> statementEnd se
+>
+> convStatement nice se ca (CreateFunction ann name args retType rep lang body vol) =
+>     convPa ca ann <+>
+>     text ("create " ++ (case rep of
+>                          Replace -> "or replace "
+>                          _ -> "") ++ "function")
+>     <+> text name
+>     <+> parens (sepCsvMap convParamDef args)
+>     <+> text "returns" <+> convTypeName retType <+> text "as" <+> text "$$"
+>     $+$ convFnBody body
+>     $+$ text "$$" <+> text "language"
+>     <+> text (case lang of
+>                         Sql -> "sql"
+>                         Plpgsql -> "plpgsql")
+>     <+> text (case vol of
+>                        Volatile -> "volatile"
+>                        Stable -> "stable"
+>                        Immutable -> "immutable")
+>     <> statementEnd se
+>     where
+>       convFnBody (SqlFnBody ann1 sts) =
+>         convPa ca ann1 <+>
+>         convNestedStatements nice ca sts
+>       convFnBody (PlpgsqlFnBody ann1 blk) =
+>           convPa ca ann1 <+>
+>           convStatement nice True ca blk
+>       convParamDef (ParamDef _ n t) = text n <+> convTypeName t
+>       convParamDef  (ParamDefTp _ t) = convTypeName t
+>
+> convStatement nice se ca (Block ann lb decls sts) =
+>   convPa ca ann <+>
+>   convLabel lb <>
+>   ifNotEmpty (\l -> text "declare"
+>                   $+$ nest 2 (vcat $ map convVarDef l)) decls
+>   $+$ text "begin"
+>   $+$ convNestedStatements nice ca sts
+>   $+$ text "end" <> statementEnd se
+>   where
+>       convVarDef (VarDef _ n t v) =
+>         text n <+> convTypeName t
+>         <+> maybeConv (\x -> text ":=" <+> convExp nice x) v <> semi
+>       convVarDef (VarAlias _ n n1) =
+>         text n <+> text "alias for" <+> text n1 <> semi
+>       convVarDef (ParamAlias _ n p) =
+>         text n <+> text "alias for $" <> text (show p) <> semi
+>
+>
+> convStatement nice se ca (CreateView ann name cols sel) =
+>     convPa ca ann <+>
+>     text "create view" <+> text name
+>     <> case cols of
+>          Nothing -> empty
+>          Just cs -> parens (sepCsvMap text cs)
+>     <+> text "as"
+>     $+$ nest 2 (convQueryExpr nice True True sel) <> statementEnd se
+>
+> convStatement nice se ca (CreateDomain ann name tp n ex) =
+>     convPa ca ann <+>
+>     text "create domain" <+> text name <+> text "as"
+>     <+> convTypeName tp <+> cname <+> checkExp ex <> statementEnd se
+>     where
+>       checkExp = maybeConv (\e -> text "check" <+> parens (convExp nice e))
+>       cname = if n == ""
+>                then empty
+>                else text "constraint" <+> text n
+>
+> convStatement _nice se ca (DropFunction ann ifExists fns casc) =
+>   convPa ca ann <+>
+>   text "drop function"
+>   <+> convIfExists ifExists
+>   <+> sepCsvMap doFunction fns
+>   <+> convCasc casc
+>   <> statementEnd se
+>   where
+>     doFunction (name,types) =
+>       text name <> parens (sepCsvMap convTypeName types)
+>
+> convStatement _nice se ca (DropSomething ann dropType ifExists names casc) =
+>     convPa ca ann <+>
+>     text "drop"
+>     <+> text (case dropType of
+>                 Table -> "table"
+>                 View -> "view"
+>                 Domain -> "domain"
+>                 Type -> "type")
+>     <+> convIfExists ifExists
+>     <+> sepCsvMap text names
+>     <+> convCasc casc
+>     <> statementEnd se
+>
+> convStatement _nice se ca (CreateType ann name atts) =
+>     convPa ca ann <+>
+>     text "create type" <+> text name <+> text "as" <+> lparen
+>     $+$ nest 2 (vcat (csv
+>           (map (\(TypeAttDef _ n t) -> text n <+> convTypeName t)  atts)))
+>     $+$ rparen <> statementEnd se
+>
+> convStatement _nice se ca (CreateLanguage ann name) =
+>     convPa ca ann <+>
+>     text "create language" <+> text name <> statementEnd se
+>
+> convStatement nice se ca (CreateTrigger ann name wh events tbl firing fnName fnArgs) =
+>     convPa ca ann <+>
+>     text "create trigger" <+> text name
+>     <+> text (case wh of
+>                       TriggerBefore -> "before"
+>                       TriggerAfter -> "after")
+>     <+> evs
+>     <+> text "on" <+> text tbl
+>     <+> text "for" <+> text (case firing of
+>                                         EachRow -> "row"
+>                                         EachStatement -> "statement")
+>     <+> text "execute procedure" <+> text fnName
+>     <> parens (sepCsvMap (convExp nice) fnArgs) <> statementEnd se
+>     where
+>       evs = sep $ punctuate (text " or ") $ map
+>             (text . (\e -> case e of
+>                                 TInsert -> "insert"
+>                                 TUpdate -> "update"
+>                                 TDelete -> "delete")) events
+>
+> -- plpgsql
+>
+> convStatement _nice se ca (NullStatement ann) =
+>   convPa ca ann <+> text "null" <> statementEnd se
+> convStatement _nice se ca (ExitStatement ann lb) =
+>   convPa ca ann <+> text "exit"
+>     <+> maybe empty text lb <> statementEnd se
+>
+
+> convStatement _ _se _ca (Into _ann _str _into (QueryStatement _annq _s)) = error "no select into"
+
+> convStatement nice se ca (Into ann str into st) =
+>   convPa ca ann <+>
+>   convStatement nice False ca st
+>   <+> text "into"
+>   <> (if str
+>       then empty <+> text "strict"
+>       else empty)
+>   <+> sepCsvMap (convExp nice) into
+>   <> statementEnd se
+>   --fixme, should be insert,update,delete,execute
+
+> convStatement nice se ca (Assignment ann name val) =
+>     convPa ca ann <+>
+>     convExp nice name <+> text ":=" <+> convExp nice val <> statementEnd se
+>
+> convStatement nice se ca (Return ann ex) =
+>     convPa ca ann <+>
+>     text "return" <+> maybeConv (convExp nice) ex <> statementEnd se
+>
+> convStatement nice se ca (ReturnNext ann ex) =
+>     convPa ca ann <+>
+>     text "return" <+> text "next" <+> convExp nice ex <> statementEnd se
+>
+> convStatement nice se ca (ReturnQuery ann sel) =
+>     convPa ca ann <+>
+>     text "return" <+> text "query"
+>     <+> convQueryExpr nice True True sel <> statementEnd se
+>
+> convStatement nice se ca (Raise ann rt st exps) =
+>     convPa ca ann <+>
+>     text "raise"
+>     <+> case rt of
+>                 RNotice -> text "notice"
+>                 RException -> text "exception"
+>                 RError -> text "error"
+>     <+> convExp nice (StringLit emptyAnnotation st)
+>     <> ifNotEmpty (\e -> comma <+> csvExp nice e) exps
+>     <> statementEnd se
+>
+> convStatement nice se ca (ForQueryStatement ann lb i sel stmts) =
+>     convPa ca ann <+>
+>     convLabel lb <>
+>     text "for" <+> convExp nice i <+> text "in"
+>     <+> convQueryExpr nice True True sel <+> text "loop"
+>     $+$ convNestedStatements nice ca stmts
+>     $+$ text "end loop" <> statementEnd se
+>
+> convStatement nice se ca (ForIntegerStatement ann lb var st en stmts) =
+>     convPa ca ann <+>
+>     convLabel lb <>
+>     text "for" <+> convExp nice var <+> text "in"
+>     <+> convExp nice st <+> text ".." <+> convExp nice en <+> text "loop"
+>     $+$ convNestedStatements nice ca stmts
+>     $+$ text "end loop" <> statementEnd se
+>
+> convStatement nice se ca (WhileStatement ann lb ex stmts) =
+>     convPa ca ann <+>
+>     convLabel lb <>
+>     text "while" <+> convExp nice ex <+> text "loop"
+>     $+$ convNestedStatements nice ca stmts
+>     $+$ text "end loop" <> statementEnd se
+> convStatement nice se ca (LoopStatement ann lb stmts) =
+>     convPa ca ann <+>
+>     convLabel lb <>
+>     text "loop"
+>     $+$ convNestedStatements nice ca stmts
+>     $+$ text "end loop" <> statementEnd se
+>
+> convStatement _nice se ca (ContinueStatement ann lb) =
+>     convPa ca ann <+> text "continue"
+>       <+> maybe empty text lb <> statementEnd se
+> convStatement nice se ca (Perform ann f@(FunCall _ _ _)) =
+>     convPa ca ann <+>
+>     text "perform" <+> convExp nice f <> statementEnd se
+> convStatement _ _ _ (Perform _ x) =
+>    error $ "internal error: convStatement not supported for " ++ show x
+>
+> convStatement _nice se ca (Copy ann tb cols src) =
+>     convPa ca ann <+>
+>     text "copy" <+> text tb
+>     <+> ifNotEmpty (parens . sepCsvMap text) cols
+>     <+> text "from"
+>     <+> case src of
+>                  CopyFilename s -> quotes $ text s <> statementEnd se
+>                  Stdin -> text "stdin" <> text ";"
+>
+> convStatement _ _ ca (CopyData ann s) =
+>     convPa ca ann <+>
+>     text s <> text "\\." <> newline
+>
+> convStatement nice se ca (If ann conds els) =
+>    convPa ca ann <+>
+>    text "if" <+> convCond (head conds)
+>    $+$ vcat (map (\c -> text "elseif" <+> convCond c) $ tail conds)
+>    $+$ ifNotEmpty (\e -> text "else" $+$ convNestedStatements nice ca e) els
+>    $+$ text "end if" <> statementEnd se
+>     where
+>       convCond (ex, sts) = convExp nice ex <+> text "then"
+>                            $+$ convNestedStatements nice ca sts
+> convStatement nice se ca (Execute ann s) =
+>     convPa ca ann <+>
+>     text "execute" <+> convExp nice s <> statementEnd se
+>
+>
+> convStatement nice se ca (CaseStatementSimple ann c conds els) =
+>     convPa ca ann <+>
+>     text "case" <+> convExp nice c
+>     $+$ nest 2 (
+>                 vcat (map (uncurry convWhenSt) conds)
+>                 $+$ convElseSt els
+>                 ) $+$ text "end case" <> statementEnd se
+>     where
+>       convWhenSt ex sts = text "when" <+> sepCsvMap (convExp nice) ex
+>                           <+> text "then" $+$ convNestedStatements nice ca sts
+>       convElseSt = ifNotEmpty (\s -> text "else"
+>                                      $+$ convNestedStatements nice ca s)
+> convStatement nice se ca (CaseStatement ann conds els) =
+>     convPa ca ann <+>
+>     text "case"
+>     $+$ nest 2 (
+>                 vcat (map (uncurry convWhenSt) conds)
+>                 $+$ convElseSt els
+>                 ) $+$ text "end case" <> statementEnd se
+>     where
+>       convWhenSt ex sts = text "when" <+> sepCsvMap (convExp nice) ex
+>                           <+> text "then" $+$ convNestedStatements nice ca sts
+>       convElseSt = ifNotEmpty (\s -> text "else"
+>                                      $+$ convNestedStatements nice ca s)
+
+>
+> -- misc
+>
+> convStatement _nice se _ (Set _ n vs) =
+>   text "set" <+> text n <+> text "="
+>   <+> sepCsvMap (text . dv) vs <> statementEnd se
+>   where
+>     dv (SetStr _ s) = "'" ++ s ++ "'"
+>     dv (SetId _ i) = i
+>     dv (SetNum _ nm) = show nm
+>
+> convStatement _nice se _ (Notify _ n) =
+>   text "notify" <+> text n  <> statementEnd se
+>
+> statementEnd :: Bool -> Doc
+> statementEnd b = if b
+>                  then semi <> newline
+>                  else empty
+
+-------------------------------------------------------------------------------
+
+Statement components
+
+> -- selects
+>
+> convQueryExpr :: Bool -> Bool -> Bool -> QueryExpr -> Doc
+> convQueryExpr nice writeSelect _ (Select _ dis l tb wh grp hav
+>                                 order lim off) =
+>   (text (if writeSelect then "select" else "")
+>          <+> (case dis of
+>                  Dupes -> empty
+>                  Distinct -> text "distinct"))
+>   $+$ nest 2 (vcat $ catMaybes
+>   [Just $ nest 2 $ convSelList nice l
+>   ,Just $ if null tb
+>           then empty
+>           else text "from" $+$ nest 2 (sepCsvMap (convTref nice) tb)
+>   ,Just $ convWhere nice wh
+>   ,case grp of
+>      [] -> Nothing
+>      g -> Just $ text "group by" $+$ nest 2 (sepCsvMap (convExp nice) g)
+>   ,flip fmap hav $ \h -> text "having" $+$ nest 2 (convExp nice h)
+>   ,case order of
+>      [] -> Nothing
+>      o -> Just $ text "order by"
+>                   $+$ nest 2 (sepCsvMap (\(oe,od) -> convExp nice oe
+>                                               <+> convDir od) o)
+>   ,flip fmap lim $ \lm -> text "limit" <+> convExp nice lm
+>   ,flip fmap off $ \offs -> text "offset" <+> convExp nice offs
+>   ])
+>
+> convQueryExpr nice writeSelect topLev (CombineQueryExpr _ tp s1 s2) =
+>   let p = convQueryExpr nice writeSelect False s1
+>           $+$ (case tp of
+>                        Except -> text "except"
+>                        Union -> text "union"
+>                        UnionAll -> text "union" <+> text "all"
+>                        Intersect -> text "intersect")
+>           $+$ convQueryExpr nice True False s2
+>   in if topLev then p else parens p
+> convQueryExpr nice _ _ (Values _ expss) =
+>   text "values" $$ nest 2 (vcat $ csv $ map (parens . csvExp nice) expss)
+> convQueryExpr nice _ _ (WithQueryExpr _ wqs ex) =
+>   text "with" $$ nest 2 (vcat $ csv $ map pwq wqs)
+>        $+$ convQueryExpr nice True False ex
+>   where
+>     pwq (WithQuery _ nm cs ex1) =
+>       text nm <> case cs of
+>                    Nothing -> empty
+>                    Just cs' -> parens $ sepCsvMap text cs'
+>       <+> text "as"
+>       <+> parens (convQueryExpr nice True False ex1)
+>
+> convTref :: Bool -> TableRef -> Doc
+> convTref nice (Tref _ f@(SQIdentifier _ t) (TableAlias _ ta))
+>   | nice, last t == ta = convDqi f
+>   -- slightly bad hack:
+> convTref nice (Tref _ f@(SQIdentifier _ t) (FullAlias _ ta _))
+>   | nice, last t == ta = convDqi f
+
+> convTref nice (Tref _ f a) = convDqi f <+> convTrefAlias nice a
+> convTref nice (JoinTref _ t1 nat jt t2 ex a) =
+>         parens (convTref nice t1
+>         $+$ (case nat of
+>                       Natural -> text "natural"
+>                       Unnatural -> empty)
+>         <+> text (case jt of
+>                           Inner -> "inner"
+>                           Cross -> "cross"
+>                           LeftOuter -> "left outer"
+>                           RightOuter -> "right outer"
+>                           FullOuter -> "full outer")
+>         <+> text "join"
+>         <+> convTref nice t2
+>         <+> maybeConv (nest 2 . convJoinScalarExpr) ex
+>         <+> convTrefAlias nice a)
+>         where
+>           convJoinScalarExpr (JoinOn _ e) = text "on" <+> convExp nice e
+>           convJoinScalarExpr (JoinUsing _ ids) =
+>               text "using" <+> parens (sepCsvMap text ids)
+>
+> convTref nice (SubTref _ sub alias) =
+>         parens (convQueryExpr nice True True sub)
+>         <+> text "as" <+> convTrefAlias nice alias
+> convTref nice (FunTref _ f@(FunCall _ _ _) a) = convExp nice f <+> convTrefAlias nice a
+> convTref _nice (FunTref _ x _) =
+>       error $ "internal error: node not supported in function tref: "
+>             ++ show x
+>
+> convTrefAlias :: Bool -> TableAlias -> Doc
+> convTrefAlias _ (NoAlias _) = empty
+> convTrefAlias _ (TableAlias _ t) = text t
+> -- hack this out for now. When the type checking is fixed, can try
+> -- to eliminate unneeded aliases?
+> convTrefAlias nice (FullAlias _ t s) =
+>   text t <> (if nice
+>              then empty
+>              else parens (sepCsvMap text s))
+
+> convDir :: Direction -> Doc
+> convDir d = text $ case d of
+>                           Asc -> "asc"
+>                           Desc -> "desc"
+>
+> convWhere :: Bool -> Maybe ScalarExpr -> Doc
+> convWhere nice (Just ex) = text "where" $+$ nest 2 (convExp nice ex)
+> convWhere _ Nothing = empty
+>
+> convSelList :: Bool -> SelectList -> Doc
+> convSelList nice (SelectList _ ex) =
+>   sepCsvMap convSelItem ex
+>   -- <+> ifNotEmpty (\i -> text "into" <+> hcatCsvMap convExp i) into
+>   where
+>     -- try to avoid printing alias if not necessary
+>     convSelItem (SelectItem _ ex1@(QIdentifier _ _ i) nm) | nice, i == nm = convExpSl nice ex1
+>     convSelItem (SelectItem _ ex1@(Identifier _ i) nm) | nice, i == nm = convExpSl nice ex1
+>     convSelItem (SelectItem _ ex1 nm) = convExpSl nice ex1 <+> text "as" <+> text nm
+>     convSelItem (SelExp _ e) = convExpSl nice e
+>
+> convCasc :: Cascade -> Doc
+> convCasc casc = text $ case casc of
+>                                  Cascade -> "cascade"
+>                                  Restrict -> "restrict"
+>
+> convDqi :: SQIdentifier -> Doc
+> convDqi (SQIdentifier _ is) = hcat $ punctuate (text ".") $ map text is
+
+> -- ddl
+>
+> convCon :: Bool -> Constraint -> Doc
+> convCon _nice (UniqueConstraint _ n c) =
+>         mname n <+> text "unique"
+>         <+> parens (sepCsvMap text c)
+> convCon _nice (PrimaryKeyConstraint _ n p) =
+>         mname n <+>
+>         text "primary key"
+>         <+> parens (sepCsvMap text p)
+> convCon nice (CheckConstraint _ n c) =
+>         mname n <+> text "check" <+> parens (convExp nice c)
+> convCon _nice (ReferenceConstraint _ n at tb rat ondel onupd) =
+>         mname n <+>
+>         text "foreign key" <+> parens (sepCsvMap text at)
+>         <+> text "references" <+> text tb
+>         <+> ifNotEmpty (parens . sepCsvMap text) rat
+>         <+> text "on update" <+> convCasc onupd
+>         <+> text "on delete" <+> convCasc ondel
+>
+> mname :: String -> Doc
+> mname n = if n == ""
+>           then empty
+>           else text "constraint" <+> text n
+>
+> convReturning :: Bool -> Maybe SelectList -> Doc
+> convReturning nice l = case l of
+>                 Nothing -> empty
+>                 Just ls -> nest 2 (text "returning" <+> convSelList nice ls)
+>
+> convIfExists :: IfExists -> Doc
+> convIfExists i = case i of
+>                         Require -> empty
+>                         IfExists -> text "if exists"
+>
+> -- plpgsql
+>
+> convNestedStatements :: Bool -> (Annotation -> String) -> StatementList -> Doc
+> convNestedStatements nice pa = nest 2 . vcat . map (convStatement nice True pa)
+>
+> convTypeName :: TypeName -> Doc
+> convTypeName (SimpleTypeName _ s) = text s
+> convTypeName (PrecTypeName _ s i) = text s <> parens(integer i)
+> convTypeName (Prec2TypeName _ s i i1) = text s <> parens (sepCsv [integer i, integer i1])
+> convTypeName (ArrayTypeName _ t) = convTypeName t <> text "[]"
+> convTypeName (SetOfTypeName _ t) = text "setof" <+> convTypeName t
+>
+> -- expressions
+>
+> convExp :: Bool -> ScalarExpr -> Doc
+> convExp _ (Identifier _ i) =
+>   if quotesNeeded
+>      then text $ "\"" ++ i ++ "\""
+>      else text i
+>   where
+>     --needs some work - quotes needed if contains invalid unquoted
+>     --chars, or maybe if matches keyword or similar
+>     quotesNeeded = case i of
+>                      x:_ | not (isLetter x || x `elem` "_*") -> True
+>                      _ | all okChar i -> False
+>                        | otherwise -> True
+>                    where
+>                      okChar x =isAlphaNum x || x `elem` "*_."
+> convExp nice (QIdentifier a i1@(Identifier _ _) i) = convExp nice i1 <> text "." <> convExp nice (Identifier a i)
+> convExp nice (QIdentifier a e i) = parens (convExp nice e) <> text "." <> convExp nice (Identifier a i)
+
+> --convExp (PIdentifier _ i) = parens $ convExp i
+> convExp _ (NumberLit _ n) = text n
+> convExp _ (StringLit _ s) = -- needs some thought about using $$?
+>                           text "'" <> text replaceQuotes <> text "'"
+>                           where
+>                             replaceQuotes = replace "'" "''" s {-if tag == "'"
+>                                               then replace "'" "''" s
+>                                               else s-}
+>
+> convExp nice (FunCall _ n es) =
+>     --check for special operators
+>    case n of
+>      "!and" | nice, [a,b] <- es -> doLeftAnds a b
+>      "!arrayctor" -> text "array" <> brackets (csvExp nice es)
+>      "!between" -> convExp nice (head es) <+> text "between"
+>                    <+> parens (convExp nice (es !! 1))
+>                   <+> text "and"
+>                   <+> parens (convExp nice (es !! 2))
+>      "!substring" -> text "substring"
+>                      <> parens (convExp nice (head es)
+>                                 <+> text "from" <+> convExp nice (es !! 1)
+>                                 <+> text "for" <+> convExp nice (es !! 2))
+>      "!arraysub" -> case es of
+>                        (Identifier _ i : es1) -> text i
+>                                                  <> brackets (csvExp nice es1)
+>                        _ -> parens (convExp nice (head es))
+>                             <> brackets (csvExp nice (tail es))
+>      "!rowctor" -> text "row" <> parens (sepCsvMap (convExp nice) es)
+>      "."   -- special case to avoid ws around '.'. Don't know if this is important
+>            -- or just cosmetic
+>          | [a,b] <- es -> convExp nice a <> text "." <> convExp nice b
+>      _ | isOperatorName n ->
+>         case forceRight (getOperatorType defaultTemplate1Catalog n) of
+>                           BinaryOp ->
+>                               let e1d = convExp nice (head es)
+>                                   opd = text $ filterKeyword n
+>                                   e2d = convExp nice (es !! 1)
+>                               in parens (if n `elem` ["!and", "!or"]
+>                                          then vcat [e1d, opd <+> e2d]
+>                                          else e1d <+> opd <+> e2d)
+>                           PrefixOp -> parens (text (if n == "u-"
+>                                                        then "-"
+>                                                        else filterKeyword n)
+>                                                <+> parens (convExp nice (head es)))
+>                           PostfixOp -> parens (convExp nice (head es)
+>                                        <+> text (filterKeyword n))
+>        | otherwise -> text n <> parens (csvExp nice es)
+>    where
+>      filterKeyword t = case t of
+>                          "!and" -> "and"
+>                          "!or" -> "or"
+>                          "!not" -> "not"
+>                          "!isnull" -> "is null"
+>                          "!isnotnull" -> "is not null"
+>                          "!like" -> "like"
+>                          "!notlike" -> "not like"
+>                          x -> x
+>      -- try to write a series of ands in a vertical line with slightly less parens
+>      doLeftAnds a b = let as = and' a
+>                       in vcat ((convExp nice (head as)
+>                                 : map (\x -> text "and" <+> convExp nice x) (tail as))
+>                                ++ [text "and" <+> convExp nice b])
+>      and' a = case a of
+>                 FunCall _ "!and" [x,y] -> and' x ++ and' y
+>                 _ -> [a]
+>
+> convExp _ (BooleanLit _ b) = bool b
+> convExp nice (InPredicate _ att t lst) =
+>   convExp nice att <+> (if not t then text "not" else empty) <+> text "in"
+>   <+> parens (case lst of
+>                        InList _ expr -> csvExp nice expr
+>                        InQueryExpr _ sel -> convQueryExpr nice True True sel)
+> convExp nice (LiftOperator _ op flav args) =
+>   convExp nice (head args) <+> text op
+>   <+> text (case flav of
+>               LiftAny -> "any"
+>               LiftAll -> "all")
+>   <+> parens (convExp nice $ head $ tail args)
+> convExp nice (ScalarSubQuery _ s) = parens (convQueryExpr nice True True s)
+> convExp _ (NullLit _) = text "null"
+> convExp nice (WindowFn _ fn part order asc frm) =
+>   convExp nice fn <+> text "over"
+>   <+> parens (if hp || ho
+>               then (if hp
+>                     then text "partition by" <+> csvExp nice part
+>                     else empty)
+>                     <+> (if ho
+>                          then text "order by" <+> csvExp nice order
+>                               <+> convDir asc
+>                          else empty)
+>                     <+> convFrm
+>               else empty)
+>   where
+>     hp = not (null part)
+>     ho = not (null order)
+>     convFrm = case frm of
+>                 FrameUnboundedPreceding -> text "range unbounded preceding"
+>                 FrameUnboundedFull -> text "range between unbounded \
+>                                            \preceding and unbounded following"
+>                 FrameRowsUnboundedPreceding -> text "rows unbounded preceding"
+>
+> convExp nice (Case _ whens els) =
+>   text "case"
+>   $+$ nest 2 (vcat (map convWhen whens)
+>               $+$ maybeConv (\e -> text "else" <+> convExp nice e) els)
+>   $+$ text "end"
+>       where
+>         convWhen (ex1, ex2) =
+>             text "when" <+> sepCsvMap (convExp nice) ex1
+>             <+> text "then" <+> convExp nice ex2
+>
+> convExp nice (CaseSimple _ val whens els) =
+>   text "case" <+> convExp nice val
+>   $+$ nest 2 (vcat (map convWhen whens)
+>               $+$ maybeConv (\e -> text "else" <+> convExp nice e) els)
+>   $+$ text "end"
+>       where
+>         convWhen (ex1, ex2) =
+>             text "when" <+> sepCsvMap (convExp nice) ex1
+>             <+> text "then" <+> convExp nice ex2
+>
+> convExp _ (PositionalArg _ a) = text "$" <> integer a
+> convExp _ (Placeholder _) = text "?"
+> convExp nice (Exists _ s) =
+>   text "exists" <+> parens (convQueryExpr nice True True s)
+> convExp nice (Cast _ ex t) = text "cast" <> parens (convExp nice ex
+>                                              <+> text "as"
+>                                              <+> convTypeName t)
+> convExp nice (TypedStringLit a t s) =
+>   convTypeName t <+> convExp nice (StringLit a s)
+> convExp nice (Interval a v f p) =
+>   text "interval" <+> convExp nice (StringLit a v)
+>   <+> convIntervalField <+> convPrec
+>   where
+>     convIntervalField =
+>       text $ case f of
+>                     IntervalYear -> "year"
+>                     IntervalMonth -> "month"
+>                     IntervalDay -> "day"
+>                     IntervalHour -> "hour"
+>                     IntervalMinute -> "minute"
+>                     IntervalSecond -> "second"
+>                     IntervalYearToMonth -> "year to month"
+>                     IntervalDayToHour -> "day to hour"
+>                     IntervalDayToMinute -> "day to minute"
+>                     IntervalDayToSecond -> "day to second"
+>                     IntervalHourToMinute -> "hour to minute"
+>                     IntervalHourToSecond -> "hour to second"
+>                     IntervalMinuteToSecond -> "minute to second"
+>     convPrec = case p of
+>                  Nothing -> empty
+>                  Just i -> parens (int i)
+> convExp nice (Extract _ f e) =
+>   text "extract"
+>   <> parens (text convField <+> text "from" <+> convExp nice e)
+>   where
+>     convField =
+>       case f of
+>              ExtractCentury -> "century"
+>              ExtractDay -> "day"
+>              ExtractDecade -> "decade"
+>              ExtractDow -> "dow"
+>              ExtractDoy -> "doy"
+>              ExtractEpoch -> "epoch"
+>              ExtractHour -> "hour"
+>              ExtractIsodow -> "isodow"
+>              ExtractIsoyear -> "isoyear"
+>              ExtractMicroseconds -> "microseconds"
+>              ExtractMillennium -> "millennium"
+>              ExtractMilliseconds -> "milliseconds"
+>              ExtractMinute -> "minute"
+>              ExtractMonth -> "month"
+>              ExtractQuarter -> "quarter"
+>              ExtractSecond -> "second"
+>              ExtractTimezone -> "timezone"
+>              ExtractTimezoneHour -> "timezone_hour"
+>              ExtractTimezoneMinute -> "timezone_minute"
+>              ExtractWeek -> "week"
+>              ExtractYear -> "year"
+
+
+> convExpSl :: Bool ->  ScalarExpr -> Doc
+> convExpSl nice (FunCall _ "." es) | [a@(Identifier _ _), b] <- es =
+>   parens (convExpSl nice a) <> text "." <> convExpSl nice b
+> convExpSl nice x = convExp nice x
+
+>
+> convSet :: Bool -> ScalarExpr -> Doc
+> convSet nice (FunCall _ "=" [Identifier _ a, e]) =
+>   text a <+> text "=" <+> convExp nice e
+> convSet nice (FunCall _ "=" [a, b]) | (FunCall _ "!rowctor" is1) <- a
+>                                 ,(FunCall _ "!rowctor" is2) <- b =
+>   rsNoRow is1 <+> text "=" <+> rsNoRow is2
+>   where
+>     rsNoRow is = parens (sepCsvMap (convExp nice) is)
+> convSet _ a = error $ "bad expression in set in update: " ++ show a
+>
+> --utils
+>
+> -- convert a list of expressions to horizontal csv
+>
+> csvExp :: Bool -> [ScalarExpr] -> Doc
+> csvExp nice = hcatCsvMap (convExp nice)
+>
+> maybeConv :: (t -> Doc) -> Maybe t -> Doc
+> maybeConv f c =
+>     case c of
+>       Nothing -> empty
+>       Just a -> f a
+>
+> csv :: [Doc] -> [Doc]
+> csv = punctuate comma
+>
+> hcatCsv :: [Doc] -> Doc
+> hcatCsv = hcat . csv
+
+> sepCsv :: [Doc] -> Doc
+> sepCsv = sep . csv
+>
+> ifNotEmpty :: ([a] -> Doc) -> [a] -> Doc
+> ifNotEmpty c l = if null l then empty else c l
+>
+> hcatCsvMap :: (a -> Doc) -> [a] -> Doc
+> hcatCsvMap ex = hcatCsv . map ex
+
+> sepCsvMap :: (a -> Doc) -> [a] -> Doc
+> sepCsvMap ex = sepCsv . map ex
+
+
+
+> --vcatCsvMap :: (a -> Doc) -> [a] -> Doc
+> --vcatCsvMap ex = vcat . csv . map ex
+
+>
+> bool :: Bool -> Doc
+> bool b = if b then text "true" else text "false"
+>
+> newline :: Doc
+> newline = text "\n"
+>
+> convPa :: (Annotation -> String) -> Annotation -> Doc
+> convPa ca a = let s = ca a
+>               in if s == ""
+>                    then empty
+>                    else text "/*\n" <+> text s
+>                         <+> text "*/\n"
+
+> convLabel :: Maybe String -> Doc
+> convLabel =
+>   maybe empty (\l -> text "<<"
+>                      <+> text l
+>                      <+> text ">>" <> text "\n")
diff --git a/src/Database/HsSqlPpp/TypeChecker.lhs b/src/Database/HsSqlPpp/TypeChecker.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/TypeChecker.lhs
@@ -0,0 +1,45 @@
+
+This is the public module for the type checking functionality.
+
+> {- | Contains the data types and functions for annotating
+>  an ast and working with annotated trees, including the
+>  representations of SQL data types.
+>
+> Annotations:
+>
+> * 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 'TypeCheckFailed';
+>
+> * each statement has an additional 'StatementInfo' annotation attached to it;
+>
+> * the parser fills in the source position annotation in every
+>   annotatable ast node.
+>
+> -}
+> module Database.HsSqlPpp.TypeChecker
+>     (
+>      -- * typechecking/ annotation functions
+>      typeCheckStatements
+>     ,typeCheckParameterizedStatement
+>     ,typeCheckQueryExpr
+>     ,typeCheckScalarExpr
+>     ,fixUpIdentifiers
+>     ,fixUpIdentifiersQE
+>     ,fixUpIdentifiersSE
+>     ,addExplicitCasts
+>     ,canonicalizeTypeNames
+>      -- * Annotated tree utils
+>     ,getStatementAnnotations
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.AstInternal
+> import Database.HsSqlPpp.AstInternals.TypeChecking.Utils
+> --import Database.HsSqlPpp.AstInternals.AstAnnotation
+> import Database.HsSqlPpp.AstInternals.AnnotationUtils
diff --git a/src/Database/HsSqlPpp/Types.lhs b/src/Database/HsSqlPpp/Types.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Types.lhs
@@ -0,0 +1,25 @@
+
+This is the public module to the SQL data types, mainly from TypeType.
+
+> {- | Contains the SQL data types, type errors, and a few supporting
+>      functions.
+> -}
+>
+> module Database.HsSqlPpp.Types
+>     (
+>      -- * SQL types
+>      Type (..)
+>     ,PseudoType (..)
+>      -- * type aliases
+>      -- | aliases for all the sql types with multiple names
+>      -- these give you the canonical names
+>     ,typeSmallInt,typeBigInt,typeInt,typeNumeric,typeFloat4
+>     ,typeFloat8,typeVarChar,typeChar,typeBool,typeDate
+>     ,typeInterval
+>     ,canonicalizeTypeName
+>     ,canonicalizeTypes
+>      -- * Type errors
+>     ,TypeError (..)
+>     ) where
+>
+> import Database.HsSqlPpp.AstInternals.TypeType
diff --git a/src/Database/HsSqlPpp/Utils/Utils.lhs b/src/Database/HsSqlPpp/Utils/Utils.lhs
new file mode 100644
--- /dev/null
+++ b/src/Database/HsSqlPpp/Utils/Utils.lhs
@@ -0,0 +1,166 @@
+
+This file contains some generic utility stuff
+
+> {-# LANGUAGE FlexibleContexts #-}
+>
+> module Database.HsSqlPpp.Utils.Utils where
+>
+> import Data.List
+> import Data.Either
+> import Data.Char
+> import Control.Arrow
+> import Control.Monad.Error
+> import Control.Applicative
+
+used to mix regular function composition and >>= in monads, so the
+order of application stays the same instead of going backwards when
+(.) is used
+
+> infixl 9 |>
+> (|>) :: (a -> b) -> (b -> c) -> a -> c
+> (|>) = flip (.)
+>
+> errorWhen :: (Error a) => Bool -> a -> Either a ()
+> errorWhen cond = when cond . Left
+>
+> returnWhen :: (Monad m) => Bool -> a -> m a -> m a
+> returnWhen c t t1 = if c then return t else t1
+>
+> liftME :: a -> Maybe b -> Either a b
+> liftME d m = case m of
+>                Nothing -> Left d
+>                Just b -> Right b
+>
+> both :: (a->b) -> (a,a) -> (b,b)
+> both fn = fn *** fn
+>
+> (<:>) :: (Applicative f) =>
+>          f a -> f [a] -> f [a]
+> (<:>) a b = (:) <$> a <*> b
+>
+
+> eitherToMaybe :: Either a b -> Maybe b
+> eitherToMaybe (Left _) = Nothing
+> eitherToMaybe (Right b) = Just b
+>
+> fromRight :: b -> Either a b -> b
+> fromRight b (Left _) = b
+> fromRight _ (Right r) = r
+>
+> fromLeft :: a -> Either a b -> a
+> fromLeft _ (Left l) = l
+> fromLeft a (Right _) = a
+>
+> mapEither :: (a->c) -> (b->d) -> Either a b -> Either c d
+> mapEither l _ (Left a) = Left $ l a
+> mapEither _ r (Right b) = Right $ r b
+>
+> mapRight :: (b -> c) -> Either a b -> Either a c
+> mapRight = mapEither id
+>
+> mapLeft :: (a -> c) -> Either a b -> Either c b
+> mapLeft l = mapEither l id
+>
+> isRight :: Either a b -> Bool
+> isRight (Right _) = True
+> isRight (Left _) = False
+>
+> leftToEmpty :: (r -> [a]) -> Either l r -> [a]
+> leftToEmpty = either (const [])
+>
+> replace :: (Eq a) => [a] -> [a] -> [a] -> [a]
+> replace _ _ [] = []
+> replace old new xs@(y:ys) =
+>   case stripPrefix old xs of
+>     Nothing -> y : replace old new ys
+>     Just ys' -> new ++ replace old new ys'
+>
+> split :: Char -> String -> [String]
+> split _ ""                =  []
+> split c s                 =  let (l, s') = break (== c) s
+>                            in  l : case s' of
+>                                            [] -> []
+>                                            (_:s'') -> split c s''
+>
+> liftThrows :: (MonadError t m) => Either t a -> m a
+> liftThrows (Left err) = throwError err
+> liftThrows (Right val) = return val
+>
+> -- run in errort monad, throw error as io error
+>
+> wrapET :: (Show e, Monad m) => ErrorT e m a -> m a
+> wrapET c = runErrorT c >>= \x ->
+>          case x of
+>            Left er -> error $ show er
+>            Right l -> return l
+>
+> wrapETs :: (Monad m) => ErrorT String m a -> m a
+> wrapETs c = runErrorT c >>= \x ->
+>          case x of
+>            Left er -> error er
+>            Right l -> return l
+>
+> -- error utility - convert either to ErrorT String
+>
+> tsl :: (MonadError String m, Show t) => Either t a -> m a
+> tsl x = case x of
+>                Left s -> throwError $ show s
+>                Right b -> return b
+>
+> listEither :: [Either a b] -> Either [a] [b]
+> listEither es = let (l,r) = partitionEithers es
+>                in if null l
+>                   then Right r
+>                   else Left l
+>
+> forceRight :: Show e => Either e a -> a
+> forceRight (Left x) = error $ show x
+> forceRight (Right x) = x
+>
+>
+> npartition :: Eq b => (a -> b) -> [a] -> [(b,[a])]
+> npartition keyf l =
+>   np [] l
+>   where
+>     np acc =
+>       foldl (\ acc p -> insertWith (++) (keyf p) [p] acc) acc
+>
+> insertWith :: Eq k => (a -> a -> a) -> k -> a -> [(k,a)] -> [(k,a)]
+> insertWith ac k v m =
+>     case lookup k m of
+>       Nothing -> m ++ [(k,v)]
+>       Just v' -> let nv = ac v' v
+>                  in map (\p@(k1,_) -> if k1 == k
+>                                       then (k1,nv)
+>                                       else p) m
+
+
+This should preserve order, so in the result, the keys (k in
+[(k,[a],[b])]) are ordered by their first appearance in as, then bs,
+and the values are ordered the matches in the same order as they
+appear in the two lists ([a] and [b] in [(k,[a],[b])])
+
+> joinLists :: Eq k => (a -> k) -> (b -> k)
+>              -> [a] -> [b] -> [(k,[a],[b])]
+> joinLists ka kb as bs =
+>     let -- arrange the two lists by key
+>         kasps = npartition ka as
+>         kbsps = npartition kb bs
+>         -- get the list of keys
+>         ks = nub $ map fst kasps ++ map fst kbsps
+>         -- put together the two lists by key
+>     in flip map ks $ \k ->
+>         (k, getem k kasps, getem k kbsps)
+>     where
+>       getem :: Eq k => k -> [(k,[a])] -> [a]
+>       getem k = concatMap snd . filter ((==k) . fst)
+
+> trim :: String -> String
+> trim = f . f
+>    where f = reverse . dropWhile isSpace
+
+> concatLefts :: [Either [a] b] -> Either [a] ()
+> concatLefts s = let l = concat $ lefts s
+>                 in if null l
+>                    then Right ()
+>                    else Left l
