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-04-04 17:03:31+02:00, mskold@stripped +9 -0
Merge mysql.com:/windows/Linux_space/MySQL/mysql-5.1
into mysql.com:/windows/Linux_space/MySQL/mysql-5.1-new-ndb
MERGE: 1.2409.28.5
include/my_base.h@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.95.2.1
sql/ha_ndbcluster.cc@stripped, 2007-04-04 17:03:27+02:00, mskold@stripped +1 -1
Merge
MERGE: 1.405.1.2
sql/ha_ndbcluster.h@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.165.4.1
sql/mysql_priv.h@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.470.16.2
sql/sql_delete.cc@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.208.1.1
sql/sql_insert.cc@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.244.1.2
sql/sql_load.cc@stripped, 2007-04-04 17:01:45+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.114.3.2
sql/sql_trigger.h@stripped, 2007-04-04 17:01:46+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.26.1.1
sql/sql_update.cc@stripped, 2007-04-04 17:01:46+02:00, mskold@stripped +0 -0
Auto merged
MERGE: 1.222.1.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-new-ndb/RESYNC
--- 1.98/include/my_base.h 2007-04-04 17:03:44 +02:00
+++ 1.99/include/my_base.h 2007-04-04 17:03:44 +02:00
@@ -172,7 +172,15 @@ enum ha_extra_function {
Off by default.
*/
HA_EXTRA_WRITE_CAN_REPLACE,
- HA_EXTRA_WRITE_CANNOT_REPLACE
+ HA_EXTRA_WRITE_CANNOT_REPLACE,
+ /*
+ Inform handler that delete_row()/update_row() cannot batch deletes/updates
+ and should perform them immediately. This may be needed when table has
+ AFTER DELETE/UPDATE triggers which access to subject table.
+ These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
+ */
+ HA_EXTRA_DELETE_CANNOT_BATCH,
+ HA_EXTRA_UPDATE_CANNOT_BATCH
};
/* The following is parameter to ha_panic() */
--- 1.492/sql/mysql_priv.h 2007-04-04 17:03:44 +02:00
+++ 1.493/sql/mysql_priv.h 2007-04-04 17:03:44 +02:00
@@ -1007,6 +1007,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
bool ignore);
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
TABLE_LIST *table_list);
+void prepare_triggers_for_insert_stmt(TABLE *table);
bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
SQL_LIST *order, ha_rows rows, ulonglong options,
--- 1.212/sql/sql_delete.cc 2007-04-04 17:03:44 +02:00
+++ 1.213/sql/sql_delete.cc 2007-04-04 17:03:44 +02:00
@@ -221,7 +221,20 @@ bool mysql_delete(THD *thd, TABLE_LIST *
init_ftfuncs(thd, select_lex, 1);
thd->proc_info="updating";
- will_batch= !table->file->start_bulk_delete();
+ if (table->triggers &&
+ table->triggers->has_triggers(TRG_EVENT_DELETE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER DELETE triggers that might access to subject table
+ and therefore might need delete to be done immediately. So we turn-off
+ the batching.
+ */
+ (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+ will_batch= FALSE;
+ }
+ else
+ will_batch= !table->file->start_bulk_delete();
table->mark_columns_needed_for_delete();
@@ -563,6 +576,17 @@ multi_delete::initialize_tables(JOIN *jo
transactional_tables= 1;
else
normal_tables= 1;
+ if (tbl->triggers &&
+ tbl->triggers->has_triggers(TRG_EVENT_DELETE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER DELETE triggers that might access to subject
+ table and therefore might need delete to be done immediately.
+ So we turn-off the batching.
+ */
+ (void) tbl->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+ }
tbl->prepare_for_position();
tbl->mark_columns_needed_for_delete();
}
--- 1.257/sql/sql_insert.cc 2007-04-04 17:03:44 +02:00
+++ 1.258/sql/sql_insert.cc 2007-04-04 17:03:44 +02:00
@@ -341,6 +341,47 @@ static int check_update_fields(THD *thd,
return 0;
}
+/*
+ Prepare triggers for INSERT-like statement.
+
+ SYNOPSIS
+ prepare_triggers_for_insert_stmt()
+ table Table to which insert will happen
+
+ NOTE
+ Prepare triggers for INSERT-like statement by marking fields
+ used by triggers and inform handlers that batching of UPDATE/DELETE
+ cannot be done if there are BEFORE UPDATE/DELETE triggers.
+*/
+
+void prepare_triggers_for_insert_stmt(TABLE *table)
+{
+ if (table->triggers)
+ {
+ if (table->triggers->has_triggers(TRG_EVENT_DELETE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER DELETE triggers that might access to
+ subject table and therefore might need delete to be done
+ immediately. So we turn-off the batching.
+ */
+ (void) table->file->extra(HA_EXTRA_DELETE_CANNOT_BATCH);
+ }
+ if (table->triggers->has_triggers(TRG_EVENT_UPDATE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER UPDATE triggers that might access to subject
+ table and therefore might need update to be done immediately.
+ So we turn-off the batching.
+ */
+ (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+ }
+ }
+ table->mark_columns_needed_for_insert();
+}
+
bool mysql_insert(THD *thd,TABLE_LIST *table_list,
List<Item> &fields,
@@ -575,7 +616,8 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
- table->mark_columns_needed_for_insert();
+ prepare_triggers_for_insert_stmt(table);
+
if (table_list->prepare_where(thd, 0, TRUE) ||
table_list->prepare_check_option(thd))
@@ -2646,7 +2688,7 @@ select_insert::prepare(List<Item> &value
table_list->prepare_check_option(thd));
if (!res)
- table->mark_columns_needed_for_insert();
+ prepare_triggers_for_insert_stmt(table);
DBUG_RETURN(res);
}
--- 1.120/sql/sql_load.cc 2007-04-04 17:03:44 +02:00
+++ 1.121/sql/sql_load.cc 2007-04-04 17:03:44 +02:00
@@ -226,7 +226,7 @@ bool mysql_load(THD *thd,sql_exchange *e
DBUG_RETURN(TRUE);
}
- table->mark_columns_needed_for_insert();
+ prepare_triggers_for_insert_stmt(table);
uint tot_length=0;
bool use_blobs= 0, use_vars= 0;
--- 1.233/sql/sql_update.cc 2007-04-04 17:03:44 +02:00
+++ 1.234/sql/sql_update.cc 2007-04-04 17:03:44 +02:00
@@ -452,7 +452,20 @@ int mysql_update(THD *thd,
(thd->variables.sql_mode &
(MODE_STRICT_TRANS_TABLES |
MODE_STRICT_ALL_TABLES)));
- will_batch= !table->file->start_bulk_update();
+ if (table->triggers &&
+ table->triggers->has_triggers(TRG_EVENT_UPDATE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER UPDATE triggers that might access to subject
+ table and therefore might need update to be done immediately.
+ So we turn-off the batching.
+ */
+ (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+ will_batch= FALSE;
+ }
+ else
+ will_batch= !table->file->start_bulk_update();
/*
We can use compare_record() to optimize away updates if
@@ -1121,6 +1134,17 @@ int multi_update::prepare(List<Item> &no
table->no_keyread=1;
table->covering_keys.clear_all();
table->pos_in_table_list= tl;
+ if (table->triggers &&
+ table->triggers->has_triggers(TRG_EVENT_UPDATE,
+ TRG_ACTION_AFTER))
+ {
+ /*
+ The table has AFTER UPDATE triggers that might access to subject
+ table and therefore might need update to be done immediately.
+ So we turn-off the batching.
+ */
+ (void) table->file->extra(HA_EXTRA_UPDATE_CANNOT_BATCH);
+ }
}
}
--- 1.27/sql/sql_trigger.h 2007-04-04 17:03:44 +02:00
+++ 1.28/sql/sql_trigger.h 2007-04-04 17:03:44 +02: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.433/sql/ha_ndbcluster.cc 2007-04-04 17:03:44 +02:00
+++ 1.434/sql/ha_ndbcluster.cc 2007-04-04 17:03:44 +02:00
@@ -2999,8 +2999,13 @@ int ha_ndbcluster::update_row(const byte
if (thd->slave_thread)
op->setAnyValue(thd->server_id);
- // 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));
}
@@ -3057,7 +3062,7 @@ int ha_ndbcluster::delete_row(const byte
if (thd->slave_thread)
((NdbOperation *)trans->getLastDefinedOperation())->setAnyValue(thd->server_id);
- 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);
}
@@ -3902,7 +3907,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;
- default:
+ 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;
break;
}
@@ -3913,6 +3924,8 @@ int ha_ndbcluster::extra(enum ha_extra_f
int ha_ndbcluster::reset()
{
DBUG_ENTER("ha_ndbcluster::reset");
+ m_delete_cannot_batch= FALSE;
+ m_update_cannot_batch= FALSE;
cond_clear();
/*
Regular partition pruning will set the bitmap appropriately.
@@ -5922,6 +5935,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.173/sql/ha_ndbcluster.h 2007-04-04 17:03:44 +02:00
+++ 1.174/sql/ha_ndbcluster.h 2007-04-04 17:03:44 +02:00
@@ -964,6 +964,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.2547) | Martin Skold | 4 Apr |