MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:igor Date:August 18 2005 5:19am
Subject:bk commit into 5.0 tree (igor:1.1988) BUG#10970
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1988 05/08/17 22:19:12 igor@stripped +4 -0
  view.test:
    Added a test case for bug #10970.
  view.result:
    Added a test case for bug #10970.
    Modified the error messages for error ER_VIEW_SELECT_TMPTABLE.
  sql_view.cc:
    Fixed bug #10970.
    In the function mysql_create_view if a view does not refer
    any tables directly the variable table must be updated
    after the call of open_and_lock_tables.
  errmsg.txt:
    Modified the error messages for error ER_VIEW_SELECT_TMPTABLE
    (when fixing bug #10970).

  mysql-test/t/view.test
    1.98 05/08/17 22:15:05 igor@stripped +13 -0
    Added a test case for bug #10970.

  mysql-test/r/view.result
    1.104 05/08/17 22:14:25 igor@stripped +7 -1
    Fixed bug #10970.
    Modified the error messages for error ER_VIEW_SELECT_TMPTABLE.

  sql/sql_view.cc
    1.58 05/08/17 22:12:23 igor@stripped +5 -3
    Fixed bug #10970.
    In the function mysql_create_view if a view does not refer
    any tables directly the variable table must be updated
    after the call of open_and_lock_tables.

  sql/share/errmsg.txt
    1.39 05/08/17 22:05:10 igor@stripped +1 -1
    Modified the error messages for error ER_VIEW_SELECT_TMPTABLE
    (when fixing bug #10970).

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	igor
# Host:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-5.0-0

--- 1.38/sql/share/errmsg.txt	Mon Aug 15 12:38:53 2005
+++ 1.39/sql/share/errmsg.txt	Wed Aug 17 22:05:10 2005
@@ -5194,7 +5194,7 @@
 ER_VIEW_SELECT_TMPTABLE  
-	eng "View's SELECT contains a temporary table '%-.64s'"
+	eng "View's SELECT refers to a temporary table '%-.64s'"
 ER_VIEW_WRONG_LIST  

--- 1.103/mysql-test/r/view.result	Fri Aug 12 11:08:29 2005
+++ 1.104/mysql-test/r/view.result	Wed Aug 17 22:14:25 2005
@@ -6,7 +6,7 @@
 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 @@
 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;

--- 1.97/mysql-test/t/view.test	Fri Aug 12 11:08:20 2005
+++ 1.98/mysql-test/t/view.test	Wed Aug 17 22:15:05 2005
@@ -1942,3 +1942,16 @@
 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;
+

--- 1.57/sql/sql_view.cc	Mon Aug 15 02:21:53 2005
+++ 1.58/sql/sql_view.cc	Wed Aug 17 22:12:23 2005
@@ -310,9 +310,11 @@
 
   /*
     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 &&
Thread
bk commit into 5.0 tree (igor:1.1988) BUG#10970igor18 Aug