[MCOL-4868] Update does not work as expected in Version 6.1.1 Created: 2021-09-16  Updated: 2022-01-04  Resolved: 2021-12-17

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.3

Type: Bug Priority: Blocker
Reporter: Edward Stoever Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-4945 NOT IN subquery for some SELECTs and ... Open
Sprint: 2021-15, 2021-16

 Description   

This update fails in 6.1.1 but succeeds in 5.6.2:
UPDATE test_cs SET b='Update' WHERE a IN (SELECT a FROM test_innodb);

Tested example 6.1.1:

root@logs:~$ mariadb -s
MariaDB [(none)]> SHOW STATUS like 'columnstore_version';
Variable_name   Value
Columnstore_version     6.1.1
MariaDB [(none)]> create schema test;
MariaDB [(none)]> use test;
MariaDB [test]> DROP TABLE if EXISTS test_cs;
MariaDB [test]> DROP TABLE if EXISTS test_innodb;
MariaDB [test]> CREATE TABLE test_cs (a INT,b VARCHAR(100)) ENGINE=columnstore;
MariaDB [test]> INSERT INTO test_cs VALUES (1,'Test1'),(2,'Test2'),(3,'Test3'),(4,'Test4');
MariaDB [test]> INSERT INTO test_cs VALUES (null,'TestNULL'),(6,NULL),(7,'Test7');
MariaDB [test]> CREATE TABLE test_innodb (a INT,b VARCHAR(100));
MariaDB [test]> INSERT INTO test_innodb VALUES (1,'innodb1'),(2,'innodb2'),(3,'innodb3');
MariaDB [test]>
MariaDB [test]> SELECT * from test_cs;
a       b
1       Test1
2       Test2
3       Test3
4       Test4
NULL    TestNULL
6       NULL
7       Test7
MariaDB [test]> -- this UPDATE did not work - no change/update on the data
MariaDB [test]> UPDATE test_cs SET b='Update' WHERE a IN (SELECT a FROM test_innodb);
MariaDB [test]> SELECT * from test_cs;
a       b
1       Test1
2       Test2
3       Test3
4       Test4
NULL    TestNULL
6       NULL
7       Test7
MariaDB [test]> -- this UPDATE is a workaround and work
MariaDB [test]> UPDATE test_cs JOIN test_innodb ON (test_cs.a=test_innodb.a) SET test_cs.b='Update';
MariaDB [test]> SELECT * from test_cs;
a       b
1       Update
2       Update
3       Update
4       Test4
NULL    TestNULL
6       NULL
7       Test7
MariaDB [test]>

Tested example 5.6.2:

root@logs:~$ mariadb -s
MariaDB [(none)]> SHOW STATUS like 'columnstore_version';
Variable_name   Value
Columnstore_version     5.6.2
MariaDB [(none)]> create schema test;
MariaDB [(none)]> USE test;
MariaDB [test]> DROP TABLE if EXISTS test_cs;
MariaDB [test]> DROP TABLE if EXISTS test_innodb;
MariaDB [test]> CREATE TABLE test_cs (a INT,b VARCHAR(100)) ENGINE=columnstore;
MariaDB [test]> INSERT INTO test_cs VALUES (1,'Test1'),(2,'Test2'),(3,'Test3'),(4,'Test4');
MariaDB [test]> INSERT INTO test_cs VALUES (null,'TestNULL'),(6,NULL),(7,'Test7');
MariaDB [test]> CREATE TABLE test_innodb (a INT,b VARCHAR(100));
MariaDB [test]> INSERT INTO test_innodb VALUES (1,'innodb1'),(2,'innodb2'),(3,'innodb3');
MariaDB [test]> SELECT * from test_cs;
a       b
1       Test1
2       Test2
3       Test3
4       Test4
NULL    TestNULL
6       NULL
7       Test7
MariaDB [test]> -- this UPDATE works on version 5.6.2
MariaDB [test]> UPDATE test_cs SET b='Update' WHERE a IN (SELECT a FROM test_innodb);
MariaDB [test]> SELECT * from test_cs;
a       b
1       Update
2       Update
3       Update
4       Test4
NULL    TestNULL
6       NULL
7       Test7
MariaDB [test]>



 Comments   
Comment by Daniel Lee (Inactive) [ 2021-12-17 ]

Build verified: 6.2.3-1 (#3550)

Reproduced the reported issue in a earlier develop-6 build.

Verified fix

MariaDB [test]> SELECT * from test_cs;
+------+----------+
| a    | b        |
+------+----------+
|    1 | Test1    |
|    2 | Test2    |
|    3 | Test3    |
|    4 | Test4    |
| NULL | TestNULL |
|    6 | NULL     |
|    7 | Test7    |
+------+----------+
7 rows in set (0.057 sec)
 
MariaDB [test]> UPDATE test_cs SET b='Update' WHERE a IN (SELECT a FROM test_innodb);
Query OK, 3 rows affected (0.209 sec)
Rows matched: 3  Changed: 3  Warnings: 0
 
MariaDB [test]> SELECT * from test_cs;
+------+----------+
| a    | b        |
+------+----------+
|    1 | Update   |
|    2 | Update   |
|    3 | Update   |
|    4 | Test4    |
| NULL | TestNULL |
|    6 | NULL     |
|    7 | Test7    |
+------+----------+
7 rows in set (0.016 sec)

Generated at Thu Feb 08 02:53:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.