List:Commits« Previous MessageNext Message »
From:Jim Winstead Date:December 8 2005 8:33pm
Subject:bk commit into 4.1 tree (jimw:1.2488) BUG#15536
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw 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.2488 05/12/08 12:33:33 jimw@stripped +5 -0
  Fix calls to free_underlaid_joins() in INSERT, DELETE, and UPDATE
  handling so that indexes are closed before trying to commit the
  transaction. (Bug #15536)

  sql/sql_update.cc
    1.149 05/12/08 12:33:30 jimw@stripped +1 -1
    Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().

  sql/sql_insert.cc
    1.172 05/12/08 12:33:30 jimw@stripped +6 -3
    Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().

  sql/sql_delete.cc
    1.138 05/12/08 12:33:29 jimw@stripped +1 -1
    Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().

  mysql-test/t/bdb.test
    1.41 05/12/08 12:33:29 jimw@stripped +19 -1
    Add new test

  mysql-test/r/bdb.result
    1.44 05/12/08 12:33:29 jimw@stripped +19 -0
    Add new results

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-15536

--- 1.137/sql/sql_delete.cc	2005-09-30 04:21:34 -07:00
+++ 1.138/sql/sql_delete.cc	2005-12-08 12:33:29 -08:00
@@ -241,6 +241,7 @@
     if (!log_delayed)
       thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   }
+  free_underlaid_joins(thd, &thd->lex->select_lex);
   if (transactional_table)
   {
     if (ha_autocommit_or_rollback(thd,error >= 0))
@@ -252,7 +253,6 @@
     mysql_unlock_tables(thd, thd->lock);
     thd->lock=0;
   }
-  free_underlaid_joins(thd, &thd->lex->select_lex);
   if (error >= 0 || thd->net.report_error)
     send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN: 0);
   else

--- 1.171/sql/sql_insert.cc	2005-08-06 19:16:04 -07:00
+++ 1.172/sql/sql_insert.cc	2005-12-08 12:33:30 -08:00
@@ -194,7 +194,7 @@
     runs without --log-update or --log-bin).
   */
   int log_on= DELAYED_LOG_UPDATE | DELAYED_LOG_BIN ;
-  bool transactional_table, log_delayed;
+  bool transactional_table, log_delayed, joins_freed= FALSE;
   uint value_count;
   ulong counter = 1;
   ulonglong id;
@@ -386,6 +386,9 @@
     thd->row_count++;
   }
 
+  free_underlaid_joins(thd, &thd->lex->select_lex);
+  joins_freed= TRUE;
+
   /*
     Now all rows are inserted.  Time to update logs and sends response to
     user
@@ -480,7 +483,6 @@
 	      (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields);
     ::send_ok(thd,info.copied+info.deleted+info.updated,(ulonglong)id,buff);
   }
-  free_underlaid_joins(thd, &thd->lex->select_lex);
   table->insert_values=0;
   DBUG_RETURN(0);
 
@@ -489,7 +491,8 @@
   if (lock_type == TL_WRITE_DELAYED)
     end_delayed_insert(thd);
 #endif
-  free_underlaid_joins(thd, &thd->lex->select_lex);
+  if (!joins_freed)
+    free_underlaid_joins(thd, &thd->lex->select_lex);
   table->insert_values=0;
   DBUG_RETURN(-1);
 }

--- 1.148/sql/sql_update.cc	2005-12-01 12:19:06 -08:00
+++ 1.149/sql/sql_update.cc	2005-12-08 12:33:30 -08:00
@@ -377,6 +377,7 @@
     if (!log_delayed)
       thd->options|=OPTION_STATUS_NO_TRANS_UPDATE;
   }
+  free_underlaid_joins(thd, &thd->lex->select_lex);
   if (transactional_table)
   {
     if (ha_autocommit_or_rollback(thd, error >= 0))
@@ -389,7 +390,6 @@
     thd->lock=0;
   }
 
-  free_underlaid_joins(thd, &thd->lex->select_lex);
   if (error >= 0)
     send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0); /* purecov: inspected */
   else

--- 1.43/mysql-test/r/bdb.result	2004-10-05 08:15:01 -07:00
+++ 1.44/mysql-test/r/bdb.result	2005-12-08 12:33:29 -08:00
@@ -1284,3 +1284,22 @@
 id
 4
 DROP TABLE t1;
+create table t1 (a int, key(a)) engine=bdb;
+create table t2 (b int, key(b)) engine=bdb;
+insert into t1 values (1),(1),(2),(3),(4);
+insert into t2 values (1),(5),(6),(7);
+delete from t1 where (a in (select b from t2));
+select count(*) from t1;
+count(*)
+3
+insert into t1 set a=(select b from t2);
+ERROR 21000: Subquery returns more than 1 row
+select count(*) from t1;
+count(*)
+3
+update t1 set a = a + 1 where (a in (select b from t2));
+select count(*) from t1;
+count(*)
+3
+drop table t1, t2;
+End of 4.1 tests

--- 1.40/mysql-test/t/bdb.test	2005-07-27 17:21:39 -07:00
+++ 1.41/mysql-test/t/bdb.test	2005-12-08 12:33:29 -08:00
@@ -930,4 +930,22 @@
 SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd");
 DROP TABLE t1;
 
-# End of 4.1 tests
+#
+# Bug #15536: Crash when DELETE with subquery using BDB tables
+#
+create table t1 (a int, key(a)) engine=bdb;
+create table t2 (b int, key(b)) engine=bdb;
+insert into t1 values (1),(1),(2),(3),(4);
+insert into t2 values (1),(5),(6),(7);
+delete from t1 where (a in (select b from t2));
+select count(*) from t1;
+# INSERT also blows up
+--error 1242
+insert into t1 set a=(select b from t2);
+select count(*) from t1;
+# UPDATE also blows up
+update t1 set a = a + 1 where (a in (select b from t2));
+select count(*) from t1;
+drop table t1, t2;
+
+--echo End of 4.1 tests
Thread
bk commit into 4.1 tree (jimw:1.2488) BUG#15536Jim Winstead8 Dec