Skip to content

Commit

Permalink
Grammar: Add RESET statement to Postgres dialect (#2182)
Browse files Browse the repository at this point in the history
Co-authored-by: Barry Pollard <barry@tunetheweb.com>
  • Loading branch information
jpy-git and tunetheweb committed Dec 26, 2021
1 parent 38e4e37 commit b900e9d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sqlfluff/dialects/dialect_postgres.py
Expand Up @@ -2764,6 +2764,7 @@ class StatementSegment(BaseSegment):
Ref("DropDatabaseStatementSegment"),
Ref("AlterFunctionStatementSegment"),
Ref("AlterViewStatementSegment"),
Ref("ResetStatementSegment"),
Ref("DiscardStatementSegment"),
],
)
Expand Down Expand Up @@ -3057,6 +3058,20 @@ class DropPolicyStatementSegment(BaseSegment):
)


@postgres_dialect.segment()
class ResetStatementSegment(BaseSegment):
"""A `RESET` statement.
As Specified in https://www.postgresql.org/docs/14/sql-reset.html
"""

type = "reset_statement"
match_grammar = Sequence(
"RESET",
OneOf("ALL", Ref("ParameterNameSegment")),
)


@postgres_dialect.segment()
class DiscardStatementSegment(BaseSegment):
"""A `DISCARD` statement.
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/dialects/postgres/postgres_reset.sql
@@ -0,0 +1,2 @@
RESET timezone;
RESET ALL;
17 changes: 17 additions & 0 deletions test/fixtures/dialects/postgres/postgres_reset.yml
@@ -0,0 +1,17 @@
# YML test files are auto-generated from SQL files and should not be edited by
# hand. To help enforce this, the "hash" field in the file must match a hash
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: e9e279911916c47d20deb5cce0ef040ce5e573f71b5044dc43b3a1f3b64bbc23
file:
- statement:
reset_statement:
keyword: RESET
parameter: timezone
- statement_terminator: ;
- statement:
reset_statement:
- keyword: RESET
- keyword: ALL
- statement_terminator: ;

0 comments on commit b900e9d

Please sign in to comment.