drop function
This commit is contained in:
parent
e7f520d7e5
commit
0c286e0edf
2 changed files with 121 additions and 0 deletions
102
corpus/drop_function_statement.txt
Normal file
102
corpus/drop_function_statement.txt
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
================================================================================
|
||||||
|
basic
|
||||||
|
================================================================================
|
||||||
|
drop function foo(bigint, text);
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
many at once
|
||||||
|
================================================================================
|
||||||
|
drop function foo(bigint, text), foo(bigint);
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier)
|
||||||
|
(identifier)
|
||||||
|
(identifier))
|
||||||
|
(drop_function_item
|
||||||
|
(identifier)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
without args
|
||||||
|
================================================================================
|
||||||
|
drop function foo;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
with no args
|
||||||
|
================================================================================
|
||||||
|
drop function foo();
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
cascade
|
||||||
|
================================================================================
|
||||||
|
drop function foo(bigint) cascade;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
restrict
|
||||||
|
================================================================================
|
||||||
|
drop function foo(bigint) restrict;
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(identifier)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
if exists
|
||||||
|
================================================================================
|
||||||
|
drop function if exists foo();
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(if_exists)
|
||||||
|
(identifier))))
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
with argnames
|
||||||
|
================================================================================
|
||||||
|
drop function if exists foo(bar text, bigint);
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(source_file
|
||||||
|
(drop_function_statement
|
||||||
|
(drop_function_item
|
||||||
|
(if_exists)
|
||||||
|
(identifier)
|
||||||
|
(var_declaration
|
||||||
|
(identifier)
|
||||||
|
(identifier))
|
||||||
|
(identifier))))
|
19
grammar.js
19
grammar.js
|
@ -45,6 +45,7 @@ module.exports = grammar({
|
||||||
_statement: $ => choice(
|
_statement: $ => choice(
|
||||||
$.psql_statement,
|
$.psql_statement,
|
||||||
$.create_function_statement,
|
$.create_function_statement,
|
||||||
|
$.drop_function_statement,
|
||||||
$.create_table_statement,
|
$.create_table_statement,
|
||||||
$.create_schema_statement,
|
$.create_schema_statement,
|
||||||
$.create_type_statement,
|
$.create_type_statement,
|
||||||
|
@ -59,6 +60,24 @@ module.exports = grammar({
|
||||||
$.do_block,
|
$.do_block,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
drop_function_statement: $ => seq(
|
||||||
|
kw("drop"), kw("function"),
|
||||||
|
commaSep1($.drop_function_item),
|
||||||
|
optional(choice(kw("cascade"), kw("restrict")))
|
||||||
|
),
|
||||||
|
|
||||||
|
drop_function_item: $ => seq(
|
||||||
|
optional($.if_exists),
|
||||||
|
$.identifier,
|
||||||
|
optional(
|
||||||
|
seq(
|
||||||
|
"(",
|
||||||
|
commaSep(
|
||||||
|
choice($.var_declaration, $._type,)
|
||||||
|
),
|
||||||
|
")",
|
||||||
|
))),
|
||||||
|
|
||||||
create_type_statement: $ => seq(
|
create_type_statement: $ => seq(
|
||||||
kw("create"), kw("type"), $.identifier, optional(choice(
|
kw("create"), kw("type"), $.identifier, optional(choice(
|
||||||
seq(kw("as"), kw("enum"), "(", commaSep1($.string), ")"),
|
seq(kw("as"), kw("enum"), "(", commaSep1($.string), ")"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue