-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CBRD-25749] Add [NOT DETERMINISTIC | DETERMINISTIC] Keywords to the CREATE FUNCTION Statement #5725
base: develop
Are you sure you want to change the base?
[CBRD-25749] Add [NOT DETERMINISTIC | DETERMINISTIC] Keywords to the CREATE FUNCTION Statement #5725
Changes from all commits
2260c0b
0542c3f
cd4e6c3
71ee4cc
0fcb37d
ca10800
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -662,6 +662,7 @@ static int g_plcsql_text_pos; | |
%type <number> deduplicate_key_mod_level | ||
%type <number> opt_index_with_clause_no_online | ||
%type <number> opt_authid | ||
%type <number> opt_deterministic | ||
/*}}}*/ | ||
|
||
/* define rule type (node) */ | ||
|
@@ -1553,6 +1554,7 @@ static int g_plcsql_text_pos; | |
%token <cptr> DECREMENT | ||
%token <cptr> DEFINER | ||
%token <cptr> DENSE_RANK | ||
%token <cptr> DETERMINISTIC | ||
%token <cptr> DONT_REUSE_OID | ||
%token <cptr> ELT | ||
%token <cptr> EMPTY | ||
|
@@ -3129,14 +3131,15 @@ create_stmt | |
opt_sp_param_list /* 6 */ | ||
RETURN sp_return_type /* 7, 8 */ | ||
opt_authid /* 9 */ | ||
is_or_as pl_language_spec /* 10, 11 */ | ||
opt_comment_spec /* 12 */ | ||
opt_deterministic /* 10 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deterministic 이 authid 앞에 와도 괜찮도록 문법 구성을 해야 할 것 같습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 리뷰 감사합니다. 말씀해 주신 부분은 조금 더 코드 분석을 진행한 후 반영하도록 하겠습니다. |
||
is_or_as pl_language_spec /* 11, 12 */ | ||
opt_comment_spec /* 13 */ | ||
{ pop_msg(); } | ||
{{ DBG_TRACE_GRAMMAR(create_stmt, | CREATE opt_or_replace FUNCTION~); | ||
PT_NODE *node = parser_pop_hint_node (); | ||
if (node) | ||
{ | ||
PT_NODE* body = $11; | ||
PT_NODE* body = $12; | ||
if (body->info.sp_body.lang == SP_LANG_PLCSQL && body->info.sp_body.impl == NULL) | ||
{ | ||
// In particular, this happens for two cases: | ||
|
@@ -3148,8 +3151,8 @@ create_stmt | |
assert(this_parser->file); | ||
|
||
int start = @1.buffer_pos - 6; // 6 : length of "create" | ||
int spec_start = @10.buffer_pos; // right after is_or_as | ||
int spec_end = @11.buffer_pos; | ||
int spec_start = @11.buffer_pos; // right after is_or_as | ||
int spec_end = @12.buffer_pos; | ||
int end = @$.buffer_pos; | ||
if (pt_set_plcsql_body_impl(node, body, start, spec_start, spec_end, end) < 0) { | ||
PT_ERROR (this_parser, node, "failed to get the user SQL from the input file"); | ||
|
@@ -3160,11 +3163,12 @@ create_stmt | |
node->info.sp.name = $5; | ||
node->info.sp.type = PT_SP_FUNCTION; | ||
node->info.sp.auth_id = $9; | ||
node->info.sp.dtrm_type = $10; | ||
node->info.sp.param_list = $6; | ||
node->info.sp.ret_type = (int) TO_NUMBER(CONTAINER_AT_0($8)); | ||
node->info.sp.ret_data_type = CONTAINER_AT_1($8); | ||
node->info.sp.body = $11; | ||
node->info.sp.comment = $12; | ||
node->info.sp.body = $12; | ||
node->info.sp.comment = $13; | ||
} | ||
|
||
$$ = node; | ||
|
@@ -12833,25 +12837,54 @@ sp_return_type | |
|
||
opt_authid | ||
: /* empty */ | ||
{{ $$ = PT_AUTHID_OWNER; }} | ||
{{ DBG_TRACE_GRAMMAR(opt_authid, : ); | ||
$$ = PT_AUTHID_OWNER; | ||
DBG_PRINT}} | ||
| AUTHID DEFINER | ||
{{ $$ = PT_AUTHID_OWNER; }} | ||
{{ DBG_TRACE_GRAMMAR(opt_authid, : AUTHID DEFINER); | ||
$$ = PT_AUTHID_OWNER; | ||
DBG_PRINT}} | ||
| AUTHID OWNER | ||
{{ $$ = PT_AUTHID_OWNER; }} | ||
{{ DBG_TRACE_GRAMMAR(opt_authid, : AUTHID OWNER); | ||
$$ = PT_AUTHID_OWNER; | ||
DBG_PRINT}} | ||
| AUTHID CALLER | ||
{{ $$ = PT_AUTHID_CALLER; }} | ||
{{ DBG_TRACE_GRAMMAR(opt_authid, : AUTHID CALLER); | ||
$$ = PT_AUTHID_CALLER; | ||
DBG_PRINT}} | ||
| AUTHID CURRENT_USER | ||
{{ $$ = PT_AUTHID_CALLER; }} | ||
{{ DBG_TRACE_GRAMMAR(opt_authid, : AUTHID CURRENT_USER); | ||
$$ = PT_AUTHID_CALLER; | ||
DBG_PRINT}} | ||
; | ||
|
||
opt_deterministic | ||
: /* empty */ | ||
{{ DBG_TRACE_GRAMMAR(opt_deterministic, : ); | ||
$$ = PT_NOT_DETERMINISTIC; | ||
DBG_PRINT}} | ||
| NOT DETERMINISTIC | ||
{{ DBG_TRACE_GRAMMAR(opt_deterministic, : NOT DETERMINISTIC); | ||
$$ = PT_NOT_DETERMINISTIC; | ||
DBG_PRINT}} | ||
| DETERMINISTIC | ||
{{ DBG_TRACE_GRAMMAR(opt_deterministic, : DETERMINISTIC); | ||
$$ = PT_DETERMINISTIC; | ||
DBG_PRINT}} | ||
; | ||
|
||
is_or_as | ||
: IS | ||
| AS | ||
: IS | ||
{ DBG_TRACE_GRAMMAR(is_or_as, : IS); DBG_PRINT} | ||
| AS | ||
{ DBG_TRACE_GRAMMAR(is_or_as, : AS); DBG_PRINT} | ||
; | ||
|
||
opt_lang_plcsql | ||
: /* empty */ | ||
: /* empty */ | ||
{ DBG_TRACE_GRAMMAR(opt_lang_plcsql, : ); DBG_PRINT} | ||
| LANGUAGE PLCSQL | ||
{ DBG_TRACE_GRAMMAR(opt_lang_plcsql, : LANGUAGE PLCSQL); DBG_PRINT} | ||
; | ||
|
||
pl_language_spec | ||
|
@@ -23217,6 +23250,7 @@ identifier | |
| DEFINER {{ DBG_TRACE_GRAMMAR(identifier, | DEFINER ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| DEDUPLICATE_ {{ DBG_TRACE_GRAMMAR(identifier, | DEDUPLICATE_ ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| DENSE_RANK {{ DBG_TRACE_GRAMMAR(identifier, | DENSE_RANK ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| DETERMINISTIC {{ DBG_TRACE_GRAMMAR(identifier, | DETERMINISTIC ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| DISK_SIZE {{ DBG_TRACE_GRAMMAR(identifier, | DISK_SIZE ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| DONT_REUSE_OID {{ DBG_TRACE_GRAMMAR(identifier, | DONT_REUSE_OID ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
| ELT {{ DBG_TRACE_GRAMMAR(identifier, | ELT ); SET_CPTR_2_PTNAME($$, $1, @$.buffer_pos); }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
#include "jsp_cl.h" | ||
#include "subquery_cache.h" | ||
#include "pl_signature.hpp" | ||
#include "sp_catalog.hpp" | ||
|
||
#if defined(WINDOWS) | ||
#include "wintcp.h" | ||
|
@@ -27623,7 +27624,21 @@ pt_make_sq_cache_key_struct (QPROC_DB_VALUE_LIST key_struct, void *p, int type) | |
} | ||
break; | ||
case TYPE_SP: | ||
/* 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 defined (CS_MODE) | ||
if (regu_src->value.sp_ptr->sig->is_deterministic == false) | ||
{ | ||
return ER_FAILED; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 불필요한 assign 문이 실행되지 않도록 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코드 리뷰 감사합니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [질문] 이 리턴문이 deterministic 하지 않은 function 은 query cache 를 사용하지 못하도록 제약하는 효과가 있는 것인가요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네, 맞습니다. deterministic 키워드를 사용한 function만 아래 로직을 수행하여 query cache 사용할 수 있습니다. |
||
} | ||
#endif | ||
|
||
regu_var_list_p = regu_src->value.sp_ptr->args; | ||
|
||
while (regu_var_list_p) | ||
{ | ||
regu_src = ®u_var_list_p->value; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
authid_spec 과 deterministic_spec 이 순서가 바뀌어도 에러가 나지 않도록 문법 구성을 해야 할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드 리뷰 감사합니다.
말씀해 주신 부분은 조금 더 코드 분석을 진행한 후 반영하도록 하겠습니다.