summaryrefslogtreecommitdiff
path: root/mysql-test/t/partition_innodb.test
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2008-10-10 12:01:01 +0200
committerMattias Jonsson <mattias.jonsson@sun.com>2008-10-10 12:01:01 +0200
commitd3ea7430152fad48cabd9efb8c80d177405dd090 (patch)
tree26c18991c89e887e3a6c706f648f8e6be6a7803f /mysql-test/t/partition_innodb.test
parent9846ab0a70241945f59e1f474137546dcbd66ed8 (diff)
downloadmariadb-git-d3ea7430152fad48cabd9efb8c80d177405dd090.tar.gz
Bug#37721: ORDER BY when WHERE contains non-partitioned
index column There was actually two problems 1) when clustered pk, order by non pk index should also compare with pk as last resort to differ keys from each other 2) bug in the index search handling in ha_partition (was found when extending the test case Solution to 1 was to include the pk in key compare if clustered pk and search on other index. Solution for 2 was to remove the optimization from ordered scan to unordered scan if clustered pk. mysql-test/r/partition_innodb.result: Bug#37721: ORDER BY when WHERE contains non-partitioned index column updated test result. mysql-test/t/partition_innodb.test: Bug#37721: ORDER BY when WHERE contains non-partitioned index column Added test case for bug verification. sql/ha_partition.cc: Bug#37721: ORDER BY when WHERE contains non-partitioned index column using m_curr_key_info with both given index and PK if clustered PK. Also including PK in read_set. Added debug prints for easier verification. sql/ha_partition.h: Bug#37721: ORDER BY when WHERE contains non-partitioned index column Changed m_curr_key_info to a null terminated array with max 2 keys and a terminating null. For use with key_rec_cmp with both given index and PK. sql/key.cc: Bug#37721: ORDER BY when WHERE contains non-partitioned index column added handling of a null terminated array of keys for use in compare.
Diffstat (limited to 'mysql-test/t/partition_innodb.test')
-rw-r--r--mysql-test/t/partition_innodb.test40
1 files changed, 40 insertions, 0 deletions
diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
index 932855cc877..c29b3458d19 100644
--- a/mysql-test/t/partition_innodb.test
+++ b/mysql-test/t/partition_innodb.test
@@ -1,6 +1,46 @@
--source include/have_partition.inc
--source include/have_innodb.inc
+#
+# Bug37721: ORDER BY when WHERE contains non-partitioned index column
+# wrong order since it did not use pk as second compare
+--echo # Bug#37721, test of ORDER BY on PK and WHERE on INDEX
+CREATE TABLE t1 (
+ a INT,
+ b INT,
+ PRIMARY KEY (a),
+ INDEX (b))
+ENGINE InnoDB
+PARTITION BY HASH(a)
+PARTITIONS 3;
+# This will give the middle partition the highest value
+INSERT INTO t1 VALUES (0,0),(4,0),(2,0);
+SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
+SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
+ALTER TABLE t1 DROP INDEX b;
+SELECT a FROM t1 WHERE b = 0 ORDER BY a ASC;
+SELECT a FROM t1 WHERE b = 0 ORDER BY a DESC;
+DROP TABLE t1;
+CREATE TABLE t1 (
+ a VARCHAR(600),
+ b VARCHAR(600),
+ PRIMARY KEY (a),
+ INDEX (b))
+ENGINE InnoDB
+PARTITION BY KEY(a)
+PARTITIONS 3;
+# This will give the middle partition the highest value
+INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'1'),repeat('0',257));
+INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'3'),repeat('0',257));
+INSERT INTO t1 VALUES (concat(repeat('MySQL',100),'2'),repeat('0',257));
+SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
+SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
+ALTER TABLE t1 DROP INDEX b;
+SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a ASC;
+SELECT right(a,1) FROM t1 WHERE b = repeat('0',257) ORDER BY a DESC;
+DROP TABLE t1;
+
+#
# Bug#32948 - FKs allowed to reference partitioned table
#
-- echo # Bug#32948