List:Commits« Previous MessageNext Message »
From:konstantin Date:November 1 2007 1:01pm
Subject:bk commit into 5.1 tree (kostja:1.2611) BUG#32030
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kostja. When kostja 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, 2007-11-01 16:01:43+03:00, kostja@bodhi.(none) +3 -0
  A fix for Bug#32030 "DELETE does not return an error and deletes rows if 
  error evaluating WHERE"
  
  DELETE with a subquery in WHERE clause would sometimes ignore subquery
  evaluation error and proceed with deletion.
  
  The fix is to check for an error after evaluation of the WHERE clause
  in DELETE.
  
  The bug is covered by the existing test suite.

  mysql-test/r/group_min_max.result@stripped, 2007-11-01 16:01:39+03:00, kostja@bodhi.(none) +1 -2
    Update the test results to reflect the fix for Bug#32030

  mysql-test/t/group_min_max.test@stripped, 2007-11-01 16:01:39+03:00, kostja@bodhi.(none) +1 -0
    Update the test case to reflect the fix for Bug#32030

  sql/sql_delete.cc@stripped, 2007-11-01 16:01:39+03:00, kostja@bodhi.(none) +11 -5
    Check for an error before calling send_ok(). Two different places are
    covered because the subquery code has slightly different execution
    paths depending on ps-protocol/old-protocol

diff -Nrup a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
--- a/mysql-test/r/group_min_max.result	2007-10-31 09:53:56 +03:00
+++ b/mysql-test/r/group_min_max.result	2007-11-01 16:01:39 +03:00
@@ -2299,8 +2299,7 @@ Handler_read_next	0
 FLUSH STATUS;
 DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x 
 FROM t1) > 10000;
-Warnings:
-Error	1242	Subquery returns more than 1 row
+ERROR 21000: Subquery returns more than 1 row
 SHOW STATUS LIKE 'handler_read__e%';
 Variable_name	Value
 Handler_read_key	8
diff -Nrup a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
--- a/mysql-test/t/group_min_max.test	2007-06-25 06:06:04 +04:00
+++ b/mysql-test/t/group_min_max.test	2007-11-01 16:01:39 +03:00
@@ -890,6 +890,7 @@ FLUSH STATUS;
 DELETE FROM t3 WHERE (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) > 10000;
 SHOW STATUS LIKE 'handler_read__e%';
 FLUSH STATUS;
+--error ER_SUBQUERY_NO_1_ROW
 DELETE FROM t3 WHERE (SELECT (SELECT MAX(b) FROM t1 GROUP BY a HAVING a < 2) x 
                       FROM t1) > 10000;
 SHOW STATUS LIKE 'handler_read__e%';
diff -Nrup a/sql/sql_delete.cc b/sql/sql_delete.cc
--- a/sql/sql_delete.cc	2007-10-30 20:08:12 +03:00
+++ b/sql/sql_delete.cc	2007-11-01 16:01:39 +03:00
@@ -159,13 +159,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *
     delete select;
     free_underlaid_joins(thd, select_lex);
     thd->row_count_func= 0;
-    send_ok(thd, (ha_rows) thd->row_count_func);
+    if (! thd->is_error())
+      send_ok(thd, (ha_rows) thd->row_count_func);
     /*
       We don't need to call reset_auto_increment in this case, because
       mysql_truncate always gives a NULL conds argument, hence we never
       get here.
     */
-    DBUG_RETURN(0);				// Nothing to delete
+    DBUG_RETURN(thd->is_error());                 // Nothing to delete
   }
 
   /* If running in safe sql mode, don't allow updates without keys */
@@ -254,10 +255,15 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   while (!(error=info.read_record(&info)) && !thd->killed &&
 	 ! thd->is_error())
   {
-    // thd->is_error() is tested to disallow delete row on error
-    if (!(select && select->skip_record())&& ! thd->is_error() )
+    bool do_delete_record= !select || !select->skip_record();
+    /* thd->is_error() is tested to disallow delete row on error. */
+    if (thd->is_error())
+    {
+      error= 1;
+      break;
+    }
+    if (do_delete_record)
     {
-
       if (table->triggers &&
           table->triggers->process_triggers(thd, TRG_EVENT_DELETE,
                                             TRG_ACTION_BEFORE, FALSE))
Thread
bk commit into 5.1 tree (kostja:1.2611) BUG#32030konstantin1 Nov