summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2005-05-24 22:35:41 +0400
committerunknown <dlenev@mysql.com>2005-05-24 22:35:41 +0400
commit896786eadd72bc7ebbd4f8c21927ed6250f5a0cc (patch)
tree711e19958b1662765373664fc69c0288e915df7e /sql/item.cc
parent8ddb0ddc5cf302a88372ba877ad843b049de1121 (diff)
parent1fa7c69d3119e9da4c0afdb57684c7f0973b4838 (diff)
downloadmariadb-git-896786eadd72bc7ebbd4f8c21927ed6250f5a0cc.tar.gz
Manual merge of patch fixing several trigger related bugs with main tree.
sql/item.cc: Auto merged sql/item.h: Auto merged sql/mysql_priv.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Manual merge sql/sql_update.cc: Manual merge
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc43
1 files changed, 22 insertions, 21 deletions
diff --git a/sql/item.cc b/sql/item.cc
index a28cc261b3c..69b1b78a961 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4554,40 +4554,40 @@ void Item_insert_value::print(String *str)
/*
- Bind item representing field of row being changed in trigger
- to appropriate Field object.
+ Find index of Field object which will be appropriate for item
+ representing field of row being changed in trigger.
SYNOPSIS
setup_field()
thd - current thread context
table - table of trigger (and where we looking for fields)
- event - type of trigger event
NOTE
This function does almost the same as fix_fields() for Item_field
- but is invoked during trigger definition parsing and takes TABLE
- object as its argument. If proper field was not found in table
- error will be reported at fix_fields() time.
+ but is invoked right after trigger definition parsing. Since at
+ this stage we can't say exactly what Field object (corresponding
+ to TABLE::record[0] or TABLE::record[1]) should be bound to this
+ Item, we only find out index of the Field and then select concrete
+ Field object in fix_fields() (by that time Table_trigger_list::old_field/
+ new_field should point to proper array of Fields).
+ It also binds Item_trigger_field to Table_triggers_list object for
+ table of trigger which uses this item.
*/
-void Item_trigger_field::setup_field(THD *thd, TABLE *table,
- enum trg_event_type event)
+
+void Item_trigger_field::setup_field(THD *thd, TABLE *table)
{
- uint field_idx= (uint)-1;
bool save_set_query_id= thd->set_query_id;
/* TODO: Think more about consequences of this step. */
thd->set_query_id= 0;
-
- if (find_field_in_real_table(thd, table, field_name,
- strlen(field_name), 0, 0,
- &field_idx))
- {
- field= (row_version == OLD_ROW && event == TRG_EVENT_UPDATE) ?
- table->triggers->old_field[field_idx] :
- table->field[field_idx];
- }
-
+ /*
+ Try to find field by its name and if it will be found
+ set field_idx properly.
+ */
+ (void)find_field_in_real_table(thd, table, field_name, strlen(field_name),
+ 0, 0, &field_idx);
thd->set_query_id= save_set_query_id;
+ triggers= table->triggers;
}
@@ -4612,9 +4612,10 @@ bool Item_trigger_field::fix_fields(THD *thd,
*/
DBUG_ASSERT(fixed == 0);
- if (field)
+ if (field_idx != (uint)-1)
{
- // QQ: May be this should be moved to setup_field?
+ field= (row_version == OLD_ROW) ? triggers->old_field[field_idx] :
+ triggers->new_field[field_idx];
set_field(field);
fixed= 1;
return 0;