mirror of
https://github.com/MariaDB/server.git
synced 2025-12-12 08:01:43 +03:00
Use bound literals in row_discard_tablespace_for_mysql.
This commit is contained in:
@@ -2384,11 +2384,9 @@ row_discard_tablespace_for_mysql(
|
|||||||
dict_foreign_t* foreign;
|
dict_foreign_t* foreign;
|
||||||
dulint new_id;
|
dulint new_id;
|
||||||
dict_table_t* table;
|
dict_table_t* table;
|
||||||
que_thr_t* thr;
|
|
||||||
que_t* graph = NULL;
|
|
||||||
ibool success;
|
ibool success;
|
||||||
ulint err;
|
ulint err;
|
||||||
char* buf;
|
pars_info_t* info = NULL;
|
||||||
|
|
||||||
/* How do we prevent crashes caused by ongoing operations on the table? Old
|
/* How do we prevent crashes caused by ongoing operations on the table? Old
|
||||||
operations could try to access non-existent pages.
|
operations could try to access non-existent pages.
|
||||||
@@ -2410,36 +2408,6 @@ discard ongoing operations.
|
|||||||
5) FOREIGN KEY operations: if table->n_foreign_key_checks_running > 0, we
|
5) FOREIGN KEY operations: if table->n_foreign_key_checks_running > 0, we
|
||||||
do not allow the discard. We also reserve the data dictionary latch. */
|
do not allow the discard. We also reserve the data dictionary latch. */
|
||||||
|
|
||||||
static const char discard_tablespace_proc1[] =
|
|
||||||
"PROCEDURE DISCARD_TABLESPACE_PROC () IS\n"
|
|
||||||
"old_id CHAR;\n"
|
|
||||||
"new_id CHAR;\n"
|
|
||||||
"new_id_low INT;\n"
|
|
||||||
"new_id_high INT;\n"
|
|
||||||
"table_name CHAR;\n"
|
|
||||||
"BEGIN\n"
|
|
||||||
"table_name := '";
|
|
||||||
static const char discard_tablespace_proc2[] =
|
|
||||||
"';\n"
|
|
||||||
"new_id_high := %lu;\n"
|
|
||||||
"new_id_low := %lu;\n"
|
|
||||||
"new_id := CONCAT(TO_BINARY(new_id_high, 4), TO_BINARY(new_id_low, 4));\n"
|
|
||||||
"SELECT ID INTO old_id\n"
|
|
||||||
"FROM SYS_TABLES\n"
|
|
||||||
"WHERE NAME = table_name;\n"
|
|
||||||
"IF (SQL %% NOTFOUND) THEN\n"
|
|
||||||
" COMMIT WORK;\n"
|
|
||||||
" RETURN;\n"
|
|
||||||
"END IF;\n"
|
|
||||||
"UPDATE SYS_TABLES SET ID = new_id\n"
|
|
||||||
"WHERE ID = old_id;\n"
|
|
||||||
"UPDATE SYS_COLUMNS SET TABLE_ID = new_id\n"
|
|
||||||
"WHERE TABLE_ID = old_id;\n"
|
|
||||||
"UPDATE SYS_INDEXES SET TABLE_ID = new_id\n"
|
|
||||||
"WHERE TABLE_ID = old_id;\n"
|
|
||||||
"COMMIT WORK;\n"
|
|
||||||
"END;\n";
|
|
||||||
|
|
||||||
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
|
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
|
||||||
|
|
||||||
trx->op_info = "discarding tablespace";
|
trx->op_info = "discarding tablespace";
|
||||||
@@ -2519,35 +2487,34 @@ do not allow the discard. We also reserve the data dictionary latch. */
|
|||||||
|
|
||||||
new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
|
new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
|
||||||
|
|
||||||
buf = mem_alloc((sizeof discard_tablespace_proc1) +
|
|
||||||
(sizeof discard_tablespace_proc2) +
|
|
||||||
20 + ut_strlenq(name, '\''));
|
|
||||||
|
|
||||||
memcpy(buf, discard_tablespace_proc1, sizeof discard_tablespace_proc1);
|
|
||||||
sprintf(ut_strcpyq(buf + (sizeof discard_tablespace_proc1 - 1),
|
|
||||||
'\'', name),
|
|
||||||
discard_tablespace_proc2,
|
|
||||||
(ulong) ut_dulint_get_high(new_id),
|
|
||||||
(ulong) ut_dulint_get_low(new_id));
|
|
||||||
|
|
||||||
graph = pars_sql(NULL, buf);
|
|
||||||
|
|
||||||
ut_a(graph);
|
|
||||||
|
|
||||||
/* Remove any locks there are on the table or its records */
|
/* Remove any locks there are on the table or its records */
|
||||||
|
|
||||||
lock_reset_all_on_table(table);
|
lock_reset_all_on_table(table);
|
||||||
|
|
||||||
graph->trx = trx;
|
info = pars_info_create();
|
||||||
trx->graph = NULL;
|
|
||||||
|
|
||||||
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
|
pars_info_add_str_literal(info, "table_name", name);
|
||||||
|
pars_info_add_dulint_literal(info, "new_id", new_id);
|
||||||
|
|
||||||
ut_a(thr = que_fork_start_command(graph));
|
err = que_eval_sql(info,
|
||||||
|
"PROCEDURE DISCARD_TABLESPACE_PROC () IS\n"
|
||||||
que_run_threads(thr);
|
"old_id CHAR;\n"
|
||||||
|
"BEGIN\n"
|
||||||
err = trx->error_state;
|
"SELECT ID INTO old_id\n"
|
||||||
|
"FROM SYS_TABLES\n"
|
||||||
|
"WHERE NAME = :table_name;\n"
|
||||||
|
"IF (SQL % NOTFOUND) THEN\n"
|
||||||
|
" COMMIT WORK;\n"
|
||||||
|
" RETURN;\n"
|
||||||
|
"END IF;\n"
|
||||||
|
"UPDATE SYS_TABLES SET ID = :new_id\n"
|
||||||
|
" WHERE ID = old_id;\n"
|
||||||
|
"UPDATE SYS_COLUMNS SET TABLE_ID = :new_id\n"
|
||||||
|
" WHERE TABLE_ID = old_id;\n"
|
||||||
|
"UPDATE SYS_INDEXES SET TABLE_ID = :new_id\n"
|
||||||
|
" WHERE TABLE_ID = old_id;\n"
|
||||||
|
"COMMIT WORK;\n"
|
||||||
|
"END;\n"
|
||||||
|
, trx);
|
||||||
|
|
||||||
if (err != DB_SUCCESS) {
|
if (err != DB_SUCCESS) {
|
||||||
trx->error_state = DB_SUCCESS;
|
trx->error_state = DB_SUCCESS;
|
||||||
@@ -2571,13 +2538,10 @@ do not allow the discard. We also reserve the data dictionary latch. */
|
|||||||
table->ibd_file_missing = TRUE;
|
table->ibd_file_missing = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
funct_exit:
|
funct_exit:
|
||||||
row_mysql_unlock_data_dictionary(trx);
|
row_mysql_unlock_data_dictionary(trx);
|
||||||
|
|
||||||
if (graph) {
|
|
||||||
que_graph_free(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
trx_commit_for_mysql(trx);
|
trx_commit_for_mysql(trx);
|
||||||
|
|
||||||
trx->op_info = "";
|
trx->op_info = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user