MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:sanja Date:June 22 2005 7:48am
Subject:bk commit into 5.0 tree (bell:1.1981) BUG#11337
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.1981 05/06/22 10:48:34 bell@stripped +4 -0
  fixed environment creation and cleaning up for processing view one by one during checking (BUG#11337)

  sql/sql_table.cc
    1.254 05/06/22 10:48:30 bell@stripped +41 -8
    fixed environment creation and cleaning up for processing view one by one (BUG#11337)

  sql/sql_lex.h
    1.186 05/06/22 10:48:30 bell@stripped +7 -1
    method for lex cleunup during view processing one by one

  mysql-test/t/view.test
    1.74 05/06/22 10:48:30 bell@stripped +17 -0
    checking views after some view with error (BUG#11337)

  mysql-test/r/view.result
    1.86 05/06/22 10:48:29 bell@stripped +19 -0
    checking views after some view with error (BUG#11337)

# 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-bug4-5.0

--- 1.185/sql/sql_lex.h	Tue Jun 21 17:18:23 2005
+++ 1.186/sql/sql_lex.h	Wed Jun 22 10:48:30 2005
@@ -627,7 +627,13 @@
     order_list.first= 0;
     order_list.next= (byte**) &order_list.first;
   }
-  
+  /*
+    This method created for reiniting LEX in mysql_admin_table() and can be
+    used only if you are going remove all SELECT_LEX & units except belonger
+    to LEX (LEX::unit & LEX::select, for other purposes there are
+    SELECT_LEX_UNIT::exclude_level & SELECT_LEX_UNIT::exclude_tree
+  */
+  void cut_subtree() { slave= 0; }
   bool test_limit();
 
   friend void lex_start(THD *thd, uchar *buf, uint length);

--- 1.253/sql/sql_table.cc	Sat Jun 18 00:14:28 2005
+++ 1.254/sql/sql_table.cc	Wed Jun 22 10:48:30 2005
@@ -2104,6 +2104,39 @@
 
 
 /*
+  cleunup lex for case when we open table by table for processing
+
+  SYNOPSIS
+    lex_cleanup_after_view()
+    lex  lex which should be cleaned
+*/
+
+static void lex_cleanup_after_view(LEX *lex)
+{
+  /*
+    thd->lex->derived_tables & additional units may be set if we open
+    a view. It is necessary to clear thd->lex->derived_tables flag
+    to prevent processing of derived tables during next open_and_lock_tables
+    if next table is a real table and cleunup & remove underlying units
+    NOTE: all units will be connected to thd->lex->select_lex, because we
+    have not UNION on most apper level.
+    */
+  if (lex->all_selects_list != &lex->select_lex)
+  {
+    lex->derived_tables= 0;
+    /* cleunup underlying units (units of VIEW) */
+    for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit();
+         un;
+         un= un->next_unit())
+      un->cleanup();
+    /* reduce all selects list to default state */
+    lex->all_selects_list= &lex->select_lex;
+    /* remove underlying units (units of VIEW) subtree */
+    lex->select_lex.cut_subtree();
+  }
+}
+
+/*
   RETURN VALUES
     FALSE Message sent to net (admin operation went ok)
     TRUE  Message should be sent by caller 
@@ -2122,7 +2155,8 @@
                                                             HA_CHECK_OPT *),
                               int (view_operator_func)(THD *, TABLE_LIST*))
 {
-  TABLE_LIST *table, *next_global_table;
+  TABLE_LIST *table, *next_global_table, *next_local_table;
+  SELECT_LEX *select= &thd->lex->select_lex;
   List<Item> field_list;
   Item *item;
   Protocol *protocol= thd->protocol;
@@ -2154,10 +2188,14 @@
     /* open only one table from local list of command */
     next_global_table= table->next_global;
     table->next_global= 0;
+    next_local_table= table->next_local;
+    table->next_local= 0;
+    select->table_list.first= (byte*)table;
     thd->no_warnings_for_error= no_warnings_for_error;
     open_and_lock_tables(thd, table);
     thd->no_warnings_for_error= 0;
     table->next_global= next_global_table;
+    table->next_local= next_local_table;
     /* if view are unsupported */
     if (table->view && view_operator_func == NULL)
     {
@@ -2205,6 +2243,7 @@
         err_msg= (const char *)buf;
       }
       protocol->store(err_msg, system_charset_info);
+      lex_cleanup_after_view(thd->lex);
       thd->clear_error();
       if (protocol->write())
 	goto err;
@@ -2274,6 +2313,7 @@
 
 send_result:
 
+    lex_cleanup_after_view(thd->lex);
     thd->clear_error();  // these errors shouldn't get client
     protocol->prepare_for_resend();
     protocol->store(table_name, system_charset_info);
@@ -2401,13 +2441,6 @@
     }
     close_thread_tables(thd);
     table->table=0;				// For query cache
-    /*
-      thd->lex->derived_tables may be set to non zero value if we open 
-      a view. It is necessary to clear thd->lex->derived_tables flag 
-      to prevent processing of derived tables during next open_and_lock_tables
-      if next table is a real table.
-    */
-    thd->lex->derived_tables= 0;
     if (protocol->write())
       goto err;
   }

--- 1.85/mysql-test/r/view.result	Wed Jun 22 08:52:02 2005
+++ 1.86/mysql-test/r/view.result	Wed Jun 22 10:48:29 2005
@@ -1831,3 +1831,22 @@
 t
 01:00
 drop view v1;
+CREATE TABLE t1 (col1 integer);
+CREATE TABLE t2 (col1 integer);
+CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;
+CREATE OR REPLACE VIEW v3 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v4 AS SELECT col1 FROM t2;
+CREATE OR REPLACE VIEW v5 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v6 AS SELECT col1 FROM t2;
+DROP TABLE t1;
+CHECK TABLE v1, v2, v3, v4, v5, v6;
+Table	Op	Msg_type	Msg_text
+test.v1	check	error	View 'test.v1' references invalid table(s) or column(s) or function(s)
+test.v2	check	status	OK
+test.v3	check	error	View 'test.v3' references invalid table(s) or column(s) or function(s)
+test.v4	check	status	OK
+test.v5	check	error	View 'test.v5' references invalid table(s) or column(s) or function(s)
+test.v6	check	status	OK
+drop view v1, v2, v3, v4, v5, v6;
+drop table t2;

--- 1.73/mysql-test/t/view.test	Wed Jun 22 08:42:00 2005
+++ 1.74/mysql-test/t/view.test	Wed Jun 22 10:48:30 2005
@@ -1673,3 +1673,20 @@
 create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
 select * from v1;
 drop view v1;
+
+#
+# checking views after some view with error (BUG#11337)
+#
+
+CREATE TABLE t1 (col1 integer);
+CREATE TABLE t2 (col1 integer);
+CREATE OR REPLACE VIEW v1 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v2 AS SELECT col1 FROM t2;
+CREATE OR REPLACE VIEW v3 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v4 AS SELECT col1 FROM t2;
+CREATE OR REPLACE VIEW v5 AS SELECT col1 FROM t1;
+CREATE OR REPLACE VIEW v6 AS SELECT col1 FROM t2;
+DROP TABLE t1;
+CHECK TABLE v1, v2, v3, v4, v5, v6;
+drop view v1, v2, v3, v4, v5, v6;
+drop table t2;
Thread
bk commit into 5.0 tree (bell:1.1981) BUG#11337sanja22 Jun