Commit 8f9df08f authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19246 Change database and table used for Mariabackup's history

Changing the mariabackup history table from PERCONA_SCHEMA.xtrabackup_history
to mysql.mariabackup_history.

Additionally, extending xb_history.test for better coverage:

- Recording the fact that the history table is created during
  "mariabackup --history" invocation when it does not exist.

- Recording the history table structure (adding SHOW CREATE TABLE)

- Recording how --history vs --history=foo affect the "name" column
  of the history table.

- Recording the fact that two consequent executions of
  "mariabackup --history[=foo]" insert into the history table
  incrementally, without truncating it on every execution.
parent 16c97187
......@@ -554,7 +554,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn)
(unsigned long)strlen(opt_incremental_history_name));
snprintf(query, sizeof(query),
"SELECT innodb_to_lsn "
"FROM PERCONA_SCHEMA.xtrabackup_history "
"FROM " XB_HISTORY_TABLE " "
"WHERE name = '%s' "
"AND innodb_to_lsn IS NOT NULL "
"ORDER BY innodb_to_lsn DESC LIMIT 1",
......@@ -567,7 +567,7 @@ select_incremental_lsn_from_history(lsn_t *incremental_lsn)
(unsigned long)strlen(opt_incremental_history_uuid));
snprintf(query, sizeof(query),
"SELECT innodb_to_lsn "
"FROM PERCONA_SCHEMA.xtrabackup_history "
"FROM " XB_HISTORY_TABLE " "
"WHERE uuid = '%s' "
"AND innodb_to_lsn IS NOT NULL "
"ORDER BY innodb_to_lsn DESC LIMIT 1",
......@@ -1568,7 +1568,7 @@ operator<<(std::ostream& s, const escape_and_quote& eq)
/*********************************************************************//**
Writes xtrabackup_info file and if backup_history is enable creates
PERCONA_SCHEMA.xtrabackup_history and writes a new history record to the
mysql.mariabackup_history and writes a new history record to the
table containing all the history info particular to the just completed
backup. */
bool
......@@ -1668,9 +1668,7 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
}
xb_mysql_query(connection,
"CREATE DATABASE IF NOT EXISTS PERCONA_SCHEMA", false);
xb_mysql_query(connection,
"CREATE TABLE IF NOT EXISTS PERCONA_SCHEMA.xtrabackup_history("
"CREATE TABLE IF NOT EXISTS " XB_HISTORY_TABLE "("
"uuid VARCHAR(40) NOT NULL PRIMARY KEY,"
"name VARCHAR(255) DEFAULT NULL,"
"tool_name VARCHAR(255) DEFAULT NULL,"
......@@ -1693,7 +1691,7 @@ write_xtrabackup_info(MYSQL *connection, const char * filename, bool history,
#define ESCAPE_BOOL(expr) ((expr)?"'Y'":"'N'")
oss << "insert into PERCONA_SCHEMA.xtrabackup_history("
oss << "insert into " XB_HISTORY_TABLE "("
<< "uuid, name, tool_name, tool_command, tool_version,"
<< "ibbackup_version, server_version, start_time, end_time,"
<< "lock_time, binlog_pos, innodb_from_lsn, innodb_to_lsn,"
......
......@@ -377,7 +377,7 @@ static struct my_option ibx_long_options[] =
{"incremental-history-name", OPT_INCREMENTAL_HISTORY_NAME,
"This option specifies the name of the backup series stored in the "
"PERCONA_SCHEMA.xtrabackup_history history record to base an "
XB_HISTORY_TABLE " history record to base an "
"incremental backup on. Backup will search the history table "
"looking for the most recent (highest innodb_to_lsn), successful "
"backup in the series and take the to_lsn value to use as the "
......@@ -392,7 +392,7 @@ static struct my_option ibx_long_options[] =
{"incremental-history-uuid", OPT_INCREMENTAL_HISTORY_UUID,
"This option specifies the UUID of the specific history record "
"stored in the PERCONA_SCHEMA.xtrabackup_history to base an "
"stored in the " XB_HISTORY_TABLE " table to base an "
"incremental backup on. --incremental-history-name, "
"--incremental-basedir and --incremental-lsn. If no valid lsn can be "
"found (no success record with that uuid), an error will be returned."
......@@ -417,7 +417,7 @@ static struct my_option ibx_long_options[] =
{"history", OPT_HISTORY,
"This option enables the tracking of backup history in the "
"PERCONA_SCHEMA.xtrabackup_history table. An optional history "
XB_HISTORY_TABLE " table. An optional history "
"series name may be specified that will be placed with the history "
"record for the current backup being taken.",
NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
......
......@@ -1352,7 +1352,7 @@ struct my_option xb_client_options[]= {
{"incremental-history-name", OPT_INCREMENTAL_HISTORY_NAME,
"This option specifies the name of the backup series stored in the "
"PERCONA_SCHEMA.xtrabackup_history history record to base an "
XB_HISTORY_TABLE " history record to base an "
"incremental backup on. Xtrabackup will search the history table "
"looking for the most recent (highest innodb_to_lsn), successful "
"backup in the series and take the to_lsn value to use as the "
......@@ -1367,7 +1367,7 @@ struct my_option xb_client_options[]= {
{"incremental-history-uuid", OPT_INCREMENTAL_HISTORY_UUID,
"This option specifies the UUID of the specific history record "
"stored in the PERCONA_SCHEMA.xtrabackup_history to base an "
"stored in the " XB_HISTORY_TABLE " table to base an "
"incremental backup on. --incremental-history-name, "
"--incremental-basedir and --incremental-lsn. If no valid lsn can be "
"found (no success record with that uuid), an error will be returned."
......@@ -1396,7 +1396,7 @@ struct my_option xb_client_options[]= {
{"history", OPT_HISTORY,
"This option enables the tracking of backup history in the "
"PERCONA_SCHEMA.xtrabackup_history table. An optional history "
XB_HISTORY_TABLE " table. An optional history "
"series name may be specified that will be placed with the history "
"record for the current backup being taken.",
NULL, NULL, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
......
......@@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
#include "changed_page_bitmap.h"
#include <set>
#define XB_HISTORY_TABLE "mysql.mariadb_backup_history"
struct xb_delta_info_t
{
xb_delta_info_t(ulint page_size, ulint zip_size, uint32_t space_id)
......
SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history;
DROP TABLE IF EXISTS mysql.mariadb_backup_history;
SHOW CREATE TABLE mysql.mariadb_backup_history;
Table Create Table
mariadb_backup_history CREATE TABLE `mariadb_backup_history` (
`uuid` varchar(40) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`tool_name` varchar(255) DEFAULT NULL,
`tool_command` text DEFAULT NULL,
`tool_version` varchar(255) DEFAULT NULL,
`ibbackup_version` varchar(255) DEFAULT NULL,
`server_version` varchar(255) DEFAULT NULL,
`start_time` timestamp NULL DEFAULT NULL,
`end_time` timestamp NULL DEFAULT NULL,
`lock_time` bigint(20) unsigned DEFAULT NULL,
`binlog_pos` varchar(128) DEFAULT NULL,
`innodb_from_lsn` bigint(20) unsigned DEFAULT NULL,
`innodb_to_lsn` bigint(20) unsigned DEFAULT NULL,
`partial` enum('Y','N') DEFAULT NULL,
`incremental` enum('Y','N') DEFAULT NULL,
`format` enum('file','tar','xbstream') DEFAULT NULL,
`compressed` enum('Y','N') DEFAULT NULL,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3
SELECT COUNT(*) FROM mysql.mariadb_backup_history;
COUNT(*)
1
DROP TABLE PERCONA_SCHEMA.xtrabackup_history;
DROP DATABASE PERCONA_SCHEMA;
SELECT name FROM mysql.mariadb_backup_history;
name
foo
SELECT COUNT(*) FROM mysql.mariadb_backup_history;
COUNT(*)
2
SELECT name FROM mysql.mariadb_backup_history;
name
foo
DROP TABLE mysql.mariadb_backup_history;
#--source include/innodb_page_size.inc
--disable_warnings
DROP TABLE IF EXISTS mysql.mariadb_backup_history;
--enable_warnings
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history=foo --backup --target-dir=$targetdir;
--enable_result_log
SELECT COUNT(*) FROM PERCONA_SCHEMA.xtrabackup_history;
DROP TABLE PERCONA_SCHEMA.xtrabackup_history;
DROP DATABASE PERCONA_SCHEMA;
rmdir $targetdir;
SHOW CREATE TABLE mysql.mariadb_backup_history;
SELECT COUNT(*) FROM mysql.mariadb_backup_history;
SELECT name FROM mysql.mariadb_backup_history;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
--disable_result_log
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --history --backup --target-dir=$targetdir;
--enable_result_log
rmdir $targetdir;
SELECT COUNT(*) FROM mysql.mariadb_backup_history;
SELECT name FROM mysql.mariadb_backup_history;
DROP TABLE mysql.mariadb_backup_history;
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