1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

Merge pull request #1986 from tntnatbry/MCOL-1482

MCOL-1482 An UPDATE operation on a non-ColumnStore table involving a cross-engine join
This commit is contained in:
Roman Nozdrin
2021-07-01 14:25:32 +03:00
committed by GitHub
6 changed files with 180 additions and 71 deletions

View File

@ -38,6 +38,7 @@ FLUSH PRIVILEGES;
# Create tables with Innodb and Columnstore engines
CREATE TABLE t1 (t1_int INT, t1_char CHAR(5))ENGINE=Innodb;
CREATE TABLE t2 (t2_int INT, t2_char CHAR(5))ENGINE=Columnstore;
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (NULL,''),(1,'aaa'),(2,'bbb'),(3,'ccc'),(4,'ddd'),(5,'eee'),(6,'ffff'),(7,'ggggg');
INSERT INTO t2 VALUES (NULL,''),(1,'hhhh'),(3,'iii'),(5,'jjj'),(7,'kkkk'),(9,'lll'),(11,'m'),(13,'nnn');
@ -46,19 +47,36 @@ UPDATE t2, t1 SET t2.t2_char = 'zzz' WHERE t1.t1_int = t2.t2_int AND t1.t1_int =
SELECT * FROM t1, t2 WHERE t1.t1_int = t2.t2_int AND t1.t1_int = 3;
UPDATE t1 JOIN t2 on t1.t1_int=t2.t2_int SET t2.t2_char='sssss';
SELECT * FROM t1, t2 WHERE t1.t1_int = t2.t2_int;
# MCOL-1482
--error ER_INTERNAL_ERROR
UPDATE t1 JOIN t2 on t1.t1_int=t2.t2_int SET t1.t1_char='s';
SELECT * FROM t1;
# Update foreign view
UPDATE v1 JOIN t2 on v1.t1_int=t2.t2_int SET v1.t1_char='t';
SELECT * FROM t1;
# Update foreign table with a subquery as the source
UPDATE t1 JOIN (SELECT * FROM t2 WHERE t2_int < 5) d_t2 on t1.t1_int=d_t2.t2_int SET t1.t1_char='u';
SELECT * FROM t1;
SELECT * FROM t2;
DELETE t2 FROM t2 JOIN t1 ON t1.t1_int = t2.t2_int AND t1.t1_int = 7;
SELECT * FROM t1;
SELECT * FROM t2;
# Similar error as MCOL-1482
# Similar error as MCOL-1482, but for a foreign engine DELETE.
--error ER_INTERNAL_ERROR
DELETE t1 FROM t1 JOIN t2 ON t1.t1_int = t2.t2_int AND t1.t1_int = 5;
# Test case from MCOL-1482 issue description
CREATE TABLE mcs(a INT, b INT)ENGINE=Columnstore;
CREATE TABLE idb(a INT, b INT)ENGINE=Innodb;
INSERT INTO mcs(a,b) VALUES (1,2),(2,3),(4,5);
INSERT INTO idb(a,b) VALUES (1,2),(2,3),(4,5);
UPDATE idb dest JOIN mcs src ON dest.a=src.a SET dest.b = dest.b + src.b + 100;
SELECT * FROM idb;
UPDATE idb dest JOIN mcs src ON dest.a=src.a SET dest.b = dest.b + src.b + 100;
SELECT * FROM idb;
# Clean UP
DROP USER 'cejuser'@'localhost';
DROP DATABASE mcs45_db;