// Grammar =
// Node*
// Node =
// name:'ident' '=' Stmt
// Stmt =
// 'ident' // Alphabetic identifier
// | 'token_ident' // Single quoted string
// | '#name' // Identifier node included in AnyName
// | Stmt* // Concatenation
// | Stmt ('|' Stmt)* // Alternation
// | Stmt '?' // Zero or one repetition
// | Stmt '*' // Kleene star
// | '(' Stmt ')' // Grouping
// | label:'ident' ':' Stmt // Labeled rule
NameRef =
'#name'?
PathSegment =
'#name'?
PathSegmentRef =
'#name'?
Path =
qualifier:PathRef?
'.'
segment:PathSegment?
PathRef =
qualifier:PathRef?
'.'
segment:PathSegmentRef?
ParamVariadic =
'variadic'
ParamInOut =
'in' 'out'
| 'inout'
ParamIn =
'in'
ParamOut =
'out'
ParamMode =
ParamVariadic
| ParamInOut
| ParamIn
| ParamOut
ParamDefault =
('default' | '=') Expr
Param =
mode:ParamMode? name:ParamName? Type ParamDefault?
ParamName =
'#name'?
ParamNameRef =
'#name'?
ParamList =
(Param (',' Param)*)?
ArgList =
'(' '*' ')'
| '(' ('distinct' | 'all')? args:(Arg (',' Arg)*)? ')'
CallExpr =
Expr ArgList WithinClause? FilterClause? NullTreatment? OverClause?
| ExtractFn
| GraphTableFn
| JsonExistsFn
| JsonArrayFn
| JsonObjectFn
| JsonObjectAggFn WithinClause? FilterClause? OverClause?
| JsonArrayAggFn WithinClause? FilterClause? OverClause?
| JsonQueryFn
| JsonScalarFn
| JsonSerializeFn
| JsonValueFn
| JsonFn
| SubstringFn
| PositionFn
| OverlayFn
| TrimFn
| XmlRootFn
| XmlSerializeFn
| XmlElementFn
| XmlForestFn
| XmlExistsFn
| XmlParseFn
| XmlPiFn
| SomeFn
| AnyFn
| AllFn
| CollationForFn
| ExistsFn
JsonArrayFn =
'json_array' '('
(
(JsonSelectFormat (',' JsonSelectFormat)*) JsonNullClause?
| (JsonExprFormat (',' JsonExprFormat)*)
)
JsonReturningClause?
')'
JsonScalarFn =
'json_scalar' '(' Expr ')'
JsonFn =
'json' '(' JsonExprFormat JsonKeysUniqueClause? ')'
JsonSelectFormat =
SelectVariant JsonFormatClause?
JsonExprFormat =
Expr JsonFormatClause?
JsonEncoding =
'#ident'?
JsonEncodingClause =
'encoding' JsonEncoding
SomeFn =
'some' '(' SelectVariant | Expr ')'
AnyFn =
'any' '(' SelectVariant | Expr ')'
AllFn =
'all' '(' SelectVariant | Expr ')'
ExtractFn =
'extract' '('
('#ident' | 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | '@string')
'from'
Expr
')'
JsonExistsFn =
'json_exists' '('
Expr
JsonFormatClause?
','
Expr
JsonPassingClause?
JsonOnErrorClause?
')'
JsonObjectFn =
'json_object' '('
(JsonReturningClause
| (JsonKeyValue (',' JsonKeyValue)*)
JsonNullClause?
JsonKeysUniqueClause?
JsonReturningClause?
)
')'
JsonObjectAggFn =
'json_objectagg' '('
JsonKeyValue?
JsonNullClause?
JsonKeysUniqueClause?
JsonReturningClause?
')'
JsonArrayAggFn =
'json_arrayagg' '('
JsonValueExpr
OrderByClause?
JsonNullClause?
JsonReturningClause?
')'
JsonQueryFn =
'json_query' '('
Expr
JsonFormatClause?
','
Expr
JsonPassingClause?
JsonReturningClause?
JsonWrapperBehaviorClause?
JsonQuotesClause?
JsonOnEmptyClause?
JsonOnErrorClause?
')'
XmlTable =
'xmltable'
'('
('xmlnamespaces' XmlNamespaceList ',')?
XmlRowPassingClause
XmlTableColumnList
')'
XmlRowPassingClause =
Expr 'passing' XmlPassingMech? Expr XmlPassingMech?
XmlNamespaceList =
'(' (XmlNamespace (',' XmlNamespace )*) ')'
XmlNamespace =
'default' Expr
| Expr 'as' prefix:XmlNamespacePrefix
XmlNamespacePrefix =
'#name'?
XmlPassingMech =
XmlPassingMechByRef
| XmlPassingMechByValue
XmlPassingMechByRef =
'by' 'ref'
XmlPassingMechByValue =
'by' 'value'
JsonPathName =
'#name'?
JsonPathNameRef =
'#name'?
JsonTable =
'json_table' '('
Expr
JsonFormatClause?
','
Expr
('as' JsonPathName)?
JsonPassingClause?
JsonTableColumnList
JsonTablePlanClause?
JsonOnErrorClause?
')'
JsonTablePlanClause =
'plan' 'default'? '(' JsonTablePlan (',' JsonTablePlan)? ')'
JsonTablePlan =
JsonPathNameRef
| JsonTablePlanChoice
| JsonTablePlanJoin
| ParenJsonTablePlan
JsonTablePlanChoice =
'cross' | 'inner' | 'outer' | 'union'
JsonTablePlanJoin =
lhs:JsonTablePlan ('cross' | 'inner' | 'outer' | 'union') rhs:JsonTablePlan
ParenJsonTablePlan =
'(' JsonTablePlan ')'
JsonSerializeFn =
'json_serialize' '('
Expr
JsonFormatClause?
JsonReturningClause?
')'
JsonValueFn =
'json_value' '('
Expr
JsonFormatClause?
','
Expr
JsonPassingClause?
JsonReturningClause?
JsonOnEmptyClause?
JsonOnErrorClause?
')'
SubstringFn =
'substring' '('
Expr 'for' Expr ('from' Expr)?
| Expr 'from' Expr ('for' Expr)?
| Expr 'similar' Expr
| (Expr (',' Expr)*)
')'
PositionFn =
'position' '(' Expr 'in' Expr ')'
OverlayFn =
'overlay' '('
(
Expr 'placing' Expr 'from' Expr ('for' Expr)?
| (Expr (',' Expr)*)?
)
')'
TrimFn =
'trim' '('
('both' | 'leading' | 'trailing')?
(
'from' (Expr (',' Expr)*)
| Expr 'from' Expr
| (Expr (',' Expr)*)?
)
')'
XmlRootFn =
'xmlroot' '('
Expr ','
('version' 'no' 'value' | 'version' Expr)
(
',' 'standalone' 'yes'
| ',' 'standalone' 'no'
| ',' 'standalone' 'no' 'value'
)?
')'
XmlSerializeFn =
'xmlserialize' '('
('document' | 'content')
Expr
'as'
Type
('no' 'indent' | 'indent')?
')'
XmlElementFn =
'xmlelement' '('
'name'
tag:ElementTag
(
',' 'xmlattributes' '('
ExprAsXmlAttrList
')'
(',' (Expr (',' Expr)*))?
| ',' (Expr (',' Expr)*)
)?
')'
ElementTag =
'#name'?
ExprAsColumnName =
Expr ('as' ColumnName)?
ExprAsColumnNameList =
(ExprAsColumnName (',' ExprAsColumnName)*)
ExprAsElementTag =
Expr ('as' tag:ElementTag)?
ExprAsElementTagList =
(ExprAsElementTag (',' ExprAsElementTag)*)
ExprAsPropertyName =
Expr ('as' PropertyName)?
ExprAsPropertyNameList =
(ExprAsPropertyName (',' ExprAsPropertyName)*)
ExprAsXmlAttr =
Expr ('as' attr:XmlAttr)?
ExprAsXmlAttrList =
(ExprAsXmlAttr (',' ExprAsXmlAttr)*)
XmlAttr =
'#name'?
XmlForestFn =
'xmlforest' '(' ExprAsElementTagList ')'
XmlExistsFn =
'xmlexists' '('
Expr
'passing'
XmlPassingMech?
Expr
XmlPassingMech?
')'
XmlParseFn =
'xmlparse' '('
('document' | 'content')
Expr
(
'preserve' 'whitespace'
| 'strip' 'whitespace'
)
')'
XmlPiFn =
'xmlpi' '('
'name'
target:XmlPiTarget
(',' Expr)?
')'
XmlPiTarget =
'#name'?
CollationForFn =
'collation' 'for' '(' Expr ')'
ExistsFn =
'exists' '(' SelectVariant ')'
CastExpr =
('cast' | 'treat') '(' Expr 'as' Type ')'
| Expr ColonColon Type
| Type Literal
ArrayExpr =
'array' '[' (Expr (',' Expr)*) ']'
| 'array' '(' Select ')'
Literal =
value:(
'@string'
| '@null'
| '@numeric_number'
| '@int_number'
| '@byte_string'
| '@bit_string'
| '@dollar_quoted_string'
| '@unicode_esc_string'
| '@esc_string'
| '@national_string'
| '@positional_param'
| 'default'
| 'false'
| 'true'
)
NamedArg =
name:ParamNameRef (FatArrow | ColonEq) Expr
JsonFormatClause =
'format' 'json' JsonEncodingClause?
JsonValueExpr =
Expr JsonFormatClause?
JsonKeyValue =
Expr (':' | 'value') JsonValueExpr
Gteq =
'>' '='
FatArrow =
'=' '>'
Neqb =
'<' '>'
Lteq =
'<' '='
NotLike =
'not' 'like'
NotIlike =
'not' 'ilike'
CustomOp =
'+' | '-' | '*' | '/' | '<' | '>' | '=' | '~' | '!' | '@' | '#' | '%' | '^' | '&' | '|' | '`' | '?'
NotIn =
'not' 'in'
IsDistinctFrom =
'is' 'distinct' 'from'
IsNotDistinctFrom =
'is' 'not' 'distinct' 'from'
UnicodeNormalForm =
'nfc'
| 'nfd'
| 'nfkc'
| 'nfkd'
IsNormalized =
'is' UnicodeNormalForm? 'normalized'
IsNotNormalized =
'is' UnicodeNormalForm? 'not' 'normalized'
OperatorCall =
'operator' '(' (PathRef '.')? Op ')'
ColonEq =
':' '='
ColonColon =
':' ':'
Neq =
'!' '='
SimilarTo =
'similar' 'to'
NotSimilarTo =
'not' 'similar' 'to'
AtTimeZone =
'at' 'time' 'zone'
AtLocal =
'at' 'local'
IsNot =
'is' 'not'
Op =
PathRef?
(
'or'
| '-'
| ':'
| '/'
| '%'
| '^'
| '+'
| '<'
| '='
| '>'
| 'and'
| 'escape'
| 'ilike'
| 'in'
| 'is'
| 'isnull'
| 'notnull'
| 'like'
| 'overlaps'
| 'value'
| AtLocal
| AtTimeZone
| ColonColon
| ColonEq
| CustomOp
| FatArrow
| Gteq
| IsDistinctFrom
| IsJson
| IsJsonArray
| IsJsonObject
| IsJsonScalar
| IsJsonValue
| IsNormalized
| IsNot
| IsNotDistinctFrom
| IsNotJson
| IsNotJsonArray
| IsNotJsonObject
| IsNotJsonScalar
| IsNotJsonValue
| IsNotNormalized
| Lteq
| Neq
| Neqb
| NotIlike
| NotIn
| NotLike
| NotSimilarTo
| OperatorCall
| SimilarTo
)
IsJson =
'is' 'json' JsonKeysUniqueClause?
IsNotJson =
'is' 'not' 'json' JsonKeysUniqueClause?
IsNotJsonValue =
'is' 'not' 'json' 'value' JsonKeysUniqueClause?
IsNotJsonObject =
'is' 'not' 'json' 'object' JsonKeysUniqueClause?
IsNotJsonArray =
'is' 'not' 'json' 'array' JsonKeysUniqueClause?
IsNotJsonScalar =
'is' 'not' 'json' 'scalar' JsonKeysUniqueClause?
IsJsonValue =
'is' 'json' 'value' JsonKeysUniqueClause?
IsJsonObject =
'is' 'json' 'object' JsonKeysUniqueClause?
IsJsonArray =
'is' 'json' 'array' JsonKeysUniqueClause?
IsJsonScalar =
'is' 'json' 'scalar' JsonKeysUniqueClause?
BinExpr =
lhs:Expr op:Op rhs:Expr
WhenClauseList =
WhenClause WhenClause*
CaseExpr =
'case' Expr? WhenClauseList ElseClause? 'end'
FieldExpr =
// We manually implement these as we have NameRef as a variant of Expr.
// Rust analyzer avoids this by having a PathExpr instead that wraps NameRef.
base:Expr '.' (field:NameRef | '*')
Expr =
CallExpr
| CastExpr
| Collate
| ArrayExpr
| Literal
| NameRef
| BinExpr
| CaseExpr
| FieldExpr
| IndexExpr
| SliceExpr
| BetweenExpr
| ParenExpr
| TupleExpr
| PrefixExpr
| PostfixExpr
ArrayType =
// int array[]
// text[]
// t[10][10]
Type 'array'? '[' Expr? ']'
PercentType =
'setof'? PathRef PercentTypeClause
PathType =
'setof'? PathRef ArgList?
CharType =
'setof'?
('varchar' | 'national'? ( 'character' | 'char' | 'nchar' ) 'varying'? )
ArgList?
BitType =
'setof'? 'bit' 'varying'? ArgList?
DoubleType =
'setof'? 'double' 'precision'
Timezone =
WithTimezone
| WithoutTimezone
TimeType =
'setof'?
('time' | 'timestamp')
('(' Literal ')')?
Timezone?
IntervalType =
'setof'?
'interval'
(
'year'
| 'month'
| 'day'
| 'hour'
| 'minute'
| 'second'
| 'year' 'to' 'month'
| 'day' 'to' 'hour'
| 'day' 'to' 'minute'
| 'day' 'to' 'second'
| 'hour' 'to' 'minute'
| 'hour' 'to' 'second'
| 'minute' 'to' 'second'
)?
('(' Literal ')')?
Type =
ArrayType
| PercentType
| PathType
// TODO: I think we can probably simplify the AST nodes for Types & Exprs.
| ExprType
| CharType
| BitType
| DoubleType
| TimeType
| IntervalType
TypeName =
Path
TypeNameRef =
PathRef
Arg =
'variadic'?
(Expr | NamedArg) OrderByClause?
// For when we're parsing expressions and then later we realize they're types.
// e.g., `select pg_catalog.varchar(10) 'foo'`
ExprType =
// TODO: really just FIELD_EXPR, CALL_EXPR, INDEX_EXPR
Expr
EventTrigger =
'#name'?
EventTriggerEvent =
'#ident'?
EventTriggerFilterVariable =
'#ident'?
EventTriggerRef =
'#name'?
Extension =
'#name'?
ExtensionRef =
'#name'?
ForeignDataWrapper =
'#name'?
ForeignDataWrapperRef =
'#name'?
FunctionName =
Path
FunctionNameRef =
PathRef
ProcedureName =
Path
ProcedureNameRef =
PathRef
RoutineName =
Path
RoutineNameRef =
PathRef
Language =
'#name'?
LanguageRef =
'#name'?
Publication =
'#name'?
PublicationRef =
'#name'?
RoleRef =
'group'? '#name'?
| 'current_role'
| 'current_user'
| 'session_user'
Role =
'group'? '#name'?
| 'current_role'
| 'current_user'
| 'session_user'
Schema =
'#name'?
SchemaRef =
'#name'?
Server =
'#name'?
ServerRef =
'#name'?
Subscription =
'#name'?
SubscriptionRef =
'#name'?
RelationNameRef =
PathRef
RemoteTableNameRef =
'#name'?
TableName =
Path
TableNameRef =
PathRef
TableNameRefList =
'(' (TableNameRef (',' TableNameRef)*) ')'
Tablespace =
'#name'?
TablespaceRef =
'#name'?
Sequence =
Path
SequenceRef =
PathRef
Statistics =
Path
StatisticsKind =
'#ident'?
StatisticsRef =
PathRef
PropertyGraph =
Path
PropertyGraphRef =
PathRef
TextSearchConfiguration =
Path
TextSearchConfigurationRef =
PathRef
TextSearchDictionary =
Path
TextSearchDictionaryRef =
PathRef
TextSearchParser =
Path
TextSearchParserRef =
PathRef
TextSearchTemplate =
Path
TextSearchTemplateRef =
PathRef
TextSearchTokenKind =
'#ident'?
RoleRefList =
RoleRef (',' RoleRef)*
ConstraintNameClause =
'constraint' ConstraintName
ConstraintName =
'#name'?
ConstraintNameRef =
PathRef
CheckConstraint =
ConstraintNameClause?
'check' '(' Expr ')'
NoInherit?
UsingIndex =
'using' 'index' IndexRef
WithOptions =
'with' 'options'
Storage =
'storage' StorageMode
StorageMode =
'default' | 'external' | '#ident'?
CompressionMethod =
'compression' CompressionMethodName
CompressionMethodName =
'default' | '#ident'?
ColumnName =
'#name'?
ColumnNameRef =
'#name'?
QualifiedColumnNameRef =
PathRef
Column =
name:ColumnName
WithOptions?
Type?
Storage?
CompressionMethod?
Collate?
constraints:ColumnConstraint*
DeferrableConstraintOption? NotDeferrableConstraintOption?
InitiallyDeferredConstraintOption? InitiallyImmediateConstraintOption?
NotEnforced? Enforced?
// Used by Insert / Update
ColumnTarget =
name:ColumnNameRef Accessor*
ColumnTargetList =
'(' (ColumnTarget (',' ColumnTarget)*) ')'
Accessor =
FieldAccessor
| IndexAccessor
| SliceAccessor
FieldAccessor =
'.' (CompositeFieldRef | '*')
CompositeField =
'#name'?
CompositeFieldRef =
'#name'?
IndexAccessor =
'[' index:Expr ']'
SliceAccessor =
'[' start:Expr? ':' end:Expr? ']'
ColumnConstraint =
CheckConstraint
| DefaultConstraint
| ExcludeConstraint
| GeneratedConstraint
| NotNullConstraint
| NullConstraint
| PrimaryKeyConstraint
| ReferencesConstraint
| UniqueConstraint
NullsDistinct =
'nulls' 'distinct'
NullsNotDistinct =
'nulls' 'not' 'distinct'
UniqueConstraint =
ConstraintNameClause?
'unique'
(UsingIndex | IndexParameters)
PrimaryKeyConstraint =
ConstraintNameClause?
'primary' 'key'
(UsingIndex | IndexParameters)
IndexParameters =
(NullsNotDistinct | NullsDistinct)?
column_list:ConstraintColumnRefList?
ConstraintIncludeClause?
WithParams?
ConstraintIndexTablespace?
SetNullColumns =
'set' 'null' ColumnRefList?
SetDefaultColumns =
'set' 'default' ColumnRefList?
Cascade =
'cascade'
Restrict =
'restrict'
NoAction =
'no' 'action'
RefAction =
NoAction
| Restrict
| Cascade
| SetNullColumns
| SetDefaultColumns
OnDeleteAction =
'on' 'delete' RefAction
OnUpdateAction =
'on' 'update' RefAction
MatchFull =
'match' 'full'
MatchPartial =
'match' 'partial'
MatchSimple =
'match' 'simple'
MatchType =
MatchFull
| MatchPartial
| MatchSimple
ForeignKeyConstraint =
ConstraintNameClause?
'foreign' 'key' from_columns:ForeignKeyColumnList 'references' TableNameRef to_columns:ForeignKeyColumnList?
MatchType?
OnDeleteAction?
OnUpdateAction?
DeferrableConstraintOption =
'deferrable'
NotDeferrableConstraintOption =
'not' 'deferrable'
InitiallyImmediateConstraintOption =
'initially' 'immediate'
InitiallyDeferredConstraintOption =
'initially' 'deferred'
NotEnforced =
'not' 'enforced'
Enforced =
'enforced'
NotNullConstraint =
ConstraintNameClause?
'not' 'null'
ColumnNameRef?
NoInherit?
NullConstraint =
ConstraintNameClause?
'null'
DefaultConstraint =
ConstraintNameClause?
'default' Expr
GeneratedConstraint =
ConstraintNameClause?
'generated'
(GeneratedIdentity | GeneratedStored)
GeneratedIdentity =
('always' | 'by' 'default') 'as' 'identity' SequenceOptionList?
GeneratedStored =
('always' | 'by' 'default') 'as' '(' Expr ')' ('stored' | 'virtual')?
ReferencesConstraint =
ConstraintNameClause?
'references' table:TableNameRef ('(' column:ColumnNameRef ')')?
MatchType?
OnDeleteAction?
OnUpdateAction?
AlterTableAction =
ValidateConstraint
| ReplicaIdentity
| OfType
| NotOf
| ForceRls
| NoForceRls
| InheritTable
| NoInheritTable
| EnableTrigger
| EnableReplicaTrigger
| EnableReplicaRule
| EnableAlwaysTrigger
| EnableAlwaysRule
| EnableRule
| EnableRls
| DisableTrigger
| DisableRls
| DisableRule
| ClusterOn
| OwnerTo
| DetachPartition
| MergePartitions
| SplitPartition
| DropConstraint
| DropColumn
| AddConstraint
| AddColumn
| AttachPartition
| SetSchema
| SetTablespace
| SetWithoutCluster
| SetWithoutOids
| SetAccessMethod
| SetLogged
| SetUnlogged
| SetOptions
| ResetOptions
| TableRenameTo
| RenameConstraint
| RenameColumn
| AlterConstraint
| AlterColumn
| OptionItemList
OptionItemList =
'(' (OptionItem (',' OptionItem)*) ')'
OptionItem =
('default' | Expr)
RelationName =
'only' ( '(' RelationNameRef ')' | RelationNameRef )
| RelationNameRef '*'
RelationList =
RelationName (',' RelationName)*
TableRelationName =
'only' ( '(' TableNameRef ')' | TableNameRef )
| TableNameRef '*'
TableList =
TableRelationName (',' TableRelationName)*
Truncate =
'truncate' 'table'? TableList
('restart' 'identity' | 'continue' 'identity')?
('cascade' | 'restrict')? ';'?
EmptyStmt =
';'
LikeOption =
ExcludingProperty
| IncludingProperty
ExcludingProperty =
'excluding' TableProperty
IncludingProperty =
'including' TableProperty
TableProperty =
PropertyAll
| PropertyComments
| PropertyCompression
| PropertyConstraints
| PropertyDefaults
| PropertyGenerated
| PropertyIdentity
| PropertyIndexes
| PropertyStatistics
| PropertyStorage
PropertyAll =
'all'
PropertyComments =
'comments'
PropertyCompression =
'compression'
PropertyConstraints =
'constraints'
PropertyDefaults =
'defaults'
PropertyGenerated =
'generated'
PropertyIdentity =
'identity'
PropertyIndexes =
'indexes'
PropertyStatistics =
'statistics'
PropertyStorage =
'storage'
LikeClause =
'like' RelationNameRef LikeOption*
WhereClause =
'where' Expr
GroupByClause =
'group' 'by' ('all' | 'distinct')? GroupByList
GroupByList =
GroupBy (',' GroupBy)*
GroupBy =
GroupingExpr
| GroupingRollup
| GroupingCube
| GroupingSets
GroupingRollup =
'rollup' '(' (Expr (',' Expr)*)? ')'
GroupingSets =
'grouping' 'sets' '(' (GroupBy (',' GroupBy)*)? ')'
GroupingCube =
'cube' '(' (Expr (',' Expr)*)? ')'
GroupingExpr =
Expr
HavingClause =
'having' Expr
WindowDef =
Window 'as' '(' WindowSpec ')'
WindowClause =
'window' (WindowDef (',' WindowDef)*)
LimitClause =
'limit' ('all' | Expr)
FetchClause =
'fetch'
('first' | 'next')
Expr?
('row' | 'rows')
('only' | 'with' 'ties')
OffsetClause =
'offset'
Expr
('row' | 'rows')?
DistinctClause =
'distinct' ('on' '(' (Expr (',' Expr)*) ')')?
Target =
'*'
| Expr AsName?
AsName =
'as'? name:ColumnName
TargetList =
Target (',' Target)*
TableConstraint =
PrimaryKeyConstraint
| UniqueConstraint
| CheckConstraint
| ExcludeConstraint
| ForeignKeyConstraint
TableArg =
Column
| LikeClause
| TableConstraint
TableArgList =
'(' args:((TableArg (',' TableArg)*)?) ')'
WhenClause =
'when' condition:Expr 'then' then:Expr
ElseClause =
'else' Expr
UsingClause =
'using' (FromItem (',' FromItem)*)
UsingOnClause =
'using' FromItem
OnClause
TableAlias =
'#name'?
FromAlias =
'as'? name:TableAlias column_list:AliasColumnList?
OptionalAsAlias =
'as'? name:TableAlias
RequiredAsAlias =
'as' name:TableAlias
SequenceOptionList =
'(' (SequenceOption (',' SequenceOption)*) ')'
SequenceOption =
OptionAsType
| OptionCache
| OptionIncrement
| OptionSequenceName
| OptionRestart
| OptionLogged
| OptionUnlogged
| OptionStart
| OptionOwnedBy
| OptionMaxValue
| OptionMinValue
| OptionNoMaxValue
| OptionNoMinValue
| OptionNoCycle
| OptionCycle
OptionAsType =
'as' Type
OptionCache =
'cache' Literal
OptionIncrement =
'increment' 'by'? Literal
OptionSequenceName =
'sequence' 'name' Sequence
OptionRestart =
'restart' ('with'? Literal)?
OptionLogged =
'logged'
OptionUnlogged =
'unlogged'
OptionStart =
'start' 'with'? Literal
OptionOwnedBy =
'owned' 'by' ('none' | name:QualifiedColumnNameRef)
OptionMaxValue =
'maxvalue' Literal
OptionMinValue =
'minvalue' Literal
OptionNoMaxValue =
'no' 'maxvalue'
OptionNoMinValue =
'no' 'minvalue'
OptionNoCycle =
'no' 'cycle'
OptionCycle =
'cycle'
ColumnList =
'(' (ColumnName (',' ColumnName)*) ')'
AliasColumnList =
'(' (AliasColumn (',' AliasColumn)*) ')'
AliasColumn =
name:ColumnName Type? Collate?
ColumnRefList =
'(' (ColumnNameRef (',' ColumnNameRef)*) ')'
ConstraintColumnRefList =
'(' (ColumnNameRef (',' ColumnNameRef)*) WithoutOverlaps? ')'
ForeignKeyColumnList =
'(' (ColumnNameRef (',' ColumnNameRef)*) PeriodColumn? ')'
PeriodColumn =
'period' name:ColumnNameRef
WithoutOverlaps =
'without' 'overlaps'
ConstraintIncludeClause =
'include' ColumnRefList
IndexIncludeClause =
'include' PartitionItemList
WithParams =
'with' AttributeList
ConstraintIndexTablespace =
'using' 'index' 'tablespace' TablespaceRef
JoinInner =
'inner'? 'join'
JoinLeft =
'left' 'outer'? 'join'
JoinRight =
'right' 'outer'? 'join'
JoinFull =
'full' 'outer'? 'join'
JoinCross =
'cross' 'join'
JoinType =
JoinInner
| JoinLeft
| JoinRight
| JoinFull
| JoinCross
OnClause =
'on' Expr
JoinUsingClause =
'using' ColumnRefList alias:RequiredAsAlias?
Join =
'natural'? JoinType FromItem (using_clause:JoinUsingClause | OnClause)?
JoinExpr =
(FromItem | JoinExpr) Join
ParenSelect =
WithClause?
'('
select:SelectVariant
')' ';'?
Select =
WithClause?
SelectClause
FromClause?
WhereClause?
GroupByClause?
HavingClause?
WindowClause?
OrderByClause?
LockingClause*
LimitClause?
FetchClause?
OffsetClause?
FilterClause? ';'?
Serializable =
'isolation' 'level' 'serializable'
RepeatableRead =
'isolation' 'level' 'repeatable' 'read'
ReadCommitted =
'isolation' 'level' 'read' 'committed'
ReadUncommitted =
'isolation' 'level' 'read' 'uncommitted'
ReadWrite =
'read' 'write'
ReadOnly =
'read' 'only'
Deferrable =
'deferrable'
NotDeferrable =
'not' 'deferrable'
TransactionMode =
Serializable
| RepeatableRead
| ReadCommitted
| ReadUncommitted
| ReadWrite
| ReadOnly
| Deferrable
| NotDeferrable
TransactionModeList =
TransactionMode (',' TransactionMode)*
Begin =
('begin' ('work' | 'transaction')? | 'start' 'transaction')
TransactionModeList? ';'?
Commit =
(
'commit' ('prepared' Literal | ('work' | 'transaction')? ('and' 'no'? 'chain')?)
| 'end' ('work' | 'transaction')? ('and' 'no'? 'chain')?
) ';'?
Rollback =
'rollback' ('work' | 'transaction')? ('and' 'no'? 'chain')? ';'?
| 'abort' ('work' | 'transaction')? ('and' 'no'? 'chain')? ';'?
| 'rollback' ('work' | 'transaction')? 'to' 'savepoint'? SavepointRef ';'?
| 'rollback' 'prepared' Literal ';'?
CreateAggregate =
'create' OrReplace? 'aggregate' AggregateName ParamList? AttributeList ';'?
IfExists =
'if' 'exists'
DropType =
'drop' 'type' IfExists? (TypeNameRef (',' TypeNameRef)*)
('cascade' | 'restrict')? ';'?
DropIndex =
'drop' 'index' 'concurrently'? IfExists? (IndexRef (',' IndexRef)*)
('cascade' | 'restrict')? ';'?
DropTable =
'drop' 'table' IfExists? (TableNameRef (',' TableNameRef)*)
('cascade' | 'restrict')? ';'?
DropDatabase =
'drop' 'database' IfExists? DatabaseRef ';'?
IfNotExists =
'if' 'not' 'exists'
PartitionOf =
'partition' 'of' TableNameRef
PreserveRows =
'preserve' 'rows'
DeleteRows =
'delete' 'rows'
Drop =
'drop'
OnCommitAction =
PreserveRows
| DeleteRows
| Drop
OnCommit =
'on' 'commit' OnCommitAction
Inherits =
'inherits' '(' (TableNameRef (',' TableNameRef)*) ')'
TablespaceClause =
'tablespace' TablespaceRef
WithoutOids =
'without' 'oids'
UsingMethod =
'using' AccessMethodRef
AccessMethod =
'#name'?
AccessMethodRef =
'#name'?
Index =
Path
IndexRef =
PathRef
Policy =
'#name'?
PolicyRef =
'#name'?
Rule =
'#name'?
RuleRef =
'#name'?
Trigger =
'#name'?
TriggerRef =
'#name'?
View =
Path
ViewRef =
PathRef
Collation =
Path
CollationRef =
PathRef
Conversion =
Path
ConversionRef =
PathRef
Channel =
'#name'?
ChannelRef =
'#name'?
Cursor =
'#name'?
CursorRef =
'#name'?
PreparedStatement =
'#name'?
PreparedStatementRef =
'#name'?
Savepoint =
'#name'?
SavepointRef =
'#name'?
Window =
'#name'?
WindowRef =
'#name'?
PartitionBy =
'partition' 'by' PartitionStrategy PartitionItemList
PartitionStrategy =
'range'
| '#ident' // list | hash
CreateTable =
'create'
Persistence?
'table' IfNotExists? TableName
PartitionOf?
OfType?
TableArgList?
PartitionType?
Inherits?
PartitionBy?
UsingMethod?
(WithParams | WithoutOids)?
OnCommit?
TablespaceClause? ';'?
CreateIndex =
'create' 'unique'? 'index' 'concurrently'? (IfNotExists? Index)? 'on' TableRelationName
UsingMethod?
PartitionItemList
IndexIncludeClause?
(NullsNotDistinct | NullsDistinct)?
WithParams?
TablespaceClause?
WhereClause? ';'?
OrReplace =
'or' 'replace'
RetType =
'returns' ('table' TableArgList | Type)
BeginFuncOptionList =
'begin' 'atomic'
BeginFuncOption*
'end'
BeginFuncOption =
Stmt
| ReturnFuncOption
ReturnFuncOption =
'return' Expr ';'
FuncOptionList =
options:(FuncOption*)
FuncOption =
BeginFuncOptionList
| ReturnFuncOption
| AsFuncOption
| SetFuncOption
| SupportFuncOption
| RowsFuncOption
| CostFuncOption
| ParallelFuncOption
| SecurityFuncOption
| CalledOnNullInputFuncOption
| ReturnsNullOnNullInputFuncOption
| StrictFuncOption
| LeakproofFuncOption
| NotLeakproofFuncOption
| ResetFuncOption
| VolatilityFuncOption
| WindowFuncOption
| TransformFuncOption
| LanguageFuncOption
CreateFunction =
'create' OrReplace? 'function' name:FunctionName ParamList RetType? option_list:FuncOptionList ';'?
SetDefault =
'set' 'default' Expr
DropDefault =
'drop' 'default'
SetNotNull =
'set' 'not' 'null'
DropNotNull =
'drop' 'not' 'null'
NotValid =
'not' 'valid'
Constraint =
DefaultConstraint
| GeneratedConstraint
| ReferencesConstraint
| PrimaryKeyConstraint
| ForeignKeyConstraint
| UniqueConstraint
| CheckConstraint
| NullConstraint
| NotNullConstraint
AddConstraint =
'add' Constraint
DeferrableConstraintOption?
NotDeferrableConstraintOption?
InitiallyDeferredConstraintOption?
InitiallyImmediateConstraintOption?
NotValid?
NoInherit?
NotEnforced?
Enforced?
DropConstraint =
'drop' 'constraint' IfExists? ConstraintNameRef ('restrict' | 'cascade')?
RenameConstraint =
'rename' 'constraint' ConstraintNameRef 'to' ConstraintName
ValidateConstraint =
'validate' 'constraint' ConstraintNameRef
OwnerTo =
'owner' 'to' RoleRef
AggregateRenameTo =
'rename' 'to' AggregateName
CollationRenameTo =
'rename' 'to' Collation
ConversionRenameTo =
'rename' 'to' Conversion
DatabaseRenameTo =
'rename' 'to' Database
DomainRenameTo =
'rename' 'to' Domain
EventTriggerRenameTo =
'rename' 'to' EventTrigger
ForeignDataWrapperRenameTo =
'rename' 'to' ForeignDataWrapper
FunctionRenameTo =
'rename' 'to' FunctionName
IndexRenameTo =
'rename' 'to' Index
LanguageRenameTo =
'rename' 'to' Language
OpClassRenameTo =
'rename' 'to' OpClassName
OpFamilyRenameTo =
'rename' 'to' OpFamilyName
PolicyRenameTo =
'rename' 'to' Policy
ProcedureRenameTo =
'rename' 'to' ProcedureName
PropertyGraphRenameTo =
'rename' 'to' PropertyGraph
PublicationRenameTo =
'rename' 'to' Publication
RoleRenameTo =
'rename' 'to' Role
RoutineRenameTo =
'rename' 'to' RoutineName
RuleRenameTo =
'rename' 'to' Rule
SchemaRenameTo =
'rename' 'to' Schema
SequenceRenameTo =
'rename' 'to' Sequence
ServerRenameTo =
'rename' 'to' Server
StatisticsRenameTo =
'rename' 'to' Statistics
SubscriptionRenameTo =
'rename' 'to' Subscription
TableRenameTo =
'rename' 'to' TableName
TablespaceRenameTo =
'rename' 'to' Tablespace
TextSearchConfigurationRenameTo =
'rename' 'to' TextSearchConfiguration
TextSearchDictionaryRenameTo =
'rename' 'to' TextSearchDictionary
TextSearchParserRenameTo =
'rename' 'to' TextSearchParser
TextSearchTemplateRenameTo =
'rename' 'to' TextSearchTemplate
TriggerRenameTo =
'rename' 'to' Trigger
TypeRenameTo =
'rename' 'to' TypeName
ViewRenameTo =
'rename' 'to' View
SetSchema =
'set' 'schema' SchemaRef
AlterDomainAction =
SetDefault
| DropDefault
| SetNotNull
| DropNotNull
| AddConstraint
| DropConstraint
| RenameConstraint
| ValidateConstraint
| OwnerTo
| DomainRenameTo
| SetSchema
AlterDomain =
'alter' 'domain' DomainRef action:AlterDomainAction ';'?
AlterTable =
'alter' 'table'
(
AllInTablespace
| IfExists? TableRelationName actions:AlterTableAction*
) ';'?
AllInTablespace =
'all' 'in' 'tablespace' TablespaceRef OwnedByRoles? SetTablespace 'nowait'?
Revoke =
'revoke' (('admin' | 'inherit' | 'grant' | 'set') 'option' 'for')?
Privileges
('on' PrivilegeObjects)?
'from' RoleRefList
('granted' 'by' RoleRef)?
('cascade' | 'restrict')? ';'?
Row =
(Expr (',' Expr)*)
RowList =
(Row (',' Row)*)
Values =
WithClause?
'values' RowList
OrderByClause?
LimitClause?
OffsetClause?
FetchClause? ';'?
Table =
WithClause?
'table' RelationName
OrderByClause?
LockingClause*
LimitClause?
FetchClause?
OffsetClause? ';'?
Insert =
WithClause?
'insert' 'into' RelationNameRef alias:RequiredAsAlias? ColumnTargetList?
('overriding' ('system' | 'user') 'value')?
('default' 'values' | SelectVariant)
OnConflictClause?
ReturningClause? ';'?
OnConflictClause =
'on' 'conflict' ConflictTarget? ConflictAction
ConflictTarget =
ConflictOnConstraint
| ConflictOnIndex
ConflictOnIndex =
ConflictIndexItemList WhereClause?
ConflictOnConstraint =
'on' 'constraint' ConstraintNameRef
ConflictIndexItemList =
'(' (ConflictIndexItem (',' ConflictIndexItem)*) ')'
ConflictIndexItem =
Expr Collate? OpClassRef?
ConflictAction =
ConflictDoNothing
| ConflictDoUpdateSet
| ConflictDoSelect
ConflictDoUpdateSet =
'do' 'update' SetClause WhereClause?
ConflictDoNothing =
'do' 'nothing'
ConflictDoSelect =
'do' 'select' LockingClause? WhereClause?
SetClause =
'set' SetColumnList
SetColumnList =
(SetColumn (',' SetColumn)*)
SetColumn =
SetSingleColumn
| SetMultipleColumns
SetSingleColumn =
ColumnTarget
'='
SetExpr
SetMultipleColumns =
ColumnTargetList
'='
(SetExprList | ParenSelect)
SetExprList =
'row'? '(' (SetExpr (',' SetExpr)*) ')'
SetExpr =
Expr
| 'default'
Update =
WithClause?
'update'
RelationName
ForPortionOf?
alias:OptionalAsAlias?
SetClause
FromClause?
(WhereClause | WhereCurrentOf)?
ReturningClause? ';'?
ForPortionOf =
'for' 'portion' 'of' ColumnNameRef
('from' Expr 'to' Expr | '(' Expr ')')
ReturningClause =
'returning'
ReturningOptionList?
TargetList
ReturningOptionList =
('with' '(' (ReturningOption (',' ReturningOption)*) ')' )
ReturningOption =
('old' | 'new')
'as'
name:TableAlias
Delete =
WithClause?
'delete' 'from' RelationName
ForPortionOf?
alias:OptionalAsAlias?
UsingClause?
(WhereClause | WhereCurrentOf)?
ReturningClause? ';'?
WhereCurrentOf =
'where' 'current' 'of' CursorRef
Notify =
'notify' ChannelRef (',' Literal)? ';'?
MergeWhenMatched =
'when' 'matched'
('and' Expr)? 'then' MergeAction
MergeWhenNotMatchedSource =
'when' 'not' 'matched' 'by' 'source'
('and' Expr)? 'then' MergeAction
MergeWhenNotMatchedTarget =
'when' 'not' 'matched' ('by' 'target')?
('and' Expr)? 'then' MergeAction
MergeWhenClause =
MergeWhenMatched
| MergeWhenNotMatchedSource
| MergeWhenNotMatchedTarget
MergeDelete =
'delete'
MergeUpdate =
'update' 'set' SetClause
MergeInsert =
'insert' ColumnTargetList?
('overriding' ('system' | 'user'))?
(Values | 'default' 'values')
MergeDoNothing =
'do' 'nothing'
MergeAction =
MergeDelete
| MergeUpdate
| MergeInsert
| MergeDoNothing
Merge =
WithClause?
'merge' 'into' TableRelationName alias:OptionalAsAlias?
UsingOnClause
MergeWhenClause*
ReturningClause? ';'?
Declare =
'declare' Cursor
'binary'?
('asensitive' | 'insensitive')?
('no'? 'scroll')?
'cursor'
(('with' | 'without') 'hold')?
'for'
query:SelectVariant ';'?
Execute =
'execute' PreparedStatementRef ArgList? ';'?
WithData =
'with' 'data'
WithNoData =
'with' 'no' 'data'
CreateTableAsQuery =
SelectVariant
| Execute
CreateTableAs =
'create'
Persistence?
'table'
IfNotExists?
TableName
TableArgList?
UsingMethod?
(WithParams | WithoutOids)?
OnCommit?
TablespaceClause?
'as'
query:CreateTableAsQuery
(WithData | WithNoData)? ';'?
CreateMaterializedView =
'create' 'materialized' 'view' IfNotExists? View ColumnList?
UsingMethod?
WithParams?
TablespaceClause?
'as'
query:SelectVariant
(WithData | WithNoData)? ';'?
SavepointCreate =
'savepoint' Savepoint ';'?
PrepareTransaction =
'prepare' 'transaction' Literal ';'?
ReleaseSavepoint =
'release' 'savepoint' SavepointRef ';'?
ParenExpr =
'(' (Expr | Select | FromItem | JoinExpr) ')'
TupleExpr =
'(' (Expr (',' Expr)*) ')'
PrefixExpr =
Expr
PostfixExpr =
Expr
NonStandardParam =
':' name:BindParamNameRef
BindParamNameRef =
'#name'?
IndexExpr =
base:Expr '[' index:Expr ']'
SliceExpr =
base:Expr '[' start:Expr? ':' end:Expr? ']'
BetweenExpr =
target:Expr 'not'? 'between' ('symmetric' | 'asymmetric')? start:Expr 'and' end:Expr
JsonTableColumn =
ColumnName 'for' 'ordinality'
| ColumnName Type
JsonFormatClause?
JsonPathClause?
JsonWrapperBehaviorClause?
JsonQuotesClause?
(JsonOnErrorClause | JsonOnEmptyClause)?
| ColumnName Type
'exists'
JsonPathClause?
JsonOnErrorClause?
| 'nested' 'path'? Expr ('as' JsonPathName)? JsonTableColumnList
JsonPathClause =
'path' Expr
JsonTableColumnList =
'columns' '(' (JsonTableColumn (',' JsonTableColumn)*) ')'
JsonReturningClause =
'returning' Type
JsonNullClause =
JsonAbsentOnNull
| JsonNullOnNull
JsonAbsentOnNull =
'absent' 'on' 'null'
JsonNullOnNull =
'null' 'on' 'null'
JsonKeysUniqueClause =
JsonWithUniqueKeys
| JsonWithoutUniqueKeys
JsonWithUniqueKeys =
'with' 'unique' 'keys'
JsonWithoutUniqueKeys =
'without' 'unique' 'keys'
JsonQuotesClause =
('keep' | 'omit') 'quotes' ('on' 'scalar' 'string')?
JsonBehaviorDefault =
'default' Expr
JsonBehaviorError =
'error'
JsonBehaviorNull =
'null'
JsonBehaviorTrue =
'true'
JsonBehaviorFalse =
'false'
JsonBehaviorUnknown =
'unknown'
JsonBehaviorEmptyArray =
'empty' 'array'?
JsonBehaviorEmptyObject =
'empty' 'object'
JsonBehavior =
JsonBehaviorDefault
| JsonBehaviorError
| JsonBehaviorNull
| JsonBehaviorTrue
| JsonBehaviorFalse
| JsonBehaviorUnknown
| JsonBehaviorEmptyArray
| JsonBehaviorEmptyObject
JsonWrapperBehaviorClause =
JsonWithConditionalWrapper
| JsonWithUnconditionalWrapper
| JsonWithoutWrapper
JsonWithConditionalWrapper =
'with' 'conditional' 'array'? 'wrapper'
JsonWithUnconditionalWrapper =
'with' 'unconditional'? 'array'? 'wrapper'
JsonWithoutWrapper =
'without' 'array'? 'wrapper'
JsonOnErrorClause =
JsonBehavior 'on' 'error'
JsonOnEmptyClause =
JsonBehavior 'on' 'empty'
JsonPassingArg =
Expr 'as' name:JsonVariableName
JsonPassingClause =
'passing' (JsonPassingArg (',' JsonPassingArg)*)
JsonVariableName =
'#name'?
PercentTypeClause =
'%' 'type'
WithTimezone =
'with' 'time' 'zone'
WithoutTimezone =
'without' 'time' 'zone'
AttributeOption =
(name:AttributeName | namespace:AttributeNamespace '.' name:AttributeName)
('=' AttributeValue)?
AttributeName =
'#name'?
AttributeNamespace =
'#name'?
AttributeValue =
Literal
| 'none'
| 'operator' '(' Op ')'
| Op
| Type
AttributeList =
'(' (AttributeOption (',' AttributeOption)*)? ')'
FilterClause =
'filter' '(' 'where' Expr ')'
OverClause =
'over' (WindowRef | '(' WindowSpec? ')')
NullTreatment =
IgnoreNulls
| RespectNulls
IgnoreNulls =
'ignore' 'nulls'
RespectNulls =
'respect' 'nulls'
WithinClause =
'within' 'group' '(' OrderByClause ')'
Materialized =
'materialized'
NotMaterialized =
'not' 'materialized'
WithQuery =
Select
| Values
| Insert
| Update
| Delete
| Merge
| CompoundSelect
| ParenSelect
| Table
CteName =
'#name'?
WithTable =
name:CteName ColumnList? 'as'? (Materialized | NotMaterialized)? '(' query:WithQuery ')'
SearchClause?
CycleClause?
SearchClause =
'search'
('breadth' | 'depth')
'first'
'by'
columns:SearchColumns
set_column:SearchSetColumn
SearchColumns =
(ColumnNameRef (',' ColumnNameRef)*)
SearchSetColumn =
'set'
ColumnNameRef
CycleClause =
'cycle'
columns:CycleColumns
set_column:CycleSetColumn
path:CyclePath
CycleColumns =
(ColumnNameRef (',' ColumnNameRef)*)
CycleSetColumn =
'set'
ColumnNameRef
column_to:CycleColumnTo?
CycleColumnTo =
'to'
Expr
default:CycleDefault
CycleDefault =
'default' Expr
CyclePath =
'using'
ColumnNameRef
WithClause =
'with' 'recursive'? (WithTable (',' WithTable)*)
SelectClause =
'select'
('all' | DistinctClause)?
TargetList?
SelectVariant =
Select
| SelectInto
| ParenSelect
| Table
| Values
| CompoundSelect
CompoundSelect =
lhs:SelectVariant
('union' | 'intersect' | 'except' )
('all' | 'distinct')?
rhs:SelectVariant
OrderByClause?
LockingClause*
LimitClause?
FetchClause?
OffsetClause?
';'?
SelectInto =
WithClause?
SelectClause
IntoClause
FromClause?
WhereClause?
GroupByClause?
HavingClause?
WindowClause?
OrderByClause?
LockingClause*
LimitClause?
OffsetClause?
FilterClause? ';'?
IntoClause =
'into' Persistence? 'table'? TableName
LockingClause =
'for'
(
ForNoKeyUpdate
| ForKeyShare
| ForShare
| ForUpdate
)
('of' (Expr (',' Expr)*))?
('skip' 'locked' | 'nowait')?
ForNoKeyUpdate =
'no' 'key' 'update'
ForKeyShare =
'key' 'share'
ForShare =
'share'
ForUpdate =
'update'
NullsFirst =
'nulls' 'first'
NullsLast =
'nulls' 'last'
SortAsc =
'asc'
SortDesc =
'desc'
SortUsing =
'using' Op
SortBy =
Expr (SortAsc | SortDesc | SortUsing)? (NullsFirst | NullsLast)?
OrderByClause =
'order' 'by' SortByList
SortByList =
SortBy (',' SortBy)*
RepeatableClause =
'repeatable' '(' Expr ')'
TablesampleClause =
'tablesample' CallExpr RepeatableClause?
FromItem =
ExprFromItem
| FunctionFromItem
| GraphTableFromItem
| JsonTableFromItem
| ParenFromItem
| RelationFromItem
| RowsFromItem
| XmlTableFromItem
RelationFromItem =
'only'? RelationNameRef '*'? alias:FromAlias? TablesampleClause?
FunctionFromItem =
'lateral'? CallExpr ('with' 'ordinality')? alias:FromAlias?
ParenFromItem =
'only'? 'lateral'? (ParenSelect | ParenExpr) alias:FromAlias?
JsonTableFromItem =
'lateral'? JsonTable alias:FromAlias?
GraphTableFromItem =
'lateral'? GraphTableFn alias:FromAlias?
XmlTableFromItem =
'lateral'? XmlTable alias:FromAlias?
ExprFromItem =
'lateral'? (CastExpr | CollationForFn) alias:FromAlias?
RowsFromItem =
'lateral'? 'rows' 'from' '(' (CallExpr (',' CallExpr)*) ')' ('with' 'ordinality')? alias:FromAlias?
FromClause =
'from'
(FromItem (',' FromItem)*)?
(JoinExpr (',' JoinExpr)*)?
XmlTableColumnList =
'columns' (XmlTableColumn (',' XmlTableColumn)*)
XmlTableColumn =
ColumnName Type XmlColumnOptionList?
| ColumnName 'for' 'ordinality'
XmlColumnOptionList =
(XmlColumnOption (XmlColumnOption*))
XmlColumnOption =
OptionIdent
| OptionDefault
| OptionNotNull
| OptionNull
| OptionPath
OptionIdent =
'#ident' Expr
OptionDefault =
'default' Expr
OptionNotNull =
'not' 'null'
OptionNull =
'null'
OptionPath =
'path' Expr
ConstraintIndexMethod =
'using' AccessMethodRef
ConstraintExclusionList =
'(' (ConstraintExclusion (',' ConstraintExclusion)*) ')'
ConstraintExclusion =
Expr 'with' Op
WhereConditionClause =
'where' '(' Expr ')'
ExcludeConstraint =
ConstraintNameClause?
'exclude' ConstraintIndexMethod? ConstraintExclusionList
ConstraintIncludeClause?
WithParams?
ConstraintIndexTablespace?
WhereConditionClause?
FrameClause =
('range' | 'rows' | 'groups')
(FrameBetween | FrameBound)
FrameExclude?
FrameBetween =
'between' start:FrameBound 'and' end:FrameBound
FrameBound =
CurrentRow
| UnboundedPreceding
| UnboundedFollowing
| ExprPreceding
| ExprFollowing
UnboundedPreceding =
'unbounded' 'preceding'
UnboundedFollowing =
'unbounded' 'following'
ExprPreceding =
Expr 'preceding'
ExprFollowing =
Expr 'following'
FrameExclude =
'exclude'
(
CurrentRow
| Group
| Ties
| NoOthers
)
CurrentRow =
'current' 'row'
Group =
'group'
Ties =
'ties'
NoOthers =
'no' 'others'
WindowSpec =
WindowRef? PartitionByClause? OrderByClause? FrameClause?
PartitionByClause =
'partition' 'by' (Expr (',' Expr)*)
AlterStatistics =
'alter' 'statistics' StatisticsRef action:AlterStatisticsAction ';'?
AlterStatisticsAction =
OwnerTo
| SetSchema
| SetStatistics
| StatisticsRenameTo
AlterServer =
'alter' 'server' ServerRef actions:AlterServerAction* ';'?
AlterServerAction =
AlterOptionList
| OwnerTo
| ServerRenameTo
| SetVersion
SetVersion =
'version' Literal
AlterOptionList =
'options' '(' (AlterOption (',' AlterOption)*)? ')'
AlterOption =
('add' | 'set')? ForeignOptionName Literal
| 'drop' ForeignOptionName
ForeignOptionName =
'#name'?
AlterSequence =
'alter' 'sequence' IfExists? SequenceRef actions:AlterSequenceAction* ';'?
AlterSequenceAction =
OwnerTo
| SequenceOption
| SequenceRenameTo
| SetLogged
| SetSchema
| SetUnlogged
AlterSchema =
'alter' 'schema' SchemaRef action:AlterSchemaAction ';'?
AlterSchemaAction =
OwnerTo
| SchemaRenameTo
AlterRule =
'alter' 'rule' RuleRef OnRelation RuleRenameTo ';'?
AlterRoutine =
'alter' 'routine' RoutineSig action:AlterRoutineAction
'restrict'? ';'?
AlterRoutineAction =
DependsOnExtension
| FuncOptionList
| NoDependsOnExtension
| OwnerTo
| RoutineRenameTo
| SetSchema
AlterRole =
'alter' 'role' ('all' | RoleRef) InDatabase? action:AlterRoleAction? ';'?
AlterRoleAction =
ResetConfigParam
| RoleOptionList
| RoleRenameTo
| SetConfigParam
InDatabase =
'in' 'database' DatabaseRef
AlterPublication =
'alter' 'publication' PublicationRef action:AlterPublicationAction ';'?
AlterPublicationAction =
AddPublicationObjects
| DropPublicationObjects
| OwnerTo
| PublicationRenameTo
| SetAllPublicationObjects
| SetOptions
| SetPublicationObjects
AddPublicationObjects =
'add' (PublicationObject (',' PublicationObject)*)
DropPublicationObjects =
'drop' (PublicationObject (',' PublicationObject)*)
SetAllPublicationObjects =
'set' 'all' ('tables' | 'sequences') ExceptTableClause?
SetPublicationObjects =
'set' (PublicationObject (',' PublicationObject)*)
AlterProcedure =
'alter' 'procedure' ProcedureSig action:AlterProcedureAction
'restrict'? ';'?
AlterProcedureAction =
DependsOnExtension
| FuncOptionList
| NoDependsOnExtension
| OwnerTo
| ProcedureRenameTo
| SetSchema
AlterPolicy =
'alter' 'policy' PolicyRef OnTable action:AlterPolicyAction ';'?
AlterPolicyAction =
AlterPolicyTo
| PolicyRenameTo
AlterPolicyTo =
('to' RoleRefList)?
UsingExprClause?
WithCheckExprClause?
AlterOperatorFamily =
'alter' 'operator' 'family' OpFamilyRef UsingMethod action:AlterOperatorFamilyAction ';'?
AlterOperatorFamilyAction =
AddOpClassOptions
| DropOpClassOptions
| OpFamilyRenameTo
| OwnerTo
| SetSchema
DropOpClassOptions =
'drop' DropOpClassOptionList
DropOpClassOptionList =
(DropOpClassOption (',' DropOpClassOption)*)
DropOpClassOption =
DropOpClassOptionFunction
| DropOpClassOptionOperator
DropOpClassOptionFunction =
'function' Literal ParamList?
DropOpClassOptionOperator =
'operator' Literal ParamList?
AddOpClassOptions =
'add' OperatorClassOptionList
OpClassOption =
OpClassOptionFunction
| OpClassOptionOperator
| OpClassOptionStorage
OpClassOptionFunction =
'function' Literal ParamList? FunctionSig
OpClassOptionOperator =
'operator' Literal Op ('(' Type ',' Type ')')? ('for' 'search' | 'for' 'order' 'by' OpFamilyRef)
OpClassOptionStorage =
'storage' Type
AlterOperatorClass =
'alter' 'operator' 'class' OpClassRef UsingMethod action:AlterOperatorClassAction ';'?
AlterOperatorClassAction =
OpClassRenameTo
| OwnerTo
| SetSchema
AlterOperator =
'alter' 'operator' OpSig action:AlterOperatorAction ';'?
AlterOperatorAction =
OwnerTo
| SetOptions
| SetSchema
AlterMaterializedViewAction =
ViewRenameTo
| RenameColumn
| SetSchema
| NoDependsOnExtension
| DependsOnExtension
| AlterTableAction
NoDependsOnExtension =
'no' 'depends' 'on' 'extension' ExtensionRef
DependsOnExtension =
'depends' 'on' 'extension' ExtensionRef
AlterMaterializedView =
'alter' 'materialized' 'view'
(
AllInTablespace
| IfExists? ViewRef action:AlterMaterializedViewAction*
) ';'?
AlterLargeObject =
'alter' 'large' 'object' Literal 'owner' 'to' RoleRef ';'?
AlterLanguage =
'alter' 'language' LanguageRef action:AlterLanguageAction? ';'?
AlterLanguageAction =
LanguageRenameTo
| OwnerTo
AlterIndex =
'alter' 'index' (
AllInTablespace
| IfExists? IndexRef action:AlterIndexAction
) ';'?
OwnedByRoles =
'owned' 'by' RoleRefList
AlterIndexAction =
AttachIndexPartition
| DependsOnExtension
| NoDependsOnExtension
| ResetOptions
| IndexRenameTo
| SetTablespace
| SetOptions
| AlterSetStatistics
AlterGroup =
'alter' 'group' RoleRef action:AlterGroupAction ';'?
AlterGroupAction =
AddUsers
| DropUsers
| RoleRenameTo
AddUsers =
'add' 'user' (RoleRef (',' RoleRef)*)
DropUsers =
'drop' 'user' (RoleRef (',' RoleRef)*)
AlterFunction =
'alter' 'function' FunctionSig action:AlterFunctionAction
'restrict'? ';'?
AlterFunctionAction =
DependsOnExtension
| FuncOptionList
| FunctionRenameTo
| NoDependsOnExtension
| OwnerTo
| SetSchema
AlterForeignTable =
'alter' 'foreign' 'table' IfExists? TableRelationName
actions:AlterTableAction* ';'?
AlterForeignDataWrapper =
'alter' 'foreign' 'data' 'wrapper' ForeignDataWrapperRef
action:AlterForeignDataWrapperAction? ';'?
AlterForeignDataWrapperAction =
FdwOptionList
| ForeignDataWrapperRenameTo
| OwnerTo
FdwOptionList =
FdwOption*
FdwOption =
OptionAlterOptionList
| OptionConnection
| OptionHandler
| OptionValidator
| OptionNoConnection
| OptionNoHandler
| OptionNoValidator
OptionAlterOptionList =
'options' '(' (AlterOption (',' AlterOption)*)? ')'
OptionConnection =
'connection' FunctionNameRef
OptionHandler =
'handler' FunctionNameRef
OptionValidator =
'validator' FunctionNameRef
OptionNoConnection =
'no' 'connection'
OptionNoHandler =
'no' 'handler'
OptionNoValidator =
'no' 'validator'
AlterEventTrigger =
'alter' 'event' 'trigger' EventTriggerRef action:AlterEventTriggerAction? ';'?
AlterEventTriggerAction =
Disable
| Enable
| EnableAlways
| EnableReplica
| EventTriggerRenameTo
| OwnerTo
Disable =
'disable'
Enable =
'enable'
EnableAlways =
'enable' 'always'
EnableReplica =
'enable' 'replica'
AlterExtension =
'alter' 'extension' ExtensionRef action:AlterExtensionAction? ';'?
AlterExtensionAction =
AlterExtensionAdd
| AlterExtensionDrop
| AlterExtensionUpdate
| SetSchema
AlterExtensionUpdate =
'update' ('to' ('#ident' | Literal))?
AlterExtensionAdd =
'add' ExtensionMemberObject
AlterExtensionDrop =
'drop' ExtensionMemberObject
ExtensionMemberObject =
ObjectAccessMethod
| ObjectAggregate
| ObjectCast
| ObjectCollation
| ObjectConversion
| ObjectDatabase
| ObjectDomain
| ObjectEventTrigger
| ObjectExtension
| ObjectForeignDataWrapper
| ObjectForeignTable
| ObjectFunction
| ObjectIndex
| ObjectLanguage
| ObjectMaterializedView
| ObjectOperator
| ObjectOperatorClass
| ObjectOperatorFamily
| ObjectProcedure
| ObjectPublication
| ObjectRole
| ObjectRoutine
| ObjectSchema
| ObjectSequence
| ObjectServer
| ObjectStatistics
| ObjectSubscription
| ObjectTable
| ObjectTablespace
| ObjectTextSearchConfig
| ObjectTextSearchDict
| ObjectTextSearchParser
| ObjectTextSearchTemplate
| ObjectTransform
| ObjectType
| ObjectView
ObjectCollation =
'collation' CollationRef
ObjectConversion =
'conversion' ConversionRef
ObjectDatabase =
'database' DatabaseRef
ObjectDomain =
'domain' DomainRef
ObjectExtension =
'extension' ExtensionRef
ObjectIndex =
'index' IndexRef
ObjectPublication =
'publication' PublicationRef
ObjectRole =
'role' RoleRef
ObjectSchema =
'schema' SchemaRef
ObjectSequence =
'sequence' SequenceRef
ObjectServer =
'server' ServerRef
ObjectStatistics =
'statistics' StatisticsRef
ObjectSubscription =
'subscription' SubscriptionRef
ObjectTable =
'table' TableNameRef
ObjectTablespace =
'tablespace' TablespaceRef
ObjectType =
'type' TypeNameRef
ObjectView =
'view' ViewRef
ObjectAccessMethod =
'access' 'method' AccessMethodRef
ObjectAggregate =
'aggregate' Aggregate
ObjectCast =
'cast' CastSig
ObjectEventTrigger =
'event' 'trigger' EventTriggerRef
ObjectForeignDataWrapper =
'foreign' 'data' 'wrapper' ForeignDataWrapperRef
ObjectForeignTable =
'foreign' 'table' TableNameRef
ObjectFunction =
'function' FunctionSig
ObjectProcedure =
'procedure' ProcedureSig
ObjectRoutine =
'routine' RoutineSig
ObjectMaterializedView =
'materialized' 'view' ViewRef
ObjectOperator =
'operator' Op '(' Type ',' Type ')'
ObjectOperatorClass =
'operator' 'class' OpClassRef UsingMethod
ObjectOperatorFamily =
'operator' 'family' OpFamilyRef UsingMethod
ObjectLanguage =
'procedural'? 'language' LanguageRef
ObjectTextSearchConfig =
'text' 'search' 'configuration' TextSearchConfigurationRef
ObjectTextSearchDict =
'text' 'search' 'dictionary' TextSearchDictionaryRef
ObjectTextSearchParser =
'text' 'search' 'parser' TextSearchParserRef
ObjectTextSearchTemplate =
'text' 'search' 'template' TextSearchTemplateRef
ObjectTransform =
'transform' 'for' Type 'language' LanguageRef
AlterDefaultPrivileges =
'alter' 'default' 'privileges'
('for' ('role' | 'user') RoleRefList)?
('in' 'schema' (SchemaRef (',' SchemaRef)*))?
action:AlterDefaultPrivilegesAction? ';'?
AlterDefaultPrivilegesAction =
GrantDefaultPrivileges
| RevokeDefaultPrivileges
GrantDefaultPrivileges =
'grant' Privileges 'on' PrivilegeTarget 'to' RoleRefList ('with' 'grant' 'option')?
RevokeDefaultPrivileges =
'revoke' ('grant' 'option' 'for')? Privileges 'on' PrivilegeTarget 'from' RoleRefList ('cascade' | 'restrict')?
Privileges =
'all' 'privileges'? ColumnRefList?
| RevokeCommandList
PrivilegeTarget =
PrivilegeTargetFunctions
| PrivilegeTargetLargeObjects
| PrivilegeTargetRoutines
| PrivilegeTargetSchemas
| PrivilegeTargetSequences
| PrivilegeTargetTables
| PrivilegeTargetTypes
PrivilegeTargetFunctions =
'functions'
PrivilegeTargetLargeObjects =
'large' 'objects'
PrivilegeTargetRoutines =
'routines'
PrivilegeTargetSchemas =
'schemas'
PrivilegeTargetSequences =
'sequences'
PrivilegeTargetTables =
'tables'
PrivilegeTargetTypes =
'types'
AlterDatabase =
'alter' 'database' DatabaseRef action:AlterDatabaseAction? ';'?
AlterDatabaseAction =
DatabaseOptionList
| DatabaseRenameTo
| OwnerTo
| RefreshCollationVersion
| ResetConfigParam
| SetConfigParam
| SetTablespace
DatabaseOptionList =
'with'? DatabaseOption*
DatabaseOption =
DatabaseOptionConnectionLimit
| DatabaseOptionEncoding
| DatabaseOptionGeneric
| DatabaseOptionOwner
| DatabaseOptionTablespace
| DatabaseOptionTemplate
DatabaseOptionConnectionLimit =
'connection' 'limit' '='? (Literal | 'default' | ConfigValueName)
DatabaseOptionEncoding =
'encoding' '='? (Literal | 'default' | ConfigValueName)
DatabaseOptionGeneric =
'#ident' '='? (Literal | 'default' | ConfigValueName)
DatabaseOptionOwner =
'owner' '='? (Literal | 'default' | RoleRef)
DatabaseOptionTablespace =
'tablespace' '='? (Literal | 'default' | TablespaceRef)
DatabaseOptionTemplate =
'template' '='? (Literal | 'default' | DatabaseRef)
SetConfigParam =
'set' ConfigParameterRef
(
'from' 'current'
| ('to' | '=') ('default' | 'null' | (Literal (',' Literal)*) | (ConfigValueName (',' ConfigValueName)*))
)
ResetConfigParam =
'reset' ('all' | ConfigParameterRef)
RefreshCollationVersion =
'refresh' 'collation' 'version'
AlterConversion =
'alter' 'conversion' ConversionRef action:AlterConversionAction ';'?
AlterConversionAction =
ConversionRenameTo
| OwnerTo
| SetSchema
AlterCollation =
'alter' 'collation' CollationRef action:AlterCollationAction ';'?
AlterCollationAction =
CollationRenameTo
| OwnerTo
| RefreshVersion
| SetSchema
RefreshVersion =
'refresh' 'version'
AlterAggregate =
'alter' 'aggregate' Aggregate action:AlterAggregateAction ';'?
AlterAggregateAction =
AggregateRenameTo
| OwnerTo
| SetSchema
AlterSubscription =
'alter' 'subscription' SubscriptionRef action:AlterSubscriptionAction ';'?
AlterSubscriptionAction =
SetConnection
| SetServer
| SetOptions
| AddPublication
| SetPublication
| DropSubscriptionPublication
| RefreshPublication
| EnableSubscription
| DisableSubscription
| SkipSubscription
| OwnerTo
| SubscriptionRenameTo
SetConnection =
'connection' Literal
SetServer =
'server' ServerRef
AddPublication =
'add' 'publication' (PublicationRef (',' PublicationRef)*) ('with' AttributeList)?
SetPublication =
'set' 'publication' (PublicationRef (',' PublicationRef)*) ('with' AttributeList)?
DropSubscriptionPublication =
'drop' 'publication' (PublicationRef (',' PublicationRef)*) ('with' AttributeList)?
RefreshPublication =
'refresh' 'publication' ('with' AttributeList)?
EnableSubscription =
'enable'
DisableSubscription =
'disable'
SkipSubscription =
'skip' AttributeList
AlterSystem =
'alter' 'system' action:AlterSystemAction ';'?
AlterSystemAction =
ResetConfigParam
| SetConfigParam
AlterTablespace =
'alter' 'tablespace' TablespaceRef action:AlterTablespaceAction ';'?
AlterTablespaceAction =
OwnerTo
| ResetOptions
| SetOptions
| TablespaceRenameTo
AlterTextSearchParser =
'alter' 'text' 'search' 'parser' TextSearchParserRef
action:AlterTextSearchParserAction ';'?
AlterTextSearchParserAction =
SetSchema
| TextSearchParserRenameTo
AlterTextSearchDictionary =
'alter' 'text' 'search' 'dictionary' TextSearchDictionaryRef
action:AlterTextSearchDictionaryAction ';'?
AlterTextSearchDictionaryAction =
AttributeList
| OwnerTo
| SetSchema
| TextSearchDictionaryRenameTo
AlterTextSearchConfiguration =
'alter' 'text' 'search' 'configuration' TextSearchConfigurationRef
action:AlterTextSearchConfigurationAction ';'?
AlterTextSearchConfigurationAction =
AddMapping
| AlterMapping
| DropMapping
| OwnerTo
| SetSchema
| TextSearchConfigurationRenameTo
AddMapping =
'add' 'mapping' 'for' (TextSearchTokenKind (',' TextSearchTokenKind)*)
'with' (TextSearchDictionaryRef (',' TextSearchDictionaryRef)*)
AlterMapping =
'alter' 'mapping'
(
'for' (TextSearchTokenKind (',' TextSearchTokenKind)*)
('with' (TextSearchDictionaryRef (',' TextSearchDictionaryRef)*)
| 'replace' TextSearchDictionaryRef 'with' TextSearchDictionaryRef)
| 'replace' TextSearchDictionaryRef 'with' TextSearchDictionaryRef
)
DropMapping =
'drop' 'mapping' IfExists? 'for' (TextSearchTokenKind (',' TextSearchTokenKind)*)
AlterTextSearchTemplate =
'alter' 'text' 'search' 'template' TextSearchTemplateRef
action:AlterTextSearchTemplateAction ';'?
AlterTextSearchTemplateAction =
SetSchema
| TextSearchTemplateRenameTo
AlterTrigger =
'alter' 'trigger' TriggerRef OnRelation action:AlterTriggerAction ';'?
AlterTriggerAction =
DependsOnExtension
| NoDependsOnExtension
| TriggerRenameTo
AlterType =
'alter' 'type' TypeNameRef action:AlterTypeAction ';'?
AlterTypeAction =
AddValue
| AlterTypeAttributeActionList
| OwnerTo
| RenameAttribute
| RenameValue
| SetOptions
| SetSchema
| TypeRenameTo
AlterTypeAttributeActionList =
actions:(AlterTypeAttributeAction (',' AlterTypeAttributeAction)*)
AlterTypeAttributeAction =
AddAttribute
| AlterAttribute
| DropAttribute
RenameAttribute =
'rename' 'attribute' CompositeFieldRef 'to' CompositeField (Cascade | Restrict)?
RenameValue =
'rename' 'value' from:Literal 'to' to:Literal
AddAttribute =
'add' 'attribute' CompositeField Type Collate? (Cascade | Restrict)?
DropAttribute =
'drop' 'attribute' IfExists? CompositeFieldRef (Cascade | Restrict)?
AlterAttribute =
'alter' 'attribute' CompositeFieldRef ('set' 'data'?)? 'type' Type Collate? (Cascade | Restrict)?
AddValue =
'add' 'value' IfNotExists? Literal ValuePosition?
ValuePosition =
BeforeValue
| AfterValue
BeforeValue =
'before' Literal
AfterValue =
'after' Literal
AlterUser =
'alter' 'user' ('all' | RoleRef) InDatabase? action:AlterUserAction? ';'?
AlterUserAction =
ResetConfigParam
| RoleOptionList
| RoleRenameTo
| SetConfigParam
AlterUserMapping =
'alter' 'user' 'mapping' 'for' RoleRef ServerName AlterOptionList ';'?
AlterView =
'alter' 'view' IfExists? ViewRef action:AlterViewAction ';'?
AlterViewAction =
AlterViewColumn
| OwnerTo
| RenameColumn
| ResetOptions
| SetOptions
| SetSchema
| ViewRenameTo
AlterViewColumn =
'alter' 'column'? name:ColumnNameRef (SetDefault | DropDefault)
Analyze =
('analyze' | 'analyse')
('verbose' | OptionItemList)?
TableAndColumnsList? ';'?
// suffix it with `On` to avoid conflicting with comment nodes
CommentOn =
'comment' 'on'
CommentObject
'is'
('null' | Literal) ';'?
CommentObject =
ObjectAccessMethod
| ObjectAggregate
| ObjectCast
| ObjectCollation
| ObjectConversion
| ObjectDatabase
| ObjectDomain
| ObjectEventTrigger
| ObjectExtension
| ObjectForeignDataWrapper
| ObjectForeignTable
| ObjectFunction
| ObjectIndex
| ObjectLanguage
| ObjectMaterializedView
| ObjectProcedure
| ObjectPublication
| ObjectRole
| ObjectRoutine
| ObjectSchema
| ObjectSequence
| ObjectServer
| ObjectStatistics
| ObjectSubscription
| ObjectTable
| ObjectTablespace
| ObjectTextSearchConfig
| ObjectTextSearchDict
| ObjectTextSearchParser
| ObjectTextSearchTemplate
| ObjectType
| ObjectView
| ObjectColumn
| ObjectConstraint
| ObjectLargeObject
| ObjectOperator
| ObjectOperatorClass
| ObjectOperatorFamily
| ObjectPolicy
| ObjectPropertyGraph
| ObjectRule
| ObjectTransform
| ObjectTrigger
ObjectColumn =
'column' name:QualifiedColumnNameRef
ObjectConstraint =
'constraint' ConstraintNameRef 'on' ('domain' DomainRef | TableNameRef)
ObjectLargeObject =
'large' 'object' Literal
ObjectPolicy =
'policy' PolicyRef 'on' TableNameRef
ObjectPropertyGraph =
'property' 'graph' PropertyGraphRef
ObjectRule =
'rule' RuleRef 'on' RelationNameRef
ObjectTrigger =
'trigger' TriggerRef 'on' RelationNameRef
Cluster =
'cluster'
('verbose' | OptionItemList)?
(TableNameRef ClusterUsingIndex? | ClusterLegacy)? ';'?
ClusterLegacy =
IndexRef OnPath
ClusterUsingIndex =
'using' IndexRef
OnPath =
'on'
TableNameRef
Repack =
'repack'
OptionItemList?
TableAndColumnsList?
(
'using' 'index' IndexRef?
)? ';'?
Persistence =
Temp
| Unlogged
Temp =
'temporary'
| 'temp'
| 'local' 'temporary'
| 'local' 'temp'
| 'global' 'temporary'
| 'global' 'temp'
Unlogged =
'unlogged'
CreatePropertyGraph =
'create' Persistence? 'property' 'graph' PropertyGraph
VertexTables?
EdgeTables? ';'?
VertexTables =
('vertex' | 'node') 'tables' '(' (VertexTableDef (',' VertexTableDef)*) ')'
VertexTableDef =
TableNameRef
('as' alias:ElementTableAlias)?
('key' ColumnRefList)?
ElementTableLabelAndProperties?
ElementTableLabelAndProperties =
ElementTableProperties
| LabelAndPropertiesList
ElementTableProperties =
NoProperties
| AllProperties
| Properties
NoProperties =
'no' 'properties'
AllProperties =
'properties' 'all' 'columns'
Properties =
'properties' '(' ExprAsPropertyNameList ')'
LabelAndPropertiesList =
(LabelAndProperties (',' LabelAndProperties)*)
Label =
'#name'?
LabelRef =
'#name'?
LabelAndProperties =
(
'label' Label
| 'default' 'label'
)
ElementTableProperties?
EdgeTables =
('edge' | 'relationship') 'tables' '(' (EdgeTableDef (',' EdgeTableDef)*) ')'
EdgeTableDef =
TableNameRef
('as' alias:ElementTableAlias)?
('key' ColumnRefList)?
SourceVertexTable
DestVertexTable
ElementTableLabelAndProperties?
SourceVertexTable =
'source' VertexTableRef
| 'source' 'key' ColumnRefList ReferencesTable
ReferencesTable =
'references' VertexTableRef ColumnRefList
DestVertexTable =
'destination' VertexTableRef
| 'destination' 'key' ColumnRefList ReferencesTable
VertexTableRef =
'#name'?
ElementTableRef =
'#name'?
ElementTableAlias =
'#name'?
ElementVariable =
'#ident'?
PropertyName =
'#name'?
PropertyNameRef =
'#name'?
AlterPropertyGraph =
'alter' 'property' 'graph' IfExists? PropertyGraphRef
action:AlterPropertyGraphAction ';'?
AlterPropertyGraphAction =
PropertyGraphRenameTo
| SetSchema
| OwnerTo
| AddVertexEdgeTables
| DropVertexTables
| DropEdgeTables
| AlterVertexEdgeLabels
| DropVertexEdgeLabel
| AddVertexEdgeLabelProperties
| DropVertexEdgeLabelProperties
AddVertexEdgeTables =
('add' VertexTables)? ('add' EdgeTables)?
DropVertexTables =
'drop' ('vertex' | 'node')
'tables' '(' (ElementTableRef (',' ElementTableRef)*) ')'
('cascade' | 'restrict')?
DropEdgeTables =
'drop' ('edge' | 'relationship')
'tables' '(' (ElementTableRef (',' ElementTableRef)*) ')'
('cascade' | 'restrict')?
AlterVertexEdgeLabels =
'alter' ('vertex' | 'node' | 'edge' | 'relationship') 'table' ElementTableRef
AddLabel AddLabel*
AddLabel =
'add' 'label' Label ElementTableProperties
DropVertexEdgeLabel =
'alter' ('vertex' | 'node' | 'edge' | 'relationship') 'table' ElementTableRef
'drop' 'label' LabelRef ('cascade' | 'restrict')?
AddVertexEdgeLabelProperties =
'alter' ('vertex' | 'node' | 'edge' | 'relationship') 'table' ElementTableRef
'alter' 'label' LabelRef
'add' 'properties' '(' ExprAsPropertyNameList ')'
DropVertexEdgeLabelProperties =
'alter' ('vertex' | 'node' | 'edge' | 'relationship') 'table' ElementTableRef
'alter' 'label' LabelRef
'drop' 'properties' '(' (PropertyNameRef (',' PropertyNameRef)*) ')' ('cascade' | 'restrict')?
DropPropertyGraph =
'drop' 'property' 'graph' IfExists? PropertyGraphRef ('cascade' | 'restrict')? ';'?
GraphTableFn =
'graph_table' '(' PropertyGraphRef 'match' PathPatternList WhereClause? 'columns' '(' ExprAsColumnNameList ')' ')'
PathPatternList =
(PathPattern (',' PathPattern)*)
PathPattern =
PathFactor PathFactor*
PathFactor =
PathPrimary
GraphPatternQualifier?
PathPrimary =
VertexPattern
| EdgeLeft
| EdgeRight
| EdgeAny
| ParenGraphPattern
VertexPattern =
'(' ElementVariable? IsLabel? WhereClause? ')'
EdgeLeft =
'<' '-' '[' ElementVariable? IsLabel? WhereClause? ']' '-'
| '<' '-'
EdgeRight =
'-' '[' ElementVariable? IsLabel? WhereClause? ']' '-' '>'
| '-' '>'
EdgeAny =
'-' '[' ElementVariable? IsLabel? WhereClause? ']' '-'
| '-'
ParenGraphPattern =
'(' PathPattern WhereClause? ')'
IsLabel =
'is' Expr
GraphPatternQualifier =
// TODO: these should be integers, not Literals
'{' Literal '}'
| '{' ',' Literal '}'
| '{' Literal ',' Literal '}'
CreateAccessMethod =
'create' 'access' 'method' AccessMethod
'type' ('table' | 'index')
HandlerClause ';'?
HandlerClause =
'handler' FunctionNameRef
CreateCast =
'create' 'cast' CastSig
(WithFunction | WithInout | WithoutFunction)
('as' 'assignment' | 'as' 'implicit')? ';'?
WithFunction =
'with' 'function' FunctionSig
WithInout =
'with' 'inout'
WithoutFunction =
'without' 'function'
CreateCollation =
'create' 'collation' IfNotExists? Collation
(CollationFrom | AttributeList)
';'?
CollationFrom =
'from' CollationRef
CreateConversion =
'create' 'default'? 'conversion' Conversion
'for' Literal
'to' Literal
'from' FunctionNameRef ';'?
CreateDatabase =
'create' 'database' Database DatabaseOptionList ';'?
Database =
'#name'?
DatabaseRef =
'#name'?
Domain =
Path
DomainRef =
PathRef
CreateDomain =
'create' 'domain' Domain 'as'? Type Collate? Constraint* ';'?
CreateEventTrigger =
'create' 'event' 'trigger' EventTrigger 'on' event:EventTriggerEvent
EventTriggerWhenClause?
'execute'
('function' | 'procedure')
CallExpr ';'?
EventTriggerWhenClause =
'when' (EventTriggerWhen ('and' EventTriggerWhen)*)
EventTriggerWhen =
var:EventTriggerFilterVariable 'in' '(' (Literal (',' Literal)*) ')'
CreateForeignDataWrapper =
'create' 'foreign' 'data' 'wrapper' ForeignDataWrapper
FdwOptionList?
AlterOptionList? ';'?
CreateForeignTable =
'create' 'foreign' 'table' IfNotExists? TableName
PartitionOf?
TableArgList?
Inherits?
PartitionType?
ServerName
AlterOptionList? ';'?
ServerName =
'server' ServerRef
CreateGroup =
'create' 'group' Role RoleOptionList? ';'?
RoleOptionList =
'with'? RoleOption*
RoleOption =
RoleOptionAdmin
| RoleOptionConnectionLimit
| RoleOptionEncryptedPassword
| RoleOptionGeneric
| RoleOptionInGroup
| RoleOptionInRole
| RoleOptionInherit
| RoleOptionPassword
| RoleOptionRole
| RoleOptionSysid
| RoleOptionUser
| RoleOptionValidUntil
RoleOptionAdmin =
'admin' RoleRefList
RoleOptionConnectionLimit =
'connection' 'limit' Literal
RoleOptionEncryptedPassword =
'encrypted' 'password' Literal
RoleOptionGeneric =
'#ident'
RoleOptionInGroup =
'in' 'group' RoleRefList
RoleOptionInRole =
'in' 'role' RoleRefList
RoleOptionInherit =
'inherit'
RoleOptionPassword =
'password' ('null' | Literal)
RoleOptionRole =
'role' RoleRefList
RoleOptionSysid =
'sysid' Literal
RoleOptionUser =
'user' RoleRefList
RoleOptionValidUntil =
'valid' 'until' Literal
CreateLanguage =
'create' OrReplace? 'trusted'? 'procedural'? 'language' Language
('handler' FunctionNameRef
('inline' FunctionNameRef)?
('validator' FunctionNameRef)?)? ';'?
CreateOperator =
'create' 'operator' Op AttributeList ';'?
CreateOperatorClass =
'create' 'operator' 'class' OpClassName 'default'? 'for' 'type' Type
UsingMethod OperatorFamilyClause?
'as'
OperatorClassOptionList ';'?
OperatorFamilyClause =
'family' OpFamilyRef
OpFamilyName =
Path
OpFamilyRef =
PathRef
OpClassName =
Path
OpClassRef =
PathRef
OperatorClassOptionList =
(OpClassOption (',' OpClassOption)*)
CreateOperatorFamily =
'create' 'operator' 'family' OpFamilyName UsingMethod ';'?
CreatePolicy =
'create' 'policy' Policy OnTable
AsPolicyType?
('for' ('all' | 'select' | 'insert' | 'update' | 'delete'))?
('to' RoleRefList)?
UsingExprClause?
WithCheckExprClause? ';'?
AsPolicyType =
'as' '#ident'
WithCheckExprClause =
'with' 'check' '(' Expr ')'
UsingExprClause =
'using' '(' Expr ')'
CreateProcedure =
'create' OrReplace? 'procedure' name:ProcedureName ParamList option_list:FuncOptionList ';'?
CreatePublication =
'create' 'publication' Publication
(
'for'
(
ForAllPublicationObjects
| (PublicationObject (',' PublicationObject)*)
)
)?
WithParams? ';'?
ForAllPublicationObjects =
'all' ('tables' | 'sequences') ExceptTableClause?
ExceptTableClause =
'except' '(' 'table' ( ExceptTableName (',' ExceptTableName)*) ')'
ExceptTableName =
'table'?
TableRelationName
PublicationObject =
PublicationObjectCurrentSchema
| PublicationObjectTable
| PublicationObjectTablesInSchema
PublicationObjectCurrentSchema =
'current_schema'
PublicationObjectTable =
'table' 'only'? (TableNameRef | '(' TableNameRef ')') '*'? ColumnRefList? WhereConditionClause?
PublicationObjectTablesInSchema =
'tables' 'in' 'schema' ('current_schema' | SchemaRef) WhereConditionClause?
CreateRole =
'create' 'role' Role RoleOptionList? ';'?
CreateRule =
'create' OrReplace? 'rule' Rule 'as'
RuleOn
RuleDo
';'?
RuleOn =
'on' RuleEvent
'to' RelationNameRef WhereClause?
RuleEvent =
'#ident'
| 'select'
| 'insert'
| 'update'
| 'delete'
RuleDo =
'do' ('also' | 'instead')?
RuleAction
Nothing =
'nothing'
RuleAction =
Nothing
| RuleStmtList
| RuleStmt
RuleStmtList =
'(' (RuleStmt (';' RuleStmt)*) ')'
RuleStmt =
SelectVariant
| Insert
| Update
| Delete
| Notify
CreateSequence =
'create' Persistence? 'sequence' IfNotExists? Sequence
SequenceOption* ';'?
CreateServer =
'create' 'server' IfNotExists? Server
('type' Literal)?
('version' Literal)?
'foreign' 'data' 'wrapper' ForeignDataWrapperRef
AlterOptionList? ';'?
CreateStatistics =
'create' 'statistics' IfNotExists? Statistics?
StatTypes?
('on' (Expr (',' Expr)*))?
FromTable ';'?
StatTypes =
'(' (StatisticsKind (',' StatisticsKind)*) ')'
CreateSubscription =
'create' 'subscription' Subscription
('connection' Literal | 'server' ServerRef)
'publication' (PublicationRef (',' PublicationRef)*)
WithParams? ';'?
CreateTablespace =
'create' 'tablespace' Tablespace
('owner' RoleRef)?
'location' Literal
WithParams? ';'?
CreateTextSearchParser =
'create' 'text' 'search' 'parser' TextSearchParser AttributeList ';'?
CreateTextSearchDictionary =
'create' 'text' 'search' 'dictionary' TextSearchDictionary AttributeList ';'?
CreateTextSearchConfiguration =
'create' 'text' 'search' 'configuration' TextSearchConfiguration AttributeList ';'?
CreateTextSearchTemplate =
'create' 'text' 'search' 'template' TextSearchTemplate AttributeList ';'?
CreateTransform =
'create' OrReplace? 'transform' 'for' Type 'language' LanguageRef
'(' (from_func:TransformFromFunc | to_func:TransformToFunc)
(',' (from_func:TransformFromFunc | to_func:TransformToFunc))? ')' ';'?
TransformFromFunc =
'from' 'sql' 'with' 'function' FunctionSig
TransformToFunc =
'to' 'sql' 'with' 'function' FunctionSig
CreateUserMapping =
'create' 'user' 'mapping' IfNotExists? 'for' RoleRef
ServerName
AlterOptionList? ';'?
CreateUser =
'create' 'user' Role
RoleOptionList? ';'?
DropLanguage =
'drop' 'procedural'? 'language' IfExists? LanguageRef
('cascade' | 'restrict')? ';'?
DropGroup =
'drop' 'group' IfExists? (RoleRef (',' RoleRef)*) ';'?
DropFunction =
'drop' 'function' IfExists? FunctionSigList
('cascade' | 'restrict')? ';'?
FunctionSigList =
(FunctionSig (',' FunctionSig)*)
FunctionSig =
FunctionNameRef ParamList?
ProcedureSigList =
(ProcedureSig (',' ProcedureSig)*)
ProcedureSig =
ProcedureNameRef ParamList?
RoutineSigList =
(RoutineSig (',' RoutineSig)*)
RoutineSig =
RoutineNameRef ParamList?
HasParamList =
Aggregate
| CreateAggregate
| CreateFunction
| CreateProcedure
| FunctionSig
| ProcedureSig
| RoutineSig
DropForeignDataWrapper =
'drop' 'foreign' 'data' 'wrapper' IfExists? (ForeignDataWrapperRef (',' ForeignDataWrapperRef)*)
('cascade' | 'restrict')? ';'?
DropForeignTable =
'drop' 'foreign' 'table' IfExists? (TableNameRef (',' TableNameRef)*)
('cascade' | 'restrict')? ';'?
DropAccessMethod =
'drop' 'access' 'method' IfExists? AccessMethodRef
('cascade' | 'restrict')? ';'?
Aggregate =
PathRef ParamList
AggregateName =
Path
DropAggregate =
'drop' 'aggregate' IfExists? (Aggregate (',' Aggregate)*)
('cascade' | 'restrict')? ';'?
DropCast =
'drop' 'cast' IfExists? CastSig
('cascade' | 'restrict')? ';'?
CastSig =
'(' lhs:Type 'as' rhs:Type ')'
DropCollation =
'drop' 'collation' IfExists? (CollationRef (',' CollationRef)*)
('cascade' | 'restrict')? ';'?
DropConversion =
'drop' 'conversion' IfExists? ConversionRef
('cascade' | 'restrict')? ';'?
DropDomain =
'drop' 'domain' IfExists? (DomainRef (',' DomainRef)*)
('cascade' | 'restrict')? ';'?
DropEventTrigger =
'drop' 'event' 'trigger' IfExists? EventTriggerRef
('cascade' | 'restrict')? ';'?
DropExtension =
'drop' 'extension' IfExists? (ExtensionRef (',' ExtensionRef)*)
('cascade' | 'restrict')? ';'?
DropMaterializedView =
'drop' 'materialized' 'view' IfExists? (ViewRef (',' ViewRef)*)
('cascade' | 'restrict')? ';'?
DropOperatorFamily =
'drop' 'operator' 'family' IfExists? OpFamilyRef UsingMethod
('cascade' | 'restrict')? ';'?
DropOperator =
'drop' 'operator' IfExists? OpSigList
('cascade' | 'restrict')? ';'?
OpSigList =
(OpSig (',' OpSig)*)
OpSig =
Op '(' (lhs:Type | 'none') ',' rhs:Type ')'
DropOperatorClass =
'drop' 'operator' 'class' IfExists? OpClassRef UsingMethod
('cascade' | 'restrict')? ';'?
DropOwned =
'drop' 'owned' 'by' RoleRefList
('cascade' | 'restrict')? ';'?
DropPolicy =
'drop' 'policy' IfExists? PolicyRef OnTable
('cascade' | 'restrict')? ';'?
DropProcedure =
'drop' 'procedure' IfExists? ProcedureSigList
('cascade' | 'restrict')? ';'?
DropPublication =
'drop' 'publication' IfExists? (PublicationRef (',' PublicationRef)*)
('cascade' | 'restrict')? ';'?
DropRole =
'drop' 'role' IfExists? (RoleRef (',' RoleRef)*) ';'?
DropRoutine =
'drop' 'routine' IfExists? RoutineSigList
('cascade' | 'restrict')? ';'?
DropRule =
'drop' 'rule' IfExists? RuleRef OnRelation
('cascade' | 'restrict')? ';'?
DropSequence =
'drop' 'sequence' IfExists? (SequenceRef (',' SequenceRef)*)
('cascade' | 'restrict')? ';'?
DropServer =
'drop' 'server' IfExists? (ServerRef (',' ServerRef)*)
('cascade' | 'restrict')? ';'?
DropStatistics =
'drop' 'statistics' IfExists? (StatisticsRef (',' StatisticsRef)*)
('cascade' | 'restrict')? ';'?
DropSubscription =
'drop' 'subscription' IfExists? SubscriptionRef
('cascade' | 'restrict')? ';'?
DropTablespace =
'drop' 'tablespace' IfExists? TablespaceRef ';'?
DropTextSearchParser =
'drop' 'text' 'search' 'parser' IfExists? TextSearchParserRef
('cascade' | 'restrict')? ';'?
DropTextSearchConfig =
'drop' 'text' 'search' 'configuration' IfExists? TextSearchConfigurationRef
('cascade' | 'restrict')? ';'?
DropTextSearchDict =
'drop' 'text' 'search' 'dictionary' IfExists? TextSearchDictionaryRef
('cascade' | 'restrict')? ';'?
DropTextSearchTemplate =
'drop' 'text' 'search' 'template' IfExists? TextSearchTemplateRef
('cascade' | 'restrict')? ';'?
DropTransform =
'drop' 'transform' IfExists? 'for' ty:Type 'language' LanguageRef
('cascade' | 'restrict')? ';'?
DropUser =
'drop' 'user' IfExists? (RoleRef (',' RoleRef)*) ';'?
DropUserMapping =
'drop' 'user' 'mapping' IfExists? 'for' RoleRef ServerName ';'?
DropView =
'drop' 'view' IfExists? (ViewRef (',' ViewRef)*)
('cascade' | 'restrict')? ';'?
Explain =
'explain'
(ExplainOptionList | ('analyze' | 'analyse') 'verbose'? | 'verbose')?
ExplainStmt ';'?
ExplainOptionList =
'(' (ExplainOption (',' ExplainOption)*) ')'
ExplainOption =
ExplainOptionName ExplainOptionValue?
ExplainOptionName =
'#name'?
ExplainOptionValue =
Literal
| 'binary'
| '#ident'
| 'json'
| 'no'
| 'none'
| 'text'
| 'xml'
| 'yes'
ExplainStmt =
Select
| CompoundSelect
| SelectInto
| ParenSelect
| Table
| Values
| Insert
| Update
| Delete
| Merge
| Execute
| Declare
| CreateTableAs
| CreateMaterializedView
ImportForeignSchema =
'import' 'foreign' 'schema' SchemaRef
(LimitToTables | ExceptTables)?
'from' ServerName
IntoSchema
AlterOptionList? ';'?
LimitToTables =
'limit' 'to' (RemoteTableNameRef (',' RemoteTableNameRef)*)
ExceptTables =
'except' (RemoteTableNameRef (',' RemoteTableNameRef)*)
IntoSchema =
'into' SchemaRef
Lock =
'lock' 'table'? RelationList
('in' LockMode 'mode')?
'nowait'? ';'?
LockMode =
AccessShare
| RowShare
| AccessExclusive
| RowExclusive
| ShareRowExclusive
| ShareUpdateExclusive
| Share
| Exclusive
AccessShare =
'access' 'share'
RowShare =
'row' 'share'
AccessExclusive =
'access' 'exclusive'
RowExclusive =
'row' 'exclusive'
ShareRowExclusive =
'share' 'row' 'exclusive'
ShareUpdateExclusive =
'share' 'update' 'exclusive'
Share =
'share'
Exclusive =
'exclusive'
Reassign =
'reassign' 'owned' 'by' old_roles:RoleRefList 'to' new_roles:RoleRefList ';'?
Refresh =
'refresh' 'materialized' 'view' 'concurrently'? ViewRef
(WithData | WithNoData)? ';'?
Grant =
'grant'
(AllPrivileges | RevokeCommandList)?
('on' PrivilegeObjects)?
'to' RoleRefList
GrantWithClause?
('granted' 'by' RoleRef)? ';'?
AllPrivileges =
'all' 'privileges'? ColumnRefList?
GrantWithClause =
'with'
(
'grant' 'option'
| GrantRoleOptionList
)
GrantRoleOptionList =
GrantRoleOption (',' GrantRoleOption)*
GrantRoleOption =
GrantRoleOptionName ('option' | 'true' | 'false')
GrantRoleOptionName =
'#name'?
PrivilegeObjects =
PrivilegeAllFunctionsInSchema
| PrivilegeAllProceduresInSchema
| PrivilegeAllRoutinesInSchema
| PrivilegeAllSequencesInSchema
| PrivilegeAllTablesInSchema
| PrivilegeDatabase
| PrivilegeDefault
| PrivilegeDomain
| PrivilegeForeignDataWrapper
| PrivilegeForeignServer
| PrivilegeFunction
| PrivilegeLanguage
| PrivilegeLargeObject
| PrivilegeParameter
| PrivilegeProcedure
| PrivilegePropertyGraph
| PrivilegeRoutine
| PrivilegeSchema
| PrivilegeSequence
| PrivilegeTable
| PrivilegeTablespace
| PrivilegeType
PrivilegeAllFunctionsInSchema =
'all' 'functions' 'in' 'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeAllProceduresInSchema =
'all' 'procedures' 'in' 'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeAllRoutinesInSchema =
'all' 'routines' 'in' 'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeAllSequencesInSchema =
'all' 'sequences' 'in' 'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeAllTablesInSchema =
'all' 'tables' 'in' 'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeParameter =
'parameter' (ConfigParameterRef (',' ConfigParameterRef)*)
PrivilegeFunction =
'function' FunctionSigList
PrivilegeProcedure =
'procedure' ProcedureSigList
PrivilegeRoutine =
'routine' RoutineSigList
PrivilegeType =
'type' (TypeNameRef (',' TypeNameRef)*)
PrivilegeDatabase =
'database' (DatabaseRef (',' DatabaseRef)*)
PrivilegeLanguage =
'language' (LanguageRef (',' LanguageRef)*)
PrivilegeSchema =
'schema' (SchemaRef (',' SchemaRef)*)
PrivilegeTablespace =
'tablespace' (TablespaceRef (',' TablespaceRef)*)
PrivilegeDomain =
'domain' (DomainRef (',' DomainRef)*)
PrivilegeSequence =
'sequence' (SequenceRef (',' SequenceRef)*)
PrivilegeTable =
'table' (RelationNameRef (',' RelationNameRef)*)
PrivilegeForeignDataWrapper =
'foreign' 'data' 'wrapper' (ForeignDataWrapperRef (',' ForeignDataWrapperRef)*)
PrivilegeForeignServer =
'foreign' 'server' (ServerRef (',' ServerRef)*)
PrivilegeLargeObject =
'large' 'object' (Literal (',' Literal)*)
PrivilegePropertyGraph =
'property' 'graph' (PropertyGraphRef (',' PropertyGraphRef)*)
PrivilegeDefault =
RelationNameRef (',' RelationNameRef)*
RevokeCommandList =
(RevokeCommand (',' RevokeCommand)*)
RevokeCommand =
( RoleRef
| 'alter' 'system'
| ('select' | 'insert' | 'update' | 'delete' | 'truncate' | 'references' | 'trigger' | '#ident' | 'all' | 'alter' | 'create' | 'temporary' | 'temp' | 'execute')
) ColumnRefList?
SecurityLabel =
'security' 'label'
ForProvider?
'on'
SecurityLabelObject
'is'
('null' | Literal) ';'?
SecurityLabelObject =
ObjectAggregate
| ObjectDatabase
| ObjectDomain
| ObjectEventTrigger
| ObjectForeignTable
| ObjectFunction
| ObjectLanguage
| ObjectMaterializedView
| ObjectProcedure
| ObjectPublication
| ObjectRole
| ObjectRoutine
| ObjectSchema
| ObjectSequence
| ObjectSubscription
| ObjectTable
| ObjectTablespace
| ObjectType
| ObjectView
| ObjectColumn
| ObjectLargeObject
ForProvider =
'for' (Literal | SecurityLabelProvider)
SecurityLabelProvider =
'#ident'?
SetConstraints =
'set' 'constraints'
('all' | (ConstraintNameRef (',' ConstraintNameRef)*))
('deferred' | 'immediate') ';'?
SetRole =
'set' ('session' | 'local')? 'role' (RoleRef | 'none')? ';'?
ResetRole =
'reset' 'role' ';'?
SetSessionAuth =
'set' ('session' | 'local')? 'session' 'authorization' (RoleRef | Literal | 'default') ';'?
ResetSessionAuth =
'reset' 'session' 'authorization' ';'?
SetTransaction =
'set'
(
SessionCharacteristics
| TransactionModes
| TransactionSnapshot
) ';'?
SessionCharacteristics =
'session' 'characteristics' 'as' 'transaction' TransactionModeList
TransactionModes =
'transaction' TransactionModeList
TransactionSnapshot =
'transaction' 'snapshot' Literal
Reindex =
'reindex' ReindexOptionList? ReindexTarget ';'?
ReindexTarget =
ReindexTargetDatabase
| ReindexTargetIndex
| ReindexTargetSchema
| ReindexTargetSystem
| ReindexTargetTable
ReindexTargetDatabase =
'database' 'concurrently'? DatabaseRef?
ReindexTargetIndex =
'index' 'concurrently'? IndexRef?
ReindexTargetSchema =
'schema' 'concurrently'? SchemaRef
ReindexTargetSystem =
'system' 'concurrently'? DatabaseRef?
ReindexTargetTable =
'table' 'concurrently'? TableNameRef?
ReindexOptionList =
'(' (ReindexOption (',' ReindexOption)*)? ')'
ReindexOption =
ReindexOptionConcurrently
| ReindexOptionTablespace
| ReindexOptionVerbose
ReindexOptionConcurrently =
'concurrently' (Literal | '#ident' | 'no' | 'yes')?
ReindexOptionTablespace =
'tablespace' TablespaceRef
ReindexOptionVerbose =
'verbose' (Literal | '#ident' | 'no' | 'yes')?
CreateView =
'create' OrReplace? Persistence? 'recursive'? 'view' View ColumnList?
WithParams?
'as' query:SelectVariant
('with' ('cascaded' | 'local')? 'check' 'option')? ';'?
Prepare =
'prepare' name:PreparedStatement ParamList? 'as' stmt:PreparableStmt ';'?
PreparableStmt =
Select
| SelectInto
| CompoundSelect
| Table
| Values
| Insert
| Update
| Delete
| Merge
Unlisten =
'unlisten' ('*' | ChannelRef) ';'?
Checkpoint =
'checkpoint' CheckpointOptionList? ';'?
CheckpointOptionList =
'(' (CheckpointOption (',' CheckpointOption)*) ')'
CheckpointOption =
CheckpointOptionName Expr?
CheckpointOptionName =
'#ident'?
Deallocate =
'deallocate' 'prepare'? (PreparedStatementRef | 'all') ';'?
Load =
'load' Literal ';'?
Listen =
'listen' Channel ';'?
Reset =
'reset' ResetTarget? ';'?
ResetTarget =
All
| ConfigParameterRef
| ResetTimeZone
| ResetTransactionIsolation
ResetTimeZone =
'time' 'zone'
ResetTransactionIsolation =
'transaction' 'isolation' 'level'
Discard =
'discard' ('all' | 'temp' | 'temporary' | 'plans' | 'sequences') ';'?
Do =
'do' ('language' (LanguageRef | Literal))? Literal ('language' (LanguageRef | Literal))? ';'?
Move =
'move' CursorAction? ('from' | 'in')? CursorRef ';'?
Fetch =
'fetch' CursorAction? ('from' | 'in')? CursorRef ';'?
CursorAction =
Absolute
| All
| Backward
| Expr
| First
| Forward
| Last
| Next
| Prior
| Relative
Next =
'next'
Prior =
'prior'
First =
'first'
Last =
'last'
Relative =
'relative' Expr
Absolute =
'absolute' Expr
Forward =
'forward' ('all' | Expr)?
Backward =
'backward' ('all' | Expr)?
Close =
'close' ('all' | CursorRef) ';'?
VacuumOptionList =
'(' (VacuumOption (',' VacuumOption)*)? ')'
Vacuum =
'vacuum'
'full'?
'freeze'?
'verbose'?
('analyze' | 'analyse')?
VacuumOptionList?
TableAndColumnsList? ';'?
TableAndColumnsList =
TableAndColumns (',' TableAndColumns)*
TableAndColumns =
TableRelationName ColumnRefList?
VacuumOption =
VacuumOptionName VacuumOptionValue?
VacuumOptionName =
'#name'?
VacuumOptionValue =
Literal
| VacuumOptionValueName
| 'no'
| 'yes'
VacuumOptionValueName =
'#name'?
Copy =
'copy'
(CopyQuery | CopyTable)
(CopyFrom | CopyTo)?
'with'?
(CopyOptionList | CopyLegacyOption*)?
WhereClause? ';'?
CopyQuery =
'(' PreparableStmt ')'
CopyTable =
'binary'? TableNameRef ColumnRefList?
CopyFrom =
'from' ('stdin' | 'stdout' | 'program'? Literal)
CopyTo =
'to' ('stdout' | 'program'? Literal)
CopyOptionList =
'(' (CopyOption (',' CopyOption)*)? ')'
CopyOption =
CopyOptionName (CopyOptionList | Literal | 'default' | 'on' | 'off' | '*' | '#ident')?
CopyOptionName =
'#name'?
CopyLegacyOption =
'binary'
| 'freeze'
| 'csv'
| 'header'
| 'json'
| ('delimiter' | 'null' | 'quote' | 'escape') 'as'? Literal
| 'encoding' Literal
| 'force' ('not' 'null' | 'quote' | 'null') ('*' | (ColumnNameRef (',' ColumnNameRef)*))
Call =
'call' ProcedureNameRef ArgList ';'?
TriggerEvent =
TriggerEventDelete
| TriggerEventInsert
| TriggerEventTruncate
| TriggerEventUpdate
TriggerEventDelete =
'delete'
TriggerEventInsert =
'insert'
TriggerEventTruncate =
'truncate'
TriggerEventUpdate =
'update'
('of' (ColumnNameRef (',' ColumnNameRef)*))?
Timing =
TimingAfter
| TimingBefore
| TimingInsteadOf
TimingAfter =
'after'
TimingBefore =
'before'
TimingInsteadOf =
'instead' 'of'
TransitionRelationName =
'#name'?
ReferencingTable =
('old' | 'new') 'table' 'as'? TransitionRelationName
Referencing =
'referencing' ReferencingTable*
CreateTrigger =
'create' OrReplace? 'constraint'? 'trigger' Trigger
Timing
TriggerEventList
OnRelation
FromTable?
DeferrableConstraintOption?
NotDeferrableConstraintOption?
InitiallyDeferredConstraintOption?
InitiallyImmediateConstraintOption?
Referencing?
('for' 'each'? ('row' | 'statement'))?
WhenCondition?
'execute' ('function' | 'procedure') CallExpr ';'?
WhenCondition =
'when' '(' Expr ')'
FromTable =
'from' TableNameRef
TriggerEventList =
(TriggerEvent ('or' TriggerEvent)*)
DropSchema =
'drop' 'schema' IfExists? (SchemaRef (',' SchemaRef)*)
('cascade' | 'restrict')? ';'?
CreateSchema =
'create' 'schema' IfNotExists? CreateSchemaTarget SchemaElement* ';'?
CreateSchemaTarget =
AuthorizationSchema
| NamedSchema
NamedSchema =
Schema ('authorization' RoleRef)?
AuthorizationSchema =
'authorization' Role
SchemaElement =
CreateTable
| CreateView
| CreateIndex
| CreateSequence
| CreateTrigger
| Grant
DropTrigger =
'drop' 'trigger' IfExists? TriggerRef OnRelation
('cascade' | 'restrict')? ';'?
OnRelation =
'on' RelationNameRef
OnTable =
'on' TableNameRef
PartitionItem =
Expr
Collate?
OpClassRef?
AttributeList?
(SortAsc | SortDesc | SortUsing)?
(NullsFirst | NullsLast)?
PartitionItemList =
'(' (PartitionItem (',' PartitionItem)*) ')'
CreateType =
'create' 'type' TypeName kind:CreateTypeKind? ';'?
CreateTypeKind =
BaseType
| CompositeType
| EnumType
| RangeType
BaseType =
AttributeList
CompositeType =
'as' CompositeFieldList
CompositeFieldList =
'(' (CompositeFieldDef (',' CompositeFieldDef)*)? ')'
CompositeFieldDef =
name:CompositeField Type? Collate?
EnumType =
'as' 'enum' VariantList
RangeType =
'as' 'range' AttributeList
VariantList =
'('
(Variant (',' Variant)*)
')'
Variant =
Literal
CreateExtension =
'create' 'extension' IfNotExists? Extension
'with'?
('schema' SchemaRef)?
('version' (Literal | '#ident'))?
'cascade'? ';'?
Set =
'set'
('session' | 'local')?
SetTarget? ';'?
SetTarget =
SetCatalog
| SetConfig
| SetSchemaValue
| SetTimeZone
| SetXmlOption
SetXmlOption =
'xml' 'option' ('document' | 'content')
SetTimeZone =
'time' 'zone' (ConfigValue | 'default' | 'local')?
SetCatalog =
'catalog' Literal
SetSchemaValue =
'schema' Literal
SetConfig =
ConfigParameterRef (
'from' 'current'
| (('to' | '=') (ConfigValue* | 'default'))
)
ConfigValue =
Literal
| ConfigValueName
ConfigValueName =
'#name'?
Show =
'show' ShowAction ';'?
ShowAction =
All
| ConfigParameterRef
| SessionAuthorization
| TimeZone
| TransactionIsolationLevel
All =
'all'
SessionAuthorization =
'session' 'authorization'
TransactionIsolationLevel =
'transaction' 'isolation' 'level'
TimeZone =
'time' 'zone'
LanguageFuncOption =
'language' (LanguageRef | Literal)
TransformFuncOption =
'transform' Type*
WindowFuncOption =
'window'
VolatilityFuncOption =
'immutable' | 'stable' | 'volatile'
LeakproofFuncOption =
'leakproof'
NotLeakproofFuncOption =
'not' 'leakproof'
ResetFuncOption =
'reset' ('all' | ConfigParameterRef)
ConfigParameterRef =
PathRef
StrictFuncOption =
'strict'
CalledOnNullInputFuncOption =
'called' 'on' 'null' 'input'
ReturnsNullOnNullInputFuncOption =
'returns' 'null' 'on' 'null' 'input'
SecurityFuncOption =
'security' ('invoker' | 'definer')
ParallelFuncOption =
'parallel' '#ident'
CostFuncOption =
'cost' Literal
RowsFuncOption =
'rows' Literal
SupportFuncOption =
'support' FunctionNameRef
SetFuncOption =
SetConfigParam
AsFuncOption =
'as' (definition:Literal | obj_file:Literal ',' link_symbol:Literal)
ReplicaIdentity =
'replica' 'identity' ('default' | 'full' | 'nothing' | 'using' 'index' IndexRef)
OfType =
'of' Type
NotOf =
'not' 'of'
ForceRls =
'force' 'row' 'level' 'security'
NoForceRls =
'no' 'force' 'row' 'level' 'security'
InheritTable =
'inherit' TableNameRef
NoInheritTable =
'no' 'inherit' TableNameRef
Inherit =
'inherit'
NoInherit =
'no' 'inherit'
EnableTrigger =
'enable' 'trigger' (TriggerRef | 'all' | 'user')?
EnableReplicaTrigger =
'enable' 'replica' 'trigger' TriggerRef
EnableReplicaRule =
'enable' 'replica' 'rule' RuleRef
EnableAlwaysTrigger =
'enable' 'always' 'trigger' TriggerRef
EnableAlwaysRule =
'enable' 'always' 'rule' RuleRef
EnableRule =
'enable' 'rule' RuleRef
EnableRls =
'enable' 'row' 'level' 'security'
DisableTrigger =
'disable' 'trigger' (TriggerRef | 'all' | 'user')?
DisableRls =
'disable' 'row' 'level' 'security'
DisableRule =
'disable' 'rule' RuleRef
ClusterOn =
'cluster' 'on' IndexRef
DetachPartition =
'detach' 'partition'
TableNameRef
('concurrently' | 'finalize')?
MergePartitions =
'merge' 'partitions'
TableNameRefList
'into'?
TableName
SplitPartition =
'split' 'partition' 'into'
PartitionList
PartitionList =
'(' (Partition (',' Partition)*) ')'
Partition =
'partition'
TableNameRef
PartitionType
DropColumn =
'drop' 'column'? IfExists? ColumnNameRef
('restrict' | 'cascade')?
AddColumn =
'add' 'column'? IfNotExists? ColumnName Type Collate? (Constraint (',' Constraint)*)?
PartitionForValuesWith =
'for' 'values' 'with' '(' '#ident' Literal ',' '#ident' Literal ')'
PartitionForValuesIn =
'for' 'values' 'in' '(' (Expr (',' Expr)*) ')'
PartitionForValuesFrom =
'for' 'values' 'from' '(' (Expr (',' Expr)*) ')' 'to' '(' (Expr (',' Expr)*) ')'
PartitionDefault =
'default'
PartitionType =
PartitionForValuesWith
| PartitionForValuesIn
| PartitionForValuesFrom
| PartitionDefault
AttachPartition =
'attach' 'partition' TableNameRef PartitionType
AttachIndexPartition =
'attach' 'partition' IndexRef
SetTablespace =
'set' 'tablespace' TablespaceRef
SetWithoutCluster =
'set' 'without' 'cluster'
SetWithoutOids =
'set' 'without' 'oids'
SetAccessMethod =
'set' 'access' 'method' AccessMethodRef
SetLogged =
'set' 'logged'
SetUnlogged =
'set' 'unlogged'
RenameColumn =
'rename' 'column'? ColumnNameRef 'to' ColumnName
AlterColumnOption =
DropDefault
| DropExpression
| DropIdentity
| DropNotNull
| Restart
| AddGenerated
| ResetOptions
| SetType
| SetOptionsList
| SetGeneratedOptions
| SetGenerated
| SetSequenceOption
| SetDefault
| SetExpression
| SetStatistics
| SetOptions
| SetStorage
| SetCompression
| SetNotNull
| Inherit
| NoInherit
AlterConstraint =
'alter' 'constraint' ConstraintNameRef
DeferrableConstraintOption?
NotDeferrableConstraintOption?
InitiallyDeferredConstraintOption?
InitiallyImmediateConstraintOption?
AlterColumn =
'alter' 'column'? ColumnNameRef option:AlterColumnOption
Restart =
'restart' ('with'? Literal)?
SetSequenceOption =
'set' SequenceOption
SetGenerated =
'set' 'generated' ('always' | 'by' 'default')
DropExpression =
'drop' 'expression' IfExists?
DropIdentity =
'drop' 'identity' IfExists?
AddGenerated =
'add' 'generated' ('always' | 'by' 'default') 'as' 'identity' SequenceOptionList?
ResetOptions =
'reset' AttributeList
SetType =
'set' 'type' Type Collate?
SetGeneratedOptions =
'set' 'generated'
SetOptionsList =
'set' 'options' AlterOptionList
AlterSetStatistics =
'set' 'column'? (Literal | ColumnNameRef)
'set' 'statistics' Literal
SetExpression =
'set' 'expression' Expr
SetStatistics =
'set' 'statistics' ('default' | Literal)
SetOptions =
'set' AttributeList
SetStorage =
'set' 'storage' StorageMode
SetCompression =
'set' 'compression' CompressionMethodName
Collate =
Expr? 'collate' CollationRef
Stmt =
// We merge this into Rollback
// Abort
AlterAggregate
| AlterCollation
| AlterConversion
| AlterDatabase
| AlterDefaultPrivileges
| AlterDomain
| AlterEventTrigger
| AlterExtension
| AlterForeignDataWrapper
| AlterForeignTable
| AlterFunction
| AlterGroup
| AlterIndex
| AlterLanguage
| AlterLargeObject
| AlterMaterializedView
| AlterOperator
| AlterOperatorClass
| AlterOperatorFamily
| AlterPropertyGraph
| AlterPolicy
| AlterProcedure
| AlterPublication
| AlterRole
| AlterRoutine
| AlterRule
| AlterSchema
| AlterSequence
| AlterServer
| AlterStatistics
| AlterSubscription
| AlterSystem
| AlterTable
| AlterTablespace
| AlterTextSearchConfiguration
| AlterTextSearchDictionary
| AlterTextSearchParser
| AlterTextSearchTemplate
| AlterTrigger
| AlterType
| AlterUser
| AlterUserMapping
| AlterView
| Analyze
| Begin
| Call
| Checkpoint
| Close
| Cluster
| CommentOn
| Commit
// Merged into Commit
// | CommitPrepared
| Copy
| CreateAccessMethod
| CreateAggregate
| CreateCast
| CreateCollation
| CreateConversion
| CreateDatabase
| CreateDomain
| CreateEventTrigger
| CreateExtension
| CreateForeignDataWrapper
| CreateForeignTable
| CreateFunction
| CreateGroup
| CreateIndex
| CreateLanguage
| CreateMaterializedView
| CreateOperator
| CreateOperatorClass
| CreateOperatorFamily
| CreatePropertyGraph
| CreatePolicy
| CreateProcedure
| CreatePublication
| CreateRole
| CreateRule
| CreateSchema
| CreateSequence
| CreateServer
| CreateStatistics
| CreateSubscription
| CreateTable
| CreateTableAs
| CreateTablespace
| CreateTextSearchConfiguration
| CreateTextSearchDictionary
| CreateTextSearchParser
| CreateTextSearchTemplate
| CreateTransform
| CreateTrigger
| CreateType
| CreateUser
| CreateUserMapping
| CreateView
| Deallocate
| Declare
| Delete
| Discard
| Do
| DropAccessMethod
| DropAggregate
| DropCast
| DropCollation
| DropConversion
| DropDatabase
| DropDomain
| DropEventTrigger
| DropExtension
| DropForeignDataWrapper
| DropForeignTable
| DropFunction
| DropGroup
| DropIndex
| DropLanguage
| DropMaterializedView
| DropOperator
| DropOperatorClass
| DropOperatorFamily
| DropOwned
| DropPropertyGraph
| DropPolicy
| DropProcedure
| DropPublication
| DropRole
| DropRoutine
| DropRule
| DropSchema
| DropSequence
| DropServer
| DropStatistics
| DropSubscription
| DropTable
| DropTablespace
| DropTextSearchConfig
| DropTextSearchDict
| DropTextSearchParser
| DropTextSearchTemplate
| DropTransform
| DropTrigger
| DropType
| DropUser
| DropUserMapping
| DropView
// Merged into Commit
// | End
| Execute
| Explain
| Fetch
| Grant
| ImportForeignSchema
| Insert
| Listen
| Load
| Lock
| Merge
| Move
| Notify
| Prepare
| PrepareTransaction
| Repack
| Reassign
| Refresh
| Reindex
| ReleaseSavepoint
| Reset
| Revoke
| Rollback
// Merged into Rollback
// | RollbackPrepared
// | RollbackToSavepoint
| SavepointCreate
| SecurityLabel
| Select
| SelectInto
| Set
| SetConstraints
| SetRole
| SetSessionAuth
| ResetRole
| ResetSessionAuth
| SetTransaction
| Show
// We don't include this and instead merge it into Begin
// | StartTransaction
| Table
| Truncate
| Unlisten
| Update
| Vacuum
| Values
| ParenSelect
| EmptyStmt
SourceFile =
Stmt*