Commit 00db9c6b authored by Kentoku SHIBA's avatar Kentoku SHIBA

MDEV-21884 MariaDB with Spider crashes on a query

parent c79051e5
--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
--connection master_1
set session spider_bgs_mode= @old_spider_bgs_mode;
set session spider_quick_mode= @old_spider_quick_mode;
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--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 $MASTER_1_COMMENT_P_2_1_BACKUP= $MASTER_1_COMMENT_P_2_1
let $MASTER_1_COMMENT_P_2_1=
COMMENT='table "ta_r3"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r2",
priority "1000"',
PARTITION pt2 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", priority "1000001"'
);
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS tbl_a;
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS ta_r2 $STR_SEMICOLON
DROP TABLE IF EXISTS ta_r3;
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE tbl_a (
pkey int NOT NULL,
txt char(8) NOT NULL,
PRIMARY KEY (pkey, txt)
) $CHILD2_1_ENGINE DEFAULT CHARACTER SET utf8;
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE ta_r2 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a,b)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET $STR_SEMICOLON
CREATE TABLE ta_r3 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a,b)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
let $CHILD2_1_SELECT_TABLES=
SELECT pkey, txt FROM tbl_a ORDER BY pkey;
let $CHILD2_1_SELECT_TABLES=
SELECT a, b, c FROM ta_r2 ORDER BY a $STR_SEMICOLON
SELECT a, b, c FROM ta_r3 ORDER BY a;
let $CHILD2_1_SELECT_ARGUMENT1=
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
--connection master_1
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode= 2;
set @old_spider_quick_mode= @@spider_quick_mode;
set session spider_quick_mode= 3;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
connection master_1;
set @old_spider_bgs_mode= @@spider_bgs_mode;
set session spider_bgs_mode= 2;
set @old_spider_quick_mode= @@spider_quick_mode;
set session spider_quick_mode= 3;
this test is for MDEV-21884
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 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a,b)
) ENGINE=Spider COMMENT='table "ta_r3"'
PARTITION BY RANGE(a) (
PARTITION pt1 VALUES LESS THAN (10) COMMENT='srv "s_2_1", table "ta_r2",
priority "1000"',
PARTITION pt2 VALUES LESS THAN MAXVALUE COMMENT='srv "s_2_1", priority "1000001"'
)
CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2
INSERT INTO tbl_a (a, b, c) VALUES
(11, 'a', '2008-08-01 10:21:39'),
(11, 'b', '2000-01-01 00:00:00'),
(12, 'e', '2007-06-04 20:03:11'),
(12, 'd', '2003-11-30 05:01:03'),
(13, 'c', '2001-12-31 23:59:59');
INSERT INTO tb_l (a, b, c) VALUES
(11, 'a', '2008-08-01 10:21:39'),
(12, 'b', '2000-01-01 00:00:00'),
(13, 'e', '2007-06-04 20:03:11'),
(14, 'd', '2003-11-30 05:01:03'),
(15, 'c', '2001-12-31 23:59:59');
test 1
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a;
a b
11 a
11 b
12 d
12 e
13 c
connection child2_1;
SET NAMES utf8;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 11 order by `b`
select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 12 order by `b`
select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 13 order by `b`
select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 14 order by `b`
select `a`,`b` from `auto_test_remote`.`ta_r3` where `a` = 15 order by `b`
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT a, b, c FROM ta_r2 ORDER BY a ;
SELECT a, b, c FROM ta_r3 ORDER BY a;
a b c
a b c
11 a 2008-08-01 10:21:39
11 b 2000-01-01 00:00:00
12 d 2003-11-30 05:01:03
12 e 2007-06-04 20:03:11
13 c 2001-12-31 23:59:59
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 master_1;
set session spider_bgs_mode= @old_spider_bgs_mode;
set session spider_quick_mode= @old_spider_quick_mode;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
end of test
!include include/default_mysqld.cnf
!include ../my_1_1.cnf
!include ../my_2_1.cnf
--source ../include/mdev_21884_init.inc
--echo
--echo this test is for MDEV-21884
--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 (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a,b)
) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
eval CREATE TABLE tbl_a (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a,b)
) $MASTER_1_ENGINE $MASTER_1_COMMENT_P_2_1;
echo CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) MASTER_1_ENGINE2 MASTER_1_CHARSET2;
eval CREATE TABLE tb_l (
a INT,
b CHAR(1),
c DATETIME,
PRIMARY KEY(a)
) $MASTER_1_ENGINE2 $MASTER_1_CHARSET2;
--enable_query_log
INSERT INTO tbl_a (a, b, c) VALUES
(11, 'a', '2008-08-01 10:21:39'),
(11, 'b', '2000-01-01 00:00:00'),
(12, 'e', '2007-06-04 20:03:11'),
(12, 'd', '2003-11-30 05:01:03'),
(13, 'c', '2001-12-31 23:59:59');
INSERT INTO tb_l (a, b, c) VALUES
(11, 'a', '2008-08-01 10:21:39'),
(12, 'b', '2000-01-01 00:00:00'),
(13, 'e', '2007-06-04 20:03:11'),
(14, 'd', '2003-11-30 05:01:03'),
(15, 'c', '2001-12-31 23:59:59');
--echo
--echo test 1
--connection child2_1
TRUNCATE TABLE mysql.general_log;
--connection master_1
SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a;
--connection child2_1
SET NAMES utf8;
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_21884_deinit.inc
--echo
--echo end of test
......@@ -3137,6 +3137,11 @@ int spider_db_fetch_table(
} else {
if (result_list->current_row_num < result_list->quick_page_size)
{
if (!current->first_position)
{
table->status = STATUS_NOT_FOUND;
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
row = current->first_position[result_list->current_row_num].row;
} else {
if ((error_num = spider_db_get_row_from_tmp_tbl(
......@@ -3335,6 +3340,11 @@ int spider_db_fetch_key(
} else {
if (result_list->current_row_num < result_list->quick_page_size)
{
if (!current->first_position)
{
table->status = STATUS_NOT_FOUND;
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
row = current->first_position[result_list->current_row_num].row;
} else {
if ((error_num = spider_db_get_row_from_tmp_tbl(
......@@ -3445,6 +3455,11 @@ int spider_db_fetch_minimum_columns(
{
DBUG_PRINT("info", ("spider current=%p", current));
DBUG_PRINT("info", ("spider first_position=%p", current->first_position));
if (!current->first_position)
{
table->status = STATUS_NOT_FOUND;
DBUG_RETURN(HA_ERR_END_OF_FILE);
}
DBUG_PRINT("info", ("spider current_row_num=%lld", result_list->current_row_num));
DBUG_PRINT("info", ("spider first_position[]=%p", &current->first_position[result_list->current_row_num]));
row = current->first_position[result_list->current_row_num].row;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment