From cd4e6c33550eb22a19478579a89f29eea37b25a6 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 17 Dec 2024 18:28:27 +0900 Subject: [PATCH] 1. Modify based on code review feedback, 2.Add the [NOT DETERMINISTIC | DETERMINISTIC] keywords to the PL/CSQL Lexer and Parser --- pl_engine/pl_server/src/main/antlr/PlcLexer.g4 | 1 + pl_engine/pl_server/src/main/antlr/PlcParser.g4 | 7 ++++++- src/parser/xasl_generation.c | 4 ++-- src/sp/jsp_cl.cpp | 10 +++++++++- src/sp/pl_signature.hpp | 2 +- src/sp/sp_catalog.hpp | 2 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pl_engine/pl_server/src/main/antlr/PlcLexer.g4 b/pl_engine/pl_server/src/main/antlr/PlcLexer.g4 index a21cc43e38..186ebdfc74 100644 --- a/pl_engine/pl_server/src/main/antlr/PlcLexer.g4 +++ b/pl_engine/pl_server/src/main/antlr/PlcLexer.g4 @@ -74,6 +74,7 @@ DECIMAL: D E C I M A L ; DECLARE: D E C L A R E ; DEFAULT: D E F A U L T ; DEFINER: D E F I N E R ; +DETERMINISTIC: D E T E R M I N I S T I C; DIV: D I V ; DOUBLE: D O U B L E ; ELSE: E L S E ; diff --git a/pl_engine/pl_server/src/main/antlr/PlcParser.g4 b/pl_engine/pl_server/src/main/antlr/PlcParser.g4 index 4b950c8177..8edc51a873 100644 --- a/pl_engine/pl_server/src/main/antlr/PlcParser.g4 +++ b/pl_engine/pl_server/src/main/antlr/PlcParser.g4 @@ -40,7 +40,7 @@ create_routine routine_definition : (PROCEDURE | FUNCTION) routine_uniq_name ( (LPAREN parameter_list RPAREN)? | LPAREN RPAREN ) (RETURN type_spec)? - (authid_spec)? (IS | AS) (LANGUAGE PLCSQL)? seq_of_declare_specs? body (SEMICOLON)? + (authid_spec)? (deterministic_spec)? (IS | AS) (LANGUAGE PLCSQL)? seq_of_declare_specs? body (SEMICOLON)? ; routine_uniq_name @@ -62,6 +62,11 @@ authid_spec | AUTHID (CALLER | CURRENT_USER) # authid_caller ; +deterministic_spec + : NOT DETERMINISTIC + | DETERMINISTIC + ; + default_value_part : (':=' | DEFAULT) expression ; diff --git a/src/parser/xasl_generation.c b/src/parser/xasl_generation.c index 6b1d5e6fc3..ff878fd0e1 100644 --- a/src/parser/xasl_generation.c +++ b/src/parser/xasl_generation.c @@ -27626,13 +27626,13 @@ pt_make_sq_cache_key_struct (QPROC_DB_VALUE_LIST key_struct, void *p, int type) case TYPE_SP: regu_var_list_p = regu_src->value.sp_ptr->args; - /* The value of regu_src->value.sp_ptr.sig.dtrm is interpreted as follows + /* The value of regu_src->value.sp_ptr->sig->is_deterministic is interpreted as follows * 0: PT_AUTHID_OWNER + PT_NOT_DETERMINISTIC * 1: PT_AUTHID_CALLER + PT_NOT_DETERMINISTIC * 2: PT_AUTHID_OWNER + PT_DETERMINISTIC * 3: PT_AUTHID_CALLER + PT_DETERMINISTIC */ - if (!(regu_src->value.sp_ptr->sig->dtrm & SP_DIRECTIVE_ENUM::SP_DIRECTIVE_RIGHTS_DETERMINISTIC)) + if (regu_src->value.sp_ptr->sig->is_deterministic == false) { return ER_FAILED; } diff --git a/src/sp/jsp_cl.cpp b/src/sp/jsp_cl.cpp index b87a6aa4d1..86c4d3b296 100644 --- a/src/sp/jsp_cl.cpp +++ b/src/sp/jsp_cl.cpp @@ -2106,7 +2106,15 @@ jsp_make_pl_signature (PARSER_CONTEXT *parser, PT_NODE *node, PT_NODE *subquery_ } sig.auth = db_private_strdup (NULL, auth_name); - sig.dtrm = directive; + if ((directive & SP_DIRECTIVE_ENUM::SP_DIRECTIVE_RIGHTS_DETERMINISTIC)) + { + sig.is_deterministic = true; + } + else + { + sig.is_deterministic = false; + } + sig.result_type = result_type; if (! (directive & SP_DIRECTIVE_ENUM::SP_DIRECTIVE_RIGHTS_CALLER)) { diff --git a/src/sp/pl_signature.hpp b/src/sp/pl_signature.hpp index 9324a9a6c2..a63e029206 100644 --- a/src/sp/pl_signature.hpp +++ b/src/sp/pl_signature.hpp @@ -92,7 +92,7 @@ namespace cubpl int type; // PL_TYPE char *name; char *auth; - int dtrm; // DETERMINISTIC + bool is_deterministic; // DETERMINISTIC int result_type; // DB_TYPE pl_arg arg; diff --git a/src/sp/sp_catalog.hpp b/src/sp/sp_catalog.hpp index 33f7eff79a..2fb470269c 100644 --- a/src/sp/sp_catalog.hpp +++ b/src/sp/sp_catalog.hpp @@ -130,7 +130,7 @@ enum sp_directive : int { SP_DIRECTIVE_RIGHTS_OWNER = 0x00, SP_DIRECTIVE_RIGHTS_CALLER = (0x01 << 0), - SP_DIRECTIVE_RIGHTS_DETERMINISTIC = (0x02 << 0), + SP_DIRECTIVE_RIGHTS_DETERMINISTIC = (0x01 << 1), }; typedef sp_directive SP_DIRECTIVE_ENUM;