From 09c93465d4a9729a7f83fdf6c4f077b3352a7047 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Thu, 19 Dec 2024 21:08:54 +0900 Subject: [PATCH 01/14] =?UTF-8?q?1.=20Fix=20the=20issue=20where=20[user=5F?= =?UTF-8?q?schema]=20is=20not=20added=20to=20the=20action=20and=20conditio?= =?UTF-8?q?n=20columns=20of=20the=20db=5Ftrigger=20catalog=20when=20SP=20i?= =?UTF-8?q?s=20included=20when=20performing=20create=20trigger,=202.=20Whe?= =?UTF-8?q?n=20creating=20a=20trigger=20with=20the=20loaddb=20--no-user-sp?= =?UTF-8?q?ecified-name=20utility,=20find=20the=20actual=20owner=20and=20m?= =?UTF-8?q?odify=20it=20to=20save=20it=20in=20the=20db=5Ftrigger=20catalog?= =?UTF-8?q?,=203.=20When=20performing=20the=20unload=20utility,=20remove?= =?UTF-8?q?=20the=20owner=E2=80=99s=20[user=5Fschema]=20from=20the=20actio?= =?UTF-8?q?n=20and=20condition=20columns.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/object/trigger_description.cpp | 51 ++++++++++++++++++- src/object/trigger_manager.c | 3 +- src/parser/compile.c | 78 +++++++++++++++++++++++++++++- src/parser/parse_tree.c | 1 + src/parser/parse_tree.h | 1 + src/parser/parse_tree_cl.c | 9 ++++ src/parser/parser.h | 2 +- 7 files changed, 140 insertions(+), 5 deletions(-) diff --git a/src/object/trigger_description.cpp b/src/object/trigger_description.cpp index b651181597d..4ef715f905d 100644 --- a/src/object/trigger_description.cpp +++ b/src/object/trigger_description.cpp @@ -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, **condition_node; + char *query_action_result, *query_condition_result; AU_DISABLE (save); @@ -303,7 +306,30 @@ 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); + parser = parser_create_parser (); + if (parser == NULL) + { + output_ctx ("/* ERROR : IF %s */\n", trigger->condition->source); + } + + if (ctxt.is_dba_user == false && ctxt.is_dba_group_member == false) + { + parser->custom_print |= PT_PRINT_NO_CURRENT_USER_NAME; + } + + // 여기서 에러가 발생함 ~!! + // evaluate () 을 추가해야 함. + condition_node = parser_parse_string (parser, trigger->condition->source); + if (condition_node != NULL) + { + query_condition_result = parser_print_tree_with_quotes (parser, *action_node); + output_ctx ("IF %s\n", query_condition_result); + } + else + { + output_ctx ("/* ERROR : IF %s */\n", trigger->condition->source); + } + parser_free_parser (parser); } if (trigger->action != NULL) @@ -316,7 +342,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 ("/* ERROR : EXECUTE %s */\n", trigger->action->source); + } + + 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 ("/* ERROR : EXECUTE %s */\n", trigger->action->source); + } + parser_free_parser (parser); break; case TR_ACT_REJECT: output_ctx ("REJECT"); diff --git a/src/object/trigger_manager.c b/src/object/trigger_manager.c index 2bd5460431c..1046fd42a58 100644 --- a/src/object/trigger_manager.c +++ b/src/object/trigger_manager.c @@ -1668,7 +1668,8 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with class_mop = ((curname == NULL && tempname == NULL) ? NULL : trigger->class_mop); activity->statement = - pt_compile_trigger_stmt ((PARSER_CONTEXT *) activity->parser, text, class_mop, curname, tempname); + pt_compile_trigger_stmt ((PARSER_CONTEXT *) activity->parser, text, class_mop, curname, tempname, + &activity->source); if (activity->statement == NULL || pt_has_error ((PARSER_CONTEXT *) activity->parser)) { error = er_errid (); diff --git a/src/parser/compile.c b/src/parser/compile.c index ab725c7fc0a..ed93206cead 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -83,6 +83,8 @@ static PT_NODE *pt_find_lck_class_from_partition (PARSER_CONTEXT * parser, PT_NO static int pt_in_lck_array (PT_CLASS_LOCKS * lcks, const char *str, LC_PREFETCH_FLAGS flags); static void remove_appended_trigger_info (char *msg, int with_evaluate); +static int change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char **new_trigger_stmt, + int with_evaluate); static PT_NODE *pt_set_trigger_obj_pre (PARSER_CONTEXT * parser, PT_NODE * node, void *arg, int *continue_walk); static PT_NODE *pt_set_trigger_obj_post (PARSER_CONTEXT * parser, PT_NODE * node, void *arg, int *continue_walk); @@ -1043,6 +1045,68 @@ remove_appended_trigger_info (char *msg, int with_evaluate) } } +/* + * change_trigger_action_query () - remove appended trigger info + * parser(in): + * action_stmt(in): + * with_evaluate(in): + */ +static int +change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char **new_trigger_stmt, int with_evaluate) +{ + int error = NO_ERROR; + char *new_trigger_stmt_str = NULL; + unsigned int save_custom; + + assert (parser != NULL || statement != NULL); + + if (!*new_trigger_stmt) + return NULL; + + save_custom = parser->custom_print; + + parser->custom_print |= PT_SUPPRESS_RESOLVED; + parser->flag.is_parsing_trigger = 1; + + new_trigger_stmt_str = parser_print_tree_with_quotes (parser, statement); + + parser->flag.is_parsing_trigger = 0; + parser->custom_print = save_custom; + + if (new_trigger_stmt_str == NULL) + { + return NULL; + } + + /* remove appended trigger info */ + if (with_evaluate) + { + char *p = NULL; + const char *eval_prefix = "evaluate ("; + size_t eval_suffix_len; + + p = strstr (new_trigger_stmt_str, eval_prefix); + if (p != NULL) + { + p = (char *) memmove (p, p + strlen (eval_prefix), strlen (p) - strlen (eval_prefix) + 1); + } + + eval_suffix_len = strlen (p); + if (eval_suffix_len > 0 && p[eval_suffix_len - 1] == ')') + { + p[eval_suffix_len - 1] = '\0'; + } + } + + if (new_trigger_stmt_str != NULL && *new_trigger_stmt) + { + free_and_init (*new_trigger_stmt); + *new_trigger_stmt = strdup (new_trigger_stmt_str); + } + + return error; +} + /* * pt_compile_trigger_stmt () - Compiles the trigger_stmt so that it can be * executed by pt_exec_trigger_stmt @@ -1057,7 +1121,7 @@ remove_appended_trigger_info (char *msg, int with_evaluate) PT_NODE * pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_OBJECT * class_op, const char *name1, - const char *name2) + const char *name2, char **new_trigger_stmt) { char *stmt_str = NULL; const char *class_name; @@ -1177,6 +1241,18 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O /* We need to do view translation here on the expression to be executed. */ if (statement) { + int error = NO_ERROR; + + with_evaluate = strstr (trigger_stmt, "EVALUATE ( ") != NULL ? true : false; + + error = + change_trigger_action_query (parser, statement->info.scope.stmt->info.trigger_action.expression, + new_trigger_stmt, with_evaluate); + if (error != NO_ERROR) + { + return NULL; + } + statement->info.scope.stmt->info.trigger_action.expression = mq_translate (parser, statement->info.scope.stmt->info.trigger_action.expression); /* diff --git a/src/parser/parse_tree.c b/src/parser/parse_tree.c index 190c738697c..165fbfcf51d 100644 --- a/src/parser/parse_tree.c +++ b/src/parser/parse_tree.c @@ -1233,6 +1233,7 @@ parser_create_parser (void) parser->flag.is_auto_commit = 0; parser->flag.is_parsing_static_sql = 0; parser->flag.is_parsing_unload_schema = 0; + parser->flag.is_parsing_trigger = 0; parser->external_into_label = NULL; parser->external_into_label_cnt = 0; diff --git a/src/parser/parse_tree.h b/src/parser/parse_tree.h index bdc1e739ce0..1700bc88ada 100644 --- a/src/parser/parse_tree.h +++ b/src/parser/parse_tree.h @@ -4020,6 +4020,7 @@ struct parser_context unsigned is_auto_commit:1; /* set to true, if auto commit. */ unsigned is_parsing_static_sql:1; /* For PL/CSQL's static SQL: parameterize PL/CSQL variable symbols (to host variable) */ unsigned is_parsing_unload_schema:1; /* Parsing in unload: used to parse the scode (original query) of PL/CSQL to remove the owner. */ + unsigned is_parsing_trigger:1; } flag; }; diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 38bf91c5fde..d6646e4945e 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -13573,6 +13573,15 @@ pt_print_name (PARSER_CONTEXT * parser, PT_NODE * p) parser->custom_print = parser->custom_print | p->info.name.custom_print; + if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) + { + if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 + || strcasecmp (p->info.name.resolved, "old") == 0) + { + parser->custom_print &= ~PT_SUPPRESS_RESOLVED; + } + } + if (!(parser->custom_print & PT_SUPPRESS_META_ATTR_CLASS) && (p->info.name.meta_class == PT_META_CLASS)) { q = pt_append_nulstring (parser, q, "class "); diff --git a/src/parser/parser.h b/src/parser/parser.h index 446024d7bf3..f466126f801 100644 --- a/src/parser/parser.h +++ b/src/parser/parser.h @@ -203,7 +203,7 @@ extern "C" extern PT_NODE *pt_class_pre_fetch (PARSER_CONTEXT * parser, PT_NODE * statement); extern PT_NODE *pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_OBJECT * class_op, - const char *name1, const char *name2); + const char *name1, const char *name2, char **new_trigger_stmt); extern int pt_exec_trigger_stmt (PARSER_CONTEXT * parser, PT_NODE * trigger_stmt, DB_OBJECT * object1, DB_OBJECT * object2, DB_VALUE * result); From 55a843083d36244bcea6784626a1af2c5470e9be Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 10:28:51 +0900 Subject: [PATCH 02/14] Remove [user_schema] from the condition column when the owner performs the unload utility. --- src/object/trigger_description.cpp | 47 ++++++++++++++++++++++++++---- src/parser/compile.c | 20 ++++++------- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/object/trigger_description.cpp b/src/object/trigger_description.cpp index af0b5b00390..922f1e5fa10 100644 --- a/src/object/trigger_description.cpp +++ b/src/object/trigger_description.cpp @@ -246,7 +246,7 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri const char *trigger_name = NULL; const char *class_name = NULL; PARSER_CONTEXT *parser; - PT_NODE **action_node, **condition_node; + PT_NODE **action_node = nullptr, **condition_node = nullptr; char *query_action_result, *query_condition_result; AU_DISABLE (save); @@ -317,6 +317,28 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri if (trigger->condition != NULL) { + 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); + return error; + } + strcpy (text, eval_prefix); + strcat (text, trigger->condition->source); + strcat (text, eval_suffix); + parser = parser_create_parser (); if (parser == NULL) { @@ -328,19 +350,32 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri parser->custom_print |= PT_PRINT_NO_CURRENT_USER_NAME; } - // 여기서 에러가 발생함 ~!! - // evaluate () 을 추가해야 함. - condition_node = parser_parse_string (parser, trigger->condition->source); + condition_node = parser_parse_string (parser, text); if (condition_node != NULL) { - query_condition_result = parser_print_tree_with_quotes (parser, *action_node); - output_ctx ("IF %s\n", query_condition_result); + query_condition_result = parser_print_tree_with_quotes (parser, *condition_node); + + /* remove appended trigger evaluate info */ + p = strstr (query_condition_result, remove_eval_prefix); + if (p != NULL) + { + p = (char *) memmove (p, p + strlen (remove_eval_prefix), strlen (p) - strlen (remove_eval_prefix) + 1); + } + + remove_eval_suffix_len = strlen (p); + if (remove_eval_suffix_len > 0 && p[remove_eval_suffix_len - 1] == ')') + { + p[remove_eval_suffix_len - 1] = '\0'; + } + + 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) diff --git a/src/parser/compile.c b/src/parser/compile.c index ed93206cead..87f48295c75 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1061,7 +1061,7 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char assert (parser != NULL || statement != NULL); if (!*new_trigger_stmt) - return NULL; + return ER_FAILED; save_custom = parser->custom_print; @@ -1075,26 +1075,26 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char if (new_trigger_stmt_str == NULL) { - return NULL; + return ER_FAILED; } - /* remove appended trigger info */ + /* remove appended trigger evaluate info */ if (with_evaluate) { char *p = NULL; - const char *eval_prefix = "evaluate ("; - size_t eval_suffix_len; + const char *remove_eval_prefix = "evaluate ("; + size_t remove_eval_suffix_len; - p = strstr (new_trigger_stmt_str, eval_prefix); + p = strstr (new_trigger_stmt_str, remove_eval_prefix); if (p != NULL) { - p = (char *) memmove (p, p + strlen (eval_prefix), strlen (p) - strlen (eval_prefix) + 1); + p = (char *) memmove (p, p + strlen (remove_eval_prefix), strlen (p) - strlen (remove_eval_prefix) + 1); } - eval_suffix_len = strlen (p); - if (eval_suffix_len > 0 && p[eval_suffix_len - 1] == ')') + remove_eval_suffix_len = strlen (p); + if (remove_eval_suffix_len > 0 && p[remove_eval_suffix_len - 1] == ')') { - p[eval_suffix_len - 1] = '\0'; + p[remove_eval_suffix_len - 1] = '\0'; } } From 195ad207ab3e28acaa2b994b5bc9ba860fae3efa Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 12:29:51 +0900 Subject: [PATCH 03/14] Remove warning messages in the parse_tree_cl file. --- src/parser/parse_tree_cl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 1f225a5c9fd..92daf61b6ef 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -8609,20 +8609,20 @@ pt_print_datatype (PARSER_CONTEXT * parser, PT_NODE * p) if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "national character"); - break; } + break; case PT_TYPE_VARNCHAR: if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "national character varying"); - break; } + break; case PT_TYPE_CHAR: if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "character"); - break; } + break; case PT_TYPE_VARCHAR: if (!parser->flag.is_parsing_unload_schema) { From 5adef6731daeb6af98099efd9c03d8bbdf0a5586 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 13:22:31 +0900 Subject: [PATCH 04/14] Fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/parse_tree_cl.c | 27 +++++++++++++++++---------- src/query/execute_statement.c | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 92daf61b6ef..88c31ef66e5 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -2863,6 +2863,11 @@ pt_print_and_list (PARSER_CONTEXT * parser, const PT_NODE * p) for (n = p; n; n = n->next) { /* print in the original order ... */ + if (parser->flag.is_parsing_trigger == 1) + { + parser->custom_print &= ~PT_SUPPRESS_RESOLVED; + } + r1 = pt_print_bytes (parser, n); if (n->node_type == PT_EXPR && !n->info.expr.paren_type && n->or_next) { @@ -8632,8 +8637,8 @@ pt_print_datatype (PARSER_CONTEXT * parser, PT_NODE * p) else { q = pt_append_nulstring (parser, q, "character varying"); - break; } + break; case PT_TYPE_BIT: case PT_TYPE_VARBIT: case PT_TYPE_FLOAT: @@ -13576,18 +13581,20 @@ pt_print_name (PARSER_CONTEXT * parser, PT_NODE * p) PARSER_VARCHAR *q = NULL, *r1; unsigned int save_custom = parser->custom_print; - char *dot = NULL; + //char *dot = NULL; parser->custom_print = parser->custom_print | p->info.name.custom_print; - if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) - { - if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 - || strcasecmp (p->info.name.resolved, "old") == 0) - { - parser->custom_print &= ~PT_SUPPRESS_RESOLVED; - } - } + /* + if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) + { + if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 + || strcasecmp (p->info.name.resolved, "old") == 0) + { + parser->custom_print &= ~PT_SUPPRESS_RESOLVED; + } + } + */ if (!(parser->custom_print & PT_SUPPRESS_META_ATTR_CLASS) && (p->info.name.meta_class == PT_META_CLASS)) { diff --git a/src/query/execute_statement.c b/src/query/execute_statement.c index 0bb255af332..1900c068438 100644 --- a/src/query/execute_statement.c +++ b/src/query/execute_statement.c @@ -6589,6 +6589,7 @@ get_activity_info (PARSER_CONTEXT * parser, DB_TRIGGER_ACTION * type, const char /* complex expression */ *type = TR_ACT_EXPRESSION; save_custom = parser->custom_print; + parser->custom_print |= PT_SUPPRESS_RESOLVED; *source = parser_print_tree_with_quotes (parser, statement); parser->custom_print = save_custom; } From fc4c1d8e492e715aaaf3cf9537045988c6754ca5 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 14:14:43 +0900 Subject: [PATCH 05/14] Second. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/compile.c | 1 - src/parser/parse_tree_cl.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index 87f48295c75..364d2e8c536 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1065,7 +1065,6 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char save_custom = parser->custom_print; - parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->flag.is_parsing_trigger = 1; new_trigger_stmt_str = parser_print_tree_with_quotes (parser, statement); diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 88c31ef66e5..2541492c4b0 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -2863,11 +2863,6 @@ pt_print_and_list (PARSER_CONTEXT * parser, const PT_NODE * p) for (n = p; n; n = n->next) { /* print in the original order ... */ - if (parser->flag.is_parsing_trigger == 1) - { - parser->custom_print &= ~PT_SUPPRESS_RESOLVED; - } - r1 = pt_print_bytes (parser, n); if (n->node_type == PT_EXPR && !n->info.expr.paren_type && n->or_next) { @@ -13025,7 +13020,7 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) // TODO: [PL/CSQL] need refactoring unsigned int save_custom = parser->custom_print; - if (parser->flag.is_parsing_static_sql == 1) + if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) { parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->custom_print & ~PT_PRINT_ALIAS; From 5c34b6a0e051cce795947487c0a1eb560246eb84 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 18:09:13 +0900 Subject: [PATCH 06/14] Third. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/object/trigger_description.cpp | 4 ++-- src/parser/parse_tree_cl.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/object/trigger_description.cpp b/src/object/trigger_description.cpp index 922f1e5fa10..8d8c89d059c 100644 --- a/src/object/trigger_description.cpp +++ b/src/object/trigger_description.cpp @@ -391,7 +391,7 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri parser = parser_create_parser (); if (parser == NULL) { - output_ctx ("/* ERROR : EXECUTE %s */\n", trigger->action->source); + output_ctx ("\n/* ERROR : EXECUTE %s */\n", trigger->action->source); } if (ctxt.is_dba_user == false && ctxt.is_dba_group_member == false) @@ -407,7 +407,7 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri } else { - output_ctx ("/* ERROR : EXECUTE %s */\n", trigger->action->source); + output_ctx ("\n/* ERROR : EXECUTE %s */\n", trigger->action->source); } parser_free_parser (parser); break; diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 2541492c4b0..53258fbdcde 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -11664,6 +11664,11 @@ pt_print_expr (PARSER_CONTEXT * parser, PT_NODE * p) else { r2 = pt_print_bytes (parser, p->info.expr.cast_type); + if (r2 == NULL) + { + q = pt_append_varchar (parser, q, r1); + break; + } q = pt_append_nulstring (parser, q, " cast("); q = pt_append_varchar (parser, q, r1); q = pt_append_nulstring (parser, q, " as "); @@ -13020,12 +13025,17 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) // TODO: [PL/CSQL] need refactoring unsigned int save_custom = parser->custom_print; - if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) + if (parser->flag.is_parsing_static_sql == 1) { parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->custom_print & ~PT_PRINT_ALIAS; } + if (parser->flag.is_parsing_trigger == 1) + { + parser->custom_print |= PT_SUPPRESS_RESOLVED; + } + r1 = pt_print_bytes (parser, p->info.insert.spec); r2 = pt_print_bytes_l (parser, p->info.insert.attr_list); From 3cc99b95da694f458231438f6bb66ddd010da50c Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 20:13:11 +0900 Subject: [PATCH 07/14] Fourth. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/parse_tree_cl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index 53258fbdcde..e5e8c1fbcbe 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -8609,20 +8609,20 @@ pt_print_datatype (PARSER_CONTEXT * parser, PT_NODE * p) if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "national character"); + break; } - break; case PT_TYPE_VARNCHAR: if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "national character varying"); + break; } - break; case PT_TYPE_CHAR: if (parser->flag.is_parsing_unload_schema) { q = pt_append_nulstring (parser, q, "character"); + break; } - break; case PT_TYPE_VARCHAR: if (!parser->flag.is_parsing_unload_schema) { @@ -8632,8 +8632,8 @@ pt_print_datatype (PARSER_CONTEXT * parser, PT_NODE * p) else { q = pt_append_nulstring (parser, q, "character varying"); + break; } - break; case PT_TYPE_BIT: case PT_TYPE_VARBIT: case PT_TYPE_FLOAT: From 2d1f5b8022c2d48c3f7d8e6ab00a8ec838bca8a0 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Fri, 20 Dec 2024 20:44:12 +0900 Subject: [PATCH 08/14] Fifth. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/parse_tree_cl.c | 12 +----------- src/query/execute_statement.c | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index e5e8c1fbcbe..fb8173b1bbb 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -11664,11 +11664,6 @@ pt_print_expr (PARSER_CONTEXT * parser, PT_NODE * p) else { r2 = pt_print_bytes (parser, p->info.expr.cast_type); - if (r2 == NULL) - { - q = pt_append_varchar (parser, q, r1); - break; - } q = pt_append_nulstring (parser, q, " cast("); q = pt_append_varchar (parser, q, r1); q = pt_append_nulstring (parser, q, " as "); @@ -13025,17 +13020,12 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) // TODO: [PL/CSQL] need refactoring unsigned int save_custom = parser->custom_print; - if (parser->flag.is_parsing_static_sql == 1) + if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) { parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->custom_print & ~PT_PRINT_ALIAS; } - if (parser->flag.is_parsing_trigger == 1) - { - parser->custom_print |= PT_SUPPRESS_RESOLVED; - } - r1 = pt_print_bytes (parser, p->info.insert.spec); r2 = pt_print_bytes_l (parser, p->info.insert.attr_list); diff --git a/src/query/execute_statement.c b/src/query/execute_statement.c index 1900c068438..0bb255af332 100644 --- a/src/query/execute_statement.c +++ b/src/query/execute_statement.c @@ -6589,7 +6589,6 @@ get_activity_info (PARSER_CONTEXT * parser, DB_TRIGGER_ACTION * type, const char /* complex expression */ *type = TR_ACT_EXPRESSION; save_custom = parser->custom_print; - parser->custom_print |= PT_SUPPRESS_RESOLVED; *source = parser_print_tree_with_quotes (parser, statement); parser->custom_print = save_custom; } From 1034d8374e58dfeea5e8ecad72281b5f5db45088 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Sat, 21 Dec 2024 02:49:46 +0900 Subject: [PATCH 09/14] Sixth. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/compile.c | 6 ++++++ src/parser/parse_tree_cl.c | 33 +++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index 364d2e8c536..ed9c4b09e8f 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1066,6 +1066,7 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char save_custom = parser->custom_print; parser->flag.is_parsing_trigger = 1; + parser->custom_print |= PT_SUPPRESS_RESOLVED; new_trigger_stmt_str = parser_print_tree_with_quotes (parser, statement); @@ -1223,8 +1224,13 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O upd->info.update.spec = entity; } + /* prevents forced cast() within the code. (parser->flag.is_parsing_trigger == 1 && p->info.expr.flag != 0) */ + parser->flag.is_parsing_trigger = 1; + statement = pt_compile (parser, statement); + parser->flag.is_parsing_trigger = 0; + /* Remove those info we append, which users can't understand them */ if (pt_has_error (parser)) { diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index fb8173b1bbb..ce9b3fad190 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -11663,6 +11663,12 @@ pt_print_expr (PARSER_CONTEXT * parser, PT_NODE * p) } else { + if (parser->flag.is_parsing_trigger == 1 && p->info.expr.flag != 0) + { + q = pt_append_varchar (parser, q, r1); + break; + } + r2 = pt_print_bytes (parser, p->info.expr.cast_type); q = pt_append_nulstring (parser, q, " cast("); q = pt_append_varchar (parser, q, r1); @@ -13020,7 +13026,8 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) // TODO: [PL/CSQL] need refactoring unsigned int save_custom = parser->custom_print; - if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) + //if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) + if (parser->flag.is_parsing_static_sql == 1) { parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->custom_print & ~PT_PRINT_ALIAS; @@ -13029,6 +13036,11 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) r1 = pt_print_bytes (parser, p->info.insert.spec); r2 = pt_print_bytes_l (parser, p->info.insert.attr_list); + if (parser->flag.is_parsing_trigger == 1) + { + r2 = NULL; + } + parser->custom_print = save_custom; if (p->info.insert.is_subinsert == PT_IS_SUBINSERT) @@ -13579,17 +13591,14 @@ pt_print_name (PARSER_CONTEXT * parser, PT_NODE * p) //char *dot = NULL; parser->custom_print = parser->custom_print | p->info.name.custom_print; - - /* - if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) - { - if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 - || strcasecmp (p->info.name.resolved, "old") == 0) - { - parser->custom_print &= ~PT_SUPPRESS_RESOLVED; - } - } - */ + //if (parser->flag.is_parsing_trigger != 1 && (*parser->statements)->node_type != PT_SCOPE) + if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) + { + //if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 || strcasecmp (p->info.name.resolved, "old") == 0) + //{ + parser->custom_print &= ~PT_SUPPRESS_RESOLVED; + //} + } if (!(parser->custom_print & PT_SUPPRESS_META_ATTR_CLASS) && (p->info.name.meta_class == PT_META_CLASS)) { From 897bb06250eb3ed15cde43d17c8f8732a6106a17 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Sat, 21 Dec 2024 22:53:48 +0900 Subject: [PATCH 10/14] Seventh. fixed an issue where the action query entered by the user was rewritten into an unexecutable rewrite query. --- src/parser/compile.c | 1 - src/parser/parse_tree_cl.c | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index ed9c4b09e8f..26f71e4e355 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1066,7 +1066,6 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char save_custom = parser->custom_print; parser->flag.is_parsing_trigger = 1; - parser->custom_print |= PT_SUPPRESS_RESOLVED; new_trigger_stmt_str = parser_print_tree_with_quotes (parser, statement); diff --git a/src/parser/parse_tree_cl.c b/src/parser/parse_tree_cl.c index ce9b3fad190..964b9aca972 100644 --- a/src/parser/parse_tree_cl.c +++ b/src/parser/parse_tree_cl.c @@ -13026,8 +13026,7 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) // TODO: [PL/CSQL] need refactoring unsigned int save_custom = parser->custom_print; - //if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) - if (parser->flag.is_parsing_static_sql == 1) + if (parser->flag.is_parsing_static_sql == 1 || parser->flag.is_parsing_trigger == 1) { parser->custom_print |= PT_SUPPRESS_RESOLVED; parser->custom_print & ~PT_PRINT_ALIAS; @@ -13036,11 +13035,6 @@ pt_print_insert (PARSER_CONTEXT * parser, PT_NODE * p) r1 = pt_print_bytes (parser, p->info.insert.spec); r2 = pt_print_bytes_l (parser, p->info.insert.attr_list); - if (parser->flag.is_parsing_trigger == 1) - { - r2 = NULL; - } - parser->custom_print = save_custom; if (p->info.insert.is_subinsert == PT_IS_SUBINSERT) @@ -13588,17 +13582,7 @@ pt_print_name (PARSER_CONTEXT * parser, PT_NODE * p) PARSER_VARCHAR *q = NULL, *r1; unsigned int save_custom = parser->custom_print; - //char *dot = NULL; - parser->custom_print = parser->custom_print | p->info.name.custom_print; - //if (parser->flag.is_parsing_trigger != 1 && (*parser->statements)->node_type != PT_SCOPE) - if (parser->flag.is_parsing_trigger == 1 && p->info.name.resolved != NULL) - { - //if (strcasecmp (p->info.name.resolved, "obj") == 0 || strcasecmp (p->info.name.resolved, "new") == 0 || strcasecmp (p->info.name.resolved, "old") == 0) - //{ - parser->custom_print &= ~PT_SUPPRESS_RESOLVED; - //} - } if (!(parser->custom_print & PT_SUPPRESS_META_ATTR_CLASS) && (p->info.name.meta_class == PT_META_CLASS)) { From 93e18aa2320e57aa14c0bfbf04a54012045923c2 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Sun, 22 Dec 2024 01:09:13 +0900 Subject: [PATCH 11/14] The unload utility part will be fixed in issue CBRD-25762. --- src/object/trigger_description.cpp | 86 +----------------------------- 1 file changed, 2 insertions(+), 84 deletions(-) diff --git a/src/object/trigger_description.cpp b/src/object/trigger_description.cpp index 8d8c89d059c..86930e73606 100644 --- a/src/object/trigger_description.cpp +++ b/src/object/trigger_description.cpp @@ -245,9 +245,6 @@ 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); @@ -317,65 +314,7 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri if (trigger->condition != NULL) { - 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); - 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); - } - - 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); - if (p != NULL) - { - p = (char *) memmove (p, p + strlen (remove_eval_prefix), strlen (p) - strlen (remove_eval_prefix) + 1); - } - - remove_eval_suffix_len = strlen (p); - if (remove_eval_suffix_len > 0 && p[remove_eval_suffix_len - 1] == ')') - { - p[remove_eval_suffix_len - 1] = '\0'; - } - - 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); + output_ctx ("IF %s\n", trigger->condition->source); } if (trigger->action != NULL) @@ -388,28 +327,7 @@ tr_dump_trigger (extract_context &ctxt, print_output &output_ctx, DB_OBJECT *tri switch (trigger->action->type) { case TR_ACT_EXPRESSION: - parser = parser_create_parser (); - if (parser == NULL) - { - output_ctx ("\n/* ERROR : EXECUTE %s */\n", trigger->action->source); - } - - 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); + output_ctx ("%s", trigger->action->source); break; case TR_ACT_REJECT: output_ctx ("REJECT"); From c0a67aeae439fd2986f1dc0f58e3dd7206f1feda Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 24 Dec 2024 00:57:30 +0900 Subject: [PATCH 12/14] Fixed the memory-monitor-check failure issue. We suspected that a memory management issue in the change_trigger_action_query function might be the cause and have made adjustments to address it. --- src/parser/compile.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index 26f71e4e355..c4b017711ed 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -83,8 +83,7 @@ static PT_NODE *pt_find_lck_class_from_partition (PARSER_CONTEXT * parser, PT_NO static int pt_in_lck_array (PT_CLASS_LOCKS * lcks, const char *str, LC_PREFETCH_FLAGS flags); static void remove_appended_trigger_info (char *msg, int with_evaluate); -static int change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char **new_trigger_stmt, - int with_evaluate); +static char *change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, int with_evaluate); static PT_NODE *pt_set_trigger_obj_pre (PARSER_CONTEXT * parser, PT_NODE * node, void *arg, int *continue_walk); static PT_NODE *pt_set_trigger_obj_post (PARSER_CONTEXT * parser, PT_NODE * node, void *arg, int *continue_walk); @@ -1051,30 +1050,28 @@ remove_appended_trigger_info (char *msg, int with_evaluate) * action_stmt(in): * with_evaluate(in): */ -static int -change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char **new_trigger_stmt, int with_evaluate) +static char * +change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, int with_evaluate) { - int error = NO_ERROR; + int result_len = 0; + char *result = NULL; char *new_trigger_stmt_str = NULL; unsigned int save_custom; assert (parser != NULL || statement != NULL); - if (!*new_trigger_stmt) - return ER_FAILED; - save_custom = parser->custom_print; parser->flag.is_parsing_trigger = 1; - new_trigger_stmt_str = parser_print_tree_with_quotes (parser, statement); + result = parser_print_tree_with_quotes (parser, statement); parser->flag.is_parsing_trigger = 0; parser->custom_print = save_custom; - if (new_trigger_stmt_str == NULL) + if (result == NULL) { - return ER_FAILED; + return NULL; } /* remove appended trigger evaluate info */ @@ -1084,7 +1081,7 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char const char *remove_eval_prefix = "evaluate ("; size_t remove_eval_suffix_len; - p = strstr (new_trigger_stmt_str, remove_eval_prefix); + p = strstr (result, remove_eval_prefix); if (p != NULL) { p = (char *) memmove (p, p + strlen (remove_eval_prefix), strlen (p) - strlen (remove_eval_prefix) + 1); @@ -1097,13 +1094,22 @@ change_trigger_action_query (PARSER_CONTEXT * parser, PT_NODE * statement, char } } - if (new_trigger_stmt_str != NULL && *new_trigger_stmt) + result_len = strlen (result) + 1; + if (result_len < 0) { - free_and_init (*new_trigger_stmt); - *new_trigger_stmt = strdup (new_trigger_stmt_str); + return NULL; } - return error; + new_trigger_stmt_str = (char *) malloc (result_len); + if (new_trigger_stmt_str == NULL) + { + er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) result_len); + return NULL; + } + + snprintf (new_trigger_stmt_str, result_len, "%s", result); + + return new_trigger_stmt_str; } /* @@ -1245,14 +1251,19 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O /* We need to do view translation here on the expression to be executed. */ if (statement) { - int error = NO_ERROR; + char *new_trigger_stmt_str = NULL; with_evaluate = strstr (trigger_stmt, "EVALUATE ( ") != NULL ? true : false; - error = - change_trigger_action_query (parser, statement->info.scope.stmt->info.trigger_action.expression, - new_trigger_stmt, with_evaluate); - if (error != NO_ERROR) + new_trigger_stmt_str = + change_trigger_action_query (parser, statement->info.scope.stmt->info.trigger_action.expression, with_evaluate); + if (new_trigger_stmt_str != NULL && *new_trigger_stmt) + { + free_and_init (*new_trigger_stmt); + *new_trigger_stmt = strdup (new_trigger_stmt_str); + free_and_init (new_trigger_stmt_str); + } + else { return NULL; } From c747dfd31bd5261ccd64f3b2a026d4a47c4aec5f Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 24 Dec 2024 01:07:42 +0900 Subject: [PATCH 13/14] edited for readability. --- src/parser/compile.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index c4b017711ed..a3cdadcb27d 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1135,7 +1135,7 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O PT_NODE *err_node; int with_evaluate; - assert (parser != NULL); + assert (parser != NULL || !*new_trigger_stmt); if (!trigger_stmt) return NULL; @@ -1257,17 +1257,16 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O new_trigger_stmt_str = change_trigger_action_query (parser, statement->info.scope.stmt->info.trigger_action.expression, with_evaluate); - if (new_trigger_stmt_str != NULL && *new_trigger_stmt) + if (new_trigger_stmt_str == NULL) { - free_and_init (*new_trigger_stmt); - *new_trigger_stmt = strdup (new_trigger_stmt_str); free_and_init (new_trigger_stmt_str); - } - else - { return NULL; } + free_and_init (*new_trigger_stmt); + *new_trigger_stmt = strdup (new_trigger_stmt_str); + free_and_init (new_trigger_stmt_str); + statement->info.scope.stmt->info.trigger_action.expression = mq_translate (parser, statement->info.scope.stmt->info.trigger_action.expression); /* From 1f14a076d961bab5a65884254c22c5069306eeee Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 24 Dec 2024 01:16:15 +0900 Subject: [PATCH 14/14] remove the part that does free_and_init when new_trigger_stmt_str is null. --- src/parser/compile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/parser/compile.c b/src/parser/compile.c index a3cdadcb27d..5b981b77474 100644 --- a/src/parser/compile.c +++ b/src/parser/compile.c @@ -1259,7 +1259,6 @@ pt_compile_trigger_stmt (PARSER_CONTEXT * parser, const char *trigger_stmt, DB_O change_trigger_action_query (parser, statement->info.scope.stmt->info.trigger_action.expression, with_evaluate); if (new_trigger_stmt_str == NULL) { - free_and_init (new_trigger_stmt_str); return NULL; }