diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-16 14:05:45 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-16 14:05:45 +0300 |
commit | f458e198c0bea67c6a3787738108bbfb139639bd (patch) | |
tree | e01d8c096a63bacfb5895de6e55d011d666e9d38 | |
parent | 8c5e18c9cfde61197a9f653efa08450ae9a6ce0a (diff) | |
parent | 19f0d6b2d9930f83688943b8f98a8b7397584df9 (diff) | |
download | mariadb-git-f458e198c0bea67c6a3787738108bbfb139639bd.tar.gz |
Merge with 5.2
56 files changed, 592 insertions, 245 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 69f3074464d..886c6c8b65d 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 @@ -60,10 +60,10 @@ MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc ../mysys/base64.c ../mysys/checksum.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 e5cff049cc5..4589d1c86af 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -112,18 +112,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/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/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/mysql-test/r/create.result b/mysql-test/r/create.result index aab2ba0cad7..5d4ffa6b9d3 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/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/mysql-test/t/create.test b/mysql-test/t/create.test index b59fa9edb9f..8f39fb0e0b9 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/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 ae294ea6081..3e3dcc10970 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); @@ -140,7 +141,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; @@ -2164,7 +2165,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 59d6aaf4b7f..d929181088a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -599,6 +599,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 */ @@ -1167,9 +1172,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/mysql_priv.h b/sql/mysql_priv.h index fe0643cdae0..9c4b887091a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1289,6 +1289,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_cache.cc b/sql/sql_cache.cc index 81cc87723c5..8c68f4c44bc 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(); + 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); diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 3da0fafb830..69dc635be16 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_repl.cc b/sql/sql_repl.cc index bce687ebcb9..fc472c17e57 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -706,6 +706,11 @@ impossible position"; DBUG_ASSERT(opt_debug_sync_timeout > 0); DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); + const char act2[]= + "now " + "signal signal.continued"; + DBUG_ASSERT(!debug_sync_set_action(current_thd, + STRING_WITH_LEN(act2))); } }); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0886671d8b5..18e5189f3ca 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3792,9 +3792,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) || diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 222991b1ed2..42f2abeca1e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3659,6 +3659,68 @@ 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]; +#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); + fn_format(tbl50, tbl50, "", reg_ext, MY_UNPACK_FILENAME); + if (!access(tbl50, 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 @@ -3944,11 +4006,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; } /* @@ -5856,10 +5919,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); /* @@ -5880,7 +5943,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; /* reset common markers of how field changed */ field->flags&= ~(FIELD_IS_RENAMED | FIELD_IN_ADD_INDEX); @@ -6607,6 +6670,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]; @@ -6836,10 +6900,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; } } diff --git a/sql/structs.h b/sql/structs.h index 86d1f12424e..29ccde3fb03 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -70,6 +70,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 d43f5c85849..ca4e50d99e1 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/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/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 : "<NULL>"))); } #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 : "<NULL>"), 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 : "<NULL>"), @@ -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 : "<NULL>"))); - 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 : "<NULL>"))); } else diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 62eac2d8873..63e60cc8465 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 29cb56f426b..b687484b0eb 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_dir.h> -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 f92a25617d7..e66d269ab93 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); } @@ -430,13 +446,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; } @@ -464,7 +483,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); @@ -551,7 +570,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) @@ -581,8 +600,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"; @@ -619,7 +639,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"; @@ -682,7 +702,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?>; } #### @@ -734,6 +754,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 <tap.h> #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 <tap.h> #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 <tap.h> #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 <my_getopt.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 @@ -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); - /* We don't need to do physical syncs in this test */ - my_disable_sync= 1; + default_argv= argv; - if (maria_log_remove()) + 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; + { 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 <tap.h> #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 <tap.h> #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 <tap.h> #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 <tap.h> #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 <tap.h> #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/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_<storage_engine>.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/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; i<ind_cac_globals.cg_block_count; i++) { + XT_IPAGE_FREE_LOCK(self, &block->cb_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; i<XT_ROW_LOCK_GROUP_COUNT; i++) { xt_spinlock_free(NULL, &rl->rl_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); diff --git a/storage/pbxt/src/xaction_xt.cc b/storage/pbxt/src/xaction_xt.cc index c5f07eedabf..fd7ae88a4ae 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; i<XT_XN_NO_OF_SEGMENTS; i++) { seg = &db->db_xn_idx[i]; - XT_XACT_INIT_LOCK(self, &seg->xs_tab_lock); seg->xs_last_xn_id = db->db_xn_curr_id; } 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() diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index dc843afeb30..e4c39b0c548 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -189,3 +189,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/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) 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; } 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; diff --git a/win/cmake/create_initial_db.cmake.in b/win/cmake/create_initial_db.cmake.in index aca8a770820..d4721b7bac4 100644 --- a/win/cmake/create_initial_db.cmake.in +++ b/win/cmake/create_initial_db.cmake.in @@ -57,7 +57,7 @@ SET(BOOTSTRAP_COMMAND --language=${CMAKE_CURRENT_BINARY_DIR}/share/english --basedir=. --datadir=. - --tmpdir=${CMAKE_CURRENT_BINARY_DIR} + --tmpdir=. --default-storage-engine=MyISAM --loose-skip-innodb --loose-skip-pbxt |