Skip to content

Commit

Permalink
1. Modify based on code review feedback, 2.Add the [NOT DETERMINISTIC…
Browse files Browse the repository at this point in the history
… | DETERMINISTIC] keywords to the PL/CSQL Lexer and Parser
  • Loading branch information
jongmin-won committed Dec 17, 2024
1 parent 0542c3f commit cd4e6c3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions pl_engine/pl_server/src/main/antlr/PlcLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
7 changes: 6 additions & 1 deletion pl_engine/pl_server/src/main/antlr/PlcParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -62,6 +62,11 @@ authid_spec
| AUTHID (CALLER | CURRENT_USER) # authid_caller
;

deterministic_spec
: NOT DETERMINISTIC
| DETERMINISTIC
;

default_value_part
: (':=' | DEFAULT) expression
;
Expand Down
4 changes: 2 additions & 2 deletions src/parser/xasl_generation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 9 additions & 1 deletion src/sp/jsp_cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion src/sp/pl_signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sp/sp_catalog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit cd4e6c3

Please sign in to comment.