diff options
author | unknown <bell@sanja.is.com.ua> | 2002-11-24 17:41:34 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2002-11-24 17:41:34 +0200 |
commit | 83e25bbc3090982c31a064b1b2cd78b710c37207 (patch) | |
tree | 80c31753814c2a84f21ef0eda97bf9e563dac4a5 /mysql-test/r | |
parent | 4587dddab92fc96764f190b8dc1d74461846f47d (diff) | |
download | mariadb-git-83e25bbc3090982c31a064b1b2cd78b710c37207.tar.gz |
fixed removed by previos patch thd->allow_sum_func "side effect" of setup_conds
renamed tables to prevent droping real tables
mysql-test/r/group_by.result:
test of error message
mysql-test/r/subselect.result:
renamed tables to prevent droping real tables
mysql-test/t/group_by.test:
test of error message
mysql-test/t/subselect.test:
renamed tables to prevent droping real tables
sql/sql_base.cc:
moved thd->allow_sum_func assignment to upper level
sql/sql_select.cc:
fixed removed by previos patch thd->allow_sum_func "side effect" of setup_conds
Diffstat (limited to 'mysql-test/r')
-rw-r--r-- | mysql-test/r/group_by.result | 2 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 134 |
2 files changed, 67 insertions, 69 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 86a8eb2dd22..ead9935f824 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1,3 +1,5 @@ +SELECT 1 FROM (SELECT 1) GROUP BY SUM(1); +Invalid use of group function drop table if exists t1,t2,t3; CREATE TABLE t1 ( spID int(10) unsigned, diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 154f8ac9667..848a90fba8f 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -17,7 +17,7 @@ SELECT (SELECT 1),MAX(1) FROM (SELECT 1); 1 1 SELECT (SELECT a) as a; Reference 'a' not supported (forward reference in item list) -drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; create table t1 (a int); create table t2 (a int, b int); create table t3 (a int); @@ -140,11 +140,11 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; Subselect returns more than 1 record -create table attend (patient_uq int, clinic_uq int, index i1 (clinic_uq)); -create table clinic( uq int primary key, name char(25)); -insert into clinic values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta"); -insert into attend values (1,1),(1,2),(2,2),(1,3); -select * from attend where exists (select * from clinic where uq = clinic_uq); +create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); +create table t7( uq int primary key, name char(25)); +insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta"); +insert into t6 values (1,1),(1,2),(2,2),(1,3); +select * from t6 where exists (select * from t7 where uq = clinic_uq); patient_uq clinic_uq 1 1 1 2 @@ -167,117 +167,113 @@ W 1 SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3); a b W a -drop table if exists inscrit; -CREATE TABLE `inscrit` ( +drop table if exists t8; +CREATE TABLE `t8` ( `pseudo` varchar(35) character set latin1 NOT NULL default '', `email` varchar(60) character set latin1 NOT NULL default '', PRIMARY KEY (`pseudo`), UNIQUE KEY `email` (`email`) ) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC; -INSERT INTO inscrit (pseudo,email) VALUES ('joce','test'); -INSERT INTO inscrit (pseudo,email) VALUES ('joce1','test1'); -INSERT INTO inscrit (pseudo,email) VALUES ('2joce1','2test1'); -EXPLAIN SELECT pseudo,(SELECT email FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce')) FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce'); +INSERT INTO t8 (pseudo,email) VALUES ('joce','test'); +INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); +INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); +EXPLAIN SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY inscrit const PRIMARY PRIMARY 35 const 1 -4 SUBSELECT inscrit const PRIMARY PRIMARY 35 const 1 -2 SUBSELECT inscrit const PRIMARY PRIMARY 35 const 1 -3 SUBSELECT inscrit const PRIMARY PRIMARY 35 const 1 -SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo,email FROM -inscrit WHERE pseudo='joce'); +1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1 +4 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1 +2 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1 +3 SUBSELECT t8 const PRIMARY PRIMARY 35 const 1 +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM +t8 WHERE pseudo='joce'); Subselect returns more than 1 field -SELECT pseudo FROM inscrit WHERE pseudo=(SELECT * FROM inscrit WHERE +SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE pseudo='joce'); Subselect returns more than 1 field -SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo='joce'); +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); pseudo joce -SELECT pseudo FROM inscrit WHERE pseudo=(SELECT pseudo FROM inscrit WHERE pseudo LIKE '%joce%'); +SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%'); Subselect returns more than 1 record -drop table if exists t1,t2,t3,t4,t5,attend,clinic,inscrit; -drop table if exists searchconthardwarefr3; -CREATE TABLE `searchconthardwarefr3` ( +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; +CREATE TABLE `t1` ( `topic` mediumint(8) unsigned NOT NULL default '0', `date` date NOT NULL default '0000-00-00', `pseudo` varchar(35) character set latin1 NOT NULL default '', PRIMARY KEY (`pseudo`,`date`,`topic`), KEY `topic` (`topic`) ) TYPE=MyISAM ROW_FORMAT=DYNAMIC; -INSERT INTO searchconthardwarefr3 (topic,date,pseudo) VALUES +INSERT INTO t1 (topic,date,pseudo) VALUES ('43506','2002-10-02','joce'),('40143','2002-08-03','joce'); -EXPLAIN SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03'; +EXPLAIN SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE searchconthardwarefr3 index NULL PRIMARY 41 NULL 2 Using where; Using index -EXPLAIN SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03'); +1 SIMPLE t1 index NULL PRIMARY 41 NULL 2 Using where; Using index +EXPLAIN SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY No tables used -2 SUBSELECT searchconthardwarefr3 index NULL PRIMARY 41 NULL 2 Using where; Using index -SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03'; +2 SUBSELECT t1 index NULL PRIMARY 41 NULL 2 Using where; Using index +SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; date 2002-08-03 -SELECT (SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03'); -(SELECT DISTINCT date FROM searchconthardwarefr3 WHERE date='2002-08-03') +SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); +(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03') 2002-08-03 -SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1; +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1; 1 1 1 1 -SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; +SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; Subselect returns more than 1 record -EXPLAIN SELECT 1 FROM searchconthardwarefr3 WHERE 1=(SELECT 1 UNION SELECT 1); +EXPLAIN SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY searchconthardwarefr3 index NULL topic 3 NULL 2 Using index +1 PRIMARY t1 index NULL topic 3 NULL 2 Using index 2 SUBSELECT No tables used 3 UNION No tables used -drop table searchconthardwarefr3; -drop table if exists forumconthardwarefr7, searchconthardwarefr7; -CREATE TABLE `forumconthardwarefr7` ( +drop table t1; +CREATE TABLE `t1` ( `numeropost` mediumint(8) unsigned NOT NULL auto_increment, `maxnumrep` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`numeropost`), UNIQUE KEY `maxnumrep` (`maxnumrep`) ) TYPE=MyISAM ROW_FORMAT=FIXED; -INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); -CREATE TABLE `searchconthardwarefr7` ( +INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2); +CREATE TABLE `t2` ( `mot` varchar(30) NOT NULL default '', `topic` mediumint(8) unsigned NOT NULL default '0', `date` date NOT NULL default '0000-00-00', `pseudo` varchar(35) NOT NULL default '', PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`) ) TYPE=MyISAM ROW_FORMAT=DYNAMIC; -INSERT INTO searchconthardwarefr7 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); -select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); +INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce'); +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); a 40143 -SELECT numeropost,maxnumrep FROM forumconthardwarefr7 WHERE exists (SELECT 1 FROM searchconthardwarefr7 WHERE (mot='joce') AND date >= '2002-10-21' AND forumconthardwarefr7.numeropost = searchconthardwarefr7.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; +SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20; numeropost maxnumrep 43506 2 40143 1 -SELECT (SELECT 1) as a FROM (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); +SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); Unknown column 'a' in 'having clause' -drop table forumconthardwarefr7, searchconthardwarefr7; -drop table if exists forumconthardwarefr7; -CREATE TABLE `forumconthardwarefr7` ( +drop table t1, t2; +drop table if exists t1; +CREATE TABLE `t1` ( `numeropost` mediumint(8) unsigned NOT NULL auto_increment, `maxnumrep` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`numeropost`), UNIQUE KEY `maxnumrep` (`maxnumrep`) ) TYPE=MyISAM ROW_FORMAT=FIXED; -INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1); -select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); +INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1); +select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); Subselect returns more than 1 record -select numeropost as a FROM forumconthardwarefr7 ORDER BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); +select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1); Subselect returns more than 1 record -drop table if exists forumconthardwarefr7; -drop table if exists iftest; -CREATE TABLE iftest (field char(1) NOT NULL DEFAULT 'b'); -INSERT INTO iftest VALUES (); -SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b'); +drop table t1; +CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); +INSERT INTO t1 VALUES (); +SELECT field FROM t1 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` ( +drop table t1; +CREATE TABLE `t1` ( `numeropost` mediumint(8) unsigned NOT NULL default '0', `numreponse` int(10) unsigned NOT NULL auto_increment, `pseudo` varchar(35) NOT NULL default '', @@ -285,20 +281,20 @@ PRIMARY KEY (`numeropost`,`numreponse`), UNIQUE KEY `numreponse` (`numreponse`), KEY `pseudo` (`pseudo`,`numeropost`) ) TYPE=MyISAM; -SELECT (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a),numreponse FROM (SELECT * FROM threadhardwarefr7) as a; +SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a; Reference 'numreponse' not supported (forward reference in item list) -SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=a) FROM (SELECT * FROM threadhardwarefr7) as a; +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; Unknown column 'a' in 'having clause' -SELECT numreponse, (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=1) FROM (SELECT * FROM threadhardwarefr7) as a; -numreponse (SELECT numeropost FROM threadhardwarefr7 HAVING numreponse=1) -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'); +SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; +numreponse (SELECT numeropost FROM t1 HAVING numreponse=1) +INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); Subselect returns more than 1 record -EXPLAIN SELECT MAX(numreponse) FROM threadhardwarefr7 WHERE numeropost='1'; +EXPLAIN SELECT MAX(numreponse) FROM t1 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'); +EXPLAIN SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 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 +1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1 2 SUBSELECT Select tables optimized away -drop table if exists threadhardwarefrtest7; +drop table t1; |