summaryrefslogtreecommitdiff
path: root/storage/xtradb/api
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-05-06 10:21:34 +0200
committerSergei Golubchik <sergii@pisem.net>2014-05-06 10:21:34 +0200
commitb968363aac2bf75d014482f8405e6a9fed73ccd6 (patch)
tree7f2aa9432e293ffe4dfcc772c06991d0b604ca24 /storage/xtradb/api
parente2e5d07b2807706fb9187f00c049474a01ab15da (diff)
parent05fd3e63665597d3bcdf1094bb111df014087936 (diff)
downloadmariadb-git-b968363aac2bf75d014482f8405e6a9fed73ccd6.tar.gz
MDEV-6184 10.0.11 merge
XtraDB 5.6.16-64.2
Diffstat (limited to 'storage/xtradb/api')
-rw-r--r--storage/xtradb/api/api0api.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/storage/xtradb/api/api0api.cc b/storage/xtradb/api/api0api.cc
index d2f1a468f25..c5299156d7a 100644
--- a/storage/xtradb/api/api0api.cc
+++ b/storage/xtradb/api/api0api.cc
@@ -3870,6 +3870,7 @@ ib_table_truncate(
ib_err_t trunc_err;
ib_trx_t ib_trx = NULL;
ib_crsr_t ib_crsr = NULL;
+ ib_ulint_t memcached_sync = 0;
ib_trx = ib_trx_begin(IB_TRX_SERIALIZABLE, true, false);
@@ -3885,6 +3886,13 @@ ib_table_truncate(
err = DB_TABLE_NOT_FOUND;
}
+ /* Remember the memcached_sync_count and set it to 0, so the
+ truncate can be executed. */
+ if (table != NULL && err == DB_SUCCESS) {
+ memcached_sync = table->memcached_sync_count;
+ table->memcached_sync_count = 0;
+ }
+
dict_mutex_exit_for_mysql();
if (err == DB_SUCCESS) {
@@ -3910,6 +3918,15 @@ ib_table_truncate(
ut_a(err == DB_SUCCESS);
}
+ /* Set the memcached_sync_count back. */
+ if (table != NULL && memcached_sync != 0) {
+ dict_mutex_enter_for_mysql();
+
+ table->memcached_sync_count = memcached_sync;
+
+ dict_mutex_exit_for_mysql();
+ }
+
return(trunc_err);
}
@@ -3972,3 +3989,51 @@ ib_cfg_get_cfg()
return(cfg_status);
}
+
+/*****************************************************************//**
+Increase/decrease the memcached sync count of table to sync memcached
+DML with SQL DDLs.
+@return DB_SUCCESS or error number */
+UNIV_INTERN
+ib_err_t
+ib_cursor_set_memcached_sync(
+/*=========================*/
+ ib_crsr_t ib_crsr, /*!< in: cursor */
+ ib_bool_t flag) /*!< in: true for increase */
+{
+ const ib_cursor_t* cursor = (const ib_cursor_t*) ib_crsr;
+ row_prebuilt_t* prebuilt = cursor->prebuilt;
+ dict_table_t* table = prebuilt->table;
+ ib_err_t err = DB_SUCCESS;
+
+ if (table != NULL) {
+ /* If memcached_sync_count is -1, means table is
+ doing DDL, we just return error. */
+ if (table->memcached_sync_count == DICT_TABLE_IN_DDL) {
+ return(DB_ERROR);
+ }
+
+ if (flag) {
+#ifdef HAVE_ATOMIC_BUILTINS
+ os_atomic_increment_lint(&table->memcached_sync_count, 1);
+#else
+ dict_mutex_enter_for_mysql();
+ ++table->memcached_sync_count;
+ dict_mutex_exit_for_mysql();
+#endif
+ } else {
+#ifdef HAVE_ATOMIC_BUILTINS
+ os_atomic_decrement_lint(&table->memcached_sync_count, 1);
+#else
+ dict_mutex_enter_for_mysql();
+ --table->memcached_sync_count;
+ dict_mutex_exit_for_mysql();
+#endif
+ ut_a(table->memcached_sync_count >= 0);
+ }
+ } else {
+ err = DB_TABLE_NOT_FOUND;
+ }
+
+ return(err);
+}