feat: support pgsql code completion (#205)

* feat: pgsql: complete sql, upgrade syntax file and complete autoImprove

* feat: pgsql: complete unit test

* feat: pgsql: update unit test for autocomplete

* feat(pgsql: update split's context type ): pgsql: update split's context type

* feat(pgsql: update schema, table, procedure, tablespace, function, view,database's rule name): pgsql

* feat: pgsql: update usualName's rule realize

* feat: pgsql:update funcName's using

---------

Co-authored-by: zhaoge <>
This commit is contained in:
XCynthia 2023-11-15 15:34:42 +08:00 committed by GitHub
parent 2e6d18e7dc
commit cbb1279f9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 36285 additions and 23896 deletions

View File

@ -33,7 +33,7 @@
lexer grammar PostgreSQLLexer; lexer grammar PostgreSQLLexer;
/** /**
* Reference Doc: https://www.postgresql.org/docs/9.3/sql-commands.html * Reference Doc: https://www.postgresql.org/docs/16.1/sql-commands.html
*/ */
// SPECIAL CHARACTERS (4.1.4) // SPECIAL CHARACTERS (4.1.4)
@ -647,6 +647,28 @@ KW_PEFERENCES: 'PEFERENCES';
KW_USAGE: 'USAGE'; KW_USAGE: 'USAGE';
KW_CONNECT: 'CONNECT'; KW_CONNECT: 'CONNECT';
KW_PUBLIC: 'PUBLIC'; KW_PUBLIC: 'PUBLIC';
KW_MERGE: 'MERGE';
KW_MATCHED: 'MATCHED';
KW_BREADTH: 'BREADTH';
KW_DEPTH: 'DEPTH';
KW_UNSAFE: 'UNSAFE';
KW_RESTRICTED: 'RESTRICTED';
KW_SAFE: 'SAFE';
KW_FINALIZE: 'FINALIZE';
KW_MODULUS: 'MODULUS';
KW_REMAINDER: 'REMAINDER';
KW_LOGIN: 'LOGIN';
KW_NOLOGIN: 'NOLOGIN';
KW_REPLICATION: 'REPLICATION';
KW_NOREPLICATION: 'NOREPLICATION';
KW_BYPASSRLS: 'BYPASSRLS';
KW_NOBYPASSRLS: 'NOBYPASSRLS';
KW_PERMISSIVE: 'PERMISSIVE';
KW_RESTRICTIVE: 'RESTRICTIVE';
KW_COMPRESSION: 'COMPRESSION';
KW_PLAIN: 'PLAIN';
KW_EXTENDED: 'EXTENDED';
KW_MAIN: 'MAIN';
// //
// IDENTIFIERS (4.1.1) // IDENTIFIERS (4.1.1)

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -522,48 +522,70 @@ KW_PEFERENCES=521
KW_USAGE=522 KW_USAGE=522
KW_CONNECT=523 KW_CONNECT=523
KW_PUBLIC=524 KW_PUBLIC=524
Identifier=525 KW_MERGE=525
QuotedIdentifier=526 KW_MATCHED=526
UnterminatedQuotedIdentifier=527 KW_BREADTH=527
InvalidQuotedIdentifier=528 KW_DEPTH=528
InvalidUnterminatedQuotedIdentifier=529 KW_UNSAFE=529
UnicodeQuotedIdentifier=530 KW_RESTRICTED=530
UnterminatedUnicodeQuotedIdentifier=531 KW_SAFE=531
InvalidUnicodeQuotedIdentifier=532 KW_FINALIZE=532
InvalidUnterminatedUnicodeQuotedIdentifier=533 KW_MODULUS=533
StringConstant=534 KW_REMAINDER=534
UnterminatedStringConstant=535 KW_LOGIN=535
UnicodeEscapeStringConstant=536 KW_NOLOGIN=536
UnterminatedUnicodeEscapeStringConstant=537 KW_REPLICATION=537
BeginDollarStringConstant=538 KW_NOREPLICATION=538
BinaryStringConstant=539 KW_BYPASSRLS=539
UnterminatedBinaryStringConstant=540 KW_NOBYPASSRLS=540
InvalidBinaryStringConstant=541 KW_PERMISSIVE=541
InvalidUnterminatedBinaryStringConstant=542 KW_RESTRICTIVE=542
HexadecimalStringConstant=543 KW_COMPRESSION=543
UnterminatedHexadecimalStringConstant=544 KW_PLAIN=544
InvalidHexadecimalStringConstant=545 KW_EXTENDED=545
InvalidUnterminatedHexadecimalStringConstant=546 KW_MAIN=546
Integral=547 Identifier=547
NumericFail=548 QuotedIdentifier=548
Numeric=549 UnterminatedQuotedIdentifier=549
PLSQLVARIABLENAME=550 InvalidQuotedIdentifier=550
PLSQLIDENTIFIER=551 InvalidUnterminatedQuotedIdentifier=551
Whitespace=552 UnicodeQuotedIdentifier=552
Newline=553 UnterminatedUnicodeQuotedIdentifier=553
LineComment=554 InvalidUnicodeQuotedIdentifier=554
BlockComment=555 InvalidUnterminatedUnicodeQuotedIdentifier=555
UnterminatedBlockComment=556 StringConstant=556
MetaCommand=557 UnterminatedStringConstant=557
EndMetaCommand=558 UnicodeEscapeStringConstant=558
ErrorCharacter=559 UnterminatedUnicodeEscapeStringConstant=559
EscapeStringConstant=560 BeginDollarStringConstant=560
UnterminatedEscapeStringConstant=561 BinaryStringConstant=561
InvalidEscapeStringConstant=562 UnterminatedBinaryStringConstant=562
InvalidUnterminatedEscapeStringConstant=563 InvalidBinaryStringConstant=563
DollarText=564 InvalidUnterminatedBinaryStringConstant=564
EndDollarStringConstant=565 HexadecimalStringConstant=565
AfterEscapeStringConstantWithNewlineMode_Continued=566 UnterminatedHexadecimalStringConstant=566
InvalidHexadecimalStringConstant=567
InvalidUnterminatedHexadecimalStringConstant=568
Integral=569
NumericFail=570
Numeric=571
PLSQLVARIABLENAME=572
PLSQLIDENTIFIER=573
Whitespace=574
Newline=575
LineComment=576
BlockComment=577
UnterminatedBlockComment=578
MetaCommand=579
EndMetaCommand=580
ErrorCharacter=581
EscapeStringConstant=582
UnterminatedEscapeStringConstant=583
InvalidEscapeStringConstant=584
InvalidUnterminatedEscapeStringConstant=585
DollarText=586
EndDollarStringConstant=587
AfterEscapeStringConstantWithNewlineMode_Continued=588
'$'=1 '$'=1
'('=2 '('=2
')'=3 ')'=3
@ -1086,5 +1108,27 @@ AfterEscapeStringConstantWithNewlineMode_Continued=566
'USAGE'=522 'USAGE'=522
'CONNECT'=523 'CONNECT'=523
'PUBLIC'=524 'PUBLIC'=524
'\\\\'=558 'MERGE'=525
'\''=566 'MATCHED'=526
'BREADTH'=527
'DEPTH'=528
'UNSAFE'=529
'RESTRICTED'=530
'SAFE'=531
'FINALIZE'=532
'MODULUS'=533
'REMAINDER'=534
'LOGIN'=535
'NOLOGIN'=536
'REPLICATION'=537
'NOREPLICATION'=538
'BYPASSRLS'=539
'NOBYPASSRLS'=540
'PERMISSIVE'=541
'RESTRICTIVE'=542
'COMPRESSION'=543
'PLAIN'=544
'EXTENDED'=545
'MAIN'=546
'\\\\'=580
'\''=588

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -522,48 +522,70 @@ KW_PEFERENCES=521
KW_USAGE=522 KW_USAGE=522
KW_CONNECT=523 KW_CONNECT=523
KW_PUBLIC=524 KW_PUBLIC=524
Identifier=525 KW_MERGE=525
QuotedIdentifier=526 KW_MATCHED=526
UnterminatedQuotedIdentifier=527 KW_BREADTH=527
InvalidQuotedIdentifier=528 KW_DEPTH=528
InvalidUnterminatedQuotedIdentifier=529 KW_UNSAFE=529
UnicodeQuotedIdentifier=530 KW_RESTRICTED=530
UnterminatedUnicodeQuotedIdentifier=531 KW_SAFE=531
InvalidUnicodeQuotedIdentifier=532 KW_FINALIZE=532
InvalidUnterminatedUnicodeQuotedIdentifier=533 KW_MODULUS=533
StringConstant=534 KW_REMAINDER=534
UnterminatedStringConstant=535 KW_LOGIN=535
UnicodeEscapeStringConstant=536 KW_NOLOGIN=536
UnterminatedUnicodeEscapeStringConstant=537 KW_REPLICATION=537
BeginDollarStringConstant=538 KW_NOREPLICATION=538
BinaryStringConstant=539 KW_BYPASSRLS=539
UnterminatedBinaryStringConstant=540 KW_NOBYPASSRLS=540
InvalidBinaryStringConstant=541 KW_PERMISSIVE=541
InvalidUnterminatedBinaryStringConstant=542 KW_RESTRICTIVE=542
HexadecimalStringConstant=543 KW_COMPRESSION=543
UnterminatedHexadecimalStringConstant=544 KW_PLAIN=544
InvalidHexadecimalStringConstant=545 KW_EXTENDED=545
InvalidUnterminatedHexadecimalStringConstant=546 KW_MAIN=546
Integral=547 Identifier=547
NumericFail=548 QuotedIdentifier=548
Numeric=549 UnterminatedQuotedIdentifier=549
PLSQLVARIABLENAME=550 InvalidQuotedIdentifier=550
PLSQLIDENTIFIER=551 InvalidUnterminatedQuotedIdentifier=551
Whitespace=552 UnicodeQuotedIdentifier=552
Newline=553 UnterminatedUnicodeQuotedIdentifier=553
LineComment=554 InvalidUnicodeQuotedIdentifier=554
BlockComment=555 InvalidUnterminatedUnicodeQuotedIdentifier=555
UnterminatedBlockComment=556 StringConstant=556
MetaCommand=557 UnterminatedStringConstant=557
EndMetaCommand=558 UnicodeEscapeStringConstant=558
ErrorCharacter=559 UnterminatedUnicodeEscapeStringConstant=559
EscapeStringConstant=560 BeginDollarStringConstant=560
UnterminatedEscapeStringConstant=561 BinaryStringConstant=561
InvalidEscapeStringConstant=562 UnterminatedBinaryStringConstant=562
InvalidUnterminatedEscapeStringConstant=563 InvalidBinaryStringConstant=563
DollarText=564 InvalidUnterminatedBinaryStringConstant=564
EndDollarStringConstant=565 HexadecimalStringConstant=565
AfterEscapeStringConstantWithNewlineMode_Continued=566 UnterminatedHexadecimalStringConstant=566
InvalidHexadecimalStringConstant=567
InvalidUnterminatedHexadecimalStringConstant=568
Integral=569
NumericFail=570
Numeric=571
PLSQLVARIABLENAME=572
PLSQLIDENTIFIER=573
Whitespace=574
Newline=575
LineComment=576
BlockComment=577
UnterminatedBlockComment=578
MetaCommand=579
EndMetaCommand=580
ErrorCharacter=581
EscapeStringConstant=582
UnterminatedEscapeStringConstant=583
InvalidEscapeStringConstant=584
InvalidUnterminatedEscapeStringConstant=585
DollarText=586
EndDollarStringConstant=587
AfterEscapeStringConstantWithNewlineMode_Continued=588
'$'=1 '$'=1
'('=2 '('=2
')'=3 ')'=3
@ -1086,5 +1108,27 @@ AfterEscapeStringConstantWithNewlineMode_Continued=566
'USAGE'=522 'USAGE'=522
'CONNECT'=523 'CONNECT'=523
'PUBLIC'=524 'PUBLIC'=524
'\\\\'=558 'MERGE'=525
'\''=566 'MATCHED'=526
'BREADTH'=527
'DEPTH'=528
'UNSAFE'=529
'RESTRICTED'=530
'SAFE'=531
'FINALIZE'=532
'MODULUS'=533
'REMAINDER'=534
'LOGIN'=535
'NOLOGIN'=536
'REPLICATION'=537
'NOREPLICATION'=538
'BYPASSRLS'=539
'NOBYPASSRLS'=540
'PERMISSIVE'=541
'RESTRICTIVE'=542
'COMPRESSION'=543
'PLAIN'=544
'EXTENDED'=545
'MAIN'=546
'\\\\'=580
'\''=588

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -29,12 +29,16 @@ import { CreateuserstmtContext } from "./PostgreSQLParser";
import { AlterrolestmtContext } from "./PostgreSQLParser"; import { AlterrolestmtContext } from "./PostgreSQLParser";
import { Opt_in_databaseContext } from "./PostgreSQLParser"; import { Opt_in_databaseContext } from "./PostgreSQLParser";
import { AlterrolesetstmtContext } from "./PostgreSQLParser"; import { AlterrolesetstmtContext } from "./PostgreSQLParser";
import { AlterroutinestmtContext } from "./PostgreSQLParser";
import { Alter_routine_cluaseContext } from "./PostgreSQLParser";
import { RoutineActionListContext } from "./PostgreSQLParser";
import { RoutineActionContext } from "./PostgreSQLParser";
import { DroprolestmtContext } from "./PostgreSQLParser"; import { DroprolestmtContext } from "./PostgreSQLParser";
import { CreategroupstmtContext } from "./PostgreSQLParser"; import { CreategroupstmtContext } from "./PostgreSQLParser";
import { AltergroupstmtContext } from "./PostgreSQLParser"; import { AltergroupstmtContext } from "./PostgreSQLParser";
import { Add_dropContext } from "./PostgreSQLParser"; import { Add_dropContext } from "./PostgreSQLParser";
import { CreateschemastmtContext } from "./PostgreSQLParser"; import { CreateschemastmtContext } from "./PostgreSQLParser";
import { OptschemanameContext } from "./PostgreSQLParser"; import { CreateSchemaNameContext } from "./PostgreSQLParser";
import { OptschemaeltlistContext } from "./PostgreSQLParser"; import { OptschemaeltlistContext } from "./PostgreSQLParser";
import { Schema_stmtContext } from "./PostgreSQLParser"; import { Schema_stmtContext } from "./PostgreSQLParser";
import { VariablesetstmtContext } from "./PostgreSQLParser"; import { VariablesetstmtContext } from "./PostgreSQLParser";
@ -62,6 +66,10 @@ import { CheckpointstmtContext } from "./PostgreSQLParser";
import { DiscardstmtContext } from "./PostgreSQLParser"; import { DiscardstmtContext } from "./PostgreSQLParser";
import { AltertablestmtContext } from "./PostgreSQLParser"; import { AltertablestmtContext } from "./PostgreSQLParser";
import { Alter_table_cmdsContext } from "./PostgreSQLParser"; import { Alter_table_cmdsContext } from "./PostgreSQLParser";
import { Partition_bound_specContext } from "./PostgreSQLParser";
import { Partition_bound_cluaseContext } from "./PostgreSQLParser";
import { Partition_bound_chooseContext } from "./PostgreSQLParser";
import { Partition_with_cluaseContext } from "./PostgreSQLParser";
import { Partition_cmdContext } from "./PostgreSQLParser"; import { Partition_cmdContext } from "./PostgreSQLParser";
import { Index_partition_cmdContext } from "./PostgreSQLParser"; import { Index_partition_cmdContext } from "./PostgreSQLParser";
import { Alter_table_cmdContext } from "./PostgreSQLParser"; import { Alter_table_cmdContext } from "./PostgreSQLParser";
@ -108,10 +116,13 @@ import { TypedtableelementlistContext } from "./PostgreSQLParser";
import { TableelementContext } from "./PostgreSQLParser"; import { TableelementContext } from "./PostgreSQLParser";
import { TypedtableelementContext } from "./PostgreSQLParser"; import { TypedtableelementContext } from "./PostgreSQLParser";
import { ColumnDefContext } from "./PostgreSQLParser"; import { ColumnDefContext } from "./PostgreSQLParser";
import { CompressionCluaseContext } from "./PostgreSQLParser";
import { StorageCluaseContext } from "./PostgreSQLParser";
import { ColumnOptionsContext } from "./PostgreSQLParser"; import { ColumnOptionsContext } from "./PostgreSQLParser";
import { ColquallistContext } from "./PostgreSQLParser"; import { ColquallistContext } from "./PostgreSQLParser";
import { ColconstraintContext } from "./PostgreSQLParser"; import { ColconstraintContext } from "./PostgreSQLParser";
import { ColconstraintelemContext } from "./PostgreSQLParser"; import { ColconstraintelemContext } from "./PostgreSQLParser";
import { Nulls_distinctContext } from "./PostgreSQLParser";
import { Generated_whenContext } from "./PostgreSQLParser"; import { Generated_whenContext } from "./PostgreSQLParser";
import { Deferrable_triggerContext } from "./PostgreSQLParser"; import { Deferrable_triggerContext } from "./PostgreSQLParser";
import { Initially_triggerContext } from "./PostgreSQLParser"; import { Initially_triggerContext } from "./PostgreSQLParser";
@ -142,6 +153,7 @@ import { Table_access_method_clauseContext } from "./PostgreSQLParser";
import { OptwithContext } from "./PostgreSQLParser"; import { OptwithContext } from "./PostgreSQLParser";
import { OncommitoptionContext } from "./PostgreSQLParser"; import { OncommitoptionContext } from "./PostgreSQLParser";
import { OpttablespaceContext } from "./PostgreSQLParser"; import { OpttablespaceContext } from "./PostgreSQLParser";
import { Index_paramenters_createContext } from "./PostgreSQLParser";
import { OptconstablespaceContext } from "./PostgreSQLParser"; import { OptconstablespaceContext } from "./PostgreSQLParser";
import { ExistingindexContext } from "./PostgreSQLParser"; import { ExistingindexContext } from "./PostgreSQLParser";
import { CreatestatsstmtContext } from "./PostgreSQLParser"; import { CreatestatsstmtContext } from "./PostgreSQLParser";
@ -207,6 +219,9 @@ import { DropusermappingstmtContext } from "./PostgreSQLParser";
import { AlterusermappingstmtContext } from "./PostgreSQLParser"; import { AlterusermappingstmtContext } from "./PostgreSQLParser";
import { CreatepolicystmtContext } from "./PostgreSQLParser"; import { CreatepolicystmtContext } from "./PostgreSQLParser";
import { AlterpolicystmtContext } from "./PostgreSQLParser"; import { AlterpolicystmtContext } from "./PostgreSQLParser";
import { AlterprocedurestmtContext } from "./PostgreSQLParser";
import { Procedure_cluaseContext } from "./PostgreSQLParser";
import { Procedure_actionContext } from "./PostgreSQLParser";
import { RowsecurityoptionalexprContext } from "./PostgreSQLParser"; import { RowsecurityoptionalexprContext } from "./PostgreSQLParser";
import { RowsecurityoptionalwithcheckContext } from "./PostgreSQLParser"; import { RowsecurityoptionalwithcheckContext } from "./PostgreSQLParser";
import { RowsecuritydefaulttoroleContext } from "./PostgreSQLParser"; import { RowsecuritydefaulttoroleContext } from "./PostgreSQLParser";
@ -273,8 +288,13 @@ import { DropopfamilystmtContext } from "./PostgreSQLParser";
import { DropownedstmtContext } from "./PostgreSQLParser"; import { DropownedstmtContext } from "./PostgreSQLParser";
import { ReassignownedstmtContext } from "./PostgreSQLParser"; import { ReassignownedstmtContext } from "./PostgreSQLParser";
import { DropstmtContext } from "./PostgreSQLParser"; import { DropstmtContext } from "./PostgreSQLParser";
import { DropviewstmtContext } from "./PostgreSQLParser";
import { ViewNameListContext } from "./PostgreSQLParser";
import { DropschemastmtContext } from "./PostgreSQLParser";
import { Object_type_any_name_listContext } from "./PostgreSQLParser";
import { Object_type_any_nameContext } from "./PostgreSQLParser"; import { Object_type_any_nameContext } from "./PostgreSQLParser";
import { Object_type_nameContext } from "./PostgreSQLParser"; import { Object_type_nameContext } from "./PostgreSQLParser";
import { Drop_typeContext } from "./PostgreSQLParser";
import { Drop_type_nameContext } from "./PostgreSQLParser"; import { Drop_type_nameContext } from "./PostgreSQLParser";
import { Object_type_name_on_any_nameContext } from "./PostgreSQLParser"; import { Object_type_name_on_any_nameContext } from "./PostgreSQLParser";
import { Any_name_listContext } from "./PostgreSQLParser"; import { Any_name_listContext } from "./PostgreSQLParser";
@ -331,6 +351,10 @@ import { AttrilistContext } from "./PostgreSQLParser";
import { Opt_or_replaceContext } from "./PostgreSQLParser"; import { Opt_or_replaceContext } from "./PostgreSQLParser";
import { Func_argsContext } from "./PostgreSQLParser"; import { Func_argsContext } from "./PostgreSQLParser";
import { Func_args_listContext } from "./PostgreSQLParser"; import { Func_args_listContext } from "./PostgreSQLParser";
import { Usual_with_argtypes_listContext } from "./PostgreSQLParser";
import { Usual_with_argtypesContext } from "./PostgreSQLParser";
import { Procedure_with_argtypes_listContext } from "./PostgreSQLParser";
import { Procedure_with_argtypesContext } from "./PostgreSQLParser";
import { Function_with_argtypes_listContext } from "./PostgreSQLParser"; import { Function_with_argtypes_listContext } from "./PostgreSQLParser";
import { Function_with_argtypesContext } from "./PostgreSQLParser"; import { Function_with_argtypesContext } from "./PostgreSQLParser";
import { Func_args_with_defaultsContext } from "./PostgreSQLParser"; import { Func_args_with_defaultsContext } from "./PostgreSQLParser";
@ -355,6 +379,7 @@ import { Opt_definitionContext } from "./PostgreSQLParser";
import { Table_func_columnContext } from "./PostgreSQLParser"; import { Table_func_columnContext } from "./PostgreSQLParser";
import { Table_func_column_listContext } from "./PostgreSQLParser"; import { Table_func_column_listContext } from "./PostgreSQLParser";
import { AlterfunctionstmtContext } from "./PostgreSQLParser"; import { AlterfunctionstmtContext } from "./PostgreSQLParser";
import { AlterFunctionTypeClauseContext } from "./PostgreSQLParser";
import { Alterfunc_opt_listContext } from "./PostgreSQLParser"; import { Alterfunc_opt_listContext } from "./PostgreSQLParser";
import { Opt_restrictContext } from "./PostgreSQLParser"; import { Opt_restrictContext } from "./PostgreSQLParser";
import { RemovefuncstmtContext } from "./PostgreSQLParser"; import { RemovefuncstmtContext } from "./PostgreSQLParser";
@ -442,6 +467,7 @@ import { AltertsconfigurationstmtContext } from "./PostgreSQLParser";
import { Any_withContext } from "./PostgreSQLParser"; import { Any_withContext } from "./PostgreSQLParser";
import { CreateconversionstmtContext } from "./PostgreSQLParser"; import { CreateconversionstmtContext } from "./PostgreSQLParser";
import { ClusterstmtContext } from "./PostgreSQLParser"; import { ClusterstmtContext } from "./PostgreSQLParser";
import { Opt_verbose_listContext } from "./PostgreSQLParser";
import { Cluster_index_specificationContext } from "./PostgreSQLParser"; import { Cluster_index_specificationContext } from "./PostgreSQLParser";
import { VacuumstmtContext } from "./PostgreSQLParser"; import { VacuumstmtContext } from "./PostgreSQLParser";
import { AnalyzestmtContext } from "./PostgreSQLParser"; import { AnalyzestmtContext } from "./PostgreSQLParser";
@ -505,6 +531,8 @@ import { Set_operator_with_all_or_distinctContext } from "./PostgreSQLParser";
import { With_clauseContext } from "./PostgreSQLParser"; import { With_clauseContext } from "./PostgreSQLParser";
import { Cte_listContext } from "./PostgreSQLParser"; import { Cte_listContext } from "./PostgreSQLParser";
import { Common_table_exprContext } from "./PostgreSQLParser"; import { Common_table_exprContext } from "./PostgreSQLParser";
import { Search_cluaseContext } from "./PostgreSQLParser";
import { Cycle_cluaseContext } from "./PostgreSQLParser";
import { Opt_materializedContext } from "./PostgreSQLParser"; import { Opt_materializedContext } from "./PostgreSQLParser";
import { Opt_with_clauseContext } from "./PostgreSQLParser"; import { Opt_with_clauseContext } from "./PostgreSQLParser";
import { Into_clauseContext } from "./PostgreSQLParser"; import { Into_clauseContext } from "./PostgreSQLParser";
@ -552,7 +580,9 @@ import { Func_alias_clauseContext } from "./PostgreSQLParser";
import { Join_typeContext } from "./PostgreSQLParser"; import { Join_typeContext } from "./PostgreSQLParser";
import { Join_qualContext } from "./PostgreSQLParser"; import { Join_qualContext } from "./PostgreSQLParser";
import { Relation_exprContext } from "./PostgreSQLParser"; import { Relation_exprContext } from "./PostgreSQLParser";
import { Publication_relation_exprContext } from "./PostgreSQLParser";
import { Relation_expr_listContext } from "./PostgreSQLParser"; import { Relation_expr_listContext } from "./PostgreSQLParser";
import { Publication_relation_expr_listContext } from "./PostgreSQLParser";
import { Relation_expr_opt_aliasContext } from "./PostgreSQLParser"; import { Relation_expr_opt_aliasContext } from "./PostgreSQLParser";
import { Tablesample_clauseContext } from "./PostgreSQLParser"; import { Tablesample_clauseContext } from "./PostgreSQLParser";
import { Opt_repeatable_clauseContext } from "./PostgreSQLParser"; import { Opt_repeatable_clauseContext } from "./PostgreSQLParser";
@ -654,6 +684,8 @@ import { Qual_opContext } from "./PostgreSQLParser";
import { Qual_all_opContext } from "./PostgreSQLParser"; import { Qual_all_opContext } from "./PostgreSQLParser";
import { Subquery_OpContext } from "./PostgreSQLParser"; import { Subquery_OpContext } from "./PostgreSQLParser";
import { Expr_listContext } from "./PostgreSQLParser"; import { Expr_listContext } from "./PostgreSQLParser";
import { Column_expr_listContext } from "./PostgreSQLParser";
import { Column_exprContext } from "./PostgreSQLParser";
import { Func_arg_listContext } from "./PostgreSQLParser"; import { Func_arg_listContext } from "./PostgreSQLParser";
import { Func_arg_exprContext } from "./PostgreSQLParser"; import { Func_arg_exprContext } from "./PostgreSQLParser";
import { Type_listContext } from "./PostgreSQLParser"; import { Type_listContext } from "./PostgreSQLParser";
@ -681,13 +713,32 @@ import { Opt_target_listContext } from "./PostgreSQLParser";
import { Target_listContext } from "./PostgreSQLParser"; import { Target_listContext } from "./PostgreSQLParser";
import { Target_elContext } from "./PostgreSQLParser"; import { Target_elContext } from "./PostgreSQLParser";
import { Qualified_name_listContext } from "./PostgreSQLParser"; import { Qualified_name_listContext } from "./PostgreSQLParser";
import { Table_qualified_nameContext } from "./PostgreSQLParser"; import { TableNameListContext } from "./PostgreSQLParser";
import { SchemaNameListContext } from "./PostgreSQLParser";
import { DatabaseNameListContext } from "./PostgreSQLParser";
import { ProcedureNameListContext } from "./PostgreSQLParser";
import { CreateTablespaceNameContext } from "./PostgreSQLParser";
import { TablespaceNameContext } from "./PostgreSQLParser";
import { CreateTableNameContext } from "./PostgreSQLParser";
import { TableNameContext } from "./PostgreSQLParser";
import { CreateViewNameContext } from "./PostgreSQLParser";
import { ViewNameContext } from "./PostgreSQLParser";
import { Qualified_nameContext } from "./PostgreSQLParser"; import { Qualified_nameContext } from "./PostgreSQLParser";
import { Tablespace_name_listContext } from "./PostgreSQLParser";
import { Name_listContext } from "./PostgreSQLParser"; import { Name_listContext } from "./PostgreSQLParser";
import { CreateDatabaseNameContext } from "./PostgreSQLParser";
import { DatabaseNameContext } from "./PostgreSQLParser";
import { SchemaNameContext } from "./PostgreSQLParser";
import { CreateRoutineNameContext } from "./PostgreSQLParser";
import { RoutineNameContext } from "./PostgreSQLParser";
import { ProcedureNameContext } from "./PostgreSQLParser";
import { CreateProcedureNameContext } from "./PostgreSQLParser";
import { NameContext } from "./PostgreSQLParser"; import { NameContext } from "./PostgreSQLParser";
import { Attr_nameContext } from "./PostgreSQLParser"; import { Attr_nameContext } from "./PostgreSQLParser";
import { File_nameContext } from "./PostgreSQLParser"; import { File_nameContext } from "./PostgreSQLParser";
import { Func_nameContext } from "./PostgreSQLParser"; import { CreateFuncNameContext } from "./PostgreSQLParser";
import { FuncNameContext } from "./PostgreSQLParser";
import { UsualNameContext } from "./PostgreSQLParser";
import { AexprconstContext } from "./PostgreSQLParser"; import { AexprconstContext } from "./PostgreSQLParser";
import { XconstContext } from "./PostgreSQLParser"; import { XconstContext } from "./PostgreSQLParser";
import { BconstContext } from "./PostgreSQLParser"; import { BconstContext } from "./PostgreSQLParser";
@ -707,6 +758,7 @@ import { Exclude_elementContext } from "./PostgreSQLParser";
import { Index_paramentersContext } from "./PostgreSQLParser"; import { Index_paramentersContext } from "./PostgreSQLParser";
import { WherePredicateContext } from "./PostgreSQLParser"; import { WherePredicateContext } from "./PostgreSQLParser";
import { Type_function_nameContext } from "./PostgreSQLParser"; import { Type_function_nameContext } from "./PostgreSQLParser";
import { Type_usual_nameContext } from "./PostgreSQLParser";
import { NonreservedwordContext } from "./PostgreSQLParser"; import { NonreservedwordContext } from "./PostgreSQLParser";
import { CollabelContext } from "./PostgreSQLParser"; import { CollabelContext } from "./PostgreSQLParser";
import { IdentifierContext } from "./PostgreSQLParser"; import { IdentifierContext } from "./PostgreSQLParser";
@ -804,6 +856,14 @@ import { Into_targetContext } from "./PostgreSQLParser";
import { Opt_cursor_fromContext } from "./PostgreSQLParser"; import { Opt_cursor_fromContext } from "./PostgreSQLParser";
import { Opt_fetch_directionContext } from "./PostgreSQLParser"; import { Opt_fetch_directionContext } from "./PostgreSQLParser";
import { Stmt_moveContext } from "./PostgreSQLParser"; import { Stmt_moveContext } from "./PostgreSQLParser";
import { MergestmtContext } from "./PostgreSQLParser";
import { Data_sourceContext } from "./PostgreSQLParser";
import { Join_conditionContext } from "./PostgreSQLParser";
import { Merge_when_clauseContext } from "./PostgreSQLParser";
import { Merge_insertContext } from "./PostgreSQLParser";
import { Merge_updateContext } from "./PostgreSQLParser";
import { ExprofdefaultlistContext } from "./PostgreSQLParser";
import { ExprofdefaultContext } from "./PostgreSQLParser";
import { Stmt_closeContext } from "./PostgreSQLParser"; import { Stmt_closeContext } from "./PostgreSQLParser";
import { Stmt_nullContext } from "./PostgreSQLParser"; import { Stmt_nullContext } from "./PostgreSQLParser";
import { Stmt_commitContext } from "./PostgreSQLParser"; import { Stmt_commitContext } from "./PostgreSQLParser";
@ -1031,6 +1091,34 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitAlterrolesetstmt?: (ctx: AlterrolesetstmtContext) => Result; visitAlterrolesetstmt?: (ctx: AlterrolesetstmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.alterroutinestmt`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAlterroutinestmt?: (ctx: AlterroutinestmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.alter_routine_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAlter_routine_cluase?: (ctx: Alter_routine_cluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.routineActionList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitRoutineActionList?: (ctx: RoutineActionListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.routineAction`.
* @param ctx the parse tree
* @return the visitor result
*/
visitRoutineAction?: (ctx: RoutineActionContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.droprolestmt`. * Visit a parse tree produced by `PostgreSQLParser.droprolestmt`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1067,11 +1155,11 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
visitCreateschemastmt?: (ctx: CreateschemastmtContext) => Result; visitCreateschemastmt?: (ctx: CreateschemastmtContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.optschemaname`. * Visit a parse tree produced by `PostgreSQLParser.createSchemaName`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitOptschemaname?: (ctx: OptschemanameContext) => Result; visitCreateSchemaName?: (ctx: CreateSchemaNameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.optschemaeltlist`. * Visit a parse tree produced by `PostgreSQLParser.optschemaeltlist`.
@ -1262,6 +1350,34 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitAlter_table_cmds?: (ctx: Alter_table_cmdsContext) => Result; visitAlter_table_cmds?: (ctx: Alter_table_cmdsContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.partition_bound_spec`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPartition_bound_spec?: (ctx: Partition_bound_specContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.partition_bound_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPartition_bound_cluase?: (ctx: Partition_bound_cluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.partition_bound_choose`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPartition_bound_choose?: (ctx: Partition_bound_chooseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.partition_with_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPartition_with_cluase?: (ctx: Partition_with_cluaseContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.partition_cmd`. * Visit a parse tree produced by `PostgreSQLParser.partition_cmd`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1584,6 +1700,20 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitColumnDef?: (ctx: ColumnDefContext) => Result; visitColumnDef?: (ctx: ColumnDefContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.compressionCluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCompressionCluase?: (ctx: CompressionCluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.storageCluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitStorageCluase?: (ctx: StorageCluaseContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.columnOptions`. * Visit a parse tree produced by `PostgreSQLParser.columnOptions`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1612,6 +1742,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitColconstraintelem?: (ctx: ColconstraintelemContext) => Result; visitColconstraintelem?: (ctx: ColconstraintelemContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.nulls_distinct`.
* @param ctx the parse tree
* @return the visitor result
*/
visitNulls_distinct?: (ctx: Nulls_distinctContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.generated_when`. * Visit a parse tree produced by `PostgreSQLParser.generated_when`.
* @param ctx the parse tree * @param ctx the parse tree
@ -1822,6 +1959,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitOpttablespace?: (ctx: OpttablespaceContext) => Result; visitOpttablespace?: (ctx: OpttablespaceContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.index_paramenters_create`.
* @param ctx the parse tree
* @return the visitor result
*/
visitIndex_paramenters_create?: (ctx: Index_paramenters_createContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.optconstablespace`. * Visit a parse tree produced by `PostgreSQLParser.optconstablespace`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2277,6 +2421,27 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitAlterpolicystmt?: (ctx: AlterpolicystmtContext) => Result; visitAlterpolicystmt?: (ctx: AlterpolicystmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.alterprocedurestmt`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAlterprocedurestmt?: (ctx: AlterprocedurestmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedure_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedure_cluase?: (ctx: Procedure_cluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedure_action`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedure_action?: (ctx: Procedure_actionContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.rowsecurityoptionalexpr`. * Visit a parse tree produced by `PostgreSQLParser.rowsecurityoptionalexpr`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2739,6 +2904,34 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitDropstmt?: (ctx: DropstmtContext) => Result; visitDropstmt?: (ctx: DropstmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.dropviewstmt`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDropviewstmt?: (ctx: DropviewstmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.viewNameList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitViewNameList?: (ctx: ViewNameListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.dropschemastmt`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDropschemastmt?: (ctx: DropschemastmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.object_type_any_name_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitObject_type_any_name_list?: (ctx: Object_type_any_name_listContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.object_type_any_name`. * Visit a parse tree produced by `PostgreSQLParser.object_type_any_name`.
* @param ctx the parse tree * @param ctx the parse tree
@ -2753,6 +2946,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitObject_type_name?: (ctx: Object_type_nameContext) => Result; visitObject_type_name?: (ctx: Object_type_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.drop_type`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDrop_type?: (ctx: Drop_typeContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.drop_type_name`. * Visit a parse tree produced by `PostgreSQLParser.drop_type_name`.
* @param ctx the parse tree * @param ctx the parse tree
@ -3145,6 +3345,34 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitFunc_args_list?: (ctx: Func_args_listContext) => Result; visitFunc_args_list?: (ctx: Func_args_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.usual_with_argtypes_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitUsual_with_argtypes_list?: (ctx: Usual_with_argtypes_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.usual_with_argtypes`.
* @param ctx the parse tree
* @return the visitor result
*/
visitUsual_with_argtypes?: (ctx: Usual_with_argtypesContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedure_with_argtypes_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedure_with_argtypes_list?: (ctx: Procedure_with_argtypes_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedure_with_argtypes`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedure_with_argtypes?: (ctx: Procedure_with_argtypesContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.function_with_argtypes_list`. * Visit a parse tree produced by `PostgreSQLParser.function_with_argtypes_list`.
* @param ctx the parse tree * @param ctx the parse tree
@ -3313,6 +3541,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitAlterfunctionstmt?: (ctx: AlterfunctionstmtContext) => Result; visitAlterfunctionstmt?: (ctx: AlterfunctionstmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.alterFunctionTypeClause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitAlterFunctionTypeClause?: (ctx: AlterFunctionTypeClauseContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.alterfunc_opt_list`. * Visit a parse tree produced by `PostgreSQLParser.alterfunc_opt_list`.
* @param ctx the parse tree * @param ctx the parse tree
@ -3922,6 +4157,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitClusterstmt?: (ctx: ClusterstmtContext) => Result; visitClusterstmt?: (ctx: ClusterstmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.opt_verbose_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitOpt_verbose_list?: (ctx: Opt_verbose_listContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.cluster_index_specification`. * Visit a parse tree produced by `PostgreSQLParser.cluster_index_specification`.
* @param ctx the parse tree * @param ctx the parse tree
@ -4363,6 +4605,20 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitCommon_table_expr?: (ctx: Common_table_exprContext) => Result; visitCommon_table_expr?: (ctx: Common_table_exprContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.search_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitSearch_cluase?: (ctx: Search_cluaseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.cycle_cluase`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCycle_cluase?: (ctx: Cycle_cluaseContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.opt_materialized`. * Visit a parse tree produced by `PostgreSQLParser.opt_materialized`.
* @param ctx the parse tree * @param ctx the parse tree
@ -4692,6 +4948,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitRelation_expr?: (ctx: Relation_exprContext) => Result; visitRelation_expr?: (ctx: Relation_exprContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.publication_relation_expr`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPublication_relation_expr?: (ctx: Publication_relation_exprContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.relation_expr_list`. * Visit a parse tree produced by `PostgreSQLParser.relation_expr_list`.
* @param ctx the parse tree * @param ctx the parse tree
@ -4699,6 +4962,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitRelation_expr_list?: (ctx: Relation_expr_listContext) => Result; visitRelation_expr_list?: (ctx: Relation_expr_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.publication_relation_expr_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitPublication_relation_expr_list?: (ctx: Publication_relation_expr_listContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.relation_expr_opt_alias`. * Visit a parse tree produced by `PostgreSQLParser.relation_expr_opt_alias`.
* @param ctx the parse tree * @param ctx the parse tree
@ -5406,6 +5676,20 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitExpr_list?: (ctx: Expr_listContext) => Result; visitExpr_list?: (ctx: Expr_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_expr_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_expr_list?: (ctx: Column_expr_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.column_expr`.
* @param ctx the parse tree
* @return the visitor result
*/
visitColumn_expr?: (ctx: Column_exprContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.func_arg_list`. * Visit a parse tree produced by `PostgreSQLParser.func_arg_list`.
* @param ctx the parse tree * @param ctx the parse tree
@ -5596,11 +5880,74 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
visitQualified_name_list?: (ctx: Qualified_name_listContext) => Result; visitQualified_name_list?: (ctx: Qualified_name_listContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.table_qualified_name`. * Visit a parse tree produced by `PostgreSQLParser.tableNameList`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitTable_qualified_name?: (ctx: Table_qualified_nameContext) => Result; visitTableNameList?: (ctx: TableNameListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.schemaNameList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitSchemaNameList?: (ctx: SchemaNameListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.databaseNameList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDatabaseNameList?: (ctx: DatabaseNameListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedureNameList`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedureNameList?: (ctx: ProcedureNameListContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createTablespaceName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateTablespaceName?: (ctx: CreateTablespaceNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.tablespaceName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTablespaceName?: (ctx: TablespaceNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createTableName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateTableName?: (ctx: CreateTableNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.tableName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTableName?: (ctx: TableNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createViewName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateViewName?: (ctx: CreateViewNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.viewName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitViewName?: (ctx: ViewNameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.qualified_name`. * Visit a parse tree produced by `PostgreSQLParser.qualified_name`.
@ -5609,6 +5956,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitQualified_name?: (ctx: Qualified_nameContext) => Result; visitQualified_name?: (ctx: Qualified_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.tablespace_name_list`.
* @param ctx the parse tree
* @return the visitor result
*/
visitTablespace_name_list?: (ctx: Tablespace_name_listContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.name_list`. * Visit a parse tree produced by `PostgreSQLParser.name_list`.
* @param ctx the parse tree * @param ctx the parse tree
@ -5616,6 +5970,55 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitName_list?: (ctx: Name_listContext) => Result; visitName_list?: (ctx: Name_listContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createDatabaseName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateDatabaseName?: (ctx: CreateDatabaseNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.databaseName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitDatabaseName?: (ctx: DatabaseNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.schemaName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitSchemaName?: (ctx: SchemaNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createRoutineName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateRoutineName?: (ctx: CreateRoutineNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.routineName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitRoutineName?: (ctx: RoutineNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.procedureName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitProcedureName?: (ctx: ProcedureNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.createProcedureName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitCreateProcedureName?: (ctx: CreateProcedureNameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.name`. * Visit a parse tree produced by `PostgreSQLParser.name`.
* @param ctx the parse tree * @param ctx the parse tree
@ -5638,11 +6041,25 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
visitFile_name?: (ctx: File_nameContext) => Result; visitFile_name?: (ctx: File_nameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.func_name`. * Visit a parse tree produced by `PostgreSQLParser.createFuncName`.
* @param ctx the parse tree * @param ctx the parse tree
* @return the visitor result * @return the visitor result
*/ */
visitFunc_name?: (ctx: Func_nameContext) => Result; visitCreateFuncName?: (ctx: CreateFuncNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.funcName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitFuncName?: (ctx: FuncNameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.usualName`.
* @param ctx the parse tree
* @return the visitor result
*/
visitUsualName?: (ctx: UsualNameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.aexprconst`. * Visit a parse tree produced by `PostgreSQLParser.aexprconst`.
@ -5777,6 +6194,13 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitType_function_name?: (ctx: Type_function_nameContext) => Result; visitType_function_name?: (ctx: Type_function_nameContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.type_usual_name`.
* @param ctx the parse tree
* @return the visitor result
*/
visitType_usual_name?: (ctx: Type_usual_nameContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.nonreservedword`. * Visit a parse tree produced by `PostgreSQLParser.nonreservedword`.
* @param ctx the parse tree * @param ctx the parse tree
@ -6456,6 +6880,62 @@ export interface PostgreSQLParserVisitor<Result> extends ParseTreeVisitor<Result
*/ */
visitStmt_move?: (ctx: Stmt_moveContext) => Result; visitStmt_move?: (ctx: Stmt_moveContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.mergestmt`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMergestmt?: (ctx: MergestmtContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.data_source`.
* @param ctx the parse tree
* @return the visitor result
*/
visitData_source?: (ctx: Data_sourceContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.join_condition`.
* @param ctx the parse tree
* @return the visitor result
*/
visitJoin_condition?: (ctx: Join_conditionContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.merge_when_clause`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMerge_when_clause?: (ctx: Merge_when_clauseContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.merge_insert`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMerge_insert?: (ctx: Merge_insertContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.merge_update`.
* @param ctx the parse tree
* @return the visitor result
*/
visitMerge_update?: (ctx: Merge_updateContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.exprofdefaultlist`.
* @param ctx the parse tree
* @return the visitor result
*/
visitExprofdefaultlist?: (ctx: ExprofdefaultlistContext) => Result;
/**
* Visit a parse tree produced by `PostgreSQLParser.exprofdefault`.
* @param ctx the parse tree
* @return the visitor result
*/
visitExprofdefault?: (ctx: ExprofdefaultContext) => Result;
/** /**
* Visit a parse tree produced by `PostgreSQLParser.stmt_close`. * Visit a parse tree produced by `PostgreSQLParser.stmt_close`.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -33,6 +33,10 @@ export enum SyntaxContextType {
FUNCTION = 'function', FUNCTION = 'function',
/** function name that will be created */ /** function name that will be created */
FUNCTION_CREATE = 'functionCreate', FUNCTION_CREATE = 'functionCreate',
/** procedure name */
PROCEDURE = 'procedure',
/** procedure name that will be created */
PROCEDURE_CREATE = 'procedureCreate',
} }
export interface WordRange { export interface WordRange {

View File

@ -1,9 +1,10 @@
import { Token } from 'antlr4ts'; import { Token } from 'antlr4ts';
import { CandidatesCollection } from 'antlr4-c3'; import { CandidatesCollection } from 'antlr4-c3';
import { PostgreSQLLexer } from '../lib/pgsql/PostgreSQLLexer'; import { PostgreSQLLexer } from '../lib/pgsql/PostgreSQLLexer';
import { PostgreSQLParser, ProgramContext } from '../lib/pgsql/PostgreSQLParser'; import { PostgreSQLParser, ProgramContext, StmtContext } from '../lib/pgsql/PostgreSQLParser';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
import { Suggestions } from './common/basic-parser-types'; import { PostgreSQLParserListener } from '../lib/pgsql/PostgreSQLParserListener';
import { SyntaxContextType, Suggestions, SyntaxSuggestion } from './common/basic-parser-types';
export default class PostgresSQL extends BasicParser< export default class PostgresSQL extends BasicParser<
PostgreSQLLexer, PostgreSQLLexer,
@ -19,20 +20,131 @@ export default class PostgresSQL extends BasicParser<
return new PostgreSQLParser(tokenStream); return new PostgreSQLParser(tokenStream);
} }
protected preferredRules: Set<number> = new Set(); protected preferredRules: Set<number> = new Set([
PostgreSQLParser.RULE_createTableName, // table name
PostgreSQLParser.RULE_tableName, // table name that will be created
PostgreSQLParser.RULE_funcName, // function name
PostgreSQLParser.RULE_createFuncName, // function name that will be created
PostgreSQLParser.RULE_createSchemaName, // schema name that will be created
PostgreSQLParser.RULE_schemaName, // schema name
PostgreSQLParser.RULE_createViewName, // view name that will be created
PostgreSQLParser.RULE_viewName, // view name
PostgreSQLParser.RULE_createDatabaseName, // database name that will be created
PostgreSQLParser.RULE_databaseName, // database name
PostgreSQLParser.RULE_createProcedureName, // procedure name that will be created
PostgreSQLParser.RULE_procedureName, // procedure name
]);
protected get splitListener() { protected get splitListener() {
return null as any; return new PgSqlSplitListener();
} }
protected processCandidates( protected processCandidates(
candidates: CandidatesCollection, candidates: CandidatesCollection,
allTokens: Token[], allTokens: Token[],
caretTokenIndex: number caretTokenIndex: number,
tokenIndexOffset: number
): Suggestions<Token> { ): Suggestions<Token> {
const originalSyntaxSuggestions: SyntaxSuggestion<Token>[] = [];
const keywords: string[] = [];
for (let candidate of candidates.rules) {
const [ruleType, candidateRule] = candidate;
const startTokenIndex = candidateRule.startTokenIndex + tokenIndexOffset;
const tokenRanges = allTokens.slice(
startTokenIndex,
caretTokenIndex + tokenIndexOffset + 1
);
let syntaxContextType: SyntaxContextType;
switch (ruleType) {
case PostgreSQLParser.RULE_createTableName: {
syntaxContextType = SyntaxContextType.TABLE_CREATE;
break;
}
case PostgreSQLParser.RULE_tableName: {
syntaxContextType = SyntaxContextType.TABLE;
break;
}
case PostgreSQLParser.RULE_createFuncName: {
syntaxContextType = SyntaxContextType.FUNCTION_CREATE;
break;
}
case PostgreSQLParser.RULE_funcName: {
syntaxContextType = SyntaxContextType.FUNCTION;
break;
}
case PostgreSQLParser.RULE_createSchemaName: {
syntaxContextType = SyntaxContextType.DATABASE_CREATE;
break;
}
case PostgreSQLParser.RULE_schemaName: {
syntaxContextType = SyntaxContextType.DATABASE;
break;
}
case PostgreSQLParser.RULE_createViewName: {
syntaxContextType = SyntaxContextType.VIEW_CREATE;
break;
}
case PostgreSQLParser.RULE_viewName: {
syntaxContextType = SyntaxContextType.VIEW;
break;
}
case PostgreSQLParser.RULE_createDatabaseName: {
syntaxContextType = SyntaxContextType.DATABASE_CREATE;
break;
}
case PostgreSQLParser.RULE_databaseName: {
syntaxContextType = SyntaxContextType.DATABASE;
break;
}
case PostgreSQLParser.RULE_createProcedureName: {
syntaxContextType = SyntaxContextType.PROCEDURE_CREATE;
break;
}
case PostgreSQLParser.RULE_procedureName: {
syntaxContextType = SyntaxContextType.PROCEDURE;
break;
}
default:
break;
}
if (syntaxContextType) {
originalSyntaxSuggestions.push({
syntaxContextType,
wordRanges: tokenRanges,
});
}
}
for (let candidate of candidates.tokens) {
const symbolicName = this._parser.vocabulary.getSymbolicName(candidate[0]);
const displayName = this._parser.vocabulary.getDisplayName(candidate[0]);
if (symbolicName && symbolicName.startsWith('KW_')) {
const keyword =
displayName.startsWith("'") && displayName.endsWith("'")
? displayName.slice(1, -1)
: displayName;
keywords.push(keyword);
}
}
return { return {
syntax: [], syntax: originalSyntaxSuggestions,
keywords: [], keywords,
}; };
} }
} }
export class PgSqlSplitListener implements PostgreSQLParserListener {
private _statementContext: ProgramContext[] = [];
enterProgram = (ctx: ProgramContext) => {
this._statementContext.push(ctx);
};
exitProgram = (ctx: ProgramContext) => {};
get statementsContext() {
return this._statementContext;
}
}

View File

@ -0,0 +1,31 @@
CREATE TABLE db. ();
INSERT INTO db.tb ;
SELECT * FROM db. ;
ALTER TABLE db ;
CREATE OR REPLACE VIEW db.v;
ALTER VIEW db.v ;
DROP VIEW db. ;
CREATE FUNCTION fn1;
DROP FUNCTION fn1;
CREATE DATABASE db;
DROP DATABASE db ;
ALTER DATABASE db ;
CREATE SCHEMA IF NOT EXISTS schema_name;
DROP SCHEMA IF EXISTS sch;
ALTER SCHEMA name RENAME TO new_name;

View File

@ -0,0 +1,12 @@
DROP ;
ALTER ;
INSERT ;
DELETE ;
CREATE ;

View File

@ -0,0 +1,275 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition, SyntaxContextType } from '../../../../src/parser/common/basic-parser-types';
import PgSQL from '../../../../src/parser/pgsql';
import { commentOtherLine } from '../../../helper';
const syntaxSql = fs.readFileSync(
path.join(__dirname, 'fixtures', 'syntaxSuggestion.sql'),
'utf-8'
);
describe('Postgre SQL Syntax Suggestion', () => {
const parser = new PgSQL();
test('Validate Syntax SQL', () => {
expect(parser.validate(syntaxSql).length).not.toBe(0);
expect(parser.validate(syntaxSql).length).not.toBe(0);
expect(parser.validate(syntaxSql).length).not.toBe(0);
});
test('Insert table ', () => {
const pos: CaretPosition = {
lineNumber: 3,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
});
test('Alter table ', () => {
const pos: CaretPosition = {
lineNumber: 7,
column: 15,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db']);
});
test('Select table ', () => {
const pos: CaretPosition = {
lineNumber: 5,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
});
test('Create table ', () => {
const pos: CaretPosition = {
lineNumber: 1,
column: 17,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.TABLE_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
});
test('Create view ', () => {
const pos: CaretPosition = {
lineNumber: 9,
column: 28,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'v']);
});
test('Drop view ', () => {
const pos: CaretPosition = {
lineNumber: 13,
column: 14,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
});
test('Alter view ', () => {
const pos: CaretPosition = {
lineNumber: 11,
column: 16,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.VIEW
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'v']);
});
test('Create function ', () => {
const pos: CaretPosition = {
lineNumber: 15,
column: 20,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['fn1']);
});
test('Drop function', () => {
const pos: CaretPosition = {
lineNumber: 17,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.FUNCTION
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['fn1']);
});
test('Create database', () => {
const pos: CaretPosition = {
lineNumber: 19,
column: 19,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db']);
});
test('Drop database', () => {
const pos: CaretPosition = {
lineNumber: 21,
column: 17,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db']);
});
test('Alter database', () => {
const pos: CaretPosition = {
lineNumber: 23,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db']);
});
test('Create schema', () => {
const pos: CaretPosition = {
lineNumber: 25,
column: 40,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE_CREATE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['schema_name']);
});
test('Drop schema', () => {
const pos: CaretPosition = {
lineNumber: 27,
column: 26,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['sch']);
});
test('Alter schema', () => {
const pos: CaretPosition = {
lineNumber: 29,
column: 18,
};
const syntaxes = parser.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos.lineNumber),
pos
)?.syntax;
const suggestion = syntaxes?.find(
(syn) => syn.syntaxContextType === SyntaxContextType.DATABASE
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['name']);
});
});

View File

@ -0,0 +1,193 @@
import fs from 'fs';
import path from 'path';
import { CaretPosition } from '../../../../src/parser/common/basic-parser-types';
import PostgresSQL from '../../../../src/parser/pgsql';
import { commentOtherLine } from '../../../helper';
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
describe('Postgres SQL Token Suggestion', () => {
const parser = new PostgresSQL();
test('After ALTER', () => {
const pos: CaretPosition = {
lineNumber: 3,
column: 7,
};
const suggestion = parser.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
'TYPE',
'TEXT',
'STATISTICS',
'TABLESPACE',
'USER',
'ROLE',
'EVENT',
'TRIGGER',
'RULE',
'FOREIGN',
'TABLE',
'MATERIALIZED',
'VIEW',
'INDEX',
'SEQUENCE',
'SUBSCRIPTION',
'SERVER',
'SCHEMA',
'ROUTINE',
'PUBLICATION',
'PROCEDURE',
'POLICY',
'OPERATOR',
'LANGUAGE',
'PROCEDURAL',
'GROUP',
'FUNCTION',
'DOMAIN',
'DATABASE',
'CONVERSION',
'COLLATION',
'AGGREGATE',
'SYSTEM',
'LARGE',
'EXTENSION',
'DEFAULT',
]);
});
test('After CREATE', () => {
const pos: CaretPosition = {
lineNumber: 9,
column: 8,
};
const suggestion = parser.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
'RECURSIVE',
'VIEW',
'TEMPORARY',
'TEMP',
'LOCAL',
'GLOBAL',
'UNLOGGED',
'OR',
'RULE',
'INDEX',
'UNIQUE',
'TABLE',
'COLLATION',
'TEXT',
'TYPE',
'OPERATOR',
'AGGREGATE',
'DATABASE',
'USER',
'ROLE',
'EVENT',
'TRIGGER',
'CONSTRAINT',
'TRANSFORM',
'TABLESPACE',
'STATISTICS',
'SUBSCRIPTION',
'SEQUENCE',
'SCHEMA',
'LANGUAGE',
'PROCEDURAL',
'TRUSTED',
'POLICY',
'PUBLICATION',
'MATERIALIZED',
'GROUP',
'PROCEDURE',
'FUNCTION',
'FOREIGN',
'SERVER',
'EXTENSION',
'DOMAIN',
'CONVERSION',
'DEFAULT',
'CAST',
'ASSERTION',
'ACCESS',
]);
});
test('After DELETE', () => {
const pos: CaretPosition = {
lineNumber: 7,
column: 8,
};
const suggestion = parser.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['FROM']);
});
test('After DROP', () => {
const pos: CaretPosition = {
lineNumber: 1,
column: 6,
};
const suggestion = parser.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual([
'OPERATOR',
'ROUTINE',
'PROCEDURE',
'FUNCTION',
'AGGREGATE',
'DATABASE',
'USER',
'GROUP',
'ROLE',
'TRANSFORM',
'TABLESPACE',
'SUBSCRIPTION',
'INDEX',
'DOMAIN',
'TYPE',
'RULE',
'TRIGGER',
'POLICY',
'SCHEMA',
'ACCESS',
'EVENT',
'EXTENSION',
'FOREIGN',
'PROCEDURAL',
'LANGUAGE',
'PUBLICATION',
'SERVER',
'TABLE',
'SEQUENCE',
'VIEW',
'MATERIALIZED',
'COLLATION',
'CONVERSION',
'STATISTICS',
'TEXT',
'OWNED',
'CAST',
]);
});
test('After INSERT', () => {
const pos: CaretPosition = {
lineNumber: 5,
column: 8,
};
const suggestion = parser.getSuggestionAtCaretPosition(
commentOtherLine(tokenSql, pos.lineNumber),
pos
)?.keywords;
expect(suggestion).toEqual(['INTO']);
});
});

View File

@ -58,11 +58,15 @@ ALTER CONVERSION name SET SCHEMA new_schema;
ALTER DATABASE name WITH CONNECTION LIMIT connlimit; ALTER DATABASE name WITH CONNECTION LIMIT connlimit;
ALTER DATABASE name RENAME TO new_name; ALTER DATABASE name RENAME TO new_name;
ALTER DATABASE name OWNER TO new_owner; ALTER DATABASE name OWNER TO new_owner;
ALTER DATABASE name OWNER TO CURRENT_ROLE;
ALTER DATABASE name OWNER TO CURRENT_USER;
ALTER DATABASE name OWNER TO SESSION_USER;
ALTER DATABASE name SET TABLESPACE new_tablespace; ALTER DATABASE name SET TABLESPACE new_tablespace;
ALTER DATABASE name SET configuration_parameter TO DEFAULT; ALTER DATABASE name SET configuration_parameter TO DEFAULT;
ALTER DATABASE name SET configuration_parameter FROM CURRENT; ALTER DATABASE name SET configuration_parameter FROM CURRENT;
ALTER DATABASE name RESET configuration_parameter; ALTER DATABASE name RESET configuration_parameter;
ALTER DATABASE name RESET ALL; ALTER DATABASE name RESET ALL;
ALTER DATABASE name;
-- ALTER DEFAULT PRIVILEGES -- ALTER DEFAULT PRIVILEGES
ALTER DEFAULT PRIVILEGES ALTER DEFAULT PRIVILEGES
@ -164,10 +168,20 @@ ALTER INDEX IF EXISTS name RENAME TO new_name;
ALTER INDEX IF EXISTS name SET TABLESPACE tablespace_name; ALTER INDEX IF EXISTS name SET TABLESPACE tablespace_name;
ALTER INDEX IF EXISTS name SET ( storage_parameter = value2 ); ALTER INDEX IF EXISTS name SET ( storage_parameter = value2 );
ALTER INDEX IF EXISTS name RESET ( storage_parameter ); ALTER INDEX IF EXISTS name RESET ( storage_parameter );
ALTER INDEX name ATTACH PARTITION index_name;
ALTER INDEX name NO DEPENDS ON EXTENSION extension_name;
ALTER INDEX IF EXISTS name ALTER COLUMN column_number
SET STATISTICS 5;
ALTER INDEX ALL IN TABLESPACE name OWNED BY role_name,role_name2
SET TABLESPACE new_tablespace NOWAIT;
-- ALTER LANGUAGE -- ALTER LANGUAGE
ALTER PROCEDURAL LANGUAGE name RENAME TO new_name; ALTER PROCEDURAL LANGUAGE name RENAME TO new_name;
ALTER LANGUAGE name OWNER TO new_owner; ALTER LANGUAGE name OWNER TO new_owner;
ALTER LANGUAGE name OWNER TO CURRENT_ROLE;
ALTER LANGUAGE name OWNER TO CURRENT_USER;
ALTER LANGUAGE name OWNER TO SESSION_USER;
-- ALTER LARGE OBJECT -- ALTER LARGE OBJECT
ALTER LARGE OBJECT 32423 OWNER TO new_owner; ALTER LARGE OBJECT 32423 OWNER TO new_owner;
@ -191,6 +205,14 @@ ALTER OPERATOR = ( integer , NONE ) SET SCHEMA new_schema;
ALTER OPERATOR CLASS name USING index_method RENAME TO new_name; ALTER OPERATOR CLASS name USING index_method RENAME TO new_name;
ALTER OPERATOR CLASS name USING index_method OWNER TO new_owner; ALTER OPERATOR CLASS name USING index_method OWNER TO new_owner;
ALTER OPERATOR CLASS name USING index_method SET SCHEMA new_schema; ALTER OPERATOR CLASS name USING index_method SET SCHEMA new_schema;
ALTER OPERATOR FAMILY name USING index_method ADD
OPERATOR 1 > ( int, int )
FOR SEARCH,
FUNCTION 24 ( int)
function_name( int );
ALTER OPERATOR FAMILY name USING index_method DROP
OPERATOR 32 ( op_typ ),FUNCTION 34 ( op_type);
-- ALTER OPERATOR FAMILY -- ALTER OPERATOR FAMILY
ALTER OPERATOR FAMILY name USING index_method ADD ALTER OPERATOR FAMILY name USING index_method ADD
@ -203,6 +225,33 @@ ALTER OPERATOR FAMILY name USING index_method RENAME TO new_name;
ALTER OPERATOR FAMILY name USING index_method OWNER TO new_owner; ALTER OPERATOR FAMILY name USING index_method OWNER TO new_owner;
ALTER OPERATOR FAMILY name USING index_method SET SCHEMA new_schema; ALTER OPERATOR FAMILY name USING index_method SET SCHEMA new_schema;
-- ALTER POLICY
ALTER POLICY name ON table_name RENAME TO new_name;
ALTER POLICY name ON table_name
TO role_name, PUBLIC, CURRENT_ROLE, CURRENT_USER, SESSION_USER
USING ( using_expression )
WITH CHECK ( check_expression );
-- ALTER PROCEDURE
ALTER PROCEDURE name ( IN argname integer, IN argname int)
RESET ALL RESTRICT;
ALTER PROCEDURE name ( IN argname integer )
RENAME TO new_name;
ALTER PROCEDURE name ( IN argname integer)
OWNER TO CURRENT_ROLE;
ALTER PROCEDURE name ( IN argname integer)
SET SCHEMA new_schema;
ALTER PROCEDURE name ( IN argname integer)
NO DEPENDS ON EXTENSION extension_name;
-- ALTER PUBLICATION
ALTER PUBLICATION name ADD TABLE ONLY table_name * ( column_name,column_name2) WHERE ( expression>3 );
ALTER PUBLICATION name SET TABLE ONLY table_name * ( column_name,column_name2) WHERE ( expression ), TABLE ONLY table_name * ( column_name,column_name2) WHERE ( expression );
ALTER PUBLICATION name DROP TABLE ONLY table_name * ( column_name,column_name2) WHERE ( expression );
ALTER PUBLICATION name SET ( publication_parameter = value, parameters2 )
ALTER PUBLICATION name OWNER TO CURRENT_ROLE;
ALTER PUBLICATION name RENAME TO new_name;
-- ALTER ROLE -- ALTER ROLE
ALTER ROLE name WITH SUPERUSER CREATEDB CREATEROLE VALID UNTIL 'timestamp'; ALTER ROLE name WITH SUPERUSER CREATEDB CREATEROLE VALID UNTIL 'timestamp';
ALTER ROLE name RENAME TO new_name; ALTER ROLE name RENAME TO new_name;
@ -211,6 +260,20 @@ ALTER ROLE name IN DATABASE database_name SET configuration_parameter FROM CURRE
ALTER ROLE ALL IN DATABASE database_name RESET configuration_parameter; ALTER ROLE ALL IN DATABASE database_name RESET configuration_parameter;
ALTER ROLE name IN DATABASE database_name RESET ALL; ALTER ROLE name IN DATABASE database_name RESET ALL;
-- ALTER ROUTINE
ALTER ROUTINE name ( IN argname integer)
COST execution_cost RESTRICT;
ALTER ROUTINE name
COST execution_cost IMMUTABLE LEAKPROOF SECURITY INVOKER ROWS result_rows SET configuration_parameter TO DEFAULT SET configuration_parameter FROM CURRENT RESET configuration_parameter RESET ALL;
ALTER ROUTINE name ( IN argname integer)
RENAME TO new_name;
ALTER ROUTINE name ( IN argname integer)
OWNER TO CURRENT_ROLE;
ALTER ROUTINE name ( IN argname integer)
SET SCHEMA new_schema;
ALTER ROUTINE name ( IN argname integer)
NO DEPENDS ON EXTENSION extension_name;
-- ALTER RULE -- ALTER RULE
ALTER RULE name ON table_name RENAME TO new_name; ALTER RULE name ON table_name RENAME TO new_name;
@ -222,6 +285,7 @@ ALTER SCHEMA name OWNER TO new_owner;
ALTER SEQUENCE IF EXISTS name INCREMENT BY 324 ALTER SEQUENCE IF EXISTS name INCREMENT BY 324
MINVALUE 34 MAXVALUE 66 MINVALUE 34 MAXVALUE 66
START WITH 12 RESTART WITH 34 START WITH 12 RESTART WITH 34
RESTART WITH restart
CACHE 324 NO CYCLE CACHE 324 NO CYCLE
OWNED BY table_name.column_name; OWNED BY table_name.column_name;
ALTER SEQUENCE name OWNER TO new_owner; ALTER SEQUENCE name OWNER TO new_owner;
@ -233,18 +297,52 @@ ALTER SERVER name VERSION 'new_version' OPTIONS ( ADD option 'value', SET option
ALTER SERVER name OWNER TO new_owner; ALTER SERVER name OWNER TO new_owner;
ALTER SERVER name RENAME TO new_name; ALTER SERVER name RENAME TO new_name;
-- ALTER STATISTICS
ALTER STATISTICS name OWNER TO CURRENT_ROLE;
ALTER STATISTICS name OWNER TO CURRENT_USER;
ALTER STATISTICS name OWNER TO SESSION_USER;
ALTER STATISTICS name RENAME TO new_name;
ALTER STATISTICS name SET SCHEMA new_schema;
ALTER STATISTICS name SET STATISTICS 23;
-- ALTER SUBSCRIPTION
ALTER SUBSCRIPTION name CONNECTION 'conninfo';
ALTER SUBSCRIPTION name SET PUBLICATION publication_name,publication_name1 WITH ( publication_option = value) ;
ALTER SUBSCRIPTION name ADD PUBLICATION publication_name WITH ( publication_option );
ALTER SUBSCRIPTION name DROP PUBLICATION publication_name WITH ( publication_option);
ALTER SUBSCRIPTION name REFRESH PUBLICATION WITH ( refresh_option = value);
ALTER SUBSCRIPTION name ENABLE;
ALTER SUBSCRIPTION name DISABLE;
ALTER SUBSCRIPTION name SET ( subscription_parameter = value);
ALTER SUBSCRIPTION name SKIP ( skip_option = value );
ALTER SUBSCRIPTION name OWNER TO CURRENT_ROLE;
ALTER SUBSCRIPTION name RENAME TO new_name;
-- ALTER SYSTEM
ALTER SYSTEM SET configuration_parameter TO DEFAULT;
ALTER SYSTEM RESET configuration_parameter;
ALTER SYSTEM RESET ALL;
-- ALTER TABLE -- ALTER TABLE
ALTER TABLE IF EXISTS ONLY name * ALTER TABLE IF EXISTS ONLY name *
ALTER COLUMN column_name SET DEFAULT expression, DISABLE RULE rewrite_rule_name, ADD CONSTRAINT constraint_name ALTER COLUMN column_name SET DEFAULT expression, DISABLE RULE rewrite_rule_name, ADD CONSTRAINT constraint_name
UNIQUE USING INDEX index_name DEFERRABLE INITIALLY DEFERRED; UNIQUE USING INDEX index_name DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE name ALTER TABLE name
RENAME column_name TO new_column_name; RENAME COLUMN column_name TO new_column_name;
ALTER TABLE IF EXISTS ONLY name * ALTER TABLE IF EXISTS ONLY name *
RENAME CONSTRAINT constraint_name TO new_constraint_name; RENAME CONSTRAINT constraint_name TO new_constraint_name;
ALTER TABLE IF EXISTS name ALTER TABLE IF EXISTS name
RENAME TO new_name; RENAME TO new_name;
ALTER TABLE name ALTER TABLE name
SET SCHEMA new_schema; SET SCHEMA new_schema;
ALTER TABLE ALL IN TABLESPACE name OWNED BY role_name,role_name2
SET TABLESPACE new_tablespace NOWAIT;
ALTER TABLE IF EXISTS name
ATTACH PARTITION partition_name FOR VALUES FROM (MINVALUE, x>3) TO (MAXVALUE,MAXVALUE);
ALTER TABLE orders
ATTACH PARTITION orders_p4 FOR VALUES WITH (MODULUS 4, REMAINDER 4);
ALTER TABLE IF EXISTS name
DETACH PARTITION partition_name CONCURRENTLY;
-- ALTER TABLESPACE -- ALTER TABLESPACE
ALTER TABLESPACE name RENAME TO new_name; ALTER TABLESPACE name RENAME TO new_name;
@ -312,3 +410,4 @@ ALTER VIEW name SET SCHEMA new_schema;
ALTER VIEW IF EXISTS name SET ( view_option_name = view_option_value, view_option_name2 = view_option_value2); ALTER VIEW IF EXISTS name SET ( view_option_name = view_option_value, view_option_name2 = view_option_value2);
ALTER VIEW name RESET ( view_option_name, view_option_name ); ALTER VIEW name RESET ( view_option_name, view_option_name );

View File

@ -156,6 +156,11 @@ CREATE TYPE floatrange AS RANGE (
subtype_diff = float8mi subtype_diff = float8mi
); );
-- CREATE ACCESS METHOD
CREATE ACCESS METHOD name
TYPE TABLE
HANDLER handler_function;
-- CREATE AGGREGATE -- CREATE AGGREGATE
CREATE AGGREGATE agg_name1 ( int, integer) ( CREATE AGGREGATE agg_name1 ( int, integer) (
SFUNC = sfunc, SFUNC = sfunc,
@ -203,7 +208,11 @@ CREATE CAST (source_type3 AS target_type3)
CREATE COLLATION coll_name ( CREATE COLLATION coll_name (
LOCALE = locale, LOCALE = locale,
LC_COLLATE = lc_collate, LC_COLLATE = lc_collate,
LC_CTYPE = lc_ctype LC_CTYPE = lc_ctype,
PROVIDER = provider,
DETERMINISTIC = boolean,
RULES = rules,
VERSION = version
); );
CREATE COLLATION coll_name FROM existing_collation; CREATE COLLATION coll_name FROM existing_collation;
@ -219,10 +228,19 @@ CREATE DATABASE name1
OWNER = user_name OWNER = user_name
TEMPLATE = template TEMPLATE = template
ENCODING = encoding ENCODING = encoding
STRATEGY = strategy
LOCALE = locale
LC_COLLATE = lc_collate LC_COLLATE = lc_collate
LC_CTYPE = lc_ctype LC_CTYPE = lc_ctype
ICU_LOCALE = icu_locale
ICU_RULES = icu_rules
LOCALE_PROVIDER = locale_provider
COLLATION_VERSION = collation_version
TABLESPACE = tablespace_name TABLESPACE = tablespace_name
CONNECTION LIMIT = connlimit; ALLOW_CONNECTIONS = allowconn
CONNECTION LIMIT = connlimit
IS_TEMPLATE = istemplate
OID = oid;
CREATE DATABASE name2; CREATE DATABASE name2;
-- CREATE DOMAIN -- CREATE DOMAIN
@ -286,22 +304,39 @@ CREATE OR REPLACE FUNCTION
WITH (isStrict, isCachable); WITH (isStrict, isCachable);
-- CREATE GROUP -- CREATE GROUP
CREATE GROUP group_name WITH SUPERUSER; CREATE GROUP group_name WITH SUPERUSER NOSUPERUSER CREATEDB NOCREATEDB
CREATEROLE NOCREATEROLE
INHERIT NOINHERIT
LOGIN NOLOGIN
REPLICATION NOREPLICATION
BYPASSRLS NOBYPASSRLS
CONNECTION LIMIT 234
ENCRYPTED PASSWORD 'password'
VALID UNTIL '2023-09-23'
IN ROLE role_name, role_name1
IN GROUP role_name
ROLE role_name
ADMIN role_name
USER role_name
SYSID 757;
CREATE GROUP group_name WITH ENCRYPTED PASSWORD 'password'; CREATE GROUP group_name WITH ENCRYPTED PASSWORD 'password';
CREATE GROUP group_name; CREATE GROUP group_name;
-- CREATE INDEX -- CREATE INDEX
CREATE UNIQUE INDEX CONCURRENTLY index_name ON table_name USING btree CREATE UNIQUE INDEX CONCURRENTLY index_name ON table_name USING btree
((a > 4) COLLATE collation_name ASC NULLS LAST ) ((a > 4) COLLATE collation_name ASC NULLS LAST )
INCLUDE (column_name1, clou_2)
NULLS NOT DISTINCT
WITH ( storage_parameter = 1) WITH ( storage_parameter = 1)
TABLESPACE tablespace_name TABLESPACE tablespace_name
WHERE (y > 4); WHERE (y > 4);
CREATE INDEX ON table_name (col1); CREATE INDEX ON table_name (col1);
-- CREATE LANGUAGE -- CREATE LANGUAGE
CREATE OR REPLACE PROCEDURAL LANGUAGE lan_name
CREATE OR REPLACE TRUSTED PROCEDURAL LANGUAGE lan_name1 CREATE OR REPLACE TRUSTED PROCEDURAL LANGUAGE lan_name1
HANDLER call_handler INLINE inline_handler VALIDATOR valfunction; HANDLER call_handler INLINE inline_handler VALIDATOR valfunction;
CREATE LANGUAGE name;
CREATE LANGUAGE name HANDLER call_handler;
-- CREATE MATERIALIZED VIEW -- CREATE MATERIALIZED VIEW
CREATE MATERIALIZED VIEW table_name CREATE MATERIALIZED VIEW table_name
@ -341,6 +376,33 @@ FOR TYPE _int4 USING gist AS
-- CREATE OPERATOR FAMILY -- CREATE OPERATOR FAMILY
CREATE OPERATOR FAMILY name USING index_method; CREATE OPERATOR FAMILY name USING index_method;
-- CREATE POLICY
CREATE POLICY name ON table_name
AS PERMISSIVE
FOR INSERT
TO PUBLIC
USING ( using_expression )
WITH CHECK ( check_expression );
CREATE POLICY name ON table_name;
-- CREATE PROCEDURE
CREATE OR REPLACE PROCEDURE
name ( IN argname int DEFAULT default_expr)
LANGUAGE lang_name
TRANSFORM { FOR TYPE type_name }
EXTERNAL SECURITY INVOKER
EXTERNAL SECURITY DEFINER
SET configuration_parameter FROM CURRENT
AS 'definition'
AS 'obj_file', 'link_symbol'
sql_body;
-- CREATE PUBLICATION
CREATE PUBLICATION name
FOR ALL TABLES, FOR publication_object
WITH ( publication_parameter = value);
CREATE PUBLICATION name;
-- CREATE ROLE -- CREATE ROLE
CREATE ROLE name WITH SUPERUSER CREATEDB CREATEROLE CREATE ROLE name WITH SUPERUSER CREATEDB CREATEROLE
CREATEUSER CREATEUSER
@ -385,6 +447,63 @@ CREATE SERVER server_name TYPE 'server_type' VERSION 'server_version'
OPTIONS ( option 'value', option 'value3'); OPTIONS ( option 'value', option 'value3');
CREATE SERVER server_name FOREIGN DATA WRAPPER fdw_name; CREATE SERVER server_name FOREIGN DATA WRAPPER fdw_name;
-- CREATE STATISTICS
CREATE STATISTICS IF NOT EXISTS statistics_name
ON ( expression )
FROM table_name;
CREATE STATISTICS IF NOT EXISTS statistics_name
( statistics_kind )
ON column_name, ( expression )
FROM table_name;
CREATE STATISTICS ON column_name, column_name FROM table_name;
-- CREATE SUBSCRIPTION
CREATE SUBSCRIPTION subscription_name
CONNECTION 'conninfo'
PUBLICATION publication_name, publication_name1
WITH ( subscription_parameter = value, subscription_parameter = value);
CREATE SUBSCRIPTION subscription_name
CONNECTION 'conninfo'
PUBLICATION publication_name;
-- CREATE TABLE
CREATE UNLOGGED TABLE IF NOT EXISTS table_name (
column_name int STORAGE PLAIN COMPRESSION compression_method COLLATE collation_name NOT NULL,
CONSTRAINT constraint_name
CHECK ( expression>3 ) NO INHERIT ,
LIKE source_table
)
INHERITS ( parent_table, parent_table)
PARTITION BY RANGE ( column_name COLLATE collation_name opclass)
USING method
WITH ( storage_parameter = value)
ON COMMIT PRESERVE ROWS
TABLESPACE tablespace_name;
CREATE TABLE table_name (column_name int);
CREATE GLOBAL TEMPORARY TABLE table_name
OF int ( column_name WITH OPTIONS GENERATED ALWAYS AS ( generation_expr ) STORED
)
PARTITION BY HASH ( ( expression>3 ) COLLATE collation_name opclass)
USING method
WITH ( storage_parameter = value )
ON COMMIT PRESERVE ROWS
TABLESPACE tablespace_name;
CREATE TABLE table_name OF type_name;
CREATE TABLE table_name
PARTITION OF parent_table (
column_name WITH OPTIONS NOT NULL
NULL
CHECK ( expression ) NO INHERIT
DEFAULT default_expr
GENERATED ALWAYS AS ( generation_expr ) STORED
GENERATED BY DEFAULT AS IDENTITY ( AS data_type )
UNIQUE NULLS NOT DISTINCT INCLUDE ( column_name )
PRIMARY KEY WITH ( storage_parameter = value )
REFERENCES reftable ( refcolumn ) MATCH FULL
ON DELETE NO ACTION ON UPDATE RESTRICT
DEFERRABLE INITIALLY DEFERRED
) FOR VALUES FROM (MINVALUE, x>3) TO (MAXVALUE,MAXVALUE);
-- CREATE TABLE AS -- CREATE TABLE AS
CREATE GLOBAL TEMPORARY TABLE table_name CREATE GLOBAL TEMPORARY TABLE table_name
(column_name, column_name2) (column_name, column_name2)
@ -436,8 +555,14 @@ CREATE TEXT SEARCH TEMPLATE name (
LEXIZE = lexize_function LEXIZE = lexize_function
); );
-- CREATE TRANSFORM
CREATE OR REPLACE TRANSFORM FOR type_name LANGUAGE lang_name (
FROM SQL WITH FUNCTION from_sql_function_name (argument_type),
TO SQL WITH FUNCTION to_sql_function_name (argument_type )
);
-- CREATE TRIGGER -- CREATE TRIGGER
CREATE CONSTRAINT TRIGGER trig_name INSTEAD OF INSERT OR UPDATE CREATE OR REPLACE CONSTRAINT TRIGGER trig_name INSTEAD OF INSERT OR UPDATE
ON table_name ON table_name
FROM referenced_table_name FROM referenced_table_name
DEFERRABLE INITIALLY IMMEDIATE DEFERRABLE INITIALLY IMMEDIATE

View File

@ -9,3 +9,5 @@ DELETE FROM ONLY table_name * AS alias
USING using_list USING using_list
WHERE y > 4 WHERE y > 4
RETURNING *; RETURNING *;
DELETE FROM table_name;

View File

@ -3,8 +3,12 @@ DROP TABLE IF EXISTS table1, table2 RESTRICT;
DROP TABLE products CASCADE; DROP TABLE products CASCADE;
DROP TABLE products1; DROP TABLE products1;
-- DROP ACCESS METHOD
DROP ACCESS METHOD IF EXISTS name CASCADE;
DROP ACCESS METHOD name;
-- DROP AGGREGATE -- DROP AGGREGATE
DROP AGGREGATE IF EXISTS aggname1(int, integer) CASCADE; DROP AGGREGATE IF EXISTS aggname1(int, integer), aggname2(IN argname integer) CASCADE;
DROP AGGREGATE aggname2(int); DROP AGGREGATE aggname2(int);
-- DROP CAST -- DROP CAST
@ -20,7 +24,7 @@ DROP CONVERSION IF EXISTS conver_name RESTRICT;
DROP CONVERSION conver_name1; DROP CONVERSION conver_name1;
-- DROP DATABASE -- DROP DATABASE
DROP DATABASE IF EXISTS db_name; DROP DATABASE IF EXISTS db_name WITH (FORCE);
DROP DATABASE db_name; DROP DATABASE db_name;
-- DROP DOMAIN -- DROP DOMAIN
@ -77,13 +81,29 @@ DROP OPERATOR FAMILY IF EXISTS family_name USING index_method RESTRICT;
DROP OPERATOR FAMILY family_name1 USING index_method; DROP OPERATOR FAMILY family_name1 USING index_method;
-- DROP OWNED -- DROP OWNED
DROP OWNED BY owner_name1, owner_name2 CASCADE; DROP OWNED BY owner_name1, CURRENT_ROLE CASCADE;
DROP OWNED BY owner_name3; DROP OWNED BY CURRENT_USER;
-- DROP POLICY
DROP POLICY IF EXISTS name ON table_name RESTRICT;
DROP POLICY name1 ON table_name1;
-- DROP PROCEDURE
DROP PROCEDURE IF EXISTS name( IN argname int, OUT argname integer), name1( OUT argname int, OUT argname int) CASCADE;
DROP PROCEDURE name1;
-- DROP PUBLICATION
DROP PUBLICATION IF EXISTS name CASCADE;
DROP PUBLICATION name;
-- DROP ROLE -- DROP ROLE
DROP ROLE IF EXISTS role_name1, role_name2; DROP ROLE IF EXISTS role_name1, role_name2;
DROP ROLE role_name3; DROP ROLE role_name3;
-- DROP ROUTINE
DROP ROUTINE IF EXISTS name (IN argname int, OUT argname integer),name1( OUT argname int, OUT argname int) RESTRICT;
DROP ROUTINE name1;
-- DROP RULE -- DROP RULE
DROP RULE IF EXISTS rule_name ON table_name CASCADE; DROP RULE IF EXISTS rule_name ON table_name CASCADE;
DROP RULE rule_name1 ON table_name1; DROP RULE rule_name1 ON table_name1;
@ -100,6 +120,14 @@ DROP SEQUENCE con_name3;
DROP SERVER IF EXISTS server_name RESTRICT; DROP SERVER IF EXISTS server_name RESTRICT;
DROP SERVER server_name1; DROP SERVER server_name1;
-- DROP STATISTICS
DROP STATISTICS IF EXISTS name, name1 CASCADE;
DROP STATISTICS name1;
-- DROP SUBSCRIPTION
DROP SUBSCRIPTION IF EXISTS name RESTRICT;
DROP SUBSCRIPTION name1;
-- DROP TABLESPACE -- DROP TABLESPACE
DROP TABLESPACE IF EXISTS tbspace_name1; DROP TABLESPACE IF EXISTS tbspace_name1;
DROP TABLESPACE tbspace_name2; DROP TABLESPACE tbspace_name2;
@ -120,6 +148,10 @@ DROP TEXT SEARCH PARSER parser_name2;
DROP TEXT SEARCH TEMPLATE IF EXISTS temp_name1 RESTRICT; DROP TEXT SEARCH TEMPLATE IF EXISTS temp_name1 RESTRICT;
DROP TEXT SEARCH TEMPLATE temp_name2; DROP TEXT SEARCH TEMPLATE temp_name2;
-- DROP TRANSFORM
DROP TRANSFORM IF EXISTS FOR type_name LANGUAGE lang_name RESTRICT;
DROP TRANSFORM FOR type_name LANGUAGE lang_name;
-- DROP TRIGGER -- DROP TRIGGER
DROP TRIGGER IF EXISTS trigger_name1 ON table_name1 CASCADE; DROP TRIGGER IF EXISTS trigger_name1 ON table_name1 CASCADE;
DROP TRIGGER trigger_name2 ON table_name2; DROP TRIGGER trigger_name2 ON table_name2;
@ -136,6 +168,7 @@ DROP USER user_name3;
DROP USER MAPPING IF EXISTS FOR user_name SERVER server_name; DROP USER MAPPING IF EXISTS FOR user_name SERVER server_name;
DROP USER MAPPING IF EXISTS FOR USER SERVER server_name; DROP USER MAPPING IF EXISTS FOR USER SERVER server_name;
DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER server_name; DROP USER MAPPING IF EXISTS FOR CURRENT_USER SERVER server_name;
DROP USER MAPPING IF EXISTS FOR CURRENT_ROLE SERVER server_name;
DROP USER MAPPING IF EXISTS FOR PUBLIC SERVER server_name; DROP USER MAPPING IF EXISTS FOR PUBLIC SERVER server_name;
DROP USER MAPPING FOR PUBLIC SERVER server_name; DROP USER MAPPING FOR PUBLIC SERVER server_name;

View File

@ -31,7 +31,7 @@ INSERT INTO reservation VALUES
-- INSERT -- INSERT
WITH RECURSIVE a AS (SELECT * from bt ) WITH RECURSIVE a AS (SELECT * from bt )
INSERT INTO table_name ( column_name, column_name2) INSERT INTO table_name.dt ( column_name, column_name2)
VALUES (1, 2) VALUES (1, 2)
RETURNING * ; RETURNING * ;
INSERT INTO films DEFAULT VALUES; INSERT INTO films DEFAULT VALUES;

View File

@ -1,21 +1,32 @@
-- ABORT -- ABORT
ABORT WORK; ABORT WORK;
ABORT TRANSACTION; ABORT TRANSACTION;
ABORT AND NO CHAIN;
-- ANALYZE -- ANALYZE
ANALYZE VERBOSE table_name ( column_name, column_name2); ANALYZE VERBOSE table_name ( column_name, column_name2);
ANALYZE VERBOSE;
ANALYZE SKIP_LOCKED true;
ANALYZE BUFFER_USAGE_LIMIT 4;
ANALYZE; ANALYZE;
-- BEGIN -- BEGIN
BEGIN WORK ISOLATION LEVEL READ UNCOMMITTED BEGIN WORK ISOLATION LEVEL READ UNCOMMITTED
READ WRITE READ WRITE
NOT DEFERRABLE; NOT DEFERRABLE;
-- CALL
CALL name (name => value);
CALL name;
-- CHECKPOINT -- CHECKPOINT
CHECKPOINT; CHECKPOINT;
-- CLUSTER -- CLUSTER
CLUSTER VERBOSE table_name USING index_name; CLUSTER VERBOSE table_name USING index_name;
CLUSTER (VERBOSE, VERBOSE TRUE) table_name USING index_name;
CLUSTER VERBOSE; CLUSTER VERBOSE;
CLUSTER;
-- CLOSE -- CLOSE
CLOSE ALL; CLOSE ALL;
@ -23,10 +34,14 @@ CLOSE name_2;
-- COMMENT -- COMMENT
COMMENT ON COMMENT ON
ACCESS METHOD object_name IS 'text';
COMMENT ON
AGGREGATE agg_name (agg_type, agg_type2) IS 'text'; AGGREGATE agg_name (agg_type, agg_type2) IS 'text';
COMMENT ON CAST (source_type AS target_type) IS 'text'; COMMENT ON CAST (source_type AS target_type) IS 'text';
COMMENT ON COLLATION object_name IS 'text'; COMMENT ON COLLATION object_name IS 'text';
COMMENT ON COLUMN relation_name.column_name IS 'text' COMMENT ON COLUMN relation_name.column_name IS 'text';
COMMENT ON CONSTRAINT constraint_name ON table_name IS 'text'
COMMENT ON CONSTRAINT constraint_name ON DOMAIN domain_name IS 'text'
COMMENT ON CONVERSION object_name IS 'text'; COMMENT ON CONVERSION object_name IS 'text';
COMMENT ON CONSTRAINT constraint_name ON table_name IS 'text'; COMMENT ON CONSTRAINT constraint_name ON table_name IS 'text';
COMMENT ON DATABASE object_name IS 'text'; COMMENT ON DATABASE object_name IS 'text';
@ -42,12 +57,18 @@ COMMENT ON MATERIALIZED VIEW object_name IS 'text';
COMMENT ON OPERATOR -(int, NONE) IS 'text'; COMMENT ON OPERATOR -(int, NONE) IS 'text';
COMMENT ON OPERATOR CLASS object_name USING index_method IS 'text'; COMMENT ON OPERATOR CLASS object_name USING index_method IS 'text';
COMMENT ON OPERATOR FAMILY object_name USING index_method IS 'text'; COMMENT ON OPERATOR FAMILY object_name USING index_method IS 'text';
COMMENT ON POLICY policy_name ON table_name IS 'text';
COMMENT ON PROCEDURAL LANGUAGE object_name IS 'text'; COMMENT ON PROCEDURAL LANGUAGE object_name IS 'text';
COMMENT ON PROCEDURE procedure_name IS 'text';;
COMMENT ON PUBLICATION object_name IS 'text';
COMMENT ON ROLE object_name IS 'text'; COMMENT ON ROLE object_name IS 'text';
COMMENT ON ROUTINE routine_name IS 'text';
COMMENT ON RULE rule_name ON table_name IS 'text'; COMMENT ON RULE rule_name ON table_name IS 'text';
COMMENT ON SCHEMA object_name IS 'text'; COMMENT ON SCHEMA object_name IS 'text';
COMMENT ON SEQUENCE object_name IS 'text'; COMMENT ON SEQUENCE object_name IS 'text';
COMMENT ON SERVER object_name IS 'text'; COMMENT ON SERVER object_name IS 'text';
COMMENT ON STATISTICS object_name IS 'text';
COMMENT ON SUBSCRIPTION object_name IS 'text';
COMMENT ON TABLE object_name IS 'text'; COMMENT ON TABLE object_name IS 'text';
COMMENT ON TABLESPACE object_name IS 'text'; COMMENT ON TABLESPACE object_name IS 'text';
COMMENT ON TEXT SEARCH CONFIGURATION object_name IS 'text'; COMMENT ON TEXT SEARCH CONFIGURATION object_name IS 'text';
@ -61,6 +82,7 @@ COMMENT ON VIEW object_name IS 'text';
-- COMMIT -- COMMIT
COMMIT TRANSACTION; COMMIT TRANSACTION;
COMMIT WORK; COMMIT WORK;
COMMIT AND NO CHAIN;
-- COMMIT PREPARED -- COMMIT PREPARED
COMMIT PREPARED 'foobar'; COMMIT PREPARED 'foobar';
@ -111,6 +133,7 @@ EXECUTE name ( parameter, parameter2);
-- EXPLAIN -- EXPLAIN
EXPLAIN ( ANALYZE 'true',VERBOSE true, COSTS TRUE, FORMAT TEXT) SELECT * FROM no_nw; EXPLAIN ( ANALYZE 'true',VERBOSE true, COSTS TRUE, FORMAT TEXT) SELECT * FROM no_nw;
EXPLAIN ANALYZE VERBOSE SELECT * FROM no_nw; EXPLAIN ANALYZE VERBOSE SELECT * FROM no_nw;
EXPLAIN SELECT * FROM no_nw;
-- FETCH -- FETCH
FETCH NEXT FROM cursor_name; FETCH NEXT FROM cursor_name;
@ -135,6 +158,12 @@ GRANT CREATE, CONNECT, TEMPORARY, TEMP
TO GROUP role_name, PUBLIC WITH GRANT OPTION; TO GROUP role_name, PUBLIC WITH GRANT OPTION;
GRANT role_name TO role_name; GRANT role_name TO role_name;
-- IMPORT FOREIGN SCHEMA
IMPORT FOREIGN SCHEMA remote_schema
LIMIT TO ( table_name)
FROM SERVER server_name
INTO local_schema
OPTIONS ( option 'value');
-- LISTEN -- LISTEN
LISTEN channel; LISTEN channel;
@ -143,13 +172,17 @@ LISTEN channel;
LOAD 'filename'; LOAD 'filename';
-- LOCK -- LOCK
-- lockmodeACCESS SHARE | ROW SHARE | ROW EXCLUSIVE | SHARE UPDATE EXCLUSIVE
-- | SHARE | SHARE ROW EXCLUSIVE | EXCLUSIVE | ACCESS EXCLUSIVE
LOCK TABLE ONLY name * IN ACCESS SHARE MODE NOWAIT; LOCK TABLE ONLY name * IN ACCESS SHARE MODE NOWAIT;
-- MOVE -- MOVE
MOVE NEXT FROM cursor_name; MOVE NEXT FROM cursor_name;
-- MERGE
WITH query_name (id) AS (SELECT id FROM table_expression)
MERGE INTO ONLY target_table_name * AS target_alias
USING ONLY source_table_name * ON s.winename = w.winename
WHEN MATCHED AND s.winename = w.winename THEN UPDATE SET column_name = DEFAULT;
-- NOTIFY -- NOTIFY
NOTIFY virtual, 'This is the payload'; NOTIFY virtual, 'This is the payload';
@ -166,7 +199,7 @@ REASSIGN OWNED BY old_role TO new_role;
REFRESH MATERIALIZED VIEW name WITH NO DATA; REFRESH MATERIALIZED VIEW name WITH NO DATA;
-- REINDEX -- REINDEX
REINDEX DATABASE name FORCE; REINDEX DATABASE CONCURRENTLY name FORCE;
REINDEX TABLE name; REINDEX TABLE name;
REINDEX INDEX name; REINDEX INDEX name;
REINDEX SYSTEM name; REINDEX SYSTEM name;
@ -182,13 +215,13 @@ RESET ALL;
REVOKE GRANT OPTION FOR REVOKE GRANT OPTION FOR
REFERENCES, CREATE REFERENCES, CREATE
ON TABLE table_name ON TABLE table_name
FROM GROUP role_name, PUBLIC FROM GROUP role_name, PUBLIC, SESSION_USER
RESTRICT; RESTRICT;
REVOKE ALL PRIVILEGES ON accounts FROM PUBLIC; REVOKE ALL PRIVILEGES ON accounts FROM CURRENT_USER;
REVOKE CREATE ON SCHEMA public_name FROM PUBLIC; REVOKE CREATE ON SCHEMA public_name FROM CURRENT_ROLE;
-- ROLLBACK -- ROLLBACK
ROLLBACK TRANSACTION; ROLLBACK TRANSACTION AND NO CHAIN;
ROLLBACK WORK; ROLLBACK WORK;
-- ROLLBACK PREPARED -- ROLLBACK PREPARED
@ -268,7 +301,7 @@ UNLISTEN *;
UNLISTEN channel; UNLISTEN channel;
-- VACUUM -- VACUUM
VACUUM ( FULL, FREEZE, VERBOSE, ANALYZE) table_name (column_name, column_name2); VACUUM ( FULL, FREEZE, VERBOSE, ANALYZE, DISABLE_PAGE_SKIPPING, SKIP_LOCKED, INDEX_CLEANUP, PROCESS_MAIN, PROCESS_TOAST, TRUNCATE, PARALLEL 4,SKIP_DATABASE_STATS, ONLY_DATABASE_STATS, BUFFER_USAGE_LIMIT) table_name (column_name, column_name2);
VACUUM FULL FREEZE VERBOSE table_name; VACUUM FULL FREEZE VERBOSE table_name;
VACUUM FULL FREEZE VERBOSE ANALYZE table_name (column_name,column_name2); VACUUM FULL FREEZE VERBOSE ANALYZE table_name (column_name,column_name2);
VACUUM ANALYZE; VACUUM ANALYZE;
@ -282,6 +315,3 @@ VALUES (1, '3'), (3, 'sdsd')
FETCH NEXT 343 ROWS ONLY ; FETCH NEXT 343 ROWS ONLY ;
VALUES (1, '3'), (3, 'sdsd'); VALUES (1, '3'), (3, 'sdsd');
-- Caveats
ANALYZE measurement;

View File

@ -1,5 +1,17 @@
-- SELECT -- SELECT
WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression) SELECT ALL random() AS name1 FROM table_expression WHERE name1=name1 GROUP BY id HAVING sum(len) < interval '5 hours' WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) UNION ALL (SELECT * FROM others) ORDER BY salary DESC LIMIT ALL OFFSET start FETCH NEXT ROWS ONLY FOR UPDATE; WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression)
SELECT ALL ON (col1,col2) random() AS name1 FROM table_expression
WHERE name1=name1
GROUP BY DISTINCT id
HAVING sum(len) < interval '5 hours'
WINDOW w AS (PARTITION BY depname ORDER BY salary DESC)
UNION ALL (SELECT * FROM others)
ORDER BY salary DESC
LIMIT ALL
OFFSET start ROWS
FETCH NEXT ROWS ONLY
FOR UPDATE OF table_name, table_name2 NOWAIT;
SELECT;
WITH query_name (id) AS (SELECT id FROM table_expression) SELECT DISTINCT random() AS name1 FROM table_expression WHERE name1=name1 GROUP BY id HAVING sum(len) < interval '5 hours' WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) INTERSECT DISTINCT (SELECT * FROM others) ORDER BY salary ASC LIMIT ALL OFFSET start FETCH NEXT ROW ONLY FOR NO KEY UPDATE; WITH query_name (id) AS (SELECT id FROM table_expression) SELECT DISTINCT random() AS name1 FROM table_expression WHERE name1=name1 GROUP BY id HAVING sum(len) < interval '5 hours' WINDOW w AS (PARTITION BY depname ORDER BY salary DESC) INTERSECT DISTINCT (SELECT * FROM others) ORDER BY salary ASC LIMIT ALL OFFSET start FETCH NEXT ROW ONLY FOR NO KEY UPDATE;
@ -9,7 +21,7 @@ WITH query_name (id) AS (SELECT id FROM table_expression) SELECT DISTINCT ON (co
-- SELECT INTO -- SELECT INTO
WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression) WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression)
SELECT DISTINCT ON (col2) SELECT DISTINCT ON (col2, col3)
INTO TEMPORARY TABLE new_table INTO TEMPORARY TABLE new_table
FROM from_item FROM from_item
WHERE name2=name1 WHERE name2=name1
@ -22,6 +34,7 @@ INTO TEMPORARY TABLE new_table
OFFSET start ROW OFFSET start ROW
FETCH FIRST 234 ROWS ONLY FETCH FIRST 234 ROWS ONLY
FOR UPDATE OF table_name NOWAIT; FOR UPDATE OF table_name NOWAIT;
SELECT INTO new_table;
-- The Most Easy -- The Most Easy
SELECT * ; SELECT * ;

View File

@ -31,7 +31,7 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
-- UPDATE -- UPDATE
WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression) WITH RECURSIVE query_name (id) AS (SELECT id FROM table_expression)
UPDATE ONLY table_name * AS alias UPDATE ONLY table_name * AS alias
SET column_name = DEFAULT, (column_name, column_nam2) = ( a+1,DEFAULT) SET column_name = DEFAULT, (column_name, column_nam2) = ROW ( a+1,DEFAULT)
FROM from_list FROM from_list
WHERE a=b WHERE a=b
RETURNING * AS output_name; RETURNING * AS output_name;