summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2021-10-27 02:43:48 +0300
committerNikita Malyavin <nikitamalyavin@gmail.com>2021-10-27 04:52:14 +0300
commit5b58394dd72d387443e34cf41e54f713cfaa95e4 (patch)
tree53929e747c7706b56520b0010e295318cda65ad6
parent58fe6b47d4e8580e370a094d8f5768d053aa52c1 (diff)
downloadmariadb-git-5b58394dd72d387443e34cf41e54f713cfaa95e4.tar.gz
MDEV-26866 FOREIGN KEY…SET NULL corrupts an index on a virtual column
innobase_get_field_from_update_vector is not a suitable function to fetch updated row info, as well as parent table's update vector is not always suitable. For instance, in case of DELETE it contains undefined data. castade->update vector seems to be good enough to fetch all base columns update data, and besides faster, and less error-prone.
-rw-r--r--mysql-test/suite/gcol/r/innodb_virtual_fk.result200
-rw-r--r--mysql-test/suite/gcol/t/innodb_virtual_fk.test184
-rw-r--r--storage/innobase/handler/ha_innodb.cc62
-rw-r--r--storage/innobase/include/row0mysql.h5
-rw-r--r--storage/innobase/row/row0ins.cc17
-rw-r--r--storage/innobase/row/row0merge.cc4
-rw-r--r--storage/innobase/row/row0sel.cc2
-rw-r--r--storage/innobase/row/row0upd.cc5
-rw-r--r--storage/innobase/row/row0vers.cc2
9 files changed, 413 insertions, 68 deletions
diff --git a/mysql-test/suite/gcol/r/innodb_virtual_fk.result b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
index 367ed1223f7..de61c16f739 100644
--- a/mysql-test/suite/gcol/r/innodb_virtual_fk.result
+++ b/mysql-test/suite/gcol/r/innodb_virtual_fk.result
@@ -826,3 +826,203 @@ DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
+USE test;
+#
+# Bug#33053297 VIRTUAL INDEX CORRUPTED DURING CASCADE UPDATE ON CHILD TABLE
+#
+# Test-Case 1
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE=InnoDB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_date date GENERATED ALWAYS AS
+(concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+'-', lpad(dayofmonth(date_sent), 2, '0'))),
+PRIMARY KEY (id),
+KEY IDX_ES1 (email_id),
+KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = InnoDB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 1 2020-10-22 13:32:41 2020-10-22
+DELETE FROM emails;
+DELETE FROM email_stats;
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-Case 2
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = InnoDB
+DEFAULT CHARSET = utf8mb4
+COLLATE = utf8mb4_unicode_ci
+ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_date date GENERATED ALWAYS AS
+(concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+'-', lpad(dayofmonth(date_sent), 2, '0'))),
+PRIMARY KEY (id),
+KEY IDX_ES1 (email_id),
+KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id)
+ON DELETE SET NULL
+ON UPDATE SET NULL
+) ENGINE = InnoDB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+UPDATE emails SET id = 2 where id = 1;
+SELECT id FROM email_stats WHERE generated_sent_date IS NULL;
+id
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 NULL 2020-10-22 13:32:41 2020-10-22
+UPDATE email_stats
+SET email_id=2
+WHERE DATE(generated_sent_date) = '2020-10-22';
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_date
+1 2 2020-10-22 13:32:41 2020-10-22
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-case 3
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = INNODB
+DEFAULT CHARSET = utf8mb4
+COLLATE = utf8mb4_unicode_ci
+ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = INNODB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+DELETE FROM emails;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+# Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+# Test-case 4
+CREATE TABLE emails (
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE = INNODB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+FOREIGN KEY (email_id) REFERENCES emails (id) ON UPDATE SET NULL
+) ENGINE = INNODB;
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+UPDATE emails SET id = 2 WHERE id = 1;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+DROP TABLE email_stats;
+DROP TABLE emails;
+CREATE TABLE emails (breaker int unsigned,
+KEY (breaker),
+id int unsigned NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+CREATE TABLE email_stats (
+id bigint unsigned NOT NULL AUTO_INCREMENT,
+email_id int unsigned DEFAULT NULL,
+date_sent datetime NOT NULL,
+generated_sent_email varchar(20) GENERATED ALWAYS AS
+(CONCAT(YEAR(date_sent),
+'-',
+COALESCE(email_id, '$'))),
+PRIMARY KEY (id),
+KEY idx_es1 (email_id),
+KEY mautic_generated_sent_date_email (generated_sent_email, email_id),
+FOREIGN KEY fk_ea1 (email_id) REFERENCES emails (breaker)
+ON DELETE SET NULL
+) ENGINE=INNODB;
+show create table email_stats;
+Table Create Table
+email_stats CREATE TABLE `email_stats` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `email_id` int(10) unsigned DEFAULT NULL,
+ `date_sent` datetime NOT NULL,
+ `generated_sent_email` varchar(20) GENERATED ALWAYS AS (concat(year(`date_sent`),'-',coalesce(`email_id`,'$'))) VIRTUAL,
+ PRIMARY KEY (`id`),
+ KEY `idx_es1` (`email_id`),
+ KEY `mautic_generated_sent_date_email` (`generated_sent_email`,`email_id`),
+ CONSTRAINT `fk_ea1` FOREIGN KEY (`email_id`) REFERENCES `emails` (`breaker`) ON DELETE SET NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+INSERT INTO emails VALUES (1,1);
+INSERT INTO email_stats(id, email_id, date_sent)
+VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 1 2020-10-22 13:32:41 2020-1
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+date_sent
+2020-10-22 13:32:41
+DELETE FROM emails;
+SELECT * FROM email_stats;
+id email_id date_sent generated_sent_email
+1 NULL 2020-10-22 13:32:41 2020-$
+SELECT date_sent
+FROM email_stats force index (mautic_generated_sent_date_email)
+WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+SELECT date_sent
+FROM email_stats force index (idx_es1)
+WHERE generated_sent_email = '2020-$';
+date_sent
+2020-10-22 13:32:41
+DROP TABLE email_stats;
+DROP TABLE emails;
diff --git a/mysql-test/suite/gcol/t/innodb_virtual_fk.test b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
index c99259531b3..0f0406b5dd4 100644
--- a/mysql-test/suite/gcol/t/innodb_virtual_fk.test
+++ b/mysql-test/suite/gcol/t/innodb_virtual_fk.test
@@ -693,3 +693,187 @@ DROP TABLE email_stats;
DROP TABLE emails_metadata;
DROP TABLE emails;
DROP DATABASE `a-b`;
+USE test;
+
+--echo #
+--echo # Bug#33053297 VIRTUAL INDEX CORRUPTED DURING CASCADE UPDATE ON CHILD TABLE
+--echo #
+
+--echo # Test-Case 1
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_date date GENERATED ALWAYS AS
+ (concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+ '-', lpad(dayofmonth(date_sent), 2, '0'))),
+ PRIMARY KEY (id),
+ KEY IDX_ES1 (email_id),
+ KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = InnoDB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+
+DELETE FROM emails;
+DELETE FROM email_stats;
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-Case 2
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci
+ ROW_FORMAT = DYNAMIC;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_date date GENERATED ALWAYS AS
+ (concat(year(date_sent), '-', lpad(month(date_sent), 2, '0'),
+ '-', lpad(dayofmonth(date_sent), 2, '0'))),
+ PRIMARY KEY (id),
+ KEY IDX_ES1 (email_id),
+ KEY mautic_generated_sent_date_email_id(generated_sent_date, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id)
+ ON DELETE SET NULL
+ ON UPDATE SET NULL
+) ENGINE = InnoDB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+
+UPDATE emails SET id = 2 where id = 1;
+
+SELECT id FROM email_stats WHERE generated_sent_date IS NULL;
+SELECT * FROM email_stats;
+UPDATE email_stats
+ SET email_id=2
+ WHERE DATE(generated_sent_date) = '2020-10-22';
+SELECT * FROM email_stats;
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-case 3
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = INNODB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci
+ ROW_FORMAT = DYNAMIC;
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON DELETE SET NULL
+) ENGINE = INNODB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+
+DELETE FROM emails;
+
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+
+--echo # Clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+--echo # Test-case 4
+CREATE TABLE emails (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE = INNODB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent), '-', COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email(generated_sent_email, email_id),
+ FOREIGN KEY (email_id) REFERENCES emails (id) ON UPDATE SET NULL
+) ENGINE = INNODB;
+
+INSERT INTO emails VALUES (1);
+INSERT INTO email_stats (id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+
+UPDATE emails SET id = 2 WHERE id = 1;
+
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-$';
+
+#clean up.
+DROP TABLE email_stats;
+DROP TABLE emails;
+
+CREATE TABLE emails (breaker int unsigned,
+ KEY (breaker),
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (id)
+) ENGINE=INNODB;
+
+CREATE TABLE email_stats (
+ id bigint unsigned NOT NULL AUTO_INCREMENT,
+ email_id int unsigned DEFAULT NULL,
+ date_sent datetime NOT NULL,
+ generated_sent_email varchar(20) GENERATED ALWAYS AS
+ (CONCAT(YEAR(date_sent),
+ '-',
+ COALESCE(email_id, '$'))),
+ PRIMARY KEY (id),
+ KEY idx_es1 (email_id),
+ KEY mautic_generated_sent_date_email (generated_sent_email, email_id),
+ FOREIGN KEY fk_ea1 (email_id) REFERENCES emails (breaker)
+ ON DELETE SET NULL
+) ENGINE=INNODB;
+
+show create table email_stats;
+INSERT INTO emails VALUES (1,1);
+INSERT INTO email_stats(id, email_id, date_sent)
+ VALUES (1, 1, '2020-10-22 13:32:41');
+SELECT * FROM email_stats;
+SELECT date_sent FROM email_stats WHERE generated_sent_email = '2020-1';
+DELETE FROM emails;
+SELECT * FROM email_stats;
+SELECT date_sent
+ FROM email_stats force index (mautic_generated_sent_date_email)
+ WHERE generated_sent_email = '2020-$';
+SELECT date_sent
+ FROM email_stats force index (idx_es1)
+ WHERE generated_sent_email = '2020-$';
+
+DROP TABLE email_stats;
+DROP TABLE emails;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 72db9df0346..62fd73c3ada 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -20169,48 +20169,6 @@ innobase_rename_vc_templ(
table->vc_templ->tb_name = t_tbname;
}
-/** Get the updated parent field value from the update vector for the
-given col_no.
-@param[in] foreign foreign key information
-@param[in] update updated parent vector.
-@param[in] col_no base column position of the child table to check
-@return updated field from the parent update vector, else NULL */
-static
-dfield_t*
-innobase_get_field_from_update_vector(
- dict_foreign_t* foreign,
- upd_t* update,
- ulint col_no)
-{
- dict_table_t* parent_table = foreign->referenced_table;
- dict_index_t* parent_index = foreign->referenced_index;
- ulint parent_field_no;
- ulint parent_col_no;
- ulint prefix_col_no;
-
- for (ulint i = 0; i < foreign->n_fields; i++) {
- if (dict_index_get_nth_col_no(foreign->foreign_index, i)
- != col_no) {
- continue;
- }
-
- parent_col_no = dict_index_get_nth_col_no(parent_index, i);
- parent_field_no = dict_table_get_nth_col_pos(
- parent_table, parent_col_no, &prefix_col_no);
-
- for (ulint j = 0; j < update->n_fields; j++) {
- upd_field_t* parent_ufield
- = &update->fields[j];
-
- if (parent_ufield->field_no == parent_field_no) {
- return(&parent_ufield->new_val);
- }
- }
- }
-
- return (NULL);
-}
-
/**
Allocate a heap and record for calculating virtual fields
@@ -20295,7 +20253,7 @@ void innobase_report_computed_value_failed(dtuple_t *row)
@param[in,out] mysql_table mysql table object
@param[in] old_table during ALTER TABLE, this is the old table
or NULL.
-@param[in] parent_update update vector for the parent row
+@param[in] update update vector for the row, if any
@param[in] foreign foreign key information
@return the field filled with computed value, or NULL if just want
to store the value in passed in "my_rec" */
@@ -20311,8 +20269,7 @@ innobase_get_computed_value(
TABLE* mysql_table,
byte* mysql_rec,
const dict_table_t* old_table,
- upd_t* parent_update,
- dict_foreign_t* foreign)
+ upd_t* update)
{
byte rec_buf2[REC_VERSION_56_MAX_INDEX_COL_LEN];
byte* buf;
@@ -20325,6 +20282,8 @@ innobase_get_computed_value(
ulint ret = 0;
+ dict_index_t *clust_index= dict_table_get_first_index(index->table);
+
ut_ad(index->table->vc_templ);
ut_ad(thd != NULL);
ut_ad(mysql_table);
@@ -20354,11 +20313,14 @@ innobase_get_computed_value(
= index->table->vc_templ->vtempl[col_no];
const byte* data;
- if (parent_update != NULL) {
- /** Get the updated field from update vector
- of the parent table. */
- row_field = innobase_get_field_from_update_vector(
- foreign, parent_update, col_no);
+ if (update != NULL) {
+ uint clust_no = dict_col_get_clust_pos(base_col,
+ clust_index);
+ const upd_field_t *uf =
+ upd_get_field_by_field_no(update,
+ clust_no, false);
+ if (uf != NULL)
+ row_field = &uf->new_val;
}
if (row_field == NULL) {
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index ed51a3a3d90..b066683dc3b 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -813,7 +813,7 @@ void innobase_report_computed_value_failed(dtuple_t *row);
@param[in,out] mysql_table mysql table object
@param[in] old_table during ALTER TABLE, this is the old table
or NULL.
-@param[in] parent_update update vector for the parent row
+@param[in] update update vector for the parent row
@param[in] foreign foreign key information
@return the field filled with computed value */
dfield_t*
@@ -828,8 +828,7 @@ innobase_get_computed_value(
TABLE* mysql_table,
byte* mysql_rec,
const dict_table_t* old_table,
- upd_t* parent_update,
- dict_foreign_t* foreign);
+ upd_t* parent_update);
/** Get the computed value by supplying the base column values.
@param[in,out] table the table whose virtual column
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index 9b2ea9db542..32ad6df29b8 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -864,7 +864,6 @@ row_ins_invalidate_query_cache(
innobase_invalidate_query_cache(thr_get_trx(thr), name);
}
-
/** Fill virtual column information in cascade node for the child table.
@param[out] cascade child update node
@param[in] rec clustered rec of child table
@@ -911,6 +910,13 @@ row_ins_foreign_fill_virtual(
if (!record) {
return DB_OUT_OF_MEMORY;
}
+ bool set_null =
+ node->is_delete
+ ? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
+ : (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL);
+ DBUG_ASSERT(set_null ||
+ (!node->is_delete
+ && (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)));
for (uint16_t i = 0; i < n_v_fld; i++) {
@@ -926,7 +932,7 @@ row_ins_foreign_fill_virtual(
dfield_t* vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, update->heap, NULL, thd, mysql_table,
- record, NULL, NULL, NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
return DB_COMPUTE_VALUE_FAILED;
@@ -942,16 +948,11 @@ row_ins_foreign_fill_virtual(
upd_field_set_v_field_no(upd_field, i, index);
- bool set_null =
- node->is_delete
- ? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)
- : (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL);
-
dfield_t* new_vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, update->heap, NULL, thd,
mysql_table, record, NULL,
- set_null ? update : node->update, foreign);
+ update);
if (new_vfield == NULL) {
return DB_COMPUTE_VALUE_FAILED;
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 53e3016180a..a4209fb1a9c 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -591,8 +591,8 @@ error:
row_field = innobase_get_computed_value(
row, v_col, clust_index,
v_heap, NULL, ifield, trx->mysql_thd,
- my_table, vcol_storage.innobase_record,
- old_table, NULL, NULL);
+ my_table, vcol_storage.innobase_record,
+ old_table, NULL);
if (row_field == NULL) {
*err = DB_COMPUTE_VALUE_FAILED;
diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc
index 4a839082a6b..a6d92cf7361 100644
--- a/storage/innobase/row/row0sel.cc
+++ b/storage/innobase/row/row0sel.cc
@@ -332,7 +332,7 @@ row_sel_sec_rec_is_for_clust_rec(
&heap, NULL, NULL,
thr_get_trx(thr)->mysql_thd,
thr->prebuilt->m_mysql_table,
- record, NULL, NULL, NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
innobase_report_computed_value_failed(row);
diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc
index 9d8a19a8dff..bf6a2b1be61 100644
--- a/storage/innobase/row/row0upd.cc
+++ b/storage/innobase/row/row0upd.cc
@@ -709,7 +709,7 @@ row_upd_build_difference_binary(
dfield_t* vfield = innobase_get_computed_value(
update->old_vrow, col, index,
&vc.heap, heap, NULL, thd, mysql_table, record,
- NULL, NULL, NULL);
+ NULL, NULL);
if (vfield == NULL) {
*error = DB_COMPUTE_VALUE_FAILED;
return(NULL);
@@ -1791,8 +1791,7 @@ row_upd_store_v_row(
node->row, col, index,
&vc.heap, node->heap,
NULL, thd, mysql_table,
- record, NULL, NULL,
- NULL);
+ record, NULL, NULL);
if (vfield == NULL) {
return false;
}
diff --git a/storage/innobase/row/row0vers.cc b/storage/innobase/row/row0vers.cc
index 38f9b881409..695c6dba472 100644
--- a/storage/innobase/row/row0vers.cc
+++ b/storage/innobase/row/row0vers.cc
@@ -474,7 +474,7 @@ row_vers_build_clust_v_col(
dfield_t *vfield = innobase_get_computed_value(
row, col, clust_index, &vc.heap,
heap, NULL, thd, maria_table, record, NULL,
- NULL, NULL);
+ NULL);
if (!vfield) {
innobase_report_computed_value_failed(row);
ut_ad(0);