mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Follow-up to MDEV-13563 mariabackup --lock-ddl-per-table
Fix memory leaks, and add a missing newline to a message.
This commit is contained in:
parent
cfd51c01e1
commit
3f17f51132
1 changed files with 15 additions and 25 deletions
|
@ -1662,6 +1662,7 @@ static void check_mdl_lock_works(const char *table_name)
|
|||
int err_no = mysql_errno(test_con);
|
||||
DBUG_ASSERT(err_no == ER_STATEMENT_TIMEOUT);
|
||||
mysql_close(test_con);
|
||||
free(query);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1671,53 +1672,42 @@ dict_fs2utf8(const char*, char*, size_t, char*, size_t);
|
|||
void
|
||||
mdl_lock_table(ulint space_id)
|
||||
{
|
||||
char *query;
|
||||
static const char q[] = "SELECT NAME "
|
||||
"FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES "
|
||||
"WHERE SPACE = " ULINTPF " AND NAME LIKE '%%/%%'";
|
||||
char query[22 + sizeof q];
|
||||
snprintf(query, sizeof query, q, space_id);
|
||||
|
||||
pthread_mutex_lock(&mdl_lock_con_mutex);
|
||||
|
||||
xb_a(asprintf(&query,
|
||||
"SELECT NAME FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES "
|
||||
"WHERE SPACE = %llu AND NAME LIKE '%%/%%'", (ulonglong)space_id));
|
||||
|
||||
xb_mysql_query(mdl_con, query, true, true);
|
||||
|
||||
MYSQL_RES *mysql_result = xb_mysql_query(mdl_con, query, true);
|
||||
|
||||
MYSQL_ROW row;
|
||||
while ((row = mysql_fetch_row(mysql_result))) {
|
||||
MYSQL_RES *mysql_result = xb_mysql_query(mdl_con, query, true, true);
|
||||
while (MYSQL_ROW row = mysql_fetch_row(mysql_result)) {
|
||||
char full_table_name[2*FN_REFLEN +2];
|
||||
char db_utf8[FN_REFLEN];
|
||||
char table_utf8[FN_REFLEN];
|
||||
static const char lq[] = "SELECT * FROM %s LIMIT 0";
|
||||
char lock_query[sizeof full_table_name + sizeof lq];
|
||||
|
||||
dict_fs2utf8(row[0], db_utf8, sizeof(db_utf8),table_utf8,sizeof(table_utf8));
|
||||
dict_fs2utf8(row[0], db_utf8, sizeof db_utf8,table_utf8,sizeof table_utf8);
|
||||
snprintf(full_table_name,sizeof(full_table_name),"`%s`.`%s`",db_utf8,table_utf8);
|
||||
|
||||
char *lock_query;
|
||||
|
||||
msg_ts("Locking MDL for %s\n", full_table_name);
|
||||
|
||||
xb_a(asprintf(&lock_query,
|
||||
"SELECT * FROM %s LIMIT 0",
|
||||
full_table_name));
|
||||
snprintf(lock_query, sizeof lock_query, lq, full_table_name);
|
||||
|
||||
xb_mysql_query(mdl_con, lock_query, false, false);
|
||||
|
||||
free(lock_query);
|
||||
|
||||
DBUG_EXECUTE_IF("check_mdl_lock_works",
|
||||
check_mdl_lock_works(full_table_name););
|
||||
}
|
||||
|
||||
mysql_free_result(mysql_result);
|
||||
free(query);
|
||||
pthread_mutex_unlock(&mdl_lock_con_mutex);
|
||||
pthread_mutex_unlock(&mdl_lock_con_mutex);
|
||||
mysql_free_result(mysql_result);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mdl_unlock_all()
|
||||
{
|
||||
msg_ts("Unlocking MDL for all tables");
|
||||
msg_ts("Unlocking MDL for all tables\n");
|
||||
xb_mysql_query(mdl_con, "COMMIT", false, true);
|
||||
mysql_close(mdl_con);
|
||||
pthread_mutex_destroy(&mdl_lock_con_mutex);
|
||||
|
|
Loading…
Reference in a new issue