mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
lp:822760 Wrong result with view + invalid dates
sql/sql_select.cc: items' cmp_type()'s must match, not result_type()'s
This commit is contained in:
parent
aab970f5e1
commit
5dc1a2231f
5 changed files with 125 additions and 1 deletions
|
@ -5031,3 +5031,40 @@ SELECT * FROM t1 WHERE a = b;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# lp:822760 Wrong result with view + invalid dates
|
||||
#
|
||||
CREATE TABLE t1 (f1 date);
|
||||
INSERT IGNORE INTO t1 VALUES ('0000-00-00');
|
||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t1 HAVING f1 = 'zz';
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM t1 HAVING f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
DROP TABLE t1;
|
||||
DROP VIEW v1;
|
||||
|
|
|
@ -5040,6 +5040,43 @@ SELECT * FROM t1 WHERE a = b;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# lp:822760 Wrong result with view + invalid dates
|
||||
#
|
||||
CREATE TABLE t1 (f1 date);
|
||||
INSERT IGNORE INTO t1 VALUES ('0000-00-00');
|
||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t1 HAVING f1 = 'zz';
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM t1 HAVING f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
DROP TABLE t1;
|
||||
DROP VIEW v1;
|
||||
set join_cache_level=default;
|
||||
show variables like 'join_cache_level';
|
||||
Variable_name Value
|
||||
|
|
|
@ -5031,3 +5031,40 @@ SELECT * FROM t1 WHERE a = b;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# lp:822760 Wrong result with view + invalid dates
|
||||
#
|
||||
CREATE TABLE t1 (f1 date);
|
||||
INSERT IGNORE INTO t1 VALUES ('0000-00-00');
|
||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t1 HAVING f1 = 'zz';
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM t1 HAVING f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
f1
|
||||
0000-00-00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: 'zz'
|
||||
Warning 1292 Incorrect datetime value: 'aa'
|
||||
DROP TABLE t1;
|
||||
DROP VIEW v1;
|
||||
|
|
|
@ -4229,3 +4229,16 @@ SELECT * FROM t1 WHERE a = b;
|
|||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # lp:822760 Wrong result with view + invalid dates
|
||||
--echo #
|
||||
CREATE TABLE t1 (f1 date);
|
||||
INSERT IGNORE INTO t1 VALUES ('0000-00-00');
|
||||
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT * FROM t1 HAVING f1 = 'zz';
|
||||
SELECT * FROM t1 HAVING f1 <= 'aa' ;
|
||||
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
|
||||
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
|
||||
DROP TABLE t1;
|
||||
DROP VIEW v1;
|
||||
|
|
|
@ -11627,7 +11627,7 @@ propagate_cond_constants(THD *thd, I_List<COND_CMP> *save_list,
|
|||
bool left_const= args[0]->const_item() && !args[0]->is_expensive();
|
||||
bool right_const= args[1]->const_item() && !args[1]->is_expensive();
|
||||
if (!(left_const && right_const) &&
|
||||
args[0]->result_type() == args[1]->result_type())
|
||||
args[0]->cmp_type() == args[1]->cmp_type())
|
||||
{
|
||||
if (right_const)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue