diff options
author | marko@hundin.mysql.fi <> | 2004-10-01 11:51:59 +0300 |
---|---|---|
committer | marko@hundin.mysql.fi <> | 2004-10-01 11:51:59 +0300 |
commit | d7ea8e7c6cc6d23aa073ed2a1f5d00a30d98998e (patch) | |
tree | cd5df16f04eff773fc341cd412fa9d695ff0680c /innobase/dict | |
parent | 1bd65d7715a0d425be608f738651b995bd23a7bc (diff) | |
download | mariadb-git-d7ea8e7c6cc6d23aa073ed2a1f5d00a30d98998e.tar.gz |
InnoDB: quote identifiers according to MySQL settings (Bug #5292)
Diffstat (limited to 'innobase/dict')
-rw-r--r-- | innobase/dict/dict0crea.c | 11 | ||||
-rw-r--r-- | innobase/dict/dict0dict.c | 96 | ||||
-rw-r--r-- | innobase/dict/dict0load.c | 48 |
3 files changed, 74 insertions, 81 deletions
diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 1e4d906b7b5..c887d821a3f 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -501,11 +501,14 @@ dict_build_index_def_step( dict_table_t* table; dict_index_t* index; dtuple_t* row; + trx_t* trx; #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ + trx = thr_get_trx(thr); + index = node->index; table = dict_table_get_low(index->table_name); @@ -514,7 +517,7 @@ dict_build_index_def_step( return(DB_TABLE_NOT_FOUND); } - thr_get_trx(thr)->table_id = table->id; + trx->table_id = table->id; node->table = table; @@ -1264,9 +1267,9 @@ loop: ut_print_timestamp(ef); fputs(" Error in foreign key constraint creation for table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, trx, table->name); fputs(".\nA foreign key constraint of name ", ef); - ut_print_name(ef, foreign->id); + ut_print_name(ef, trx, foreign->id); fputs("\nalready exists." " (Note that internally InnoDB adds 'databasename/'\n" "in front of the user-defined constraint name).\n", @@ -1286,7 +1289,7 @@ loop: ut_print_timestamp(ef); fputs(" Internal error in foreign key constraint creation" " for table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, trx, table->name); fputs(".\n" "See the MySQL .err log in the datadir for more information.\n", ef); mutex_exit(&dict_foreign_err_mutex); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index eeefd7bf1ae..b5dd06b1bf1 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2085,14 +2085,14 @@ Report an error in a foreign key definition. */ static void dict_foreign_error_report_low( +/*==========================*/ FILE* file, /* in: output stream */ const char* name) /* in: table name */ { rewind(file); ut_print_timestamp(file); - fputs(" Error in foreign key constraint of table ", file); - ut_print_name(file, name); - fputs(":\n", file); + fprintf(file, " Error in foreign key constraint of table %s:\n", + name); } /************************************************************************** @@ -2100,6 +2100,7 @@ Report an error in a foreign key definition. */ static void dict_foreign_error_report( +/*======================*/ FILE* file, /* in: output stream */ dict_foreign_t* fk, /* in: foreign key constraint */ const char* msg) /* in: the error message */ @@ -2108,10 +2109,10 @@ dict_foreign_error_report( dict_foreign_error_report_low(file, fk->foreign_table_name); fputs(msg, file); fputs(" Constraint:\n", file); - dict_print_info_on_foreign_key_in_create_format(file, fk); + dict_print_info_on_foreign_key_in_create_format(file, NULL, fk); if (fk->foreign_index) { fputs("\nThe index in the foreign key in table is ", file); - ut_print_name(file, fk->foreign_index->name); + ut_print_name(file, NULL, fk->foreign_index->name); fputs( "See http://www.innodb.com/ibman.php for correct foreign key definition.\n", file); @@ -2946,7 +2947,7 @@ col_loop1: mutex_enter(&dict_foreign_err_mutex); dict_foreign_error_report_low(ef, name); fputs("There is no index in table ", ef); - ut_print_name(ef, name); + ut_print_name(ef, NULL, name); fprintf(ef, " where the columns appear\n" "as the first columns. Constraint:\n%s\n" "See http://www.innodb.com/ibman.php for correct foreign key definition.\n", @@ -3389,12 +3390,12 @@ loop: ut_print_timestamp(ef); fputs( " Error in dropping of a foreign key constraint of table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, NULL, table->name); fputs(",\n" "in SQL command\n", ef); fputs(str, ef); fputs("\nCannot find a constraint with the given id ", ef); - ut_print_name(ef, id); + ut_print_name(ef, NULL, id); fputs(".\n", ef); mutex_exit(&dict_foreign_err_mutex); @@ -3411,7 +3412,7 @@ syntax_error: ut_print_timestamp(ef); fputs( " Syntax error in dropping of a foreign key constraint of table ", ef); - ut_print_name(ef, table->name); + ut_print_name(ef, NULL, table->name); fprintf(ef, ",\n" "close to:\n%s\n in SQL command\n%s\n", ptr, str); mutex_exit(&dict_foreign_err_mutex); @@ -3818,9 +3819,11 @@ dict_update_statistics_low( if (table->ibd_file_missing) { ut_print_timestamp(stderr); fprintf(stderr, -" InnoDB: cannot calculate statistics for table %s\n" -"InnoDB: because the .ibd file is missing. See section 15.1 of\n" -"InnoDB: http:/www.innodb.com/ibman.html for help\n", table->name); + " InnoDB: cannot calculate statistics for table %s\n" +"InnoDB: because the .ibd file is missing. For help, please refer to\n" +"InnoDB: " +"http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n", + table->name); return; } @@ -3906,25 +3909,19 @@ dict_foreign_print_low( ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - fputs(" FOREIGN KEY CONSTRAINT ", stderr); - ut_print_name(stderr, foreign->id); - fputs(": ", stderr); - ut_print_name(stderr, foreign->foreign_table_name); - fputs(" (", stderr); + fprintf(stderr, " FOREIGN KEY CONSTRAINT %s: %s (", + foreign->id, foreign->foreign_table_name); for (i = 0; i < foreign->n_fields; i++) { - putc(' ', stderr); - ut_print_name(stderr, foreign->foreign_col_names[i]); + fprintf(stderr, " %s", foreign->foreign_col_names[i]); } - fputs(" )\n" - " REFERENCES ", stderr); - ut_print_name(stderr, foreign->referenced_table_name); - fputs(" (", stderr); + fprintf(stderr, " )\n" + " REFERENCES %s (", + foreign->referenced_table_name); for (i = 0; i < foreign->n_fields; i++) { - putc(' ', stderr); - ut_print_name(stderr, foreign->referenced_col_names[i]); + fprintf(stderr, " %s", foreign->referenced_col_names[i]); } fputs(" )\n", stderr); @@ -3981,12 +3978,11 @@ dict_table_print_low( dict_update_statistics_low(table, TRUE); - fputs("--------------------------------------\n" - "TABLE: name ", stderr); - ut_print_name(stderr, table->name); fprintf(stderr, - ", id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" - " COLUMNS: ", +"--------------------------------------\n" +"TABLE: name %s, id %lu %lu, columns %lu, indexes %lu, appr.rows %lu\n" +" COLUMNS: ", + table->name, (ulong) ut_dulint_get_high(table->id), (ulong) ut_dulint_get_low(table->id), (ulong) table->n_cols, @@ -4037,8 +4033,7 @@ dict_col_print_low( #endif /* UNIV_SYNC_DEBUG */ type = dict_col_get_type(col); - ut_print_name(stderr, col->name); - fputs(": ", stderr); + fprintf(stderr, "%s: ", col->name); dtype_print(type); } @@ -4068,13 +4063,12 @@ dict_index_print_low( n_vals = index->stat_n_diff_key_vals[1]; } - fputs(" INDEX: ", stderr); - dict_index_name_print(stderr, index); fprintf(stderr, - ", id %lu %lu, fields %lu/%lu, type %lu\n" + " INDEX: name %s, id %lu %lu, fields %lu/%lu, type %lu\n" " root page %lu, appr.key vals %lu," " leaf pages %lu, size pages %lu\n" " FIELDS: ", + index->name, (ulong) ut_dulint_get_high(tree->id), (ulong) ut_dulint_get_low(tree->id), (ulong) index->n_user_defined_cols, @@ -4106,8 +4100,7 @@ dict_field_print_low( #ifdef UNIV_SYNC_DEBUG ut_ad(mutex_own(&(dict_sys->mutex))); #endif /* UNIV_SYNC_DEBUG */ - putc(' ', stderr); - ut_print_name(stderr, field->name); + fprintf(stderr, " %s", field->name); if (field->prefix_len != 0) { fprintf(stderr, "(%lu)", (ulong) field->prefix_len); @@ -4122,6 +4115,7 @@ void dict_print_info_on_foreign_key_in_create_format( /*============================================*/ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_foreign_t* foreign)/* in: foreign key constraint */ { const char* stripped_id; @@ -4136,11 +4130,11 @@ dict_print_info_on_foreign_key_in_create_format( } fputs(",\n CONSTRAINT ", file); - ut_print_name(file, stripped_id); + ut_print_name(file, trx, stripped_id); fputs(" FOREIGN KEY (", file); for (i = 0;;) { - ut_print_name(file, foreign->foreign_col_names[i]); + ut_print_name(file, trx, foreign->foreign_col_names[i]); if (++i < foreign->n_fields) { fputs(", ", file); } else { @@ -4153,7 +4147,7 @@ dict_print_info_on_foreign_key_in_create_format( if (dict_tables_have_same_db(foreign->foreign_table_name, foreign->referenced_table_name)) { /* Do not print the database name of the referenced table */ - ut_print_name(file, dict_remove_db_name( + ut_print_name(file, trx, dict_remove_db_name( foreign->referenced_table_name)); } else { /* Look for the '/' in the table name */ @@ -4163,16 +4157,17 @@ dict_print_info_on_foreign_key_in_create_format( i++; } - ut_print_namel(file, foreign->referenced_table_name, i); + ut_print_namel(file, trx, foreign->referenced_table_name, i); putc('.', file); - ut_print_name(file, foreign->referenced_table_name + i + 1); + ut_print_name(file, trx, + foreign->referenced_table_name + i + 1); } putc(' ', file); putc('(', file); for (i = 0;;) { - ut_print_name(file, foreign->referenced_col_names[i]); + ut_print_name(file, trx, foreign->referenced_col_names[i]); if (++i < foreign->n_fields) { fputs(", ", file); } else { @@ -4218,6 +4213,7 @@ dict_print_info_on_foreign_keys( a CREATE TABLE, otherwise in the format of SHOW TABLE STATUS */ FILE* file, /* in: file where to print */ + trx_t* trx, /* in: transaction */ dict_table_t* table) /* in: table */ { dict_foreign_t* foreign; @@ -4235,7 +4231,7 @@ dict_print_info_on_foreign_keys( while (foreign != NULL) { if (create_table_format) { dict_print_info_on_foreign_key_in_create_format( - file, foreign); + file, trx, foreign); } else { ulint i; fputs("; (", file); @@ -4245,19 +4241,20 @@ dict_print_info_on_foreign_keys( putc(' ', file); } - ut_print_name(file, + ut_print_name(file, trx, foreign->foreign_col_names[i]); } fputs(") REFER ", file); - ut_print_name(file, foreign->referenced_table_name); + ut_print_name(file, trx, + foreign->referenced_table_name); putc('(', file); for (i = 0; i < foreign->n_fields; i++) { if (i) { putc(' ', file); } - ut_print_name(file, + ut_print_name(file, trx, foreign->referenced_col_names[i]); } @@ -4300,10 +4297,11 @@ void dict_index_name_print( /*==================*/ FILE* file, /* in: output stream */ + trx_t* trx, /* in: transaction */ const dict_index_t* index) /* in: index to print */ { fputs("index ", file); - ut_print_name(file, index->name); + ut_print_name(file, trx, index->name); fputs(" of table ", file); - ut_print_name(file, index->table_name); + ut_print_name(file, trx, index->table_name); } diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index ee4ae9dd1a1..9293b117899 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -30,7 +30,7 @@ dict_get_first_table_name_in_db( /* out, own: table name, NULL if does not exist; the caller must free the memory in the string! */ - const char* name) /* in: database name which ends to '/' */ + const char* name) /* in: database name which ends in '/' */ { dict_table_t* sys_tables; btr_pcur_t pcur; @@ -165,7 +165,7 @@ loop: if (table == NULL) { fputs("InnoDB: Failed to load table ", stderr); - ut_print_namel(stderr, field, len); + ut_print_namel(stderr, NULL, field, len); putc('\n', stderr); } else { /* The table definition was corrupt if there @@ -389,18 +389,16 @@ Report that an index field or index for a table has been delete marked. */ static void dict_load_report_deleted_index( +/*===========================*/ const char* name, /* in: table name */ ulint field) /* in: index field, or ULINT_UNDEFINED */ { - fputs("InnoDB: Error: data dictionary entry" - " for table ", stderr); - ut_print_name(stderr, name); - fputs(" is corrupt!\n", stderr); + fprintf(stderr, "InnoDB: Error: data dictionary entry" + " for table %s is corrupt!\n", name); if (field != ULINT_UNDEFINED) { fprintf(stderr, "InnoDB: Index field %lu is delete marked.\n", field); - } - else { + } else { fputs("InnoDB: An index is delete marked.\n", stderr); } } @@ -620,12 +618,10 @@ dict_load_indexes( if (page_no == FIL_NULL) { - fputs("InnoDB: Error: trying to load index ", stderr); - ut_print_name(stderr, name_buf); - fputs(" for table ", stderr); - ut_print_name(stderr, table->name); - fputs("\n" - "InnoDB: but the index tree has been freed!\n", stderr); + fprintf(stderr, + "InnoDB: Error: trying to load index %s for table %s\n" + "InnoDB: but the index tree has been freed!\n", + name_buf, table->name); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -636,12 +632,10 @@ dict_load_indexes( if ((type & DICT_CLUSTERED) == 0 && NULL == dict_table_get_first_index(table)) { - fputs("InnoDB: Error: trying to load index ", stderr); - ut_print_namel(stderr, name_buf, name_len); - fputs(" for table ", stderr); - ut_print_name(stderr, table->name); - fputs("\n" - "InnoDB: but the first index is not clustered!\n", stderr); + fprintf(stderr, + "InnoDB: Error: trying to load index %s for table %s\n" + "InnoDB: but the first index is not clustered!\n", + name_buf, table->name); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1097,10 +1091,9 @@ dict_load_foreign( || rec_get_deleted_flag(rec)) { /* Not found */ - fputs("InnoDB: Error A: cannot load foreign constraint ", - stderr); - ut_print_name(stderr, id); - putc('\n', stderr); + fprintf(stderr, + "InnoDB: Error A: cannot load foreign constraint %s\n", + id); btr_pcur_close(&pcur); mtr_commit(&mtr); @@ -1114,10 +1107,9 @@ dict_load_foreign( /* Check if the id in record is the searched one */ if (len != ut_strlen(id) || ut_memcmp(id, field, len) != 0) { - fputs("InnoDB: Error B: cannot load foreign constraint ", - stderr); - ut_print_name(stderr, id); - putc('\n', stderr); + fprintf(stderr, + "InnoDB: Error B: cannot load foreign constraint %s\n", + id); btr_pcur_close(&pcur); mtr_commit(&mtr); |