Commit 42cc59a8 authored by Igor Babaev's avatar Igor Babaev

Backported the test case for bug 43618 from mysql code line.

parent d86ad186
......@@ -138,6 +138,47 @@ ORDER BY c2 DESC LIMIT 2;
--echo
DROP TABLE t1;
--echo #
--echo # BUG#43618: MyISAM&Maria returns wrong results with 'between'
--echo # on timestamp
--echo #
CREATE TABLE t1(
ts TIMESTAMP NOT NULL,
c char NULL,
PRIMARY KEY(ts)
);
INSERT INTO t1 VALUES
('1971-01-01','a'),
('2007-05-25','b'),
('2008-01-01','c'),
('2038-01-09','d');
--disable_warnings
--echo
--echo # Execute select with invalid timestamp, desc ordering
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
--echo
--echo # Should use index condition
EXPLAIN
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
--echo
--enable_warnings
DROP TABLE t1;
--echo #
--echo # BUG#49906: Assertion failed - Field_varstring::val_str in field.cc
--echo # (Note: Fixed by patch for LP BUG#625841)
......
......@@ -131,6 +131,42 @@ ORDER BY c2 DESC LIMIT 2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
DROP TABLE t1;
#
# BUG#43618: MyISAM&Maria returns wrong results with 'between'
# on timestamp
#
CREATE TABLE t1(
ts TIMESTAMP NOT NULL,
c char NULL,
PRIMARY KEY(ts)
);
INSERT INTO t1 VALUES
('1971-01-01','a'),
('2007-05-25','b'),
('2008-01-01','c'),
('2038-01-09','d');
# Execute select with invalid timestamp, desc ordering
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
ts c
2008-01-01 00:00:00 c
2007-05-25 00:00:00 b
# Should use index condition
EXPLAIN
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition
DROP TABLE t1;
#
# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc
......
......@@ -131,6 +131,42 @@ ORDER BY c2 DESC LIMIT 2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
DROP TABLE t1;
#
# BUG#43618: MyISAM&Maria returns wrong results with 'between'
# on timestamp
#
CREATE TABLE t1(
ts TIMESTAMP NOT NULL,
c char NULL,
PRIMARY KEY(ts)
);
INSERT INTO t1 VALUES
('1971-01-01','a'),
('2007-05-25','b'),
('2008-01-01','c'),
('2038-01-09','d');
# Execute select with invalid timestamp, desc ordering
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
ts c
2008-01-01 00:00:00 c
2007-05-25 00:00:00 b
# Should use index condition
EXPLAIN
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition
DROP TABLE t1;
#
# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc
......
......@@ -129,6 +129,42 @@ ORDER BY c2 DESC LIMIT 2;
c1 c2 c3 c4
2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
DROP TABLE t1;
#
# BUG#43618: MyISAM&Maria returns wrong results with 'between'
# on timestamp
#
CREATE TABLE t1(
ts TIMESTAMP NOT NULL,
c char NULL,
PRIMARY KEY(ts)
);
INSERT INTO t1 VALUES
('1971-01-01','a'),
('2007-05-25','b'),
('2008-01-01','c'),
('2038-01-09','d');
# Execute select with invalid timestamp, desc ordering
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
ts c
2008-01-01 00:00:00 c
2007-05-25 00:00:00 b
# Should use index condition
EXPLAIN
SELECT *
FROM t1
WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
ORDER BY ts DESC
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition
DROP TABLE t1;
#
# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc
......
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