You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
fix(plugin): this is to addres the original patch QA found in the original patch
This commit is contained in:
@ -16,14 +16,6 @@
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA. */
|
||||
|
||||
// This makes specific MDB classes' attributes public to implement
|
||||
// MCOL-4740 temporary solution. Search for MCOL-4740
|
||||
// to get the actual place where it is used.
|
||||
#define updated_leaves \
|
||||
updated_leaves; \
|
||||
\
|
||||
public:
|
||||
|
||||
#include "ha_mcs.h"
|
||||
#include "maria_def.h"
|
||||
#include <typeinfo>
|
||||
@ -622,39 +614,10 @@ int ha_mcs::rnd_init(bool scan)
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
void update_counters_on_multi_update()
|
||||
{
|
||||
if (ha_mcs_common::isMultiUpdateStatement(current_thd->lex->sql_command) &&
|
||||
!ha_mcs_common::isForeignTableUpdate(current_thd))
|
||||
{
|
||||
SELECT_LEX_UNIT* unit = ¤t_thd->lex->unit;
|
||||
SELECT_LEX* select_lex = unit->first_select();
|
||||
auto* multi = (select_lex->join) ? reinterpret_cast<multi_update*>(select_lex->join->result) : nullptr;
|
||||
|
||||
if (multi)
|
||||
{
|
||||
multi->table_to_update = multi->update_tables ? multi->update_tables->table : 0;
|
||||
|
||||
cal_impl_if::cal_connection_info* ci =
|
||||
reinterpret_cast<cal_impl_if::cal_connection_info*>(get_fe_conn_info_ptr());
|
||||
|
||||
if (ci)
|
||||
{
|
||||
multi->updated = multi->found = ci->affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ha_mcs::rnd_end()
|
||||
{
|
||||
DBUG_ENTER("ha_mcs::rnd_end");
|
||||
|
||||
// MCOL-4740 multi_update::send_eof(), which outputs the affected
|
||||
// number of rows to the client, is called after handler::rnd_end().
|
||||
// So we set multi_update::updated and multi_update::found here.
|
||||
update_counters_on_multi_update();
|
||||
|
||||
int rc;
|
||||
try
|
||||
{
|
||||
|
@ -17,8 +17,40 @@
|
||||
#include <typeinfo>
|
||||
#include <string>
|
||||
|
||||
// This makes specific MDB classes' attributes public to implement
|
||||
// MCOL-4740 temporary solution. Search for MCOL-4740
|
||||
// to get the actual place where it is used.
|
||||
#define updated_leaves \
|
||||
updated_leaves; \
|
||||
\
|
||||
public:
|
||||
|
||||
#include "ha_mcs_pushdown.h"
|
||||
|
||||
void update_counters_on_multi_update()
|
||||
{
|
||||
if (ha_mcs_common::isMultiUpdateStatement(current_thd->lex->sql_command) &&
|
||||
!ha_mcs_common::isForeignTableUpdate(current_thd))
|
||||
{
|
||||
SELECT_LEX_UNIT* unit = ¤t_thd->lex->unit;
|
||||
SELECT_LEX* select_lex = unit->first_select();
|
||||
auto* multi = (select_lex->join) ? reinterpret_cast<multi_update*>(select_lex->join->result) : nullptr;
|
||||
|
||||
if (multi)
|
||||
{
|
||||
multi->table_to_update = multi->update_tables ? multi->update_tables->table : 0;
|
||||
|
||||
cal_impl_if::cal_connection_info* ci =
|
||||
reinterpret_cast<cal_impl_if::cal_connection_info*>(get_fe_conn_info_ptr());
|
||||
|
||||
if (ci)
|
||||
{
|
||||
multi->updated = multi->found = ci->affectedRows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void check_walk(const Item* item, void* arg);
|
||||
|
||||
void restore_query_state(ha_columnstore_select_handler* handler)
|
||||
@ -1168,6 +1200,11 @@ int ha_columnstore_select_handler::end_scan()
|
||||
|
||||
scan_ended = true;
|
||||
|
||||
// MCOL-4740 multi_update::send_eof(), which outputs the affected
|
||||
// number of rows to the client, is called after handler::rnd_end().
|
||||
// So we set multi_update::updated and multi_update::found here.
|
||||
update_counters_on_multi_update();
|
||||
|
||||
int rc = ha_mcs_impl_rnd_end(table, true);
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
|
80
mysql-test/columnstore/bugfixes/mcol-4740.result
Normal file
80
mysql-test/columnstore/bugfixes/mcol-4740.result
Normal file
@ -0,0 +1,80 @@
|
||||
DROP DATABASE IF EXISTS mcol_4740;
|
||||
CREATE DATABASE mcol_4740;
|
||||
USE mcol_4740;
|
||||
CREATE TABLE mcs_1 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore;
|
||||
CREATE TABLE mcs_2 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore;
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 1);
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 2);
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 3);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 1);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 2);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 3);
|
||||
SELECT * FROM mcs_1;
|
||||
a b c
|
||||
33 99 1
|
||||
33 99 2
|
||||
33 99 3
|
||||
UPDATE mcs_1 A, mcs_2 B SET A.b = B.b WHERE A.c = B.c LIMIT 1;
|
||||
affected rows: 1
|
||||
info: Rows matched: 1 Changed: 1 Warnings: 0
|
||||
SELECT * FROM mcs_1;
|
||||
a b c
|
||||
33 11 1
|
||||
33 99 2
|
||||
33 99 3
|
||||
UPDATE mcs_1 A, mcs_2 B SET A.b = A.b + 1, B.b = B.b + 1;
|
||||
ERROR 42000: The storage engine for the table doesn't support MCS-1012: This version of Columnstore supports update of only one table at a time.
|
||||
CREATE TABLE `test1` (
|
||||
`id` text NOT NULL,
|
||||
`p_date` int(11) DEFAULT NULL,
|
||||
`con_bfr` text DEFAULT NULL,
|
||||
`org_bfr` text DEFAULT NULL,
|
||||
`pat_bfr` text DEFAULT NULL,
|
||||
`data_type` text DEFAULT NULL,
|
||||
`order_no` text DEFAULT NULL,
|
||||
`tra_bfr` text DEFAULT NULL,
|
||||
`load_bfr` text DEFAULT NULL,
|
||||
`status` int(11) DEFAULT NULL
|
||||
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
|
||||
INSERT INTO test1 values ('index_srgt_id','0','consultation_date_bfr','organization_code_bfr','patient_id_bfr','data_type','order_no','transaction_time_bfr','load_timestamp_bfr','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000001','20190610','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000002','20190610','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000003','20190611','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000004','20190612','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
SELECT status FROM test1;
|
||||
status
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
UPDATE test1 main
|
||||
INNER JOIN (SELECT id,
|
||||
con_bfr,
|
||||
order_no,
|
||||
ROW_NUMBER() OVER (PARTITION BY IFNULL(p_date,''),
|
||||
IFNULL(con_bfr,''),
|
||||
IFNULL(org_bfr,''),
|
||||
IFNULL(pat_bfr,''),
|
||||
IFNULL(data_type,'')
|
||||
ORDER BY IFNULL(tra_bfr,'') DESC,
|
||||
IFNULL(load_bfr,'') DESC,
|
||||
id DESC
|
||||
) AS row_num
|
||||
FROM test1 tmp
|
||||
) tmp
|
||||
ON main.id = tmp.id
|
||||
AND main.con_bfr = tmp.con_bfr
|
||||
AND main.order_no = tmp.order_no
|
||||
AND tmp.row_num = 1
|
||||
SET main.status = 1;
|
||||
affected rows: 4
|
||||
info: Rows matched: 4 Changed: 4 Warnings: 0
|
||||
SELECT status FROM test1;
|
||||
status
|
||||
1
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
DROP DATABASE mcol_4740;
|
82
mysql-test/columnstore/bugfixes/mcol-4740.test
Normal file
82
mysql-test/columnstore/bugfixes/mcol-4740.test
Normal file
@ -0,0 +1,82 @@
|
||||
#
|
||||
# MCOL-4740 UPDATE involving multi-tables returns wrong "Rows matched"
|
||||
#
|
||||
|
||||
--source ../include/have_columnstore.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mcol_4740;
|
||||
--enable_warnings
|
||||
CREATE DATABASE mcol_4740;
|
||||
USE mcol_4740;
|
||||
|
||||
# Test case 1 from MCOL
|
||||
CREATE TABLE mcs_1 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore;
|
||||
CREATE TABLE mcs_2 (a INT, b INT(11), c VARCHAR(100)) engine=columnstore;
|
||||
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 1);
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 2);
|
||||
INSERT INTO mcs_1 VALUES (33, 99, 3);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 1);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 2);
|
||||
INSERT INTO mcs_2 VALUES (33, 11, 3);
|
||||
|
||||
SELECT * FROM mcs_1;
|
||||
|
||||
--enable_info
|
||||
UPDATE mcs_1 A, mcs_2 B SET A.b = B.b WHERE A.c = B.c LIMIT 1;
|
||||
--disable_info
|
||||
|
||||
SELECT * FROM mcs_1;
|
||||
|
||||
--error ER_CHECK_NOT_IMPLEMENTED
|
||||
UPDATE mcs_1 A, mcs_2 B SET A.b = A.b + 1, B.b = B.b + 1;
|
||||
|
||||
# Test case 2 from MCOL
|
||||
CREATE TABLE `test1` (
|
||||
`id` text NOT NULL,
|
||||
`p_date` int(11) DEFAULT NULL,
|
||||
`con_bfr` text DEFAULT NULL,
|
||||
`org_bfr` text DEFAULT NULL,
|
||||
`pat_bfr` text DEFAULT NULL,
|
||||
`data_type` text DEFAULT NULL,
|
||||
`order_no` text DEFAULT NULL,
|
||||
`tra_bfr` text DEFAULT NULL,
|
||||
`load_bfr` text DEFAULT NULL,
|
||||
`status` int(11) DEFAULT NULL
|
||||
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO test1 values ('index_srgt_id','0','consultation_date_bfr','organization_code_bfr','patient_id_bfr','data_type','order_no','transaction_time_bfr','load_timestamp_bfr','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000001','20190610','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000002','20190610','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000003','20190611','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
INSERT INTO test1 values ('adt-a55-9000000004','20190612','2.01906E+13','1116508857','PTNT-0001','ADT-01','511','2.01801E+13','2.01801E+13','0');
|
||||
|
||||
SELECT status FROM test1;
|
||||
|
||||
--enable_info
|
||||
UPDATE test1 main
|
||||
INNER JOIN (SELECT id,
|
||||
con_bfr,
|
||||
order_no,
|
||||
ROW_NUMBER() OVER (PARTITION BY IFNULL(p_date,''),
|
||||
IFNULL(con_bfr,''),
|
||||
IFNULL(org_bfr,''),
|
||||
IFNULL(pat_bfr,''),
|
||||
IFNULL(data_type,'')
|
||||
ORDER BY IFNULL(tra_bfr,'') DESC,
|
||||
IFNULL(load_bfr,'') DESC,
|
||||
id DESC
|
||||
) AS row_num
|
||||
FROM test1 tmp
|
||||
) tmp
|
||||
ON main.id = tmp.id
|
||||
AND main.con_bfr = tmp.con_bfr
|
||||
AND main.order_no = tmp.order_no
|
||||
AND tmp.row_num = 1
|
||||
SET main.status = 1;
|
||||
--disable_info
|
||||
|
||||
SELECT status FROM test1;
|
||||
|
||||
DROP DATABASE mcol_4740;
|
Reference in New Issue
Block a user