Commit ae6cc963 authored by unknown's avatar unknown

Manual merge

parent 967242f4
......@@ -2992,6 +2992,93 @@ eval CREATE VIEW v1 AS $query;
--echo # Previously the following would fail.
eval $query;
#
# Bug#24532: The return data type of IS TRUE is different from similar
# operations
#
--disable_warnings
drop view if exists view_24532_a;
drop view if exists view_24532_b;
drop table if exists table_24532;
--enable_warnings
create table table_24532 (
a int,
b bigint,
c int(4),
d bigint(48)
);
create view view_24532_a as
select
a IS TRUE,
a IS NOT TRUE,
a IS FALSE,
a IS NOT FALSE,
a IS UNKNOWN,
a IS NOT UNKNOWN,
a is NULL,
a IS NOT NULL,
ISNULL(a),
b IS TRUE,
b IS NOT TRUE,
b IS FALSE,
b IS NOT FALSE,
b IS UNKNOWN,
b IS NOT UNKNOWN,
b is NULL,
b IS NOT NULL,
ISNULL(b),
c IS TRUE,
c IS NOT TRUE,
c IS FALSE,
c IS NOT FALSE,
c IS UNKNOWN,
c IS NOT UNKNOWN,
c is NULL,
c IS NOT NULL,
ISNULL(c),
d IS TRUE,
d IS NOT TRUE,
d IS FALSE,
d IS NOT FALSE,
d IS UNKNOWN,
d IS NOT UNKNOWN,
d is NULL,
d IS NOT NULL,
ISNULL(d)
from table_24532;
describe view_24532_a;
create view view_24532_b as
select
a IS TRUE,
if(ifnull(a, 0), 1, 0) as old_istrue,
a IS NOT TRUE,
if(ifnull(a, 0), 0, 1) as old_isnottrue,
a IS FALSE,
if(ifnull(a, 1), 0, 1) as old_isfalse,
a IS NOT FALSE,
if(ifnull(a, 1), 1, 0) as old_isnotfalse
from table_24532;
describe view_24532_b;
show create view view_24532_b;
insert into table_24532 values (0, 0, 0, 0);
select * from view_24532_b;
update table_24532 set a=1;
select * from view_24532_b;
update table_24532 set a=NULL;
select * from view_24532_b;
drop view view_24532_a;
drop view view_24532_b;
drop table table_24532;
--echo End of 5.0 tests.
......
......@@ -76,19 +76,6 @@ const LEX_STRING null_lex_str={0,0};
#define __attribute__(X)
#endif
/* Helper for parsing "IS [NOT] truth_value" */
inline Item *is_truth_value(THD *thd, Item *A, bool v1, bool v2)
{
Item *v1_t= new (thd->mem_root) Item_int((char *) (v1 ? "TRUE" : "FALSE"),
v1, 1);
Item *v1_f= new (thd->mem_root) Item_int((char *) (v1 ? "FALSE" : "TRUE"),
!v1, 1);
Item *v2_t= new (thd->mem_root) Item_int((char *) (v2 ? "TRUE" : "FALSE"),
v2, 1);
Item *ifnull= new (thd->mem_root) Item_func_ifnull(A, v2_t);
return new (thd->mem_root) Item_func_if(ifnull, v1_t, v1_f);
}
#ifndef DBUG_OFF
#define YYDEBUG 1
......@@ -6225,13 +6212,18 @@ bool_factor:
| bool_test ;
bool_test:
bool_pri IS TRUE_SYM { $$= is_truth_value(YYTHD, $1,1,0); }
| bool_pri IS not TRUE_SYM { $$= is_truth_value(YYTHD, $1,0,0); }
| bool_pri IS FALSE_SYM { $$= is_truth_value(YYTHD, $1,0,1); }
| bool_pri IS not FALSE_SYM { $$= is_truth_value(YYTHD, $1,1,1); }
| bool_pri IS UNKNOWN_SYM { $$= new Item_func_isnull($1); }
| bool_pri IS not UNKNOWN_SYM { $$= new Item_func_isnotnull($1); }
| bool_pri ;
bool_pri IS TRUE_SYM
{ $$= new (YYTHD->mem_root) Item_func_istrue($1); }
| bool_pri IS not TRUE_SYM
{ $$= new (YYTHD->mem_root) Item_func_isnottrue($1); }
| bool_pri IS FALSE_SYM
{ $$= new (YYTHD->mem_root) Item_func_isfalse($1); }
| bool_pri IS not FALSE_SYM
{ $$= new (YYTHD->mem_root) Item_func_isnotfalse($1); }
| bool_pri IS UNKNOWN_SYM { $$= new Item_func_isnull($1); }
| bool_pri IS not UNKNOWN_SYM { $$= new Item_func_isnotnull($1); }
| bool_pri
;
bool_pri:
bool_pri IS NULL_SYM { $$= new Item_func_isnull($1); }
......
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