#At file:///opt/local/work/mysql-6.1-fk-stage/
2707 Konstantin Osipov 2008-12-12
WL#148, Milestone 8, Part 1.
Review comments.
Extract cascade structures initialization into a separate loop.
(preparation,to be able to reuse code).
modified:
sql/fk.cc
sql/sql_select.h
=== modified file 'sql/fk.cc'
--- a/sql/fk.cc 2008-12-11 23:21:56 +0000
+++ b/sql/fk.cc 2008-12-11 23:46:13 +0000
@@ -903,7 +903,7 @@ bool Foreign_key_parent_rcontext::prepar
m_key_idx= m_key - m_child_table->key_info;
/*
- Create Field objects to operate with old record (record[1]
+ Create Field objects to operate with old record (record[1])
during update. We need to work with the old parent
value to be able to find its old children.
*/
@@ -1000,15 +1000,20 @@ bool Foreign_key_parent_rcontext::prepar
if (! m_key_copy[i])
return TRUE;
key_col_pos+= m_key->key_part[i].store_length;
+ }
- if (m_fk_list->action_type() == TRG_EVENT_UPDATE &&
- m_ref_action == FK_OPTION_CASCADE)
+ if (m_fk_list->action_type() == TRG_EVENT_UPDATE &&
+ m_ref_action == FK_OPTION_CASCADE)
+ {
+ for (i= 0; i < m_key->key_parts; i++)
{
+ uint src_field_index= m_key_copy[i]->from_field_index();
+
if (!(m_cascade_copy[i]= new (m_thd->mem_root) Copy_field()))
return TRUE;
m_cascade_copy[i]->set(m_key->key_part[i].field,
- m_parent_table->field[old_parent_col->field_index],
- FALSE);
+ m_parent_table->field[src_field_index],
+ FALSE);
}
}
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2008-11-06 18:39:27 +0000
+++ b/sql/sql_select.h 2008-12-11 23:46:13 +0000
@@ -812,6 +812,10 @@ class store_key_field: public store_key
}
}
const char *name() const { return field_name; }
+ const uint16 from_field_index() const
+ {
+ return copy_field.from_field->field_index;
+ }
protected:
enum store_key_result copy_inner()
| Thread |
|---|
| • bzr commit into mysql-6.1-fk branch (kostja:2707) WL#148 | Konstantin Osipov | 12 Dec |