-
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-25762] When a general user performs a trigger unload, remove [user_schema] from condition and action_definition if the owner is the user themselves. #5731
base: develop
Are you sure you want to change the base?
Changes from all commits
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 | ||
---|---|---|---|---|
|
@@ -245,6 +245,9 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri | |||
char owner_name[DB_MAX_USER_LENGTH] = { '\0' }; | ||||
const char *trigger_name = NULL; | ||||
const char *class_name = NULL; | ||||
PARSER_CONTEXT *parser; | ||||
PT_NODE **action_node = nullptr, **condition_node = nullptr; | ||||
char *query_action_result, *query_condition_result; | ||||
|
||||
AU_DISABLE (save); | ||||
|
||||
|
@@ -314,7 +317,65 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri | |||
|
||||
if (trigger->condition != NULL) | ||||
{ | ||||
output_ctx ("IF %s\n", trigger->condition->source); | ||||
char *text; | ||||
int length; | ||||
const char *eval_prefix = "EVALUATE ( "; | ||||
const char *eval_suffix = " ) "; | ||||
char *p = NULL; | ||||
const char *remove_eval_prefix = "evaluate ("; | ||||
size_t remove_eval_suffix_len; | ||||
|
||||
length = strlen (eval_prefix) + strlen (trigger->condition->source) + strlen (eval_suffix) + 1; | ||||
text = (char *) malloc (length); | ||||
if (text == NULL) | ||||
{ | ||||
output_ctx ("/* ERROR : IF %s */\n", trigger->condition->source); | ||||
error = ER_OUT_OF_VIRTUAL_MEMORY; | ||||
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) length); | ||||
free_and_init (text); | ||||
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.
Suggested change
text == NULL 이기 때문에 free_and_init 을 하지 않아도 될 것 같습니다. |
||||
return error; | ||||
} | ||||
strcpy (text, eval_prefix); | ||||
strcat (text, trigger->condition->source); | ||||
strcat (text, eval_suffix); | ||||
|
||||
parser = parser_create_parser (); | ||||
if (parser == NULL) | ||||
{ | ||||
output_ctx ("/* ERROR : IF %s */\n", trigger->condition->source); | ||||
} | ||||
Comment on lines
+342
to
+346
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. 아래 로직에서 parser 에 접근하기 때문에, parser == NULL 이면 함수를 종료해야 할 필요가 있어 보입니다. |
||||
|
||||
if (ctxt.is_dba_user == false && ctxt.is_dba_group_member == false) | ||||
{ | ||||
parser->custom_print |= PT_PRINT_NO_CURRENT_USER_NAME; | ||||
} | ||||
|
||||
condition_node = parser_parse_string (parser, text); | ||||
if (condition_node != NULL) | ||||
{ | ||||
query_condition_result = parser_print_tree_with_quotes (parser, *condition_node); | ||||
|
||||
/* remove appended trigger evaluate info */ | ||||
p = strstr (query_condition_result, remove_eval_prefix); | ||||
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. p == NULL 을 처리해야 할 필요가 있어 보입니다. |
||||
if (p != NULL) | ||||
{ | ||||
p = (char *) memmove (p, p + strlen (remove_eval_prefix), strlen (p) - strlen (remove_eval_prefix) + 1); | ||||
} | ||||
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. else 구문으로 P가 NULL인 경우에 대한 처리가 필요합니다. |
||||
|
||||
remove_eval_suffix_len = strlen (p); | ||||
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. 362라인이 잘 수행된 후에는 |
||||
if (remove_eval_suffix_len > 0 && p[remove_eval_suffix_len - 1] == ')') | ||||
{ | ||||
p[remove_eval_suffix_len - 1] = '\0'; | ||||
} | ||||
Comment on lines
+366
to
+369
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.
|
||||
|
||||
output_ctx ("IF %s\n", query_condition_result); | ||||
} | ||||
else | ||||
{ | ||||
output_ctx ("/* ERROR : IF %s */\n", trigger->condition->source); | ||||
} | ||||
parser_free_parser (parser); | ||||
free_and_init (text); | ||||
} | ||||
|
||||
if (trigger->action != NULL) | ||||
|
@@ -327,7 +388,28 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri | |||
switch (trigger->action->type) | ||||
{ | ||||
case TR_ACT_EXPRESSION: | ||||
output_ctx ("%s", trigger->action->source); | ||||
parser = parser_create_parser (); | ||||
if (parser == NULL) | ||||
{ | ||||
output_ctx ("\n/* ERROR : EXECUTE %s */\n", trigger->action->source); | ||||
} | ||||
Comment on lines
+392
to
+395
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. 아래 로직에서 parser 에 접근하기 때문에, parser == NULL 이면 함수를 종료해야 할 필요가 있어 보입니다. |
||||
|
||||
if (ctxt.is_dba_user == false && ctxt.is_dba_group_member == false) | ||||
{ | ||||
parser->custom_print |= PT_PRINT_NO_CURRENT_USER_NAME; | ||||
} | ||||
|
||||
action_node = parser_parse_string (parser, trigger->action->source); | ||||
if (action_node != NULL) | ||||
{ | ||||
query_action_result = parser_print_tree_with_quotes (parser, *action_node); | ||||
output_ctx ("%s", query_action_result); | ||||
} | ||||
else | ||||
{ | ||||
output_ctx ("\n/* ERROR : EXECUTE %s */\n", trigger->action->source); | ||||
} | ||||
parser_free_parser (parser); | ||||
break; | ||||
case TR_ACT_REJECT: | ||||
output_ctx ("REJECT"); | ||||
|
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.
trigger_manager.c 에 EVAL_PREFIX 와 EVAL_SUFFIX 가 static const char 로 선언되어 있는데, 이것을 활용할 수 있도록 수정하는 것이 더 좋을 거 같습니다.
https://github.com/jongmin-won/cubrid/blob/be32f5eab076f699c955defe8db2da98a13462e9/src/object/trigger_manager.c#L128-L129