mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 18:20:07 +01:00
Fixed bug #26124: SELECT from a view wrapper over a table
with a column of the DATETIME type could return a wrong result set if the WHERE clause included a BETWEEN condition on the column. Fixed the method Item_func_between::fix_length_and_dec where the aggregation type for BETWEEN predicates calculated incorrectly if the first argument was a view column of the DATETIME type.
This commit is contained in:
parent
968369906e
commit
5ed805bfd6
3 changed files with 36 additions and 2 deletions
|
@ -3034,4 +3034,22 @@ SHOW CREATE VIEW v1;
|
|||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
|
||||
DROP VIEW v1;
|
||||
CREATE TABLE t1 (mydate DATETIME);
|
||||
INSERT INTO t1 VALUES
|
||||
('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31');
|
||||
CREATE VIEW v1 AS SELECT mydate from t1;
|
||||
SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
|
||||
mydate
|
||||
2007-01-01 00:00:00
|
||||
2007-01-02 00:00:00
|
||||
2007-01-30 00:00:00
|
||||
2007-01-31 00:00:00
|
||||
SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
|
||||
mydate
|
||||
2007-01-01 00:00:00
|
||||
2007-01-02 00:00:00
|
||||
2007-01-30 00:00:00
|
||||
2007-01-31 00:00:00
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests.
|
||||
|
|
|
@ -2986,4 +2986,20 @@ SHOW CREATE VIEW v1;
|
|||
|
||||
DROP VIEW v1;
|
||||
|
||||
#
|
||||
# Bug #26124: BETWEEN over a view column of the DATETIME type
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (mydate DATETIME);
|
||||
INSERT INTO t1 VALUES
|
||||
('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31');
|
||||
|
||||
CREATE VIEW v1 AS SELECT mydate from t1;
|
||||
|
||||
SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
|
||||
SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
|
|
@ -1185,11 +1185,11 @@ void Item_func_between::fix_length_and_dec()
|
|||
They are compared as integers, so for const item this time-consuming
|
||||
conversion can be done only once, not for every single comparison
|
||||
*/
|
||||
if (args[0]->type() == FIELD_ITEM &&
|
||||
if (args[0]->real_item()->type() == FIELD_ITEM &&
|
||||
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
|
||||
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
Field *field=((Item_field*) args[0])->field;
|
||||
Field *field=((Item_field*) (args[0]->real_item()))->field;
|
||||
if (field->can_be_compared_as_longlong())
|
||||
{
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue