Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SET statement to pg dialect #4927

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;