List:Commits« Previous MessageNext Message »
From:kroki Date:July 14 2006 10:34am
Subject:bk commit into 5.0 tree (kroki:1.2216) BUG#19182
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of tomash. When tomash 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@stripped, 2006-07-14 14:34:23+04:00, kroki@stripped +4 -0
  Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work
             from stored procedure.
  
  The cause of a bug was that cached LEX::create_list was modified, and
  then together with LEX::key_list was reset.

  mysql-test/r/ps_11bugs.result@stripped, 2006-07-14 14:34:18+04:00, kroki@stripped +19 -0
    Add result for bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo;
    doesn't work from stored procedure.

  mysql-test/t/ps_11bugs.test@stripped, 2006-07-14 14:34:18+04:00, kroki@stripped +34 -0
    Add test case for bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo;
    doesn't work from stored procedure.

  sql/sql_insert.cc@stripped, 2006-07-14 14:34:18+04:00, kroki@stripped +16 -0
    Chop off extra fields added to field list, so that original field list
    will stay unmodified after the call.

  sql/sql_parse.cc@stripped, 2006-07-14 14:34:19+04:00, kroki@stripped +0 -3
    Remove clearing of LEX::create_list and LEX::key_list.

# 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:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-5.0-bug19182

--- 1.194/sql/sql_insert.cc	2006-07-14 14:34:30 +04:00
+++ 1.195/sql/sql_insert.cc	2006-07-14 14:34:30 +04:00
@@ -2469,6 +2469,7 @@
   Item *item;
   Field *tmp_field;
   bool not_used;
+  uint save_fields_elements= extra_fields->elements;
   DBUG_ENTER("create_table_from_items");
 
   tmp_table.alias= 0;
@@ -2541,6 +2542,21 @@
         quick_rm_table(create_info->db_type, create_table->db,
                        table_case_name(create_info, create_table->table_name));
     }
+
+    /*
+      Chop off extra fields added before the call to mysql_create_table().
+    */
+    if (extra_fields->elements > save_fields_elements)
+    {
+      list_node *node= extra_fields->first_node();
+      list_node **pnode= &node;
+      for (uint i= 0; i < save_fields_elements; ++i)
+        pnode= &(*pnode)->next;
+
+      while (extra_fields->elements > save_fields_elements)
+        extra_fields->remove(pnode);
+    }
+
     reenable_binlog(thd);
     if (!table)                                   // open failed
       DBUG_RETURN(0);

--- 1.561/sql/sql_parse.cc	2006-07-14 14:34:30 +04:00
+++ 1.562/sql/sql_parse.cc	2006-07-14 14:34:30 +04:00
@@ -2947,9 +2947,6 @@
           res= handle_select(thd, lex, result, 0);
           delete result;
         }
-	/* reset for PS */
-	lex->create_list.empty();
-	lex->key_list.empty();
       }
     }
     else

--- 1.4/mysql-test/r/ps_11bugs.result	2006-07-14 14:34:30 +04:00
+++ 1.5/mysql-test/r/ps_11bugs.result	2006-07-14 14:34:30 +04:00
@@ -130,3 +130,22 @@
 execute st_18492;
 a
 drop table t1;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (i INT);
+PREPARE st_19182 FROM "CREATE TABLE t2 (j INT, KEY (j)) SELECT i FROM t1";
+EXECUTE st_19182;
+DESC t2;
+Field	Type	Null	Key	Default	Extra
+j	int(11)	YES	MUL	NULL	
+i	int(11)	YES		NULL	
+DROP TABLE t2;
+EXECUTE st_19182;
+DESC t2;
+Field	Type	Null	Key	Default	Extra
+j	int(11)	YES	MUL	NULL	
+i	int(11)	YES		NULL	
+DEALLOCATE PREPARE st_19182;
+DROP TABLE t2;
+DROP TABLE t1;
+End of 5.0 tests.

--- 1.6/mysql-test/t/ps_11bugs.test	2006-07-14 14:34:30 +04:00
+++ 1.7/mysql-test/t/ps_11bugs.test	2006-07-14 14:34:30 +04:00
@@ -144,3 +144,37 @@
 execute st_18492;
 
 drop table t1;
+
+
+#
+# Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work
+# from stored procedure.
+#
+# The cause of a bug was that cached LEX::create_list was modified,
+# and then together with LEX::key_list was reset.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+PREPARE st_19182 FROM "CREATE TABLE t2 (j INT, KEY (j)) SELECT i FROM t1";
+
+EXECUTE st_19182;
+DESC t2;
+
+DROP TABLE t2;
+
+# Check that on second execution we don't loose 'j' column and the key
+# on it.
+EXECUTE st_19182;
+DESC t2;
+
+DEALLOCATE PREPARE st_19182;
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo End of 5.0 tests.
Thread
bk commit into 5.0 tree (kroki:1.2216) BUG#19182kroki14 Jul