Skip to content
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-25719] When executing loaddb with a past unload file (no user_schema) containing a trigger, the loaddb operation succeeds, but the trigger execution fails. #5666

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/object/trigger_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,75 @@ compile_trigger_activity (TR_TRIGGER * trigger, TR_ACTIVITY * activity, int with
activity->parser = NULL;
}
}

{
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 */
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);
#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 */
char *p = NULL;
const char *eval_prefix = "evaluate (";
size_t eval_suffix_len;

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);
}

eval_suffix_len = strlen (p);
if (eval_suffix_len > 0 && p[eval_suffix_len - 1] == ')')
{
p[eval_suffix_len - 1] = '\0';
}

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 */
Expand Down
Loading