MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:timour Date:September 11 2006 9:26am
Subject:bk commit into 5.0 tree (timour:1.2260) BUG#21774
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of timka. When timka 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-09-11 12:26:17+03:00, timour@stripped +5 -0
  Fix for BUG#21774: Column count doesn't match value count at row x
  
  Also completes the fix of related BUG 18080, because the fix for
  BUG#21774 exposed a problem with the fix for 18080.
  
  The problem was in that the handling of SQLCOM_INSERT in sql_parse.cc
  incorrectly and prematurely reset the name resolution context.
  In addition, setup_tables() also uncoditionally reset the name
  resolution context after processing NATURAL/USING joins.
  
  The fix removes unneccessary resets of the name resolution context.

  mysql-test/r/insert_select.result@stripped, 2006-09-11 12:26:15+03:00, timour@stripped +10 -0
    Test for BUG#21774.

  mysql-test/t/insert_select.test@stripped, 2006-09-11 12:26:15+03:00, timour@stripped +18 -0
    Test for BUG#21774.

  sql/sql_base.cc@stripped, 2006-09-11 12:26:15+03:00, timour@stripped +13 -1
    Fix for BUG 18080.
    - Reset the name resolution context only if it has not been
      previously set. This is needed because when setup_tables()
      was called after setup_natural_join_row_types(), it
      overrode the name resolution context that pointed to the
      top-most NATURAL/USING join.
    - Added ASSERTs to make sure the name resolution context is
      in a consistent state.

  sql/sql_insert.cc@stripped, 2006-09-11 12:26:15+03:00, timour@stripped +9 -0
    Added ASSERTS to make sure that resetting the name resolution
    context is unnecessary for INSERT ... VALUES statements because
    the statement always contains exactly one table.

  sql/sql_parse.cc@stripped, 2006-09-11 12:26:15+03:00, timour@stripped +0 -2
    The fix for BUG#21774.
    Removed an erroneous skipping of the first table which was
    supposed to force name resolution only in the VALUES part of
    an INSERT statement.
    
    The subsequent prepare procedures for INSERT called in sql_insert.cc
    already reset the context before setup of the tables/fields in
    each part of the statement.

# 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:	timour
# Host:	lamia.home
# Root:	/home/timka/mysql/src/5.0-bug-21774

--- 1.349/sql/sql_base.cc	2006-09-11 12:26:22 +03:00
+++ 1.350/sql/sql_base.cc	2006-09-11 12:26:22 +03:00
@@ -4453,7 +4453,19 @@ bool setup_tables(THD *thd, Name_resolut
   uint tablenr= 0;
   DBUG_ENTER("setup_tables");
 
-  context->table_list= context->first_name_resolution_table= tables;
+  /*
+    Due to the various call paths that lead to setup_tables() it may happen
+    that context->table_list and context->first_name_resolution_table can be
+    NULL.
+    TODO: investigate all cases when this my happen, and initialize the
+    name resolution context correctly in all those places.
+  */
+  if (!context->table_list || !context->first_name_resolution_table)
+  {
+    /* Test whether the context is in a consistent state. */
+    DBUG_ASSERT(!context->first_name_resolution_table && !context->table_list);
+    context->table_list= context->first_name_resolution_table= tables;
+  }
 
   /*
     this is used for INSERT ... SELECT.

--- 1.199/sql/sql_insert.cc	2006-09-11 12:26:22 +03:00
+++ 1.200/sql/sql_insert.cc	2006-09-11 12:26:22 +03:00
@@ -411,6 +411,15 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   table= table_list->table;
 
   context= &thd->lex->select_lex.context;
+  /*
+    These three asserts test the hypothesis that the resetting of the name
+    resolution context below is not necessary since the list of local tables
+    for INSERT always consists of one table.
+  */
+  DBUG_ASSERT(!table_list->next_local);
+  DBUG_ASSERT(!context->table_list->next_local);
+  DBUG_ASSERT(!context->first_name_resolution_table->next_name_resolution_table);
+
   /* Save the state of the current name resolution context. */
   ctx_state.save_state(context, table_list);
 

--- 1.565/sql/sql_parse.cc	2006-09-11 12:26:22 +03:00
+++ 1.566/sql/sql_parse.cc	2006-09-11 12:26:22 +03:00
@@ -3344,8 +3344,6 @@ end_with_restore_list:
     DBUG_ASSERT(first_table == all_tables && first_table != 0);
     if ((res= insert_precheck(thd, all_tables)))
       break;
-    /* Skip first table, which is the table we are inserting in */
-    select_lex->context.table_list= first_table->next_local;
 
     if (!thd->locked_tables &&
         !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))

--- 1.40/mysql-test/r/insert_select.result	2006-09-11 12:26:22 +03:00
+++ 1.41/mysql-test/r/insert_select.result	2006-09-11 12:26:22 +03:00
@@ -695,6 +695,16 @@ CREATE TABLE t2 (z int, y int);
 CREATE TABLE t3 (a int, b int);
 INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
 DROP TABLE IF EXISTS t1,t2,t3;
+CREATE DATABASE bug21774_1;
+CREATE DATABASE bug21774_2;
+CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
+use bug21774_1;
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
+DROP DATABASE bug21774_1;
+DROP DATABASE bug21774_2;
 CREATE DATABASE meow;
 CREATE TABLE table_target   ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
 CREATE TABLE table_target2  ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));

--- 1.32/mysql-test/t/insert_select.test	2006-09-11 12:26:22 +03:00
+++ 1.33/mysql-test/t/insert_select.test	2006-09-11 12:26:22 +03:00
@@ -249,6 +249,24 @@ INSERT INTO t3 (SELECT x, y FROM t1 JOIN
 DROP TABLE IF EXISTS t1,t2,t3;
 
 #
+# Bug #21774: Column count doesn't match value count at row x
+#
+CREATE DATABASE bug21774_1;
+CREATE DATABASE bug21774_2;
+
+CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
+
+use bug21774_1;
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
+
+DROP DATABASE bug21774_1;
+DROP DATABASE bug21774_2;
+
+#
 # Bug #20989: View '(null).(null)' references invalid table(s)... on
 #             SQL SECURITY INVOKER
 #
Thread
bk commit into 5.0 tree (timour:1.2260) BUG#21774timour11 Sep