mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
bug #504: in "datetime op int" comparison int wasn't converted to datetime
This commit is contained in:
@ -52,10 +52,17 @@ a
|
|||||||
0000-00-00 00:00:00
|
0000-00-00 00:00:00
|
||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1 (id int, dt datetime);
|
create table t1 (id int, dt datetime);
|
||||||
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00");
|
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30");
|
||||||
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
|
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
|
||||||
id dt
|
id dt
|
||||||
1 2001-08-14 00:00:00
|
1 2001-08-14 00:00:00
|
||||||
|
create index dt on t1 (dt);
|
||||||
|
select * from t1 where dt > 20021020;
|
||||||
|
id dt
|
||||||
|
4 2003-09-15 01:20:30
|
||||||
|
select * from t1 ignore index (dt) where dt > 20021020;
|
||||||
|
id dt
|
||||||
|
4 2003-09-15 01:20:30
|
||||||
drop table t1;
|
drop table t1;
|
||||||
CREATE TABLE `t1` (
|
CREATE TABLE `t1` (
|
||||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
@ -36,8 +36,11 @@ drop table t1;
|
|||||||
#
|
#
|
||||||
|
|
||||||
create table t1 (id int, dt datetime);
|
create table t1 (id int, dt datetime);
|
||||||
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00");
|
insert into t1 values (1,"2001-08-14 00:00:00"),(2,"2001-08-15 00:00:00"),(3,"2001-08-16 00:00:00"),(4,"2003-09-15 01:20:30");
|
||||||
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
|
select * from t1 where dt='2001-08-14 00:00:00' and dt = if(id=1,'2001-08-14 00:00:00','1999-08-15');
|
||||||
|
create index dt on t1 (dt);
|
||||||
|
select * from t1 where dt > 20021020;
|
||||||
|
select * from t1 ignore index (dt) where dt > 20021020;
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -46,7 +46,7 @@ longlong Item_func_not::val_int()
|
|||||||
|
|
||||||
static bool convert_constant_item(Field *field, Item **item)
|
static bool convert_constant_item(Field *field, Item **item)
|
||||||
{
|
{
|
||||||
if ((*item)->const_item() && (*item)->type() != Item::INT_ITEM)
|
if ((*item)->const_item())
|
||||||
{
|
{
|
||||||
if (!(*item)->save_in_field(field, 1) &&
|
if (!(*item)->save_in_field(field, 1) &&
|
||||||
!((*item)->null_value))
|
!((*item)->null_value))
|
||||||
|
Reference in New Issue
Block a user