Skip to content

Commit

Permalink
Add SET statement to pg dialect (#4927)
Browse files Browse the repository at this point in the history
* Add SET statement to pg dialect

* Fix statement name
  • Loading branch information
de-luca authored Jan 5, 2024
1 parent e195dd5 commit bf0005c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ json_expression ::= {column_name} ( jsona_binary_operator | jsonb_binary_operato
jsona_binary_operator ::= '->' | '->>' | '#>'
jsonb_binary_operator ::= '@>' | '<@' | '?|' | '?&' | '?' | '#-'

extension_stmt ::= create_sequence_stmt | copy_stdin | truncate_stm {
extension_stmt ::= create_sequence_stmt | copy_stdin | truncate_stmt | set_stmt {
extends = "com.alecstrong.sql.psi.core.psi.impl.SqlExtensionStmtImpl"
implements = "com.alecstrong.sql.psi.core.psi.SqlExtensionStmt"
override = true
Expand Down Expand Up @@ -406,9 +406,22 @@ copy_option_force_not_null ::= 'FORCE_NOT_NULL' LP {column_name} ( COMMA {column
copy_option_force_null ::= 'FORCE_NULL' LP {column_name} ( COMMA {column_name}) * RP
copy_option_encoding ::= 'ENCODING' string_literal

truncate_stm ::= 'TRUNCATE' [ 'TABLE' ] ( truncate_only | truncate_descendant ) [ truncate_option * ]
truncate_stmt ::= 'TRUNCATE' [ 'TABLE' ] ( truncate_only | truncate_descendant ) [ truncate_option * ]
truncate_only ::= 'ONLY' {table_name} ( COMMA {table_name} ) *
truncate_descendant ::= {table_name} ['*'] ( COMMA {table_name} ['*'] ) *
truncate_option ::= truncate_option_identity | truncate_option_cascade
truncate_option_identity ::= ( 'RESTART' | 'CONTINUE' ) 'IDENTITY'
truncate_option_cascade ::= 'CASCADE' | 'RESTRICT'

set_stmt ::= 'SET' [ ('SESSION' | 'LOCAL') ] ( set_config | set_timezone | set_schema | set_names | set_seed )
set_value ::= literal_value | {identifier} | DEFAULT
set_config ::= {identifier} ( TO | EQ ) set_value
set_schema ::= 'SCHEMA' string_literal
set_names ::= 'NAMES' set_value
set_seed ::= 'SEED' TO ( set_value | [PLUS | MINUS]{numeric_literal} )
set_timezone ::= 'TIME' 'ZONE'
( [PLUS | MINUS]{numeric_literal}
| interval_expression ['HOUR' TO 'MINUTE']
| 'LOCAL'
| set_value
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SET test = yes;
SET test = 'yes';
SET test = DEFAULT;
SET test TO yes;
SET test TO 'yes';
SET test TO DEFAULT;

SET SESSION test = yes;
SET LOCAL test = yes;

SET TIME ZONE 'PST8PDT';
SET TIME ZONE 'Europe/Paris';
SET TIME ZONE +1;
SET TIME ZONE -7;
SET TIME ZONE INTERVAL '-08:00' HOUR TO MINUTE;
SET TIME ZONE LOCAL;
SET TIME ZONE DEFAULT;

SET SCHEMA 'postgres';

SET NAMES 'utf8';
SET NAMES DEFAULT;

SET SEED TO 0.1;
SET SEED TO -0.5;
SET SEED TO DEFAULT;

0 comments on commit bf0005c

Please sign in to comment.