summaryrefslogtreecommitdiff
path: root/sql/item.cc
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-02-16 19:44:54 +0300
committerunknown <evgen@moonbone.local>2007-02-16 19:44:54 +0300
commit98f87d9702296580e676511cdcd3a4ea6f416973 (patch)
tree10ae53777ea7028084e78772a51ef513fcc5965b /sql/item.cc
parentc039eed82cb21d75965fd9b2e936396e0282e0cb (diff)
parentd5813a06f67d6478fed95aa9d10c44e1c1eb1076 (diff)
downloadmariadb-git-98f87d9702296580e676511cdcd3a4ea6f416973.tar.gz
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into moonbone.local:/mnt/gentoo64/work/16630-bug-5.0-opt-mysql sql/item.cc: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'sql/item.cc')
-rw-r--r--sql/item.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/sql/item.cc b/sql/item.cc
index b4a7820eabf..e97b9f504cd 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4809,6 +4809,51 @@ void Item_field::update_null_value()
}
+/*
+ Add the field to the select list and substitute it for the reference to
+ the field.
+
+ SYNOPSIS
+ Item_field::update_value_transformer()
+ select_arg current select
+
+ DESCRIPTION
+ If the field doesn't belong to the table being inserted into then it is
+ added to the select list, pointer to it is stored in the ref_pointer_array
+ of the select and the field itself is substituted for the Item_ref object.
+ This is done in order to get correct values from update fields that
+ belongs to the SELECT part in the INSERT .. SELECT .. ON DUPLICATE KEY
+ UPDATE statement.
+
+ RETURN
+ 0 if error occured
+ ref if all conditions are met
+ this field otherwise
+*/
+
+Item *Item_field::update_value_transformer(byte *select_arg)
+{
+ SELECT_LEX *select= (SELECT_LEX*)select_arg;
+ DBUG_ASSERT(fixed);
+
+ if (field->table != select->context.table_list->table &&
+ type() != Item::TRIGGER_FIELD_ITEM)
+ {
+ List<Item> *all_fields= &select->join->all_fields;
+ Item **ref_pointer_array= select->ref_pointer_array;
+ int el= all_fields->elements;
+ Item_ref *ref;
+
+ ref_pointer_array[el]= (Item*)this;
+ all_fields->push_front((Item*)this);
+ ref= new Item_ref(&select->context, ref_pointer_array + el,
+ table_name, field_name);
+ return ref;
+ }
+ return this;
+}
+
+
Item_ref::Item_ref(Name_resolution_context *context_arg,
Item **item, const char *table_name_arg,
const char *field_name_arg)