Commit 93d8f887 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.2 into 10.3

parents 2944d7e6 4e825b0e
Subproject commit a746c3af449a8754e78ad7971e59e79af7957cdb
Subproject commit fc431a035a21ac1d4ef25d9d3cd8c4d7e64a8ee7
......@@ -2459,7 +2459,38 @@ count(*)+sleep(0)
2
drop table t1;
#
# Start of 10.3 tests
# MDEV-25112: MIN/MAX optimization for query containing BETWEEN in WHERE
#
create table t1 (a int) engine=myisam;
insert into t1 values (267), (273), (287), (303), (308);
select max(a) from t1 where a < 303 and (a between 267 AND 287);
max(a)
287
explain select max(a) from t1 where a < 303 and (a between 267 AND 287);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
select min(a) from t1 where a > 267 and (a between 273 AND 303);
min(a)
273
explain select min(a) from t1 where a > 267 and (a between 273 AND 303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
create index idx on t1(a);
select max(a) from t1 where a < 303 and (a between 267 AND 287);
max(a)
287
explain select max(a) from t1 where a < 303 and (a between 267 AND 287);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select min(a) from t1 where a > 267 and (a between 273 AND 303);
min(a)
273
explain select min(a) from t1 where a > 267 and (a between 273 AND 303);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1;
#
# End of 10.2 tests
#
#
# MDEV-9408 CREATE TABLE SELECT MAX(int_column) creates different columns for table vs view
......@@ -2491,3 +2522,6 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
#
# End of 10.3 tests
#
......@@ -1704,7 +1704,33 @@ select count(*)+sleep(0) from t1;
drop table t1;
--echo #
--echo # Start of 10.3 tests
--echo # MDEV-25112: MIN/MAX optimization for query containing BETWEEN in WHERE
--echo #
create table t1 (a int) engine=myisam;
insert into t1 values (267), (273), (287), (303), (308);
let $q1=
select max(a) from t1 where a < 303 and (a between 267 AND 287);
let $q2=
select min(a) from t1 where a > 267 and (a between 273 AND 303);
eval $q1;
eval explain $q1;
eval $q2;
eval explain $q2;
create index idx on t1(a);
eval $q1;
eval explain $q1;
eval $q2;
eval explain $q2;
drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
......@@ -1729,3 +1755,7 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -86,7 +86,7 @@ my_off_t my_tell(File fd, myf MyFlags)
DBUG_ENTER("my_tell");
DBUG_PRINT("my",("fd: %d MyFlags: %lu",fd, MyFlags));
DBUG_ASSERT(fd >= 0);
#if defined (HAVE_TELL) && !defined (_WIN32)
#if defined (HAVE_TELL) && !defined (_WIN32) && !defined(_AIX)
pos= tell(fd);
#else
pos= my_seek(fd, 0L, MY_SEEK_CUR,0);
......
......@@ -842,7 +842,10 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
if (is_field_part)
{
if (between || eq_type)
{
*range_fl&= ~(NO_MAX_RANGE | NO_MIN_RANGE);
*range_fl&= ~(max_fl ? NEAR_MAX : NEAR_MIN);
}
else
{
*range_fl&= ~(max_fl ? NO_MAX_RANGE : NO_MIN_RANGE);
......
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