From d6a6775598d1e8ce16865c986a356a252ea09a18 Mon Sep 17 00:00:00 2001 From: Christian De la Hoz Date: Wed, 1 Sep 2021 17:48:14 +0200 Subject: [PATCH] security definer --- corpus/create_function/general.txt | 34 ++++++++++++++++++++++++++++++ grammar.js | 8 ++++++- 2 files changed, 41 insertions(+), 1 deletion(-) 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(