summaryrefslogtreecommitdiff
path: root/storage/innobase/api/api0api.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-05-06 09:57:39 +0200
committerSergei Golubchik <sergii@pisem.net>2014-05-06 09:57:39 +0200
commite2e5d07b2807706fb9187f00c049474a01ab15da (patch)
tree811b3c4d12a5a75af76fc88d793c3cdb17bf4414 /storage/innobase/api/api0api.cc
parent3792693f311a90cf195ec6d2f9b3762255a249c7 (diff)
parent83759e02dc12c8fb2576e240f307bc789e9c59cd (diff)
downloadmariadb-git-e2e5d07b2807706fb9187f00c049474a01ab15da.tar.gz
MDEV-6184 10.0.11 merge
InnoDB 5.6.16
Diffstat (limited to 'storage/innobase/api/api0api.cc')
-rw-r--r--storage/innobase/api/api0api.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/storage/innobase/api/api0api.cc b/storage/innobase/api/api0api.cc
index d2f1a468f25..c5299156d7a 100644
--- a/storage/innobase/api/api0api.cc
+++ b/storage/innobase/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);
+}