summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnel Husakovic <anel@mariadb.org>2022-11-28 16:29:20 +0100
committerAndrew Hutchings <andrew@linuxjedi.co.uk>2022-11-29 19:44:18 +0000
commit6c973be2e9f6068507d42ccb644ff0a92e164d08 (patch)
treee5a379ca89e67366e4a4c9f1e61b1a709e70d3ad
parent9a95838a96a5bbdc2c2064de968e4d686bd6d666 (diff)
downloadmariadb-git-6c973be2e9f6068507d42ccb644ff0a92e164d08.tar.gz
MDEV-28299: Server crashes in XINDXS::Range/CntIndexRange (Connect engine)
- Bug happens only in case when the range function on empty key single column index (XINDEXS) is used. - Solution is to return with empty result in this scenario. Reviewed by: <>
-rw-r--r--storage/connect/mysql-test/connect/r/index.result36
-rw-r--r--storage/connect/mysql-test/connect/t/index.test26
-rw-r--r--storage/connect/xindex.cpp4
3 files changed, 66 insertions, 0 deletions
diff --git a/storage/connect/mysql-test/connect/r/index.result b/storage/connect/mysql-test/connect/r/index.result
index bffaaecc785..edeca2d1960 100644
--- a/storage/connect/mysql-test/connect/r/index.result
+++ b/storage/connect/mysql-test/connect/r/index.result
@@ -139,3 +139,39 @@ DELETE FROM t1;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
+#
+# MDEV-28299: Server crashes in
+# XINDXS::Range/CntIndexRange (Connect engine)
+#
+CREATE TABLE t1 ( a int not null, KEY (a))engine=CONNECT;
+Warnings:
+Warning 1105 No table_type. Will be set to DOS
+Warning 1105 No file name. Table will use t1.dos
+SELECT * FROM t1 WHERE a=1;
+a
+INSERT INTO t1 values (1),(2),(1);
+SELECT * FROM t1 WHERE a=1;
+a
+1
+1
+DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, pk int, PRIMARY KEY (pk)) engine=CONNECT;
+Warnings:
+Warning 1105 No table_type. Will be set to DOS
+Warning 1105 No file name. Table will use t1.dos
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+a
+INSERT INTO t1 values (1,2,1),(2,1,2),(1,2,3),(3,4,4);
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+a
+INSERT INTO t1 values (1,2,5);
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+a
+1
+DROP TABLE t1;
diff --git a/storage/connect/mysql-test/connect/t/index.test b/storage/connect/mysql-test/connect/t/index.test
index 5e913582734..9dc6357074d 100644
--- a/storage/connect/mysql-test/connect/t/index.test
+++ b/storage/connect/mysql-test/connect/t/index.test
@@ -84,3 +84,29 @@ DROP TABLE t3;
--remove_file $MYSQLD_DATADIR/test/emp.txt
--remove_file $MYSQLD_DATADIR/test/sexe.csv
--remove_file $MYSQLD_DATADIR/test/sitmat.csv
+
+--echo #
+--echo # MDEV-28299: Server crashes in
+--echo # XINDXS::Range/CntIndexRange (Connect engine)
+--echo #
+
+CREATE TABLE t1 ( a int not null, KEY (a))engine=CONNECT;
+SELECT * FROM t1 WHERE a=1;
+
+INSERT INTO t1 values (1),(2),(1);
+SELECT * FROM t1 WHERE a=1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int, b int, pk int, PRIMARY KEY (pk)) engine=CONNECT;
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+INSERT INTO t1 values (1,2,1),(2,1,2),(1,2,3),(3,4,4);
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+INSERT INTO t1 values (1,2,5);
+SELECT x.a
+FROM t1 AS x JOIN t1 AS y ON (x.a = y.b)
+WHERE x.pk > 3;
+DROP TABLE t1;
diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp
index 9892bf889ce..334a70c4688 100644
--- a/storage/connect/xindex.cpp
+++ b/storage/connect/xindex.cpp
@@ -2028,6 +2028,10 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl)
PXCOL kp = To_KeyCol;
OPVAL op = Op;
+// In case single column index doesn't exist return
+ if (!kp)
+ return 0;
+
switch (limit) {
case 1: Op = (incl) ? OP_GE : OP_GT; break;
case 2: Op = (incl) ? OP_GT : OP_GE; break;