mariadb/mysql-test/main/backup_syntax.test
Monty c53aab974b Added syntax and implementation for BACKUP STAGE's
Part of MDEV-5336 Implement LOCK FOR BACKUP

- Changed check of Global_only_lock to also include BACKUP lock.
- We store latest MDL_BACKUP_DDL lock in thd->mdl_backup_ticket to be able
  to downgrade lock during copy_data_between_tables()
2018-12-09 22:12:27 +02:00

181 lines
4.5 KiB
Text

########################################################################
# Tests things releated to syntax of BACKUP STAGE (MDEV-5336)
########################################################################
--source include/have_innodb.inc
--source include/have_metadata_lock_info.inc
--echo #-----------------------------------------------------------------------
--echo # Basic syntax checks
--echo #-----------------------------------------------------------------------
--echo # Check existing BACKUP STAGE statements in the sequence to be used.
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo # Check invalid variants of BACKUP .... syntax.
--error ER_PARSE_ERROR
BACKUP LOG;
--error ER_PARSE_ERROR
BACKUP LOCK;
--error ER_PARSE_ERROR
BACKUP STAGE;
--error ER_PARSE_ERROR
BACKUP STAGE LOCK;
--error ER_BACKUP_UNKNOWN_STAGE
BACKUP STAGE not_existing;
--echo #-----------------------------------------------------------------------
--echo # BACKUP STAGE statements in various orders.
--echo #-----------------------------------------------------------------------
--echo # All BACKUP STAGE statements != 'BACKUP STAGE START' expect that a
--echo # backup lock (generated by BACKUP STAGE START) already exists.
--echo #
backup stage start;
backup stage flush;
--error ER_BACKUP_WRONG_STAGE
backup stage start;
--error ER_BACKUP_WRONG_STAGE
backup stage start;
backup stage block_commit;
--error ER_BACKUP_WRONG_STAGE
backup stage flush;
--error ER_BACKUP_WRONG_STAGE
backup stage flush;
backup stage end;
--error ER_BACKUP_NOT_RUNNING
backup stage flush;
--error ER_BACKUP_NOT_RUNNING
BACKUP STAGE END;
--error ER_BACKUP_NOT_RUNNING
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_NOT_RUNNING
BACKUP STAGE BLOCK_DDL;
--error ER_BACKUP_NOT_RUNNING
BACKUP STAGE FLUSH;
--echo # Ordered "give up" with 'BACKUP STAGE END' because of whatever reason.
--echo # Some existing backup lock assumed a 'BACKUP STAGE END' is allowed in
--echo # every situation.
BACKUP STAGE START;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo # Orders with BACKUP STAGE FLUSH omitted.
BACKUP STAGE START;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo # Orders with BACKUP STAGE BLOCK_DDL omitted.
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo # Orders with BACKUP STAGE BLOCK_COMMIT omitted.
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo # Orders with doubled BACKUP STAGE statements.
--echo # We get an error but that seems to have no bad impact on the state.
--echo # And so we are allowed to go on with BACKUP STAGE statements.
BACKUP STAGE START;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE FLUSH;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo # Scrambled orders.
BACKUP STAGE START;
BACKUP STAGE FLUSH;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE START;
BACKUP STAGE BLOCK_DDL;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE START;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE FLUSH;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE BLOCK_DDL;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
--echo #----
BACKUP STAGE START;
BACKUP STAGE FLUSH;
BACKUP STAGE BLOCK_COMMIT;
--error ER_BACKUP_WRONG_STAGE
BACKUP STAGE BLOCK_DDL;
BACKUP STAGE END;
--echo #
--echo # Check Oracle syntax
--echo #
set SQL_MODE=Oracle;
backup stage start;
backup stage end;
set SQL_MODE=default;