diff options
author | unknown <igor@rurik.mysql.com> | 2005-08-18 07:25:56 -0700 |
---|---|---|
committer | unknown <igor@rurik.mysql.com> | 2005-08-18 07:25:56 -0700 |
commit | be9ccb352da5536d6936100c68b675c05636c870 (patch) | |
tree | 114106527109aaf7417171ae3fa22e6fadc8339c | |
parent | 749f599efa81de151401d0af33c4b31292727b15 (diff) | |
parent | 6ea6df4e533219ffed0e420949d5e3a41febd276 (diff) | |
download | mariadb-git-be9ccb352da5536d6936100c68b675c05636c870.tar.gz |
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into rurik.mysql.com:/home/igor/mysql-5.0
-rw-r--r-- | mysql-test/r/view.result | 8 | ||||
-rw-r--r-- | mysql-test/t/view.test | 13 | ||||
-rw-r--r-- | sql/share/errmsg.txt | 2 | ||||
-rw-r--r-- | sql/sql_view.cc | 8 |
4 files changed, 26 insertions, 5 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 2af2f06ad52..f6c15669e9e 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -6,7 +6,7 @@ create view v1 (c,d) as select a,b from t1; ERROR 42S02: Table 'test.t1' doesn't exist create temporary table t1 (a int, b int); create view v1 (c) as select b+1 from t1; -ERROR HY000: View's SELECT contains a temporary table 't1' +ERROR HY000: View's SELECT refers to a temporary table 't1' drop table t1; create table t1 (a int, b int); insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10); @@ -2097,3 +2097,9 @@ select * from v1; f1 1 drop view v1; +CREATE TEMPORARY TABLE t1 (a int); +CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1); +CREATE VIEW v1 AS SELECT f1(); +ERROR HY000: View's SELECT refers to a temporary table 't1' +DROP FUNCTION f1; +DROP TABLE t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index ceff7af401c..5635358120a 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1942,3 +1942,16 @@ DROP TABLE t1,t2,t3,t4,t5; create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; select * from v1; drop view v1; + +# +# Test for bug #10970: view referring a temporary table indirectly +# + +CREATE TEMPORARY TABLE t1 (a int); +CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1); +-- error 1352 +CREATE VIEW v1 AS SELECT f1(); + +DROP FUNCTION f1; +DROP TABLE t1; + diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 2c28eef1ea1..65afefef35a 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5194,7 +5194,7 @@ ER_VIEW_SELECT_VARIABLE rus "View SELECT содержит переменную или параметр" ukr "View SELECT ма╓ зминну або параметер" ER_VIEW_SELECT_TMPTABLE - eng "View's SELECT contains a temporary table '%-.64s'" + eng "View's SELECT refers to a temporary table '%-.64s'" rus "View SELECT содержит ссылку на временную таблицу '%-.64s'" ukr "View SELECT використову╓ тимчасову таблицю '%-.64s'" ER_VIEW_WRONG_LIST diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 577d1d32fcc..af21b43e5c9 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -306,9 +306,11 @@ bool mysql_create_view(THD *thd, /* check that tables are not temporary and this VIEW do not used in query - (it is possible with ALTERing VIEW) - */ - for (tbl= tables; tbl; tbl= tbl->next_global) + (it is possible with ALTERing VIEW). + open_and_lock_tables can change the value of tables, + e.g. it may happen if before the function call tables was equal to 0. + */ + for (tbl= tables= lex->query_tables; tbl; tbl= tbl->next_global) { /* is this table temporary and is not view? */ if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view && |