mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge sanja.is.com.ua:/home/bell/mysql/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/work-row-4.1 mysql-test/r/subselect.result: Auto merged sql/sql_base.cc: Auto merged sql/sql_select.cc: Auto merged
This commit is contained in:
@ -158,3 +158,6 @@ select * from t1;
|
||||
if('2002'='2002','Y','N')
|
||||
Y
|
||||
drop table if exists t1;
|
||||
create table t1 (a int, key(a));
|
||||
create table t2 (b int, foreign key(b) references t1(a), key(b));
|
||||
drop table if exists t1,t2;
|
||||
|
@ -40,3 +40,28 @@ a
|
||||
select 1 from (select 1);
|
||||
1
|
||||
1
|
||||
drop table if exists t1;
|
||||
create table t1(a int not null, t char(8), index(a));
|
||||
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
|
||||
a t
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
5 5
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
10 10
|
||||
11 11
|
||||
12 12
|
||||
13 13
|
||||
14 14
|
||||
15 15
|
||||
16 16
|
||||
17 17
|
||||
18 18
|
||||
19 19
|
||||
20 20
|
||||
drop table if exists t1;
|
||||
|
@ -168,4 +168,19 @@ test2 2 2
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
2
|
||||
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
|
||||
1
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
1
|
||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
|
||||
titre numeropost maxnumrep
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
2
|
||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
|
||||
titre numeropost maxnumrep
|
||||
SELECT FOUND_ROWS();
|
||||
FOUND_ROWS()
|
||||
3
|
||||
drop table t1;
|
||||
|
@ -269,3 +269,23 @@ INSERT INTO iftest VALUES ();
|
||||
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
|
||||
Subselect returns more than 1 record
|
||||
drop table iftest;
|
||||
drop table if exists threadhardwarefr7;
|
||||
CREATE TABLE `threadhardwarefr7` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL default '0',
|
||||
`numreponse` int(10) unsigned NOT NULL auto_increment,
|
||||
`pseudo` varchar(35) NOT NULL default '',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
UNIQUE KEY `numreponse` (`numreponse`),
|
||||
KEY `pseudo` (`pseudo`,`numeropost`)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
Subselect returns more than 1 record
|
||||
EXPLAIN SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE Select tables optimized away
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY threadhardwarefr7 const PRIMARY,numreponse PRIMARY 7 const,const 1
|
||||
2 SUBSELECT Select tables optimized away
|
||||
drop table if exists threadhardwarefrtest7;
|
||||
|
@ -110,3 +110,6 @@ drop table t1;
|
||||
create table t1 select if('2002'='2002','Y','N');
|
||||
select * from t1;
|
||||
drop table if exists t1;
|
||||
create table t1 (a int, key(a));
|
||||
create table t2 (b int, foreign key(b) references t1(a), key(b));
|
||||
drop table if exists t1,t2;
|
||||
|
@ -22,3 +22,15 @@ drop table if exists t1.t2,t3;
|
||||
select * from (select 1);
|
||||
select a from (select 1 as a);
|
||||
select 1 from (select 1);
|
||||
drop table if exists t1;
|
||||
create table t1(a int not null, t char(8), index(a));
|
||||
disable_query_log;
|
||||
let $1 = 10000;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 values ($1,'$1');
|
||||
dec $1;
|
||||
}
|
||||
enable_query_log;
|
||||
SELECT * FROM (SELECT * FROM t1) ORDER BY a ASC LIMIT 0,20;
|
||||
drop table if exists t1;
|
@ -84,4 +84,10 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
|
||||
('test1','1'),('test2','2'),('test3','3');
|
||||
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) LIMIT 0;
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
|
||||
SELECT FOUND_ROWS();
|
||||
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
|
||||
SELECT FOUND_ROWS();
|
||||
drop table t1;
|
||||
|
@ -166,3 +166,19 @@ INSERT INTO iftest VALUES ();
|
||||
-- error 1240
|
||||
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
|
||||
drop table iftest;
|
||||
|
||||
drop table if exists threadhardwarefr7;
|
||||
CREATE TABLE `threadhardwarefr7` (
|
||||
`numeropost` mediumint(8) unsigned NOT NULL default '0',
|
||||
`numreponse` int(10) unsigned NOT NULL auto_increment,
|
||||
`pseudo` varchar(35) NOT NULL default '',
|
||||
PRIMARY KEY (`numeropost`,`numreponse`),
|
||||
UNIQUE KEY `numreponse` (`numreponse`),
|
||||
KEY `pseudo` (`pseudo`,`numeropost`)
|
||||
) TYPE=MyISAM;
|
||||
INSERT INTO threadhardwarefr7 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
|
||||
-- error 1240
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
EXPLAIN SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1';
|
||||
EXPLAIN SELECT numreponse FROM threadhardwarefr7 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1');
|
||||
drop table if exists threadhardwarefrtest7;
|
||||
|
Reference in New Issue
Block a user