Commit be505e3e authored by unknown's avatar unknown

Cherrypick into XtraDB: Bug#13002783 PARTIALLY UNINITIALIZED CASCADE UPDATE VECTOR

We merged the test case for this into MariaDB 5.1, but the fix
was not yet part of XtraDB.
parent 47575bd0
2011-10-25 The InnoDB Team
* handler/ha_innodb.cc, row/row0ins.c:
Fix Bug#13002783 PARTIALLY UNINITIALIZED CASCADE UPDATE VECTOR
2011-08-08 The InnoDB Team 2011-08-08 The InnoDB Team
* row/row0sel.c: * row/row0sel.c:
......
...@@ -5360,14 +5360,15 @@ calc_row_difference( ...@@ -5360,14 +5360,15 @@ calc_row_difference(
/* The field has changed */ /* The field has changed */
ufield = uvect->fields + n_changed; ufield = uvect->fields + n_changed;
UNIV_MEM_INVALID(ufield, sizeof *ufield);
/* Let us use a dummy dfield to make the conversion /* Let us use a dummy dfield to make the conversion
from the MySQL column format to the InnoDB format */ from the MySQL column format to the InnoDB format */
if (n_len != UNIV_SQL_NULL) {
dict_col_copy_type(prebuilt->table->cols + i, dict_col_copy_type(prebuilt->table->cols + i,
dfield_get_type(&dfield)); dfield_get_type(&dfield));
if (n_len != UNIV_SQL_NULL) {
buf = row_mysql_store_col_in_innobase_format( buf = row_mysql_store_col_in_innobase_format(
&dfield, &dfield,
(byte*)buf, (byte*)buf,
...@@ -5375,7 +5376,7 @@ calc_row_difference( ...@@ -5375,7 +5376,7 @@ calc_row_difference(
new_mysql_row_col, new_mysql_row_col,
col_pack_len, col_pack_len,
dict_table_is_comp(prebuilt->table)); dict_table_is_comp(prebuilt->table));
dfield_copy_data(&ufield->new_val, &dfield); dfield_copy(&ufield->new_val, &dfield);
} else { } else {
dfield_set_null(&ufield->new_val); dfield_set_null(&ufield->new_val);
} }
......
...@@ -434,11 +434,9 @@ row_ins_cascade_calc_update_vec( ...@@ -434,11 +434,9 @@ row_ins_cascade_calc_update_vec(
dict_table_t* table = foreign->foreign_table; dict_table_t* table = foreign->foreign_table;
dict_index_t* index = foreign->foreign_index; dict_index_t* index = foreign->foreign_index;
upd_t* update; upd_t* update;
upd_field_t* ufield;
dict_table_t* parent_table; dict_table_t* parent_table;
dict_index_t* parent_index; dict_index_t* parent_index;
upd_t* parent_update; upd_t* parent_update;
upd_field_t* parent_ufield;
ulint n_fields_updated; ulint n_fields_updated;
ulint parent_field_no; ulint parent_field_no;
ulint i; ulint i;
...@@ -474,13 +472,15 @@ row_ins_cascade_calc_update_vec( ...@@ -474,13 +472,15 @@ row_ins_cascade_calc_update_vec(
dict_index_get_nth_col_no(parent_index, i)); dict_index_get_nth_col_no(parent_index, i));
for (j = 0; j < parent_update->n_fields; j++) { for (j = 0; j < parent_update->n_fields; j++) {
parent_ufield = parent_update->fields + j; const upd_field_t* parent_ufield
= &parent_update->fields[j];
if (parent_ufield->field_no == parent_field_no) { if (parent_ufield->field_no == parent_field_no) {
ulint min_size; ulint min_size;
const dict_col_t* col; const dict_col_t* col;
ulint ufield_len; ulint ufield_len;
upd_field_t* ufield;
col = dict_index_get_nth_col(index, i); col = dict_index_get_nth_col(index, i);
...@@ -493,6 +493,8 @@ row_ins_cascade_calc_update_vec( ...@@ -493,6 +493,8 @@ row_ins_cascade_calc_update_vec(
ufield->field_no ufield->field_no
= dict_table_get_nth_col_pos( = dict_table_get_nth_col_pos(
table, dict_col_get_no(col)); table, dict_col_get_no(col));
ufield->orig_len = 0;
ufield->exp = NULL; ufield->exp = NULL;
ufield->new_val = parent_ufield->new_val; ufield->new_val = parent_ufield->new_val;
...@@ -993,10 +995,9 @@ row_ins_foreign_check_on_constraint( ...@@ -993,10 +995,9 @@ row_ins_foreign_check_on_constraint(
goto nonstandard_exit_func; goto nonstandard_exit_func;
} }
if ((node->is_delete if (node->is_delete
&& (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)) ? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
|| (!node->is_delete : (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL)) {
&& (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL))) {
/* Build the appropriate update vector which sets /* Build the appropriate update vector which sets
foreign->n_fields first fields in rec to SQL NULL */ foreign->n_fields first fields in rec to SQL NULL */
...@@ -1005,6 +1006,8 @@ row_ins_foreign_check_on_constraint( ...@@ -1005,6 +1006,8 @@ row_ins_foreign_check_on_constraint(
update->info_bits = 0; update->info_bits = 0;
update->n_fields = foreign->n_fields; update->n_fields = foreign->n_fields;
UNIV_MEM_INVALID(update->fields,
update->n_fields * sizeof *update->fields);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
upd_field_t* ufield = &update->fields[i]; upd_field_t* ufield = &update->fields[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