diff options
author | Monty <monty@mariadb.org> | 2021-01-17 16:06:43 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2021-05-19 22:54:13 +0200 |
commit | 6aa9a552c213246d4db6cfce78c75fd4b7f32df5 (patch) | |
tree | ebc124b95681bdbf9631a8f014a41aa5c3b54e63 /storage/maria/ha_maria.cc | |
parent | 7a588c30b19d9ee21be2755d70f7ed7fd3676c4b (diff) | |
download | mariadb-git-6aa9a552c213246d4db6cfce78c75fd4b7f32df5.tar.gz |
MDEV-24576 Atomic CREATE TABLE
There are a few different cases to consider
Logging of CREATE TABLE and CREATE TABLE ... LIKE
- If REPLACE is used and there was an existing table, DDL log the drop of
the table.
- If discovery of table is to be done
- DDL LOG create table
else
- DDL log create table (with engine type)
- create the table
- If table was created
- Log entry to binary log with xid
- Mark DDL log completed
Crash recovery:
- If query was in binary log do nothing and exit
- If discoverted table
- Delete the .frm file
-else
- Drop created table and frm file
- If table was dropped, write a DROP TABLE statement in binary log
CREATE TABLE ... SELECT required a little more work as when one is using
statement logging the query is written to the binary log before commit is
done.
This was fixed by adding a DROP TABLE to the binary log during crash
recovery if the ddl log entry was not closed. In this case the binary log
will contain:
CREATE TABLE xxx ... SELECT ....
DROP TABLE xxx;
Other things:
- Added debug_crash_here() functionality to Aria to be able to test
crash in create table between the creation of the .MAI and the .MAD files.
Diffstat (limited to 'storage/maria/ha_maria.cc')
-rw-r--r-- | storage/maria/ha_maria.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 84c81d9f7b3..d3600e9fc45 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -45,6 +45,7 @@ C_MODE_END #include "key.h" #include "log.h" #include "sql_parse.h" +#include "debug_sync.h" /* Note that in future versions, only *transactional* Maria tables can @@ -996,6 +997,13 @@ my_bool ma_killed_in_mariadb(MARIA_HA *info) return (((TABLE*) (info->external_ref))->in_use->killed != 0); } +void maria_debug_crash_here(const char *keyword) +{ +#ifndef DBUG_OFF + debug_crash_here(keyword); +#endif /* DBUG_OFF */ +} + } /* extern "C" */ /** @@ -3794,6 +3802,7 @@ static int ha_maria_init(void *p) HTON_TRANSACTIONAL_AND_NON_TRANSACTIONAL); bzero(maria_log_pagecache, sizeof(*maria_log_pagecache)); maria_tmpdir= &mysql_tmpdir_list; /* For REDO */ + ma_debug_crash_here= maria_debug_crash_here; if (!aria_readonly) res= maria_upgrade(); |