diff options
author | unknown <aivanov@mysql.com> | 2006-04-20 23:09:49 +0400 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2006-04-20 23:09:49 +0400 |
commit | 66ee876ba3b50fba4ed159eb23587bf02fc2d44b (patch) | |
tree | c521f14ae71f3ca4157aef4b3a2b63f929314bf6 /innobase | |
parent | 5a19f3bc71b9db630fac01561ffc6f37434ac509 (diff) | |
download | mariadb-git-66ee876ba3b50fba4ed159eb23587bf02fc2d44b.tar.gz |
Applied innodb-4.1-ss22 snapshot.
Fix BUG#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW INNODB STATUS
output.
Fix BUG#18934: "InnoDB crashes when table uses column names like DB_ROW_ID".
Refuse tables that use reserved column names.
innobase/dict/dict0dict.c:
Applied innodb-4.1-ss22 snapshot.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format() (Bug#16814).
Refuse tables that use reserved column names (Bug#18934).
innobase/dict/dict0mem.c:
Applied innodb-4.1-ss22 snapshot.
Refuse tables that use reserved column names (Bug#18934).
innobase/include/dict0dict.h:
Applied innodb-4.1-ss22 snapshot.
Refuse tables that use reserved column names (Bug#18934).
innobase/include/dict0mem.h:
Applied innodb-4.1-ss22 snapshot.
Refuse tables that use reserved column names (Bug#18934).
innobase/include/univ.i:
Applied innodb-4.1-ss22 snapshot.
innobase/row/row0mysql.c:
Applied innodb-4.1-ss22 snapshot.
Refuse tables that use reserved column names (Bug#18934).
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/dict/dict0dict.c | 35 | ||||
-rw-r--r-- | innobase/dict/dict0mem.c | 15 | ||||
-rw-r--r-- | innobase/include/dict0dict.h | 9 | ||||
-rw-r--r-- | innobase/include/dict0mem.h | 7 | ||||
-rw-r--r-- | innobase/include/univ.i | 3 | ||||
-rw-r--r-- | innobase/row/row0mysql.c | 14 |
6 files changed, 82 insertions, 1 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 093df5118af..4b23ce047b2 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -1377,6 +1377,38 @@ dict_col_reposition_in_cache( HASH_INSERT(dict_col_t, hash, dict_sys->col_hash, fold, col); } +/******************************************************************** +If the given column name is reserved for InnoDB system columns, return +TRUE.*/ + +ibool +dict_col_name_is_reserved( +/*======================*/ + /* out: TRUE if name is reserved */ + const char* name) /* in: column name */ +{ + /* This check reminds that if a new system column is added to + the program, it should be dealt with here. */ +#if DATA_N_SYS_COLS != 4 +#error "DATA_N_SYS_COLS != 4" +#endif + + static const char* reserved_names[] = { + "DB_ROW_ID", "DB_TRX_ID", "DB_ROLL_PTR", "DB_MIX_ID" + }; + + ulint i; + + for (i = 0; i < UT_ARR_SIZE(reserved_names); i++) { + if (strcmp(name, reserved_names[i]) == 0) { + + return(TRUE); + } + } + + return(FALSE); +} + /************************************************************************** Adds an index to the dictionary cache. */ @@ -2160,8 +2192,9 @@ dict_foreign_error_report( fputs(msg, file); fputs(" Constraint:\n", file); dict_print_info_on_foreign_key_in_create_format(file, NULL, fk); + putc('\n', file); if (fk->foreign_index) { - fputs("\nThe index in the foreign key in table is ", file); + fputs("The index in the foreign key in table is ", file); ut_print_name(file, NULL, fk->foreign_index->name); fputs( "\nSee http://dev.mysql.com/doc/mysql/en/InnoDB_foreign_key_constraints.html\n" diff --git a/innobase/dict/dict0mem.c b/innobase/dict/dict0mem.c index 1d45585aac1..5a2b2e005d0 100644 --- a/innobase/dict/dict0mem.c +++ b/innobase/dict/dict0mem.c @@ -94,6 +94,21 @@ dict_mem_table_create( return(table); } +/******************************************************************** +Free a table memory object. */ + +void +dict_mem_table_free( +/*================*/ + dict_table_t* table) /* in: table */ +{ + ut_ad(table); + ut_ad(table->magic_n == DICT_TABLE_MAGIC_N); + + mutex_free(&(table->autoinc_mutex)); + mem_heap_free(table->heap); +} + /************************************************************************** Creates a cluster memory object. */ diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index bf1382e8bb2..1226055e135 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -98,6 +98,15 @@ ulint dict_col_get_clust_pos( /*===================*/ dict_col_t* col); +/******************************************************************** +If the given column name is reserved for InnoDB system columns, return +TRUE. */ + +ibool +dict_col_name_is_reserved( +/*======================*/ + /* out: TRUE if name is reserved */ + const char* name); /* in: column name */ /************************************************************************ Initializes the autoinc counter. It is not an error to initialize an already initialized counter. */ diff --git a/innobase/include/dict0mem.h b/innobase/include/dict0mem.h index 1e496a25477..5c3a4ed76d4 100644 --- a/innobase/include/dict0mem.h +++ b/innobase/include/dict0mem.h @@ -55,6 +55,13 @@ dict_mem_table_create( is ignored if the table is made a member of a cluster */ ulint n_cols); /* in: number of columns */ +/******************************************************************** +Free a table memory object. */ + +void +dict_mem_table_free( +/*================*/ + dict_table_t* table); /* in: table */ /************************************************************************** Creates a cluster memory object. */ diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 625978ffc38..6939edbcaf8 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -242,6 +242,9 @@ contains the sum of the following flag and the locally stored len. */ #define UNIV_EXTERN_STORAGE_FIELD (UNIV_SQL_NULL - UNIV_PAGE_SIZE) +/* Compile-time constant of the given array's size. */ +#define UT_ARR_SIZE(a) (sizeof(a) / sizeof((a)[0])) + #include <stdio.h> #include "ut0dbg.h" #include "ut0ut.h" diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index ba50e6a3511..23d019b6f78 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1474,6 +1474,7 @@ row_create_table_for_mysql( const char* table_name; ulint table_name_len; ulint err; + ulint i; ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); #ifdef UNIV_SYNC_DEBUG @@ -1510,6 +1511,19 @@ row_create_table_for_mysql( return(DB_ERROR); } + /* Check that no reserved column names are used. */ + for (i = 0; i < dict_table_get_n_user_cols(table); i++) { + dict_col_t* col = dict_table_get_nth_col(table, i); + + if (dict_col_name_is_reserved(col->name)) { + + dict_mem_table_free(table); + trx_commit_for_mysql(trx); + + return(DB_ERROR); + } + } + trx_start_if_not_started(trx); if (row_mysql_is_recovered_tmp_table(table->name)) { |