Browse Source
MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
MDEV-20502 Queries against spider tables return wrong values for columns following constant declarations.
When executing a query like "select id, 0 as const, val from ...", there are 3 columns(items) in Query->select at handlerton->create_group_by(). After that, MariaDB makes a temporary table with 2 columns. The skipped items are const item, so fixing Spider to skip const items for items at Query->select.bb-10.4-MDEV-22203
10 changed files with 216 additions and 4 deletions
-
11storage/spider/mysql-test/spider/bugfix/include/mdev_20502_deinit.inc
-
25storage/spider/mysql-test/spider/bugfix/include/mdev_20502_init.inc
-
61storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result
-
3storage/spider/mysql-test/spider/bugfix/t/mdev_20502.cnf
-
71storage/spider/mysql-test/spider/bugfix/t/mdev_20502.test
-
2storage/spider/mysql-test/spider/r/timestamp.result
-
3storage/spider/spd_db_conn.cc
-
20storage/spider/spd_db_mysql.cc
-
19storage/spider/spd_db_oracle.cc
-
5storage/spider/spd_group_by_handler.cc
@ -0,0 +1,11 @@ |
|||||
|
--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP |
||||
|
--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP |
||||
|
--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP |
||||
|
--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP |
||||
|
--disable_warnings |
||||
|
--disable_query_log |
||||
|
--disable_result_log |
||||
|
--source ../t/test_deinit.inc |
||||
|
--enable_result_log |
||||
|
--enable_query_log |
||||
|
--enable_warnings |
||||
@ -0,0 +1,25 @@ |
|||||
|
--disable_warnings |
||||
|
--disable_query_log |
||||
|
--disable_result_log |
||||
|
--source ../t/test_init.inc |
||||
|
--enable_result_log |
||||
|
--enable_query_log |
||||
|
--enable_warnings |
||||
|
--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1 |
||||
|
let $MASTER_1_COMMENT_2_1= |
||||
|
COMMENT='table "tbl_a", srv "s_2_1"'; |
||||
|
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES |
||||
|
let $CHILD2_1_DROP_TABLES= |
||||
|
DROP TABLE IF EXISTS tbl_a; |
||||
|
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES |
||||
|
let $CHILD2_1_CREATE_TABLES= |
||||
|
CREATE TABLE tbl_a ( |
||||
|
id int(10) unsigned NOT NULL AUTO_INCREMENT, |
||||
|
val int(10) unsigned DEFAULT NULL, |
||||
|
PRIMARY KEY (id) |
||||
|
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET; |
||||
|
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES |
||||
|
let $CHILD2_1_SELECT_TABLES= |
||||
|
SELECT id, val FROM tbl_a ORDER BY id; |
||||
|
let $CHILD2_1_SELECT_ARGUMENT1= |
||||
|
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; |
||||
@ -0,0 +1,61 @@ |
|||||
|
for master_1 |
||||
|
for child2 |
||||
|
child2_1 |
||||
|
child2_2 |
||||
|
child2_3 |
||||
|
for child3 |
||||
|
|
||||
|
this test is for MDEV-20502 |
||||
|
|
||||
|
drop and create databases |
||||
|
connection master_1; |
||||
|
CREATE DATABASE auto_test_local; |
||||
|
USE auto_test_local; |
||||
|
connection child2_1; |
||||
|
SET @old_log_output = @@global.log_output; |
||||
|
SET GLOBAL log_output = 'TABLE,FILE'; |
||||
|
CREATE DATABASE auto_test_remote; |
||||
|
USE auto_test_remote; |
||||
|
|
||||
|
create table and insert |
||||
|
connection child2_1; |
||||
|
CHILD2_1_CREATE_TABLES |
||||
|
TRUNCATE TABLE mysql.general_log; |
||||
|
connection master_1; |
||||
|
CREATE TABLE tbl_a ( |
||||
|
id int(10) unsigned NOT NULL AUTO_INCREMENT, |
||||
|
val int(10) unsigned DEFAULT NULL, |
||||
|
PRIMARY KEY(id) |
||||
|
) ENGINE=Spider COMMENT='table "tbl_a", srv "s_2_1"' |
||||
|
INSERT INTO tbl_a (val) VALUES (1); |
||||
|
|
||||
|
test 1 |
||||
|
connection child2_1; |
||||
|
TRUNCATE TABLE mysql.general_log; |
||||
|
connection master_1; |
||||
|
SELECT id, 0 AS const, val FROM tbl_a; |
||||
|
id const val |
||||
|
1 0 1 |
||||
|
connection child2_1; |
||||
|
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; |
||||
|
argument |
||||
|
select t0.`id` `id`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t0 |
||||
|
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' |
||||
|
SELECT id, val FROM tbl_a ORDER BY id; |
||||
|
id val |
||||
|
1 1 |
||||
|
|
||||
|
deinit |
||||
|
connection master_1; |
||||
|
DROP DATABASE IF EXISTS auto_test_local; |
||||
|
connection child2_1; |
||||
|
DROP DATABASE IF EXISTS auto_test_remote; |
||||
|
SET GLOBAL log_output = @old_log_output; |
||||
|
for master_1 |
||||
|
for child2 |
||||
|
child2_1 |
||||
|
child2_2 |
||||
|
child2_3 |
||||
|
for child3 |
||||
|
|
||||
|
end of test |
||||
@ -0,0 +1,3 @@ |
|||||
|
!include include/default_mysqld.cnf |
||||
|
!include ../my_1_1.cnf |
||||
|
!include ../my_2_1.cnf |
||||
@ -0,0 +1,71 @@ |
|||||
|
--source ../include/mdev_20502_init.inc |
||||
|
--echo |
||||
|
--echo this test is for MDEV-20502 |
||||
|
--echo |
||||
|
--echo drop and create databases |
||||
|
|
||||
|
--connection master_1 |
||||
|
--disable_warnings |
||||
|
CREATE DATABASE auto_test_local; |
||||
|
USE auto_test_local; |
||||
|
|
||||
|
--connection child2_1 |
||||
|
SET @old_log_output = @@global.log_output; |
||||
|
SET GLOBAL log_output = 'TABLE,FILE'; |
||||
|
CREATE DATABASE auto_test_remote; |
||||
|
USE auto_test_remote; |
||||
|
--enable_warnings |
||||
|
|
||||
|
--echo |
||||
|
--echo create table and insert |
||||
|
|
||||
|
--connection child2_1 |
||||
|
--disable_query_log |
||||
|
echo CHILD2_1_CREATE_TABLES; |
||||
|
eval $CHILD2_1_CREATE_TABLES; |
||||
|
--enable_query_log |
||||
|
TRUNCATE TABLE mysql.general_log; |
||||
|
|
||||
|
--connection master_1 |
||||
|
--disable_query_log |
||||
|
echo CREATE TABLE tbl_a ( |
||||
|
id int(10) unsigned NOT NULL AUTO_INCREMENT, |
||||
|
val int(10) unsigned DEFAULT NULL, |
||||
|
PRIMARY KEY(id) |
||||
|
) $MASTER_1_ENGINE $MASTER_1_COMMENT_2_1; |
||||
|
eval CREATE TABLE tbl_a ( |
||||
|
id int(10) unsigned NOT NULL AUTO_INCREMENT, |
||||
|
val int(10) unsigned DEFAULT NULL, |
||||
|
PRIMARY KEY(id) |
||||
|
) $MASTER_1_ENGINE $MASTER_1_COMMENT_2_1; |
||||
|
--enable_query_log |
||||
|
INSERT INTO tbl_a (val) VALUES (1); |
||||
|
|
||||
|
--echo |
||||
|
--echo test 1 |
||||
|
|
||||
|
--connection child2_1 |
||||
|
TRUNCATE TABLE mysql.general_log; |
||||
|
|
||||
|
--connection master_1 |
||||
|
SELECT id, 0 AS const, val FROM tbl_a; |
||||
|
|
||||
|
--connection child2_1 |
||||
|
eval $CHILD2_1_SELECT_ARGUMENT1; |
||||
|
eval $CHILD2_1_SELECT_TABLES; |
||||
|
|
||||
|
--echo |
||||
|
--echo deinit |
||||
|
--disable_warnings |
||||
|
|
||||
|
--connection master_1 |
||||
|
DROP DATABASE IF EXISTS auto_test_local; |
||||
|
|
||||
|
--connection child2_1 |
||||
|
DROP DATABASE IF EXISTS auto_test_remote; |
||||
|
SET GLOBAL log_output = @old_log_output; |
||||
|
|
||||
|
--enable_warnings |
||||
|
--source ../include/mdev_20502_deinit.inc |
||||
|
--echo |
||||
|
--echo end of test |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue