Commit 0db72d6e authored by unknown's avatar unknown

Merge mskold@build.mysql.com:/home/bk/mysql-4.1

into mysql.com:/usr/local/home/marty/MySQL/test/mysql-4.1

parents 33dcc14d 9e6d1014
......@@ -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));
}
......@@ -2482,7 +2482,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);
}
......@@ -2503,7 +2503,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));
......
......@@ -110,6 +110,8 @@ extern int srv_query_thread_priority;
extern ibool srv_use_awe;
extern ibool srv_use_adaptive_hash_indexes;
extern ulint srv_max_purge_lag;
/*-------------------------------------------*/
extern ulint srv_n_rows_inserted;
......@@ -163,6 +165,7 @@ extern ulint srv_test_array_size;
extern ulint srv_activity_count;
extern ulint srv_fatal_semaphore_wait_threshold;
extern ulint srv_dml_needed_delay;
extern mutex_t* kernel_mutex_temp;/* mutex protecting the server, trx structs,
query threads, and lock table: we allocate
......
......@@ -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 */
......
......@@ -432,6 +432,10 @@ struct trx_sys_struct{
trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS];
/* Pointer array to rollback segments;
NULL if slot not in use */
ulint rseg_history_len;/* Length of the TRX_RSEG_HISTORY
list (update undo logs for committed
transactions), protected by
rseg->mutex */
UT_LIST_BASE_NODE_T(read_view_t) view_list;
/* List of read views sorted on trx no,
biggest first */
......
......@@ -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",
......@@ -1672,7 +1672,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);
......@@ -1709,7 +1709,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);
......@@ -3314,7 +3314,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);
......@@ -3841,7 +3841,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);
......@@ -3892,7 +3892,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);
......@@ -1084,6 +1087,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
......@@ -1092,7 +1096,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 */
......@@ -1150,18 +1154,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);
......@@ -1294,7 +1298,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;
}
......@@ -1310,7 +1314,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;
......@@ -1329,18 +1333,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 */
......
......@@ -395,12 +395,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;
......@@ -415,9 +416,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;
}
......
......@@ -1951,7 +1951,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;
......@@ -2034,7 +2035,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);
}
......@@ -2078,11 +2079,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);
......@@ -2125,7 +2128,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));
......@@ -2284,7 +2287,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(
......@@ -2416,8 +2423,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);
......@@ -2450,7 +2458,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);
......@@ -2458,7 +2466,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);
......@@ -2486,8 +2494,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,
......@@ -2812,7 +2818,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);
......@@ -3246,7 +3252,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);
......@@ -3264,7 +3270,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);
......@@ -3283,7 +3289,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;
......@@ -1220,10 +1222,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);
......@@ -1242,7 +1245,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);
......@@ -1251,7 +1254,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);
......
......@@ -58,6 +58,10 @@ ulint srv_activity_count = 0;
/* The following is the maximum allowed duration of a lock wait. */
ulint srv_fatal_semaphore_wait_threshold = 600;
/* How much data manipulation language (DML) statements need to be delayed,
in microseconds, in order to reduce the lagging of the purge thread. */
ulint srv_dml_needed_delay = 0;
ibool srv_lock_timeout_and_monitor_active = FALSE;
ibool srv_error_monitor_active = FALSE;
......@@ -258,6 +262,8 @@ disable adaptive hash indexes */
ibool srv_use_awe = FALSE;
ibool srv_use_adaptive_hash_indexes = TRUE;
/* Maximum allowable purge history length. <=0 means 'infinite'. */
ulint srv_max_purge_lag = 0;
/*-------------------------------------------*/
ulint srv_n_spin_wait_rounds = 20;
......
......@@ -295,6 +295,9 @@ trx_purge_add_update_undo_to_history(
/* Add the log as the first in the history list */
flst_add_first(rseg_header + TRX_RSEG_HISTORY,
undo_header + TRX_UNDO_HISTORY_NODE, mtr);
mutex_enter(&kernel_mutex);
trx_sys->rseg_history_len++;
mutex_exit(&kernel_mutex);
/* Write the trx number to the undo log header */
mlog_write_dulint(undo_header + TRX_UNDO_TRX_NO, trx->no, mtr);
......@@ -386,6 +389,12 @@ loop:
flst_cut_end(rseg_hdr + TRX_RSEG_HISTORY,
log_hdr + TRX_UNDO_HISTORY_NODE, n_removed_logs, &mtr);
mutex_enter(&kernel_mutex);
ut_ad(trx_sys->rseg_history_len >= n_removed_logs);
trx_sys->rseg_history_len -= n_removed_logs;
mutex_exit(&kernel_mutex);
freed = FALSE;
while (!freed) {
......@@ -470,6 +479,11 @@ loop:
}
if (cmp >= 0) {
mutex_enter(&kernel_mutex);
ut_a(trx_sys->rseg_history_len >= n_removed_logs);
trx_sys->rseg_history_len -= n_removed_logs;
mutex_exit(&kernel_mutex);
flst_truncate_end(rseg_hdr + TRX_RSEG_HISTORY,
log_hdr + TRX_UNDO_HISTORY_NODE,
n_removed_logs, &mtr);
......@@ -1031,6 +1045,27 @@ trx_purge(void)
purge_sys->view = NULL;
mem_heap_empty(purge_sys->heap);
/* Determine how much data manipulation language (DML) statements
need to be delayed in order to reduce the lagging of the purge
thread. */
srv_dml_needed_delay = 0; /* in microseconds; default: no delay */
/* If we cannot advance the 'purge view' because of an old
'consistent read view', then the DML statements cannot be delayed.
Also, srv_max_purge_lag <= 0 means 'infinity'. */
if (srv_max_purge_lag > 0
&& !UT_LIST_GET_LAST(trx_sys->view_list)) {
float ratio = (float) trx_sys->rseg_history_len
/ srv_max_purge_lag;
if (ratio > 1) {
/* If the history list length exceeds the
innodb_max_purge_lag, the
data manipulation statements are delayed
by at least 5000 microseconds. */
srv_dml_needed_delay = (ratio - .5) * 10000;
}
}
purge_sys->view = read_view_oldest_copy_or_open_new(NULL,
purge_sys->heap);
mutex_exit(&kernel_mutex);
......
......@@ -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);
......
......@@ -135,6 +135,7 @@ trx_rseg_mem_create(
trx_ulogf_t* undo_log_hdr;
fil_addr_t node_addr;
ulint sum_of_undo_sizes;
ulint len;
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
......@@ -166,7 +167,9 @@ trx_rseg_mem_create(
MLOG_4BYTES, mtr)
+ 1 + sum_of_undo_sizes;
if (flst_get_len(rseg_header + TRX_RSEG_HISTORY, mtr) > 0) {
len = flst_get_len(rseg_header + TRX_RSEG_HISTORY, mtr);
if (len > 0) {
trx_sys->rseg_history_len += len;
node_addr = trx_purge_get_log_from_hist(
flst_get_last(rseg_header + TRX_RSEG_HISTORY,
......@@ -206,6 +209,8 @@ trx_rseg_list_and_array_init(
UT_LIST_INIT(trx_sys->rseg_list);
trx_sys->rseg_history_len = 0;
for (i = 0; i < TRX_SYS_N_RSEGS; i++) {
page_no = trx_sysf_rseg_get_page_no(sys_header, i, mtr);
......
......@@ -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++;
......
......@@ -98,7 +98,7 @@ long innobase_mirrored_log_groups, innobase_log_files_in_group,
innobase_buffer_pool_size, innobase_additional_mem_pool_size,
innobase_file_io_threads, innobase_lock_wait_timeout,
innobase_thread_concurrency, innobase_force_recovery,
innobase_open_files, innobase_auto_extend_increment;
innobase_open_files;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
......@@ -737,15 +737,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);
}
/*********************************************************************
......@@ -964,7 +984,6 @@ innobase_init(void)
srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
srv_max_n_open_files = (ulint) innobase_open_files;
srv_auto_extend_increment = (ulint) innobase_auto_extend_increment;
srv_innodb_status = (ibool) innobase_create_status_file;
srv_print_verbose_log = mysql_embedded ? 0 : 1;
......@@ -1485,12 +1504,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;
......@@ -1540,7 +1561,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"
......@@ -2864,7 +2885,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 */
......@@ -4076,14 +4097,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);
......@@ -4470,7 +4493,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;
......@@ -4536,7 +4560,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);
......@@ -5272,59 +5297,51 @@ ulonglong ha_innobase::get_mysql_bin_log_pos()
}
extern "C" {
/***********************************************************************
This function finds charset information and returns the character
length for multibyte character set. */
ulint innobase_get_charset_mbmaxlen(
ulint charset_id) /* in: charset id */
{
CHARSET_INFO* charset; /* charset used in the field */
charset = get_charset(charset_id,MYF(MY_WME));
ut_ad(charset);
ut_ad(charset->mbmaxlen);
return charset->mbmaxlen;
}
}
extern "C" {
/***********************************************************************
This function finds charset information and returns position the nth
character for multibyte character set.*/
/**********************************************************************
This function is used to find storage length of prefix_len characters
in bytes for prefix indexes using multibyte character set.
Function finds charset information and returns length of
prefix_len characters in the index field in bytes. */
ulint innobase_get_at_most_n_mbchars(
/*=================================*/
ulint charset_id, /* in: character set id */
ulint nth, /* in: nth character */
ulint prefix_len, /* in: prefix length of the index */
ulint data_len, /* in: length of the sting in bytes */
const char *pos) /* in: character string */
{
ulint byte_length; /* storage length, in bytes. */
ulint char_length; /* character length in bytes */
CHARSET_INFO* charset; /* charset used in the field */
ulint byte_length; /* storage length, in bytes. */
ulint char_length; /* character length in bytes */
CHARSET_INFO* charset; /* charset used in the field */
ut_ad(pos);
byte_length = data_len;
ut_ad(pos);
byte_length = data_len;
charset = get_charset(charset_id,MYF(MY_WME));
charset = get_charset(charset_id,MYF(MY_WME));
ut_ad(charset);
ut_ad(charset->mbmaxlen);
ut_ad(charset);
ut_ad(charset->mbmaxlen);
char_length= byte_length / charset->mbmaxlen;
nth = nth / charset->mbmaxlen;
/* Calculate the storage length of the one character in bytes and
how many characters the prefix index contains */
if (byte_length > char_length)
{
char_length= my_charpos(charset, pos, pos + byte_length, nth);
set_if_smaller(char_length, byte_length);
}
else
char_length = nth;
char_length = byte_length / charset->mbmaxlen;
prefix_len = prefix_len / charset->mbmaxlen;
/* If length of the string is greater than storage length of the
one character, we have to find the storage position of the
prefix_len character in the string */
if (byte_length > char_length) {
char_length = my_charpos(charset, pos,
pos + byte_length, prefix_len);
set_if_smaller(char_length, byte_length);
}
else {
char_length = prefix_len;
}
return char_length;
return char_length;
}
}
......
......@@ -183,7 +183,6 @@ extern long innobase_buffer_pool_awe_mem_mb;
extern long innobase_file_io_threads, innobase_lock_wait_timeout;
extern long innobase_force_recovery, innobase_thread_concurrency;
extern long innobase_open_files;
extern long innobase_auto_extend_increment;
extern char *innobase_data_home_dir, *innobase_data_file_path;
extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
extern char *innobase_unix_file_flush_method;
......@@ -194,6 +193,8 @@ extern my_bool innobase_log_archive,
innobase_create_status_file;
extern "C" {
extern ulong srv_max_buf_pool_modified_pct;
extern ulong srv_auto_extend_increment;
extern ulong srv_max_purge_lag;
}
extern TYPELIB innobase_lock_typelib;
......
......@@ -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);
......
......@@ -3998,6 +3998,7 @@ enum options_mysqld
OPT_INNODB_BUFFER_POOL_SIZE,
OPT_INNODB_BUFFER_POOL_AWE_MEM_MB,
OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
OPT_INNODB_MAX_PURGE_LAG,
OPT_INNODB_FILE_IO_THREADS,
OPT_INNODB_LOCK_WAIT_TIMEOUT,
OPT_INNODB_THREAD_CONCURRENCY,
......@@ -4233,6 +4234,11 @@ Disable with --skip-innodb (will save memory).",
{"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT,
"Percentage of dirty pages allowed in bufferpool.", (gptr*) &srv_max_buf_pool_modified_pct,
(gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0},
{"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG,
"",
(gptr*) &srv_max_purge_lag,
(gptr*) &srv_max_purge_lag, 0, GET_LONG, REQUIRED_ARG, 0, 0, ~0L,
0, 1L, 0},
{"innodb_status_file", OPT_INNODB_STATUS_FILE,
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
(gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file,
......@@ -4712,6 +4718,11 @@ replicating a LOAD DATA INFILE command.",
(gptr*) &innobase_additional_mem_pool_size,
(gptr*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG,
1*1024*1024L, 512*1024L, ~0L, 0, 1024, 0},
{"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
"Data file autoextend increment in megabytes",
(gptr*) &srv_auto_extend_increment,
(gptr*) &srv_auto_extend_increment,
0, GET_LONG, REQUIRED_ARG, 8L, 1L, ~0L, 0, 1L, 0},
{"innodb_buffer_pool_awe_mem_mb", OPT_INNODB_BUFFER_POOL_AWE_MEM_MB,
"If Windows AWE is used, the size of InnoDB buffer pool allocated from the AWE memory.",
(gptr*) &innobase_buffer_pool_awe_mem_mb, (gptr*) &innobase_buffer_pool_awe_mem_mb, 0,
......@@ -4753,11 +4764,6 @@ replicating a LOAD DATA INFILE command.",
"How many files at the maximum InnoDB keeps open at the same time.",
(gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0,
GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0},
{"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
"Data file autoextend increment in megabytes",
(gptr*) &innobase_auto_extend_increment,
(gptr*) &innobase_auto_extend_increment,
0, GET_LONG, REQUIRED_ARG, 8L, 1L, ~0L, 0, 1L, 0},
#ifdef HAVE_REPLICATION
/*
Disabled for the 4.1.3 release. Disabling just this paragraph of code is
......
......@@ -351,6 +351,10 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout",
#ifdef HAVE_INNOBASE_DB
sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct",
&srv_max_buf_pool_modified_pct);
sys_var_long_ptr sys_innodb_autoextend_increment("innodb_autoextend_increment",
&srv_auto_extend_increment);
sys_var_long_ptr sys_innodb_max_purge_lag("innodb_max_purge_lag",
&srv_max_purge_lag);
#endif
/* Time/date/datetime formats */
......@@ -601,6 +605,8 @@ sys_var *sys_variables[]=
&sys_os,
#ifdef HAVE_INNOBASE_DB
&sys_innodb_max_dirty_pages_pct,
&sys_innodb_max_purge_lag,
&sys_innodb_autoextend_increment,
#endif
&sys_unique_checks,
&sys_warning_count
......@@ -674,6 +680,7 @@ struct show_var_st init_vars[]= {
{"init_slave", (char*) &sys_init_slave, SHOW_SYS},
#ifdef HAVE_INNOBASE_DB
{"innodb_additional_mem_pool_size", (char*) &innobase_additional_mem_pool_size, SHOW_LONG },
{sys_innodb_autoextend_increment.name, (char*) &sys_innodb_autoextend_increment, SHOW_SYS},
{"innodb_buffer_pool_awe_mem_mb", (char*) &innobase_buffer_pool_awe_mem_mb, SHOW_LONG },
{"innodb_buffer_pool_size", (char*) &innobase_buffer_pool_size, SHOW_LONG },
{"innodb_data_file_path", (char*) &innobase_data_file_path, SHOW_CHAR_PTR},
......@@ -693,6 +700,7 @@ struct show_var_st init_vars[]= {
{"innodb_log_files_in_group", (char*) &innobase_log_files_in_group, SHOW_LONG},
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
{sys_innodb_max_dirty_pages_pct.name, (char*) &sys_innodb_max_dirty_pages_pct, SHOW_SYS},
{sys_innodb_max_purge_lag.name, (char*) &sys_innodb_max_purge_lag, SHOW_SYS},
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
{"innodb_open_files", (char*) &innobase_open_files, SHOW_LONG },
{"innodb_thread_concurrency", (char*) &innobase_thread_concurrency, SHOW_LONG },
......
......@@ -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