Commit ec47414a authored by marko's avatar marko

branches/5.1: Merge r4922 from branches/zip.

This the fix for the first part of Bug #41609 from InnoDB Plugin to
the built-in InnoDB in MySQL 5.1. This allows InnoDB Hot Backup to
back up a database while the built-in InnoDB in MySQL 5.1 is creating
temporary tables. (This fix does not address the printouts about
missing .ibd files for temporary tables at InnoDB startup, which was
committed to branches/zip in r6252.)

rb://219 approved by Sunny Bains.

branches/zip: Distinguish temporary tables in MLOG_FILE_CREATE.
This addresses Mantis Issue #23 in InnoDB Hot Backup and some
of MySQL Bug #41609.

In MLOG_FILE_CREATE, we need to distinguish temporary tables, so that
InnoDB Hot Backup can work correctly.  It turns out that we can do this
easily, by using a bit of the previously unused parameter for page number.
(The page number parameter of MLOG_FILE_CREATE has been written as 0 
ever since MySQL 4.1, which introduced MLOG_FILE_CREATE.)

MLOG_FILE_FLAG_TEMP: A flag for indicating a temporary table in
the page number parameter of MLOG_FILE_ operations.

fil_op_write_log(): Add the parameter log_flags.

fil_op_log_parse_or_replay(): Add the parameter log_flags.
Do not replay MLOG_FILE_CREATE when MLOG_FILE_FLAG_TEMP is set in log_flags.
This only affects ibbackup --apply-log.  InnoDB itself never replays file
operations.
parent 59e5c6dc
...@@ -1740,6 +1740,8 @@ fil_op_write_log( ...@@ -1740,6 +1740,8 @@ fil_op_write_log(
MLOG_FILE_DELETE, or MLOG_FILE_DELETE, or
MLOG_FILE_RENAME */ MLOG_FILE_RENAME */
ulint space_id, /* in: space id */ ulint space_id, /* in: space id */
ulint log_flags, /* in: redo log flags (stored
in the page number field) */
const char* name, /* in: table name in the familiar const char* name, /* in: table name in the familiar
'databasename/tablename' format, or 'databasename/tablename' format, or
the file path in the case of the file path in the case of
...@@ -1760,8 +1762,8 @@ fil_op_write_log( ...@@ -1760,8 +1762,8 @@ fil_op_write_log(
return; return;
} }
log_ptr = mlog_write_initial_log_record_for_file_op(type, space_id, 0, log_ptr = mlog_write_initial_log_record_for_file_op(
log_ptr, mtr); type, space_id, log_flags, log_ptr, mtr);
/* Let us store the strings as null-terminated for easier readability /* Let us store the strings as null-terminated for easier readability
and handling */ and handling */
...@@ -1810,11 +1812,11 @@ fil_op_log_parse_or_replay( ...@@ -1810,11 +1812,11 @@ fil_op_log_parse_or_replay(
not fir completely between ptr and end_ptr */ not fir completely between ptr and end_ptr */
byte* end_ptr, /* in: buffer end */ byte* end_ptr, /* in: buffer end */
ulint type, /* in: the type of this log record */ ulint type, /* in: the type of this log record */
ibool do_replay, /* in: TRUE if we want to replay the ulint space_id, /* in: the space id of the tablespace in
operation, and not just parse the log record */ question, or 0 if the log record should
ulint space_id) /* in: if do_replay is TRUE, the space id of only be parsed but not replayed */
the tablespace in question; otherwise ulint log_flags) /* in: redo log flags
ignored */ (stored in the page number parameter) */
{ {
ulint name_len; ulint name_len;
ulint new_name_len; ulint new_name_len;
...@@ -1868,7 +1870,7 @@ fil_op_log_parse_or_replay( ...@@ -1868,7 +1870,7 @@ fil_op_log_parse_or_replay(
printf("new name %s\n", new_name); printf("new name %s\n", new_name);
} }
*/ */
if (do_replay == FALSE) { if (!space_id) {
return(ptr); return(ptr);
} }
...@@ -1917,6 +1919,8 @@ fil_op_log_parse_or_replay( ...@@ -1917,6 +1919,8 @@ fil_op_log_parse_or_replay(
} else if (fil_get_space_id_for_table(name) } else if (fil_get_space_id_for_table(name)
!= ULINT_UNDEFINED) { != ULINT_UNDEFINED) {
/* Do nothing */ /* Do nothing */
} else if (log_flags & MLOG_FILE_FLAG_TEMP) {
/* Temporary table, do nothing */
} else { } else {
/* Create the database directory for name, if it does /* Create the database directory for name, if it does
not exist yet */ not exist yet */
...@@ -2078,7 +2082,7 @@ fil_delete_tablespace( ...@@ -2078,7 +2082,7 @@ fil_delete_tablespace(
to write any log record */ to write any log record */
mtr_start(&mtr); mtr_start(&mtr);
fil_op_write_log(MLOG_FILE_DELETE, id, path, NULL, &mtr); fil_op_write_log(MLOG_FILE_DELETE, id, 0, path, NULL, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
#endif #endif
mem_free(path); mem_free(path);
...@@ -2349,7 +2353,7 @@ fil_rename_tablespace( ...@@ -2349,7 +2353,7 @@ fil_rename_tablespace(
mtr_start(&mtr); mtr_start(&mtr);
fil_op_write_log(MLOG_FILE_RENAME, id, old_name, new_name, fil_op_write_log(MLOG_FILE_RENAME, id, 0, old_name, new_name,
&mtr); &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
} }
...@@ -2525,8 +2529,9 @@ fil_create_new_single_table_tablespace( ...@@ -2525,8 +2529,9 @@ fil_create_new_single_table_tablespace(
mtr_start(&mtr); mtr_start(&mtr);
fil_op_write_log(MLOG_FILE_CREATE, *space_id, tablename, fil_op_write_log(MLOG_FILE_CREATE, *space_id,
NULL, &mtr); is_temp ? MLOG_FILE_FLAG_TEMP : 0,
tablename, NULL, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
} }
......
...@@ -330,11 +330,11 @@ fil_op_log_parse_or_replay( ...@@ -330,11 +330,11 @@ fil_op_log_parse_or_replay(
not fir completely between ptr and end_ptr */ not fir completely between ptr and end_ptr */
byte* end_ptr, /* in: buffer end */ byte* end_ptr, /* in: buffer end */
ulint type, /* in: the type of this log record */ ulint type, /* in: the type of this log record */
ibool do_replay, /* in: TRUE if we want to replay the ulint space_id, /* in: the space id of the tablespace in
operation, and not just parse the log record */ question, or 0 if the log record should
ulint space_id); /* in: if do_replay is TRUE, the space id of only be parsed but not replayed */
the tablespace in question; otherwise ulint log_flags); /* in: redo log flags
ignored */ (stored in the page number parameter) */
/*********************************************************************** /***********************************************************************
Deletes a single-table tablespace. The tablespace must be cached in the Deletes a single-table tablespace. The tablespace must be cached in the
memory cache. */ memory cache. */
......
...@@ -134,6 +134,12 @@ flag value must give the length also! */ ...@@ -134,6 +134,12 @@ flag value must give the length also! */
#define MLOG_BIGGEST_TYPE ((byte)46) /* biggest value (used in #define MLOG_BIGGEST_TYPE ((byte)46) /* biggest value (used in
asserts) */ asserts) */
/* Flags for MLOG_FILE operations (stored in the page number
parameter, called log_flags in the functions). The page number
parameter was initially written as 0. */
#define MLOG_FILE_FLAG_TEMP 1 /* identifies TEMPORARY TABLE in
MLOG_FILE_CREATE */
/******************************************************************* /*******************************************************************
Starts a mini-transaction and creates a mini-transaction handle Starts a mini-transaction and creates a mini-transaction handle
and buffer in the memory buffer given by the caller. */ and buffer in the memory buffer given by the caller. */
......
...@@ -939,8 +939,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -939,8 +939,7 @@ recv_parse_or_apply_log_rec_body(
case MLOG_FILE_CREATE: case MLOG_FILE_CREATE:
case MLOG_FILE_RENAME: case MLOG_FILE_RENAME:
case MLOG_FILE_DELETE: case MLOG_FILE_DELETE:
ptr = fil_op_log_parse_or_replay(ptr, end_ptr, type, FALSE, ptr = fil_op_log_parse_or_replay(ptr, end_ptr, type, 0, 0);
ULINT_UNDEFINED);
break; break;
default: default:
ptr = NULL; ptr = NULL;
...@@ -1938,8 +1937,8 @@ recv_parse_log_recs( ...@@ -1938,8 +1937,8 @@ recv_parse_log_recs(
point to the datadir we should use there */ point to the datadir we should use there */
if (NULL == fil_op_log_parse_or_replay( if (NULL == fil_op_log_parse_or_replay(
body, end_ptr, type, TRUE, body, end_ptr, type,
space)) { space, page_no)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: file op" "InnoDB: Error: file op"
" log record of type %lu" " log record of type %lu"
......
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