Commit 9f3b53fb authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-9093 Persistent computed column is not updated when update query contains join

added lost virtual fields update call
parent a3d843d9
......@@ -287,3 +287,30 @@ select * from t1;
set sql_warnings = 0;
drop table t1;
--echo #
--echo # MDEV-9093: Persistent computed column is not updated when
--echo # update query contains join
--echo #
CREATE TABLE `t1` (
`id` bigint(20) NOT NULL,
`name` varchar(254) DEFAULT NULL,
`name_hash` varchar(64) AS (sha1(name)) PERSISTENT,
PRIMARY KEY (`id`)
);
insert into t1(id,name) values (2050, 'name1'),(2051, 'name2'),(2041, 'name3');
create table t2 (id bigint);
insert into t2 values (2050),(2051),(2041);
select * from t1;
update t1 join t2 using(id) set name = concat(name,
'+1') where t1.id in (2051,2041);
select * from t1;
drop table t1,t2;
......@@ -425,3 +425,29 @@ select * from t1;
a b c d
set sql_warnings = 0;
drop table t1;
#
# MDEV-9093: Persistent computed column is not updated when
# update query contains join
#
CREATE TABLE `t1` (
`id` bigint(20) NOT NULL,
`name` varchar(254) DEFAULT NULL,
`name_hash` varchar(64) AS (sha1(name)) PERSISTENT,
PRIMARY KEY (`id`)
);
insert into t1(id,name) values (2050, 'name1'),(2051, 'name2'),(2041, 'name3');
create table t2 (id bigint);
insert into t2 values (2050),(2051),(2041);
select * from t1;
id name name_hash
2041 name3 1aefcd1b0f39da45fa1fd7236f683c907c15ef82
2050 name1 9b46b0dd3a8083c070c3b9953bb5f3f95c5ab4da
2051 name2 39ea84acf1fef629fef18a9c6f5799bba32ecc25
update t1 join t2 using(id) set name = concat(name,
'+1') where t1.id in (2051,2041);
select * from t1;
id name name_hash
2041 name3+1 93c9096df48221428de46e146abc9f4f94bf7d2e
2050 name1 9b46b0dd3a8083c070c3b9953bb5f3f95c5ab4da
2051 name2+1 fd4f236320db3956a5ec073c5ec39707d7f05708
drop table t1,t2;
......@@ -363,3 +363,29 @@ select * from t1;
a b c d
set sql_warnings = 0;
drop table t1;
#
# MDEV-9093: Persistent computed column is not updated when
# update query contains join
#
CREATE TABLE `t1` (
`id` bigint(20) NOT NULL,
`name` varchar(254) DEFAULT NULL,
`name_hash` varchar(64) AS (sha1(name)) PERSISTENT,
PRIMARY KEY (`id`)
);
insert into t1(id,name) values (2050, 'name1'),(2051, 'name2'),(2041, 'name3');
create table t2 (id bigint);
insert into t2 values (2050),(2051),(2041);
select * from t1;
id name name_hash
2050 name1 9b46b0dd3a8083c070c3b9953bb5f3f95c5ab4da
2051 name2 39ea84acf1fef629fef18a9c6f5799bba32ecc25
2041 name3 1aefcd1b0f39da45fa1fd7236f683c907c15ef82
update t1 join t2 using(id) set name = concat(name,
'+1') where t1.id in (2051,2041);
select * from t1;
id name name_hash
2050 name1 9b46b0dd3a8083c070c3b9953bb5f3f95c5ab4da
2051 name2+1 fd4f236320db3956a5ec073c5ec39707d7f05708
2041 name3+1 93c9096df48221428de46e146abc9f4f94bf7d2e
drop table t1,t2;
......@@ -2234,6 +2234,12 @@ int multi_update::do_updates()
if (!can_compare_record || compare_record(table))
{
int error;
if (table->vfield &&
update_virtual_fields(thd, table,
(table->triggers ?
VCOL_UPDATE_ALL :
VCOL_UPDATE_FOR_WRITE)))
goto err2;
if ((error= cur_table->view_check_option(thd, ignore)) !=
VIEW_CHECK_OK)
{
......
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