mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03: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:
@@ -5031,3 +5031,40 @@ SELECT * FROM t1 WHERE a = b;
|
|||||||
id select_type table type possible_keys key key_len ref rows Extra
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||||
DROP TABLE t1;
|
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
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||||
DROP TABLE t1;
|
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;
|
set join_cache_level=default;
|
||||||
show variables like 'join_cache_level';
|
show variables like 'join_cache_level';
|
||||||
Variable_name Value
|
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
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
1 SIMPLE t1 system NULL NULL NULL NULL 1
|
||||||
DROP TABLE t1;
|
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;
|
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 left_const= args[0]->const_item() && !args[0]->is_expensive();
|
||||||
bool right_const= args[1]->const_item() && !args[1]->is_expensive();
|
bool right_const= args[1]->const_item() && !args[1]->is_expensive();
|
||||||
if (!(left_const && right_const) &&
|
if (!(left_const && right_const) &&
|
||||||
args[0]->result_type() == args[1]->result_type())
|
args[0]->cmp_type() == args[1]->cmp_type())
|
||||||
{
|
{
|
||||||
if (right_const)
|
if (right_const)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user