MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:sanja Date:December 1 2005 10:15am
Subject:bk commit into 5.0 tree (bell:1.1988) BUG#15096
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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/12/01 12:15:48 bell@stripped +3 -0
  View creation code fixed to expect empty TABLE_LIST::table pointer (BUG#15096).

  sql/sql_view.cc
    1.79 05/12/01 12:15:43 bell@stripped +22 -13
    View placed in a function never get TABLE during view creation,
    because we have never executed that function in this process.
    So we should expect empty TABLE_LIST::table pointer.

  mysql-test/t/view.test
    1.127 05/12/01 12:15:43 bell@stripped +21 -0
    BUG#15096 test suite.

  mysql-test/r/view.result
    1.137 05/12/01 12:15:43 bell@stripped +15 -0
    BUG#15096 test suite.

# 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:	bell
# Host:	sanja.is.com.ua
# Root:	/home/bell/mysql/bk/work-bug3-5.0

--- 1.136/mysql-test/r/view.result	2005-11-18 16:26:43 +02:00
+++ 1.137/mysql-test/r/view.result	2005-12-01 12:15:43 +02:00
@@ -2424,3 +2424,18 @@
 NULL	12
 drop view v1;
 drop table t1;
+CREATE VIEW v1 AS SELECT 42 AS Meaning;
+DROP FUNCTION IF EXISTS f1;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+DECLARE retn INTEGER;
+SELECT Meaning FROM v1 INTO retn;
+RETURN retn;
+END
+//
+CREATE VIEW v2 AS SELECT f1();
+select * from v2;
+f1()
+42
+drop view v2,v1;
+drop function f1;

--- 1.126/mysql-test/t/view.test	2005-11-18 16:26:43 +02:00
+++ 1.127/mysql-test/t/view.test	2005-12-01 12:15:43 +02:00
@@ -2280,3 +2280,24 @@
 select f1, sum(f2) from v1 group by f1;
 drop view v1;
 drop table t1;
+
+#
+# BUG#15096: using function with view for view creation
+#
+CREATE VIEW v1 AS SELECT 42 AS Meaning;
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+DELIMITER //;
+CREATE FUNCTION f1() RETURNS INTEGER
+BEGIN
+  DECLARE retn INTEGER;
+  SELECT Meaning FROM v1 INTO retn;
+  RETURN retn;
+END
+//
+DELIMITER ;//
+CREATE VIEW v2 AS SELECT f1();
+select * from v2;
+drop view v2,v1;
+drop function f1;

--- 1.78/sql/sql_view.cc	2005-11-21 21:15:43 +02:00
+++ 1.79/sql/sql_view.cc	2005-12-01 12:15:43 +02:00
@@ -350,15 +350,6 @@
   */ 
   for (tbl= 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 &&
-        !tbl->schema_table)
-    {
-      my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias);
-      res= TRUE;
-      goto err;
-    }
-
     /* is this table view and the same view which we creates now? */
     if (tbl->view &&
         strcmp(tbl->view_db.str, view->db) == 0 &&
@@ -370,11 +361,29 @@
     }
 
     /*
-      Copy the privileges of the underlying VIEWs which were filled by
-      fill_effective_table_privileges
-      (they were not copied at derived tables processing)
+      tbl->table can be NULL when tbl is a placeholder for a view
+      that is indirectly referenced via a stored function from the
+      view being created. We don't check these indirectly
+      referenced views in CREATE VIEW so they don't have table
+      object.
     */
-    tbl->table->grant.privilege= tbl->grant.privilege;
+    if (tbl->table)
+    {
+      /* is this table temporary and is not view? */
+      if (tbl->table->s->tmp_table != NO_TMP_TABLE && !tbl->view &&
+          !tbl->schema_table)
+      {
+        my_error(ER_VIEW_SELECT_TMPTABLE, MYF(0), tbl->alias);
+        res= TRUE;
+        goto err;
+      }
+      /*
+        Copy the privileges of the underlying VIEWs which were filled by
+        fill_effective_table_privileges
+        (they were not copied at derived tables processing)
+      */
+      tbl->table->grant.privilege= tbl->grant.privilege;
+    }
   }
 
   /* prepare select to resolve all fields */
Thread
bk commit into 5.0 tree (bell:1.1988) BUG#15096sanja1 Dec