hssqlppp-0.5.18: SQL parser and type checker

Safe HaskellNone
LanguageHaskell2010

Database.HsSqlPpp.Ast

Contents

Description

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: https://github.com/JakeWheat/hssqlppp/blob/master/src/Database/HsSqlPpp/Internals/AstInternal.ag

Synopsis

Name and TypeName

Scalar expressions

data Direction

Constructors

Asc 
Desc 

data Distinct

Constructors

Distinct 
All 

Query expressions

makeSelect :: QueryExpr

'default' valued select, use for creating select values

makeSelect :: QueryExpr
makeSelect = Select
             {ann = emptyAnnotation
             ,selDistinct = All
             ,selSelectList = (SelectList emptyAnnotation [])
             ,selTref = []
             ,selWhere = Nothing
             ,selGroupBy = []
             ,selHaving = Nothing
             ,selOrderBy = []
             ,selLimit = Nothing
             ,selOffset = Nothing
             ,selOption = []}

On its own, it isn't valid syntax: to use it you have to replace the select list at minimum

use something like this

s = makeSelect {selSelectList = sl [se $ i "a"]
               ,selTref = [tref "t"]}
    where
        a = emptyAnnotation
        sl = SelectList a
        se = SelExp a
        i = Identifier a
        tref t = Tref a (Name a [Nmc t])

data JoinHint

Constructors

Loop 
Hash 
Merge 

data Natural

Constructors

Natural 
Unnatural 

Statements

data Statement

Constructors

QueryStatement Annotation QueryExpr 
Insert Annotation Name [NameComponent] QueryExpr MaybeSelectList 
Update Annotation Name SetClauseList TableRefList MaybeBoolExpr MaybeSelectList 
Delete Annotation Name TableRefList MaybeBoolExpr MaybeSelectList 
CopyFrom Annotation Name [NameComponent] CopyFromSource [CopyOption] 
CopyData Annotation String 
CopyTo Annotation CopyToSource String [CopyOption] 
Truncate Annotation [Name] RestartIdentity Cascade 
CreateTable Annotation Name AttributeDefList ConstraintList MaybeTablePartitionDef 
AlterTable Annotation Name AlterTableOperation 
AlterDatabase Annotation Name AlterDatabaseOperation 
CreateSequence Annotation Name Integer Integer Integer Integer Integer 
AlterSequence Annotation Name Name 
CreateTableAs Annotation Name QueryExpr 
CreateView Annotation Name MaybeNameComponentList QueryExpr 
AlterView Annotation Name MaybeNameComponentList QueryExpr 
CreateType Annotation Name TypeAttributeDefList 
CreateUser Annotation Name String 
CreateLogin Annotation Name String 
AlterUser Annotation Name String 
AlterLogin Annotation Name String 
CreateFunction Annotation Name ParamDefList TypeName Replace Language FnBody Volatility 
CreateDomain Annotation Name TypeName String MaybeBoolExpr 
CreateLanguage Annotation String 
CreateTrigger Annotation NameComponent TriggerWhen [TriggerEvent] Name TriggerFire Name ScalarExprList 
DropFunction Annotation IfExists NameTypeNameListPairList Cascade 
DropSomething Annotation DropType IfExists [Name] Cascade 
DropTrigger Annotation IfExists NameComponent Name Cascade 
CreateDatabase Annotation Name 
Set Annotation String [SetValue] 
Notify Annotation String 
Into Annotation Bool [Name] Statement 
Assignment Annotation Name ScalarExpr 
Return Annotation MaybeScalarExpr 
ReturnNext Annotation ScalarExpr 
ReturnQuery Annotation QueryExpr 
Raise Annotation RaiseType String ScalarExprList 
NullStatement Annotation 
Perform Annotation ScalarExpr 
Execute Annotation ScalarExpr 
ForQueryStatement Annotation (Maybe String) NameComponent QueryExpr StatementList 
ForIntegerStatement Annotation (Maybe String) NameComponent ScalarExpr ScalarExpr StatementList 
LoopStatement Annotation (Maybe String) StatementList 
WhileStatement Annotation (Maybe String) ScalarExpr StatementList 
ContinueStatement Annotation (Maybe String) 
ExitStatement Annotation (Maybe String) 
CaseStatementSimple Annotation ScalarExpr ScalarExprListStatementListPairList StatementList 
CaseStatement Annotation ScalarExprListStatementListPairList StatementList 
If Annotation ScalarExprStatementListPairList StatementList 
Block Annotation (Maybe String) VarDefList StatementList 
AntiStatement String 
DeclareStatement Annotation [(String, TypeName, Maybe ScalarExpr)] 
ExecStatement Annotation Name ScalarExprList 
CreateIndexTSQL Annotation NameComponent Name [NameComponent] 

dml components

ddl components

data Cascade

Constructors

Cascade 
Restrict 

data IfExists

Constructors

Require 
IfExists 

function ddl components

data Replace

Constructors

Replace 
NoReplace 

data Language

Constructors

Sql 
Plpgsql 

PlPgsql components

utility

misc

type ScalarExprListList = [ScalarExprTransposedList]