Commit 0237e9bb authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26041 Recovery failure due to delete-marked SYS_FIELDS record

trx_t::drop_table(): Delete-mark the SYS_TABLES and SYS_INDEXES
record before delete-marking any SYS_COLUMNS or SYS_FIELDS records.
Otherwise, dict_load_indexes() could fail on recovery. This fixes up
commit 1bd681c8 (MDEV-25506).
parent e04bbf73
...@@ -205,18 +205,19 @@ dberr_t trx_t::drop_table(const dict_table_t &table) ...@@ -205,18 +205,19 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
"WHERE TABLE_ID=:id FOR UPDATE;\n" "WHERE TABLE_ID=:id FOR UPDATE;\n"
"BEGIN\n" "BEGIN\n"
"DELETE FROM SYS_TABLES WHERE ID=:id;\n"
"DELETE FROM SYS_COLUMNS WHERE TABLE_ID=:id;\n"
"OPEN idx;\n" "OPEN idx;\n"
"WHILE 1 = 1 LOOP\n" "WHILE 1 = 1 LOOP\n"
" FETCH idx INTO iid;\n" " FETCH idx INTO iid;\n"
" IF (SQL % NOTFOUND) THEN EXIT; END IF;\n" " IF (SQL % NOTFOUND) THEN EXIT; END IF;\n"
" DELETE FROM SYS_FIELDS WHERE INDEX_ID=iid;\n"
" DELETE FROM SYS_INDEXES WHERE CURRENT OF idx;\n" " DELETE FROM SYS_INDEXES WHERE CURRENT OF idx;\n"
" DELETE FROM SYS_FIELDS WHERE INDEX_ID=iid;\n"
"END LOOP;\n" "END LOOP;\n"
"CLOSE idx;\n" "CLOSE idx;\n"
"DELETE FROM SYS_COLUMNS WHERE TABLE_ID=:id;\n"
"DELETE FROM SYS_TABLES WHERE ID=:id;\n"
"END;\n", FALSE, this); "END;\n", FALSE, this);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment