Fix for trigger.test failure in --debug mode.

We can't have Item_trigger_field as aggregated object inside of
sp_instr_set_trigger_field class since in this case its destructor
will be called twice. So instead let us create this Item separately
and store pointer to it in instruction object.
parent b763679f
...@@ -1499,8 +1499,8 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) ...@@ -1499,8 +1499,8 @@ sp_instr_set_trigger_field::execute(THD *thd, uint *nextp)
DBUG_ENTER("sp_instr_set_trigger_field::execute"); DBUG_ENTER("sp_instr_set_trigger_field::execute");
/* QQ: Still unsure what should we return in case of error 1 or -1 ? */ /* QQ: Still unsure what should we return in case of error 1 or -1 ? */
if (!value->fixed && value->fix_fields(thd, 0, &value) || if (!value->fixed && value->fix_fields(thd, 0, &value) ||
trigger_field.fix_fields(thd, 0, 0) || trigger_field->fix_fields(thd, 0, 0) ||
(value->save_in_field(trigger_field.field, 0) < 0)) (value->save_in_field(trigger_field->field, 0) < 0))
res= -1; res= -1;
*nextp= m_ip + 1; *nextp= m_ip + 1;
DBUG_RETURN(res); DBUG_RETURN(res);
...@@ -1510,7 +1510,7 @@ void ...@@ -1510,7 +1510,7 @@ void
sp_instr_set_trigger_field::print(String *str) sp_instr_set_trigger_field::print(String *str)
{ {
str->append("set ", 4); str->append("set ", 4);
trigger_field.print(str); trigger_field->print(str);
str->append(":=", 2); str->append(":=", 2);
value->print(str); value->print(str);
} }
......
...@@ -467,9 +467,9 @@ class sp_instr_set_trigger_field : public sp_instr ...@@ -467,9 +467,9 @@ class sp_instr_set_trigger_field : public sp_instr
public: public:
sp_instr_set_trigger_field(uint ip, sp_pcontext *ctx, sp_instr_set_trigger_field(uint ip, sp_pcontext *ctx,
LEX_STRING field_name, Item *val) Item_trigger_field *trg_fld, Item *val)
: sp_instr(ip, ctx), : sp_instr(ip, ctx),
trigger_field(Item_trigger_field::NEW_ROW, field_name.str), trigger_field(trg_fld),
value(val) value(val)
{} {}
...@@ -480,9 +480,8 @@ public: ...@@ -480,9 +480,8 @@ public:
virtual void print(String *str); virtual void print(String *str);
Item_trigger_field trigger_field;
private: private:
Item_trigger_field *trigger_field;
Item *value; Item *value;
}; // class sp_instr_trigger_field : public sp_instr }; // class sp_instr_trigger_field : public sp_instr
......
...@@ -7565,6 +7565,7 @@ sys_option_value: ...@@ -7565,6 +7565,7 @@ sys_option_value:
{ {
/* We are in trigger and assigning value to field of new row */ /* We are in trigger and assigning value to field of new row */
Item *it; Item *it;
Item_trigger_field *trg_fld;
sp_instr_set_trigger_field *i; sp_instr_set_trigger_field *i;
if ($1) if ($1)
{ {
...@@ -7585,17 +7586,19 @@ sys_option_value: ...@@ -7585,17 +7586,19 @@ sys_option_value:
it= new Item_null(); it= new Item_null();
} }
if (!(i= new sp_instr_set_trigger_field( if (!(trg_fld= new Item_trigger_field(Item_trigger_field::NEW_ROW,
$2.base_name.str)) ||
!(i= new sp_instr_set_trigger_field(
lex->sphead->instructions(), lex->spcont, lex->sphead->instructions(), lex->spcont,
$2.base_name, it))) trg_fld, it)))
YYABORT; YYABORT;
/* /*
Let us add this item to list of all Item_trigger_field Let us add this item to list of all Item_trigger_field
objects in trigger. objects in trigger.
*/ */
lex->trg_table_fields.link_in_list((byte *)&i->trigger_field, lex->trg_table_fields.link_in_list((byte *)trg_fld,
(byte **)&i->trigger_field.next_trg_field); (byte **)&trg_fld->next_trg_field);
lex->sphead->add_instr(i); lex->sphead->add_instr(i);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment