diff --git a/corpus/drop_type_statement.txt b/corpus/drop_type_statement.txt new file mode 100644 index 0000000..904f0a7 --- /dev/null +++ b/corpus/drop_type_statement.txt @@ -0,0 +1,51 @@ +================================================================================ +basic +================================================================================ +drop type foo; +-------------------------------------------------------------------------------- + +(source_file + (drop_type_statement + (identifier))) + +================================================================================ +many at once +================================================================================ +drop type foo, bar; +-------------------------------------------------------------------------------- + +(source_file + (drop_type_statement + (identifier) + (identifier))) + +================================================================================ +cascade +================================================================================ +drop type foo cascade; +-------------------------------------------------------------------------------- + +(source_file + (drop_type_statement + (identifier))) + +================================================================================ +restrict +================================================================================ +drop type foo restrict; +-------------------------------------------------------------------------------- + +(source_file + (drop_type_statement + (identifier))) + +================================================================================ +if exists +================================================================================ +drop type if exists foo; +-------------------------------------------------------------------------------- + +(source_file + (drop_type_statement + (if_exists) + (identifier))) diff --git a/corpus/plpgsql/open_cursor_statement.txt b/corpus/plpgsql/open_cursor_statement.txt new file mode 100644 index 0000000..4629a9c --- /dev/null +++ b/corpus/plpgsql/open_cursor_statement.txt @@ -0,0 +1,42 @@ +================================================================================ +open for select +================================================================================ +DO $$ +BEGIN + OPEN curs for select 2; +END +$$; +-------------------------------------------------------------------------------- + +(source_file + (do_block + (block + (dollar_quote) + (body + (open_cursor_statement + (identifier) + (select_statement + (select_item + (number))))) + (dollar_quote)))) + +================================================================================ +open for execute +================================================================================ +DO $$ +BEGIN + open foo for execute('select 1'); +END +$$; +-------------------------------------------------------------------------------- + +(source_file + (do_block + (block + (dollar_quote) + (body + (open_cursor_statement + (identifier) + (execute_statement + (string)))) + (dollar_quote)))) diff --git a/grammar.js b/grammar.js index 2ea28d9..c5a3159 100644 --- a/grammar.js +++ b/grammar.js @@ -46,6 +46,7 @@ module.exports = grammar({ $.psql_statement, $.create_function_statement, $.drop_function_statement, + $.drop_type_statement, $.create_table_statement, $.create_schema_statement, $.create_type_statement, @@ -61,6 +62,13 @@ module.exports = grammar({ $.do_block, ), + drop_type_statement: $ => seq( + kw("drop"), kw("type"), + optional($.if_exists), + commaSep1($.identifier), + optional(choice(kw("cascade"), kw("restrict"))) + ), + update_statement: $ => seq( optional($.with_query), kw("update"), $.identifier, optional(seq(optional(kw("as")), $.identifier)), @@ -423,6 +431,7 @@ module.exports = grammar({ $._statement, $.assign_statement, $.get_diagnostics_statement, + $.open_cursor_statement, $.return_statement, $.raise_statement, $.if_statement, @@ -433,6 +442,11 @@ module.exports = grammar({ ";", ), + open_cursor_statement: $ => seq( + kw("open"), $.identifier, kw("for"), + choice($.select_statement, $.execute_statement) + ), + get_diagnostics_statement: $ => seq(kw("get"), optional(kw("current")), kw("diagnostics"), $.assign_statement), for_statement: $ => seq(