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(
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);
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
}
......@@ -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);
......
This diff is collapsed.
......@@ -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();
......
......@@ -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). */
......
......@@ -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. */
......
......@@ -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
......
......@@ -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
......
......@@ -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));
......
......@@ -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 */
......
......@@ -197,13 +197,25 @@ ut_print_buf(
const byte* buf, /* in: memory 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. */
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 */
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -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(
......
......@@ -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);
......
This diff is collapsed.
......@@ -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 */
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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),
......
......@@ -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);
......
......@@ -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++;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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(&quote_char, 1, system_charset_info);
packet->append(name, length, system_charset_info);
packet->append(&quote_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,
......
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