diff --git a/corpus/create_function/general.txt b/corpus/create_function/general.txt index fdca2b4..43f2beb 100644 --- a/corpus/create_function/general.txt +++ b/corpus/create_function/general.txt @@ -123,3 +123,37 @@ CREATE FUNCTION FOO () RETURNS TABLE(a text, b bigint) AS 'select' LANGUAGE sql; (identifier)))) (string) (identifier))) + +================================================================================ +security definer +================================================================================ +CREATE FUNCTION FOO () RETURNS void AS 'select' LANGUAGE sql SECURITY definer; +-------------------------------------------------------------------------------- + +(source_file + (create_function_statement + (function_signature + (identifier) + (function_parameters)) + (function_return + (identifier)) + (string) + (identifier) + (function_run_as))) + +================================================================================ +security invoker +================================================================================ +CREATE FUNCTION FOO () RETURNS void AS 'select' LANGUAGE sql SECURITY INVOKER; +-------------------------------------------------------------------------------- + +(source_file + (create_function_statement + (function_signature + (identifier) + (function_parameters)) + (function_return + (identifier)) + (string) + (identifier) + (function_run_as))) diff --git a/grammar.js b/grammar.js index e77c75d..c6530cc 100644 --- a/grammar.js +++ b/grammar.js @@ -582,7 +582,13 @@ module.exports = grammar({ $.string, ), kw("language"), choice($.identifier, $.string), - optional($.function_volatility) + optional($.function_volatility), + optional($.function_run_as), + ), + + function_run_as: $ => seq( + kw("security"), + choice(kw("invoker"), kw("definer")) ), function_return: $ => seq(