summaryrefslogtreecommitdiff
path: root/sql/backup.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@mariadb.org>2019-01-14 15:46:49 +0200
committerMichael Widenius <monty@mariadb.org>2019-01-14 16:18:50 +0200
commitaad0165ceab4fa4e756f5fd473ef9df003a447cb (patch)
tree1ed8c68e116b67a51b810e6c8b0c6b408ff23708 /sql/backup.cc
parent3975e22d55834930be7b1939ae9a5d416fa0905a (diff)
downloadmariadb-git-aad0165ceab4fa4e756f5fd473ef9df003a447cb.tar.gz
Added support for BACKUP LOCK / BACKUP UNLOCK
Diffstat (limited to 'sql/backup.cc')
-rw-r--r--sql/backup.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/backup.cc b/sql/backup.cc
index e022a7c2c04..99c18e1260b 100644
--- a/sql/backup.cc
+++ b/sql/backup.cc
@@ -354,3 +354,32 @@ bool backup_reset_alter_copy_lock(THD *thd)
thd->variables.lock_wait_timeout);
return res;
}
+
+
+/*****************************************************************************
+ Backup locks
+ These functions are used by maria_backup to ensure that there are no active
+ ddl's on the object the backup is going to copy
+*****************************************************************************/
+
+
+bool backup_lock(THD *thd, TABLE_LIST *table)
+{
+ backup_unlock(thd);
+ table->mdl_request.duration= MDL_EXPLICIT;
+ if (thd->mdl_context.acquire_lock(&table->mdl_request,
+ thd->variables.lock_wait_timeout))
+ return 1;
+ thd->mdl_backup_lock= table->mdl_request.ticket;
+ return 0;
+}
+
+
+/* Release old backup lock if it exists */
+
+void backup_unlock(THD *thd)
+{
+ if (thd->mdl_backup_lock)
+ thd->mdl_context.release_lock(thd->mdl_backup_lock);
+ thd->mdl_backup_lock= 0;
+}