Commit cfb8abd6 authored by unknown's avatar unknown

Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0

into rurik.mysql.com:/home/igor/mysql-5.0

parents 9de04d2e a217d5c5
......@@ -942,7 +942,7 @@ ROW(1, 1, 'a') IN (select a,b,c from t1)
1
select ROW(1, 2, 'a') IN (select a,b,c from t1);
ROW(1, 2, 'a') IN (select a,b,c from t1)
NULL
0
select ROW(1, 1, 'a') IN (select b,a,c from t1);
ROW(1, 1, 'a') IN (select b,a,c from t1)
1
......@@ -960,7 +960,7 @@ ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a')
1
select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a')
NULL
0
select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a')
1
......@@ -2709,7 +2709,51 @@ select (1,2,3) = (select * from t1);
ERROR 21000: Operand should contain 3 column(s)
select (select * from t1) = (1,2,3);
ERROR 21000: Operand should contain 2 column(s)
drop table t1
#;
CREATE TABLE `t1` (
`itemid` bigint(20) unsigned NOT NULL auto_increment,
`sessionid` bigint(20) unsigned default NULL,
`time` int(10) unsigned NOT NULL default '0',
`type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
NULL default '',
`data` text collate latin1_general_ci NOT NULL,
PRIMARY KEY (`itemid`)
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
CREATE TABLE `t2` (
`sessionid` bigint(20) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`date` int(10) unsigned NOT NULL default '0',
`ip` varchar(15) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`sessionid`)
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
ip count( e.itemid )
10.10.10.1 1
drop tables t1,t2;
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
max(fld)
1
drop table t1;
CREATE TABLE t1 (one int, two int, flag char(1));
CREATE TABLE t2 (one int, two int, flag char(1));
INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N');
one two flag
5 6 N
7 8 N
SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
one two flag
5 6 N
7 8 N
DROP TABLE t1,t2;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
......
......@@ -1726,8 +1726,57 @@ select (select a from t1) = (1,2);
select (1,2,3) = (select * from t1);
-- error 1241
select (select * from t1) = (1,2,3);
drop table t1
#
# Item_int_with_ref check (BUG#10020)
#
CREATE TABLE `t1` (
`itemid` bigint(20) unsigned NOT NULL auto_increment,
`sessionid` bigint(20) unsigned default NULL,
`time` int(10) unsigned NOT NULL default '0',
`type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT
NULL default '',
`data` text collate latin1_general_ci NOT NULL,
PRIMARY KEY (`itemid`)
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `t1` VALUES (1, 1, 1, 'D', '');
CREATE TABLE `t2` (
`sessionid` bigint(20) unsigned NOT NULL auto_increment,
`pid` int(10) unsigned NOT NULL default '0',
`date` int(10) unsigned NOT NULL default '0',
`ip` varchar(15) collate latin1_general_ci NOT NULL default '',
PRIMARY KEY (`sessionid`)
) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
drop tables t1,t2;
# BUG#11821 : Select from subselect using aggregate function on an enum
# segfaults:
create table t1 (fld enum('0','1'));
insert into t1 values ('1');
select * from (select max(fld) from t1) as foo;
drop table t1;
#
# Bug #11867: queries with ROW(,elems>) IN (SELECT DISTINCT <cols> FROM ...)
#
CREATE TABLE t1 (one int, two int, flag char(1));
CREATE TABLE t2 (one int, two int, flag char(1));
INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N');
SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N');
SELECT * FROM t1
WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N');
DROP TABLE t1,t2;
# End of 4.1 tests
#
#decimal-related tests
#
......@@ -1868,4 +1917,3 @@ select * from (select max(fld) from t1) as foo;
drop table t1;
# End of 4.1 tests
......@@ -1070,15 +1070,20 @@ Item_in_subselect::row_value_transformer(JOIN *join)
List_iterator_fast<Item> li(select_lex->item_list);
for (uint i= 0; i < n; i++)
{
Item *func;
DBUG_ASSERT(left_expr->fixed && select_lex->ref_pointer_array[i]->fixed);
if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->el(i)->cols()))
DBUG_RETURN(RES_ERROR);
Item *func= new Item_ref_null_helper(&select_lex->context,
this,
select_lex->ref_pointer_array+i,
(char *) "<no matter>",
(char *) "<list ref>");
if (join->having || select_lex->with_sum_func ||
select_lex->group_list.elements)
func= new Item_ref_null_helper(&select_lex->context,
this,
select_lex->ref_pointer_array+i,
(char *) "<no matter>",
(char *) "<list ref>");
else
func= li++;
func=
eq_creator.create(new Item_direct_ref(&select_lex->context,
(*optimizer->get_cache())->
......
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