From 8ec2f705feec8edcbe8aab7193d72ba96494a395 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 3 Dec 2024 21:19:17 +0900 Subject: [PATCH 1/3] When executing loaddb with a past unload file (no user_schema) containing a trigger, the loaddb operation succeeds, but the trigger execution fails. --- src/object/trigger_manager.c | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/object/trigger_manager.c b/src/object/trigger_manager.c index 2bd5460431c..52669b7c25a 100644 --- a/src/object/trigger_manager.c +++ b/src/object/trigger_manager.c @@ -1732,6 +1732,56 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with activity->parser = NULL; } } + + { + unsigned int save_custom; + PARSER_CONTEXT *temp_parser = (PARSER_CONTEXT *) activity->parser; + PT_NODE **temp_statement = + &((PT_NODE *) activity->statement)->info.scope.stmt->info.trigger_action.expression; + char *new_source; + + switch (activity->type) + { + case TR_ACT_EXPRESSION: + if (!with_evaluate) + { + /* trigger->action */ + save_custom = temp_parser->custom_print; + temp_parser->custom_print |= PT_SUPPRESS_RESOLVED; + new_source = parser_print_tree_with_quotes (temp_parser, *temp_statement); +#if !defined (NDEBUG) + assert (parser_parse_string_use_sys_charset (temp_parser, new_source) != NULL); +#endif + if (activity->source) + { + free_and_init (activity->source); + } + + activity->source = strdup (new_source); + temp_parser->custom_print = save_custom; + } + else + { + /* trigger->condition */ + new_source = parser_print_tree_with_quotes (temp_parser, *temp_statement); +#if !defined (NDEBUG) + assert (parser_parse_string_use_sys_charset (temp_parser, new_source) != NULL); +#endif + if (activity->source) + { + free_and_init (activity->source); + } + + activity->source = strdup (new_source); + } + break; + case TR_ACT_REJECT: + case TR_ACT_INVALIDATE: + case TR_ACT_PRINT: + default: + break; + } + } } /* free the computed string */ From 058ca65d2d7d2a05cee02ebd52ff9f03b4ba7546 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 10 Dec 2024 15:01:11 +0900 Subject: [PATCH 2/3] Removes the 'evaluate' keyword from trigger->condition. --- src/object/trigger_manager.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/object/trigger_manager.c b/src/object/trigger_manager.c index 52669b7c25a..78ec195ebcf 100644 --- a/src/object/trigger_manager.c +++ b/src/object/trigger_manager.c @@ -1734,7 +1734,6 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with } { - unsigned int save_custom; PARSER_CONTEXT *temp_parser = (PARSER_CONTEXT *) activity->parser; PT_NODE **temp_statement = &((PT_NODE *) activity->statement)->info.scope.stmt->info.trigger_action.expression; @@ -1746,6 +1745,8 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with if (!with_evaluate) { /* trigger->action */ + unsigned int save_custom; + save_custom = temp_parser->custom_print; temp_parser->custom_print |= PT_SUPPRESS_RESOLVED; new_source = parser_print_tree_with_quotes (temp_parser, *temp_statement); @@ -1763,10 +1764,28 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with else { /* trigger->condition */ + char *p = NULL; + const char *eval_prefix = "evaluate ("; + const char *eval_suffix = " )"; + new_source = parser_print_tree_with_quotes (temp_parser, *temp_statement); #if !defined (NDEBUG) assert (parser_parse_string_use_sys_charset (temp_parser, new_source) != NULL); #endif + + /* remove appended trigger info */ + p = strstr (new_source, eval_prefix); + if (p != NULL) + { + p = (char *) memmove (p, p + strlen (eval_prefix), strlen (p) - strlen (eval_prefix) + 1); + } + + p = strstr (new_source, eval_suffix); + if (p != NULL) + { + p = (char *) memmove (p, p + strlen (eval_suffix), strlen (p) - strlen (eval_suffix) + 1); + } + if (activity->source) { free_and_init (activity->source); From eed2b85a1aa24716084ca8bbfd00d38eb770e493 Mon Sep 17 00:00:00 2001 From: jongmin-won Date: Tue, 10 Dec 2024 18:30:11 +0900 Subject: [PATCH 3/3] Remove the last ')' character from trigger->condition. --- src/object/trigger_manager.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/object/trigger_manager.c b/src/object/trigger_manager.c index 78ec195ebcf..c103802b613 100644 --- a/src/object/trigger_manager.c +++ b/src/object/trigger_manager.c @@ -1766,7 +1766,7 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with /* trigger->condition */ char *p = NULL; const char *eval_prefix = "evaluate ("; - const char *eval_suffix = " )"; + size_t eval_suffix_len; new_source = parser_print_tree_with_quotes (temp_parser, *temp_statement); #if !defined (NDEBUG) @@ -1780,10 +1780,10 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with p = (char *) memmove (p, p + strlen (eval_prefix), strlen (p) - strlen (eval_prefix) + 1); } - p = strstr (new_source, eval_suffix); - if (p != NULL) + eval_suffix_len = strlen (p); + if (eval_suffix_len > 0 && p[eval_suffix_len - 1] == ')') { - p = (char *) memmove (p, p + strlen (eval_suffix), strlen (p) - strlen (eval_suffix) + 1); + p[eval_suffix_len - 1] = '\0'; } if (activity->source)