mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
func_in.result, func_in.test:
Fixed bug #11885. sql_select.cc: Fixed bug #11885. Predicates of the forms 'a IN (v)' 'a NOT IN (v)' now is replaced by 'a=v' and 'a<>v' at the parsing stage. sql_yacc.yy: Fixed bug #11885. Predicates of the forms 'a IN (v)' 'a NOT IN (v)' now is replaced by 'a=v' and 'a<>v' at the parsing stage. sql/sql_yacc.yy: Fixed bug #11885. Predicates of the forms 'a IN (v)' 'a NOT IN (v) now is replaced by 'a=v' and 'a<>v' at the parsing stage. sql/sql_select.cc: Fixed bug #11885. Predicates of the forms 'a IN (v)' 'a NOT IN (v) now is replaced by 'a=v' and 'a<>v' at the parsing stage. mysql-test/t/func_in.test: Fixed bug #11885. mysql-test/r/func_in.result: Fixed bug #11885.
This commit is contained in:
@ -119,7 +119,7 @@ c char(1) character set latin1 collate latin1_danish_ci
|
|||||||
insert into t1 values ('A','B','C');
|
insert into t1 values ('A','B','C');
|
||||||
insert into t1 values ('a','c','c');
|
insert into t1 values ('a','c','c');
|
||||||
select * from t1 where a in (b);
|
select * from t1 where a in (b);
|
||||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation ' IN '
|
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
|
||||||
select * from t1 where a in (b,c);
|
select * from t1 where a in (b,c);
|
||||||
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
|
||||||
select * from t1 where 'a' in (a,b,c);
|
select * from t1 where 'a' in (a,b,c);
|
||||||
@ -193,3 +193,26 @@ select * from t1 where a in (NULL, 'aa');
|
|||||||
a
|
a
|
||||||
aa
|
aa
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||||
|
INSERT INTO t1 VALUES (44), (45), (46);
|
||||||
|
SELECT * FROM t1 WHERE a IN (45);
|
||||||
|
a
|
||||||
|
45
|
||||||
|
SELECT * FROM t1 WHERE a NOT IN (0, 45);
|
||||||
|
a
|
||||||
|
44
|
||||||
|
46
|
||||||
|
SELECT * FROM t1 WHERE a NOT IN (45);
|
||||||
|
a
|
||||||
|
44
|
||||||
|
46
|
||||||
|
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);
|
||||||
|
SHOW CREATE VIEW v1;
|
||||||
|
View Create View
|
||||||
|
v1 CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where (`test`.`t1`.`a` <> 45)
|
||||||
|
SELECT * FROM v1;
|
||||||
|
a
|
||||||
|
44
|
||||||
|
46
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -101,3 +101,21 @@ create table t1 (a char(20) character set binary);
|
|||||||
insert into t1 values ('aa'), ('bb');
|
insert into t1 values ('aa'), ('bb');
|
||||||
select * from t1 where a in (NULL, 'aa');
|
select * from t1 where a in (NULL, 'aa');
|
||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #11885: WHERE condition with NOT IN (one element)
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a int PRIMARY KEY);
|
||||||
|
INSERT INTO t1 VALUES (44), (45), (46);
|
||||||
|
|
||||||
|
SELECT * FROM t1 WHERE a IN (45);
|
||||||
|
SELECT * FROM t1 WHERE a NOT IN (0, 45);
|
||||||
|
SELECT * FROM t1 WHERE a NOT IN (45);
|
||||||
|
|
||||||
|
CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45);
|
||||||
|
SHOW CREATE VIEW v1;
|
||||||
|
SELECT * FROM v1;
|
||||||
|
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@ -2834,11 +2834,11 @@ add_key_fields(KEY_FIELD **key_fields,uint *and_level,
|
|||||||
cond_func->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
|
cond_func->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
|
||||||
!(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT))
|
!(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT))
|
||||||
values--;
|
values--;
|
||||||
|
DBUG_ASSERT(cond_func->functype() != Item_func::IN_FUNC ||
|
||||||
|
cond_func->argument_count() != 2);
|
||||||
add_key_equal_fields(key_fields, *and_level, cond_func,
|
add_key_equal_fields(key_fields, *and_level, cond_func,
|
||||||
(Item_field*) (cond_func->key_item()->real_item()),
|
(Item_field*) (cond_func->key_item()->real_item()),
|
||||||
cond_func->argument_count() == 2 &&
|
0, values,
|
||||||
cond_func->functype() == Item_func::IN_FUNC,
|
|
||||||
values,
|
|
||||||
cond_func->argument_count()-1,
|
cond_func->argument_count()-1,
|
||||||
usable_tables);
|
usable_tables);
|
||||||
}
|
}
|
||||||
|
@ -4227,9 +4227,25 @@ bool_pri:
|
|||||||
|
|
||||||
predicate:
|
predicate:
|
||||||
bit_expr IN_SYM '(' expr_list ')'
|
bit_expr IN_SYM '(' expr_list ')'
|
||||||
{ $4->push_front($1); $$= new Item_func_in(*$4); }
|
{
|
||||||
|
if ($4->elements == 1)
|
||||||
|
$$= new Item_func_eq($1, $4->head());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$4->push_front($1);
|
||||||
|
$$= new Item_func_in(*$4);
|
||||||
|
}
|
||||||
|
}
|
||||||
| bit_expr not IN_SYM '(' expr_list ')'
|
| bit_expr not IN_SYM '(' expr_list ')'
|
||||||
{ $5->push_front($1); $$= negate_expression(YYTHD, new Item_func_in(*$5)); }
|
{
|
||||||
|
if ($5->elements == 1)
|
||||||
|
$$= new Item_func_ne($1, $5->head());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$5->push_front($1);
|
||||||
|
$$= negate_expression(YYTHD, new Item_func_in(*$5));
|
||||||
|
}
|
||||||
|
}
|
||||||
| bit_expr IN_SYM in_subselect
|
| bit_expr IN_SYM in_subselect
|
||||||
{ $$= new Item_in_subselect($1, $3); }
|
{ $$= new Item_in_subselect($1, $3); }
|
||||||
| bit_expr not IN_SYM in_subselect
|
| bit_expr not IN_SYM in_subselect
|
||||||
|
Reference in New Issue
Block a user