Commit d7ea8e7c authored by marko@hundin.mysql.fi's avatar marko@hundin.mysql.fi

InnoDB: quote identifiers according to MySQL settings (Bug #5292)

parent 1bd65d77
...@@ -595,10 +595,10 @@ btr_page_get_father_for_rec( ...@@ -595,10 +595,10 @@ btr_page_get_father_for_rec(
buf_page_print(buf_frame_align(node_ptr)); buf_page_print(buf_frame_align(node_ptr));
fputs("InnoDB: Corruption of an index tree: table ", stderr); 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); UT_LIST_GET_FIRST(tree->tree_indexes)->table_name);
fputs(", index ", stderr); fputs(", index ", stderr);
ut_print_name(stderr, ut_print_name(stderr, NULL,
UT_LIST_GET_FIRST(tree->tree_indexes)->name); UT_LIST_GET_FIRST(tree->tree_indexes)->name);
fprintf(stderr, ",\n" fprintf(stderr, ",\n"
"InnoDB: father ptr page no %lu, child page no %lu\n", "InnoDB: father ptr page no %lu, child page no %lu\n",
...@@ -2341,7 +2341,7 @@ btr_index_rec_validate_report( ...@@ -2341,7 +2341,7 @@ btr_index_rec_validate_report(
dict_index_t* index) /* in: index */ dict_index_t* index) /* in: index */
{ {
fputs("InnoDB: Record in ", stderr); 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", fprintf(stderr, ", page %lu, at offset %lu\n",
buf_frame_get_page_no(page), (ulint)(rec - page)); buf_frame_get_page_no(page), (ulint)(rec - page));
} }
...@@ -2479,7 +2479,7 @@ btr_validate_report1( ...@@ -2479,7 +2479,7 @@ btr_validate_report1(
{ {
fprintf(stderr, "InnoDB: Error in page %lu of ", fprintf(stderr, "InnoDB: Error in page %lu of ",
buf_frame_get_page_no(page)); buf_frame_get_page_no(page));
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
if (level) { if (level) {
fprintf(stderr, ", index tree level %lu", level); fprintf(stderr, ", index tree level %lu", level);
} }
...@@ -2500,7 +2500,7 @@ btr_validate_report2( ...@@ -2500,7 +2500,7 @@ btr_validate_report2(
fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ", fprintf(stderr, "InnoDB: Error in pages %lu and %lu of ",
buf_frame_get_page_no(page1), buf_frame_get_page_no(page1),
buf_frame_get_page_no(page2)); buf_frame_get_page_no(page2));
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
if (level) { if (level) {
fprintf(stderr, ", index tree level %lu", level); fprintf(stderr, ", index tree level %lu", level);
} }
......
...@@ -839,7 +839,7 @@ static ...@@ -839,7 +839,7 @@ static
void void
btr_cur_trx_report( btr_cur_trx_report(
/*===============*/ /*===============*/
const trx_t* trx, /* in: transaction */ trx_t* trx, /* in: transaction */
const dict_index_t* index, /* in: index */ const dict_index_t* index, /* in: index */
const char* op) /* in: operation */ const char* op) /* in: operation */
{ {
...@@ -847,7 +847,7 @@ btr_cur_trx_report( ...@@ -847,7 +847,7 @@ btr_cur_trx_report(
ut_dulint_get_high(trx->id), ut_dulint_get_high(trx->id),
ut_dulint_get_low(trx->id)); ut_dulint_get_low(trx->id));
fputs(op, stderr); fputs(op, stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, trx, index);
putc('\n', stderr); putc('\n', stderr);
} }
...@@ -899,7 +899,7 @@ btr_cur_optimistic_insert( ...@@ -899,7 +899,7 @@ btr_cur_optimistic_insert(
if (!dtuple_check_typed_no_assert(entry)) { if (!dtuple_check_typed_no_assert(entry)) {
fputs("InnoDB: Error in a tuple to insert into ", stderr); 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) { if (btr_cur_print_record_ops && thr) {
...@@ -1001,7 +1001,7 @@ calculate_sizes_again: ...@@ -1001,7 +1001,7 @@ calculate_sizes_again:
fputs("InnoDB: Error: cannot insert tuple ", stderr); fputs("InnoDB: Error: cannot insert tuple ", stderr);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
fputs(" into ", stderr); 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", fprintf(stderr, "\nInnoDB: max insert size %lu\n",
(ulong) max_size); (ulong) max_size);
ut_error; ut_error;
......
...@@ -427,7 +427,7 @@ buf_page_print( ...@@ -427,7 +427,7 @@ buf_page_print(
btr_page_get_index_id(read_buf)); btr_page_get_index_id(read_buf));
if (index) { if (index) {
fputs("InnoDB: (", stderr); fputs("InnoDB: (", stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
fputs(")\n", stderr); fputs(")\n", stderr);
} }
} }
...@@ -2123,7 +2123,7 @@ buf_print(void) ...@@ -2123,7 +2123,7 @@ buf_print(void)
if (index) { if (index) {
putc(' ', stderr); putc(' ', stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
} }
putc('\n', stderr); putc('\n', stderr);
......
...@@ -501,11 +501,14 @@ dict_build_index_def_step( ...@@ -501,11 +501,14 @@ dict_build_index_def_step(
dict_table_t* table; dict_table_t* table;
dict_index_t* index; dict_index_t* index;
dtuple_t* row; dtuple_t* row;
trx_t* trx;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
trx = thr_get_trx(thr);
index = node->index; index = node->index;
table = dict_table_get_low(index->table_name); table = dict_table_get_low(index->table_name);
...@@ -514,7 +517,7 @@ dict_build_index_def_step( ...@@ -514,7 +517,7 @@ dict_build_index_def_step(
return(DB_TABLE_NOT_FOUND); return(DB_TABLE_NOT_FOUND);
} }
thr_get_trx(thr)->table_id = table->id; trx->table_id = table->id;
node->table = table; node->table = table;
...@@ -1264,9 +1267,9 @@ loop: ...@@ -1264,9 +1267,9 @@ loop:
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Error in foreign key constraint creation for table ", fputs(" Error in foreign key constraint creation for table ",
ef); ef);
ut_print_name(ef, table->name); ut_print_name(ef, trx, table->name);
fputs(".\nA foreign key constraint of name ", ef); fputs(".\nA foreign key constraint of name ", ef);
ut_print_name(ef, foreign->id); ut_print_name(ef, trx, foreign->id);
fputs("\nalready exists." fputs("\nalready exists."
" (Note that internally InnoDB adds 'databasename/'\n" " (Note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n", "in front of the user-defined constraint name).\n",
...@@ -1286,7 +1289,7 @@ loop: ...@@ -1286,7 +1289,7 @@ loop:
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Internal error in foreign key constraint creation" fputs(" Internal error in foreign key constraint creation"
" for table ", ef); " for table ", ef);
ut_print_name(ef, table->name); ut_print_name(ef, trx, table->name);
fputs(".\n" fputs(".\n"
"See the MySQL .err log in the datadir for more information.\n", ef); "See the MySQL .err log in the datadir for more information.\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
......
...@@ -2085,14 +2085,14 @@ Report an error in a foreign key definition. */ ...@@ -2085,14 +2085,14 @@ Report an error in a foreign key definition. */
static static
void void
dict_foreign_error_report_low( dict_foreign_error_report_low(
/*==========================*/
FILE* file, /* in: output stream */ FILE* file, /* in: output stream */
const char* name) /* in: table name */ const char* name) /* in: table name */
{ {
rewind(file); rewind(file);
ut_print_timestamp(file); ut_print_timestamp(file);
fputs(" Error in foreign key constraint of table ", file); fprintf(file, " Error in foreign key constraint of table %s:\n",
ut_print_name(file, name); name);
fputs(":\n", file);
} }
/************************************************************************** /**************************************************************************
...@@ -2100,6 +2100,7 @@ Report an error in a foreign key definition. */ ...@@ -2100,6 +2100,7 @@ Report an error in a foreign key definition. */
static static
void void
dict_foreign_error_report( dict_foreign_error_report(
/*======================*/
FILE* file, /* in: output stream */ FILE* file, /* in: output stream */
dict_foreign_t* fk, /* in: foreign key constraint */ dict_foreign_t* fk, /* in: foreign key constraint */
const char* msg) /* in: the error message */ const char* msg) /* in: the error message */
...@@ -2108,10 +2109,10 @@ dict_foreign_error_report( ...@@ -2108,10 +2109,10 @@ dict_foreign_error_report(
dict_foreign_error_report_low(file, fk->foreign_table_name); dict_foreign_error_report_low(file, fk->foreign_table_name);
fputs(msg, file); fputs(msg, file);
fputs(" Constraint:\n", 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) { if (fk->foreign_index) {
fputs("\nThe index in the foreign key in table is ", file); 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( fputs(
"See http://www.innodb.com/ibman.php for correct foreign key definition.\n", "See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
file); file);
...@@ -2946,7 +2947,7 @@ col_loop1: ...@@ -2946,7 +2947,7 @@ col_loop1:
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, name); dict_foreign_error_report_low(ef, name);
fputs("There is no index in table ", ef); 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" fprintf(ef, " where the columns appear\n"
"as the first columns. Constraint:\n%s\n" "as the first columns. Constraint:\n%s\n"
"See http://www.innodb.com/ibman.php for correct foreign key definition.\n", "See http://www.innodb.com/ibman.php for correct foreign key definition.\n",
...@@ -3389,12 +3390,12 @@ loop: ...@@ -3389,12 +3390,12 @@ loop:
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs( fputs(
" Error in dropping of a foreign key constraint of table ", ef); " 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" fputs(",\n"
"in SQL command\n", ef); "in SQL command\n", ef);
fputs(str, ef); fputs(str, ef);
fputs("\nCannot find a constraint with the given id ", 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); fputs(".\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
...@@ -3411,7 +3412,7 @@ syntax_error: ...@@ -3411,7 +3412,7 @@ syntax_error:
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs( fputs(
" Syntax error in dropping of a foreign key constraint of table ", ef); " 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" fprintf(ef, ",\n"
"close to:\n%s\n in SQL command\n%s\n", ptr, str); "close to:\n%s\n in SQL command\n%s\n", ptr, str);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
...@@ -3818,9 +3819,11 @@ dict_update_statistics_low( ...@@ -3818,9 +3819,11 @@ dict_update_statistics_low(
if (table->ibd_file_missing) { if (table->ibd_file_missing) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: cannot calculate statistics for table %s\n" " InnoDB: cannot calculate statistics for table %s\n"
"InnoDB: because the .ibd file is missing. See section 15.1 of\n" "InnoDB: because the .ibd file is missing. For help, please refer to\n"
"InnoDB: http:/www.innodb.com/ibman.html for help\n", table->name); "InnoDB: "
"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n",
table->name);
return; return;
} }
...@@ -3906,25 +3909,19 @@ dict_foreign_print_low( ...@@ -3906,25 +3909,19 @@ dict_foreign_print_low(
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
fputs(" FOREIGN KEY CONSTRAINT ", stderr); fprintf(stderr, " FOREIGN KEY CONSTRAINT %s: %s (",
ut_print_name(stderr, foreign->id); foreign->id, foreign->foreign_table_name);
fputs(": ", stderr);
ut_print_name(stderr, foreign->foreign_table_name);
fputs(" (", stderr);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
putc(' ', stderr); fprintf(stderr, " %s", foreign->foreign_col_names[i]);
ut_print_name(stderr, foreign->foreign_col_names[i]);
} }
fputs(" )\n" fprintf(stderr, " )\n"
" REFERENCES ", stderr); " REFERENCES %s (",
ut_print_name(stderr, foreign->referenced_table_name); foreign->referenced_table_name);
fputs(" (", stderr);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
putc(' ', stderr); fprintf(stderr, " %s", foreign->referenced_col_names[i]);
ut_print_name(stderr, foreign->referenced_col_names[i]);
} }
fputs(" )\n", stderr); fputs(" )\n", stderr);
...@@ -3981,12 +3978,11 @@ dict_table_print_low( ...@@ -3981,12 +3978,11 @@ dict_table_print_low(
dict_update_statistics_low(table, TRUE); dict_update_statistics_low(table, TRUE);
fputs("--------------------------------------\n"
"TABLE: name ", stderr);
ut_print_name(stderr, table->name);
fprintf(stderr, fprintf(stderr,
", id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" "--------------------------------------\n"
" COLUMNS: ", "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_high(table->id),
(ulong) ut_dulint_get_low(table->id), (ulong) ut_dulint_get_low(table->id),
(ulong) table->n_cols, (ulong) table->n_cols,
...@@ -4037,8 +4033,7 @@ dict_col_print_low( ...@@ -4037,8 +4033,7 @@ dict_col_print_low(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
type = dict_col_get_type(col); type = dict_col_get_type(col);
ut_print_name(stderr, col->name); fprintf(stderr, "%s: ", col->name);
fputs(": ", stderr);
dtype_print(type); dtype_print(type);
} }
...@@ -4068,13 +4063,12 @@ dict_index_print_low( ...@@ -4068,13 +4063,12 @@ dict_index_print_low(
n_vals = index->stat_n_diff_key_vals[1]; n_vals = index->stat_n_diff_key_vals[1];
} }
fputs(" INDEX: ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, 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," " root page %lu, appr.key vals %lu,"
" leaf pages %lu, size pages %lu\n" " leaf pages %lu, size pages %lu\n"
" FIELDS: ", " FIELDS: ",
index->name,
(ulong) ut_dulint_get_high(tree->id), (ulong) ut_dulint_get_high(tree->id),
(ulong) ut_dulint_get_low(tree->id), (ulong) ut_dulint_get_low(tree->id),
(ulong) index->n_user_defined_cols, (ulong) index->n_user_defined_cols,
...@@ -4106,8 +4100,7 @@ dict_field_print_low( ...@@ -4106,8 +4100,7 @@ dict_field_print_low(
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
putc(' ', stderr); fprintf(stderr, " %s", field->name);
ut_print_name(stderr, field->name);
if (field->prefix_len != 0) { if (field->prefix_len != 0) {
fprintf(stderr, "(%lu)", (ulong) field->prefix_len); fprintf(stderr, "(%lu)", (ulong) field->prefix_len);
...@@ -4122,6 +4115,7 @@ void ...@@ -4122,6 +4115,7 @@ void
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(
/*============================================*/ /*============================================*/
FILE* file, /* in: file where to print */ FILE* file, /* in: file where to print */
trx_t* trx, /* in: transaction */
dict_foreign_t* foreign)/* in: foreign key constraint */ dict_foreign_t* foreign)/* in: foreign key constraint */
{ {
const char* stripped_id; const char* stripped_id;
...@@ -4136,11 +4130,11 @@ dict_print_info_on_foreign_key_in_create_format( ...@@ -4136,11 +4130,11 @@ dict_print_info_on_foreign_key_in_create_format(
} }
fputs(",\n CONSTRAINT ", file); fputs(",\n CONSTRAINT ", file);
ut_print_name(file, stripped_id); ut_print_name(file, trx, stripped_id);
fputs(" FOREIGN KEY (", file); fputs(" FOREIGN KEY (", file);
for (i = 0;;) { 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) { if (++i < foreign->n_fields) {
fputs(", ", file); fputs(", ", file);
} else { } else {
...@@ -4153,7 +4147,7 @@ dict_print_info_on_foreign_key_in_create_format( ...@@ -4153,7 +4147,7 @@ dict_print_info_on_foreign_key_in_create_format(
if (dict_tables_have_same_db(foreign->foreign_table_name, if (dict_tables_have_same_db(foreign->foreign_table_name,
foreign->referenced_table_name)) { foreign->referenced_table_name)) {
/* Do not print the database name of the referenced table */ /* 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)); foreign->referenced_table_name));
} else { } else {
/* Look for the '/' in the table name */ /* Look for the '/' in the table name */
...@@ -4163,16 +4157,17 @@ dict_print_info_on_foreign_key_in_create_format( ...@@ -4163,16 +4157,17 @@ dict_print_info_on_foreign_key_in_create_format(
i++; i++;
} }
ut_print_namel(file, foreign->referenced_table_name, i); ut_print_namel(file, trx, foreign->referenced_table_name, i);
putc('.', file); 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);
putc('(', file); putc('(', file);
for (i = 0;;) { 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) { if (++i < foreign->n_fields) {
fputs(", ", file); fputs(", ", file);
} else { } else {
...@@ -4218,6 +4213,7 @@ dict_print_info_on_foreign_keys( ...@@ -4218,6 +4213,7 @@ dict_print_info_on_foreign_keys(
a CREATE TABLE, otherwise in the format a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */ of SHOW TABLE STATUS */
FILE* file, /* in: file where to print */ FILE* file, /* in: file where to print */
trx_t* trx, /* in: transaction */
dict_table_t* table) /* in: table */ dict_table_t* table) /* in: table */
{ {
dict_foreign_t* foreign; dict_foreign_t* foreign;
...@@ -4235,7 +4231,7 @@ dict_print_info_on_foreign_keys( ...@@ -4235,7 +4231,7 @@ dict_print_info_on_foreign_keys(
while (foreign != NULL) { while (foreign != NULL) {
if (create_table_format) { if (create_table_format) {
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(
file, foreign); file, trx, foreign);
} else { } else {
ulint i; ulint i;
fputs("; (", file); fputs("; (", file);
...@@ -4245,19 +4241,20 @@ dict_print_info_on_foreign_keys( ...@@ -4245,19 +4241,20 @@ dict_print_info_on_foreign_keys(
putc(' ', file); putc(' ', file);
} }
ut_print_name(file, ut_print_name(file, trx,
foreign->foreign_col_names[i]); foreign->foreign_col_names[i]);
} }
fputs(") REFER ", file); fputs(") REFER ", file);
ut_print_name(file, foreign->referenced_table_name); ut_print_name(file, trx,
foreign->referenced_table_name);
putc('(', file); putc('(', file);
for (i = 0; i < foreign->n_fields; i++) { for (i = 0; i < foreign->n_fields; i++) {
if (i) { if (i) {
putc(' ', file); putc(' ', file);
} }
ut_print_name(file, ut_print_name(file, trx,
foreign->referenced_col_names[i]); foreign->referenced_col_names[i]);
} }
...@@ -4300,10 +4297,11 @@ void ...@@ -4300,10 +4297,11 @@ void
dict_index_name_print( dict_index_name_print(
/*==================*/ /*==================*/
FILE* file, /* in: output stream */ FILE* file, /* in: output stream */
trx_t* trx, /* in: transaction */
const dict_index_t* index) /* in: index to print */ const dict_index_t* index) /* in: index to print */
{ {
fputs("index ", file); fputs("index ", file);
ut_print_name(file, index->name); ut_print_name(file, trx, index->name);
fputs(" of table ", file); fputs(" of table ", file);
ut_print_name(file, index->table_name); ut_print_name(file, trx, index->table_name);
} }
...@@ -30,7 +30,7 @@ dict_get_first_table_name_in_db( ...@@ -30,7 +30,7 @@ dict_get_first_table_name_in_db(
/* out, own: table name, NULL if /* out, own: table name, NULL if
does not exist; the caller must does not exist; the caller must
free the memory in the string! */ 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; dict_table_t* sys_tables;
btr_pcur_t pcur; btr_pcur_t pcur;
...@@ -165,7 +165,7 @@ loop: ...@@ -165,7 +165,7 @@ loop:
if (table == NULL) { if (table == NULL) {
fputs("InnoDB: Failed to load table ", stderr); fputs("InnoDB: Failed to load table ", stderr);
ut_print_namel(stderr, field, len); ut_print_namel(stderr, NULL, field, len);
putc('\n', stderr); putc('\n', stderr);
} else { } else {
/* The table definition was corrupt if there /* 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. */ ...@@ -389,18 +389,16 @@ Report that an index field or index for a table has been delete marked. */
static static
void void
dict_load_report_deleted_index( dict_load_report_deleted_index(
/*===========================*/
const char* name, /* in: table name */ const char* name, /* in: table name */
ulint field) /* in: index field, or ULINT_UNDEFINED */ ulint field) /* in: index field, or ULINT_UNDEFINED */
{ {
fputs("InnoDB: Error: data dictionary entry" fprintf(stderr, "InnoDB: Error: data dictionary entry"
" for table ", stderr); " for table %s is corrupt!\n", name);
ut_print_name(stderr, name);
fputs(" is corrupt!\n", stderr);
if (field != ULINT_UNDEFINED) { if (field != ULINT_UNDEFINED) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Index field %lu is delete marked.\n", field); "InnoDB: Index field %lu is delete marked.\n", field);
} } else {
else {
fputs("InnoDB: An index is delete marked.\n", stderr); fputs("InnoDB: An index is delete marked.\n", stderr);
} }
} }
...@@ -620,12 +618,10 @@ dict_load_indexes( ...@@ -620,12 +618,10 @@ dict_load_indexes(
if (page_no == FIL_NULL) { if (page_no == FIL_NULL) {
fputs("InnoDB: Error: trying to load index ", stderr); fprintf(stderr,
ut_print_name(stderr, name_buf); "InnoDB: Error: trying to load index %s for table %s\n"
fputs(" for table ", stderr); "InnoDB: but the index tree has been freed!\n",
ut_print_name(stderr, table->name); name_buf, table->name);
fputs("\n"
"InnoDB: but the index tree has been freed!\n", stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -636,12 +632,10 @@ dict_load_indexes( ...@@ -636,12 +632,10 @@ dict_load_indexes(
if ((type & DICT_CLUSTERED) == 0 if ((type & DICT_CLUSTERED) == 0
&& NULL == dict_table_get_first_index(table)) { && NULL == dict_table_get_first_index(table)) {
fputs("InnoDB: Error: trying to load index ", stderr); fprintf(stderr,
ut_print_namel(stderr, name_buf, name_len); "InnoDB: Error: trying to load index %s for table %s\n"
fputs(" for table ", stderr); "InnoDB: but the first index is not clustered!\n",
ut_print_name(stderr, table->name); name_buf, table->name);
fputs("\n"
"InnoDB: but the first index is not clustered!\n", stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -1097,10 +1091,9 @@ dict_load_foreign( ...@@ -1097,10 +1091,9 @@ dict_load_foreign(
|| rec_get_deleted_flag(rec)) { || rec_get_deleted_flag(rec)) {
/* Not found */ /* Not found */
fputs("InnoDB: Error A: cannot load foreign constraint ", fprintf(stderr,
stderr); "InnoDB: Error A: cannot load foreign constraint %s\n",
ut_print_name(stderr, id); id);
putc('\n', stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
...@@ -1114,10 +1107,9 @@ dict_load_foreign( ...@@ -1114,10 +1107,9 @@ dict_load_foreign(
/* Check if the id in record is the searched one */ /* Check if the id in record is the searched one */
if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) { if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) {
fputs("InnoDB: Error B: cannot load foreign constraint ", fprintf(stderr,
stderr); "InnoDB: Error B: cannot load foreign constraint %s\n",
ut_print_name(stderr, id); id);
putc('\n', stderr);
btr_pcur_close(&pcur); btr_pcur_close(&pcur);
mtr_commit(&mtr); mtr_commit(&mtr);
......
This diff is collapsed.
...@@ -3268,8 +3268,9 @@ leave_loop: ...@@ -3268,8 +3268,9 @@ leave_loop:
mutex_exit(&ibuf_mutex); mutex_exit(&ibuf_mutex);
printf("Discarded %lu ibuf entries for space %lu\n", (ulong) n_inserts, fprintf(stderr,
(ulong) space); "InnoDB: Discarded %lu ibuf entries for space %lu\n",
(ulong) n_inserts, (ulong) space);
ibuf_exit(); ibuf_exit();
......
...@@ -356,6 +356,7 @@ dict_print_info_on_foreign_keys( ...@@ -356,6 +356,7 @@ dict_print_info_on_foreign_keys(
a CREATE TABLE, otherwise in the format a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */ of SHOW TABLE STATUS */
FILE* file, /* in: file where to print */ FILE* file, /* in: file where to print */
trx_t* trx, /* in: transaction */
dict_table_t* table); /* in: table */ dict_table_t* table); /* in: table */
/************************************************************************** /**************************************************************************
Outputs info on a foreign key of a table in a format suitable for Outputs info on a foreign key of a table in a format suitable for
...@@ -364,6 +365,7 @@ void ...@@ -364,6 +365,7 @@ void
dict_print_info_on_foreign_key_in_create_format( dict_print_info_on_foreign_key_in_create_format(
/*============================================*/ /*============================================*/
FILE* file, /* in: file where to print */ FILE* file, /* in: file where to print */
trx_t* trx, /* in: transaction */
dict_foreign_t* foreign);/* in: foreign key constraint */ dict_foreign_t* foreign);/* in: foreign key constraint */
/************************************************************************ /************************************************************************
Displays the names of the index and the table. */ Displays the names of the index and the table. */
...@@ -371,6 +373,7 @@ void ...@@ -371,6 +373,7 @@ void
dict_index_name_print( dict_index_name_print(
/*==================*/ /*==================*/
FILE* file, /* in: output stream */ FILE* file, /* in: output stream */
trx_t* trx, /* in: transaction */
const dict_index_t* index); /* in: index to print */ const dict_index_t* index); /* in: index to print */
/************************************************************************ /************************************************************************
Gets the first index on the table (the clustered index). */ Gets the first index on the table (the clustered index). */
......
...@@ -147,12 +147,13 @@ row_build_row_ref_in_tuple( ...@@ -147,12 +147,13 @@ row_build_row_ref_in_tuple(
dtuple_t* ref, /* in/out: row reference built; see the dtuple_t* ref, /* in/out: row reference built; see the
NOTE below! */ NOTE below! */
dict_index_t* index, /* in: index */ 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 NOTE: the data fields in ref will point
directly into this record, therefore, directly into this record, therefore,
the buffer page of this record must be the buffer page of this record must be
at least s-latched and the latch held at least s-latched and the latch held
as long as the row reference is used! */ 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 From a row build a row reference with which we can search the clustered
index record. */ index record. */
......
...@@ -105,7 +105,8 @@ row_sel_convert_mysql_key_to_innobase( ...@@ -105,7 +105,8 @@ row_sel_convert_mysql_key_to_innobase(
ulint buf_len, /* in: buffer length */ ulint buf_len, /* in: buffer length */
dict_index_t* index, /* in: index of the key value */ dict_index_t* index, /* in: index of the key value */
byte* key_ptr, /* in: MySQL 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 Searches for rows in the database. This is used in the interface to
MySQL. This function opens a cursor, and also implements fetch next MySQL. This function opens a cursor, and also implements fetch next
......
...@@ -55,7 +55,8 @@ upd_field_set_field_no( ...@@ -55,7 +55,8 @@ upd_field_set_field_no(
upd_field_t* upd_field, /* in: update vector field */ upd_field_t* upd_field, /* in: update vector field */
ulint field_no, /* in: field number in a clustered ulint field_no, /* in: field number in a clustered
index */ 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 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. */ to determine their positions within a clustered index record. */
...@@ -149,6 +150,7 @@ row_upd_build_sec_rec_difference_binary( ...@@ -149,6 +150,7 @@ row_upd_build_sec_rec_difference_binary(
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
dtuple_t* entry, /* in: entry to insert */ dtuple_t* entry, /* in: entry to insert */
rec_t* rec, /* in: secondary index record */ rec_t* rec, /* in: secondary index record */
trx_t* trx, /* in: transaction */
mem_heap_t* heap); /* in: memory heap from which allocated */ mem_heap_t* heap); /* in: memory heap from which allocated */
/******************************************************************* /*******************************************************************
Builds an update vector from those fields, excluding the roll ptr and Builds an update vector from those fields, excluding the roll ptr and
...@@ -166,6 +168,7 @@ row_upd_build_difference_binary( ...@@ -166,6 +168,7 @@ row_upd_build_difference_binary(
externally stored fields in entry, or NULL */ externally stored fields in entry, or NULL */
ulint n_ext_vec,/* in: number of fields in ext_vec */ ulint n_ext_vec,/* in: number of fields in ext_vec */
rec_t* rec, /* in: clustered index record */ rec_t* rec, /* in: clustered index record */
trx_t* trx, /* in: transaction */
mem_heap_t* heap); /* in: memory heap from which allocated */ mem_heap_t* heap); /* in: memory heap from which allocated */
/*************************************************************** /***************************************************************
Replaces the new column values stored in the update vector to the index entry Replaces the new column values stored in the update vector to the index entry
......
...@@ -78,7 +78,8 @@ upd_field_set_field_no( ...@@ -78,7 +78,8 @@ upd_field_set_field_no(
upd_field_t* upd_field, /* in: update vector field */ upd_field_t* upd_field, /* in: update vector field */
ulint field_no, /* in: field number in a clustered ulint field_no, /* in: field number in a clustered
index */ index */
dict_index_t* index) /* in: index */ dict_index_t* index, /* in: index */
trx_t* trx) /* in: transaction */
{ {
upd_field->field_no = field_no; upd_field->field_no = field_no;
...@@ -86,7 +87,7 @@ upd_field_set_field_no( ...@@ -86,7 +87,7 @@ upd_field_set_field_no(
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access field %lu in ", "InnoDB: Error: trying to access field %lu in ",
(ulong) field_no); (ulong) field_no);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, trx, index);
fprintf(stderr, "\n" fprintf(stderr, "\n"
"InnoDB: but index only has %lu fields\n", "InnoDB: but index only has %lu fields\n",
(ulong) dict_index_get_n_fields(index)); (ulong) dict_index_get_n_fields(index));
......
...@@ -145,6 +145,7 @@ trx_undo_update_rec_get_update( ...@@ -145,6 +145,7 @@ trx_undo_update_rec_get_update(
dulint trx_id, /* in: transaction id from this undorecord */ dulint trx_id, /* in: transaction id from this undorecord */
dulint roll_ptr,/* in: roll pointer from this undo record */ dulint roll_ptr,/* in: roll pointer from this undo record */
ulint info_bits,/* in: info bits 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 mem_heap_t* heap, /* in: memory heap from which the memory
needed is allocated */ needed is allocated */
upd_t** upd); /* out, own: update vector */ upd_t** upd); /* out, own: update vector */
......
...@@ -197,13 +197,25 @@ ut_print_buf( ...@@ -197,13 +197,25 @@ ut_print_buf(
const byte* buf, /* in: memory buffer */ const byte* buf, /* in: memory buffer */
ulint len); /* in: length of the buffer */ 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. */ Outputs a NUL-terminated string, quoted as an SQL identifier. */
struct trx_struct;
void void
ut_print_name( ut_print_name(
/*==========*/ /*==========*/
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
struct trx_struct*trx, /* in: transaction */
const char* name); /* in: name to print */ const char* name); /* in: name to print */
/************************************************************************** /**************************************************************************
...@@ -213,6 +225,7 @@ void ...@@ -213,6 +225,7 @@ void
ut_print_namel( ut_print_namel(
/*==========*/ /*==========*/
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
struct trx_struct*trx, /* in: transaction (NULL=no quotes) */
const char* name, /* in: name to print */ const char* name, /* in: name to print */
ulint namelen);/* in: length of name */ ulint namelen);/* in: length of name */
......
...@@ -398,7 +398,7 @@ lock_check_trx_id_sanity( ...@@ -398,7 +398,7 @@ lock_check_trx_id_sanity(
stderr); stderr);
rec_print(stderr, rec); rec_print(stderr, rec);
fputs("InnoDB: in ", stderr); fputs("InnoDB: in ", stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
fprintf(stderr, "\n" fprintf(stderr, "\n"
"InnoDB: is %lu %lu which is higher than the global trx id counter %lu %lu!\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", "InnoDB: The table is corrupt. You have to do dump + drop + reimport.\n",
...@@ -1651,7 +1651,7 @@ lock_rec_enqueue_waiting( ...@@ -1651,7 +1651,7 @@ lock_rec_enqueue_waiting(
fputs( fputs(
" InnoDB: Error: a record lock wait happens in a dictionary operation!\n" " InnoDB: Error: a record lock wait happens in a dictionary operation!\n"
"InnoDB: Table name ", stderr); "InnoDB: Table name ", stderr);
ut_print_name(stderr, index->table_name); ut_print_name(stderr, trx, index->table_name);
fputs(".\n" fputs(".\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n",
stderr); stderr);
...@@ -1688,7 +1688,7 @@ lock_rec_enqueue_waiting( ...@@ -1688,7 +1688,7 @@ lock_rec_enqueue_waiting(
if (lock_print_waits) { if (lock_print_waits) {
fprintf(stderr, "Lock wait for trx %lu in index ", fprintf(stderr, "Lock wait for trx %lu in index ",
(ulong) ut_dulint_get_low(trx->id)); (ulong) ut_dulint_get_low(trx->id));
ut_print_name(stderr, index->name); ut_print_name(stderr, trx, index->name);
} }
return(DB_LOCK_WAIT); return(DB_LOCK_WAIT);
...@@ -3293,7 +3293,7 @@ lock_table_enqueue_waiting( ...@@ -3293,7 +3293,7 @@ lock_table_enqueue_waiting(
fputs( fputs(
" InnoDB: Error: a table lock wait happens in a dictionary operation!\n" " InnoDB: Error: a table lock wait happens in a dictionary operation!\n"
"InnoDB: Table name ", stderr); "InnoDB: Table name ", stderr);
ut_print_name(stderr, table->name); ut_print_name(stderr, trx, table->name);
fputs(".\n" fputs(".\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n",
stderr); stderr);
...@@ -3820,7 +3820,7 @@ lock_table_print( ...@@ -3820,7 +3820,7 @@ lock_table_print(
fputs("EXPLICIT ", file); fputs("EXPLICIT ", file);
} }
fputs("TABLE LOCK table ", 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", fprintf(file, " trx id %lu %lu",
(ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.low); (ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.low);
...@@ -3871,7 +3871,7 @@ lock_rec_print( ...@@ -3871,7 +3871,7 @@ lock_rec_print(
fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ", fprintf(file, "RECORD LOCKS space id %lu page no %lu n bits %lu ",
(ulong) space, (ulong) page_no, (ulong) space, (ulong) page_no,
(ulong) lock_rec_get_n_bits(lock)); (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", fprintf(file, " trx id %lu %lu",
(ulong) (lock->trx)->id.high, (ulong) (lock->trx)->id.high,
(ulong) (lock->trx)->id.low); (ulong) (lock->trx)->id.low);
......
...@@ -1579,7 +1579,7 @@ page_validate( ...@@ -1579,7 +1579,7 @@ page_validate(
fputs("InnoDB: Record heap and dir overlap on a page ", fputs("InnoDB: Record heap and dir overlap on a page ",
stderr); stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
fprintf(stderr, ", %p, %p\n", fprintf(stderr, ", %p, %p\n",
page_header_get_ptr(page, PAGE_HEAP_TOP), page_header_get_ptr(page, PAGE_HEAP_TOP),
page_dir_get_nth_slot(page, n_slots - 1)); page_dir_get_nth_slot(page, n_slots - 1));
...@@ -1610,7 +1610,7 @@ page_validate( ...@@ -1610,7 +1610,7 @@ page_validate(
fprintf(stderr, fprintf(stderr,
"InnoDB: Records in wrong order on page %lu", "InnoDB: Records in wrong order on page %lu",
(ulong) buf_frame_get_page_no(page)); (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); fputs("\nInnoDB: previous record ", stderr);
rec_print(stderr, old_rec); rec_print(stderr, old_rec);
fputs("\nInnoDB: record ", stderr); fputs("\nInnoDB: record ", stderr);
...@@ -1752,7 +1752,7 @@ func_exit: ...@@ -1752,7 +1752,7 @@ func_exit:
func_exit2: func_exit2:
fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ", fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ",
(ulong) buf_frame_get_page_no(page)); (ulong) buf_frame_get_page_no(page));
dict_index_name_print(stderr, index); dict_index_name_print(stderr, NULL, index);
putc('\n', stderr); putc('\n', stderr);
buf_page_print(page); buf_page_print(page);
} }
......
...@@ -1229,7 +1229,7 @@ opt_print_query_plan( ...@@ -1229,7 +1229,7 @@ opt_print_query_plan(
} }
fputs("Table ", stderr); 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", fprintf(stderr,"; exact m. %lu, match %lu, end conds %lu\n",
(unsigned long) plan->n_exact_match, (unsigned long) plan->n_exact_match,
(unsigned long) n_fields, (unsigned long) n_fields,
......
...@@ -886,7 +886,7 @@ pars_process_assign_list( ...@@ -886,7 +886,7 @@ pars_process_assign_list(
upd_field_set_field_no(upd_field, upd_field_set_field_no(upd_field,
dict_index_get_nth_col_pos(clust_index, dict_index_get_nth_col_pos(clust_index,
col_sym->col_no), col_sym->col_no),
clust_index); clust_index, NULL);
upd_field->exp = assign_node->val; upd_field->exp = assign_node->val;
if (!dtype_is_fixed_size( if (!dtype_is_fixed_size(
......
...@@ -252,7 +252,7 @@ row_ins_sec_index_entry_by_modify( ...@@ -252,7 +252,7 @@ row_ins_sec_index_entry_by_modify(
heap = mem_heap_create(1024); heap = mem_heap_create(1024);
update = row_upd_build_sec_rec_difference_binary(cursor->index, 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) { if (mode == BTR_MODIFY_LEAF) {
/* Try an optimistic updating of the record, keeping changes /* Try an optimistic updating of the record, keeping changes
within the page */ within the page */
...@@ -316,7 +316,7 @@ row_ins_clust_index_entry_by_modify( ...@@ -316,7 +316,7 @@ row_ins_clust_index_entry_by_modify(
roll_ptr */ roll_ptr */
update = row_upd_build_difference_binary(cursor->index, entry, ext_vec, 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) { if (mode == BTR_MODIFY_LEAF) {
/* Try optimistic updating of the record, keeping changes /* Try optimistic updating of the record, keeping changes
within the page */ within the page */
...@@ -554,29 +554,30 @@ row_ins_foreign_report_err( ...@@ -554,29 +554,30 @@ row_ins_foreign_report_err(
table */ table */
{ {
FILE* ef = dict_foreign_err_file; FILE* ef = dict_foreign_err_file;
trx_t* trx = thr_get_trx(thr);
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
rewind(ef); rewind(ef);
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Transaction:\n", ef); fputs(" Transaction:\n", ef);
trx_print(ef, thr_get_trx(thr)); trx_print(ef, trx);
fputs("Foreign key constraint fails for table ", ef); 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); 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); putc('\n', ef);
fputs(errstr, ef); fputs(errstr, ef);
fputs(" in parent table, in index ", 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) { if (entry) {
fputs(" tuple:\n", ef); fputs(" tuple:\n", ef);
dtuple_print(ef, entry); dtuple_print(ef, entry);
} }
fputs("\nBut in child table ", ef); 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); fputs(", in index ", ef);
ut_print_name(ef, foreign->foreign_index->name); ut_print_name(ef, trx, foreign->foreign_index->name);
if (rec) { if (rec) {
fputs(", there is a record:\n", ef); fputs(", there is a record:\n", ef);
rec_print(ef, rec); rec_print(ef, rec);
...@@ -612,19 +613,19 @@ row_ins_foreign_report_add_err( ...@@ -612,19 +613,19 @@ row_ins_foreign_report_add_err(
fputs(" Transaction:\n", ef); fputs(" Transaction:\n", ef);
trx_print(ef, trx); trx_print(ef, trx);
fputs("Foreign key constraint fails for table ", ef); 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); 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); 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) { if (entry) {
fputs(" tuple:\n", ef); fputs(" tuple:\n", ef);
dtuple_print(ef, entry); dtuple_print(ef, entry);
} }
fputs("\nBut in parent table ", ef); 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); 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); fputs(",\nthe closest match we can find is record:\n", ef);
if (rec && page_rec_is_supremum(rec)) { if (rec && page_rec_is_supremum(rec)) {
/* If the cursor ended on a supremum record, it is better /* If the cursor ended on a supremum record, it is better
...@@ -704,11 +705,13 @@ row_ins_foreign_check_on_constraint( ...@@ -704,11 +705,13 @@ row_ins_foreign_check_on_constraint(
ulint n_to_update; ulint n_to_update;
ulint err; ulint err;
ulint i; ulint i;
trx_t* trx;
ut_a(thr && foreign && pcur && mtr); 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 /* Since we are going to delete or update a row, we have to invalidate
the MySQL query cache for table */ the MySQL query cache for table */
...@@ -847,7 +850,7 @@ row_ins_foreign_check_on_constraint( ...@@ -847,7 +850,7 @@ row_ins_foreign_check_on_constraint(
fputs( fputs(
"InnoDB: error in cascade of a foreign key op\n" "InnoDB: error in cascade of a foreign key op\n"
"InnoDB: ", stderr); "InnoDB: ", stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, trx, index);
fputs("\n" fputs("\n"
"InnoDB: record ", stderr); "InnoDB: record ", stderr);
...@@ -1057,6 +1060,7 @@ row_ins_check_foreign_constraint( ...@@ -1057,6 +1060,7 @@ row_ins_check_foreign_constraint(
ulint err; ulint err;
ulint i; ulint i;
mtr_t mtr; mtr_t mtr;
trx_t* trx = thr_get_trx(thr);
run_again: run_again:
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
...@@ -1065,7 +1069,7 @@ run_again: ...@@ -1065,7 +1069,7 @@ run_again:
err = DB_SUCCESS; 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 /* The user has suppressed foreign key checks currently for
this session */ this session */
...@@ -1123,18 +1127,18 @@ run_again: ...@@ -1123,18 +1127,18 @@ run_again:
rewind(ef); rewind(ef);
ut_print_timestamp(ef); ut_print_timestamp(ef);
fputs(" Transaction:\n", ef); fputs(" Transaction:\n", ef);
trx_print(ef, thr_get_trx(thr)); trx_print(ef, trx);
fputs("Foreign key constraint fails for table ", ef); 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); fputs(":\n", ef);
dict_print_info_on_foreign_key_in_create_format(ef, dict_print_info_on_foreign_key_in_create_format(ef,
foreign); trx, foreign);
fputs("\nTrying to add to index ", ef); 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); fputs(" tuple:\n", ef);
dtuple_print(ef, entry); dtuple_print(ef, entry);
fputs("\nBut the parent table ", ef); 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); fputs(" does not currently exist!\n", ef);
mutex_exit(&dict_foreign_err_mutex); mutex_exit(&dict_foreign_err_mutex);
...@@ -1267,7 +1271,7 @@ run_again: ...@@ -1267,7 +1271,7 @@ run_again:
if (check_ref) { if (check_ref) {
err = DB_NO_REFERENCED_ROW; err = DB_NO_REFERENCED_ROW;
row_ins_foreign_report_add_err( row_ins_foreign_report_add_err(
thr_get_trx(thr), foreign, rec, entry); trx, foreign, rec, entry);
} else { } else {
err = DB_SUCCESS; err = DB_SUCCESS;
} }
...@@ -1283,7 +1287,7 @@ next_rec: ...@@ -1283,7 +1287,7 @@ next_rec:
if (check_ref) { if (check_ref) {
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
row_ins_foreign_report_add_err( row_ins_foreign_report_add_err(
thr_get_trx(thr), foreign, rec, entry); trx, foreign, rec, entry);
err = DB_NO_REFERENCED_ROW; err = DB_NO_REFERENCED_ROW;
} else { } else {
err = DB_SUCCESS; err = DB_SUCCESS;
...@@ -1302,18 +1306,18 @@ next_rec: ...@@ -1302,18 +1306,18 @@ next_rec:
do_possible_lock_wait: do_possible_lock_wait:
if (err == DB_LOCK_WAIT) { if (err == DB_LOCK_WAIT) {
thr_get_trx(thr)->error_state = err; trx->error_state = err;
que_thr_stop_for_mysql(thr); que_thr_stop_for_mysql(thr);
srv_suspend_mysql_thread(thr); srv_suspend_mysql_thread(thr);
if (thr_get_trx(thr)->error_state == DB_SUCCESS) { if (trx->error_state == DB_SUCCESS) {
goto run_again; goto run_again;
} }
err = thr_get_trx(thr)->error_state; err = trx->error_state;
} }
return(err); return(err);
......
This diff is collapsed.
...@@ -543,8 +543,8 @@ row_purge_parse_undo_rec( ...@@ -543,8 +543,8 @@ row_purge_parse_undo_rec(
node->heap); node->heap);
ptr = trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, ptr = trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id,
roll_ptr, info_bits, node->heap, roll_ptr, info_bits, trx,
&(node->update)); node->heap, &(node->update));
/* Read to the partial row the fields that occur in indexes */ /* Read to the partial row the fields that occur in indexes */
......
...@@ -383,12 +383,13 @@ row_build_row_ref_in_tuple( ...@@ -383,12 +383,13 @@ row_build_row_ref_in_tuple(
dtuple_t* ref, /* in/out: row reference built; see the dtuple_t* ref, /* in/out: row reference built; see the
NOTE below! */ NOTE below! */
dict_index_t* index, /* in: index */ 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 NOTE: the data fields in ref will point
directly into this record, therefore, directly into this record, therefore,
the buffer page of this record must be the buffer page of this record must be
at least s-latched and the latch held at least s-latched and the latch held
as long as the row reference is used! */ as long as the row reference is used! */
trx_t* trx) /* in: transaction */
{ {
dict_index_t* clust_index; dict_index_t* clust_index;
dfield_t* dfield; dfield_t* dfield;
...@@ -403,9 +404,9 @@ row_build_row_ref_in_tuple( ...@@ -403,9 +404,9 @@ row_build_row_ref_in_tuple(
if (!index->table) { if (!index->table) {
fputs("InnoDB: table ", stderr); fputs("InnoDB: table ", stderr);
notfound: notfound:
ut_print_name(stderr, index->table_name); ut_print_name(stderr, trx, index->table_name);
fputs(" for index ", stderr); fputs(" for index ", stderr);
ut_print_name(stderr, index->name); ut_print_name(stderr, trx, index->name);
fputs(" not found\n", stderr); fputs(" not found\n", stderr);
ut_error; ut_error;
} }
......
...@@ -1942,7 +1942,8 @@ row_sel_convert_mysql_key_to_innobase( ...@@ -1942,7 +1942,8 @@ row_sel_convert_mysql_key_to_innobase(
ulint buf_len, /* in: buffer length */ ulint buf_len, /* in: buffer length */
dict_index_t* index, /* in: index of the key value */ dict_index_t* index, /* in: index of the key value */
byte* key_ptr, /* in: MySQL 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_buf = buf;
byte* original_key_ptr = key_ptr; byte* original_key_ptr = key_ptr;
...@@ -2025,7 +2026,7 @@ row_sel_convert_mysql_key_to_innobase( ...@@ -2025,7 +2026,7 @@ row_sel_convert_mysql_key_to_innobase(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs( fputs(
" InnoDB: Error: BLOB or TEXT prefix > 255 bytes in query to table ", stderr); " 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); putc('\n', stderr);
} }
...@@ -2069,11 +2070,13 @@ row_sel_convert_mysql_key_to_innobase( ...@@ -2069,11 +2070,13 @@ row_sel_convert_mysql_key_to_innobase(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fputs(
" InnoDB: Warning: using a partial-field key prefix in search.\n" " 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 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) data_field_len,
(ulong) (key_ptr - key_end)); (ulong) (key_ptr - key_end));
fflush(stderr); fflush(stderr);
...@@ -2116,7 +2119,7 @@ row_sel_store_row_id_to_prebuilt( ...@@ -2116,7 +2119,7 @@ row_sel_store_row_id_to_prebuilt(
if (len != DATA_ROW_ID_LEN) { if (len != DATA_ROW_ID_LEN) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: Row id field is wrong length %lu in ", (ulong) len); "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" fprintf(stderr, "\n"
"InnoDB: Field number %lu, record:\n", "InnoDB: Field number %lu, record:\n",
(ulong) dict_index_get_sys_col_pos(index, DATA_ROW_ID)); (ulong) dict_index_get_sys_col_pos(index, DATA_ROW_ID));
...@@ -2275,7 +2278,11 @@ row_sel_store_mysql_rec( ...@@ -2275,7 +2278,11 @@ row_sel_store_mysql_rec(
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" InnoDB: Warning: could not allocate %lu + 1000000 bytes to retrieve\n" " 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) { if (extern_field_heap) {
mem_heap_free( mem_heap_free(
...@@ -2407,8 +2414,9 @@ row_sel_get_clust_rec_for_mysql( ...@@ -2407,8 +2414,9 @@ row_sel_get_clust_rec_for_mysql(
trx_t* trx; trx_t* trx;
*out_rec = NULL; *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); clust_index = dict_table_get_first_index(sec_index->table);
...@@ -2441,7 +2449,7 @@ row_sel_get_clust_rec_for_mysql( ...@@ -2441,7 +2449,7 @@ row_sel_get_clust_rec_for_mysql(
fputs(" InnoDB: error clustered record" fputs(" InnoDB: error clustered record"
" for sec rec not found\n" " for sec rec not found\n"
"InnoDB: ", stderr); "InnoDB: ", stderr);
dict_index_name_print(stderr, sec_index); dict_index_name_print(stderr, trx, sec_index);
fputs("\n" fputs("\n"
"InnoDB: sec index record ", stderr); "InnoDB: sec index record ", stderr);
rec_print(stderr, rec); rec_print(stderr, rec);
...@@ -2449,7 +2457,7 @@ row_sel_get_clust_rec_for_mysql( ...@@ -2449,7 +2457,7 @@ row_sel_get_clust_rec_for_mysql(
"InnoDB: clust index record ", stderr); "InnoDB: clust index record ", stderr);
rec_print(stderr, clust_rec); rec_print(stderr, clust_rec);
putc('\n', stderr); putc('\n', stderr);
trx_print(stderr, thr_get_trx(thr)); trx_print(stderr, trx);
fputs("\n" fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
...@@ -2477,8 +2485,6 @@ row_sel_get_clust_rec_for_mysql( ...@@ -2477,8 +2485,6 @@ row_sel_get_clust_rec_for_mysql(
/* This is a non-locking consistent read: if necessary, fetch /* This is a non-locking consistent read: if necessary, fetch
a previous version of the record */ a previous version of the record */
trx = thr_get_trx(thr);
old_vers = NULL; old_vers = NULL;
/* If the isolation level allows reading of uncommitted data, /* If the isolation level allows reading of uncommitted data,
...@@ -2803,7 +2809,7 @@ row_search_for_mysql( ...@@ -2803,7 +2809,7 @@ row_search_for_mysql(
"InnoDB: Error: trying to free a corrupt\n" "InnoDB: Error: trying to free a corrupt\n"
"InnoDB: table handle. Magic n %lu, table name ", "InnoDB: table handle. Magic n %lu, table name ",
(ulong) prebuilt->magic_n); (ulong) prebuilt->magic_n);
ut_print_name(stderr, prebuilt->table->name); ut_print_name(stderr, trx, prebuilt->table->name);
putc('\n', stderr); putc('\n', stderr);
mem_analyze_corruption((byte*)prebuilt); mem_analyze_corruption((byte*)prebuilt);
...@@ -3237,7 +3243,7 @@ rec_loop: ...@@ -3237,7 +3243,7 @@ rec_loop:
(ulong) (rec - buf_frame_align(rec)), (ulong) (rec - buf_frame_align(rec)),
(ulong) next_offs, (ulong) next_offs,
(ulong) buf_frame_get_page_no(rec)); (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" fputs(". Run CHECK TABLE. You may need to\n"
"InnoDB: restore from a backup, or dump + drop + reimport the table.\n", "InnoDB: restore from a backup, or dump + drop + reimport the table.\n",
stderr); stderr);
...@@ -3255,7 +3261,7 @@ rec_loop: ...@@ -3255,7 +3261,7 @@ rec_loop:
(ulong) (rec - buf_frame_align(rec)), (ulong) (rec - buf_frame_align(rec)),
(ulong) next_offs, (ulong) next_offs,
(ulong) buf_frame_get_page_no(rec)); (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", fputs(". We try to skip the rest of the page.\n",
stderr); stderr);
...@@ -3274,7 +3280,7 @@ rec_loop: ...@@ -3274,7 +3280,7 @@ rec_loop:
(ulong) (rec - buf_frame_align(rec)), (ulong) (rec - buf_frame_align(rec)),
(ulong) next_offs, (ulong) next_offs,
(ulong) buf_frame_get_page_no(rec)); (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", fputs(". We try to skip the record.\n",
stderr); stderr);
......
...@@ -422,6 +422,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ...@@ -422,6 +422,7 @@ row_undo_mod_del_unmark_sec_and_undo_update(
ibool found; ibool found;
big_rec_t* dummy_big_rec; big_rec_t* dummy_big_rec;
mtr_t mtr; mtr_t mtr;
trx_t* trx = thr_get_trx(thr);
log_free_check(); log_free_check();
mtr_start(&mtr); mtr_start(&mtr);
...@@ -431,7 +432,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ...@@ -431,7 +432,7 @@ row_undo_mod_del_unmark_sec_and_undo_update(
if (!found) { if (!found) {
fputs("InnoDB: error in sec index entry del undo in\n" fputs("InnoDB: error in sec index entry del undo in\n"
"InnoDB: ", stderr); "InnoDB: ", stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, trx, index);
fputs("\n" fputs("\n"
"InnoDB: tuple ", stderr); "InnoDB: tuple ", stderr);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
...@@ -439,7 +440,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ...@@ -439,7 +440,7 @@ row_undo_mod_del_unmark_sec_and_undo_update(
"InnoDB: record ", stderr); "InnoDB: record ", stderr);
rec_print(stderr, btr_pcur_get_rec(&pcur)); rec_print(stderr, btr_pcur_get_rec(&pcur));
putc('\n', stderr); putc('\n', stderr);
trx_print(stderr, thr_get_trx(thr)); trx_print(stderr, trx);
fputs("\n" fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
} else { } else {
...@@ -451,7 +452,7 @@ row_undo_mod_del_unmark_sec_and_undo_update( ...@@ -451,7 +452,7 @@ row_undo_mod_del_unmark_sec_and_undo_update(
heap = mem_heap_create(100); heap = mem_heap_create(100);
update = row_upd_build_sec_rec_difference_binary(index, entry, 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) { if (upd_get_n_fields(update) == 0) {
/* Do nothing */ /* Do nothing */
...@@ -671,14 +672,15 @@ row_undo_mod_parse_undo_rec( ...@@ -671,14 +672,15 @@ row_undo_mod_parse_undo_rec(
ulint type; ulint type;
ulint cmpl_info; ulint cmpl_info;
ibool dummy_extern; ibool dummy_extern;
trx_t* trx;
ut_ad(node && thr); ut_ad(node && thr);
trx = thr_get_trx(thr);
ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info, ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info,
&dummy_extern, &undo_no, &table_id); &dummy_extern, &undo_no, &table_id);
node->rec_type = type; 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 /* TODO: other fixes associated with DROP TABLE + rollback in the
same table by another user */ same table by another user */
...@@ -704,8 +706,8 @@ row_undo_mod_parse_undo_rec( ...@@ -704,8 +706,8 @@ row_undo_mod_parse_undo_rec(
node->heap); node->heap);
trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id, trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id,
roll_ptr, info_bits, node->heap, roll_ptr, info_bits, trx,
&(node->update)); node->heap, &(node->update));
node->new_roll_ptr = roll_ptr; node->new_roll_ptr = roll_ptr;
node->new_trx_id = trx_id; node->new_trx_id = trx_id;
node->cmpl_info = cmpl_info; node->cmpl_info = cmpl_info;
......
...@@ -685,6 +685,7 @@ row_upd_build_sec_rec_difference_binary( ...@@ -685,6 +685,7 @@ row_upd_build_sec_rec_difference_binary(
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
dtuple_t* entry, /* in: entry to insert */ dtuple_t* entry, /* in: entry to insert */
rec_t* rec, /* in: secondary index record */ rec_t* rec, /* in: secondary index record */
trx_t* trx, /* in: transaction */
mem_heap_t* heap) /* in: memory heap from which allocated */ mem_heap_t* heap) /* in: memory heap from which allocated */
{ {
upd_field_t* upd_field; upd_field_t* upd_field;
...@@ -725,7 +726,7 @@ row_upd_build_sec_rec_difference_binary( ...@@ -725,7 +726,7 @@ row_upd_build_sec_rec_difference_binary(
dfield_copy(&(upd_field->new_val), dfield); 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; upd_field->extern_storage = FALSE;
...@@ -754,6 +755,7 @@ row_upd_build_difference_binary( ...@@ -754,6 +755,7 @@ row_upd_build_difference_binary(
externally stored fields in entry, or NULL */ externally stored fields in entry, or NULL */
ulint n_ext_vec,/* in: number of fields in ext_vec */ ulint n_ext_vec,/* in: number of fields in ext_vec */
rec_t* rec, /* in: clustered index record */ rec_t* rec, /* in: clustered index record */
trx_t* trx, /* in: transaction */
mem_heap_t* heap) /* in: memory heap from which allocated */ mem_heap_t* heap) /* in: memory heap from which allocated */
{ {
upd_field_t* upd_field; upd_field_t* upd_field;
...@@ -800,7 +802,7 @@ row_upd_build_difference_binary( ...@@ -800,7 +802,7 @@ row_upd_build_difference_binary(
dfield_copy(&(upd_field->new_val), dfield); 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)) { if (upd_ext_vec_contains(ext_vec, n_ext_vec, i)) {
upd_field->extern_storage = TRUE; upd_field->extern_storage = TRUE;
...@@ -1200,10 +1202,11 @@ row_upd_sec_index_entry( ...@@ -1200,10 +1202,11 @@ row_upd_sec_index_entry(
rec_t* rec; rec_t* rec;
ulint err = DB_SUCCESS; ulint err = DB_SUCCESS;
mtr_t mtr; mtr_t mtr;
trx_t* trx = thr_get_trx(thr);
index = node->index; 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); heap = mem_heap_create(1024);
...@@ -1222,7 +1225,7 @@ row_upd_sec_index_entry( ...@@ -1222,7 +1225,7 @@ row_upd_sec_index_entry(
if (!found) { if (!found) {
fputs("InnoDB: error in sec index entry update in\n" fputs("InnoDB: error in sec index entry update in\n"
"InnoDB: ", stderr); "InnoDB: ", stderr);
dict_index_name_print(stderr, index); dict_index_name_print(stderr, trx, index);
fputs("\n" fputs("\n"
"InnoDB: tuple ", stderr); "InnoDB: tuple ", stderr);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
...@@ -1231,7 +1234,7 @@ row_upd_sec_index_entry( ...@@ -1231,7 +1234,7 @@ row_upd_sec_index_entry(
rec_print(stderr, rec); rec_print(stderr, rec);
putc('\n', stderr); putc('\n', stderr);
trx_print(stderr, thr_get_trx(thr)); trx_print(stderr, trx);
fputs("\n" fputs("\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr);
......
...@@ -770,6 +770,7 @@ trx_undo_update_rec_get_update( ...@@ -770,6 +770,7 @@ trx_undo_update_rec_get_update(
dulint trx_id, /* in: transaction id from this undo record */ dulint trx_id, /* in: transaction id from this undo record */
dulint roll_ptr,/* in: roll pointer from this undo record */ dulint roll_ptr,/* in: roll pointer from this undo record */
ulint info_bits,/* in: info bits 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 mem_heap_t* heap, /* in: memory heap from which the memory
needed is allocated */ needed is allocated */
upd_t** upd) /* out, own: update vector */ upd_t** upd) /* out, own: update vector */
...@@ -803,7 +804,7 @@ trx_undo_update_rec_get_update( ...@@ -803,7 +804,7 @@ trx_undo_update_rec_get_update(
upd_field_set_field_no(upd_field, upd_field_set_field_no(upd_field,
dict_index_get_sys_col_pos(index, DATA_TRX_ID), 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); dfield_set_data(&(upd_field->new_val), buf, DATA_TRX_ID_LEN);
upd_field = upd_get_nth_field(update, n_fields + 1); upd_field = upd_get_nth_field(update, n_fields + 1);
...@@ -812,7 +813,7 @@ trx_undo_update_rec_get_update( ...@@ -812,7 +813,7 @@ trx_undo_update_rec_get_update(
upd_field_set_field_no(upd_field, upd_field_set_field_no(upd_field,
dict_index_get_sys_col_pos(index, DATA_ROLL_PTR), 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); dfield_set_data(&(upd_field->new_val), buf, DATA_ROLL_PTR_LEN);
/* Store then the updated ordinary columns to the update vector */ /* Store then the updated ordinary columns to the update vector */
...@@ -824,13 +825,13 @@ trx_undo_update_rec_get_update( ...@@ -824,13 +825,13 @@ trx_undo_update_rec_get_update(
if (field_no >= dict_index_get_n_fields(index)) { if (field_no >= dict_index_get_n_fields(index)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: trying to access update undo rec field %lu in ", (ulong) field_no); "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" fprintf(stderr, "\n"
"InnoDB: but index has only %lu fields\n" "InnoDB: but index has only %lu fields\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n"
"InnoDB: Run also CHECK TABLE ", "InnoDB: Run also CHECK TABLE ",
(ulong) dict_index_get_n_fields(index)); (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" fprintf(stderr, "\n"
"InnoDB: n_fields = %lu, i = %lu, ptr %p\n", "InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
(ulong) n_fields, (ulong) i, ptr); (ulong) n_fields, (ulong) i, ptr);
...@@ -841,7 +842,7 @@ trx_undo_update_rec_get_update( ...@@ -841,7 +842,7 @@ trx_undo_update_rec_get_update(
upd_field = upd_get_nth_field(update, i); 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) { if (len != UNIV_SQL_NULL && len >= UNIV_EXTERN_STORAGE_FIELD) {
...@@ -1266,12 +1267,11 @@ trx_undo_prev_version_build( ...@@ -1266,12 +1267,11 @@ trx_undo_prev_version_build(
mtr_memo_contains(index_mtr, buf_block_align(index_rec), mtr_memo_contains(index_mtr, buf_block_align(index_rec),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
if (!(index->type & DICT_CLUSTERED)) { if (!(index->type & DICT_CLUSTERED)) {
fputs("InnoDB: Error: trying to access" fprintf(stderr, "InnoDB: Error: trying to access"
" update undo rec for non-clustered ", stderr); " update undo rec for non-clustered index %s\n"
dict_index_name_print(stderr, index); "InnoDB: Submit a detailed bug report to"
fputs("\n" " http://bugs.mysql.com\n"
"InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n" "InnoDB: index record ", index->name);
"InnoDB: index record ", stderr);
rec_print(stderr, index_rec); rec_print(stderr, index_rec);
fputs("\n" fputs("\n"
"InnoDB: record version ", stderr); "InnoDB: record version ", stderr);
...@@ -1309,32 +1309,29 @@ trx_undo_prev_version_build( ...@@ -1309,32 +1309,29 @@ trx_undo_prev_version_build(
ptr = trx_undo_rec_skip_row_ref(ptr, index); ptr = trx_undo_rec_skip_row_ref(ptr, index);
ptr = trx_undo_update_rec_get_update(ptr, index, type, trx_id, 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) { if (ut_dulint_cmp(table_id, index->table->id) != 0) {
ptr = NULL; ptr = NULL;
fputs("InnoDB: Error: trying to access" fprintf(stderr,
" update undo rec for table ", stderr); "InnoDB: Error: trying to access update undo rec for table %s\n"
ut_print_name(stderr, index->table_name);
fputs("\n"
"InnoDB: but the table id in the undo record is wrong\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: Submit a detailed bug report to http://bugs.mysql.com\n"
"InnoDB: Run also CHECK TABLE ", stderr); "InnoDB: Run also CHECK TABLE %s\n",
ut_print_name(stderr, index->table_name); index->table_name, index->table_name);
putc('\n', stderr);
} }
if (ptr == NULL) { if (ptr == NULL) {
/* The record was corrupted, return an error; these printfs /* The record was corrupted, return an error; these printfs
should catch an elusive bug in row_vers_old_has_index_entry */ should catch an elusive bug in row_vers_old_has_index_entry */
fputs("InnoDB: ", stderr); fprintf(stderr,
dict_index_name_print(stderr, index); "InnoDB: table %s, index %s, n_uniq %lu\n"
fprintf(stderr, ", n_uniq %lu\n"
"InnoDB: undo rec address %p, type %lu cmpl_info %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: undo rec table id %lu %lu, index table id %lu %lu\n"
"InnoDB: dump of 150 bytes in undo rec: ", "InnoDB: dump of 150 bytes in undo rec: ",
index->table_name, index->name,
(ulong) dict_index_get_n_unique(index), (ulong) dict_index_get_n_unique(index),
undo_rec, (ulong) type, (ulong) cmpl_info, undo_rec, (ulong) type, (ulong) cmpl_info,
(ulong) ut_dulint_get_high(table_id), (ulong) ut_dulint_get_high(table_id),
......
...@@ -229,7 +229,7 @@ trx_rollback_to_savepoint_for_mysql( ...@@ -229,7 +229,7 @@ trx_rollback_to_savepoint_for_mysql(
if (trx->conc_state == TRX_NOT_STARTED) { if (trx->conc_state == TRX_NOT_STARTED) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fputs(" InnoDB: Error: transaction has a savepoint ", 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); fputs(" though it is not started\n", stderr);
return(DB_ERROR); return(DB_ERROR);
} }
...@@ -467,7 +467,7 @@ loop: ...@@ -467,7 +467,7 @@ loop:
if (table) { if (table) {
fputs("InnoDB: Table found: dropping table ", stderr); 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); fputs(" in recovery\n", stderr);
err = row_drop_table_for_mysql(table->name, trx, TRUE); err = row_drop_table_for_mysql(table->name, trx, TRUE);
......
...@@ -16,18 +16,22 @@ Created 5/11/1994 Heikki Tuuri ...@@ -16,18 +16,22 @@ Created 5/11/1994 Heikki Tuuri
#include <string.h> #include <string.h>
#include "ut0sort.h" #include "ut0sort.h"
#include "trx0trx.h"
ibool ut_always_false = FALSE; ibool ut_always_false = FALSE;
/********************************************************************* /*********************************************************************
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 sql/ha_innodb.cc! */ This definition must match the one in sql/ha_innodb.cc! */
extern
char int
mysql_get_identifier_quote_char(void); mysql_get_identifier_quote_char(
/*=================================*/ /*============================*/
/* out: quote character to be /* 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, Gets the high 32 bits in a ulint. That is makes a shift >> 32,
...@@ -333,6 +337,31 @@ ut_2_power_up( ...@@ -333,6 +337,31 @@ ut_2_power_up(
return(res); 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. */ Outputs a NUL-terminated string, quoted as an SQL identifier. */
...@@ -341,9 +370,10 @@ void ...@@ -341,9 +370,10 @@ void
ut_print_name( ut_print_name(
/*==========*/ /*==========*/
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction */
const char* name) /* in: name to print */ 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 ...@@ -353,12 +383,17 @@ void
ut_print_namel( ut_print_namel(
/*==========*/ /*==========*/
FILE* f, /* in: output stream */ FILE* f, /* in: output stream */
trx_t* trx, /* in: transaction (NULL=no quotes) */
const char* name, /* in: name to print */ const char* name, /* in: name to print */
ulint namelen)/* in: length of name */ ulint namelen)/* in: length of name */
{ {
const char* s = name; const char* s = name;
const char* e = s + namelen; 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); putc(q, f);
while (s < e) { while (s < e) {
int c = *s++; int c = *s++;
......
...@@ -736,15 +736,35 @@ innobase_invalidate_query_cache( ...@@ -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" extern "C"
char int
mysql_get_identifier_quote_char(void) mysql_get_identifier_quote_char(
/*=================================*/ /*============================*/
/* out: quote character to be /* 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 */
{ {
return '`'; 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(current_thd);
} }
/********************************************************************* /*********************************************************************
...@@ -1483,12 +1503,14 @@ ha_innobase::open( ...@@ -1483,12 +1503,14 @@ ha_innobase::open(
{ {
dict_table_t* ib_table; dict_table_t* ib_table;
char norm_name[1000]; char norm_name[1000];
THD* thd;
DBUG_ENTER("ha_innobase::open"); DBUG_ENTER("ha_innobase::open");
UT_NOT_USED(mode); UT_NOT_USED(mode);
UT_NOT_USED(test_if_locked); UT_NOT_USED(test_if_locked);
thd = current_thd;
normalize_table_name(norm_name, name); normalize_table_name(norm_name, name);
user_thd = NULL; user_thd = NULL;
...@@ -1538,7 +1560,7 @@ ha_innobase::open( ...@@ -1538,7 +1560,7 @@ ha_innobase::open(
DBUG_RETURN(1); 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); ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB error:\n" fprintf(stderr, " InnoDB error:\n"
"MySQL is trying to open a table handle but the .ibd file for\n" "MySQL is trying to open a table handle but the .ibd file for\n"
...@@ -2862,7 +2884,7 @@ ha_innobase::index_read( ...@@ -2862,7 +2884,7 @@ ha_innobase::index_read(
(ulint)upd_and_key_val_buff_len, (ulint)upd_and_key_val_buff_len,
index, index,
(byte*) key_ptr, (byte*) key_ptr,
(ulint) key_len); (ulint) key_len, prebuilt->trx);
} else { } else {
/* We position the cursor to the last or the first entry /* We position the cursor to the last or the first entry
in the index */ in the index */
...@@ -4074,14 +4096,16 @@ ha_innobase::records_in_range( ...@@ -4074,14 +4096,16 @@ ha_innobase::records_in_range(
index, index,
(byte*) (min_key ? min_key->key : (byte*) (min_key ? min_key->key :
(const mysql_byte*) 0), (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( row_sel_convert_mysql_key_to_innobase(
range_end, (byte*) key_val_buff2, range_end, (byte*) key_val_buff2,
buff2_len, index, buff2_len, index,
(byte*) (max_key ? max_key->key : (byte*) (max_key ? max_key->key :
(const mysql_byte*) 0), (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 : mode1 = convert_search_mode_to_innobase(min_key ? min_key->flag :
HA_READ_KEY_EXACT); HA_READ_KEY_EXACT);
...@@ -4468,7 +4492,8 @@ ha_innobase::update_table_comment( ...@@ -4468,7 +4492,8 @@ ha_innobase::update_table_comment(
(ulong) fsp_get_available_space_in_free_extents( (ulong) fsp_get_available_space_in_free_extents(
prebuilt->table->space)); 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); flen = ftell(file);
if(length + flen + 3 > 64000) { if(length + flen + 3 > 64000) {
flen = 64000 - 3 - length; flen = 64000 - 3 - length;
...@@ -4534,7 +4559,8 @@ ha_innobase::get_foreign_key_create_info(void) ...@@ -4534,7 +4559,8 @@ ha_innobase::get_foreign_key_create_info(void)
trx_search_latch_release_if_reserved(prebuilt->trx); trx_search_latch_release_if_reserved(prebuilt->trx);
/* output the data to a temporary file */ /* 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*)""; prebuilt->trx->op_info = (char*)"";
flen = ftell(file); flen = ftell(file);
......
...@@ -636,6 +636,7 @@ int mysqld_show_keys(THD *thd, TABLE_LIST *table); ...@@ -636,6 +636,7 @@ int mysqld_show_keys(THD *thd, TABLE_LIST *table);
int mysqld_show_logs(THD *thd); int mysqld_show_logs(THD *thd);
void append_identifier(THD *thd, String *packet, const char *name, void append_identifier(THD *thd, String *packet, const char *name,
uint length); 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); 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_dump_create_info(THD *thd, TABLE *table, int fd = -1);
int mysqld_show_create(THD *thd, TABLE_LIST *table_list); int mysqld_show_create(THD *thd, TABLE_LIST *table_list);
......
...@@ -1143,41 +1143,19 @@ static const char *require_quotes(const char *name, uint name_length) ...@@ -1143,41 +1143,19 @@ 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(&quote_char, 1, system_charset_info);
packet->append(name, length, system_charset_info);
packet->append(&quote_char, 1, system_charset_info);
}
void void
append_identifier(THD *thd, String *packet, const char *name, uint length) append_identifier(THD *thd, String *packet, const char *name, uint length)
{ {
const char *name_end; 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);
return;
}
if (!require_quotes(name, length)) if (q == EOF) {
{
if (!(thd->options & OPTION_QUOTE_SHOW_CREATE))
packet->append(name, length, system_charset_info); packet->append(name, length, system_charset_info);
else
append_quoted_simple_identifier(packet, quote_char, name, length);
return; return;
} }
char quote_char= q;
/* The identifier must be quoted as it includes a quote character */ /* The identifier must be quoted as it includes a quote character */
packet->reserve(length*2 + 2); packet->reserve(length*2 + 2);
...@@ -1195,6 +1173,22 @@ append_identifier(THD *thd, String *packet, const char *name, uint length) ...@@ -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 */ /* Append directory name (if exists) to CREATE INFO */
static void append_directory(THD *thd, String *packet, const char *dir_type, static void append_directory(THD *thd, String *packet, const char *dir_type,
......
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