From e2ff2885319e480477e8f7d2824065ee4f4363a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 May 2011 15:06:16 +0200 Subject: [PATCH 01/15] Fix buildbot failure in rpl_stop_slave.test. Problem was setting DEBUG_SYNC twice in a row too fast in the test case; this could cause the second setting to override the first before the code had time to react to the first, causing the signal to get lost. Fixed by waiting for the code to receive the first signal before overwriting it in the test case. --- mysql-test/suite/rpl/r/rpl_stop_slave.result | 1 + mysql-test/suite/rpl/t/rpl_stop_slave.test | 1 + sql/sql_repl.cc | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_stop_slave.result b/mysql-test/suite/rpl/r/rpl_stop_slave.result index ac5eacc7066..56199b003c5 100644 --- a/mysql-test/suite/rpl/r/rpl_stop_slave.result +++ b/mysql-test/suite/rpl/r/rpl_stop_slave.result @@ -168,6 +168,7 @@ STOP SLAVE; ROLLBACK; [connection master] SET DEBUG_SYNC= 'now SIGNAL signal.continue'; +SET DEBUG_SYNC= 'now WAIT_FOR signal.continued'; SET DEBUG_SYNC= 'RESET'; [connection slave] include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/rpl/t/rpl_stop_slave.test b/mysql-test/suite/rpl/t/rpl_stop_slave.test index 8d2b26dd4ea..1502c694ea0 100644 --- a/mysql-test/suite/rpl/t/rpl_stop_slave.test +++ b/mysql-test/suite/rpl/t/rpl_stop_slave.test @@ -109,6 +109,7 @@ ROLLBACK; --source include/rpl_connection_master.inc SET DEBUG_SYNC= 'now SIGNAL signal.continue'; +SET DEBUG_SYNC= 'now WAIT_FOR signal.continued'; SET DEBUG_SYNC= 'RESET'; --source include/rpl_connection_slave.inc diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 418c2985f85..5038d02abca 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -571,6 +571,11 @@ impossible position"; DBUG_ASSERT(opt_debug_sync_timeout > 0); DBUG_ASSERT(!debug_sync_set_action(current_thd, STRING_WITH_LEN(act))); + const char act2[]= + "now " + "signal signal.continued"; + DBUG_ASSERT(!debug_sync_set_action(current_thd, + STRING_WITH_LEN(act2))); } }); From 11411f5b6ca747df3e650c1e452bc601b157f50e Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 10 May 2011 18:00:28 +0200 Subject: [PATCH 02/15] Cygwin-specific klugde to workaround missing TEMP/TMP variables. --- win/cmake/create_initial_db.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/win/cmake/create_initial_db.cmake.in b/win/cmake/create_initial_db.cmake.in index f2b8c67bcf2..d4721b7bac4 100644 --- a/win/cmake/create_initial_db.cmake.in +++ b/win/cmake/create_initial_db.cmake.in @@ -57,6 +57,7 @@ SET(BOOTSTRAP_COMMAND --language=${CMAKE_CURRENT_BINARY_DIR}/share/english --basedir=. --datadir=. + --tmpdir=. --default-storage-engine=MyISAM --loose-skip-innodb --loose-skip-pbxt From 27fb650b8bc53a9bad060230e054b303364aeb1e Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 10 May 2011 18:18:25 +0200 Subject: [PATCH 03/15] Fix Windows embedded warnings --- libmysqld/libmysqld.def | 1 - storage/xtradb/CMakeLists.txt | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libmysqld/libmysqld.def b/libmysqld/libmysqld.def index 754aa6b3c29..08325cc6180 100644 --- a/libmysqld/libmysqld.def +++ b/libmysqld/libmysqld.def @@ -1,5 +1,4 @@ LIBRARY LIBMYSQLD -DESCRIPTION 'MySQL 5.1 Embedded Server Library' VERSION 5.1 EXPORTS mysql_thread_end diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index 9782f43fb27..509f7f0fe73 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -48,10 +48,11 @@ IF(MSVC) SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c PROPERTIES COMPILE_FLAGS -Od) ENDIF() - # Avoid "unreferenced label" warning in generated file - SET_SOURCE_FILES_PROPERTIES(pars/pars0grm.c + # Avoid "unreferenced label" warning in generated file + GET_FILENAME_COMPONENT(_SRC_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/pars0grm.c PROPERTIES COMPILE_FLAGS "/wd4102") - SET_SOURCE_FILES_PROPERTIES(pars/lexyy.c + SET_SOURCE_FILES_PROPERTIES(${_SRC_DIR}/pars/lexyy.c PROPERTIES COMPILE_FLAGS "/wd4003") ENDIF() From e343a2c1347a0e99b363dbced913276d2355237f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 10 May 2011 18:19:11 +0200 Subject: [PATCH 04/15] small enhancement of the create table options feature: no unnecessary casting from void*, more type safety. typos fixed. --- sql/create_options.cc | 3 +- sql/create_options.h | 2 +- sql/field.h | 5 ++- sql/handler.h | 11 ++++-- sql/sql_table.cc | 10 ++--- sql/structs.h | 3 +- sql/table.h | 2 +- storage/example/ha_example.cc | 69 ++++++++++++++++++----------------- 8 files changed, 58 insertions(+), 47 deletions(-) diff --git a/sql/create_options.cc b/sql/create_options.cc index a7124310279..42c69436897 100644 --- a/sql/create_options.cc +++ b/sql/create_options.cc @@ -258,7 +258,7 @@ static const size_t ha_option_type_sizeof[]= @retval FALSE OK */ -my_bool parse_option_list(THD* thd, void **option_struct, +my_bool parse_option_list(THD* thd, void *option_struct_arg, engine_option_value *option_list, ha_create_table_option *rules, my_bool suppress_warning, @@ -267,6 +267,7 @@ my_bool parse_option_list(THD* thd, void **option_struct, ha_create_table_option *opt; size_t option_struct_size= 0; engine_option_value *val= option_list; + void **option_struct= (void**)option_struct_arg; DBUG_ENTER("parse_option_list"); DBUG_PRINT("enter", ("struct: 0x%lx list: 0x%lx rules: 0x%lx suppres %u root 0x%lx", diff --git a/sql/create_options.h b/sql/create_options.h index b66bbf43570..174abb1a59a 100644 --- a/sql/create_options.h +++ b/sql/create_options.h @@ -70,7 +70,7 @@ class Create_field; my_bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share); -my_bool parse_option_list(THD* thd, void **option_struct, +my_bool parse_option_list(THD* thd, void *option_struct, engine_option_value *option_list, ha_create_table_option *rules, my_bool suppress_warning, diff --git a/sql/field.h b/sql/field.h index 5302b3de821..928f8ff2529 100644 --- a/sql/field.h +++ b/sql/field.h @@ -32,6 +32,7 @@ class Send_field; class Protocol; class Create_field; class Relay_log_info; +struct ha_field_option_struct; struct st_cache_field; int field_conv(Field *to,Field *from); @@ -137,7 +138,7 @@ public: const char *field_name; /** reference to the list of options or NULL */ engine_option_value *option_list; - void *option_struct; /* structure with parsed options */ + ha_field_option_struct *option_struct; /* structure with parsed options */ LEX_STRING comment; /* Field is part of the following keys */ key_map key_start, part_of_key, part_of_key_not_clustered; @@ -2155,7 +2156,7 @@ public: Field *field; // For alter table engine_option_value *option_list; /** structure with parsed options (for comparing fields in ALTER TABLE) */ - void *option_struct; + ha_field_option_struct *option_struct; uint8 row,col,sc_length,interval_id; // For rea_create_table uint offset,pack_flag; diff --git a/sql/handler.h b/sql/handler.h index 32112fdcd13..3dadf37dcdf 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -593,6 +593,11 @@ struct handler_log_file_data { See ha_example.cc for an example. */ + +struct ha_table_option_struct; +struct ha_field_option_struct; +struct ha_index_option_struct; + enum ha_option_type { HA_OPTION_TYPE_ULL, /* unsigned long long */ HA_OPTION_TYPE_STRING, /* char * */ HA_OPTION_TYPE_ENUM, /* uint */ @@ -1060,9 +1065,9 @@ typedef struct st_ha_create_information enum ha_choice page_checksum; ///< If we have page_checksums engine_option_value *option_list; ///< list of table create options /* the following three are only for ALTER TABLE, check_if_incompatible_data() */ - void *option_struct; ///< structure with parsed table options - void **fileds_option_struct; ///< array of field option structures - void **indexes_option_struct; ///< array of index option structures + ha_table_option_struct *option_struct; ///< structure with parsed table options + ha_field_option_struct **fields_option_struct; ///< array of field option structures + ha_index_option_struct **indexes_option_struct; ///< array of index option structures } HA_CREATE_INFO; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 98de5e95da9..2697155df86 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5855,10 +5855,10 @@ compare_tables(TABLE *table, DBUG_RETURN(0); } - if ((create_info->fileds_option_struct= - (void**)thd->calloc(sizeof(void*) * table->s->fields)) == NULL || - (create_info->indexes_option_struct= - (void**)thd->calloc(sizeof(void*) * table->s->keys)) == NULL) + if ((create_info->fields_option_struct= (ha_field_option_struct**) + thd->calloc(sizeof(void*) * table->s->fields)) == NULL || + (create_info->indexes_option_struct= (ha_index_option_struct**) + thd->calloc(sizeof(void*) * table->s->keys)) == NULL) DBUG_RETURN(1); /* @@ -5879,7 +5879,7 @@ compare_tables(TABLE *table, tmp_new_field= tmp_new_field_it++) { DBUG_ASSERT(i < table->s->fields); - create_info->fileds_option_struct[i]= tmp_new_field->option_struct; + create_info->fields_option_struct[i]= tmp_new_field->option_struct; /* Make sure we have at least the default charset in use. */ if (!new_field->charset) diff --git a/sql/structs.h b/sql/structs.h index 64e69fca0d0..e2fd2140763 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -69,6 +69,7 @@ typedef struct st_key_part_info { /* Info about a key part */ } KEY_PART_INFO ; class engine_option_value; +struct ha_index_option_struct; typedef struct st_key { uint key_length; /* Tot length of key */ @@ -104,7 +105,7 @@ typedef struct st_key { struct st_table *table; /** reference to the list of options or NULL */ engine_option_value *option_list; - void *option_struct; /* structure with parsed options */ + ha_index_option_struct *option_struct; /* structure with parsed options */ } KEY; diff --git a/sql/table.h b/sql/table.h index afe1f64dae1..1b7713022ce 100644 --- a/sql/table.h +++ b/sql/table.h @@ -343,7 +343,7 @@ typedef struct st_table_share struct st_table *open_tables; /* link to open tables */ #endif engine_option_value *option_list; /* text options for table */ - void *option_struct; /* structure with parsed options */ + ha_table_option_struct *option_struct; /* structure with parsed options */ /* The following is copied to each TABLE on OPEN */ Field **field; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index f2aee1de70c..273b7039296 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -115,13 +115,14 @@ pthread_mutex_t example_mutex; /** - structure for CREATE TABLE options (table options) + Structure for CREATE TABLE options (table options). + It needs to be called ha_table_option_struct. - These can be specified in the CREATE TABLE: - CREATE TABLE ( ... ) {...here...} + The option values can be specified in the CREATE TABLE at the end: + CREATE TABLE ( ... ) *here* */ -struct example_table_options_struct +struct ha_table_option_struct { const char *strparam; ulonglong ullparam; @@ -131,19 +132,26 @@ struct example_table_options_struct /** - structure for CREATE TABLE options (field options) + Structure for CREATE TABLE options (field options). + It needs to be called ha_field_option_struct. - These can be specified in the CREATE TABLE per field: - CREATE TABLE ( field ... {...here...}, ... ) + The option values can be specified in the CREATE TABLE per field: + CREATE TABLE ( field ... *here*, ... ) */ -struct example_field_options_struct +struct ha_field_option_struct { - const char *compex_param_to_parse_it_in_engine; + const char *complex_param_to_parse_it_in_engine; }; -/* HA_TOPTION_* macros expect the structure called ha_table_option_struct */ -#define ha_table_option_struct example_table_options_struct +/* + no example here, but index options can be declared similarly + using the ha_index_option_struct structure. + + Their values can be specified in the CREATE TABLE per index: + CREATE TABLE ( field ..., .., INDEX .... *here*, ... ) +*/ + ha_create_table_option example_table_option_list[]= { /* @@ -169,8 +177,6 @@ ha_create_table_option example_table_option_list[]= HA_TOPTION_END }; -/* HA_FOPTION_* macros expect the structure called ha_field_option_struct */ -#define ha_field_option_struct example_field_options_struct ha_create_table_option example_field_option_list[]= { /* @@ -178,7 +184,7 @@ ha_create_table_option example_field_option_list[]= or boolean - for example a list - it needs to specify the option as a string and parse it internally. */ - HA_FOPTION_STRING("COMPLEX", compex_param_to_parse_it_in_engine), + HA_FOPTION_STRING("COMPLEX", complex_param_to_parse_it_in_engine), HA_FOPTION_END }; @@ -368,8 +374,7 @@ int ha_example::open(const char *name, int mode, uint test_if_locked) thr_lock_data_init(&share->lock,&lock,NULL); #ifndef DBUG_OFF - example_table_options_struct *options= - (example_table_options_struct *)table->s->option_struct; + ha_table_option_struct *options= table->s->option_struct; DBUG_ASSERT(options); DBUG_PRINT("info", ("strparam: '%-.64s' ullparam: %llu enumparam: %u "\ @@ -899,8 +904,7 @@ int ha_example::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { #ifndef DBUG_OFF - example_table_options_struct *options= - (example_table_options_struct *)table_arg->s->option_struct; + ha_table_option_struct *options= table_arg->s->option_struct; DBUG_ENTER("ha_example::create"); /* This example shows how to support custom engine specific table and field @@ -913,13 +917,12 @@ int ha_example::create(const char *name, TABLE *table_arg, options->ullparam, options->enumparam, options->boolparam)); for (Field **field= table_arg->s->field; *field; field++) { - example_field_options_struct *field_options= - (example_field_options_struct *)(*field)->option_struct; + ha_field_option_struct *field_options= (*field)->option_struct; DBUG_ASSERT(field_options); DBUG_PRINT("info", ("field: %s complex: '%-.64s'", (*field)->field_name, - (field_options->compex_param_to_parse_it_in_engine ? - field_options->compex_param_to_parse_it_in_engine : + (field_options->complex_param_to_parse_it_in_engine ? + field_options->complex_param_to_parse_it_in_engine : ""))); } #endif @@ -941,21 +944,21 @@ int ha_example::create(const char *name, TABLE *table_arg, bool ha_example::check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes) { - example_table_options_struct *param_old, *param_new; + ha_table_option_struct *param_old, *param_new; uint i; DBUG_ENTER("ha_example::check_if_incompatible_data"); /* This example shows how custom engine specific table and field options can be accessed from this function to be compared. */ - param_new= (example_table_options_struct *)info->option_struct; + param_new= info->option_struct; DBUG_PRINT("info", ("new strparam: '%-.64s' ullparam: %llu enumparam: %u " "boolparam: %u", (param_new->strparam ? param_new->strparam : ""), param_new->ullparam, param_new->enumparam, param_new->boolparam)); - param_old= (example_table_options_struct *)table->s->option_struct; + param_old= table->s->option_struct; DBUG_PRINT("info", ("old strparam: '%-.64s' ullparam: %llu enumparam: %u " "boolparam: %u", (param_old->strparam ? param_old->strparam : ""), @@ -974,19 +977,19 @@ bool ha_example::check_if_incompatible_data(HA_CREATE_INFO *info, for (i= 0; i < table->s->fields; i++) { - example_field_options_struct *f_old, *f_new; - f_old= (example_field_options_struct *)table->s->field[i]->option_struct; + ha_field_option_struct *f_old, *f_new; + f_old= table->s->field[i]->option_struct; DBUG_ASSERT(f_old); DBUG_PRINT("info", ("old field: %u old complex: '%-.64s'", i, - (f_old->compex_param_to_parse_it_in_engine ? - f_old->compex_param_to_parse_it_in_engine : + (f_old->complex_param_to_parse_it_in_engine ? + f_old->complex_param_to_parse_it_in_engine : ""))); - if (info->fileds_option_struct[i]) + if (info->fields_option_struct[i]) { - f_new= (example_field_options_struct *)info->fileds_option_struct[i]; + f_new= info->fields_option_struct[i]; DBUG_PRINT("info", ("old field: %u new complex: '%-.64s'", i, - (f_new->compex_param_to_parse_it_in_engine ? - f_new->compex_param_to_parse_it_in_engine : + (f_new->complex_param_to_parse_it_in_engine ? + f_new->complex_param_to_parse_it_in_engine : ""))); } else From 520927a7df486a1a21f87dadd9c5a920bf583917 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 May 2011 14:09:48 +0300 Subject: [PATCH 05/15] Bugfix: New table creation/renaming block added if old encoded table present. mysql-test/r/create.result: test of renaming mysql-test/r/upgrade.result: Now such behaviour prohibited to avoid problems. mysql-test/t/create.test: test of renaming mysql-test/t/upgrade.test: Now such behaviour prohibited to avoid problems. sql/mysql_priv.h: Function to test table name presence added. sql/sql_rename.cc: Rename fixed. sql/sql_table.cc: Function to test table name presence added. Create fixed. --- mysql-test/r/create.result | 19 +++++++++++ mysql-test/r/upgrade.result | 6 +--- mysql-test/t/create.test | 25 +++++++++++++++ mysql-test/t/upgrade.test | 4 +-- sql/mysql_priv.h | 5 +++ sql/sql_rename.cc | 16 +++++----- sql/sql_table.cc | 64 ++++++++++++++++++++++++++++++++++--- 7 files changed, 119 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index e871d9526ca..720e7c1d24e 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1890,5 +1890,24 @@ create table t3 (a int) row_format=page; drop table t1,t2,t3; # -- End of Bug#45829 +# new table creation/renaming blocked if old encoded table present +create table `t-1` (a int) engine=myisam; +insert into `t-1` values (1); +show tables; +Tables_in_test +t-1 +flush tables; +convert table files in mysql 5.0 file name encoding +show tables; +Tables_in_test +#mysql50#t-1 +create table `t-1` (a int); +ERROR 42S01: Table '#mysql50#t-1' already exists +create table t1 (a int); +alter table t1 rename `t-1`; +ERROR 42S01: Table '#mysql50#t-1' already exists +rename table t1 to `t-1`; +ERROR 42S01: Table '#mysql50#t-1' already exists +drop table `#mysql50#t-1`, t1; End of 5.1 tests diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index f2c8886c915..ec63cc0d98c 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -48,14 +48,10 @@ insert into `txu#p#p1` values (1); select * from `txu@0023p@0023p1`; ERROR 42S02: Table 'test.txu@0023p@0023p1' doesn't exist create table `txu@0023p@0023p1` (s1 int); -insert into `txu@0023p@0023p1` values (2); -select * from `txu@0023p@0023p1`; -s1 -2 +ERROR 42S01: Table '#mysql50#txu@0023p@0023p1' already exists select * from `txu#p#p1`; s1 1 -drop table `txu@0023p@0023p1`; drop table `txu#p#p1`; # # Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1 diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index f3cd48af543..fa991aab0d7 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1534,5 +1534,30 @@ drop table t1,t2,t3; --echo --echo # -- End of Bug#45829 +# +--echo # new table creation/renaming blocked if old encoded table present +# +let $MYSQLD_DATADIR= `select @@datadir`; +create table `t-1` (a int) engine=myisam; +insert into `t-1` values (1); +show tables; +flush tables; +--echo convert table files in mysql 5.0 file name encoding +--copy_file $MYSQLD_DATADIR/test/t@002d1.MYD $MYSQLD_DATADIR/test/t-1.MYD +--copy_file $MYSQLD_DATADIR/test/t@002d1.MYI $MYSQLD_DATADIR/test/t-1.MYI +--copy_file $MYSQLD_DATADIR/test/t@002d1.frm $MYSQLD_DATADIR/test/t-1.frm +--remove_file $MYSQLD_DATADIR/test/t@002d1.MYD +--remove_file $MYSQLD_DATADIR/test/t@002d1.MYI +--remove_file $MYSQLD_DATADIR/test/t@002d1.frm +show tables; +--error ER_TABLE_EXISTS_ERROR +create table `t-1` (a int); +create table t1 (a int); +--error ER_TABLE_EXISTS_ERROR +alter table t1 rename `t-1`; +--error ER_TABLE_EXISTS_ERROR +rename table t1 to `t-1`; +drop table `#mysql50#t-1`, t1; + --echo --echo End of 5.1 tests diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index 400ce07b7fd..a8c875ef764 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -41,11 +41,9 @@ create table `txu#p#p1` (s1 int); insert into `txu#p#p1` values (1); --error 1146 select * from `txu@0023p@0023p1`; +--error ER_TABLE_EXISTS_ERROR create table `txu@0023p@0023p1` (s1 int); -insert into `txu@0023p@0023p1` values (2); -select * from `txu@0023p@0023p1`; select * from `txu#p#p1`; -drop table `txu@0023p@0023p1`; drop table `txu#p#p1`; --echo # diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 24c8ba0b257..51450950521 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1206,6 +1206,11 @@ bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd, TABLE_LIST *table)); bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t); bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t); +bool check_table_file_presence(char *old_path, char *path, + const char *db, + const char *table_name, + const char *alias, + bool issue_error); Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, Item ***copy_func, Field **from_field, Field **def_field, diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index df7054c94d0..81c6e3ad4be 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -245,7 +245,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, char *new_table_alias, bool skip_error) { int rc= 1; - char name[FN_REFLEN + 1]; + char new_name[FN_REFLEN + 1], old_name[FN_REFLEN + 1]; const char *new_alias, *old_alias; frm_type_enum frm_type; enum legacy_db_type table_type; @@ -264,17 +264,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, } DBUG_ASSERT(new_alias); - build_table_filename(name, sizeof(name) - 1, + build_table_filename(new_name, sizeof(new_name) - 1, new_db, new_alias, reg_ext, 0); - if (!access(name,F_OK)) + build_table_filename(old_name, sizeof(old_name) - 1, + ren_table->db, old_alias, reg_ext, 0); + if (check_table_file_presence(old_name, + new_name, new_db, new_alias, new_alias, TRUE)) { - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); DBUG_RETURN(1); // This can't be skipped } - build_table_filename(name, sizeof(name) - 1, - ren_table->db, old_alias, reg_ext, 0); - frm_type= mysql_frm_type(thd, name, &table_type); + frm_type= mysql_frm_type(thd, old_name, &table_type); switch (frm_type) { case FRMTYPE_TABLE: @@ -319,7 +319,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name, default: DBUG_ASSERT(0); // should never happen case FRMTYPE_ERROR: - my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); + my_error(ER_FILE_NOT_FOUND, MYF(0), old_name, my_errno); break; } if (rc && !skip_error) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 939ca6302d9..d76f1a427be 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3611,6 +3611,58 @@ static inline int write_create_table_bin_log(THD *thd, } +/** + Check that there is no frm file for given table + + @param old_path path to the old frm file + @param path path to the frm file in new encoding + @param db database name + @param table_name table name + @param alias table name for error message (for new encoding) + @param issue_error should we issue error messages + + @retval FALSE there is no frm file + @retval TRUE there is frm file +*/ + +bool check_table_file_presence(char *old_path, + char *path, + const char *db, + const char *table_name, + const char *alias, + bool issue_error) +{ + if (!access(path,F_OK)) + { + if (issue_error) + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),alias); + return TRUE; + } + { + /* + Check if file of the table in 5.0 file name encoding exists. + + Except case when it is the same table. + */ + char tbl50[FN_REFLEN]; + strxmov(tbl50, mysql_data_home, "/", db, "/", table_name, NullS); + if (!access(fn_format(tbl50, tbl50, "", reg_ext, + MY_UNPACK_FILENAME), F_OK) && + (old_path == NULL || + strcmp(old_path, tbl50) != 0)) + { + if (issue_error) + { + strxmov(tbl50, MYSQL50_TABLE_NAME_PREFIX, table_name, NullS); + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tbl50); + } + return TRUE; + } + } + return FALSE; +} + + /* Create a table @@ -3892,11 +3944,12 @@ bool mysql_create_table_no_lock(THD *thd, VOID(pthread_mutex_lock(&LOCK_open)); if (!internal_tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { - if (!access(path,F_OK)) + if (check_table_file_presence(NULL, path, db, table_name, table_name, + !(create_info->options & + HA_LEX_CREATE_IF_NOT_EXISTS))) { if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) goto warn; - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto unlock_and_end; } /* @@ -6512,6 +6565,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, TABLE *table, *new_table= 0, *name_lock= 0; int error= 0; char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN + 1]; + char old_name_buff[FN_REFLEN + 1]; char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; char path[FN_REFLEN + 1]; @@ -6741,10 +6795,12 @@ view_err: build_table_filename(new_name_buff, sizeof(new_name_buff) - 1, new_db, new_name_buff, reg_ext, 0); - if (!access(new_name_buff, F_OK)) + build_table_filename(old_name_buff, sizeof(old_name_buff) - 1, + db, table_name, reg_ext, 0); + if (check_table_file_presence(old_name_buff, new_name_buff, new_db, + new_name, new_alias, TRUE)) { /* Table will be closed in do_command() */ - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias); goto err; } } From 84505e6e3a107e062d1caa20cf7ed63443133ef6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 12 May 2011 14:56:08 +0300 Subject: [PATCH 06/15] db_name can change case, so we need copy of it for case insensitive FS. --- sql/sql_show.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 09367503448..884d58d3674 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3415,9 +3415,15 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) it.rewind(); /* To get access to new elements in basis list */ while ((db_name= it++)) { - /* db_name can be changed in make_table_list() func */ - LEX_STRING orig_db_name= *db_name; + LEX_STRING orig_db_name; + /* + db_name can be changed in make_table_list() func. + We need copy of db_name because it can change case. + */ + if (!thd->make_lex_string(&orig_db_name, db_name->str, + db_name->length, FALSE)) + goto err; #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!(check_access(thd,SELECT_ACL, db_name->str, &thd->col_access, 0, 1, with_i_schema) || From 1c95254523954637ae1904c436916ed1da13f378 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 12 May 2011 15:31:11 +0200 Subject: [PATCH 07/15] Fix check_table_file_presence: On Windows, do not attempt access() for special device names like CON, PRN etc. access() would return 0, this does not mean that fiile with this name exists. --- sql/sql_table.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d76f1a427be..feacecd40a5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3645,9 +3645,19 @@ bool check_table_file_presence(char *old_path, Except case when it is the same table. */ char tbl50[FN_REFLEN]; +#ifdef _WIN32 + if (check_if_legal_tablename(table_name) != 0) + { + /* + Check for reserved device names for which access() returns 0 + (CON, AUX etc). + */ + return FALSE; + } +#endif strxmov(tbl50, mysql_data_home, "/", db, "/", table_name, NullS); - if (!access(fn_format(tbl50, tbl50, "", reg_ext, - MY_UNPACK_FILENAME), F_OK) && + fn_format(tbl50, tbl50, "", reg_ext, MY_UNPACK_FILENAME); + if (!access(tbl50, F_OK) && (old_path == NULL || strcmp(old_path, tbl50) != 0)) { From 83ce12ba699468dbb9477803a741dfaba426e7f7 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 12 May 2011 15:34:02 +0200 Subject: [PATCH 08/15] Windows build : Make win\config.js optional in 5.1 Simplifies handling 5.1 in buildbot. --- CMakeLists.txt | 93 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e727080df2..4954e4a9d07 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,98 @@ ENDIF(COMMAND cmake_policy) PROJECT(MySql) # This reads user configuration, generated by configure.js. -INCLUDE(win/configure.data) +INCLUDE(win/configure.data OPTIONAL) + +MACRO(MYSQL_GET_CONFIG_VALUE keyword var) + IF(NOT ${var}) + IF (EXISTS ${CMAKE_SOURCE_DIR}/configure.in) + FILE (STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "^[ ]*${keyword}=") + IF(str) + STRING(REPLACE "${keyword}=" "" str ${str}) + STRING(REGEX REPLACE "[ ].*" "" str ${str}) + SET(${var} ${str} CACHE INTERNAL "Config variable") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + + +# Read mysql version for configure script + +MACRO(GET_MYSQL_VERSION) + IF(NOT VERSION_STRING) + IF(EXISTS ${CMAKE_SOURCE_DIR}/configure.in) + FILE(STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "AM_INIT_AUTOMAKE") + STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][^ \\)]+" VERSION_STRING "${str}") + IF(NOT VERSION_STRING) + STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}") + IF(NOT VERSION_STRING) + FILE(STRINGS configure.in str REGEX "AC_INIT\\(") + STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][a-zA-Z0-9]+" VERSION_STRING "${str}") + IF(NOT VERSION_STRING) + STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION_STRING "${str}") + ENDIF() + ENDIF() + ENDIF() + ENDIF() + ENDIF() + + IF(NOT VERSION_STRING) + MESSAGE(FATAL_ERROR + "VERSION_STRING cannot be parsed, please specify -DVERSION_STRING=major.minor.patch-extra" + "when calling cmake") + ENDIF() + + SET(VERSION ${VERSION_STRING}) + STRING(REPLACE "-" "_" MYSQL_U_SCORE_VERSION "${VERSION_STRING}") + + # Remove trailing (non-numeric) part of the version string + STRING(REGEX REPLACE "[^\\.0-9].*" "" VERSION_STRING ${VERSION_STRING}) + + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" MAJOR_VERSION "${VERSION_STRING}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" MINOR_VERSION "${VERSION_STRING}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PATCH "${VERSION_STRING}") + SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version") + SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}") + MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH}") + MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION) + SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH}) +ENDMACRO() + +# Get mysql version and other interesting variables +GET_MYSQL_VERSION() + +MYSQL_GET_CONFIG_VALUE("PROTOCOL_VERSION" PROTOCOL_VERSION) +MYSQL_GET_CONFIG_VALUE("DOT_FRM_VERSION" DOT_FRM_VERSION) +MYSQL_GET_CONFIG_VALUE("MYSQL_TCP_PORT_DEFAULT" MYSQL_TCP_PORT_DEFAULT) +MYSQL_GET_CONFIG_VALUE("MYSQL_UNIX_ADDR_DEFAULT" MYSQL_UNIX_ADDR_DEFAULT) +MYSQL_GET_CONFIG_VALUE("SHARED_LIB_MAJOR_VERSION" SHARED_LIB_MAJOR_VERSION) +IF(NOT MYSQL_TCP_PORT_DEFAULT) + SET(MYSQL_TCP_PORT_DEFAULT "3306") +ENDIF() +IF(NOT MYSQL_TCP_PORT) + SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT}) + SET(MYSQL_TCP_PORT_DEFAULT "0") +ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT) + SET(MYSQL_TCP_PORT_DEFAULT "0") +ENDIF() + + +IF(NOT MYSQL_UNIX_ADDR) + SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock") +ENDIF() +IF(NOT COMPILATION_COMMENT) + SET(COMPILATION_COMMENT "Source distribution") +ENDIF() + +SET(WITH_EXAMPLE_STORAGE_ENGINE TRUE) +SET(WITH_FEDERATEDX_STORAGE_ENGINE TRUE) +SET(WITH_PARTITION_STORAGE_ENGINE TRUE) +SET(WITH_MARIA_STORAGE_ENGINE TRUE) +SET(WITH_PBXT_STORAGE_ENGINE TRUE) +SET(WITH_XTRADB_STORAGE_ENGINE TRUE) # Hardcode support for CSV storage engine SET(WITH_CSV_STORAGE_ENGINE TRUE) From 5933619ceb8883ebc36e71d11824acfd272913bc Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 13 May 2011 16:22:05 +0300 Subject: [PATCH 09/15] Made test-unit run in parlallel. This was achived by having all aria tests that uses temporary files to create the temporary file in an unique tempdirectory. aria_chk now returns 1 if one got any warnings during check and 2 if one got errors. lp:728919 maria_chk should fail on all detected corruptions mysql-test/lib/My/SafeProcess.pm: Removed ^M lines from the file storage/maria/ma_check.c: Fixed indentation storage/maria/maria_chk.c: aria_chk now returns 1 if one got any warnings during check and 2 if one got errors. storage/maria/unittest/ma_control_file-t.c: Use unique sub directory for test results storage/maria/unittest/ma_maria_log_cleanup.c: Added help function create_tmpdir() storage/maria/unittest/ma_pagecache_consist.c: Use unique sub directory for test results storage/maria/unittest/ma_pagecache_rwconsist.c: Use unique sub directory for test results storage/maria/unittest/ma_pagecache_rwconsist2.c: Use unique sub directory for test results storage/maria/unittest/ma_pagecache_single.c: Use unique sub directory for test results storage/maria/unittest/ma_test_all-t: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler-t.c: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler_first_lsn-t.c: Use unique sub directory for test results remove delete of files that are already deleted by maria_log_remove() storage/maria/unittest/ma_test_loghandler_max_lsn-t.c: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler_multithread-t.c: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler_noflush-t.c: Use unique sub directory for test results remove delete of files that are already deleted by maria_log_remove() storage/maria/unittest/ma_test_loghandler_nologs-t.c: Use unique sub directory for test results storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Use unique sub directory for test results remove delete of files that are already deleted by maria_log_remove() storage/maria/unittest/ma_test_loghandler_purge-t.c: Use unique sub directory for test results support-files/compiler_warnings.supp: Supress some warnings unittest/unit.pl: Run 4 unittests in parallel --- mysql-test/lib/My/SafeProcess.pm | 22 ++++----- storage/maria/ma_check.c | 36 +++++++------- storage/maria/maria_chk.c | 17 +++++-- storage/maria/unittest/ma_control_file-t.c | 26 +++++++++- storage/maria/unittest/ma_maria_log_cleanup.c | 24 +++++++++- storage/maria/unittest/ma_pagecache_consist.c | 30 +++++++++++- .../maria/unittest/ma_pagecache_rwconsist.c | 29 +++++++++++- .../maria/unittest/ma_pagecache_rwconsist2.c | 29 +++++++++++- storage/maria/unittest/ma_pagecache_single.c | 32 +++++++++++-- storage/maria/unittest/ma_test_all-t | 47 ++++++++++++++----- storage/maria/unittest/ma_test_loghandler-t.c | 14 +++--- .../unittest/ma_test_loghandler_first_lsn-t.c | 23 +++++---- .../unittest/ma_test_loghandler_max_lsn-t.c | 13 ++--- .../ma_test_loghandler_multigroup-t.c | 25 +++++----- .../ma_test_loghandler_multithread-t.c | 19 ++++---- .../unittest/ma_test_loghandler_noflush-t.c | 16 +++---- .../unittest/ma_test_loghandler_nologs-t.c | 14 +++--- .../unittest/ma_test_loghandler_pagecache-t.c | 28 +++++------ .../unittest/ma_test_loghandler_purge-t.c | 12 ++--- support-files/compiler_warnings.supp | 7 +++ unittest/unit.pl | 1 + 21 files changed, 329 insertions(+), 135 deletions(-) diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index d75644a7311..baeb452fde0 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -86,17 +86,17 @@ sub is_child { my @safe_process_cmd; my $safe_kill; -my $bindir; -if(defined $ENV{MTR_BINDIR}) -{ - # This is an out-of-source build. Build directory - # is given in MTR_BINDIR env.variable - $bindir = $ENV{MTR_BINDIR}."/mysql-test"; -} -else -{ - $bindir = "."; -} +my $bindir; +if(defined $ENV{MTR_BINDIR}) +{ + # This is an out-of-source build. Build directory + # is given in MTR_BINDIR env.variable + $bindir = $ENV{MTR_BINDIR}."/mysql-test"; +} +else +{ + $bindir = "."; +} # Find the safe process binary or script sub find_bin { diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index fbaae67a699..136a2c7e545 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -234,14 +234,14 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, { if (test_flag & T_VERBOSE) puts(""); _ma_check_print_error(param,"Can't read delete-link at filepos: %s", - llstr(next_link,buff)); + llstr(next_link,buff)); DBUG_RETURN(1); } if (*buff != '\0') { if (test_flag & T_VERBOSE) puts(""); _ma_check_print_error(param,"Record at pos: %s is not remove-marked", - llstr(next_link,buff)); + llstr(next_link,buff)); goto wrong; } if (share->options & HA_OPTION_PACK_RECORD) @@ -250,7 +250,9 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, if (empty && prev_link != old_link) { if (test_flag & T_VERBOSE) puts(""); - _ma_check_print_error(param,"Deleted block at %s doesn't point back at previous delete link",llstr(next_link,buff2)); + _ma_check_print_error(param, + "Deleted block at %s doesn't point back at previous delete link", + llstr(next_link,buff2)); goto wrong; } old_link=next_link; @@ -269,23 +271,23 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, if (empty != share->state.state.empty) { _ma_check_print_warning(param, - "Found %s deleted space in delete link chain. Should be %s", - llstr(empty,buff2), - llstr(share->state.state.empty,buff)); + "Found %s deleted space in delete link chain. Should be %s", + llstr(empty,buff2), + llstr(share->state.state.empty,buff)); } if (next_link != HA_OFFSET_ERROR) { _ma_check_print_error(param, - "Found more than the expected %s deleted rows in delete link chain", - llstr(share->state.state.del, buff)); + "Found more than the expected %s deleted rows in delete link chain", + llstr(share->state.state.del, buff)); goto wrong; } if (i != 0) { _ma_check_print_error(param, - "Found %s deleted rows in delete link chain. Should be %s", - llstr(share->state.state.del - i, buff2), - llstr(share->state.state.del, buff)); + "Found %s deleted rows in delete link chain. Should be %s", + llstr(share->state.state.del - i, buff2), + llstr(share->state.state.del, buff)); goto wrong; } } @@ -423,8 +425,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) ulonglong2double(share->state.state.key_file_length) > ulonglong2double(share->base.margin_key_file_length)*0.9) _ma_check_print_warning(param,"Keyfile is almost full, %10s of %10s used", - llstr(share->state.state.key_file_length,buff), - llstr(share->base.max_key_file_length-1,buff)); + llstr(share->state.state.key_file_length,buff), + llstr(share->base.max_key_file_length-1,buff)); size= my_seek(info->dfile.file, 0L, MY_SEEK_END, MYF(0)); skr=(my_off_t) share->state.state.data_file_length; @@ -448,8 +450,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) else { _ma_check_print_warning(param, - "Size of datafile is: %-9s Should be: %s", - llstr(size,buff), llstr(skr,buff2)); + "Size of datafile is: %-9s Should be: %s", + llstr(size,buff), llstr(skr,buff2)); } } if (!(param->testflag & T_VERY_SILENT) && @@ -457,8 +459,8 @@ int maria_chk_size(HA_CHECK *param, register MARIA_HA *info) ulonglong2double(share->state.state.data_file_length) > (ulonglong2double(share->base.max_data_file_length)*0.9)) _ma_check_print_warning(param, "Datafile is almost full, %10s of %10s used", - llstr(share->state.state.data_file_length,buff), - llstr(share->base.max_data_file_length-1,buff2)); + llstr(share->state.state.data_file_length,buff), + llstr(share->base.max_data_file_length-1,buff2)); DBUG_RETURN(error); } /* maria_chk_size */ diff --git a/storage/maria/maria_chk.c b/storage/maria/maria_chk.c index b0e29f1d027..bb345f63b02 100644 --- a/storage/maria/maria_chk.c +++ b/storage/maria/maria_chk.c @@ -938,7 +938,13 @@ static void get_options(register int *argc,register char ***argv) } /* get options */ - /* Check table */ +/** + Check/repair table + + @return 0 table is ok + @return 1 Got warning during check + @return 2 Got error during check/repair. +*/ static int maria_chk(HA_CHECK *param, char *filename) { @@ -1404,6 +1410,7 @@ end2: if (param->error_printed) { + error= 2; if (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX)) { VOID(fprintf(stderr, @@ -1422,8 +1429,12 @@ end2: else if (param->warning_printed && ! (param->testflag & (T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE))) + { + if (!error) + error= 1; VOID(fprintf(stderr, "Aria table '%s' is usable but should be fixed\n", filename)); + } VOID(fflush(stderr)); DBUG_RETURN(error); } /* maria_chk */ @@ -1754,14 +1765,14 @@ static int maria_sort_records(HA_CHECK *param, { _ma_check_print_warning(param, "Can't sort table '%s' on key %d; No such key", - name,sort_key+1); + name,sort_key+1); param->error_printed=0; DBUG_RETURN(0); /* Nothing to do */ } if (keyinfo->flag & HA_FULLTEXT) { _ma_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d", - name,sort_key+1); + name,sort_key+1); param->error_printed=0; DBUG_RETURN(0); /* Nothing to do */ } diff --git a/storage/maria/unittest/ma_control_file-t.c b/storage/maria/unittest/ma_control_file-t.c index 164ea284f31..ca559fe57df 100644 --- a/storage/maria/unittest/ma_control_file-t.c +++ b/storage/maria/unittest/ma_control_file-t.c @@ -117,6 +117,26 @@ static CONTROL_FILE_ERROR local_ma_control_file_open(void) return error; } +static char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} int main(int argc,char *argv[]) @@ -124,11 +144,12 @@ int main(int argc,char *argv[]) MY_INIT(argv[0]); my_init(); - maria_data_root= (char *)"."; default_error_handler_hook= error_handler_hook; plan(12); + maria_data_root= create_tmpdir(argv[0]); + diag("Unit tests for control file"); get_options(argc,argv); @@ -155,6 +176,9 @@ int main(int argc,char *argv[]) ok(0 == test_bad_blocksize(), "test of bad blocksize"); ok(0 == test_bad_size(), "test of too small/big file"); + delete_file(0); + rmdir(maria_data_root); + return exit_status(); } diff --git a/storage/maria/unittest/ma_maria_log_cleanup.c b/storage/maria/unittest/ma_maria_log_cleanup.c index f85c75b1a88..5e84acf41af 100644 --- a/storage/maria/unittest/ma_maria_log_cleanup.c +++ b/storage/maria/unittest/ma_maria_log_cleanup.c @@ -16,7 +16,7 @@ #include "../maria_def.h" #include -my_bool maria_log_remove() +my_bool maria_log_remove(const char *testdir) { MY_DIR *dirp; uint i; @@ -59,6 +59,28 @@ my_bool maria_log_remove() } } my_dirend(dirp); + if (testdir) + rmdir(testdir); return 0; } +char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index 0a9e5737c7e..c060f7691a6 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -30,7 +30,8 @@ static const char* default_dbug_option; #endif -static char *file1_name= (char*)"page_cache_test_file_1"; +static const char *base_file1_name= "page_cache_test_file_1"; +static char file1_name[FN_REFLEN]; static PAGECACHE_FILE file1; static pthread_cond_t COND_thread_count; static pthread_mutex_t LOCK_thread_count; @@ -330,6 +331,27 @@ static void *test_thread_writer(void *arg) return 0; } +static char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} + int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) @@ -337,7 +359,6 @@ int main(int argc __attribute__((unused)), pthread_t tid; pthread_attr_t thr_attr; int *param, error, pagen; - MY_INIT(argv[0]); #ifndef DBUG_OFF @@ -357,9 +378,13 @@ int main(int argc __attribute__((unused)), DBUG_ENTER("main"); DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name())); plan(number_of_writers + number_of_readers); + SKIP_BIG_TESTS(number_of_writers + number_of_readers) { + char *test_dirname= create_tmpdir(argv[0]); + fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0)); + if ((file1.file= my_open(file1_name, O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) { @@ -491,6 +516,7 @@ int main(int argc __attribute__((unused)), DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("Program end")); + rmdir(test_dirname); } /* SKIP_BIG_TESTS */ my_end(0); diff --git a/storage/maria/unittest/ma_pagecache_rwconsist.c b/storage/maria/unittest/ma_pagecache_rwconsist.c index ff386c48414..511a503f349 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist.c @@ -33,7 +33,8 @@ static const char* default_dbug_option; #define SLEEP my_sleep(5) -static char *file1_name= (char*)"page_cache_test_file_1"; +static const char *base_file1_name= "page_cache_test_file_1"; +static char file1_name[FN_REFLEN]; static PAGECACHE_FILE file1; static pthread_cond_t COND_thread_count; static pthread_mutex_t LOCK_thread_count; @@ -200,6 +201,27 @@ static void *test_thread_writer(void *arg) return 0; } +char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} + int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) @@ -230,6 +252,9 @@ int main(int argc __attribute__((unused)), SKIP_BIG_TESTS(number_of_writers + number_of_readers) { + char *test_dirname= create_tmpdir(argv[0]); + fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0)); + if ((file1.file= my_open(file1_name, O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) { @@ -355,6 +380,8 @@ int main(int argc __attribute__((unused)), DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("Program end")); + + rmdir(test_dirname); } /* SKIP_BIG_TESTS */ my_end(0); diff --git a/storage/maria/unittest/ma_pagecache_rwconsist2.c b/storage/maria/unittest/ma_pagecache_rwconsist2.c index 34183a2d0ab..97d821832fe 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist2.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist2.c @@ -40,7 +40,8 @@ static const char* default_dbug_option; #define SLEEP my_sleep(5) -static char *file1_name= (char*)"page_cache_test_file_1"; +static const char *base_file1_name= "page_cache_test_file_1"; +static char file1_name[FN_REFLEN]; static PAGECACHE_FILE file1; static pthread_cond_t COND_thread_count; static pthread_mutex_t LOCK_thread_count; @@ -196,6 +197,27 @@ static void *test_thread_writer(void *arg) return 0; } +static char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} + int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) @@ -226,6 +248,9 @@ int main(int argc __attribute__((unused)), SKIP_BIG_TESTS(number_of_writers + number_of_readers) { + char *test_dirname= create_tmpdir(argv[0]); + fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0)); + if ((file1.file= my_open(file1_name, O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) { @@ -350,6 +375,8 @@ int main(int argc __attribute__((unused)), DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("Program end")); + + rmdir(test_dirname); } /* SKIP_BIG_TESTS */ my_end(0); diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index 32e588e165a..750339f3074 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -35,8 +35,9 @@ static const char* default_dbug_option; #define SKIP_BIG_TESTS(X) /* no-op */ #endif -static char *file1_name= (char*)"page_cache_test_file_1"; -static char *file2_name= (char*)"page_cache_test_file_2"; +static const char *base_file1_name= "page_cache_test_file_1"; +static const char *base_file2_name= "page_cache_test_file_2"; +static char file1_name[FN_REFLEN], file2_name[FN_REFLEN]; static PAGECACHE_FILE file1; static pthread_cond_t COND_thread_count; static pthread_mutex_t LOCK_thread_count; @@ -720,6 +721,28 @@ static void *test_thread(void *arg) } +static char *create_tmpdir(const char *progname) +{ + static char test_dirname[FN_REFLEN]; + char tmp_name[FN_REFLEN]; + uint length; + + /* Create a temporary directory of name TMP-'executable', but without the -t extension */ + fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT); + length= strlen(tmp_name); + if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't') + tmp_name[length-2]= 0; + strxmov(test_dirname, "TMP-", tmp_name, NullS); + + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + (void) my_mkdir(test_dirname, 0777, MYF(0)); + return test_dirname; +} + + int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { @@ -748,6 +771,9 @@ int main(int argc __attribute__((unused)), plan(18); SKIP_BIG_TESTS(18) { + char *test_dirname= create_tmpdir(argv[0]); + fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0)); + fn_format(file2_name, base_file2_name, test_dirname, "", MYF(0)); if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR, MYF(MY_WME))) < 0) @@ -841,13 +867,13 @@ int main(int argc __attribute__((unused)), exit(1); my_delete(file1_name, MYF(0)); + rmdir(test_dirname); } /* SKIP_BIG_TESTS */ DBUG_PRINT("info", ("file1 (%d) closed", file1.file)); DBUG_PRINT("info", ("Program end")); my_end(0); - } return exit_status(); } diff --git a/storage/maria/unittest/ma_test_all-t b/storage/maria/unittest/ma_test_all-t index f07b7d0a554..4d72c6dfadf 100755 --- a/storage/maria/unittest/ma_test_all-t +++ b/storage/maria/unittest/ma_test_all-t @@ -28,9 +28,10 @@ my $NEW_TEST= 0; # Test group separator in an array of tests my $test_begin= 0; my $test_end= 0; my $test_counter= 0; +my $using_internal_tmpdir= 0; my $full_tmpdir; my $tmpdir="tmp"; - +my $exec_dir="TMP-ma_test_all"; # Run test in this directory run_tests(); #### @@ -60,7 +61,14 @@ sub run_tests print "$my_progname version $VER\n"; exit(0); } - $maria_path= dirname($0) . "/.."; + + if (! -d $exec_dir) + { + die if (!mkdir("$exec_dir")); + } + chdir($exec_dir); + + $maria_path= "../" . dirname($0) . "/.."; my $suffix= ( $^O =~ /win/i && $^O !~ /darwin/i ) ? ".exe" : ""; $maria_exe_path= "$maria_path/release"; @@ -76,7 +84,7 @@ sub run_tests $maria_exe_path= $maria_path; if ( ! -f "$maria_exe_path/ma_test1$suffix" ) { - die("Cannot find ma_test1 executable\n"); + die("Cannot find ma_test1 executable in $maria_path\n"); } } } @@ -90,7 +98,8 @@ sub run_tests } else { - $full_tmpdir= "tmp"; + $full_tmpdir= $tmpdir; + $using_internal_tmpdir= 1; if (! -d "$full_tmpdir") { die if (!mkdir("$full_tmpdir")); @@ -227,6 +236,13 @@ sub run_tests run_tests_on_clrs($suffix, $opt_verbose, 0); unlink_all_possible_tmp_files(); + if ($using_internal_tmpdir) + { + rmdir($tmpdir); + } + rmdir($exec_dir); + chdir(".."); + rmdir($exec_dir); exit($runtime_error); } @@ -429,13 +445,16 @@ sub run_pack_tests() "cp test1.MAD test2.MAD", "cp test1.MAI test2.MAI", "$maria_exe_path/aria_pack$suffix --force -s --join=test3 test1 test2", - "$maria_exe_path/aria_chk -s test3", - "$maria_exe_path/aria_chk -s --safe-recover test3", - "$maria_exe_path/aria_chk -s test3" ); - return &count_tests(\@t) if ($count); + return (&count_tests(\@t) + 3) if ($count); &run_test_bunch(\@t, $verbose, 0); + + ok("$maria_exe_path/aria_chk -s test3", $verbose, 0, 1); + @t= ("$maria_exe_path/aria_chk -s --safe-recover test3", + "$maria_exe_path/aria_chk -s test3"); + &run_test_bunch(\@t, $verbose, 0); + return 0; } @@ -463,7 +482,7 @@ sub run_tests_on_warnings_and_errors # maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 will warn that # Datafile is almost full ok("$maria_exe_path/aria_chk$suffix -h$tmpdir -sm $tmpdir/test2 >ma_test2_message.txt 2>&1", - $verbose, 0); + $verbose, 0, 1); ok("cat ma_test2_message.txt", $verbose, 0); ok("grep \"warning: Datafile is almost full\" ma_test2_message.txt>/dev/null", $verbose, 0); @@ -550,7 +569,7 @@ sub run_tests_on_clrs sub ok { my ($com, $verbose, $iteration, $expected_error)= @_; - my ($msg, $output, $err, $len); + my ($msg, $output, $err, $errcode, $len); $test_counter++; if ($test_begin > $test_counter) @@ -580,8 +599,9 @@ sub ok print " " x (62 - $len); } $err= $?; + $errcode= ($? >> 8); if ((!$err && !$expected_error) || - (($err >> 8) == $expected_error && $expected_error)) + ($errcode == $expected_error && $expected_error)) { print "[ " if ($verbose); print "ok"; @@ -618,7 +638,7 @@ sub ok } $msg.= "at line "; $msg.= (caller)[2]; - $msg.= "\n(errcode: $err, test: $test_counter)\n"; + $msg.= "\n(errcode: $errcode, test: $test_counter)\n"; if ($expected_error) { $msg.= "Was expecting errcode: $expected_error\n"; @@ -681,7 +701,7 @@ sub unlink_all_possible_tmp_files() unlink_log_files(); # Unlink tmp files that may have been created when testing the test programs - unlink <$full_tmpdir/*.TMD aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test2.MA? test3.MA?>; + unlink <$full_tmpdir/*.TMD $full_tmpdir/aria_read_log_test1.txt $full_tmpdir/test1*.MA? $full_tmpdir/ma_test_recovery.output aria_log_control aria_log.00000001 aria_log.00000002 aria_logtest1.MA? test1.MA? test2.MA? test3.MA?>; } #### @@ -733,6 +753,7 @@ Options might depend on previous ones. --start-from=... Alias for --run-tests --silent=... Silent option passed to ma_test* tests ('$opt_silent') +--tmpdir=... Store tests data in this directory (works for most tests) --valgrind=... Options for valgrind. ('$opt_valgrind') --verbose Be more verbose. Will print each unittest on a line diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index 53459a5239d..4603992350f 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -19,7 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); extern void example_loghandler_init(); #ifndef DBUG_OFF @@ -161,7 +162,6 @@ int main(int argc __attribute__((unused)), char *argv[]) LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 3]; struct st_translog_scanner_data scanner; int rc; - MY_INIT(argv[0]); if (my_set_max_open_files(100) < 100) @@ -170,9 +170,11 @@ int main(int argc __attribute__((unused)), char *argv[]) exit(1); } bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; - if (maria_log_remove()) + + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); + /* We don't need to do physical syncs in this test */ my_disable_sync= 1; @@ -207,7 +209,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -656,7 +658,7 @@ err: end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); return(test(exit_status())); diff --git a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c index 06d9a00c04c..7e5b9543e98 100644 --- a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c @@ -19,7 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); extern void translog_example_table_init(); #ifndef DBUG_OFF @@ -31,7 +32,6 @@ static const char *default_dbug_option; #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FLAGS 0 -static char *first_translog_file= (char*)"maria_log.00000001"; int main(int argc __attribute__((unused)), char *argv[]) { @@ -40,18 +40,18 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN lsn, first_lsn, theor_lsn; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; - MY_INIT(argv[0]); plan(2); bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; - if (maria_log_remove()) + /* + Don't give an error if we can't create dir, as it may already exist from a previously aborted + run + */ + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); - /* be sure that we have no logs in the directory*/ - my_delete(CONTROL_FILE_BASE_NAME, MYF(0)); - my_delete(first_translog_file, MYF(0)); bzero(long_tr_id, 6); #ifndef DBUG_OFF @@ -78,9 +78,8 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, - LOG_FLAGS, 0, &translog_example_table_init, - 0)) + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, + LOG_FLAGS, 0, &translog_example_table_init, 0)) { fprintf(stderr, "Can't init loghandler (%d)\n", errno); exit(1); @@ -154,7 +153,7 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); exit(0); } diff --git a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c index 64f486b8cf1..915bec4893d 100644 --- a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c @@ -19,7 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); extern void translog_example_table_init(); #ifndef DBUG_OFF @@ -40,14 +41,14 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE pagecache; LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; - MY_INIT(argv[0]); plan(2); bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; - if (maria_log_remove()) + + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); bzero(long_tr_id, 6); @@ -75,7 +76,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -150,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); exit(0); } diff --git a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c index aab94ff10c7..6ea9c95acfa 100644 --- a/storage/maria/unittest/ma_test_loghandler_multigroup-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multigroup-t.c @@ -21,7 +21,8 @@ #include "sequence_storage.h" #include -extern my_bool maria_log_remove(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); extern void translog_example_table_init(); #ifndef DBUG_OFF @@ -238,21 +239,23 @@ int main(int argc __attribute__((unused)), char *argv[]) TRANSLOG_HEADER_BUFFER rec; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 2]; struct st_translog_scanner_data scanner; + const char *progname=argv[0]; int rc; - MY_INIT(argv[0]); - bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; + load_defaults("my", load_default_groups, &argc, &argv); - default_argv= argv; get_options(&argc, &argv); + default_argv= argv; + + bzero(&pagecache, sizeof(pagecache)); + maria_data_root= create_tmpdir(progname); + if (maria_log_remove(0)) + exit(1); + /* We don't need to do physical syncs in this test */ my_disable_sync= 1; - if (maria_log_remove()) - exit(1); - { uchar buff[4]; for (i= 0; i < (LONG_BUFFER_SIZE + LSN_STORE_SIZE * 2 + 2); i++) @@ -276,7 +279,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, 0, 0, &translog_example_table_init, 0)) { fprintf(stderr, "Can't init loghandler (%d)\n", errno); @@ -439,7 +442,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "pass2: Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, 0, READONLY, &translog_example_table_init, 0)) { fprintf(stderr, "pass2: Can't init loghandler (%d)\n", errno); @@ -741,7 +744,7 @@ err: ma_control_file_end(); free_defaults(default_argv); seq_storage_destroy(&seq); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); return (test(exit_status())); diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index e46fe047a97..234b233bf52 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -19,8 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); -extern void translog_example_table_init(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); #ifndef DBUG_OFF static const char *default_dbug_option; @@ -268,6 +268,7 @@ int main(int argc __attribute__((unused)), pthread_attr_t thr_attr; int *param, error; int rc; + MY_INIT(argv[0]); plan(WRITERS + FLUSHERS + ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS ); @@ -275,7 +276,10 @@ int main(int argc __attribute__((unused)), my_disable_sync= 1; bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) + exit(1); + long_buffer= malloc(LONG_BUFFER_SIZE + 7 * 2 + 2); if (long_buffer == 0) { @@ -285,11 +289,6 @@ int main(int argc __attribute__((unused)), for (i= 0; i < (LONG_BUFFER_SIZE + 7 * 2 + 2); i++) long_buffer[i]= (i & 0xFF); - MY_INIT(argv[0]); - if (maria_log_remove()) - exit(1); - - #ifndef DBUG_OFF #if defined(__WIN__) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; @@ -347,7 +346,7 @@ int main(int argc __attribute__((unused)), fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -546,7 +545,7 @@ err: translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); return(exit_status()); diff --git a/storage/maria/unittest/ma_test_loghandler_noflush-t.c b/storage/maria/unittest/ma_test_loghandler_noflush-t.c index 973dfd03bcf..3e1ce202fac 100644 --- a/storage/maria/unittest/ma_test_loghandler_noflush-t.c +++ b/storage/maria/unittest/ma_test_loghandler_noflush-t.c @@ -19,7 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); extern void translog_example_table_init(); #ifndef DBUG_OFF @@ -31,8 +32,6 @@ static const char *default_dbug_option; #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FLAGS 0 -static char *first_translog_file= (char*)"maria_log.00000001"; - int main(int argc __attribute__((unused)), char *argv[]) { uint pagen; @@ -49,12 +48,9 @@ int main(int argc __attribute__((unused)), char *argv[]) plan(1); bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; - if (maria_log_remove()) + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); - /* be sure that we have no logs in the directory*/ - my_delete(CONTROL_FILE_BASE_NAME, MYF(0)); - my_delete(first_translog_file, MYF(0)); bzero(long_tr_id, 6); #ifndef DBUG_OFF @@ -81,7 +77,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -139,7 +135,7 @@ err: translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); exit(rc); diff --git a/storage/maria/unittest/ma_test_loghandler_nologs-t.c b/storage/maria/unittest/ma_test_loghandler_nologs-t.c index 34508d1d751..03badc9aced 100644 --- a/storage/maria/unittest/ma_test_loghandler_nologs-t.c +++ b/storage/maria/unittest/ma_test_loghandler_nologs-t.c @@ -19,8 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); -extern void example_loghandler_init(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); #ifndef DBUG_OFF static const char *default_dbug_option; @@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(&pagecache, sizeof(pagecache)); bzero(long_buffer, LONG_BUFFER_SIZE); - maria_data_root= (char *)"."; - if (maria_log_remove()) + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); bzero(long_tr_id, 6); @@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -151,7 +151,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 1)) { @@ -189,7 +189,7 @@ int main(int argc __attribute__((unused)), char *argv[]) ok(1, "New log is OK"); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); exit(0); } diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index 1d21d8c6a23..4e8f7a744ee 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -19,8 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); -extern void translog_example_table_init(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); #ifndef DBUG_OFF static const char *default_dbug_option; @@ -31,8 +31,10 @@ static const char *default_dbug_option; #define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512) #define LOG_FLAGS 0 -static char *first_translog_file= (char*)"aria_log.00000001"; -static char *file1_name= (char*)"page_cache_test_file_1"; +static const char *base_first_translog_file= "aria_log.00000001"; +static const char *base_file1_name= "page_cache_test_file_1"; +static char file1_name[FN_REFLEN], first_translog_file[FN_REFLEN]; + static PAGECACHE_FILE file1; @@ -68,18 +70,15 @@ int main(int argc __attribute__((unused)), char *argv[]) LSN lsn; my_off_t file_size; LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1]; - MY_INIT(argv[0]); plan(1); bzero(&pagecache, sizeof(pagecache)); - maria_data_root= (char *)"."; - if (maria_log_remove()) + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); - /* be sure that we have no logs in the directory*/ - my_delete(CONTROL_FILE_BASE_NAME, MYF(0)); - my_delete(first_translog_file, MYF(0)); + fn_format(first_translog_file, base_first_translog_file, maria_data_root, "", MYF(0)); bzero(long_tr_id, 6); #ifndef DBUG_OFF @@ -106,7 +105,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -145,6 +144,7 @@ int main(int argc __attribute__((unused)), char *argv[]) exit(1); } + fn_format(file1_name, base_file1_name, maria_data_root, "", MYF(0)); if ((file1.file= my_open(file1_name, O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1) { @@ -192,9 +192,9 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - my_delete(CONTROL_FILE_BASE_NAME, MYF(0)); - my_delete(first_translog_file, MYF(0)); - my_delete(file1_name, MYF(0)); + my_delete(file1_name, MYF(MY_WME)); + if (maria_log_remove(maria_data_root)) + exit(1); exit(0); } diff --git a/storage/maria/unittest/ma_test_loghandler_purge-t.c b/storage/maria/unittest/ma_test_loghandler_purge-t.c index d37b45bc3ca..8badfd9451e 100644 --- a/storage/maria/unittest/ma_test_loghandler_purge-t.c +++ b/storage/maria/unittest/ma_test_loghandler_purge-t.c @@ -19,8 +19,8 @@ #include #include "../trnman.h" -extern my_bool maria_log_remove(); -extern void translog_example_table_init(); +extern my_bool maria_log_remove(const char *testdir); +extern char *create_tmpdir(const char *progname); #ifndef DBUG_OFF static const char *default_dbug_option; @@ -49,8 +49,8 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(&pagecache, sizeof(pagecache)); bzero(long_buffer, LONG_BUFFER_SIZE); - maria_data_root= (char *)"."; - if (maria_log_remove()) + maria_data_root= create_tmpdir(argv[0]); + if (maria_log_remove(0)) exit(1); bzero(long_tr_id, 6); @@ -78,7 +78,7 @@ int main(int argc __attribute__((unused)), char *argv[]) fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno); exit(1); } - if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache, + if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS, 0, &translog_example_table_init, 0)) { @@ -186,7 +186,7 @@ int main(int argc __attribute__((unused)), char *argv[]) translog_destroy(); end_pagecache(&pagecache, 1); ma_control_file_end(); - if (maria_log_remove()) + if (maria_log_remove(maria_data_root)) exit(1); exit(0); } diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 3025fdf5f5d..0a0f08eac16 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -183,3 +183,10 @@ ctype-simple\.c : .*unary minus operator applied to unsigned type, result still regexec\.c : passing argument 3 of.*matcher.* discards qualifiers from pointer target type libmysql\.c: passing argument 2 of .*memcpy.* discards qualifiers from pointer target type : 3000-4000 storage/xtradb/dict/dict0dict\.c : passing argument 1 of .*strcpy.* discards qualifiers from pointer target type : 2500-3500 + +# +# Strange things from autoconf that is probably safe to ignore +# + +configure.in : warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body +configure.in : config/ac-macros/character_sets.m4.*prefer named diversions diff --git a/unittest/unit.pl b/unittest/unit.pl index 9900f47f374..4eaf4cd2f9b 100644 --- a/unittest/unit.pl +++ b/unittest/unit.pl @@ -103,6 +103,7 @@ sub run_cmd (@) { # Removing the first './' from the file names foreach (@files) { s!^\./!! } $ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"'; + $ENV{'HARNESS_OPTIONS'}="j4"; $Test::Harness::Timer = 1; runtests @files; } From bd94d5b8284c4ecfe29d0caeb20c391cb2091f98 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 13 May 2011 17:55:36 +0200 Subject: [PATCH 10/15] LPBUG#782269 : Fixed double initialization of condition variables in PBXT. --- storage/pbxt/src/xaction_xt.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/pbxt/src/xaction_xt.cc b/storage/pbxt/src/xaction_xt.cc index 48abc5d2b66..0d94449c3da 100644 --- a/storage/pbxt/src/xaction_xt.cc +++ b/storage/pbxt/src/xaction_xt.cc @@ -1123,7 +1123,6 @@ xtPublic void xt_xn_init_db(XTThreadPtr self, XTDatabaseHPtr db) */ for (u_int i=0; idb_xn_idx[i]; - XT_XACT_INIT_LOCK(self, &seg->xs_tab_lock); seg->xs_last_xn_id = db->db_xn_curr_id; } From 218c7665be6ca9c310ba1dd847b5ab88f70eeb33 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 14 May 2011 01:05:12 +0200 Subject: [PATCH 11/15] Fix PBXT bugs found while testing with Application Verifier : LPBUG#782269 : critical sections are initialized twice in xt_xn_init_db() LPBUG#782431: active lock in memory released by xt_ind_exit() LPBUG#782433 : xt_heap_release() does not release spinlock hp->h_lock initialized in xt_heap_new(). LPBUG#782435: xt_exit_row_locks() tries to release unallocated locks --- storage/pbxt/src/cache_xt.cc | 5 +++++ storage/pbxt/src/heap_xt.cc | 1 + storage/pbxt/src/lock_xt.cc | 5 +++++ storage/pbxt/src/lock_xt.h | 1 + 4 files changed, 12 insertions(+) diff --git a/storage/pbxt/src/cache_xt.cc b/storage/pbxt/src/cache_xt.cc index 24e42d9e984..090250dd802 100644 --- a/storage/pbxt/src/cache_xt.cc +++ b/storage/pbxt/src/cache_xt.cc @@ -717,6 +717,11 @@ xtPublic void xt_ind_exit(XTThreadPtr self) ind_handle_exit(self); if (ind_cac_globals.cg_blocks) { + XTIndBlockPtr block = ind_cac_globals.cg_blocks; + for (u_int i=0; icb_lock); + block++; + } xt_free(self, ind_cac_globals.cg_blocks); ind_cac_globals.cg_blocks = NULL; xt_free_mutex(&ind_cac_globals.cg_lock); diff --git a/storage/pbxt/src/heap_xt.cc b/storage/pbxt/src/heap_xt.cc index a4e3fec1611..11331f6489f 100644 --- a/storage/pbxt/src/heap_xt.cc +++ b/storage/pbxt/src/heap_xt.cc @@ -109,6 +109,7 @@ xtPublic void xt_heap_release(XTThreadPtr self, XTHeapPtr hp) if (hp->h_finalize) (*hp->h_finalize)(self, hp); xt_spinlock_unlock(&hp->h_lock); + xt_spinlock_free(NULL, &hp->h_lock); xt_free(self, hp); return; } diff --git a/storage/pbxt/src/lock_xt.cc b/storage/pbxt/src/lock_xt.cc index 5dbba9db83a..e4a38716845 100644 --- a/storage/pbxt/src/lock_xt.cc +++ b/storage/pbxt/src/lock_xt.cc @@ -726,11 +726,15 @@ xtBool xt_init_row_locks(XTRowLocksPtr rl) rl->rl_groups[i].lg_list_in_use = 0; rl->rl_groups[i].lg_list = NULL; } + rl->valid = 1; return OK; } void xt_exit_row_locks(XTRowLocksPtr rl) { + if (!rl->valid) + return; + for (int i=0; irl_groups[i].lg_lock); rl->rl_groups[i].lg_wait_queue = NULL; @@ -741,6 +745,7 @@ void xt_exit_row_locks(XTRowLocksPtr rl) rl->rl_groups[i].lg_list = NULL; } } + rl->valid = 0; } /* diff --git a/storage/pbxt/src/lock_xt.h b/storage/pbxt/src/lock_xt.h index 4e5af648c37..28737478d48 100644 --- a/storage/pbxt/src/lock_xt.h +++ b/storage/pbxt/src/lock_xt.h @@ -658,6 +658,7 @@ typedef struct XTLockGroup { struct XTLockWait; typedef struct XTRowLocks { + int valid; XTLockGroupRec rl_groups[XT_ROW_LOCK_GROUP_COUNT]; void xt_cancel_temp_lock(XTLockWaitPtr lw); From 8a376ae237f108bdff96d15bfffd5231d1dd78df Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 14 May 2011 18:37:20 +0200 Subject: [PATCH 12/15] LPBUG#782223 : Memory released by Query_cache::resize() or Query_cache::free() contains active rwlocks. The bug was found by application verifier. Fixed by destroying locks prior to free(), --- sql/sql_cache.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 81cc87723c5..f358d5537d2 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2253,6 +2253,18 @@ void Query_cache::free_cache() { DBUG_ENTER("Query_cache::free_cache"); + /* Destroy locks */ + Query_cache_block *block= queries_blocks; + if (block) + { + do + { + Query_cache_query *query= block->query(); + my_rwlock_destroy(&query->lock); + block= block->next; + } while (block != queries_blocks); + } + my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR)); make_disabled(); hash_free(&queries); From 5f267b47de4aee6c078c21368bfbf359fb5e3ab7 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 14 May 2011 18:42:07 +0200 Subject: [PATCH 13/15] Fix bugs found by application verifier : - Fix active lock in freed memory in ha_archive (share mutex was not released prior to free()) - Do not attempt vio_fastsend or vio_keepalive on named pipes and shared memory. --- storage/archive/ha_archive.cc | 1 + vio/viosocket.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index a7fda9a471a..d70de0dd13c 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -357,6 +357,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) { *rc= my_errno ? my_errno : -1; pthread_mutex_unlock(&archive_mutex); + pthread_mutex_destroy(&share->mutex); my_free(share, MYF(0)); DBUG_RETURN(NULL); } diff --git a/vio/viosocket.c b/vio/viosocket.c index f47a7a10ad2..f780764cbe4 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -193,6 +193,11 @@ int vio_fastsend(Vio * vio __attribute__((unused))) int r=0; DBUG_ENTER("vio_fastsend"); + if (vio->type == VIO_TYPE_NAMEDPIPE ||vio->type == VIO_TYPE_SHARED_MEMORY) + { + DBUG_RETURN(0); + } + #if defined(IPTOS_THROUGHPUT) { int tos = IPTOS_THROUGHPUT; @@ -228,7 +233,7 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) DBUG_ENTER("vio_keepalive"); DBUG_PRINT("enter", ("sd: %d set_keep_alive: %d", vio->sd, (int) set_keep_alive)); - if (vio->type != VIO_TYPE_NAMEDPIPE) + if (vio->type != VIO_TYPE_NAMEDPIPE && vio->type != VIO_TYPE_SHARED_MEMORY) { if (set_keep_alive) opt = 1; From b898022a6d5b5c7af31703f721b51b8c65c0f165 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 14 May 2011 18:59:06 +0200 Subject: [PATCH 14/15] Fix compile error on Unixes my_rwlock_destroy=>rwlock_destroy --- sql/sql_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f358d5537d2..8c68f4c44bc 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2260,7 +2260,7 @@ void Query_cache::free_cache() do { Query_cache_query *query= block->query(); - my_rwlock_destroy(&query->lock); + rwlock_destroy(&query->lock); block= block->next; } while (block != queries_blocks); } From 19f0d6b2d9930f83688943b8f98a8b7397584df9 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 15 May 2011 13:38:18 +0200 Subject: [PATCH 15/15] Small CMake fixes : - add version info for the client library, dynamic plugins and some utilities - do not recompile client library sources 3 times (for mysqlclient , mysqlclient_notls and libmysql) One time is sufficient, so get rid of mysqlclient_notls, and link static client library to the shared. - remove incremental linking flag --- CMakeLists.txt | 10 +--------- client/CMakeLists.txt | 18 +++++++++--------- extra/CMakeLists.txt | 16 ++++++++-------- libmysql/CMakeLists.txt | 10 ++++------ storage/mysql_storage_engine.cmake | 1 + tests/CMakeLists.txt | 4 ++-- 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc753f1a85..3c6a65505fe 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,15 +171,7 @@ IF(MSVC) IF(CMAKE_SIZEOF_VOID_P MATCHES 4) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 4) - - # Disable automatic manifest generation. - STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS - ${CMAKE_EXE_LINKER_FLAGS}) - # Explicitly disable it since it is the default for newer versions of VS - STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS}) - IF(NOT tmp_manifest) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") - ENDIF(NOT tmp_manifest) + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL:NO") ENDIF(MSVC) IF(WIN32) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 4105922fa90..ecfd3a0f0ce 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -14,7 +14,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake") -# We use the "mysqlclient_notls" library here just as safety, in case +# We use the "mysqlclient" library here just as safety, in case # any of the clients here would go beyond the client API and access the # Thread Local Storage directly. @@ -29,27 +29,27 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}) MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysql mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysql mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc DESTINATION bin) SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS") TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex wsock32 dbug) MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqldump mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqldump mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqlimport mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqlimport mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient wsock32) ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs) MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqlshow mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqlshow mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/mf_tempdir.c @@ -59,10 +59,10 @@ MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/my_vle.c ../mysys/base64.c DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc DESTINATION bin) -TARGET_LINK_LIBRARIES(mysqladmin mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysqladmin mysqlclient wsock32) MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c DESTINATION bin) SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS") diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt index 15194556a6b..adb357cf790 100755 --- a/extra/CMakeLists.txt +++ b/extra/CMakeLists.txt @@ -32,26 +32,26 @@ ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp --charset=${PROJECT_SOURCE_DIR}/sql/share/charsets --out-dir=${CMAKE_BINARY_DIR}/sql/share/ --header_file=${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp - --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h - --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h + --name_file=${CMAKE_BINARY_DIR}/include/mysqld_ername.h.tmp + --state_file=${CMAKE_BINARY_DIR}/include/sql_state.h.tmp --in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp ${CMAKE_BINARY_DIR}/include/mysqld_error.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/mysqld_ername.h.tmp ${CMAKE_BINARY_DIR}/include/mysqld_ername.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/include/sql_state.h.tmp ${CMAKE_BINARY_DIR}/include/sql_state.h DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg.txt) ADD_CUSTOM_TARGET(GenError ALL DEPENDS ${CMAKE_BINARY_DIR}/include/mysqld_error.h.tmp) -ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) +MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c) TARGET_LINK_LIBRARIES(my_print_defaults strings mysys debug dbug taocrypt wsock32) -ADD_EXECUTABLE(perror perror.c) +MYSQL_ADD_EXECUTABLE(perror perror.c) TARGET_LINK_LIBRARIES(perror strings mysys debug dbug wsock32) -ADD_EXECUTABLE(resolveip resolveip.c) +MYSQL_ADD_EXECUTABLE(resolveip resolveip.c) TARGET_LINK_LIBRARIES(resolveip strings mysys debug dbug wsock32) -ADD_EXECUTABLE(replace replace.c) +MYSQL_ADD_EXECUTABLE(replace replace.c COMPONENT Server) TARGET_LINK_LIBRARIES(replace strings mysys debug dbug wsock32) - -MYSQL_INSTALL_TARGETS(comp_err my_print_defaults perror resolveip replace DESTINATION bin COMPONENT Server) diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index c748f9b073f..4ac0b9a01ee 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -110,18 +110,16 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) ADD_DEPENDENCIES(mysqlclient GenError) -TARGET_LINK_LIBRARIES(mysqlclient) -ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) -ADD_DEPENDENCIES(mysqlclient_notls GenError) -TARGET_LINK_LIBRARIES(mysqlclient_notls) +SET(SHARED_SOURCES dll.c libmysql.def) +ADD_VERSION_INFO(libmysql SHARED SHARED_SOURCES) +ADD_LIBRARY(libmysql SHARED ${SHARED_SOURCES}) -ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) IF(WIN32) SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") ENDIF(WIN32) ADD_DEPENDENCIES(libmysql GenError) -TARGET_LINK_LIBRARIES(libmysql wsock32) +TARGET_LINK_LIBRARIES(libmysql mysqlclient ws2_32) ADD_DEFINITIONS(-DHAVE_DLOPEN) MYSQL_INSTALL_TARGETS(mysqlclient DESTINATION lib COMPONENT Development) diff --git a/storage/mysql_storage_engine.cmake b/storage/mysql_storage_engine.cmake index e500526350b..07b4151c50c 100644 --- a/storage/mysql_storage_engine.cmake +++ b/storage/mysql_storage_engine.cmake @@ -36,6 +36,7 @@ IF(NOT SOURCE_SUBLIBS) #Create a DLL.The name of the dll is ha_.dll #The dll is linked to the mysqld executable SET(dyn_libname ha_${libname}) + ADD_VERSION_INFO(${dyn_libname} SHARED ${engine}_SOURCES) ADD_LIBRARY(${dyn_libname} MODULE ${${engine}_SOURCES}) TARGET_LINK_LIBRARIES (${dyn_libname} mysqlservices mysqld) IF(${engine}_LIBS) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4095f2ec342..967ebae2e22 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,9 +20,9 @@ ADD_DEFINITIONS("-DMYSQL_CLIENT") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c) -TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient wsock32) ADD_EXECUTABLE(bug25714 bug25714.c) -TARGET_LINK_LIBRARIES(bug25714 mysqlclient_notls wsock32) +TARGET_LINK_LIBRARIES(bug25714 mysqlclient wsock32) INSTALL(TARGETS mysql_client_test DESTINATION bin COMPONENT Test)