diff options
author | unknown <marko@hundin.mysql.fi> | 2004-10-01 11:51:59 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-10-01 11:51:59 +0300 |
commit | a418a35ceba85354328b5f75bb4e908f88b6759f (patch) | |
tree | cd5df16f04eff773fc341cd412fa9d695ff0680c | |
parent | 927179ecd464e6dca78d0eabc2653ec63072456f (diff) | |
download | mariadb-git-a418a35ceba85354328b5f75bb4e908f88b6759f.tar.gz |
InnoDB: quote identifiers according to MySQL settings (Bug #5292)
innobase/btr/btr0btr.c:
Add parameter to ut_print_name() and dict_index_name_print() calls
innobase/btr/btr0cur.c:
Add parameter to dict_index_name_print() calls
innobase/buf/buf0buf.c:
Add parameter to dict_index_name_print() calls
innobase/dict/dict0crea.c:
Add parameter to ut_print_name() calls
innobase/dict/dict0dict.c:
Add parameter to ut_print_name() calls
Update documentation links to http://dev.mysql.com
innobase/dict/dict0load.c:
Add parameter to ut_print_name() calls
innobase/fil/fil0fil.c:
Use ut_print_filename()
Update links to documentation to http://dev.mysql.com
innobase/ibuf/ibuf0ibuf.c:
Replaced printf(...) with fprintf(stderr,...)
innobase/include/dict0dict.h:
Added trx parameters
innobase/include/row0row.h:
Added trx parameter
innobase/include/row0sel.h:
Added trx parameter
innobase/include/row0upd.h:
Added trx parameters
innobase/include/row0upd.ic:
Added trx parameter for dict_index_name_print()
innobase/include/trx0rec.h:
Added trx parameter
innobase/include/ut0ut.h:
Added ut_print_filename()
Added trx parameter to ut_print_name() and ut_print_namel()
innobase/lock/lock0lock.c:
Added parameter to dict_index_name_print() and ut_print_name() calls
innobase/page/page0page.c:
Added parameter to dict_index_name_print() calls
innobase/pars/pars0opt.c:
Added parameter to dict_index_name_print() call
innobase/pars/pars0pars.c:
Added parameter to upd_field_set_field_no() call
innobase/row/row0ins.c:
Added trx parameters
innobase/row/row0mysql.c:
Added trx parameters
innobase/row/row0purge.c:
Added trx parameter
innobase/row/row0row.c:
Added trx parameter
innobase/row/row0sel.c:
Added trx parameters
innobase/row/row0umod.c:
Added trx parameters
innobase/row/row0upd.c:
Added trx parameters
innobase/trx/trx0rec.c:
Added trx parameters
innobase/trx/trx0roll.c:
Added parameter to ut_print_name() calls
innobase/ut/ut0ut.c:
Added ut_print_filename()
Added trx parameter to ut_print_namel() and ut_print_name() calls
sql/ha_innodb.cc:
Added trx parameters
Rewrote mysql_get_identifier_quote_char()
sql/mysql_priv.h:
Added get_quote_char_for_identifier()
sql/sql_show.cc:
Added get_quote_char_for_identifier()
Removed append_quoted_simple_identifier()
Make append_identifier() use get_quote_char_for_identifier()
32 files changed, 487 insertions, 360 deletions
diff --git a/innobase/btr/btr0btr.c b/innobase/btr/btr0btr.c index 27d798f925a..2bbfb42b2aa 100644 --- a/innobase/btr/btr0btr.c +++ b/innobase/btr/btr0btr.c @@ -595,10 +595,10 @@ btr_page_get_father_for_rec( buf_page_print(buf_frame_align(node_ptr)); fputs("InnoDB: Corruption of an index tree: table ", stderr); - ut_print_name(stderr, + ut_print_name(stderr, NULL, UT_LIST_GET_FIRST(tree->tree_indexes)->table_name); fputs(", index ", stderr); - ut_print_name(stderr, + ut_print_name(stderr, NULL, UT_LIST_GET_FIRST(tree->tree_indexes)->name); fprintf(stderr, ",\n" "InnoDB: father ptr page no %lu, child page no %lu\n", @@ -2341,7 +2341,7 @@ btr_index_rec_validate_report( dict_index_t* index) /* in: index */ { fputs("InnoDB: Record in ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); fprintf(stderr, ", page %lu, at offset %lu\n", buf_frame_get_page_no(page), (ulint)(rec - page)); } @@ -2479,7 +2479,7 @@ btr_validate_report1( { fprintf(stderr, "InnoDB: Error in page %lu of ", buf_frame_get_page_no(page)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); if (level) { fprintf(stderr, ", index tree level %lu", level); } @@ -2500,7 +2500,7 @@ btr_validate_report2( fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ", buf_frame_get_page_no(page1), buf_frame_get_page_no(page2)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); if (level) { fprintf(stderr, ", index tree level %lu", level); } diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index be201da4510..48de5644908 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -839,7 +839,7 @@ static void btr_cur_trx_report( /*===============*/ - const trx_t* trx, /* in: transaction */ + trx_t* trx, /* in: transaction */ const dict_index_t* index, /* in: index */ const char* op) /* in: operation */ { @@ -847,7 +847,7 @@ btr_cur_trx_report( ut_dulint_get_high(trx->id), ut_dulint_get_low(trx->id)); fputs(op, stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); putc('\n', stderr); } @@ -899,7 +899,7 @@ btr_cur_optimistic_insert( if (!dtuple_check_typed_no_assert(entry)) { fputs("InnoDB: Error in a tuple to insert into ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, thr_get_trx(thr), index); } if (btr_cur_print_record_ops && thr) { @@ -1001,7 +1001,7 @@ calculate_sizes_again: fputs("InnoDB: Error: cannot insert tuple ", stderr); dtuple_print(stderr, entry); fputs(" into ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, thr_get_trx(thr), index); fprintf(stderr, "\nInnoDB: max insert size %lu\n", (ulong) max_size); ut_error; diff --git a/innobase/buf/buf0buf.c b/innobase/buf/buf0buf.c index 5ec8998473d..e039ff4f81f 100644 --- a/innobase/buf/buf0buf.c +++ b/innobase/buf/buf0buf.c @@ -427,7 +427,7 @@ buf_page_print( btr_page_get_index_id(read_buf)); if (index) { fputs("InnoDB: (", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); fputs(")\n", stderr); } } @@ -2123,7 +2123,7 @@ buf_print(void) if (index) { putc(' ', stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); } putc('\n', stderr); diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 1e4d906b7b5..c887d821a3f 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -501,11 +501,14 @@ dict_build_index_def_step( dict_table_t* table; dict_index_t* index; dtuple_t* row; + trx_t* trx; #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ + trx = thr_get_trx(thr); + index = node->index; table = dict_table_get_low(index->table_name); @@ -514,7 +517,7 @@ dict_build_index_def_step( return(DB_TABLE_NOT_FOUND); } - thr_get_trx(thr)->table_id = table->id; + trx->table_id = table->id; node->table = table; @@ -1264,9 +1267,9 @@ loop: ut_print_timestamp(ef); fputs(" Error in foreign key constraint creation for table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, trx, table->name); fputs(".\nA foreign key constraint of name ", ef); - ut_print_name(ef, foreign->id); + ut_print_name(ef, trx, foreign->id); fputs("\nalready exists." " (Note that internally InnoDB adds 'databasename/'\n" "in front of the user-defined constraint name).\n", @@ -1286,7 +1289,7 @@ loop: ut_print_timestamp(ef); fputs(" Internal error in foreign key constraint creation" " for table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, trx, table->name); fputs(".\n" "See the MySQL .err log in the datadir for more information.\n", ef); mutex_exit(&dict_foreign_err_mutex); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index eeefd7bf1ae..b5dd06b1bf1 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2085,14 +2085,14 @@ Report an error in a foreign key definition. */ static void dict_foreign_error_report_low( +/*==========================*/ FILE* file, /* in: output stream */ const char* name) /* in: table name */ { rewind(file); ut_print_timestamp(file); - fputs(" Error in foreign key constraint of table ", file); - ut_print_name(file, name); - fputs(":\n", file); + fprintf(file, " Error in foreign key constraint of table %s:\n", + name); } /************************************************************************** @@ -2100,6 +2100,7 @@ Report an error in a foreign key definition. */ static void dict_foreign_error_report( +/*======================*/ FILE* file, /* in: output stream */ dict_foreign_t* fk, /* in: foreign key constraint */ const char* msg) /* in: the error message */ @@ -2108,10 +2109,10 @@ dict_foreign_error_report( dict_foreign_error_report_low(file, fk->foreign_table_name); fputs(msg, file); fputs(" Constraint:\n", file); - dict_print_info_on_foreign_key_in_create_format(file, fk); + dict_print_info_on_foreign_key_in_create_format(file, NULL, fk); if (fk->foreign_index) { fputs("\nThe index in the foreign key in table is ", file); - ut_print_name(file, fk->foreign_index->name); + ut_print_name(file, NULL, fk->foreign_index->name); fputs( "See http://www.innodb.com/ibman.php for correct foreign key definition.\n", file); @@ -2946,7 +2947,7 @@ col_loop1: mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fputs("There is no index in table ", ef); - ut_print_name(ef, name); + ut_print_name(ef, NULL, name); fprintf(ef, " where the columns appear\n" "as the first columns. Constraint:\n%s\n" "See http://www.innodb.com/ibman.php for correct foreign key definition.\n", @@ -3389,12 +3390,12 @@ loop: ut_print_timestamp(ef); fputs( " Error in dropping of a foreign key constraint of table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, NULL, table->name); fputs(",\n" "in SQL command\n", ef); fputs(str, ef); fputs("\nCannot find a constraint with the given id ", ef); - ut_print_name(ef, id); + ut_print_name(ef, NULL, id); fputs(".\n", ef); mutex_exit(&dict_foreign_err_mutex); @@ -3411,7 +3412,7 @@ syntax_error: ut_print_timestamp(ef); fputs( " Syntax error in dropping of a foreign key constraint of table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, NULL, table->name); fprintf(ef, ",\n" "close to:\n%s\n in SQL command\n%s\n", ptr, str); mutex_exit(&dict_foreign_err_mutex); @@ -3818,9 +3819,11 @@ dict_update_statistics_low( if (table->ibd_file_missing) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: cannot calculate statistics for table %s\n" -"InnoDB: because the .ibd file is missing. See section 15.1 of\n" -"InnoDB: http:/www.innodb.com/ibman.html for help\n", table->name); + " InnoDB: cannot calculate statistics for table %s\n" +"InnoDB: because the .ibd file is missing. For help, please refer to\n" +"InnoDB: " +"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n", + table->name); return; } @@ -3906,25 +3909,19 @@ dict_foreign_print_low( ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - fputs(" FOREIGN KEY CONSTRAINT ", stderr); - ut_print_name(stderr, foreign->id); - fputs(": ", stderr); - ut_print_name(stderr, foreign->foreign_table_name); - fputs(" (", stderr); + fprintf(stderr, " FOREIGN KEY CONSTRAINT %s: %s (", + foreign->id, foreign->foreign_table_name); for (i = 0; i < foreign->n_fields; i++) { - putc(' ', stderr); - ut_print_name(stderr, foreign->foreign_col_names[i]); + fprintf(stderr, " %s", foreign->foreign_col_names[i]); } - fputs(" )\n" - " REFERENCES ", stderr); - ut_print_name(stderr, foreign->referenced_table_name); - fputs(" (", stderr); + fprintf(stderr, " )\n" + " REFERENCES %s (", + foreign->referenced_table_name); for (i = 0; i < foreign->n_fields; i++) { - putc(' ', stderr); - ut_print_name(stderr, foreign->referenced_col_names[i]); + fprintf(stderr, " %s", foreign->referenced_col_names[i]); } fputs(" )\n", stderr); @@ -3981,12 +3978,11 @@ dict_table_print_low( dict_update_statistics_low(table, TRUE); - fputs("--------------------------------------\n" - "TABLE: name ", stderr); - ut_print_name(stderr, table->name); fprintf(stderr, - ", id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" - " COLUMNS: ", +"--------------------------------------\n" +"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" +" COLUMNS: ", + table->name, (ulong) ut_dulint_get_high(table->id), (ulong) ut_dulint_get_low(table->id), (ulong) table->n_cols, @@ -4037,8 +4033,7 @@ dict_col_print_low( #endif /* UNIV_SYNC_DEBUG */ type = dict_col_get_type(col); - ut_print_name(stderr, col->name); - fputs(": ", stderr); + fprintf(stderr, "%s: ", col->name); dtype_print(type); } @@ -4068,13 +4063,12 @@ dict_index_print_low( n_vals = index->stat_n_diff_key_vals[1]; } - fputs(" INDEX: ", stderr); - dict_index_name_print(stderr, index); fprintf(stderr, - ", id %lu %lu, fields %lu/%lu, type %lu\n" + " INDEX: name %s, id %lu %lu, fields %lu/%lu, type %lu\n" " root page %lu, appr.key vals %lu," " leaf pages %lu, size pages %lu\n" " FIELDS: ", + index->name, (ulong) ut_dulint_get_high(tree->id), (ulong) ut_dulint_get_low(tree->id), (ulong) index->n_user_defined_cols, @@ -4106,8 +4100,7 @@ dict_field_print_low( #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - putc(' ', stderr); - ut_print_name(stderr, field->name); + fprintf(stderr, " %s", field->name); if (field->prefix_len != 0) { fprintf(stderr, "(%lu)", (ulong) field->prefix_len); @@ -4122,6 +4115,7 @@ void dict_print_info_on_foreign_key_in_create_format( /*============================================*/ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_foreign_t* foreign)/* in: foreign key constraint */ { const char* stripped_id; @@ -4136,11 +4130,11 @@ dict_print_info_on_foreign_key_in_create_format( } fputs(",\n CONSTRAINT ", file); - ut_print_name(file, stripped_id); + ut_print_name(file, trx, stripped_id); fputs(" FOREIGN KEY (", file); for (i = 0;;) { - ut_print_name(file, foreign->foreign_col_names[i]); + ut_print_name(file, trx, foreign->foreign_col_names[i]); if (++i < foreign->n_fields) { fputs(", ", file); } else { @@ -4153,7 +4147,7 @@ dict_print_info_on_foreign_key_in_create_format( if (dict_tables_have_same_db(foreign->foreign_table_name, foreign->referenced_table_name)) { /* Do not print the database name of the referenced table */ - ut_print_name(file, dict_remove_db_name( + ut_print_name(file, trx, dict_remove_db_name( foreign->referenced_table_name)); } else { /* Look for the '/' in the table name */ @@ -4163,16 +4157,17 @@ dict_print_info_on_foreign_key_in_create_format( i++; } - ut_print_namel(file, foreign->referenced_table_name, i); + ut_print_namel(file, trx, foreign->referenced_table_name, i); putc('.', file); - ut_print_name(file, foreign->referenced_table_name + i + 1); + ut_print_name(file, trx, + foreign->referenced_table_name + i + 1); } putc(' ', file); putc('(', file); for (i = 0;;) { - ut_print_name(file, foreign->referenced_col_names[i]); + ut_print_name(file, trx, foreign->referenced_col_names[i]); if (++i < foreign->n_fields) { fputs(", ", file); } else { @@ -4218,6 +4213,7 @@ dict_print_info_on_foreign_keys( a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS */ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_table_t* table) /* in: table */ { dict_foreign_t* foreign; @@ -4235,7 +4231,7 @@ dict_print_info_on_foreign_keys( while (foreign != NULL) { if (create_table_format) { dict_print_info_on_foreign_key_in_create_format( - file, foreign); + file, trx, foreign); } else { ulint i; fputs("; (", file); @@ -4245,19 +4241,20 @@ dict_print_info_on_foreign_keys( putc(' ', file); } - ut_print_name(file, + ut_print_name(file, trx, foreign->foreign_col_names[i]); } fputs(") REFER ", file); - ut_print_name(file, foreign->referenced_table_name); + ut_print_name(file, trx, + foreign->referenced_table_name); putc('(', file); for (i = 0; i < foreign->n_fields; i++) { if (i) { putc(' ', file); } - ut_print_name(file, + ut_print_name(file, trx, foreign->referenced_col_names[i]); } @@ -4300,10 +4297,11 @@ void dict_index_name_print( /*==================*/ FILE* file, /* in: output stream */ + trx_t* trx, /* in: transaction */ const dict_index_t* index) /* in: index to print */ { fputs("index ", file); - ut_print_name(file, index->name); + ut_print_name(file, trx, index->name); fputs(" of table ", file); - ut_print_name(file, index->table_name); + ut_print_name(file, trx, index->table_name); } diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index ee4ae9dd1a1..9293b117899 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -30,7 +30,7 @@ dict_get_first_table_name_in_db( /* out, own: table name, NULL if does not exist; the caller must free the memory in the string! */ - const char* name) /* in: database name which ends to '/' */ + const char* name) /* in: database name which ends in '/' */ { dict_table_t* sys_tables; btr_pcur_t pcur; @@ -165,7 +165,7 @@ loop: if (table == NULL) { fputs("InnoDB: Failed to load table ", stderr); - ut_print_namel(stderr, field, len); + ut_print_namel(stderr, NULL, field, len); putc('\n', stderr); } else { /* The table definition was corrupt if there @@ -389,18 +389,16 @@ Report that an index field or index for a table has been delete marked. */ static void dict_load_report_deleted_index( +/*===========================*/ const char* name, /* in: table name */ ulint field) /* in: index field, or ULINT_UNDEFINED */ { - fputs("InnoDB: Error: data dictionary entry" - " for table ", stderr); - ut_print_name(stderr, name); - fputs(" is corrupt!\n", stderr); + fprintf(stderr, "InnoDB: Error: data dictionary entry" + " for table %s is corrupt!\n", name); if (field != ULINT_UNDEFINED) { fprintf(stderr, "InnoDB: Index field %lu is delete marked.\n", field); - } - else { + } else { fputs("InnoDB: An index is delete marked.\n", stderr); } } @@ -620,12 +618,10 @@ dict_load_indexes( if (page_no == FIL_NULL) { - fputs("InnoDB: Error: trying to load index ", stderr); - ut_print_name(stderr, name_buf); - fputs(" for table ", stderr); - ut_print_name(stderr, table->name); - fputs("\n" - "InnoDB: but the index tree has been freed!\n", stderr); + fprintf(stderr, + "InnoDB: Error: trying to load index %s for table %s\n" + "InnoDB: but the index tree has been freed!\n", + name_buf, table->name); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -636,12 +632,10 @@ dict_load_indexes( if ((type & DICT_CLUSTERED) == 0 && NULL == dict_table_get_first_index(table)) { - fputs("InnoDB: Error: trying to load index ", stderr); - ut_print_namel(stderr, name_buf, name_len); - fputs(" for table ", stderr); - ut_print_name(stderr, table->name); - fputs("\n" - "InnoDB: but the first index is not clustered!\n", stderr); + fprintf(stderr, + "InnoDB: Error: trying to load index %s for table %s\n" + "InnoDB: but the first index is not clustered!\n", + name_buf, table->name); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1097,10 +1091,9 @@ dict_load_foreign( || rec_get_deleted_flag(rec)) { /* Not found */ - fputs("InnoDB: Error A: cannot load foreign constraint ", - stderr); - ut_print_name(stderr, id); - putc('\n', stderr); + fprintf(stderr, + "InnoDB: Error A: cannot load foreign constraint %s\n", + id); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1114,10 +1107,9 @@ dict_load_foreign( /* Check if the id in record is the searched one */ if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) { - fputs("InnoDB: Error B: cannot load foreign constraint ", - stderr); - ut_print_name(stderr, id); - putc('\n', stderr); + fprintf(stderr, + "InnoDB: Error B: cannot load foreign constraint %s\n", + id); btr_pcur_close(&pcur); mtr_commit(&mtr); diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index 885738deae2..edc459f2605 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -428,7 +428,9 @@ fil_node_create( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Error: Could not find tablespace %lu for\n" -"InnoDB: file %s from the tablespace memory cache.\n", (ulong) id, name); +"InnoDB: file ", (ulong) id); + ut_print_filename(stderr, name); + fputs(" in the tablespace memory cache.\n", stderr); mem_free(node->name); mem_free(node); @@ -596,16 +598,19 @@ fil_try_to_close_file_in_LRU( } if (print_info && node->n_pending_flushes > 0) { - fprintf(stderr, -"InnoDB: cannot close file %s, because n_pending_flushes %lu\n", node->name, + fputs("InnoDB: cannot close file ", stderr); + ut_print_filename(stderr, node->name); + fprintf(stderr, ", because n_pending_flushes %lu\n", (ulong) node->n_pending_flushes); } if (print_info && node->modification_counter != node->flush_counter) { + fputs("InnoDB: cannot close file ", stderr); + ut_print_filename(stderr, node->name); fprintf(stderr, -"InnoDB: cannot close file %s, because mod_count %lld != fl_count %lld\n", - node->name, node->modification_counter, + ", because mod_count %lld != fl_count %lld\n", + node->modification_counter, node->flush_counter); } @@ -660,10 +665,11 @@ retry: for a while */ if (count2 > 20000) { + fputs("InnoDB: Warning: tablespace ", stderr); + ut_print_filename(stderr, space->name); fprintf(stderr, -"InnoDB: Warning: tablespace %s has i/o ops stopped for a long time %lu\n", - space->name, - (ulong) count2); + " has i/o ops stopped for a long time %lu\n", + (ulong) count2); } mutex_exit(&(system->mutex)); @@ -833,11 +839,12 @@ try_again: ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Warning: trying to init to the tablespace memory cache\n" -"InnoDB: a tablespace %lu of name %s,\n" -"InnoDB: but a tablespace %lu of the same name %s\n" +"InnoDB: a tablespace %lu of name ", (ulong) id); + ut_print_filename(stderr, name); + fprintf(stderr, ",\n" +"InnoDB: but a tablespace %lu of the same name\n" "InnoDB: already exists in the tablespace memory cache!\n", - (ulong) id, name, - (ulong) space->id, space->name); + (ulong) space->id); if (id == 0 || purpose != FIL_TABLESPACE) { @@ -868,10 +875,14 @@ try_again: if (space != NULL) { fprintf(stderr, -"InnoDB: Error: trying to add tablespace %lu of name %s\n" +"InnoDB: Error: trying to add tablespace %lu of name ", (ulong) id); + ut_print_filename(stderr, name); + fprintf(stderr, "\n" "InnoDB: to the tablespace memory cache, but tablespace\n" -"InnoDB: %lu of name %s already exists in the tablespace\n" -"InnoDB: memory cache!\n", (ulong) id, name, (ulong) space->id, space->name); +"InnoDB: %lu of name ", (ulong) space->id); + ut_print_filename(stderr, space->name); + fputs(" already exists in the tablespace\n" +"InnoDB: memory cache!\n", stderr); mutex_exit(&(system->mutex)); @@ -1772,10 +1783,12 @@ stop_ibuf_merges: } else { if (count > 5000) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Warning: trying to delete tablespace %s,\n" + fputs( +" InnoDB: Warning: trying to delete tablespace ", stderr); + ut_print_filename(stderr, space->name); + fprintf(stderr, ",\n" "InnoDB: but there are %lu pending ibuf merges on it.\n" -"InnoDB: Loop %lu.\n", space->name, (ulong) space->n_pending_ibuf_merges, +"InnoDB: Loop %lu.\n", (ulong) space->n_pending_ibuf_merges, (ulong) count); } @@ -1819,10 +1832,12 @@ try_again: if (space->n_pending_flushes > 0 || node->n_pending > 0) { if (count > 1000) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Warning: trying to delete tablespace %s,\n" + fputs( +" InnoDB: Warning: trying to delete tablespace ", stderr); + ut_print_filename(stderr, space->name); + fprintf(stderr, ",\n" "InnoDB: but there are %lu flushes and %lu pending i/o's on it\n" -"InnoDB: Loop %lu.\n", space->name, (ulong) space->n_pending_flushes, +"InnoDB: Loop %lu.\n", (ulong) space->n_pending_flushes, (ulong) node->n_pending, (ulong) count); } @@ -1931,8 +1946,9 @@ fil_rename_tablespace_in_mem( HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(old_name), space2, 0 == strcmp(old_name, space2->name)); if (space != space2) { - fprintf(stderr, -"InnoDB: Error: cannot find %s in tablespace memory cache\n", old_name); + fputs("InnoDB: Error: cannot find ", stderr); + ut_print_filename(stderr, old_name); + fputs(" in tablespace memory cache\n", stderr); return(FALSE); } @@ -1940,8 +1956,9 @@ fil_rename_tablespace_in_mem( HASH_SEARCH(name_hash, system->name_hash, ut_fold_string(path), space2, 0 == strcmp(path, space2->name)); if (space2 != NULL) { - fprintf(stderr, -"InnoDB: Error: %s is already in tablespace memory cache\n", path); + fputs("InnoDB: Error: ", stderr); + ut_print_filename(stderr, path); + fputs(" is already in tablespace memory cache\n", stderr); return(FALSE); } @@ -2019,10 +2036,11 @@ retry: if (count > 1000) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Warning: problems renaming %s to %s, %lu iterations\n", - old_name, new_name, - (ulong) count); + fputs(" InnoDB: Warning: problems renaming ", stderr); + ut_print_filename(stderr, old_name); + fputs(" to ", stderr); + ut_print_filename(stderr, new_name); + fprintf(stderr, ", %lu iterations\n", (ulong) count); } mutex_enter(&(system->mutex)); @@ -2032,8 +2050,9 @@ retry: if (space == NULL) { fprintf(stderr, "InnoDB: Error: cannot find space id %lu from the tablespace memory cache\n" -"InnoDB: though the table %s in a rename operation should have that id\n", - (ulong) id, old_name); +"InnoDB: though the table ", (ulong) id); + ut_print_filename(stderr, old_name); + fputs(" in a rename operation should have that id\n", stderr); mutex_exit(&(system->mutex)); return(FALSE); @@ -2166,22 +2185,25 @@ fil_create_new_single_table_tablespace( OS_DATA_FILE, &ret); if (ret == FALSE) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error creating file %s.\n", path); + fputs(" InnoDB: Error creating file ", stderr); + ut_print_filename(stderr, path); + fputs(".\n", stderr); /* The following call will print an error message */ err = os_file_get_last_error(TRUE); if (err == OS_FILE_ALREADY_EXISTS) { - fprintf(stderr, + fputs( "InnoDB: The file already exists though the corresponding table did not\n" "InnoDB: exist in the InnoDB data dictionary. Have you moved InnoDB\n" "InnoDB: .ibd files around without using the SQL commands\n" "InnoDB: DISCARD TABLESPACE and IMPORT TABLESPACE, or did\n" "InnoDB: mysqld crash in the middle of CREATE TABLE? You can\n" -"InnoDB: resolve the problem by removing the file %s\n" -"InnoDB: under the 'datadir' of MySQL.\n", path); +"InnoDB: resolve the problem by removing the file ", stderr); + ut_print_filename(stderr, path); + fputs("\n" +"InnoDB: under the 'datadir' of MySQL.\n", stderr); mem_free(path); return(DB_TABLESPACE_ALREADY_EXISTS); @@ -2249,16 +2271,20 @@ fil_create_new_single_table_tablespace( ut_free(buf2); if (!ret) { - fprintf(stderr, -"InnoDB: Error: could not write the first page to tablespace %s\n", path); + fputs( +"InnoDB: Error: could not write the first page to tablespace ", stderr); + ut_print_filename(stderr, path); + putc('\n', stderr); goto error_exit; } ret = os_file_flush(file); if (!ret) { - fprintf(stderr, -"InnoDB: Error: file flush of tablespace %s failed\n", path); + fputs( +"InnoDB: Error: file flush of tablespace ", stderr); + ut_print_filename(stderr, path); + fputs(" failed\n", stderr); goto error_exit; } @@ -2361,12 +2387,14 @@ fil_reset_too_high_lsns( fprintf(stderr, " InnoDB: Flush lsn in the tablespace file %lu to be imported\n" "InnoDB: is %lu %lu, which exceeds current system lsn %lu %lu.\n" -"InnoDB: We reset the lsn's in the file %s.\n", +"InnoDB: We reset the lsn's in the file ", (ulong) space_id, (ulong) ut_dulint_get_high(flush_lsn), (ulong) ut_dulint_get_low(flush_lsn), (ulong) ut_dulint_get_high(current_lsn), - (ulong) ut_dulint_get_low(current_lsn), filepath); + (ulong) ut_dulint_get_low(current_lsn)); + ut_print_filename(stderr, filepath); + fputs(".\n", stderr); /* Loop through all the pages in the tablespace and reset the lsn and the page checksum if necessary */ @@ -2464,14 +2492,17 @@ fil_open_single_table_tablespace( ut_print_timestamp(stderr); - fprintf(stderr, + fputs( " InnoDB: Error: trying to open a table, but could not\n" -"InnoDB: open the tablespace file %s!\n", filepath); - fprintf(stderr, -"InnoDB: have you moved InnoDB .ibd files around without using the\n" +"InnoDB: open the tablespace file ", stderr); + ut_print_filename(stderr, filepath); + fputs("!\n" +"InnoDB: Have you moved InnoDB .ibd files around without using the\n" "InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n" -"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n" -"InnoDB: how to resolve the issue.\n"); +"InnoDB: Please refer to\n" +"InnoDB:" +" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: how to resolve the issue.\n", stderr); mem_free(filepath); @@ -2493,14 +2524,17 @@ fil_open_single_table_tablespace( if (space_id != id) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error: tablespace id in file %s is %lu, but in the InnoDB\n" -"InnoDB: data dictionary it is %lu.\n", filepath, (ulong) space_id, (ulong) id); - fprintf(stderr, + fputs( +" InnoDB: Error: tablespace id in file ", stderr); + ut_print_filename(stderr, filepath); + fprintf(stderr, " is %lu, but in the InnoDB\n" +"InnoDB: data dictionary it is %lu.\n" "InnoDB: Have you moved InnoDB .ibd files around without using the\n" "InnoDB: commands DISCARD TABLESPACE and IMPORT TABLESPACE?\n" -"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n" -"InnoDB: how to resolve the issue.\n"); +"InnoDB: Please refer to\n" +"InnoDB:" +" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: how to resolve the issue.\n", (ulong) space_id, (ulong) id); ret = FALSE; @@ -2867,8 +2901,10 @@ next_file_item: } if (0 != os_file_closedir(dbdir)) { - fprintf(stderr, -"InnoDB: Warning: could not close database directory %s\n", dbpath); + fputs( +"InnoDB: Warning: could not close database directory ", stderr); + ut_print_filename(stderr, dbpath); + putc('\n', stderr); } } @@ -2921,9 +2957,10 @@ fil_print_orphaned_tablespaces(void) while (space) { if (space->purpose == FIL_TABLESPACE && space->id != 0 && !space->mark) { - fprintf(stderr, -"InnoDB: Warning: tablespace %s of id %lu has no matching table in\n" -"InnoDB: the InnoDB data dictionary.\n", space->name, (ulong) space->id); + fputs("InnoDB: Warning: tablespace ", stderr); + ut_print_filename(stderr, space->name); + fprintf(stderr, " of id %lu has no matching table in\n" +"InnoDB: the InnoDB data dictionary.\n", (ulong) space->id); } space = UT_LIST_GET_NEXT(space_list, space); @@ -3072,26 +3109,31 @@ fil_space_for_table_exists_in_mem( if (space == NULL) { if (namespace == NULL) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error: table %s\n" + fputs(" InnoDB: Error: table ", stderr); + ut_print_filename(stderr, name); + fprintf(stderr, "\n" "InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" "InnoDB: but tablespace with that id or name does not exist. Have\n" "InnoDB: you deleted or moved .ibd files?\n", - name, (ulong) id); + (ulong) id); } else { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error: table %s\n" + fputs(" InnoDB: Error: table ", stderr); + ut_print_filename(stderr, name); + fprintf(stderr, "\n" "InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" "InnoDB: but tablespace with that id does not exist. There is\n" "InnoDB: a tablespace of name %s and id %lu, though. Have\n" "InnoDB: you deleted or moved .ibd files?\n", - name, (ulong) id, namespace->name, + (ulong) id, namespace->name, (ulong) namespace->id); } - fprintf(stderr, -"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n" -"InnoDB: how to resolve the issue.\n"); + error_exit: + fputs( +"InnoDB: Please refer to\n" +"InnoDB:" +" http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" +"InnoDB: how to resolve the issue.\n", stderr); mem_free(path); mutex_exit(&(system->mutex)); @@ -3101,26 +3143,23 @@ fil_space_for_table_exists_in_mem( if (0 != strcmp(space->name, path)) { ut_print_timestamp(stderr); - fprintf(stderr, -" InnoDB: Error: table %s\n" + fputs(" InnoDB: Error: table ", stderr); + ut_print_filename(stderr, name); + fprintf(stderr, "\n" "InnoDB: in InnoDB data dictionary has tablespace id %lu,\n" "InnoDB: but tablespace with that id has name %s.\n" -"InnoDB: Have you deleted or moved .ibd files?\n", name, (ulong) id, space->name); +"InnoDB: Have you deleted or moved .ibd files?\n", (ulong) id, space->name); if (namespace != NULL) { - fprintf(stderr, + fputs( "InnoDB: There is a tablespace with the right name\n" -"InnoDB: %s, but its id is %lu.\n", namespace->name, (ulong) namespace->id); +"InnoDB: ", stderr); + ut_print_filename(stderr, namespace->name); + fprintf(stderr, ", but its id is %lu.\n", + (ulong) namespace->id); } - fprintf(stderr, -"InnoDB: You can look from section 15.1 of http://www.innodb.com/ibman.html\n" -"InnoDB: how to resolve the issue.\n"); - - mem_free(path); - mutex_exit(&(system->mutex)); - - return(FALSE); + goto error_exit; } mem_free(path); diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c index f05e69863a3..b3c8ade2414 100644 --- a/innobase/ibuf/ibuf0ibuf.c +++ b/innobase/ibuf/ibuf0ibuf.c @@ -3268,8 +3268,9 @@ leave_loop: mutex_exit(&ibuf_mutex); - printf("Discarded %lu ibuf entries for space %lu\n", (ulong) n_inserts, - (ulong) space); + fprintf(stderr, + "InnoDB: Discarded %lu ibuf entries for space %lu\n", + (ulong) n_inserts, (ulong) space); ibuf_exit(); diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index ebb34f7dda0..a1a1ebdfe08 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -356,6 +356,7 @@ dict_print_info_on_foreign_keys( a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS */ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_table_t* table); /* in: table */ /************************************************************************** Outputs info on a foreign key of a table in a format suitable for @@ -364,6 +365,7 @@ void dict_print_info_on_foreign_key_in_create_format( /*============================================*/ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_foreign_t* foreign);/* in: foreign key constraint */ /************************************************************************ Displays the names of the index and the table. */ @@ -371,6 +373,7 @@ void dict_index_name_print( /*==================*/ FILE* file, /* in: output stream */ + trx_t* trx, /* in: transaction */ const dict_index_t* index); /* in: index to print */ /************************************************************************ Gets the first index on the table (the clustered index). */ diff --git a/innobase/include/row0row.h b/innobase/include/row0row.h index 3956f3c1692..951e211fb37 100644 --- a/innobase/include/row0row.h +++ b/innobase/include/row0row.h @@ -147,12 +147,13 @@ row_build_row_ref_in_tuple( dtuple_t* ref, /* in/out: row reference built; see the NOTE below! */ dict_index_t* index, /* in: index */ - rec_t* rec); /* in: record in the index; + rec_t* rec, /* in: record in the index; NOTE: the data fields in ref will point directly into this record, therefore, the buffer page of this record must be at least s-latched and the latch held as long as the row reference is used! */ + trx_t* trx); /* in: transaction */ /*********************************************************************** From a row build a row reference with which we can search the clustered index record. */ diff --git a/innobase/include/row0sel.h b/innobase/include/row0sel.h index 0be224eb255..bb6fb70ca86 100644 --- a/innobase/include/row0sel.h +++ b/innobase/include/row0sel.h @@ -105,7 +105,8 @@ row_sel_convert_mysql_key_to_innobase( ulint buf_len, /* in: buffer length */ dict_index_t* index, /* in: index of the key value */ byte* key_ptr, /* in: MySQL key value */ - ulint key_len); /* in: MySQL key value length */ + ulint key_len, /* in: MySQL key value length */ + trx_t* trx); /* in: transaction */ /************************************************************************ Searches for rows in the database. This is used in the interface to MySQL. This function opens a cursor, and also implements fetch next diff --git a/innobase/include/row0upd.h b/innobase/include/row0upd.h index f5e0a88231f..28210364833 100644 --- a/innobase/include/row0upd.h +++ b/innobase/include/row0upd.h @@ -55,7 +55,8 @@ upd_field_set_field_no( upd_field_t* upd_field, /* in: update vector field */ ulint field_no, /* in: field number in a clustered index */ - dict_index_t* index); /* in: index */ + dict_index_t* index, /* in: index */ + trx_t* trx); /* in: transaction */ /************************************************************************* Writes into the redo log the values of trx id and roll ptr and enough info to determine their positions within a clustered index record. */ @@ -149,6 +150,7 @@ row_upd_build_sec_rec_difference_binary( dict_index_t* index, /* in: index */ dtuple_t* entry, /* in: entry to insert */ rec_t* rec, /* in: secondary index record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap); /* in: memory heap from which allocated */ /******************************************************************* Builds an update vector from those fields, excluding the roll ptr and @@ -166,6 +168,7 @@ row_upd_build_difference_binary( externally stored fields in entry, or NULL */ ulint n_ext_vec,/* in: number of fields in ext_vec */ rec_t* rec, /* in: clustered index record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap); /* in: memory heap from which allocated */ /*************************************************************** Replaces the new column values stored in the update vector to the index entry diff --git a/innobase/include/row0upd.ic b/innobase/include/row0upd.ic index d89938d696a..a124228a0de 100644 --- a/innobase/include/row0upd.ic +++ b/innobase/include/row0upd.ic @@ -78,7 +78,8 @@ upd_field_set_field_no( upd_field_t* upd_field, /* in: update vector field */ ulint field_no, /* in: field number in a clustered index */ - dict_index_t* index) /* in: index */ + dict_index_t* index, /* in: index */ + trx_t* trx) /* in: transaction */ { upd_field->field_no = field_no; @@ -86,7 +87,7 @@ upd_field_set_field_no( fprintf(stderr, "InnoDB: Error: trying to access field %lu in ", (ulong) field_no); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fprintf(stderr, "\n" "InnoDB: but index only has %lu fields\n", (ulong) dict_index_get_n_fields(index)); diff --git a/innobase/include/trx0rec.h b/innobase/include/trx0rec.h index 50d942d9040..9d7f41cd94e 100644 --- a/innobase/include/trx0rec.h +++ b/innobase/include/trx0rec.h @@ -145,6 +145,7 @@ trx_undo_update_rec_get_update( dulint trx_id, /* in: transaction id from this undorecord */ dulint roll_ptr,/* in: roll pointer from this undo record */ ulint info_bits,/* in: info bits from this undo record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap, /* in: memory heap from which the memory needed is allocated */ upd_t** upd); /* out, own: update vector */ diff --git a/innobase/include/ut0ut.h b/innobase/include/ut0ut.h index f4a682c57ec..dee8785c9e7 100644 --- a/innobase/include/ut0ut.h +++ b/innobase/include/ut0ut.h @@ -198,12 +198,24 @@ ut_print_buf( ulint len); /* in: length of the buffer */ /************************************************************************** +Outputs a NUL-terminated file name, quoted with apostrophes. */ + +void +ut_print_filename( +/*==============*/ + FILE* f, /* in: output stream */ + const char* name); /* in: name to print */ + +/************************************************************************** Outputs a NUL-terminated string, quoted as an SQL identifier. */ +struct trx_struct; + void ut_print_name( /*==========*/ FILE* f, /* in: output stream */ + struct trx_struct*trx, /* in: transaction */ const char* name); /* in: name to print */ /************************************************************************** @@ -213,6 +225,7 @@ void ut_print_namel( /*==========*/ FILE* f, /* in: output stream */ + struct trx_struct*trx, /* in: transaction (NULL=no quotes) */ const char* name, /* in: name to print */ ulint namelen);/* in: length of name */ diff --git a/innobase/lock/lock0lock.c b/innobase/lock/lock0lock.c index c9c0cd109a9..5ede0a5b46a 100644 --- a/innobase/lock/lock0lock.c +++ b/innobase/lock/lock0lock.c @@ -398,7 +398,7 @@ lock_check_trx_id_sanity( stderr); rec_print(stderr, rec); fputs("InnoDB: in ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); fprintf(stderr, "\n" "InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\n" "InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n", @@ -1651,7 +1651,7 @@ lock_rec_enqueue_waiting( fputs( " InnoDB: Error: a record lock wait happens in a dictionary operation!\n" "InnoDB: Table name ", stderr); - ut_print_name(stderr, index->table_name); + ut_print_name(stderr, trx, index->table_name); fputs(".\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); @@ -1688,7 +1688,7 @@ lock_rec_enqueue_waiting( if (lock_print_waits) { fprintf(stderr, "Lock wait for trx %lu in index ", (ulong) ut_dulint_get_low(trx->id)); - ut_print_name(stderr, index->name); + ut_print_name(stderr, trx, index->name); } return(DB_LOCK_WAIT); @@ -3293,7 +3293,7 @@ lock_table_enqueue_waiting( fputs( " InnoDB: Error: a table lock wait happens in a dictionary operation!\n" "InnoDB: Table name ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs(".\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); @@ -3820,7 +3820,7 @@ lock_table_print( fputs("EXPLICIT ", file); } fputs("TABLE LOCK table ", file); - ut_print_name(file, lock->un_member.tab_lock.table->name); + ut_print_name(file, lock->trx, lock->un_member.tab_lock.table->name); fprintf(file, " trx id %lu %lu", (ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.low); @@ -3871,7 +3871,7 @@ lock_rec_print( fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ", (ulong) space, (ulong) page_no, (ulong) lock_rec_get_n_bits(lock)); - dict_index_name_print(file, lock->index); + dict_index_name_print(file, lock->trx, lock->index); fprintf(file, " trx id %lu %lu", (ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.low); diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c index b5f411c43fc..343f300fc77 100644 --- a/innobase/page/page0page.c +++ b/innobase/page/page0page.c @@ -1579,7 +1579,7 @@ page_validate( fputs("InnoDB: Record heap and dir overlap on a page ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); fprintf(stderr, ", %p, %p\n", page_header_get_ptr(page, PAGE_HEAP_TOP), page_dir_get_nth_slot(page, n_slots - 1)); @@ -1610,7 +1610,7 @@ page_validate( fprintf(stderr, "InnoDB: Records in wrong order on page %lu", (ulong) buf_frame_get_page_no(page)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); fputs("\nInnoDB: previous record ", stderr); rec_print(stderr, old_rec); fputs("\nInnoDB: record ", stderr); @@ -1752,7 +1752,7 @@ func_exit: func_exit2: fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ", (ulong) buf_frame_get_page_no(page)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, NULL, index); putc('\n', stderr); buf_page_print(page); } diff --git a/innobase/pars/pars0opt.c b/innobase/pars/pars0opt.c index 7ba4af15243..0d487f6e54a 100644 --- a/innobase/pars/pars0opt.c +++ b/innobase/pars/pars0opt.c @@ -1229,7 +1229,7 @@ opt_print_query_plan( } fputs("Table ", stderr); - dict_index_name_print(stderr, plan->index); + dict_index_name_print(stderr, NULL, plan->index); fprintf(stderr,"; exact m. %lu, match %lu, end conds %lu\n", (unsigned long) plan->n_exact_match, (unsigned long) n_fields, diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c index e4b388cba82..846cb060a7e 100644 --- a/innobase/pars/pars0pars.c +++ b/innobase/pars/pars0pars.c @@ -886,7 +886,7 @@ pars_process_assign_list( upd_field_set_field_no(upd_field, dict_index_get_nth_col_pos(clust_index, col_sym->col_no), - clust_index); + clust_index, NULL); upd_field->exp = assign_node->val; if (!dtype_is_fixed_size( diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 0da749212d2..003d27cf2e6 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -252,7 +252,7 @@ row_ins_sec_index_entry_by_modify( heap = mem_heap_create(1024); update = row_upd_build_sec_rec_difference_binary(cursor->index, - entry, rec, heap); + entry, rec, thr_get_trx(thr), heap); if (mode == BTR_MODIFY_LEAF) { /* Try an optimistic updating of the record, keeping changes within the page */ @@ -316,7 +316,7 @@ row_ins_clust_index_entry_by_modify( roll_ptr */ update = row_upd_build_difference_binary(cursor->index, entry, ext_vec, - n_ext_vec, rec, heap); + n_ext_vec, rec, thr_get_trx(thr), heap); if (mode == BTR_MODIFY_LEAF) { /* Try optimistic updating of the record, keeping changes within the page */ @@ -554,29 +554,30 @@ row_ins_foreign_report_err( table */ { FILE* ef = dict_foreign_err_file; + trx_t* trx = thr_get_trx(thr); mutex_enter(&dict_foreign_err_mutex); rewind(ef); ut_print_timestamp(ef); fputs(" Transaction:\n", ef); - trx_print(ef, thr_get_trx(thr)); + trx_print(ef, trx); fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, foreign->foreign_table_name); + ut_print_name(ef, trx, foreign->foreign_table_name); fputs(":\n", ef); - dict_print_info_on_foreign_key_in_create_format(ef, foreign); + dict_print_info_on_foreign_key_in_create_format(ef, trx, foreign); putc('\n', ef); fputs(errstr, ef); fputs(" in parent table, in index ", ef); - ut_print_name(ef, foreign->referenced_index->name); + ut_print_name(ef, trx, foreign->referenced_index->name); if (entry) { fputs(" tuple:\n", ef); dtuple_print(ef, entry); } fputs("\nBut in child table ", ef); - ut_print_name(ef, foreign->foreign_table_name); + ut_print_name(ef, trx, foreign->foreign_table_name); fputs(", in index ", ef); - ut_print_name(ef, foreign->foreign_index->name); + ut_print_name(ef, trx, foreign->foreign_index->name); if (rec) { fputs(", there is a record:\n", ef); rec_print(ef, rec); @@ -612,19 +613,19 @@ row_ins_foreign_report_add_err( fputs(" Transaction:\n", ef); trx_print(ef, trx); fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, foreign->foreign_table_name); + ut_print_name(ef, trx, foreign->foreign_table_name); fputs(":\n", ef); - dict_print_info_on_foreign_key_in_create_format(ef, foreign); + dict_print_info_on_foreign_key_in_create_format(ef, trx, foreign); fputs("\nTrying to add in child table, in index ", ef); - ut_print_name(ef, foreign->foreign_index->name); + ut_print_name(ef, trx, foreign->foreign_index->name); if (entry) { fputs(" tuple:\n", ef); dtuple_print(ef, entry); } fputs("\nBut in parent table ", ef); - ut_print_name(ef, foreign->referenced_table_name); + ut_print_name(ef, trx, foreign->referenced_table_name); fputs(", in index ", ef); - ut_print_name(ef, foreign->referenced_index->name); + ut_print_name(ef, trx, foreign->referenced_index->name); fputs(",\nthe closest match we can find is record:\n", ef); if (rec && page_rec_is_supremum(rec)) { /* If the cursor ended on a supremum record, it is better @@ -704,11 +705,13 @@ row_ins_foreign_check_on_constraint( ulint n_to_update; ulint err; ulint i; - + trx_t* trx; ut_a(thr && foreign && pcur && mtr); + trx = thr_get_trx(thr); + /* Since we are going to delete or update a row, we have to invalidate the MySQL query cache for table */ @@ -847,7 +850,7 @@ row_ins_foreign_check_on_constraint( fputs( "InnoDB: error in cascade of a foreign key op\n" "InnoDB: ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs("\n" "InnoDB: record ", stderr); @@ -1057,6 +1060,7 @@ row_ins_check_foreign_constraint( ulint err; ulint i; mtr_t mtr; + trx_t* trx = thr_get_trx(thr); run_again: #ifdef UNIV_SYNC_DEBUG @@ -1065,7 +1069,7 @@ run_again: err = DB_SUCCESS; - if (thr_get_trx(thr)->check_foreigns == FALSE) { + if (trx->check_foreigns == FALSE) { /* The user has suppressed foreign key checks currently for this session */ @@ -1123,18 +1127,18 @@ run_again: rewind(ef); ut_print_timestamp(ef); fputs(" Transaction:\n", ef); - trx_print(ef, thr_get_trx(thr)); + trx_print(ef, trx); fputs("Foreign key constraint fails for table ", ef); - ut_print_name(ef, foreign->foreign_table_name); + ut_print_name(ef, trx, foreign->foreign_table_name); fputs(":\n", ef); dict_print_info_on_foreign_key_in_create_format(ef, - foreign); + trx, foreign); fputs("\nTrying to add to index ", ef); - ut_print_name(ef, foreign->foreign_index->name); + ut_print_name(ef, trx, foreign->foreign_index->name); fputs(" tuple:\n", ef); dtuple_print(ef, entry); fputs("\nBut the parent table ", ef); - ut_print_name(ef, foreign->referenced_table_name); + ut_print_name(ef, trx, foreign->referenced_table_name); fputs(" does not currently exist!\n", ef); mutex_exit(&dict_foreign_err_mutex); @@ -1267,7 +1271,7 @@ run_again: if (check_ref) { err = DB_NO_REFERENCED_ROW; row_ins_foreign_report_add_err( - thr_get_trx(thr), foreign, rec, entry); + trx, foreign, rec, entry); } else { err = DB_SUCCESS; } @@ -1283,7 +1287,7 @@ next_rec: if (check_ref) { rec = btr_pcur_get_rec(&pcur); row_ins_foreign_report_add_err( - thr_get_trx(thr), foreign, rec, entry); + trx, foreign, rec, entry); err = DB_NO_REFERENCED_ROW; } else { err = DB_SUCCESS; @@ -1302,18 +1306,18 @@ next_rec: do_possible_lock_wait: if (err == DB_LOCK_WAIT) { - thr_get_trx(thr)->error_state = err; + trx->error_state = err; que_thr_stop_for_mysql(thr); srv_suspend_mysql_thread(thr); - if (thr_get_trx(thr)->error_state == DB_SUCCESS) { + if (trx->error_state == DB_SUCCESS) { goto run_again; } - err = thr_get_trx(thr)->error_state; + err = trx->error_state; } return(err); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index f4c4cc62082..8f5d3a216bc 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -457,7 +457,7 @@ row_prebuilt_free( "InnoDB: table handle. Magic n %lu, magic n2 %lu, table name", (ulong) prebuilt->magic_n, (ulong) prebuilt->magic_n2); - ut_print_name(stderr, prebuilt->table->name); + ut_print_name(stderr, NULL, prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption((byte*)prebuilt); @@ -550,7 +550,7 @@ row_update_prebuilt_trx( "InnoDB: Error: trying to use a corrupt\n" "InnoDB: table handle. Magic n %lu, table name", (ulong) prebuilt->magic_n); - ut_print_name(stderr, prebuilt->table->name); + ut_print_name(stderr, NULL, prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption((byte*)prebuilt); @@ -864,7 +864,7 @@ row_insert_for_mysql( "InnoDB: Error: trying to free a corrupt\n" "InnoDB: table handle. Magic n %lu, table name", (ulong) prebuilt->magic_n); - ut_print_name(stderr, prebuilt->table->name); + ut_print_name(stderr, prebuilt->trx, prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption((byte*)prebuilt); @@ -1081,7 +1081,7 @@ row_update_for_mysql( "InnoDB: Error: trying to free a corrupt\n" "InnoDB: table handle. Magic n %lu, table name", (ulong) prebuilt->magic_n); - ut_print_name(stderr, prebuilt->table->name); + ut_print_name(stderr, prebuilt->trx, prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption((byte*)prebuilt); @@ -1568,7 +1568,7 @@ row_create_table_for_mysql( if (err == DB_OUT_OF_FILE_SPACE) { fputs("InnoDB: Warning: cannot create table ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs(" because tablespace full\n", stderr); row_drop_table_for_mysql(table->name, trx, FALSE); @@ -1576,7 +1576,7 @@ row_create_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs(" already exists in InnoDB internal\n" "InnoDB: data dictionary. Have you deleted the .frm file\n" "InnoDB: and not used DROP TABLE? Have you used DROP DATABASE\n" @@ -1643,10 +1643,10 @@ row_create_index_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: column ", stderr); - ut_print_name(stderr, + ut_print_name(stderr, trx, dict_index_get_nth_field(index, i)->name); fputs(" appears twice in ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs("\n" "InnoDB: This is not allowed in InnoDB.\n", stderr); @@ -1795,7 +1795,7 @@ row_drop_table_for_mysql_in_background( if (error != DB_SUCCESS) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: Dropping table ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs(" in background drop list failed\n", stderr); } @@ -1874,9 +1874,9 @@ already_dropped: UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop); ut_print_timestamp(stderr); - fputs(" InnoDB: Dropped table ", stderr); - ut_print_name(stderr, drop->table_name); - fputs(" in background drop queue.\n", stderr); + fprintf(stderr, + " InnoDB: Dropped table %s in background drop queue.\n", + drop->table_name); mem_free(drop->table_name); @@ -2031,7 +2031,7 @@ row_discard_tablespace_for_mysql( if (table->space == 0) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs("\n" "InnoDB: is in the system tablespace 0 which cannot be discarded\n", stderr); err = DB_ERROR; @@ -2165,7 +2165,7 @@ row_import_tablespace_for_mysql( if (table->space == 0) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs("\n" "InnoDB: is in the system tablespace 0 which cannot be imported\n", stderr); err = DB_ERROR; @@ -2178,7 +2178,7 @@ row_import_tablespace_for_mysql( fputs( " InnoDB: Error: you are trying to IMPORT a tablespace\n" "InnoDB: ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs(", though you have not called DISCARD on it yet\n" "InnoDB: during the lifetime of the mysqld process!\n", stderr); @@ -2395,7 +2395,7 @@ row_drop_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs(" does not exist in the InnoDB internal\n" "InnoDB: data dictionary though MySQL is trying to drop it.\n" "InnoDB: Have you copied the .frm file of the table to the\n" @@ -2429,10 +2429,10 @@ row_drop_table_for_mysql( ut_print_timestamp(ef); fputs(" Cannot drop table ", ef); - ut_print_name(ef, name); + ut_print_name(ef, trx, name); fputs("\n" "because it is referenced by ", ef); - ut_print_name(ef, foreign->foreign_table_name); + ut_print_name(ef, trx, foreign->foreign_table_name); putc('\n', ef); mutex_exit(&dict_foreign_err_mutex); @@ -2444,7 +2444,7 @@ row_drop_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Warning: MySQL is trying to drop table ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs("\n" "InnoDB: though there are still open handles to it.\n" "InnoDB: Adding the table to the background drop queue.\n", @@ -2461,7 +2461,7 @@ row_drop_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: You are trying to drop table ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs("\n" "InnoDB: though there are foreign key check running on it.\n" "InnoDB: Adding the table to the background drop queue.\n", @@ -2503,7 +2503,7 @@ row_drop_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: not able to remove table ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs(" from the dictionary cache!\n", stderr); err = DB_ERROR; } @@ -2526,7 +2526,7 @@ row_drop_table_for_mysql( fprintf(stderr, " InnoDB: Error: not able to delete tablespace %lu of table ", (ulong) space_id); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs("!\n", stderr); err = DB_ERROR; } @@ -2590,10 +2590,10 @@ loop: ut_print_timestamp(stderr); fputs( " InnoDB: Warning: MySQL is trying to drop database ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fputs("\n" "InnoDB: though there are still open handles to table ", stderr); - ut_print_name(stderr, table_name); + ut_print_name(stderr, trx, table_name); fputs(".\n", stderr); os_thread_sleep(1000000); @@ -2609,10 +2609,10 @@ loop: if (err != DB_SUCCESS) { fputs("InnoDB: DROP DATABASE ", stderr); - ut_print_name(stderr, name); + ut_print_name(stderr, trx, name); fprintf(stderr, " failed with error %lu for table ", (ulint) err); - ut_print_name(stderr, table_name); + ut_print_name(stderr, trx, table_name); putc('\n', stderr); break; } @@ -2793,7 +2793,7 @@ row_rename_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, old_name); + ut_print_name(stderr, trx, old_name); fputs(" does not exist in the InnoDB internal\n" "InnoDB: data dictionary though MySQL is trying to rename the table.\n" "InnoDB: Have you copied the .frm file of the table to the\n" @@ -2808,7 +2808,7 @@ row_rename_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, old_name); + ut_print_name(stderr, trx, old_name); fputs( " does not have an .ibd file in the database directory.\n" "InnoDB: You can look for further help from section 15.1 of\n" @@ -2940,16 +2940,16 @@ row_rename_table_for_mysql( if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: table ", stderr); - ut_print_name(stderr, new_name); + ut_print_name(stderr, trx, new_name); fputs(" exists in the InnoDB internal data\n" "InnoDB: dictionary though MySQL is trying rename table ", stderr); - ut_print_name(stderr, old_name); + ut_print_name(stderr, trx, old_name); fputs(" to it.\n" "InnoDB: Have you deleted the .frm file and not used DROP TABLE?\n" "InnoDB: You can look for further help from section 15.1 of\n" "InnoDB: http://www.innodb.com/ibman.php\n" "InnoDB: If table ", stderr); - ut_print_name(stderr, new_name); + ut_print_name(stderr, trx, new_name); fputs(" is a temporary table #sql..., then it can be that\n" "InnoDB: there are still queries running on the table, and it will be\n" "InnoDB: dropped automatically when the queries end.\n" @@ -2975,9 +2975,9 @@ row_rename_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error in table rename, cannot rename ", stderr); - ut_print_name(stderr, old_name); + ut_print_name(stderr, trx, old_name); fputs(" to ", stderr); - ut_print_name(stderr, new_name); + ut_print_name(stderr, trx, new_name); putc('\n', stderr); err = DB_ERROR; @@ -2999,14 +2999,14 @@ row_rename_table_for_mysql( ut_print_timestamp(stderr); fputs(" InnoDB: Error: in ALTER TABLE ", stderr); - ut_print_name(stderr, new_name); + ut_print_name(stderr, trx, new_name); fputs("\n" "InnoDB: has or is referenced in foreign key constraints\n" "InnoDB: which are not compatible with the new table definition.\n", stderr); ut_a(dict_table_rename_in_cache(table, - old_name, FALSE)); + old_name, FALSE)); trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, NULL); @@ -3022,14 +3022,14 @@ row_rename_table_for_mysql( fputs( " InnoDB: Error: in RENAME TABLE table ", stderr); - ut_print_name(stderr, new_name); + ut_print_name(stderr, trx, new_name); fputs("\n" "InnoDB: is referenced in foreign key constraints\n" "InnoDB: which are not compatible with the new table definition.\n", stderr); ut_a(dict_table_rename_in_cache(table, - old_name, FALSE)); + old_name, FALSE)); trx->error_state = DB_SUCCESS; trx_general_rollback_for_mysql(trx, FALSE, @@ -3146,7 +3146,8 @@ loop: fputs("InnoDB: index records in a wrong order in ", stderr); not_ok: - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, + prebuilt->trx, index); fputs("\n" "InnoDB: prev record ", stderr); dtuple_print(stderr, prev_entry); @@ -3232,7 +3233,8 @@ row_check_table_for_mysql( ret = DB_ERROR; fputs("Error: ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, + prebuilt->trx, index); fprintf(stderr, " contains %lu entries, should be %lu\n", (ulong) n_rows, diff --git a/innobase/row/row0purge.c b/innobase/row/row0purge.c index 8f5f0831dc6..f7e01169b9d 100644 --- a/innobase/row/row0purge.c +++ b/innobase/row/row0purge.c @@ -543,8 +543,8 @@ row_purge_parse_undo_rec( node->heap); ptr = trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, - roll_ptr, info_bits, node->heap, - &(node->update)); + roll_ptr, info_bits, trx, + node->heap, &(node->update)); /* Read to the partial row the fields that occur in indexes */ diff --git a/innobase/row/row0row.c b/innobase/row/row0row.c index 680539764fd..a289d9a7172 100644 --- a/innobase/row/row0row.c +++ b/innobase/row/row0row.c @@ -383,12 +383,13 @@ row_build_row_ref_in_tuple( dtuple_t* ref, /* in/out: row reference built; see the NOTE below! */ dict_index_t* index, /* in: index */ - rec_t* rec) /* in: record in the index; + rec_t* rec, /* in: record in the index; NOTE: the data fields in ref will point directly into this record, therefore, the buffer page of this record must be at least s-latched and the latch held as long as the row reference is used! */ + trx_t* trx) /* in: transaction */ { dict_index_t* clust_index; dfield_t* dfield; @@ -403,9 +404,9 @@ row_build_row_ref_in_tuple( if (!index->table) { fputs("InnoDB: table ", stderr); notfound: - ut_print_name(stderr, index->table_name); + ut_print_name(stderr, trx, index->table_name); fputs(" for index ", stderr); - ut_print_name(stderr, index->name); + ut_print_name(stderr, trx, index->name); fputs(" not found\n", stderr); ut_error; } diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 2c0092adc6e..f8ebed4ea1c 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -1942,7 +1942,8 @@ row_sel_convert_mysql_key_to_innobase( ulint buf_len, /* in: buffer length */ dict_index_t* index, /* in: index of the key value */ byte* key_ptr, /* in: MySQL key value */ - ulint key_len) /* in: MySQL key value length */ + ulint key_len, /* in: MySQL key value length */ + trx_t* trx) /* in: transaction */ { byte* original_buf = buf; byte* original_key_ptr = key_ptr; @@ -2025,7 +2026,7 @@ row_sel_convert_mysql_key_to_innobase( ut_print_timestamp(stderr); fputs( " InnoDB: Error: BLOB or TEXT prefix > 255 bytes in query to table ", stderr); - ut_print_name(stderr, index->table_name); + ut_print_name(stderr, trx, index->table_name); putc('\n', stderr); } @@ -2069,11 +2070,13 @@ row_sel_convert_mysql_key_to_innobase( ut_print_timestamp(stderr); - fprintf(stderr, + fputs( " InnoDB: Warning: using a partial-field key prefix in search.\n" - "InnoDB: Table name %s, index name %s. Last data field length %lu bytes,\n" + "InnoDB: ", stderr); + dict_index_name_print(stderr, trx, index); + fprintf(stderr, ". Last data field length %lu bytes,\n" "InnoDB: key ptr now exceeds key end by %lu bytes.\n" - "InnoDB: Key value in the MySQL format:\n", index->table_name, index->name, + "InnoDB: Key value in the MySQL format:\n", (ulong) data_field_len, (ulong) (key_ptr - key_end)); fflush(stderr); @@ -2116,7 +2119,7 @@ row_sel_store_row_id_to_prebuilt( if (len != DATA_ROW_ID_LEN) { fprintf(stderr, "InnoDB: Error: Row id field is wrong length %lu in ", (ulong) len); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, prebuilt->trx, index); fprintf(stderr, "\n" "InnoDB: Field number %lu, record:\n", (ulong) dict_index_get_sys_col_pos(index, DATA_ROW_ID)); @@ -2275,7 +2278,11 @@ row_sel_store_mysql_rec( ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Warning: could not allocate %lu + 1000000 bytes to retrieve\n" -"InnoDB: a big column. Table name %s\n", (ulong) len, prebuilt->table->name); +"InnoDB: a big column. Table name ", (ulong) len); + ut_print_name(stderr, + prebuilt->trx, + prebuilt->table->name); + putc('\n', stderr); if (extern_field_heap) { mem_heap_free( @@ -2407,8 +2414,9 @@ row_sel_get_clust_rec_for_mysql( trx_t* trx; *out_rec = NULL; + trx = thr_get_trx(thr); - row_build_row_ref_in_tuple(prebuilt->clust_ref, sec_index, rec); + row_build_row_ref_in_tuple(prebuilt->clust_ref, sec_index, rec, trx); clust_index = dict_table_get_first_index(sec_index->table); @@ -2441,7 +2449,7 @@ row_sel_get_clust_rec_for_mysql( fputs(" InnoDB: error clustered record" " for sec rec not found\n" "InnoDB: ", stderr); - dict_index_name_print(stderr, sec_index); + dict_index_name_print(stderr, trx, sec_index); fputs("\n" "InnoDB: sec index record ", stderr); rec_print(stderr, rec); @@ -2449,7 +2457,7 @@ row_sel_get_clust_rec_for_mysql( "InnoDB: clust index record ", stderr); rec_print(stderr, clust_rec); putc('\n', stderr); - trx_print(stderr, thr_get_trx(thr)); + trx_print(stderr, trx); fputs("\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); @@ -2477,8 +2485,6 @@ row_sel_get_clust_rec_for_mysql( /* This is a non-locking consistent read: if necessary, fetch a previous version of the record */ - trx = thr_get_trx(thr); - old_vers = NULL; /* If the isolation level allows reading of uncommitted data, @@ -2803,7 +2809,7 @@ row_search_for_mysql( "InnoDB: Error: trying to free a corrupt\n" "InnoDB: table handle. Magic n %lu, table name ", (ulong) prebuilt->magic_n); - ut_print_name(stderr, prebuilt->table->name); + ut_print_name(stderr, trx, prebuilt->table->name); putc('\n', stderr); mem_analyze_corruption((byte*)prebuilt); @@ -3237,7 +3243,7 @@ rec_loop: (ulong) (rec - buf_frame_align(rec)), (ulong) next_offs, (ulong) buf_frame_get_page_no(rec)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs(". Run CHECK TABLE. You may need to\n" "InnoDB: restore from a backup, or dump + drop + reimport the table.\n", stderr); @@ -3255,7 +3261,7 @@ rec_loop: (ulong) (rec - buf_frame_align(rec)), (ulong) next_offs, (ulong) buf_frame_get_page_no(rec)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs(". We try to skip the rest of the page.\n", stderr); @@ -3274,7 +3280,7 @@ rec_loop: (ulong) (rec - buf_frame_align(rec)), (ulong) next_offs, (ulong) buf_frame_get_page_no(rec)); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs(". We try to skip the record.\n", stderr); diff --git a/innobase/row/row0umod.c b/innobase/row/row0umod.c index d47227166f3..e16d696314b 100644 --- a/innobase/row/row0umod.c +++ b/innobase/row/row0umod.c @@ -422,6 +422,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ibool found; big_rec_t* dummy_big_rec; mtr_t mtr; + trx_t* trx = thr_get_trx(thr); log_free_check(); mtr_start(&mtr); @@ -431,7 +432,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( if (!found) { fputs("InnoDB: error in sec index entry del undo in\n" "InnoDB: ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs("\n" "InnoDB: tuple ", stderr); dtuple_print(stderr, entry); @@ -439,7 +440,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( "InnoDB: record ", stderr); rec_print(stderr, btr_pcur_get_rec(&pcur)); putc('\n', stderr); - trx_print(stderr, thr_get_trx(thr)); + trx_print(stderr, trx); fputs("\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); } else { @@ -451,7 +452,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( heap = mem_heap_create(100); update = row_upd_build_sec_rec_difference_binary(index, entry, - btr_cur_get_rec(btr_cur), heap); + btr_cur_get_rec(btr_cur), trx, heap); if (upd_get_n_fields(update) == 0) { /* Do nothing */ @@ -671,14 +672,15 @@ row_undo_mod_parse_undo_rec( ulint type; ulint cmpl_info; ibool dummy_extern; - + trx_t* trx; + ut_ad(node && thr); - + trx = thr_get_trx(thr); ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info, &dummy_extern, &undo_no, &table_id); node->rec_type = type; - node->table = dict_table_get_on_id(table_id, thr_get_trx(thr)); + node->table = dict_table_get_on_id(table_id, trx); /* TODO: other fixes associated with DROP TABLE + rollback in the same table by another user */ @@ -704,8 +706,8 @@ row_undo_mod_parse_undo_rec( node->heap); trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, - roll_ptr, info_bits, node->heap, - &(node->update)); + roll_ptr, info_bits, trx, + node->heap, &(node->update)); node->new_roll_ptr = roll_ptr; node->new_trx_id = trx_id; node->cmpl_info = cmpl_info; diff --git a/innobase/row/row0upd.c b/innobase/row/row0upd.c index d35ae0a3e38..a93736312f8 100644 --- a/innobase/row/row0upd.c +++ b/innobase/row/row0upd.c @@ -685,6 +685,7 @@ row_upd_build_sec_rec_difference_binary( dict_index_t* index, /* in: index */ dtuple_t* entry, /* in: entry to insert */ rec_t* rec, /* in: secondary index record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap) /* in: memory heap from which allocated */ { upd_field_t* upd_field; @@ -725,7 +726,7 @@ row_upd_build_sec_rec_difference_binary( dfield_copy(&(upd_field->new_val), dfield); - upd_field_set_field_no(upd_field, i, index); + upd_field_set_field_no(upd_field, i, index, trx); upd_field->extern_storage = FALSE; @@ -754,6 +755,7 @@ row_upd_build_difference_binary( externally stored fields in entry, or NULL */ ulint n_ext_vec,/* in: number of fields in ext_vec */ rec_t* rec, /* in: clustered index record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap) /* in: memory heap from which allocated */ { upd_field_t* upd_field; @@ -800,7 +802,7 @@ row_upd_build_difference_binary( dfield_copy(&(upd_field->new_val), dfield); - upd_field_set_field_no(upd_field, i, index); + upd_field_set_field_no(upd_field, i, index, trx); if (upd_ext_vec_contains(ext_vec, n_ext_vec, i)) { upd_field->extern_storage = TRUE; @@ -1200,10 +1202,11 @@ row_upd_sec_index_entry( rec_t* rec; ulint err = DB_SUCCESS; mtr_t mtr; - + trx_t* trx = thr_get_trx(thr); + index = node->index; - check_ref = row_upd_index_is_referenced(index, thr_get_trx(thr)); + check_ref = row_upd_index_is_referenced(index, trx); heap = mem_heap_create(1024); @@ -1222,7 +1225,7 @@ row_upd_sec_index_entry( if (!found) { fputs("InnoDB: error in sec index entry update in\n" "InnoDB: ", stderr); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fputs("\n" "InnoDB: tuple ", stderr); dtuple_print(stderr, entry); @@ -1231,7 +1234,7 @@ row_upd_sec_index_entry( rec_print(stderr, rec); putc('\n', stderr); - trx_print(stderr, thr_get_trx(thr)); + trx_print(stderr, trx); fputs("\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); diff --git a/innobase/trx/trx0rec.c b/innobase/trx/trx0rec.c index 382f723a05c..ba93c6de2bd 100644 --- a/innobase/trx/trx0rec.c +++ b/innobase/trx/trx0rec.c @@ -770,6 +770,7 @@ trx_undo_update_rec_get_update( dulint trx_id, /* in: transaction id from this undo record */ dulint roll_ptr,/* in: roll pointer from this undo record */ ulint info_bits,/* in: info bits from this undo record */ + trx_t* trx, /* in: transaction */ mem_heap_t* heap, /* in: memory heap from which the memory needed is allocated */ upd_t** upd) /* out, own: update vector */ @@ -803,7 +804,7 @@ trx_undo_update_rec_get_update( upd_field_set_field_no(upd_field, dict_index_get_sys_col_pos(index, DATA_TRX_ID), - index); + index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN); upd_field = upd_get_nth_field(update, n_fields + 1); @@ -812,7 +813,7 @@ trx_undo_update_rec_get_update( upd_field_set_field_no(upd_field, dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), - index); + index, trx); dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN); /* Store then the updated ordinary columns to the update vector */ @@ -824,13 +825,13 @@ trx_undo_update_rec_get_update( if (field_no >= dict_index_get_n_fields(index)) { fprintf(stderr, "InnoDB: Error: trying to access update undo rec field %lu in ", (ulong) field_no); - dict_index_name_print(stderr, index); + dict_index_name_print(stderr, trx, index); fprintf(stderr, "\n" "InnoDB: but index has only %lu fields\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" "InnoDB: Run also CHECK TABLE ", (ulong) dict_index_get_n_fields(index)); - ut_print_name(stderr, index->table_name); + ut_print_name(stderr, trx, index->table_name); fprintf(stderr, "\n" "InnoDB: n_fields = %lu, i = %lu, ptr %p\n", (ulong) n_fields, (ulong) i, ptr); @@ -841,7 +842,7 @@ trx_undo_update_rec_get_update( upd_field = upd_get_nth_field(update, i); - upd_field_set_field_no(upd_field, field_no, index); + upd_field_set_field_no(upd_field, field_no, index, trx); if (len != UNIV_SQL_NULL && len >= UNIV_EXTERN_STORAGE_FIELD) { @@ -1266,12 +1267,11 @@ trx_undo_prev_version_build( mtr_memo_contains(index_mtr, buf_block_align(index_rec), MTR_MEMO_PAGE_X_FIX)); if (!(index->type & DICT_CLUSTERED)) { - fputs("InnoDB: Error: trying to access" - " update undo rec for non-clustered ", stderr); - dict_index_name_print(stderr, index); - fputs("\n" -"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" - "InnoDB: index record ", stderr); + fprintf(stderr, "InnoDB: Error: trying to access" + " update undo rec for non-clustered index %s\n" + "InnoDB: Submit a detailed bug report to" + " http://bugs.mysql.com\n" + "InnoDB: index record ", index->name); rec_print(stderr, index_rec); fputs("\n" "InnoDB: record version ", stderr); @@ -1309,32 +1309,29 @@ trx_undo_prev_version_build( ptr = trx_undo_rec_skip_row_ref(ptr, index); ptr = trx_undo_update_rec_get_update(ptr, index, type, trx_id, - roll_ptr, info_bits, heap, &update); + roll_ptr, info_bits, NULL, heap, &update); if (ut_dulint_cmp(table_id, index->table->id) != 0) { ptr = NULL; - fputs("InnoDB: Error: trying to access" - " update undo rec for table ", stderr); - ut_print_name(stderr, index->table_name); - fputs("\n" + fprintf(stderr, +"InnoDB: Error: trying to access update undo rec for table %s\n" "InnoDB: but the table id in the undo record is wrong\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" -"InnoDB: Run also CHECK TABLE ", stderr); - ut_print_name(stderr, index->table_name); - putc('\n', stderr); +"InnoDB: Run also CHECK TABLE %s\n", + index->table_name, index->table_name); } if (ptr == NULL) { /* The record was corrupted, return an error; these printfs should catch an elusive bug in row_vers_old_has_index_entry */ - fputs("InnoDB: ", stderr); - dict_index_name_print(stderr, index); - fprintf(stderr, ", n_uniq %lu\n" + fprintf(stderr, + "InnoDB: table %s, index %s, n_uniq %lu\n" "InnoDB: undo rec address %p, type %lu cmpl_info %lu\n" "InnoDB: undo rec table id %lu %lu, index table id %lu %lu\n" "InnoDB: dump of 150 bytes in undo rec: ", + index->table_name, index->name, (ulong) dict_index_get_n_unique(index), undo_rec, (ulong) type, (ulong) cmpl_info, (ulong) ut_dulint_get_high(table_id), diff --git a/innobase/trx/trx0roll.c b/innobase/trx/trx0roll.c index e65755a0f73..eb7c7f43f03 100644 --- a/innobase/trx/trx0roll.c +++ b/innobase/trx/trx0roll.c @@ -229,7 +229,7 @@ trx_rollback_to_savepoint_for_mysql( if (trx->conc_state == TRX_NOT_STARTED) { ut_print_timestamp(stderr); fputs(" InnoDB: Error: transaction has a savepoint ", stderr); - ut_print_name(stderr, savep->name); + ut_print_name(stderr, trx, savep->name); fputs(" though it is not started\n", stderr); return(DB_ERROR); } @@ -467,7 +467,7 @@ loop: if (table) { fputs("InnoDB: Table found: dropping table ", stderr); - ut_print_name(stderr, table->name); + ut_print_name(stderr, trx, table->name); fputs(" in recovery\n", stderr); err = row_drop_table_for_mysql(table->name, trx, TRUE); diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index 39850227162..b67be77b29e 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -16,18 +16,22 @@ Created 5/11/1994 Heikki Tuuri #include <string.h> #include "ut0sort.h" +#include "trx0trx.h" ibool ut_always_false = FALSE; /********************************************************************* Get the quote character to be used in SQL identifiers. This definition must match the one in sql/ha_innodb.cc! */ - -char -mysql_get_identifier_quote_char(void); -/*=================================*/ +extern +int +mysql_get_identifier_quote_char( +/*============================*/ /* out: quote character to be - used in SQL identifiers */ + used in SQL identifiers; EOF if none */ + trx_t* trx, /* in: transaction */ + const char* name, /* in: name to print */ + ulint namelen);/* in: length of name */ /************************************************************ Gets the high 32 bits in a ulint. That is makes a shift >> 32, @@ -333,6 +337,31 @@ ut_2_power_up( return(res); } +/************************************************************************** +Outputs a NUL-terminated file name, quoted with apostrophes. */ + +void +ut_print_filename( +/*==============*/ + FILE* f, /* in: output stream */ + const char* name) /* in: name to print */ +{ + putc('\'', f); + for (;;) { + int c = *name++; + switch (c) { + case 0: + goto done; + case '\'': + putc(c, f); + /* fall through */ + default: + putc(c, f); + } + } +done: + putc('\'', f); +} /************************************************************************** Outputs a NUL-terminated string, quoted as an SQL identifier. */ @@ -341,9 +370,10 @@ void ut_print_name( /*==========*/ FILE* f, /* in: output stream */ + trx_t* trx, /* in: transaction */ const char* name) /* in: name to print */ { - ut_print_namel(f, name, strlen(name)); + ut_print_namel(f, trx, name, strlen(name)); } /************************************************************************** @@ -353,12 +383,17 @@ void ut_print_namel( /*==========*/ FILE* f, /* in: output stream */ + trx_t* trx, /* in: transaction (NULL=no quotes) */ const char* name, /* in: name to print */ ulint namelen)/* in: length of name */ { const char* s = name; const char* e = s + namelen; - char q = mysql_get_identifier_quote_char(); + int q = mysql_get_identifier_quote_char(trx, name, namelen); + if (q == EOF) { + fwrite(name, 1, namelen, f); + return; + } putc(q, f); while (s < e) { int c = *s++; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index a9a8764c941..76fef067f29 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -736,15 +736,35 @@ innobase_invalidate_query_cache( } /********************************************************************* -Get the quote character to be used in SQL identifiers. */ +Get the quote character to be used in SQL identifiers. +This definition must match the one in innobase/ut/ut0ut.c! */ extern "C" -char -mysql_get_identifier_quote_char(void) -/*=================================*/ +int +mysql_get_identifier_quote_char( +/*============================*/ /* out: quote character to be - used in SQL identifiers */ + used in SQL identifiers; EOF if none */ + trx_t* trx, /* in: transaction */ + const char* name, /* in: name to print */ + ulint namelen)/* in: length of name */ +{ + if (!trx || !trx->mysql_thd) { + return(EOF); + } + return(get_quote_char_for_identifier((THD*) trx->mysql_thd, + name, namelen)); +} + +/************************************************************************** +Obtain a pointer to the MySQL THD object, as in current_thd(). This +definition must match the one in sql/ha_innodb.cc! */ +extern "C" +void* +innobase_current_thd(void) +/*======================*/ + /* out: MySQL THD object */ { - return '`'; + return(current_thd); } /********************************************************************* @@ -1483,12 +1503,14 @@ ha_innobase::open( { dict_table_t* ib_table; char norm_name[1000]; + THD* thd; DBUG_ENTER("ha_innobase::open"); UT_NOT_USED(mode); UT_NOT_USED(test_if_locked); + thd = current_thd; normalize_table_name(norm_name, name); user_thd = NULL; @@ -1538,7 +1560,7 @@ ha_innobase::open( DBUG_RETURN(1); } - if (ib_table->ibd_file_missing && !current_thd->tablespace_op) { + if (ib_table->ibd_file_missing && !thd->tablespace_op) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB error:\n" "MySQL is trying to open a table handle but the .ibd file for\n" @@ -2862,7 +2884,7 @@ ha_innobase::index_read( (ulint)upd_and_key_val_buff_len, index, (byte*) key_ptr, - (ulint) key_len); + (ulint) key_len, prebuilt->trx); } else { /* We position the cursor to the last or the first entry in the index */ @@ -4074,14 +4096,16 @@ ha_innobase::records_in_range( index, (byte*) (min_key ? min_key->key : (const mysql_byte*) 0), - (ulint) (min_key ? min_key->length : 0)); + (ulint) (min_key ? min_key->length : 0), + prebuilt->trx); row_sel_convert_mysql_key_to_innobase( range_end, (byte*) key_val_buff2, buff2_len, index, (byte*) (max_key ? max_key->key : (const mysql_byte*) 0), - (ulint) (max_key ? max_key->length : 0)); + (ulint) (max_key ? max_key->length : 0), + prebuilt->trx); mode1 = convert_search_mode_to_innobase(min_key ? min_key->flag : HA_READ_KEY_EXACT); @@ -4468,7 +4492,8 @@ ha_innobase::update_table_comment( (ulong) fsp_get_available_space_in_free_extents( prebuilt->table->space)); - dict_print_info_on_foreign_keys(FALSE, file, prebuilt->table); + dict_print_info_on_foreign_keys(FALSE, file, + prebuilt->trx, prebuilt->table); flen = ftell(file); if(length + flen + 3 > 64000) { flen = 64000 - 3 - length; @@ -4534,7 +4559,8 @@ ha_innobase::get_foreign_key_create_info(void) trx_search_latch_release_if_reserved(prebuilt->trx); /* output the data to a temporary file */ - dict_print_info_on_foreign_keys(TRUE, file, prebuilt->table); + dict_print_info_on_foreign_keys(TRUE, file, + prebuilt->trx, prebuilt->table); prebuilt->trx->op_info = (char*)""; flen = ftell(file); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e47807dd36e..59d53a4cbb6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -636,6 +636,7 @@ int mysqld_show_keys(THD *thd, TABLE_LIST *table); int mysqld_show_logs(THD *thd); void append_identifier(THD *thd, String *packet, const char *name, uint length); +int get_quote_char_for_identifier(THD *thd, const char *name, uint length); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); int mysqld_show_create(THD *thd, TABLE_LIST *table_list); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index fbb45ce2484..6a380664cb7 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1143,40 +1143,18 @@ static const char *require_quotes(const char *name, uint name_length) } -static void append_quoted_simple_identifier(String *packet, char quote_char, - const char *name, uint length) -{ - packet->append("e_char, 1, system_charset_info); - packet->append(name, length, system_charset_info); - packet->append("e_char, 1, system_charset_info); -} - - void append_identifier(THD *thd, String *packet, const char *name, uint length) { const char *name_end; - char quote_char; + int q= get_quote_char_for_identifier(thd, name, length); - if (thd->variables.sql_mode & MODE_ANSI_QUOTES) - quote_char= '\"'; - else - quote_char= '`'; - - if (is_keyword(name,length)) - { - append_quoted_simple_identifier(packet, quote_char, name, length); + if (q == EOF) { + packet->append(name, length, system_charset_info); return; } - if (!require_quotes(name, length)) - { - if (!(thd->options & OPTION_QUOTE_SHOW_CREATE)) - packet->append(name, length, system_charset_info); - else - append_quoted_simple_identifier(packet, quote_char, name, length); - return; - } + char quote_char= q; /* The identifier must be quoted as it includes a quote character */ @@ -1195,6 +1173,22 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) } +/* Get the quote character for displaying an identifier. + If no quote character is needed, return EOF. */ + +int get_quote_char_for_identifier(THD *thd, const char *name, uint length) +{ + if (!is_keyword(name,length) && + !require_quotes(name, length) && + !(thd->options & OPTION_QUOTE_SHOW_CREATE)) + return EOF; + else if (thd->variables.sql_mode & MODE_ANSI_QUOTES) + return '"'; + else + return '`'; +} + + /* Append directory name (if exists) to CREATE INFO */ static void append_directory(THD *thd, String *packet, const char *dir_type, |