From 16a810f0cb84c78ff365a0742729da6ea5fcff35 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 14:58:36 +0200 Subject: [PATCH] fixed parsing mode for derived tables (BUG#2421) mysql-test/r/derived.result: test of BUG#2421 mysql-test/t/derived.test: test of BUG#2421 sql/sql_yacc.yy: fixed parsing mode for derived tables --- mysql-test/r/derived.result | 6 ++++++ mysql-test/t/derived.test | 8 ++++++++ sql/sql_yacc.yy | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 170c393524b..481a2a5cd72 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -298,3 +298,9 @@ INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00 select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; 497 ID NULL drop table t1, t2, t3; +CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); +insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10); +SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; +min max avg +10.00 10.00 10 +DROP TABLE t1; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 154fc4b3834..95ad9daf91e 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -183,3 +183,11 @@ CREATE TABLE t3 ( INSERT INTO t3 VALUES (1000,0.00),(1001,0.25),(1002,0.50),(1003,0.75),(1008,1.00),(1009,1.25),(1010,1.50),(1011,1.75); select 497, TMP.ID, NULL from (select 497 as ID, MAX(t3.DATA) as DATA from t1 join t2 on (t1.ObjectID = t2.ID) join t3 on (t1.ObjectID = t3.ID) group by t2.ParID order by DATA DESC) as TMP; drop table t1, t2, t3; + +# +# select list counter +# +CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); +insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10); +SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; +DROP TABLE t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f04cc9ec1dc..682ca64f09b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3253,8 +3253,13 @@ select_derived: YYABORT; mysql_init_select(lex); lex->current_select->linkage= DERIVED_TABLE_TYPE; + lex->current_select->parsing_place= SELECT_LEX_NODE::SELECT_LIST; } - select_options select_item_list opt_select_from union_opt + select_options select_item_list + { + Select->parsing_place= SELECT_LEX_NODE::NO_MATTER; + } + opt_select_from union_opt ; opt_outer: