Skip to content

Commit 13047cd

Browse files
author
Alexey Botchkov
committed
MDEV-26540 Spider: Assertion `inited==RND' failed in handler::ha_rnd_end on DELETE.
The ha_partition::direct_delete_rows() only calls file->ha_rnd_init() if the rnd_seq is on. (that is when it's the first call to the direct_update_rows() with RND scan). So don't call the ::ha_rnd_end() if rnd_seq isn't set.
1 parent f18dcfc commit 13047cd

File tree

3 files changed

+88
-4
lines changed

3 files changed

+88
-4
lines changed

sql/ha_partition.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12171,10 +12171,13 @@ int ha_partition::direct_delete_rows(ha_rows *delete_rows_result)
1217112171
file->pre_direct_delete_rows() :
1217212172
file->ha_direct_delete_rows(&delete_rows))))
1217312173
{
12174-
if (m_pre_calling)
12175-
file->ha_pre_rnd_end();
12176-
else
12177-
file->ha_rnd_end();
12174+
if (rnd_seq)
12175+
{
12176+
if (m_pre_calling)
12177+
file->ha_pre_rnd_end();
12178+
else
12179+
file->ha_rnd_end();
12180+
}
1217812181
DBUG_RETURN(error);
1217912182
}
1218012183
delete_rows_result+= delete_rows;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
for master_1
2+
for child2
3+
for child3
4+
SET spider_same_server_link=1;
5+
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
6+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
7+
CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB;
8+
CREATE TABLE t2 (pk INT,c1 INT) ENGINE=Spider COMMENT='TABLE "st"' PARTITION BY LIST COLUMNS (c1)
9+
(PARTITION p DEFAULT COMMENT='srv "d"' ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"');
10+
DELETE FROM t2 WHERE pk=2;
11+
ERROR 42S22: Unknown column 'pk' in 'WHERE'
12+
DROP TABLE t, t2;
13+
CREATE TABLE t (c1 INT,c2 INT,c3 INT,c4 DATE,c5 DATE,c6 TIME,c7 TIME,c8 DATE,c9 DATE,c10 CHAR(1),c11 VARCHAR(1),KEY(c1),KEY(c3),KEY(c4),KEY(c6),KEY(c8),KEY(c10,c3)) ENGINE=Spider PARTITION BY LIST (c1) (PARTITION p VALUES IN (1,2));
14+
SHOW CREATE TABLE t;
15+
Table Create Table
16+
t CREATE TABLE `t` (
17+
`c1` int(11) DEFAULT NULL,
18+
`c2` int(11) DEFAULT NULL,
19+
`c3` int(11) DEFAULT NULL,
20+
`c4` date DEFAULT NULL,
21+
`c5` date DEFAULT NULL,
22+
`c6` time DEFAULT NULL,
23+
`c7` time DEFAULT NULL,
24+
`c8` date DEFAULT NULL,
25+
`c9` date DEFAULT NULL,
26+
`c10` char(1) DEFAULT NULL,
27+
`c11` varchar(1) DEFAULT NULL,
28+
KEY `c1` (`c1`),
29+
KEY `c3` (`c3`),
30+
KEY `c4` (`c4`),
31+
KEY `c6` (`c6`),
32+
KEY `c8` (`c8`),
33+
KEY `c10` (`c10`,`c3`)
34+
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
35+
PARTITION BY LIST (`c1`)
36+
(PARTITION `p` VALUES IN (1,2) ENGINE = SPIDER)
37+
Warnings:
38+
Error 1429 Unable to connect to foreign data source: localhost
39+
Error 1429 Unable to connect to foreign data source: localhost
40+
DELETE FROM t;
41+
ERROR HY000: Unable to connect to foreign data source: localhost
42+
DROP TABLE t;
43+
DROP SERVER srv;
44+
for master_1
45+
for child2
46+
for child3
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--disable_query_log
2+
--disable_result_log
3+
--source ../../t/test_init.inc
4+
--enable_result_log
5+
--enable_query_log
6+
7+
--source include/have_innodb.inc
8+
--source include/have_partition.inc
9+
10+
SET spider_same_server_link=1;
11+
12+
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
13+
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
14+
15+
CREATE TABLE t (c INT KEY,c1 BLOB,c2 TEXT) ENGINE=InnoDB;
16+
CREATE TABLE t2 (pk INT,c1 INT) ENGINE=Spider COMMENT='TABLE "st"' PARTITION BY LIST COLUMNS (c1)
17+
(PARTITION p DEFAULT COMMENT='srv "d"' ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t"');
18+
--error ER_BAD_FIELD_ERROR
19+
DELETE FROM t2 WHERE pk=2;
20+
21+
DROP TABLE t, t2;
22+
23+
CREATE TABLE t (c1 INT,c2 INT,c3 INT,c4 DATE,c5 DATE,c6 TIME,c7 TIME,c8 DATE,c9 DATE,c10 CHAR(1),c11 VARCHAR(1),KEY(c1),KEY(c3),KEY(c4),KEY(c6),KEY(c8),KEY(c10,c3)) ENGINE=Spider PARTITION BY LIST (c1) (PARTITION p VALUES IN (1,2));
24+
SHOW CREATE TABLE t;
25+
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
26+
DELETE FROM t;
27+
DROP TABLE t;
28+
29+
DROP SERVER srv;
30+
31+
--disable_query_log
32+
--disable_result_log
33+
--source ../../t/test_deinit.inc
34+
--enable_result_log
35+
--enable_query_log

0 commit comments

Comments
 (0)