Commit f1bbfdf4 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

checked INTO clause during view creation (BUG#5332)

parent 31dacc6e
...@@ -365,7 +365,7 @@ ...@@ -365,7 +365,7 @@
#define ER_WRONG_OBJECT 1346 #define ER_WRONG_OBJECT 1346
#define ER_NONUPDATEABLE_COLUMN 1347 #define ER_NONUPDATEABLE_COLUMN 1347
#define ER_VIEW_SELECT_DERIVED 1348 #define ER_VIEW_SELECT_DERIVED 1348
#define ER_VIEW_SELECT_PROCEDURE 1349 #define ER_VIEW_SELECT_CLAUSE 1349
#define ER_VIEW_SELECT_VARIABLE 1350 #define ER_VIEW_SELECT_VARIABLE 1350
#define ER_VIEW_SELECT_TMPTABLE 1351 #define ER_VIEW_SELECT_TMPTABLE 1351
#define ER_VIEW_WRONG_LIST 1352 #define ER_VIEW_WRONG_LIST 1352
...@@ -374,4 +374,4 @@ ...@@ -374,4 +374,4 @@
#define ER_VIEW_INVALID 1355 #define ER_VIEW_INVALID 1355
#define ER_SP_NO_DROP_SP 1356 #define ER_SP_NO_DROP_SP 1356
#define ER_SP_GOTO_IN_HNDLR 1357 #define ER_SP_GOTO_IN_HNDLR 1357
#define ER_ERROR_MESSAGES 357 #define ER_ERROR_MESSAGES 358
...@@ -1253,3 +1253,11 @@ create view v4 as select * from v3; ...@@ -1253,3 +1253,11 @@ create view v4 as select * from v3;
select * from v4; select * from v4;
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
drop view v4, v3, v2, v1; drop view v4, v3, v2, v1;
create view v1 as select 5 into @w;
ERROR HY000: View's SELECT contains a 'INTO' clause
create view v1 as select 5 into outfile 'ttt';
ERROR HY000: View's SELECT contains a 'INTO' clause
create table t1 (a int);
create view v1 as select a from t1 procedure analyse();
ERROR HY000: View's SELECT contains a 'PROCEDURE' clause
drop table t1;
...@@ -1207,3 +1207,15 @@ create view v4 as select * from v3; ...@@ -1207,3 +1207,15 @@ create view v4 as select * from v3;
-- error 1242 -- error 1242
select * from v4; select * from v4;
drop view v4, v3, v2, v1; drop view v4, v3, v2, v1;
#
# VIEW over SELECT with prohibited clauses
#
-- error 1349
create view v1 as select 5 into @w;
-- error 1349
create view v1 as select 5 into outfile 'ttt';
create table t1 (a int);
-- error 1349
create view v1 as select a from t1 procedure analyse();
drop table t1;
...@@ -361,7 +361,7 @@ character-set=latin2 ...@@ -361,7 +361,7 @@ character-set=latin2
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
/* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB :/* Copyright Abandoned 1997 TCX DataKonsult AB & Monty Program KB & Detron HB
This file is public domain and comes with NO WARRANTY of any kind */ This file is public domain and comes with NO WARRANTY of any kind */
/* Knud Riishøjgård knudriis@post.tele.dk 99 && /* Knud Riishøjgård knudriis@post.tele.dk 99 &&
...@@ -355,7 +355,7 @@ character-set=latin1 ...@@ -355,7 +355,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -363,7 +363,7 @@ character-set=latin1 ...@@ -363,7 +363,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=latin1 ...@@ -352,7 +352,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -357,7 +357,7 @@ character-set=latin7 ...@@ -357,7 +357,7 @@ character-set=latin7
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=latin1 ...@@ -352,7 +352,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -364,7 +364,7 @@ character-set=latin1 ...@@ -364,7 +364,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=greek ...@@ -352,7 +352,7 @@ character-set=greek
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=latin2 ...@@ -354,7 +354,7 @@ character-set=latin2
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=latin1 ...@@ -352,7 +352,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=ujis ...@@ -354,7 +354,7 @@ character-set=ujis
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=euckr ...@@ -352,7 +352,7 @@ character-set=euckr
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=latin1 ...@@ -354,7 +354,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=latin1 ...@@ -354,7 +354,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -356,7 +356,7 @@ character-set=latin2 ...@@ -356,7 +356,7 @@ character-set=latin2
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -353,7 +353,7 @@ character-set=latin1 ...@@ -353,7 +353,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -356,7 +356,7 @@ character-set=latin2 ...@@ -356,7 +356,7 @@ character-set=latin2
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=koi8r ...@@ -354,7 +354,7 @@ character-set=koi8r
"'%-.64s.%-.64s' - %s" "'%-.64s.%-.64s' - %s"
" '%-.64s' " " '%-.64s' "
"View SELECT FROM" "View SELECT FROM"
"View SELECT PROCEDURE" "View SELECT '%s'"
"View SELECT " "View SELECT "
"View SELECT '%-.64s'" "View SELECT '%-.64s'"
"View SELECT view " "View SELECT view "
......
...@@ -358,7 +358,7 @@ character-set=cp1250 ...@@ -358,7 +358,7 @@ character-set=cp1250
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -360,7 +360,7 @@ character-set=latin2 ...@@ -360,7 +360,7 @@ character-set=latin2
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -354,7 +354,7 @@ character-set=latin1 ...@@ -354,7 +354,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -352,7 +352,7 @@ character-set=latin1 ...@@ -352,7 +352,7 @@ character-set=latin1
"'%-.64s.%-.64s' is not %s" "'%-.64s.%-.64s' is not %s"
"Column '%-.64s' is not updatable" "Column '%-.64s' is not updatable"
"View's SELECT contains a subquery in the FROM clause" "View's SELECT contains a subquery in the FROM clause"
"View's SELECT contains a PROCEDURE clause" "View's SELECT contains a '%s' clause"
"View's SELECT contains a variable or parameter" "View's SELECT contains a variable or parameter"
"View's SELECT contains a temporary table '%-.64s'" "View's SELECT contains a temporary table '%-.64s'"
"View's SELECT and view's field list have different column counts" "View's SELECT and view's field list have different column counts"
......
...@@ -357,7 +357,7 @@ character-set=koi8u ...@@ -357,7 +357,7 @@ character-set=koi8u
"'%-.64s.%-.64s' %s" "'%-.64s.%-.64s' %s"
" '%-.64s' " " '%-.64s' "
"View SELECT Ц æ FROM" "View SELECT Ц æ FROM"
"View SELECT æ PROCEDURE" "View SELECT æ '%s'"
"View SELECT " "View SELECT "
"View SELECT դ '%-.64s'" "View SELECT դ '%-.64s'"
"View SELECT ̦ æ view Ҧ ˦˦ æ" "View SELECT ̦ æ view Ҧ ˦˦ æ"
......
...@@ -59,12 +59,21 @@ int mysql_create_view(THD *thd, ...@@ -59,12 +59,21 @@ int mysql_create_view(THD *thd,
int res= 0; int res= 0;
DBUG_ENTER("mysql_create_view"); DBUG_ENTER("mysql_create_view");
if (lex->derived_tables || lex->proc_list.first || if (lex->proc_list.first ||
lex->result)
{
my_error(ER_VIEW_SELECT_CLAUSE, MYF(0), (lex->result ?
"INTO" :
"PROCEDURE"));
res= -1;
goto err;
}
if (lex->derived_tables ||
lex->variables_used || lex->param_list.elements) lex->variables_used || lex->param_list.elements)
{ {
my_error((lex->derived_tables ? ER_VIEW_SELECT_DERIVED : my_error((lex->derived_tables ?
(lex->proc_list.first ? ER_VIEW_SELECT_PROCEDURE : ER_VIEW_SELECT_DERIVED :
ER_VIEW_SELECT_VARIABLE)), MYF(0)); ER_VIEW_SELECT_VARIABLE), MYF(0));
res= -1; res= -1;
goto err; goto err;
} }
......
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