List:Commits« Previous MessageNext Message »
From:Martin Skold Date:February 27 2007 10:34am
Subject:bk commit into 5.1 tree (mskold:1.2432)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty 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-02-27 11:34:07+01:00, mskold@stripped +8 -0
  Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.0
  into  mysql.com:/windows/Linux_space/MySQL/mysql-5.1
  MERGE: 1.1810.2399.18

  include/my_base.h@stripped, 2007-02-27 11:34:02+01:00, mskold@stripped +3 -4
    Merge
    MERGE: 1.70.5.1

  mysql-test/r/ndb_trigger.result@stripped, 2007-02-27 11:20:56+01:00, mskold@stripped +0 -56
    Using local, will re-generate.
    MERGE: 1.1.1.1

  mysql-test/t/ndb_trigger.test@stripped, 2007-02-27 11:34:02+01:00, mskold@stripped +0 -2
    Merge
    MERGE: 1.1.1.1

  sql/ha_ndbcluster.cc@stripped, 2007-02-27 11:34:02+01:00, mskold@stripped +4 -6
    Merge
    MERGE: 1.175.61.12

  sql/ha_ndbcluster.h@stripped, 2007-02-27 11:18:24+01:00, mskold@stripped +0 -0
    Auto merged
    MERGE: 1.82.6.3

  sql/sql_delete.cc@stripped, 2007-02-27 11:34:02+01:00, mskold@stripped +7 -13
    Merge
    MERGE: 1.144.21.1

  sql/sql_trigger.h@stripped, 2007-02-27 11:18:25+01:00, mskold@stripped +0 -0
    Auto merged
    MERGE: 1.19.4.1

  sql/sql_update.cc@stripped, 2007-02-27 11:34:02+01:00, mskold@stripped +7 -20
    Merge
    MERGE: 1.154.25.2

# 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:	mskold
# Host:	linux.site
# Root:	/windows/Linux_space/MySQL/mysql-5.1/RESYNC

--- 1.95/include/my_base.h	2007-02-27 11:34:18 +01:00
+++ 1.96/include/my_base.h	2007-02-27 11:34:18 +01:00
@@ -171,7 +171,9 @@ enum ha_extra_function {
     Off by default.
   */
   HA_EXTRA_WRITE_CAN_REPLACE,
-  HA_EXTRA_WRITE_CANNOT_REPLACE
+  HA_EXTRA_WRITE_CANNOT_REPLACE,
+  HA_EXTRA_DELETE_CANNOT_BATCH,
+  HA_EXTRA_UPDATE_CANNOT_BATCH
 };
 
 	/* The following is parameter to ha_panic() */

--- 1.208/sql/sql_delete.cc	2007-02-27 11:34:18 +01:00
+++ 1.209/sql/sql_delete.cc	2007-02-27 11:34:18 +01:00
@@ -216,10 +216,15 @@ bool mysql_delete(THD *thd, TABLE_LIST *
 
   init_ftfuncs(thd, select_lex, 1);
   thd->proc_info="updating";
-  will_batch= !table->file->start_bulk_delete();
-
-
-  table->mark_columns_needed_for_delete();
+  if (table->triggers && table->triggers->has_triggers(TRG_EVENT_DELETE,
+				                       TRG_ACTION_AFTER))
+  {
+    /*
+      The table table has AFTER DELETE triggers that need delete
+      to be done immediately, no batching is possible
+    */
+    (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+  }
 
   while (!(error=info.read_record(&info)) && !thd->killed &&
 	 !thd->net.report_error)

--- 1.222/sql/sql_update.cc	2007-02-27 11:34:18 +01:00
+++ 1.223/sql/sql_update.cc	2007-02-27 11:34:18 +01:00
@@ -447,17 +447,15 @@ int mysql_update(THD *thd,
                               (thd->variables.sql_mode &
                                (MODE_STRICT_TRANS_TABLES |
                                 MODE_STRICT_ALL_TABLES)));
-  will_batch= !table->file->start_bulk_update();
-
-  /*
-    We can use compare_record() to optimize away updates if
-    the table handler is returning all columns OR if
-    if all updated columns are read
-  */
-  can_compare_record= (!(table->file->ha_table_flags() &
-                         HA_PARTIAL_COLUMN_READ) ||
-                       bitmap_is_subset(table->write_set, table->read_set));
-
+  if (table->triggers && table->triggers->has_triggers(TRG_EVENT_UPDATE,
+				                       TRG_ACTION_AFTER))
+  {
+    /*
+      The table table has AFTER UPDATE triggers that need update
+      to be done immediately, no batching is possible
+    */
+    (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+  }
   while (!(error=info.read_record(&info)) && !thd->killed)
   {
     if (!(select && select->skip_record()))

--- 1.2/mysql-test/t/ndb_trigger.test	2007-02-27 11:34:18 +01:00
+++ 1.3/mysql-test/t/ndb_trigger.test	2007-02-27 11:34:18 +01:00
@@ -110,5 +110,56 @@ drop trigger t4_au;
 drop trigger t4_ad;
 
 drop table t1, t2, t3, t4, t5;
+# Test for bug#26242
+# Verify that AFTER UPDATE/DELETE triggers are executed
+# after the change has actually taken place
+
+CREATE TABLE t1 (
+  id INT NOT NULL PRIMARY KEY,
+  xy INT
+) ENGINE=ndbcluster;
+
+INSERT INTO t1 VALUES (1, 0);
+
+DELIMITER //;
+CREATE TRIGGER t1_update AFTER UPDATE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id = NEW.id; END //
+DELIMITER ;//
+
+CREATE TABLE t2 (
+  id INT NOT NULL PRIMARY KEY,
+  xy INT
+) ENGINE=ndbcluster;
+
+INSERT INTO t2 VALUES (2, 0);
+
+CREATE TABLE t3 (id INT NOT NULL PRIMARY KEY) ENGINE=ndbcluster;
+
+INSERT INTO t3 VALUES (1);
+
+UPDATE t1 SET xy = 3 WHERE id = 1;
+SELECT xy FROM t1 where id = 1;
+SELECT xy FROM t2 where id = 1;
+
+UPDATE t1 SET xy  = 4 WHERE id IN (SELECT id FROM t3 WHERE id = 1);
+SELECT xy FROM t1 where id = 1;
+SELECT xy FROM t2 where id = 1;
+
+DROP TRIGGER t1_update;
+
+DELIMITER //;
+CREATE TRIGGER t1_delete AFTER DELETE ON t1 FOR EACH ROW BEGIN REPLACE INTO t2 SELECT * FROM t1 WHERE t1.id > 4; END //
+DELIMITER ;//
+
+INSERT INTO t1 VALUES (5, 0),(6,0);
+INSERT INTO t2 VALUES (5, 1),(6,1);
+INSERT INTO t3 VALUES (5);
+SELECT * FROM t1 order by id;
+SELECT * FROM t2 order by id;
+DELETE FROM t1 WHERE id IN (SELECT id FROM t3 WHERE id = 5);
+SELECT * FROM t1 order by id;
+SELECT * FROM t2 order by id;
+
+
+DROP TRIGGER t1_delete;
+DROP TABLE t1, t2, t3;
 
---echo End of 5.1 tests

--- 1.26/sql/sql_trigger.h	2007-02-27 11:34:18 +01:00
+++ 1.27/sql/sql_trigger.h	2007-02-27 11:34:18 +01:00
@@ -110,6 +110,11 @@ public:
                                 const char *old_table,
                                 const char *new_db,
                                 const char *new_table);
+  bool has_triggers(trg_event_type event_type, 
+		    trg_action_time_type action_time)
+  {
+    return (bodies[event_type][action_time]);
+  }
   bool has_delete_triggers()
   {
     return (bodies[TRG_EVENT_DELETE][TRG_ACTION_BEFORE] ||

--- 1.406/sql/ha_ndbcluster.cc	2007-02-27 11:34:18 +01:00
+++ 1.407/sql/ha_ndbcluster.cc	2007-02-27 11:34:18 +01:00
@@ -2992,8 +2992,11 @@ int ha_ndbcluster::update_row(const byte
       no_fields++;
     op->setValue(no_fields, part_func_value);
   }
-  // Execute update operation
-  if (!cursor && execute_no_commit(this,trans,FALSE) != 0) {
+  // Execute update operation if we are not doing a scan for update
+  // and there exist UPDATE AFTER triggers
+
+  if ((!cursor || m_update_cannot_batch) && 
+      execute_no_commit(this,trans,FALSE) != 0) {
     no_uncommitted_rows_execute_failure();
     DBUG_RETURN(ndb_err(trans));
   }
@@ -3047,7 +3050,7 @@ int ha_ndbcluster::delete_row(const byte
 
     no_uncommitted_rows_update(-1);
 
-    if (!m_primary_key_update)
+    if (!(m_primary_key_update || m_delete_cannot_batch))
       // If deleting from cursor, NoCommit will be handled in next_result
       DBUG_RETURN(0);
   }
@@ -3886,6 +3889,13 @@ int ha_ndbcluster::extra(enum ha_extra_f
     DBUG_PRINT("info", ("Turning OFF use of write instead of insert"));
     m_use_write= FALSE;
     break;
+  case HA_EXTRA_DELETE_CANNOT_BATCH:
+    DBUG_PRINT("info", ("HA_EXTRA_DELETE_CANNOT_BATCH"));
+    m_delete_cannot_batch= TRUE;
+    break;
+  case HA_EXTRA_UPDATE_CANNOT_BATCH:
+    DBUG_PRINT("info", ("HA_EXTRA_UPDATE_CANNOT_BATCH"));
+    m_update_cannot_batch= TRUE;
   default:
     break;
   }
@@ -3905,6 +3915,8 @@ int ha_ndbcluster::reset()
   */
   if (m_part_info)
     bitmap_set_all(&m_part_info->used_partitions);
+  m_delete_cannot_batch= FALSE;
+  m_update_cannot_batch= FALSE;
   DBUG_RETURN(0);
 }
 
@@ -5826,6 +5838,8 @@ ha_ndbcluster::ha_ndbcluster(handlerton 
   m_bulk_insert_rows((ha_rows) 1024),
   m_rows_changed((ha_rows) 0),
   m_bulk_insert_not_flushed(FALSE),
+  m_delete_cannot_batch(FALSE),
+  m_update_cannot_batch(FALSE),
   m_ops_pending(0),
   m_skip_auto_increment(TRUE),
   m_blobs_pending(0),

--- 1.168/sql/ha_ndbcluster.h	2007-02-27 11:34:18 +01:00
+++ 1.169/sql/ha_ndbcluster.h	2007-02-27 11:34:18 +01:00
@@ -960,6 +960,8 @@ private:
   ha_rows m_bulk_insert_rows;
   ha_rows m_rows_changed;
   bool m_bulk_insert_not_flushed;
+  bool m_delete_cannot_batch;
+  bool m_update_cannot_batch;
   ha_rows m_ops_pending;
   bool m_skip_auto_increment;
   bool m_blobs_pending;
Thread
bk commit into 5.1 tree (mskold:1.2432)Martin Skold27 Feb