List:Commits« Previous MessageNext Message »
From:sanja Date:December 13 2005 1:18pm
Subject:bk commit into 5.0 tree (bell:1.1993) BUG#14308
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.1993 05/12/13 15:18:49 bell@stripped +4 -0
  The check for recursive view definitions added. (BUG#14308)

  sql/sql_view.cc
    1.81 05/12/13 15:18:45 bell@stripped +17 -0
    The check of view recursion.

  sql/share/errmsg.txt
    1.56 05/12/13 15:18:45 bell@stripped +2 -0
    New error message about a recursive view.

  mysql-test/t/view.test
    1.130 05/12/13 15:18:45 bell@stripped +31 -0
    BUG#14308 test suite.

  mysql-test/r/view.result
    1.141 05/12/13 15:18:44 bell@stripped +23 -0
    BUG#14308 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-bug1-5.0

--- 1.55/sql/share/errmsg.txt	2005-12-06 19:21:34 +02:00
+++ 1.56/sql/share/errmsg.txt	2005-12-13 15:18:45 +02:00
@@ -5605,3 +5605,5 @@
 ER_SP_PROC_TABLE_CORRUPT
 	eng "Failed to load routine %s. The table mysql.proc is missing, corrupt, or contains bad data (internal code %d)"
+ER_VIEW_RECURSIVE
+        eng "`%-.64s`.`%-.64s` contain view recursion"

--- 1.140/mysql-test/r/view.result	2005-12-07 13:36:31 +02:00
+++ 1.141/mysql-test/r/view.result	2005-12-13 15:18:44 +02:00
@@ -2456,3 +2456,26 @@
 42
 drop view v2,v1;
 drop function f1;
+create table t1 (a int);
+create view v1 as select * from t1;
+create view v2 as select * from v1;
+drop table t1;
+rename table v2 to t1;
+select * from v1;
+ERROR HY000: `test`.`v1` contain view recursion
+drop view t1, v1;
+create table t1 (a int);
+create function f1() returns int
+begin
+declare mx int;
+select max(a) from t1 into mx;
+return mx;
+end//
+create view v1 as select f1() as a;
+create view v2 as select * from v1;
+drop table t1;
+rename table v2 to t1;
+select * from v1;
+ERROR HY000: Recursive stored functions and triggers are not allowed.
+drop function f1;
+drop view t1, v1;

--- 1.129/mysql-test/t/view.test	2005-12-07 11:36:24 +02:00
+++ 1.130/mysql-test/t/view.test	2005-12-13 15:18:45 +02:00
@@ -2319,3 +2319,34 @@
 select * from v2;
 drop view v2,v1;
 drop function f1;
+
+#
+# BUG#14308: Recursive view definitions
+#
+# using view only
+create table t1 (a int);
+create view v1 as select * from t1;
+create view v2 as select * from v1;
+drop table t1;
+rename table v2 to t1;
+-- error ER_VIEW_RECURSIVE
+select * from v1;
+drop view t1, v1;
+# using SP function
+create table t1 (a int);
+delimiter //;
+create function f1() returns int
+begin
+  declare mx int;
+  select max(a) from t1 into mx;
+  return mx;
+end//
+delimiter ;//
+create view v1 as select f1() as a;
+create view v2 as select * from v1;
+drop table t1;
+rename table v2 to t1;
+-- error ER_SP_NO_RECURSION
+select * from v1;
+drop function f1;
+drop view t1, v1;

--- 1.80/sql/sql_view.cc	2005-12-02 21:19:21 +02:00
+++ 1.81/sql/sql_view.cc	2005-12-13 15:18:45 +02:00
@@ -918,6 +918,23 @@
       tbl->skip_temporary= 1;
       tbl->belong_to_view= top_view;
       tbl->referencing_view= table;
+      /* check loop via view definition */
+      for (TABLE_LIST *precedent= table;
+           precedent;
+           precedent= precedent->referencing_view)
+      {
+        if (precedent->view_name.length == tbl->table_name_length &&
+            precedent->view_db.length == tbl->db_length &&
+            my_strcasecmp(system_charset_info,
+                          precedent->view_name.str, tbl->table_name) == 0 &&
+            my_strcasecmp(system_charset_info,
+                          precedent->view_db.str, tbl->db) == 0)
+        {
+          my_error(ER_VIEW_RECURSIVE, MYF(0),
+                   top_view->view_db.str, top_view->view_name.str);
+          goto err;
+        }
+      }
       /*
         First we fill want_privilege with SELECT_ACL (this is needed for the
         tables which belongs to view subqueries and temporary table views,
Thread
bk commit into 5.0 tree (bell:1.1993) BUG#14308sanja13 Dec