Details
-
Task
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Won't Fix
-
None
Description
For UPDATEs involving a single table, the server call to handler::ha_direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) allows ColumnStore to correctly set the number of updated rows.
However, for UPDATEs involving multi-tables, the server does not call handler::direct_update_rows(). This is causing the following UPDATE statement in ColumnStore to incorrectly report the affected number of rows to the client, even when the actual UPDATE is successful:
MariaDB [test]> CREATE TABLE mcs_1 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore; |
Query OK, 0 rows affected (0.287 sec) |
|
MariaDB [test]> CREATE TABLE mcs_2 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore; |
Query OK, 0 rows affected (0.271 sec) |
|
MariaDB [test]> INSERT INTO mcs_1 VALUES (33, 99, 1); |
Query OK, 1 row affected (1.179 sec)
|
|
MariaDB [test]> INSERT INTO mcs_1 VALUES (33, 99, 2); |
Query OK, 1 row affected (0.115 sec)
|
|
MariaDB [test]> INSERT INTO mcs_1 VALUES (33, 99, 3); |
Query OK, 1 row affected (1.116 sec)
|
|
MariaDB [test]> INSERT INTO mcs_2 VALUES (33, 11, 1); |
Query OK, 1 row affected (0.173 sec)
|
|
MariaDB [test]> INSERT INTO mcs_2 VALUES (33, 11, 2); |
Query OK, 1 row affected (1.119 sec)
|
|
MariaDB [test]> INSERT INTO mcs_2 VALUES (33, 11, 3); |
Query OK, 1 row affected (0.112 sec)
|
|
MariaDB [test]> SELECT * FROM mcs_1; |
+------+------+------+ |
| a | b | c |
|
+------+------+------+ |
| 33 | 99 | 1 |
|
| 33 | 99 | 2 |
|
| 33 | 99 | 3 |
|
+------+------+------+ |
3 rows in set (0.056 sec) |
|
MariaDB [test]> UPDATE mcs_1 A, mcs_2 B SET A.b = B.b WHERE A.c = B.c LIMIT 1; |
Query OK, 0 row affected (1.154 sec)
|
Rows matched: 0 Changed: 0 Warnings: 0 |
|
MariaDB [test]> SELECT * FROM mcs_1; |
+------+------+------+ |
| a | b | c |
|
+------+------+------+ |
| 33 | 11 | 1 |
|
| 33 | 99 | 2 |
|
| 33 | 99 | 3 |
|
+------+------+------+ |
3 rows in set (0.009 sec) |
As can be seen, the UPDATE is successful but the number of affected rows reported to the client is incorrect.
For the above multi-table UPDATE, the server execution calls the below functions in the following order:
1. handler::rnd_init()
2. handler::rnd_end()
3. multi_update::send_eof()
multi_update::send_eof() is responsible for reporting the count of the affected rows to the client. Knowing this execution order, ColumnStore can correctly set the number of affected rows in handler::rnd_end(), provided the following members of class multi_update are made public:
multi_update::update_tables
multi_update::table_to_update
multi_update::updated
multi_update::found
Attachments
Issue Links
- blocks
-
MCOL-4740 UPDATE returns wrong "Rows matched" on multi-tables
- Closed
- relates to
-
MDEV-32256 bulk multi-update / multi-delete API for smart engines
- Open