mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-19866 With a Spider table, a SELECT with WHERE involving primary key breaks following SELECTs (#1356)
Change checking scanning partitions from part_spec to part_info->read_partitions
This commit is contained in:
parent
fa7051c419
commit
9d6b601e79
6 changed files with 310 additions and 30 deletions
|
@ -0,0 +1,14 @@
|
|||
--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
|
||||
--let $CHILD2_2_DROP_TABLES= $CHILD2_2_DROP_TABLES_BACKUP
|
||||
--let $CHILD2_2_CREATE_TABLES= $CHILD2_2_CREATE_TABLES_BACKUP
|
||||
--let $CHILD2_2_SELECT_TABLES= $CHILD2_2_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,52 @@
|
|||
--disable_warnings
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
--source ../t/test_init.inc
|
||||
if (!$HAVE_PARTITION)
|
||||
{
|
||||
--source group_by_order_by_limit_deinit.inc
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
skip Test requires partitioning;
|
||||
}
|
||||
--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"'
|
||||
PARTITION BY KEY(pkey) (
|
||||
PARTITION pt1 COMMENT='srv "s_2_1"',
|
||||
PARTITION pt2 COMMENT='srv "s_2_2"'
|
||||
);
|
||||
--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 (
|
||||
pkey int NOT NULL,
|
||||
val char(1) NOT NULL,
|
||||
PRIMARY KEY (pkey)
|
||||
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
|
||||
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
|
||||
let $CHILD2_1_SELECT_TABLES=
|
||||
SELECT pkey, val FROM tbl_a ORDER BY pkey;
|
||||
let $CHILD2_1_SELECT_ARGUMENT1=
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
|
||||
--let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES
|
||||
let $CHILD2_2_DROP_TABLES=
|
||||
DROP TABLE IF EXISTS tbl_a;
|
||||
--let $CHILD2_2_CREATE_TABLES_BACKUP= $CHILD2_2_CREATE_TABLES
|
||||
let $CHILD2_2_CREATE_TABLES=
|
||||
CREATE TABLE tbl_a (
|
||||
pkey int NOT NULL,
|
||||
val char(1) NOT NULL,
|
||||
PRIMARY KEY (pkey)
|
||||
) $CHILD2_2_ENGINE $CHILD2_2_CHARSET;
|
||||
--let $CHILD2_2_SELECT_TABLES_BACKUP= $CHILD2_2_SELECT_TABLES
|
||||
let $CHILD2_2_SELECT_TABLES=
|
||||
SELECT pkey, val FROM tbl_a ORDER BY pkey;
|
||||
let $CHILD2_2_SELECT_ARGUMENT1=
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
|
111
storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result
Normal file
111
storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result
Normal file
|
@ -0,0 +1,111 @@
|
|||
for master_1
|
||||
for child2
|
||||
child2_1
|
||||
child2_2
|
||||
child2_3
|
||||
for child3
|
||||
|
||||
this test is for MDEV-19866
|
||||
|
||||
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;
|
||||
connection child2_2;
|
||||
SET @old_log_output = @@global.log_output;
|
||||
SET GLOBAL log_output = 'TABLE,FILE';
|
||||
CREATE DATABASE auto_test_remote2;
|
||||
USE auto_test_remote2;
|
||||
|
||||
create table and insert
|
||||
connection child2_1;
|
||||
CHILD2_1_CREATE_TABLES
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
connection child2_2;
|
||||
CHILD2_2_CREATE_TABLES
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
connection master_1;
|
||||
CREATE TABLE tbl_a (
|
||||
pkey int NOT NULL,
|
||||
val char(1) NOT NULL,
|
||||
PRIMARY KEY (pkey)
|
||||
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1
|
||||
INSERT INTO tbl_a (pkey,val) VALUES (1,'1'),(2,'2'),(3,'3'),(4,'4');
|
||||
|
||||
select test 1
|
||||
connection child2_1;
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
connection child2_2;
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
connection master_1;
|
||||
SELECT * FROM tbl_a;
|
||||
pkey val
|
||||
1 1
|
||||
3 3
|
||||
2 2
|
||||
4 4
|
||||
SELECT * FROM tbl_a WHERE pkey = 1;
|
||||
pkey val
|
||||
1 1
|
||||
SELECT * FROM tbl_a;
|
||||
pkey val
|
||||
1 1
|
||||
3 3
|
||||
2 2
|
||||
4 4
|
||||
SELECT * FROM tbl_a WHERE pkey = 2;
|
||||
pkey val
|
||||
2 2
|
||||
SELECT * FROM tbl_a;
|
||||
pkey val
|
||||
1 1
|
||||
3 3
|
||||
2 2
|
||||
4 4
|
||||
connection child2_1;
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
|
||||
argument
|
||||
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
|
||||
select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1
|
||||
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
|
||||
select `pkey`,`val` from `auto_test_remote`.`tbl_a`
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
|
||||
SELECT pkey, val FROM tbl_a ORDER BY pkey;
|
||||
pkey val
|
||||
1 1
|
||||
3 3
|
||||
connection child2_2;
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
|
||||
argument
|
||||
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
|
||||
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
|
||||
select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 2
|
||||
select `pkey`,`val` from `auto_test_remote2`.`tbl_a`
|
||||
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
|
||||
SELECT pkey, val FROM tbl_a ORDER BY pkey;
|
||||
pkey val
|
||||
2 2
|
||||
4 4
|
||||
|
||||
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;
|
||||
connection child2_2;
|
||||
DROP DATABASE IF EXISTS auto_test_remote2;
|
||||
SET GLOBAL log_output = @old_log_output;
|
||||
for master_1
|
||||
for child2
|
||||
child2_1
|
||||
child2_2
|
||||
child2_3
|
||||
for child3
|
||||
|
||||
end of test
|
4
storage/spider/mysql-test/spider/bugfix/t/mdev_19866.cnf
Normal file
4
storage/spider/mysql-test/spider/bugfix/t/mdev_19866.cnf
Normal file
|
@ -0,0 +1,4 @@
|
|||
!include include/default_mysqld.cnf
|
||||
!include ../my_1_1.cnf
|
||||
!include ../my_2_1.cnf
|
||||
!include ../my_2_2.cnf
|
97
storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test
Normal file
97
storage/spider/mysql-test/spider/bugfix/t/mdev_19866.test
Normal file
|
@ -0,0 +1,97 @@
|
|||
--source ../include/mdev_19866_init.inc
|
||||
--echo
|
||||
--echo this test is for MDEV-19866
|
||||
--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;
|
||||
|
||||
--connection child2_2
|
||||
SET @old_log_output = @@global.log_output;
|
||||
SET GLOBAL log_output = 'TABLE,FILE';
|
||||
CREATE DATABASE auto_test_remote2;
|
||||
USE auto_test_remote2;
|
||||
--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 child2_2
|
||||
--disable_query_log
|
||||
echo CHILD2_2_CREATE_TABLES;
|
||||
eval $CHILD2_2_CREATE_TABLES;
|
||||
--enable_query_log
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
|
||||
--connection master_1
|
||||
--disable_query_log
|
||||
echo CREATE TABLE tbl_a (
|
||||
pkey int NOT NULL,
|
||||
val char(1) NOT NULL,
|
||||
PRIMARY KEY (pkey)
|
||||
) MASTER_1_ENGINE MASTER_1_CHARSET MASTER_1_COMMENT_2_1;
|
||||
eval CREATE TABLE tbl_a (
|
||||
pkey int NOT NULL,
|
||||
val char(1) NOT NULL,
|
||||
PRIMARY KEY (pkey)
|
||||
) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_2_1;
|
||||
--enable_query_log
|
||||
INSERT INTO tbl_a (pkey,val) VALUES (1,'1'),(2,'2'),(3,'3'),(4,'4');
|
||||
|
||||
--echo
|
||||
--echo select test 1
|
||||
|
||||
--connection child2_1
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
|
||||
--connection child2_2
|
||||
TRUNCATE TABLE mysql.general_log;
|
||||
|
||||
--connection master_1
|
||||
SELECT * FROM tbl_a;
|
||||
SELECT * FROM tbl_a WHERE pkey = 1;
|
||||
SELECT * FROM tbl_a;
|
||||
SELECT * FROM tbl_a WHERE pkey = 2;
|
||||
SELECT * FROM tbl_a;
|
||||
|
||||
--connection child2_1
|
||||
eval $CHILD2_1_SELECT_ARGUMENT1;
|
||||
eval $CHILD2_1_SELECT_TABLES;
|
||||
|
||||
--connection child2_2
|
||||
eval $CHILD2_2_SELECT_ARGUMENT1;
|
||||
eval $CHILD2_2_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;
|
||||
|
||||
--connection child2_2
|
||||
DROP DATABASE IF EXISTS auto_test_remote2;
|
||||
SET GLOBAL log_output = @old_log_output;
|
||||
|
||||
--enable_warnings
|
||||
--source ../include/mdev_19866_deinit.inc
|
||||
--echo
|
||||
--echo end of test
|
|
@ -1639,21 +1639,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
if (from->table->part_info)
|
||||
{
|
||||
DBUG_PRINT("info",("spider partition handler"));
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
DBUG_PRINT("info",("spider part_spec->start_part=%u", part_spec->start_part));
|
||||
DBUG_PRINT("info",("spider part_spec->end_part=%u", part_spec->end_part));
|
||||
if (
|
||||
part_spec->start_part == partition->get_no_current_part_id() ||
|
||||
part_spec->start_part != part_spec->end_part
|
||||
) {
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint bits = bitmap_bits_set(&part_info->read_partitions);
|
||||
DBUG_PRINT("info",("spider bits=%u", bits));
|
||||
if (bits != 1)
|
||||
{
|
||||
DBUG_PRINT("info",("spider using multiple partitions is not supported by this feature yet"));
|
||||
#else
|
||||
DBUG_PRINT("info",("spider partition is not supported by this feature yet"));
|
||||
#endif
|
||||
DBUG_RETURN(NULL);
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1671,17 +1668,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
/* all tables are const_table */
|
||||
DBUG_RETURN(NULL);
|
||||
}
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
if (from->table->part_info)
|
||||
{
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint part = bitmap_get_first_set(&part_info->read_partitions);
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
handler **handlers = partition->get_child_handlers();
|
||||
spider = (ha_spider *) handlers[part_spec->start_part];
|
||||
spider = (ha_spider *) handlers[part];
|
||||
} else {
|
||||
#endif
|
||||
spider = (ha_spider *) from->table->file;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
share = spider->share;
|
||||
|
@ -1702,17 +1700,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
{
|
||||
if (from->table->const_table)
|
||||
continue;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
if (from->table->part_info)
|
||||
{
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint part = bitmap_get_first_set(&part_info->read_partitions);
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
handler **handlers = partition->get_child_handlers();
|
||||
spider = (ha_spider *) handlers[part_spec->start_part];
|
||||
spider = (ha_spider *) handlers[part];
|
||||
} else {
|
||||
#endif
|
||||
spider = (ha_spider *) from->table->file;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
share = spider->share;
|
||||
|
@ -1740,17 +1739,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
do {
|
||||
if (from->table->const_table)
|
||||
continue;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
if (from->table->part_info)
|
||||
{
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint part = bitmap_get_first_set(&part_info->read_partitions);
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
handler **handlers = partition->get_child_handlers();
|
||||
spider = (ha_spider *) handlers[part_spec->start_part];
|
||||
spider = (ha_spider *) handlers[part];
|
||||
} else {
|
||||
#endif
|
||||
spider = (ha_spider *) from->table->file;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
share = spider->share;
|
||||
|
@ -1888,17 +1888,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
{
|
||||
from = from->next_local;
|
||||
}
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
if (from->table->part_info)
|
||||
{
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint part = bitmap_get_first_set(&part_info->read_partitions);
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
handler **handlers = partition->get_child_handlers();
|
||||
spider = (ha_spider *) handlers[part_spec->start_part];
|
||||
spider = (ha_spider *) handlers[part];
|
||||
} else {
|
||||
#endif
|
||||
spider = (ha_spider *) from->table->file;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
share = spider->share;
|
||||
|
@ -1976,17 +1977,18 @@ group_by_handler *spider_create_group_by_handler(
|
|||
continue;
|
||||
fields->clear_conn_holder_from_conn();
|
||||
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
if (from->table->part_info)
|
||||
{
|
||||
partition_info *part_info = from->table->part_info;
|
||||
uint part = bitmap_get_first_set(&part_info->read_partitions);
|
||||
ha_partition *partition = (ha_partition *) from->table->file;
|
||||
part_id_range *part_spec = partition->get_part_spec();
|
||||
handler **handlers = partition->get_child_handlers();
|
||||
spider = (ha_spider *) handlers[part_spec->start_part];
|
||||
spider = (ha_spider *) handlers[part];
|
||||
} else {
|
||||
#endif
|
||||
spider = (ha_spider *) from->table->file;
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS) && defined(PARTITION_HAS_GET_PART_SPEC)
|
||||
#if defined(PARTITION_HAS_GET_CHILD_HANDLERS)
|
||||
}
|
||||
#endif
|
||||
share = spider->share;
|
||||
|
|
Loading…
Reference in a new issue