Commit 820aa11e authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-27581 Wrong result with DESC key on partitioned Spider table

take descending indexes into account when generating a query

also fixes MDEV-27617
parent 24ee346a
......@@ -2796,5 +2796,17 @@ hex(c) c i
C3A4 ä 1
drop table t;
#
# MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results
#
create table t (a int, b char(1), primary key(a desc)) engine=myisam;
insert into t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h');
handler t open;
# MUST return 2,'g'. '>' always means READ_AFTER_KEY. desc or not.
handler t read `primary` > (3);
a b
2 g
handler t close;
drop table t;
#
# End of 10.8 tests
#
......@@ -1895,6 +1895,17 @@ insert into t (c) values ('ä'),('a');
select hex(c),c,i from t order by c, i;
drop table t;
--echo #
--echo # MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results
--echo #
create table t (a int, b char(1), primary key(a desc)) engine=myisam;
insert into t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h');
handler t open;
--echo # MUST return 2,'g'. '>' always means READ_AFTER_KEY. desc or not.
handler t read `primary` > (3);
handler t close;
drop table t;
--echo #
--echo # End of 10.8 tests
--echo #
......@@ -38,6 +38,39 @@ id
5
6
drop table t_sp1, auto_test_local.t;
#
# MDEV-27581 Wrong result with DESC key on partitioned Spider table
#
create table auto_test_local.t1 (a int primary key);
create table auto_test_local.t2 (a int primary key);
create table t (a int, primary key (a desc)) engine=spider
engine=spider comment='wrapper "mysql", srv "s_1"'
partition by range (a)
(partition p1 values less than (4) comment "table 't1'",
partition p2 values less than (maxvalue) comment "table 't2'");
insert into t values (1),(2),(10),(11);
select * from t where a > 1 order by a;
a
2
10
11
drop table t, auto_test_local.t1, auto_test_local.t2;
#
# MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results
#
create table auto_test_local.t (a int, b char(1), primary key(a desc));
insert into auto_test_local.t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h');
create table ts (a int, b char(1), primary key(a desc))
engine=spider comment='wrapper "mysql", srv "s_1", table "t"';
set spider_use_handler=3;
select a, b from ts where a > 0 and b = 'g' order by a;
a b
2 g
set spider_use_handler=default;
select a, b from ts where a > 0 and b = 'g' order by a;
a b
2 g
drop table ts, auto_test_local.t;
drop database auto_test_local;
for master_1
connection master_1;
......
......@@ -5,7 +5,7 @@ set spider_same_server_link= on;
--echo #
--echo # MDEV-27590 Auto-increment on Spider tables with DESC PK does not work properly
--echo #
select @@spider_auto_increment_mode;
create or replace table auto_test_local.t (id int primary key) engine=InnoDB;
create or replace table t_sp1 (id int auto_increment, primary key(id desc))
......@@ -15,6 +15,34 @@ insert into t_sp1 () values (),(),();
select * from t_sp1;
drop table t_sp1, auto_test_local.t;
--echo #
--echo # MDEV-27581 Wrong result with DESC key on partitioned Spider table
--echo #
create table auto_test_local.t1 (a int primary key);
create table auto_test_local.t2 (a int primary key);
create table t (a int, primary key (a desc)) engine=spider
engine=spider comment='wrapper "mysql", srv "s_1"'
partition by range (a)
(partition p1 values less than (4) comment "table 't1'",
partition p2 values less than (maxvalue) comment "table 't2'");
insert into t values (1),(2),(10),(11);
select * from t where a > 1 order by a;
drop table t, auto_test_local.t1, auto_test_local.t2;
--echo #
--echo # MDEV-27617 HANDLER KEY > (x) does not work with DESC keys, Spider is affected and returns wrong results
--echo #
create table auto_test_local.t (a int, b char(1), primary key(a desc));
insert into auto_test_local.t VALUES (1,'f'),(2,'g'),(3,'j'), (4,'i'),(5,'h');
create table ts (a int, b char(1), primary key(a desc))
engine=spider comment='wrapper "mysql", srv "s_1", table "t"';
set spider_use_handler=3;
select a, b from ts where a > 0 and b = 'g' order by a;
set spider_use_handler=default;
select a, b from ts where a > 0 and b = 'g' order by a;
drop table ts, auto_test_local.t;
drop database auto_test_local;
--source ../t/test_deinit.inc
This diff is collapsed.
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