summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-11-16 21:53:35 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-12 20:35:50 +0100
commit44ca4993b85461a4bdc5f53fd6fdedcc116f2e8b (patch)
tree9c4a0b5f430c663179868f98b0f33c1c02161876
parent2a0f7a34d6ab31aa23522a78ea9fefdf871ea63a (diff)
downloadmariadb-git-44ca4993b85461a4bdc5f53fd6fdedcc116f2e8b.tar.gz
bugfix: partitioning and keyread on an indexed vcol
-rw-r--r--mysql-test/suite/vcol/r/partition.result20
-rw-r--r--mysql-test/suite/vcol/t/partition.test20
-rw-r--r--sql/ha_partition.cc2
3 files changed, 41 insertions, 1 deletions
diff --git a/mysql-test/suite/vcol/r/partition.result b/mysql-test/suite/vcol/r/partition.result
new file mode 100644
index 00000000000..349deed653d
--- /dev/null
+++ b/mysql-test/suite/vcol/r/partition.result
@@ -0,0 +1,20 @@
+CREATE TABLE t1 (
+id INT NOT NULL,
+store_id INT NOT NULL,
+x INT GENERATED ALWAYS AS (id + store_id)
+)
+PARTITION BY RANGE (store_id) (
+PARTITION p0 VALUES LESS THAN (6),
+PARTITION p1 VALUES LESS THAN (11),
+PARTITION p2 VALUES LESS THAN (16),
+PARTITION p3 VALUES LESS THAN (21)
+);
+INSERT t1 (id, store_id) VALUES(1, 2), (3, 4), (3, 12), (4, 18);
+CREATE INDEX idx ON t1(x);
+SELECT x FROM t1;
+x
+3
+7
+15
+22
+DROP TABLE t1;
diff --git a/mysql-test/suite/vcol/t/partition.test b/mysql-test/suite/vcol/t/partition.test
new file mode 100644
index 00000000000..67cda6b6d8b
--- /dev/null
+++ b/mysql-test/suite/vcol/t/partition.test
@@ -0,0 +1,20 @@
+#
+# test keyread on an indexed vcol
+#
+--source include/have_partition.inc
+
+CREATE TABLE t1 (
+ id INT NOT NULL,
+ store_id INT NOT NULL,
+ x INT GENERATED ALWAYS AS (id + store_id)
+)
+PARTITION BY RANGE (store_id) (
+ PARTITION p0 VALUES LESS THAN (6),
+ PARTITION p1 VALUES LESS THAN (11),
+ PARTITION p2 VALUES LESS THAN (16),
+ PARTITION p3 VALUES LESS THAN (21)
+);
+INSERT t1 (id, store_id) VALUES(1, 2), (3, 4), (3, 12), (4, 18);
+CREATE INDEX idx ON t1(x);
+SELECT x FROM t1;
+DROP TABLE t1;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index a54d406f9eb..d1a5a7bb0ea 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -3434,7 +3434,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
}
m_start_key.length= 0;
m_rec0= table->record[0];
- m_rec_length= table_share->stored_rec_length;
+ m_rec_length= table_share->reclength;
if (!m_part_ids_sorted_by_num_of_records)
{
if (!(m_part_ids_sorted_by_num_of_records=