summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-12-06 00:40:28 +0200
committerunknown <bell@sanja.is.com.ua>2002-12-06 00:40:28 +0200
commitf67abe26fbadc52a14621a627c999e563b38bc8f (patch)
treebbdab3cd51ac1e8b7d77d92c2541b96f9447eeb4
parentef4f5b2148e3120033725f56470d87686612a637 (diff)
downloadmariadb-git-f67abe26fbadc52a14621a627c999e563b38bc8f.tar.gz
fixed bug of PROCEDURE in same query with subselects
prohibited using procedure inside subquery fixed error handling of procedure analize mysql-test/r/subselect.result: test of PROCEDURE in subselect test of PROCEDURE of subselect mysql-test/t/subselect.test: test of PROCEDURE in subselect test of PROCEDURE of subselect sql/sql_analyse.cc: fixed error handling in procedure analize sql/sql_parse.cc: fixed bug of PROCEDURE in same query with subselects sql/sql_yacc.yy: prohibited using procedure inside subquery
-rw-r--r--mysql-test/r/subselect.result4
-rw-r--r--mysql-test/t/subselect.test5
-rw-r--r--sql/sql_analyse.cc8
-rw-r--r--sql/sql_parse.cc9
-rw-r--r--sql/sql_yacc.yy7
5 files changed, 26 insertions, 7 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index d198575deb5..d442e4d97ce 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -43,6 +43,10 @@ SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
1
1
+select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
+Wrong usage of PROCEDURE and subquery
+SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+Incorrect parameters to procedure 'ANALYSE'
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 9ed4250976b..8b174882bc6 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -20,6 +20,11 @@ SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c O
SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
+-- error 1221
+select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
+-- error 1108
+SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index f98eb0e0b26..ac641f64b53 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -89,21 +89,21 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val() < 0)
{
- net_printf(thd, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name);
+ my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0);
}
pc->max_tree_elements = (uint) (*param->item)->val_int();
param = param->next;
if (param->next) // no third parameter possible
{
- net_printf(thd, ER_WRONG_PARAMCOUNT_TO_PROCEDURE, proc_name);
+ my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0);
}
// second parameter
if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val() < 0)
{
- net_printf(thd, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name);
+ my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0);
}
pc->max_treemem = (uint) (*param->item)->val_int();
@@ -111,7 +111,7 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result,
else if ((*param->item)->type() != Item::INT_ITEM ||
(*param->item)->val() < 0)
{
- net_printf(thd, ER_WRONG_PARAMETERS_TO_PROCEDURE, proc_name);
+ my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name);
DBUG_RETURN(0);
}
// if only one parameter was given, it will be the value of max_tree_elements
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 086f58e0fd6..bd14d0f9b6a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3054,9 +3054,12 @@ mysql_init_select(LEX *lex)
select_lex->init_select();
select_lex->master_unit()->select_limit= select_lex->select_limit=
lex->thd->variables.select_limit;
- lex->exchange= 0;
- lex->result= 0;
- lex->proc_list.first= 0;
+ if (select_lex == &lex->select_lex)
+ {
+ lex->exchange= 0;
+ lex->result= 0;
+ lex->proc_list.first= 0;
+ }
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c860d98bcc4..cd7503fdb5c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2750,6 +2750,13 @@ procedure_clause:
| PROCEDURE ident /* Procedure name */
{
LEX *lex=Lex;
+ if (&lex->select_lex != lex->current_select)
+ {
+ net_printf(lex->thd, ER_WRONG_USAGE,
+ "PROCEDURE",
+ "subquery");
+ YYABORT;
+ }
lex->proc_list.elements=0;
lex->proc_list.first=0;
lex->proc_list.next= (byte**) &lex->proc_list.first;