diff options
41 files changed, 2294 insertions, 464 deletions
diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed index 60be7fa5dc6..3b45bb4f30c 100644 --- a/BitKeeper/etc/collapsed +++ b/BitKeeper/etc/collapsed @@ -1 +1,5 @@ 452a92d0-31-8wSzSfZi165fcGcXPA +454a7ef8gdvE_ddMlJyghvOAkKPNOQ +454f8960jsVT_kMKJtZ9OCgXoba0xQ +4554a95d7txO1DuO9G3nAizI3SkFAA +4554b3722d71SbPiI2Gx-RhbZjmuIQ diff --git a/Makefile.am b/Makefile.am index 38e6a28b1b5..36175ce55e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,6 +115,12 @@ test-force: ./mysql-test-run --force && \ ./mysql-test-run --ps-protocol --force +test-force-mem: + cd mysql-test; \ + ./mysql-test-run --force --mem && \ + ./mysql-test-run --ps-protocol --force --mem + + # We are testing a new Perl version of the test script test-pl: cd mysql-test; \ diff --git a/client/mysqltest.c b/client/mysqltest.c index 9fe427000d4..c6cbf6aabe0 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -32,7 +32,7 @@ Holyfoot */ -#define MTEST_VERSION "3.0" +#define MTEST_VERSION "3.1" #include <my_global.h> #include <mysql_embed.h> @@ -81,13 +81,13 @@ enum { OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES, - OPT_MARK_PROGRESS + OPT_MARK_PROGRESS, OPT_CHARSETS_DIR }; static int record= 0, opt_sleep= -1; static char *db= 0, *pass= 0; const char *user= 0, *host= 0, *unix_sock= 0, *opt_basedir= "./"; -const char *opt_include= 0; +const char *opt_include= 0, *opt_charsets_dir; static int port= 0; static int opt_max_connect_retries; static my_bool opt_compress= 0, silent= 0, verbose= 0; @@ -146,7 +146,6 @@ static struct st_test_file* file_stack_end; static CHARSET_INFO *charset_info= &my_charset_latin1; /* Default charset */ -static const char *charset_name= "latin1"; /* Default character set name */ static const char *embedded_server_groups[]= { @@ -274,6 +273,7 @@ enum enum_commands { Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, + Q_CHMOD_FILE, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -356,6 +356,7 @@ const char *command_names[]= "die", /* Don't execute any more commands, compare result */ "exit", + "chmod", 0 }; @@ -1813,6 +1814,46 @@ void do_copy_file(struct st_command *command) /* SYNOPSIS + do_chmod_file + command command handle + + DESCRIPTION + chmod <octal> <file> + Change file permission of <file> + +*/ + +void do_chmod_file(struct st_command *command) +{ + ulong mode= 0; + static DYNAMIC_STRING ds_mode; + static DYNAMIC_STRING ds_file; + const struct command_arg chmod_file_args[] = { + "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file", + "file", ARG_STRING, TRUE, &ds_file, "Filename of file to modify" + }; + DBUG_ENTER("do_chmod_file"); + + check_command_args(command, command->first_argument, + chmod_file_args, + sizeof(chmod_file_args)/sizeof(struct command_arg), + ' '); + + /* Parse what mode to set */ + if (ds_mode.length != 4 || + str2int(ds_mode.str, 8, 0, INT_MAX, &mode) == NullS) + die("You must write a 4 digit octal number for mode"); + + DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str)); + handle_command_error(command, chmod(ds_file.str, mode)); + dynstr_free(&ds_mode); + dynstr_free(&ds_file); + DBUG_VOID_RETURN; +} + + +/* + SYNOPSIS do_file_exists command called command @@ -2920,10 +2961,12 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, Connect failed Only allow retry if this was an error indicating the server - could not be contacted + could not be contacted. Error code differs depending + on protocol/connection type */ - if (mysql_errno(mysql) == CR_CONNECTION_ERROR && + if ((mysql_errno(mysql) == CR_CONN_HOST_ERROR || + mysql_errno(mysql) == CR_CONNECTION_ERROR) && failed_attempts < opt_max_connect_retries) my_sleep(connection_retry_sleep); else @@ -3151,7 +3194,11 @@ void do_connect(struct st_command *command) if (opt_compress || con_compress) mysql_options(&next_con->mysql, MYSQL_OPT_COMPRESS, NullS); mysql_options(&next_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); - mysql_options(&next_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name); + mysql_options(&next_con->mysql, MYSQL_SET_CHARSET_NAME, + charset_info->csname); + if (opt_charsets_dir) + mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_DIR, + opt_charsets_dir); #ifdef HAVE_OPENSSL if (opt_use_ssl || con_ssl) @@ -3837,6 +3884,9 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir, (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"character-sets-dir", OPT_CHARSETS_DIR, + "Directory where character sets are.", (gptr*) &opt_charsets_dir, + (gptr*) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use the compressed server/client protocol.", (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -4190,8 +4240,9 @@ void init_win_path_patterns() /* List of string patterns to match in order to find paths */ const char* paths[] = { "$MYSQL_TEST_DIR", "$MYSQL_TMP_DIR", - "./test/", 0 }; - int num_paths= 3; + "$MYSQLTEST_VARDIR", + "./test/" }; + int num_paths= sizeof(paths)/sizeof(char*); int i; char* p; @@ -4211,6 +4262,13 @@ void init_win_path_patterns() else p= my_strdup(paths[i], MYF(MY_FAE)); + /* Don't insert zero length strings in patterns array */ + if (strlen(p) == 0) + { + my_free(p, MYF(0)); + continue; + } + if (insert_dynamic(&patterns, (gptr) &p)) die(NullS); @@ -4260,7 +4318,7 @@ void fix_win_paths(const char *val, int len) { const char** pattern= dynamic_element(&patterns, i, const char**); DBUG_PRINT("info", ("pattern: %s", *pattern)); - if (strlen(*pattern) == 0) continue; + /* Search for the path in string */ while ((p= strstr(val, *pattern))) { @@ -5582,7 +5640,11 @@ int main(int argc, char **argv) if (opt_compress) mysql_options(&cur_con->mysql,MYSQL_OPT_COMPRESS,NullS); mysql_options(&cur_con->mysql, MYSQL_OPT_LOCAL_INFILE, 0); - mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_NAME, charset_name); + mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_NAME, + charset_info->csname); + if (opt_charsets_dir) + mysql_options(&cur_con->mysql, MYSQL_SET_CHARSET_DIR, + opt_charsets_dir); #ifdef HAVE_OPENSSL @@ -5677,6 +5739,7 @@ int main(int argc, char **argv) case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; + case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; case Q_DELIMITER: do_delimiter(command); @@ -6509,7 +6572,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, { my_regex_t r; my_regmatch_t *subs; - char *buf_end, *replace_end; + char *replace_end; char *buf= *buf_p; int len; int buf_len, need_buf_len; @@ -6529,8 +6592,6 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, SECURE_REG_BUF - buf_end= buf + buf_len; - if (icase) cflags|= REG_ICASE; diff --git a/include/Makefile.am b/include/Makefile.am index a17ef377e78..3a3b319505c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -69,6 +69,7 @@ abi_check: mysql.h mysql_version.h mysql_com.h mysql_time.h my_list.h \ if [ @ICHECK@ != no ] ; then \ @ICHECK@ --canonify --skip-from-re /usr/ -o $@.ic mysql.h; \ @ICHECK@ --compare mysql_h.ic $@.ic; \ + $(RM) -f $@.ic; \ fi; \ touch abi_check; diff --git a/include/abi_check b/include/abi_check new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/include/abi_check diff --git a/include/abi_check.ic b/include/abi_check.ic new file mode 100644 index 00000000000..30ef44a1ccb --- /dev/null +++ b/include/abi_check.ic @@ -0,0 +1,914 @@ +struct rand_struct; +struct st_list; +struct st_mem_root; +struct st_mysql; +struct st_mysql_bind; +struct st_mysql_data; +struct st_mysql_field; +struct st_mysql_manager; +struct st_mysql_methods; +struct st_mysql_options; +struct st_mysql_parameters; +struct st_mysql_res; +struct st_mysql_rows; +struct st_mysql_stmt; +struct st_mysql_time; +struct st_net; +struct st_typelib; +struct st_udf_args; +struct st_udf_init; +struct st_used_mem; +enum Item_result; +enum enum_field_types; +enum enum_mysql_set_option; +enum enum_mysql_stmt_state; +enum enum_mysql_timestamp_type; +enum enum_server_command; +enum enum_stmt_attr_type; +enum mysql_enum_shutdown_level; +enum mysql_option; +enum mysql_protocol_type; +enum mysql_rpl_type; +enum mysql_status; +# 131 "mysql.h" +typedef struct st_mysql_rows MYSQL_ROWS; +# 24 "my_list.h" +typedef struct st_list LIST; +# 232 "mysql.h" +typedef struct st_mysql MYSQL; +# 571 "mysql.h" +typedef struct st_mysql_bind MYSQL_BIND; +# 93 "mysql.h" +typedef struct st_mysql_field MYSQL_FIELD; +# 117 "mysql.h" +typedef unsigned int MYSQL_FIELD_OFFSET; +# 323 "mysql.h" +typedef struct st_mysql_manager MYSQL_MANAGER; +# 337 "mysql.h" +typedef struct st_mysql_parameters MYSQL_PARAMETERS; +# 292 "mysql.h" +typedef struct st_mysql_res MYSQL_RES; +# 116 "mysql.h" +typedef char * * MYSQL_ROW; +# 137 "mysql.h" +typedef MYSQL_ROWS * MYSQL_ROW_OFFSET; +# 596 "mysql.h" +typedef struct st_mysql_stmt MYSQL_STMT; +# 151 "mysql_com.h" +typedef struct st_net NET; +# 21 "typelib.h" +typedef struct st_typelib TYPELIB; +# 141 "mysql_com.h" +typedef struct st_vio Vio; +# 57 "mysql.h" +typedef char * gptr; +# 29 "my_list.h" +typedef int (* list_walk_action)(void *, void *); +# 48 "mysql.h" +typedef char my_bool; +# 63 "mysql.h" +typedef int my_socket; +# 125 "mysql.h" +typedef unsigned long long int my_ulonglong; +# 35 "my_alloc.h" +typedef struct st_mem_root MEM_ROOT; +# 141 "mysql.h" +typedef struct st_mysql_data MYSQL_DATA; +# 648 "mysql.h" +typedef struct st_mysql_methods MYSQL_METHODS; +# 48 "mysql_time.h" +typedef struct st_mysql_time MYSQL_TIME; +# 315 "mysql_com.h" +typedef struct st_udf_args UDF_ARGS; +# 326 "mysql_com.h" +typedef struct st_udf_init UDF_INIT; +# 27 "my_alloc.h" +typedef struct st_used_mem USED_MEM; +# 302 "mysql_com.h" +struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(double)))) rand_struct + { + unsigned long int seed1; + unsigned long int seed2; + unsigned long int max_value; + double max_value_dbl; + }; +# 24 "my_list.h" +struct __attribute__((aligned(__alignof__(void *)))) st_list + { + struct st_list * prev; + struct st_list * next; + void * data; + }; +# 35 "my_alloc.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_mem_root + { + USED_MEM * free; + USED_MEM * used; + USED_MEM * pre_alloc; + unsigned int min_malloc; + unsigned int block_size; + unsigned int block_num; + unsigned int first_block_usage; + void (* error_handler)(void); + }; +# 232 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql + { + NET net; + gptr connector_fd; + char * host; + char * user; + char * passwd; + char * unix_socket; + char * server_version; + char * host_info; + char * info; + char * db; + struct charset_info_st * charset; + MYSQL_FIELD * fields; + MEM_ROOT field_alloc; + my_ulonglong affected_rows; + my_ulonglong insert_id; + my_ulonglong extra_info; + unsigned long int thread_id; + unsigned long int packet_length; + unsigned int port; + unsigned long int client_flag; + unsigned long int server_capabilities; + unsigned int protocol_version; + unsigned int field_count; + unsigned int server_status; + unsigned int server_language; + unsigned int warning_count; + struct st_mysql_options options; + enum mysql_status status; + my_bool free_me; + my_bool reconnect; + char scramble[(20 + 1)]; + my_bool rpl_pivot; + struct st_mysql * master; + struct st_mysql * next_slave; + struct st_mysql * last_used_slave; + struct st_mysql * last_used_con; + LIST * stmts; + struct st_mysql_methods const * methods; + void * thd; + my_bool * unbuffered_fetch_owner; + struct st_mysql_stmt * current_stmt; + }; +# 571 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind + { + unsigned long int * length; + my_bool * is_null; + void * buffer; + enum enum_field_types buffer_type; + unsigned long int buffer_length; + unsigned char * inter_buffer; + unsigned long int offset; + unsigned long int internal_length; + unsigned int param_number; + unsigned int pack_length; + my_bool is_unsigned; + my_bool long_data_used; + my_bool internal_is_null; + void (* store_param_func)(NET * net, struct st_mysql_bind * param); + void (* fetch_result)(struct st_mysql_bind *, unsigned char * * row); + void (* skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char * * row); + }; +# 141 "mysql.h" +struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_data + { + my_ulonglong rows; + unsigned int fields; + MYSQL_ROWS * data; + MEM_ROOT alloc; + MYSQL_ROWS * * prev_ptr; + }; +# 93 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_field + { + char * name; + char * org_name; + char * table; + char * org_table; + char * db; + char * catalog; + char * def; + unsigned long int length; + unsigned long int max_length; + unsigned int name_length; + unsigned int org_name_length; + unsigned int table_length; + unsigned int org_table_length; + unsigned int db_length; + unsigned int catalog_length; + unsigned int def_length; + unsigned int flags; + unsigned int decimals; + unsigned int charsetnr; + enum enum_field_types type; + }; +# 323 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_manager + { + NET net; + char * host; + char * user; + char * passwd; + unsigned int port; + my_bool free_me; + my_bool eof; + int cmd_status; + int last_errno; + char * net_buf; + char * net_buf_pos; + char * net_data_end; + int net_buf_size; + char last_error[256]; + }; +# 648 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)))) st_mysql_methods + { + my_bool (* read_query_result)(MYSQL * mysql); + my_bool (* advanced_command)(MYSQL * mysql, enum enum_server_command, char const * header, unsigned long int, char const * arg, unsigned long int, my_bool, MYSQL_STMT * stmt); + MYSQL_DATA * (* read_rows)(MYSQL * mysql, MYSQL_FIELD * mysql_fields, unsigned int); + MYSQL_RES * (* use_result)(MYSQL * mysql); + void (* fetch_lengths)(unsigned long int * to, MYSQL_ROW, unsigned int); + void (* flush_use_result)(MYSQL * mysql); + MYSQL_FIELD * (* list_fields)(MYSQL * mysql); + my_bool (* read_prepare_result)(MYSQL * mysql, MYSQL_STMT * stmt); + int (* stmt_execute)(MYSQL_STMT * stmt); + int (* read_binary_rows)(MYSQL_STMT * stmt); + int (* unbuffered_fetch)(MYSQL * mysql, char * * row); + void (* free_embedded_thd)(MYSQL * mysql); + char const * (* read_statistics)(MYSQL * mysql); + my_bool (* next_result)(MYSQL * mysql); + int (* read_change_user_result)(MYSQL * mysql, char * buff, char const * passwd); + }; +# 162 "mysql.h" +struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_mysql_options + { + unsigned int connect_timeout; + unsigned int read_timeout; + unsigned int write_timeout; + unsigned int port; + unsigned int protocol; + unsigned long int client_flag; + char * host; + char * user; + char * password; + char * unix_socket; + char * db; + struct st_dynamic_array * init_commands; + char * my_cnf_file; + char * my_cnf_group; + char * charset_dir; + char * charset_name; + char * ssl_key; + char * ssl_cert; + char * ssl_ca; + char * ssl_capath; + char * ssl_cipher; + char * shared_memory_base_name; + unsigned long int max_allowed_packet; + my_bool use_ssl; + my_bool compress; + my_bool named_pipe; + my_bool rpl_probe; + my_bool rpl_parse; + my_bool no_master_reads; + my_bool separate_thread; + enum mysql_option methods_to_use; + char * client_ip; + my_bool secure_auth; + int (* local_infile_init)(void * *, char const *, void *); + int (* local_infile_read)(void *, char *, unsigned int); + void (* local_infile_end)(void); + int (* local_infile_error)(void *, char *, unsigned int); + void * local_infile_userdata; + }; +# 337 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)))) st_mysql_parameters + { + unsigned long int * p_max_allowed_packet; + unsigned long int * p_net_buffer_length; + }; +# 292 "mysql.h" +struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_res + { + my_ulonglong row_count; + MYSQL_FIELD * fields; + MYSQL_DATA * data; + MYSQL_ROWS * data_cursor; + unsigned long int * lengths; + MYSQL * handle; + MEM_ROOT field_alloc; + unsigned int field_count; + unsigned int current_field; + MYSQL_ROW row; + MYSQL_ROW current_row; + my_bool eof; + my_bool unbuffered_fetch_cancelled; + struct st_mysql_methods const * methods; + }; +# 131 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_rows + { + struct st_mysql_rows * next; + MYSQL_ROW data; + unsigned long int length; + }; +# 596 "mysql.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql_stmt + { + MEM_ROOT mem_root; + LIST list; + MYSQL * mysql; + MYSQL_BIND * params; + MYSQL_BIND * bind; + MYSQL_FIELD * fields; + MYSQL_DATA result; + MYSQL_ROWS * data_cursor; + my_ulonglong affected_rows; + my_ulonglong insert_id; + int (* read_row_func)(struct st_mysql_stmt * stmt, unsigned char * * row); + unsigned long int stmt_id; + unsigned int last_errno; + unsigned int param_count; + unsigned int field_count; + enum enum_mysql_stmt_state state; + char last_error[512]; + char sqlstate[(5 + 1)]; + my_bool send_types_to_server; + my_bool bind_param_done; + my_bool bind_result_done; + my_bool unbuffered_fetch_cancelled; + my_bool update_max_length; + }; +# 48 "mysql_time.h" +struct __attribute__((aligned(__alignof__(unsigned long int)))) st_mysql_time + { + unsigned int year; + unsigned int month; + unsigned int day; + unsigned int hour; + unsigned int minute; + unsigned int second; + unsigned long int second_part; + my_bool neg; + enum enum_mysql_timestamp_type time_type; + }; +# 151 "mysql_com.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_net + { + Vio * vio; + unsigned char * buff; + unsigned char * buff_end; + unsigned char * write_pos; + unsigned char * read_pos; + my_socket fd; + unsigned long int max_packet; + unsigned long int max_packet_size; + unsigned int pkt_nr; + unsigned int compress_pkt_nr; + unsigned int write_timeout; + unsigned int read_timeout; + unsigned int retry_count; + int fcntl; + my_bool compress; + unsigned long int remain_in_buf; + unsigned long int length; + unsigned long int buf_length; + unsigned long int where_b; + unsigned int * return_status; + unsigned char reading_or_writing; + char save_char; + my_bool no_send_ok; + char last_error[512]; + char sqlstate[(5 + 1)]; + unsigned int last_errno; + unsigned char error; + gptr query_cache_query; + my_bool report_error; + my_bool return_errno; + }; +# 21 "typelib.h" +struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib + { + unsigned int count; + char const * name; + char const * * type_names; + unsigned int * type_lengths; + }; +# 315 "mysql_com.h" +struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_udf_args + { + unsigned int arg_count; + enum Item_result * arg_type; + char * * args; + unsigned long int * lengths; + char * maybe_null; + }; +# 326 "mysql_com.h" +struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_udf_init + { + my_bool maybe_null; + unsigned int decimals; + unsigned long int max_length; + char * ptr; + my_bool const_item; + }; +# 27 "my_alloc.h" +struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_used_mem + { + struct st_used_mem * next; + unsigned int left; + unsigned int size; + }; +# 313 "mysql_com.h" +enum Item_result + { + STRING_RESULT = 0, + REAL_RESULT = 1, + INT_RESULT = 2, + ROW_RESULT = 3, + }; +# 186 "mysql_com.h" +enum enum_field_types + { + MYSQL_TYPE_DECIMAL = 0, + MYSQL_TYPE_TINY = 1, + MYSQL_TYPE_SHORT = 2, + MYSQL_TYPE_LONG = 3, + MYSQL_TYPE_FLOAT = 4, + MYSQL_TYPE_DOUBLE = 5, + MYSQL_TYPE_NULL = 6, + MYSQL_TYPE_TIMESTAMP = 7, + MYSQL_TYPE_LONGLONG = 8, + MYSQL_TYPE_INT24 = 9, + MYSQL_TYPE_DATE = 10, + MYSQL_TYPE_TIME = 11, + MYSQL_TYPE_DATETIME = 12, + MYSQL_TYPE_YEAR = 13, + MYSQL_TYPE_NEWDATE = 14, + MYSQL_TYPE_ENUM = 247, + MYSQL_TYPE_SET = 248, + MYSQL_TYPE_TINY_BLOB = 249, + MYSQL_TYPE_MEDIUM_BLOB = 250, + MYSQL_TYPE_LONG_BLOB = 251, + MYSQL_TYPE_BLOB = 252, + MYSQL_TYPE_VAR_STRING = 253, + MYSQL_TYPE_STRING = 254, + MYSQL_TYPE_GEOMETRY = 255, + }; +# 269 "mysql_com.h" +enum enum_mysql_set_option + { + MYSQL_OPTION_MULTI_STATEMENTS_ON = 0, + MYSQL_OPTION_MULTI_STATEMENTS_OFF = 1, + }; +# 563 "mysql.h" +enum enum_mysql_stmt_state + { + MYSQL_STMT_INIT_DONE = 1, + MYSQL_STMT_PREPARE_DONE = 2, + MYSQL_STMT_EXECUTE_DONE = 3, + MYSQL_STMT_FETCH_DONE = 4, + }; +# 29 "mysql_time.h" +enum enum_mysql_timestamp_type + { + MYSQL_TIMESTAMP_NONE = -(2), + MYSQL_TIMESTAMP_ERROR = -(1), + MYSQL_TIMESTAMP_DATE = 0, + MYSQL_TIMESTAMP_DATETIME = 1, + MYSQL_TIMESTAMP_TIME = 2, + }; +# 39 "mysql_com.h" +enum enum_server_command + { + COM_SLEEP = 0, + COM_QUIT = 1, + COM_INIT_DB = 2, + COM_QUERY = 3, + COM_FIELD_LIST = 4, + COM_CREATE_DB = 5, + COM_DROP_DB = 6, + COM_REFRESH = 7, + COM_SHUTDOWN = 8, + COM_STATISTICS = 9, + COM_PROCESS_INFO = 10, + COM_CONNECT = 11, + COM_PROCESS_KILL = 12, + COM_DEBUG = 13, + COM_PING = 14, + COM_TIME = 15, + COM_DELAYED_INSERT = 16, + COM_CHANGE_USER = 17, + COM_BINLOG_DUMP = 18, + COM_TABLE_DUMP = 19, + COM_CONNECT_OUT = 20, + COM_REGISTER_SLAVE = 21, + COM_PREPARE = 22, + COM_EXECUTE = 23, + COM_LONG_DATA = 24, + COM_CLOSE_STMT = 25, + COM_RESET_STMT = 26, + COM_SET_OPTION = 27, + COM_END = 28, + }; +# 635 "mysql.h" +enum enum_stmt_attr_type + { + STMT_ATTR_UPDATE_MAX_LENGTH = 0, + }; +# 244 "mysql_com.h" +enum mysql_enum_shutdown_level + { + SHUTDOWN_DEFAULT = 0, + SHUTDOWN_WAIT_CONNECTIONS = (unsigned char)((1 << 0)), + SHUTDOWN_WAIT_TRANSACTIONS = (unsigned char)((1 << 1)), + SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)), + SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1), + SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1), + KILL_CONNECTION = 255, + }; +# 151 "mysql.h" +enum mysql_option + { + MYSQL_OPT_CONNECT_TIMEOUT = 0, + MYSQL_OPT_COMPRESS = 1, + MYSQL_OPT_NAMED_PIPE = 2, + MYSQL_INIT_COMMAND = 3, + MYSQL_READ_DEFAULT_FILE = 4, + MYSQL_READ_DEFAULT_GROUP = 5, + MYSQL_SET_CHARSET_DIR = 6, + MYSQL_SET_CHARSET_NAME = 7, + MYSQL_OPT_LOCAL_INFILE = 8, + MYSQL_OPT_PROTOCOL = 9, + MYSQL_SHARED_MEMORY_BASE_NAME = 10, + MYSQL_OPT_READ_TIMEOUT = 11, + MYSQL_OPT_WRITE_TIMEOUT = 12, + MYSQL_OPT_USE_RESULT = 13, + MYSQL_OPT_USE_REMOTE_CONNECTION = 14, + MYSQL_OPT_USE_EMBEDDED_CONNECTION = 15, + MYSQL_OPT_GUESS_CONNECTION = 16, + MYSQL_SET_CLIENT_IP = 17, + MYSQL_SECURE_AUTH = 18, + }; +# 214 "mysql.h" +enum mysql_protocol_type + { + MYSQL_PROTOCOL_DEFAULT = 0, + MYSQL_PROTOCOL_TCP = 1, + MYSQL_PROTOCOL_SOCKET = 2, + MYSQL_PROTOCOL_PIPE = 3, + MYSQL_PROTOCOL_MEMORY = 4, + }; +# 224 "mysql.h" +enum mysql_rpl_type + { + MYSQL_RPL_MASTER = 0, + MYSQL_RPL_SLAVE = 1, + MYSQL_RPL_ADMIN = 2, + }; +# 209 "mysql.h" +enum mysql_status + { + MYSQL_STATUS_READY = 0, + MYSQL_STATUS_GET_RESULT = 1, + MYSQL_STATUS_USE_RESULT = 2, + }; +# 365 "mysql_com.h" +extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); +# 358 "mysql_com.h" +extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); +# 353 "mysql_com.h" +extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); +# 28 "typelib.h" +extern int find_type(char * x, TYPELIB * typelib, unsigned int); +# 367 "mysql_com.h" +extern void get_salt_from_password(unsigned char * res, char const * password); +# 360 "mysql_com.h" +extern void get_salt_from_password_323(unsigned long int * res, char const * password); +# 372 "mysql_com.h" +extern char * get_tty_password(char * opt_message); +# 30 "typelib.h" +extern char const * get_type(TYPELIB * typelib, unsigned int); +# 355 "mysql_com.h" +extern void hash_password(unsigned long int * to, char const * password, unsigned int); +# 31 "my_list.h" +extern LIST * list_add(LIST * root, LIST * element); +# 33 "my_list.h" +extern LIST * list_cons(void * data, LIST * root); +# 32 "my_list.h" +extern LIST * list_delete(LIST * root, LIST * element); +# 35 "my_list.h" +extern void list_free(LIST * root, unsigned int); +# 36 "my_list.h" +extern unsigned int list_length(LIST *); +# 34 "my_list.h" +extern LIST * list_reverse(LIST * root); +# 37 "my_list.h" +extern int list_walk(LIST *, list_walk_action, gptr); +# 378 "mysql_com.h" +extern int load_defaults(char const * conf_file, char const * * groups, int * argc, char * * * argv); +# 368 "mysql_com.h" +extern void make_password_from_salt(char * to, unsigned char const * hash_stage2); +# 361 "mysql_com.h" +extern void make_password_from_salt_323(char * to, unsigned long int const * salt); +# 363 "mysql_com.h" +extern void make_scrambled_password(char * to, char const * password); +# 356 "mysql_com.h" +extern void make_scrambled_password_323(char * to, char const * password); +# 29 "typelib.h" +extern void make_type(char * to, unsigned int, TYPELIB * typelib); +# 299 "mysql_com.h" +extern int my_connect(my_socket, struct sockaddr const * name, unsigned int, unsigned int); +# 377 "mysql_com.h" +extern my_bool my_init(void); +# 281 "mysql_com.h" +extern my_bool my_net_init(NET * net, Vio * vio); +# 282 "mysql_com.h" +extern void my_net_local_init(NET * net); +# 292 "mysql_com.h" +extern unsigned long int my_net_read(NET * net); +# 287 "mysql_com.h" +extern my_bool my_net_write(NET * net, char const * packet, unsigned long int); +# 352 "mysql_com.h" +extern double my_rnd(struct rand_struct *); +# 381 "mysql_com.h" +extern void my_thread_end(void); +# 380 "mysql_com.h" +extern my_bool my_thread_init(void); +# 539 "mysql.h" +extern void myodbc_remove_escape(MYSQL * mysql, char * name); +# 481 "mysql.h" +extern int mysql_add_slave(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); +# 393 "mysql.h" +extern my_ulonglong mysql_affected_rows(MYSQL * mysql); +# 720 "mysql.h" +extern my_bool mysql_autocommit(MYSQL * mysql, my_bool); +# 408 "mysql.h" +extern my_bool mysql_change_user(MYSQL * mysql, char const * user, char const * passwd, char const * db); +# 401 "mysql.h" +extern char const * mysql_character_set_name(MYSQL * mysql); +# 723 "mysql.h" +extern void mysql_close(MYSQL * sock); +# 718 "mysql.h" +extern my_bool mysql_commit(MYSQL * mysql); +# 510 "mysql.h" +extern void mysql_data_seek(MYSQL_RES * result, my_ulonglong); +# 528 "mysql.h" +extern void mysql_debug(char const * debug); +# 467 "mysql.h" +extern void mysql_disable_reads_from_master(MYSQL * mysql); +# 461 "mysql.h" +extern void mysql_disable_rpl_parse(MYSQL * mysql); +# 489 "mysql.h" +extern int mysql_dump_debug_info(MYSQL * mysql); +# 541 "mysql.h" +extern my_bool mysql_embedded(void); +# 466 "mysql.h" +extern void mysql_enable_reads_from_master(MYSQL * mysql); +# 460 "mysql.h" +extern void mysql_enable_rpl_parse(MYSQL * mysql); +# 385 "mysql.h" +extern my_bool mysql_eof(MYSQL_RES * res); +# 395 "mysql.h" +extern unsigned int mysql_errno(MYSQL * mysql); +# 373 "mysql_com.h" +extern char const * mysql_errno_to_sqlstate(unsigned int); +# 396 "mysql.h" +extern char const * mysql_error(MYSQL * mysql); +# 521 "mysql.h" +extern unsigned long int mysql_escape_string(char * to, char const * from, unsigned long int); +# 518 "mysql.h" +extern MYSQL_FIELD * mysql_fetch_field(MYSQL_RES * result); +# 386 "mysql.h" +extern MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES * res, unsigned int); +# 388 "mysql.h" +extern MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES * res); +# 517 "mysql.h" +extern unsigned long int * mysql_fetch_lengths(MYSQL_RES * result); +# 516 "mysql.h" +extern MYSQL_ROW mysql_fetch_row(MYSQL_RES * result); +# 392 "mysql.h" +extern unsigned int mysql_field_count(MYSQL * mysql); +# 514 "mysql.h" +extern MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES * result, MYSQL_FIELD_OFFSET); +# 390 "mysql.h" +extern MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES * res); +# 509 "mysql.h" +extern void mysql_free_result(MYSQL_RES * result); +# 499 "mysql.h" +extern char const * mysql_get_client_info(void); +# 500 "mysql.h" +extern unsigned long int mysql_get_client_version(void); +# 501 "mysql.h" +extern char const * mysql_get_host_info(MYSQL * mysql); +# 367 "mysql.h" +extern MYSQL_PARAMETERS * mysql_get_parameters(void); +# 503 "mysql.h" +extern unsigned int mysql_get_proto_info(MYSQL * mysql); +# 498 "mysql.h" +extern char const * mysql_get_server_info(MYSQL * mysql); +# 502 "mysql.h" +extern unsigned long int mysql_get_server_version(MYSQL * mysql); +# 523 "mysql.h" +extern unsigned long int mysql_hex_string(char * to, char const * from, unsigned long int); +# 399 "mysql.h" +extern char const * mysql_info(MYSQL * mysql); +# 404 "mysql.h" +extern MYSQL * mysql_init(MYSQL * mysql); +# 394 "mysql.h" +extern my_ulonglong mysql_insert_id(MYSQL * mysql); +# 492 "mysql.h" +extern int mysql_kill(MYSQL * mysql, unsigned long int); +# 504 "mysql.h" +extern MYSQL_RES * mysql_list_dbs(MYSQL * mysql, char const * wild); +# 519 "mysql.h" +extern MYSQL_RES * mysql_list_fields(MYSQL * mysql, char const * table, char const * wild); +# 506 "mysql.h" +extern MYSQL_RES * mysql_list_processes(MYSQL * mysql); +# 505 "mysql.h" +extern MYSQL_RES * mysql_list_tables(MYSQL * mysql, char const * wild); +# 548 "mysql.h" +extern void mysql_manager_close(MYSQL_MANAGER * con); +# 549 "mysql.h" +extern int mysql_manager_command(MYSQL_MANAGER * con, char const * cmd, int); +# 543 "mysql.h" +extern MYSQL_MANAGER * mysql_manager_connect(MYSQL_MANAGER * con, char const * host, char const * user, char const * passwd, unsigned int); +# 551 "mysql.h" +extern int mysql_manager_fetch_line(MYSQL_MANAGER * con, char * res_buf, int); +# 542 "mysql.h" +extern MYSQL_MANAGER * mysql_manager_init(MYSQL_MANAGER * con); +# 427 "mysql.h" +extern my_bool mysql_master_query(MYSQL * mysql, char const * q, unsigned long int); +# 429 "mysql.h" +extern my_bool mysql_master_send_query(MYSQL * mysql, char const * q, unsigned long int); +# 721 "mysql.h" +extern my_bool mysql_more_results(MYSQL * mysql); +# 722 "mysql.h" +extern int mysql_next_result(MYSQL * mysql); +# 384 "mysql.h" +extern unsigned int mysql_num_fields(MYSQL_RES * res); +# 383 "mysql.h" +extern my_ulonglong mysql_num_rows(MYSQL_RES * res); +# 529 "mysql.h" +extern char * mysql_odbc_escape_string(MYSQL * mysql, char * to, unsigned long int, char const * from, unsigned long int, void * param, char * (* extend_buffer)(void *, char * to, unsigned long int * length)); +# 507 "mysql.h" +extern int mysql_options(MYSQL * mysql, enum mysql_option, char const * arg); +# 496 "mysql.h" +extern int mysql_ping(MYSQL * mysql); +# 75 "mysql.h" +extern unsigned int mysql_port; +# 418 "mysql.h" +extern int mysql_query(MYSQL * mysql, char const * q); +# 554 "mysql.h" +extern my_bool mysql_read_query_result(MYSQL * mysql); +# 469 "mysql.h" +extern my_bool mysql_reads_from_master_enabled(MYSQL * mysql); +# 410 "mysql.h" +extern MYSQL * mysql_real_connect(MYSQL * mysql, char const * host, char const * user, char const * passwd, char const * db, unsigned int, char const * unix_socket, unsigned long int); +# 525 "mysql.h" +extern unsigned long int mysql_real_escape_string(MYSQL * mysql, char * to, char const * from, unsigned long int); +# 421 "mysql.h" +extern int mysql_real_query(MYSQL * mysql, char const * q, unsigned long int); +# 490 "mysql.h" +extern int mysql_refresh(MYSQL * mysql, unsigned int); +# 719 "mysql.h" +extern my_bool mysql_rollback(MYSQL * mysql); +# 512 "mysql.h" +extern MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES * result, MYSQL_ROW_OFFSET); +# 389 "mysql.h" +extern MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES * res); +# 463 "mysql.h" +extern int mysql_rpl_parse_enabled(MYSQL * mysql); +# 474 "mysql.h" +extern my_bool mysql_rpl_probe(MYSQL * mysql); +# 471 "mysql.h" +extern enum mysql_rpl_type mysql_rpl_query_type(char const * q, int); +# 417 "mysql.h" +extern int mysql_select_db(MYSQL * mysql, char const * db); +# 419 "mysql.h" +extern int mysql_send_query(MYSQL * mysql, char const * q, unsigned long int); +# 354 "mysql.h" +extern void mysql_server_end(void); +# 353 "mysql.h" +extern int mysql_server_init(int, char * * argv, char * * groups); +# 402 "mysql.h" +extern int mysql_set_character_set(MYSQL * mysql, char const * csname); +# 452 "mysql.h" +extern void mysql_set_local_infile_default(MYSQL * mysql); +# 441 "mysql.h" +extern void mysql_set_local_infile_handler(MYSQL * mysql, int (* local_infile_init)(void * *, char const *, void *), int (* local_infile_read)(void *, char *, unsigned int), void (* local_infile_end)(void), int (* local_infile_error)(void *, char *, unsigned int), void *); +# 477 "mysql.h" +extern int mysql_set_master(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); +# 493 "mysql.h" +extern int mysql_set_server_option(MYSQL * mysql, enum enum_mysql_set_option); +# 486 "mysql.h" +extern int mysql_shutdown(MYSQL * mysql, enum mysql_enum_shutdown_level); +# 432 "mysql.h" +extern my_bool mysql_slave_query(MYSQL * mysql, char const * q, unsigned long int); +# 434 "mysql.h" +extern my_bool mysql_slave_send_query(MYSQL * mysql, char const * q, unsigned long int); +# 397 "mysql.h" +extern char const * mysql_sqlstate(MYSQL * mysql); +# 405 "mysql.h" +extern my_bool mysql_ssl_set(MYSQL * mysql, char const * key, char const * cert, char const * ca, char const * capath, char const * cipher); +# 497 "mysql.h" +extern char const * mysql_stat(MYSQL * mysql); +# 714 "mysql.h" +extern my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT * stmt); +# 692 "mysql.h" +extern my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void * attr); +# 689 "mysql.h" +extern my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void const * attr); +# 695 "mysql.h" +extern my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +# 696 "mysql.h" +extern my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); +# 697 "mysql.h" +extern my_bool mysql_stmt_close(MYSQL_STMT * stmt); +# 712 "mysql.h" +extern void mysql_stmt_data_seek(MYSQL_STMT * stmt, my_ulonglong); +# 706 "mysql.h" +extern unsigned int mysql_stmt_errno(MYSQL_STMT * stmt); +# 707 "mysql.h" +extern char const * mysql_stmt_error(MYSQL_STMT * stmt); +# 682 "mysql.h" +extern int mysql_stmt_execute(MYSQL_STMT * stmt); +# 683 "mysql.h" +extern int mysql_stmt_fetch(MYSQL_STMT * stmt); +# 684 "mysql.h" +extern int mysql_stmt_fetch_column(MYSQL_STMT * stmt, MYSQL_BIND * bind, unsigned int, unsigned long int); +# 716 "mysql.h" +extern unsigned int mysql_stmt_field_count(MYSQL_STMT * stmt); +# 699 "mysql.h" +extern my_bool mysql_stmt_free_result(MYSQL_STMT * stmt); +# 679 "mysql.h" +extern MYSQL_STMT * mysql_stmt_init(MYSQL * mysql); +# 715 "mysql.h" +extern my_ulonglong mysql_stmt_insert_id(MYSQL_STMT * stmt); +# 713 "mysql.h" +extern my_ulonglong mysql_stmt_num_rows(MYSQL_STMT * stmt); +# 688 "mysql.h" +extern unsigned long int mysql_stmt_param_count(MYSQL_STMT * stmt); +# 705 "mysql.h" +extern MYSQL_RES * mysql_stmt_param_metadata(MYSQL_STMT * stmt); +# 680 "mysql.h" +extern int mysql_stmt_prepare(MYSQL_STMT * stmt, char const * query, unsigned long int); +# 698 "mysql.h" +extern my_bool mysql_stmt_reset(MYSQL_STMT * stmt); +# 704 "mysql.h" +extern MYSQL_RES * mysql_stmt_result_metadata(MYSQL_STMT * stmt); +# 709 "mysql.h" +extern MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT * stmt, MYSQL_ROW_OFFSET); +# 711 "mysql.h" +extern MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT * stmt); +# 700 "mysql.h" +extern my_bool mysql_stmt_send_long_data(MYSQL_STMT * stmt, unsigned int, char const * data, unsigned long int); +# 708 "mysql.h" +extern char const * mysql_stmt_sqlstate(MYSQL_STMT * stmt); +# 687 "mysql.h" +extern int mysql_stmt_store_result(MYSQL_STMT * stmt); +# 423 "mysql.h" +extern MYSQL_RES * mysql_store_result(MYSQL * mysql); +# 376 "mysql.h" +extern void mysql_thread_end(void); +# 400 "mysql.h" +extern unsigned long int mysql_thread_id(MYSQL * mysql); +# 375 "mysql.h" +extern my_bool mysql_thread_init(void); +# 540 "mysql.h" +extern unsigned int mysql_thread_safe(void); +# 76 "mysql.h" +extern char * mysql_unix_port; +# 424 "mysql.h" +extern MYSQL_RES * mysql_use_result(MYSQL * mysql); +# 398 "mysql.h" +extern unsigned int mysql_warning_count(MYSQL * mysql); +# 284 "mysql_com.h" +extern void net_clear(NET * net); +# 283 "mysql_com.h" +extern void net_end(NET * net); +# 286 "mysql_com.h" +extern my_bool net_flush(NET * net); +# 291 "mysql_com.h" +extern int net_real_write(NET * net, char const * packet, unsigned long int); +# 285 "mysql_com.h" +extern my_bool net_realloc(NET * net, unsigned long int); +# 751 "mysql.h" +extern unsigned long int net_safe_read(MYSQL * mysql); +# 288 "mysql_com.h" +extern my_bool net_write_command(NET * net, unsigned char, char const * header, unsigned long int, char const * packet, unsigned long int); +# 350 "mysql_com.h" +extern void randominit(struct rand_struct *, unsigned long int, unsigned long int); +# 364 "mysql_com.h" +extern void scramble(char * to, char const * message, char const * password); +# 357 "mysql_com.h" +extern void scramble_323(char * to, char const * message, char const * password); +# 32 "typelib.h" +extern TYPELIB sql_protocol_typelib; diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index c696c940790..b576e4f5a70 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -4252,29 +4252,47 @@ fil_flush_file_spaces( { fil_system_t* system = fil_system; fil_space_t* space; + ulint* space_ids; + ulint n_space_ids; + ulint i; mutex_enter(&(system->mutex)); - space = UT_LIST_GET_FIRST(system->unflushed_spaces); + n_space_ids = UT_LIST_GET_LEN(system->unflushed_spaces); + if (n_space_ids == 0) { - while (space) { - if (space->purpose == purpose && !space->is_being_deleted) { + mutex_exit(&system->mutex); + return; + } - space->n_pending_flushes++; /* prevent dropping of the - space while we are - flushing */ - mutex_exit(&(system->mutex)); + /* Assemble a list of space ids to flush. Previously, we + traversed system->unflushed_spaces and called UT_LIST_GET_NEXT() + on a space that was just removed from the list by fil_flush(). + Thus, the space could be dropped and the memory overwritten. */ + space_ids = mem_alloc(n_space_ids * sizeof *space_ids); - fil_flush(space->id); + n_space_ids = 0; - mutex_enter(&(system->mutex)); + for (space = UT_LIST_GET_FIRST(system->unflushed_spaces); + space; + space = UT_LIST_GET_NEXT(unflushed_spaces, space)) { + + if (space->purpose == purpose && !space->is_being_deleted) { - space->n_pending_flushes--; + space_ids[n_space_ids++] = space->id; } - space = UT_LIST_GET_NEXT(unflushed_spaces, space); } - - mutex_exit(&(system->mutex)); + + mutex_exit(&system->mutex); + + /* Flush the spaces. It will not hurt to call fil_flush() on + a non-existing space id. */ + for (i = 0; i < n_space_ids; i++) { + + fil_flush(space_ids[i]); + } + + mem_free(space_ids); } /********************************************************************** diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 4cac19a24bd..4efe6f42d5e 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -1235,13 +1235,30 @@ int mi_enable_indexes(MI_INFO *info) RETURN 0 indexes are not disabled 1 all indexes are disabled - [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] + 2 non-unique indexes are disabled */ int mi_indexes_are_disabled(MI_INFO *info) { MYISAM_SHARE *share= info->s; - return (! share->state.key_map && share->base.keys); + /* + No keys or all are enabled. keys is the number of keys. Left shifted + gives us only one bit set. When decreased by one, gives us all all bits + up to this one set and it gets unset. + */ + if (!share->base.keys || + (share->state.key_map == (ULL(1) << share->base.keys) - ULL(1))) + return 0; + + /* All are disabled */ + if (!share->state.key_map) + return 1; + + /* + We have keys. Some enabled, some disabled. + Don't check for any non-unique disabled but return directly 2 + */ + return 2; } diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 9fb66fecfa8..f8bf5c490f0 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -32,20 +32,22 @@ endif benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test -EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS) -EXTRA_DIST = $(EXTRA_SCRIPTS) -GENSCRIPTS = mysql-test-run install_test_db mtr +EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \ + $(PRESCRIPTS) +EXTRA_DIST = $(EXTRA_SCRIPTS) +GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) -test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \ - std_data/server-cert.pem std_data/server-key.pem +test_DATA = std_data/client-key.pem \ + std_data/client-cert.pem \ + std_data/cacert.pem \ + std_data/server-cert.pem \ + std_data/server-key.pem CLEANFILES = $(GENSCRIPTS) $(test_DATA) INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I.. -EXTRA_PROGRAMS = mysql_test_run_new -noinst_HEADERS = my_manage.h -mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c my_create_tables.c +noinst_HEADERS = my_manage.h dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ @@ -112,6 +114,11 @@ mtr: $(RM) -f mtr $(LN_S) mysql-test-run.pl mtr +# mysql-test-run - a shortcut for executing mysql-test-run.pl +mysql-test-run: + $(RM) -f mysql-test-run + $(LN_S) mysql-test-run.pl mysql-test-run + SUFFIXES = .sh .sh: diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index d270d72d526..9e943fec9ef 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -593,6 +593,10 @@ sub mtr_options_from_test_file($$) { while ( my $line= <$F> ) { + + # Skip line if it start's with # + next if ( $line =~ /^#/ ); + # Match this line against tag in "tags" array foreach my $tag (@tags) { diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 984d834486c..09749bc74e3 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -13,6 +13,8 @@ sub mtr_tofile ($@); sub mtr_tonewfile($@); sub mtr_lastlinefromfile($); sub mtr_appendfile_to_file ($$); +sub mtr_grab_file($); + ############################################################################## # @@ -128,6 +130,7 @@ sub unspace { return "$quote$string$quote"; } +# Read a whole file, stripping leading and trailing whitespace. sub mtr_fromfile ($) { my $file= shift; @@ -181,5 +184,16 @@ sub mtr_appendfile_to_file ($$) { close TOFILE; } +# Read a whole file verbatim. +sub mtr_grab_file($) { + my $file= shift; + open(FILE, '<', $file) + or return undef; + local $/= undef; + my $data= scalar(<FILE>); + close FILE; + return $data; +} + 1; diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 5ac89aee62c..c016f3dc34f 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -66,6 +66,9 @@ sub mtr_add_arg ($$@) { ############################################################################## +# Note - More specific paths should be given before less specific. For examle +# /client/debug should be listed before /client + sub mtr_path_exists (@) { foreach my $path ( @_ ) { @@ -81,6 +84,9 @@ sub mtr_path_exists (@) { } } +# Note - More specific paths should be given before less specific. For examle +# /client/debug should be listed before /client + sub mtr_script_exists (@) { foreach my $path ( @_ ) { @@ -103,6 +109,9 @@ sub mtr_script_exists (@) { } } +# Note - More specific paths should be given before less specific. For examle +# /client/debug should be listed before /client + sub mtr_file_exists (@) { foreach my $path ( @_ ) { @@ -111,6 +120,9 @@ sub mtr_file_exists (@) { return ""; } +# Note - More specific paths should be given before less specific. For examle +# /client/debug should be listed before /client + sub mtr_exe_maybe_exists (@) { my @path= @_; @@ -129,6 +141,9 @@ sub mtr_exe_maybe_exists (@) { return ""; } +# Note - More specific paths should be given before less specific. For examle +# /client/debug should be listed before /client + sub mtr_exe_exists (@) { my @path= @_; if (my $path= mtr_exe_maybe_exists(@path)) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index eef2f1b9dd5..cf0dc0dc6f8 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -708,7 +708,7 @@ sub mtr_wait_blocking($) { } } -# Start "mysqladmin shutdown" for a specific mysqld +# Start "mysqladmin <command>" for a specific mysqld sub mtr_mysqladmin_start($$$) { my $srv= shift; my $command= shift; @@ -738,9 +738,8 @@ sub mtr_mysqladmin_start($$$) { # Shutdown time must be high as slave may be in reconnect mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo"); mtr_add_arg($args, "$command"); - my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log"; my $pid= mtr_spawn($::exe_mysqladmin, $args, - "", $path_mysqladmin_log, $path_mysqladmin_log, "", + "", "", "", "", { append_log_file => 1 }); mtr_verbose("mtr_mysqladmin_start, pid: $pid"); return $pid; diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 8d7de9d1a4b..a2c16e1941a 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -34,7 +34,12 @@ sub mtr_verbose (@); # We can't use diff -u or diff -a as these are not portable sub mtr_show_failed_diff ($) { - my $tname= shift; + my $result_file_name= shift; + + # The reject and log files have been dumped to + # to filenames based on the result_file's name + my $tname= basename($result_file_name); + $tname=~ s/\..*$//; my $reject_file= "r/$tname.reject"; my $result_file= "r/$tname.result"; @@ -89,10 +94,14 @@ sub mtr_report_test_skipped ($) { { print "[ disabled ] $tinfo->{'comment'}\n"; } - else + elsif ( $tinfo->{'comment'} ) { print "[ skipped ] $tinfo->{'comment'}\n"; } + else + { + print "[ skipped ]\n"; + } } sub mtr_report_tests_not_skipped_though_disabled ($) { diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run-shell.sh index 544721cf40d..544721cf40d 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run-shell.sh diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a734408e049..5002f778da5 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -65,7 +65,9 @@ use IO::Socket; use IO::Socket::INET; use strict; use warnings; -use diagnostics; + +select(STDOUT); +$| = 1; # Automatically flush STDOUT our $glob_win32_perl= ($^O eq "MSWin32"); # ActiveState Win32 Perl our $glob_cygwin_perl= ($^O eq "cygwin"); # Cygwin Perl @@ -94,11 +96,6 @@ $Devel::Trace::TRACE= 1; # ############################################################################## -# We are to use handle_options() in "mysys/my_getopt.c" for the C version -# -# In the C version we want to use structs and, in some cases, arrays of -# structs. We let each struct be a separate hash. - # Misc global variables our $mysql_version_id; our $glob_mysql_test_dir= undef; @@ -106,7 +103,6 @@ our $glob_mysql_bench_dir= undef; our $glob_hostname= undef; our $glob_scriptname= undef; our $glob_timers= undef; -our $glob_use_running_server= 0; our $glob_use_running_ndbcluster= 0; our $glob_use_running_ndbcluster_slave= 0; our $glob_use_embedded_server= 0; @@ -127,6 +123,12 @@ our $opt_vardir; # A path but set directly on cmd line our $path_vardir_trace; # unix formatted opt_vardir for trace files our $opt_tmpdir; # A path but set directly on cmd line +# Visual Studio produces executables in different sub-directories based on the +# configuration used to build them. To make life easier, an environment +# variable or command-line option may be specified to control which set of +# executables will be used by the test suite. +our $opt_vs_config = $ENV{'MTR_VS_CONFIG'}; + our $default_vardir; our $opt_usage; @@ -159,7 +161,7 @@ our $exe_libtool; our $opt_bench= 0; our $opt_small_bench= 0; -our $opt_big_test= 0; # Send --big-test to mysqltest +our $opt_big_test= 0; our @opt_extra_mysqld_opt; @@ -176,13 +178,15 @@ our $opt_debug; our $opt_do_test; our @opt_cases; # The test cases names in argv our $opt_embedded_server; -our $opt_extern; + +our $opt_extern= 0; +our $opt_socket; + our $opt_fast; our $opt_force; our $opt_reorder= 0; our $opt_enable_disabled; -our $opt_mem; -our $opt_report_features; +our $opt_mem= $ENV{'MTR_MEM'}; our $opt_gcov; our $opt_gcov_err; @@ -216,6 +220,7 @@ our $opt_ndbcluster_port_slave; our $opt_ndbconnectstring_slave; our $opt_record; +our $opt_report_features; our $opt_check_testcases; our $opt_skip; @@ -227,17 +232,11 @@ our $opt_skip_im; our $opt_sleep; -our $opt_sleep_time_after_restart= 1; -our $opt_sleep_time_for_delete= 10; our $opt_testcase_timeout; our $opt_suite_timeout; my $default_testcase_timeout= 15; # 15 min max my $default_suite_timeout= 180; # 3 hours max -our $opt_socket; - -our $opt_source_dist; - our $opt_start_and_exit; our $opt_start_dirty; our $opt_start_from; @@ -247,7 +246,6 @@ our $opt_strace_client; our $opt_timer= 1; our $opt_user; -our $opt_user_test; our $opt_valgrind= 0; our $opt_valgrind_mysqld= 0; @@ -269,7 +267,6 @@ our $opt_stress_test_file= ""; our $opt_wait_for_master; our $opt_wait_for_slave; -our $opt_wait_timeout= 10; our $opt_warnings; @@ -299,6 +296,8 @@ our $glob_tot_real_time= 0; our %mysqld_variables; +my $source_dist= 0; + ###################################################################### # @@ -309,11 +308,12 @@ our %mysqld_variables; sub main (); sub initial_setup (); sub command_line_setup (); -sub datadir_setup (); +sub datadir_list_setup (); sub executable_setup (); sub environment_setup (); sub kill_running_servers (); -sub cleanup_stale_files (); +sub remove_stale_vardir (); +sub setup_vardir (); sub check_ssl_support ($); sub check_running_as_root(); sub check_ndbcluster_support ($); @@ -352,7 +352,6 @@ main(); sub main () { - initial_setup(); command_line_setup(); check_ndbcluster_support(\%mysqld_variables); @@ -438,112 +437,6 @@ sub main () { mtr_exit(0); } -############################################################################## -# -# Initial setup independent on command line arguments -# -############################################################################## - -sub initial_setup () { - - select(STDOUT); - $| = 1; # Make unbuffered - - # If so requested, we try to avail ourselves of a unique build thread number. - if ( $ENV{'MTR_BUILD_THREAD'} ) { - if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) { - print "Requesting build thread... "; - $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); - print "got ".$ENV{'MTR_BUILD_THREAD'}."\n"; - } - } - - $glob_scriptname= basename($0); - - # We require that we are in the "mysql-test" directory - # to run mysql-test-run - if (! -f $glob_scriptname) - { - mtr_error("Can't find the location for the mysql-test-run script\n" . - "Go to to the mysql-test directory and execute the script " . - "as follows:\n./$glob_scriptname"); - } - - if ( -d "../sql" ) - { - $opt_source_dist= 1; - } - - $glob_hostname= mtr_short_hostname(); - - # Find the absolute path to the test directory - $glob_mysql_test_dir= cwd(); - if ( $glob_cygwin_perl ) - { - # Windows programs like 'mysqld' needs Windows paths - $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`; - chomp($glob_mysql_test_dir); - } - - # In most cases, the base directory we find everything relative to, - # is the parent directory of the "mysql-test" directory. For source - # distributions, TAR binary distributions and some other packages. - $glob_basedir= dirname($glob_mysql_test_dir); - - # In the RPM case, binaries and libraries are installed in the - # default system locations, instead of having our own private base - # directory. And we install "/usr/share/mysql-test". Moving up one - # more directory relative to "mysql-test" gives us a usable base - # directory for RPM installs. - if ( ! $opt_source_dist and ! -d "$glob_basedir/bin" ) - { - $glob_basedir= dirname($glob_basedir); - } - - # Expect mysql-bench to be located adjacent to the source tree, by default - $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench" - unless defined $glob_mysql_bench_dir; - $glob_mysql_bench_dir= undef - unless -d $glob_mysql_bench_dir; - - $path_my_basedir= - $opt_source_dist ? $glob_mysql_test_dir : $glob_basedir; - - $glob_timers= mtr_init_timers(); - - # - # Find the mysqld executable to be able to find the mysqld version - # number as early as possible - # - - # Look for the path where to find the client binaries - $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", - "$glob_basedir/client_debug", - "$glob_basedir/client/release", - "$glob_basedir/client/debug", - "$glob_basedir/client", - "$glob_basedir/bin"); - - # Look for the mysqld executable - $exe_mysqld= mtr_exe_exists ("$glob_basedir/sql/mysqld", - "$path_client_bindir/mysqld-max-nt", - "$path_client_bindir/mysqld-max", - "$path_client_bindir/mysqld-nt", - "$path_client_bindir/mysqld", - "$path_client_bindir/mysqld-debug", - "$path_client_bindir/mysqld-max", - "$glob_basedir/libexec/mysqld", - "$glob_basedir/bin/mysqld", - "$glob_basedir/sbin/mysqld", - "$glob_basedir/sql/release/mysqld", - "$glob_basedir/sql/debug/mysqld"); - - # Use the mysqld found above to find out what features are available - collect_mysqld_features(); - -} - - ############################################################################## # @@ -580,6 +473,16 @@ sub command_line_setup () { # differs between operating systems and configuration, see # http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html # But a fairly safe range seems to be 5001 - 32767 + + # If so requested, we try to avail ourselves of a unique build thread number. + if ( $ENV{'MTR_BUILD_THREAD'} ) { + if ( lc($ENV{'MTR_BUILD_THREAD'}) eq 'auto' ) { + print "Requesting build thread... "; + $ENV{'MTR_BUILD_THREAD'} = mtr_require_unique_id_and_wait("/tmp/mysql-test-ports", 200, 299); + print "got ".$ENV{'MTR_BUILD_THREAD'}."\n"; + } + } + if ( $ENV{'MTR_BUILD_THREAD'} ) { # Up to two masters, up to three slaves @@ -621,6 +524,7 @@ sub command_line_setup () { 'bench' => \$opt_bench, 'small-bench' => \$opt_small_bench, 'with-ndbcluster' => \$opt_with_ndbcluster, + 'vs-config' => \$opt_vs_config, # Control what test suites or cases to run 'force' => \$opt_force, @@ -715,9 +619,7 @@ sub command_line_setup () { 'start-and-exit' => \$opt_start_and_exit, 'timer!' => \$opt_timer, 'unified-diff|udiff' => \$opt_udiff, - 'user-test=s' => \$opt_user_test, 'user=s' => \$opt_user, - 'wait-timeout=i' => \$opt_wait_timeout, 'testcase-timeout=i' => \$opt_testcase_timeout, 'suite-timeout=i' => \$opt_suite_timeout, 'warnings|log-warnings' => \$opt_warnings, @@ -727,6 +629,85 @@ sub command_line_setup () { usage("") if $opt_usage; + $glob_scriptname= basename($0); + + # We require that we are in the "mysql-test" directory + # to run mysql-test-run + if (! -f $glob_scriptname) + { + mtr_error("Can't find the location for the mysql-test-run script\n" . + "Go to to the mysql-test directory and execute the script " . + "as follows:\n./$glob_scriptname"); + } + + if ( -d "../sql" ) + { + $source_dist= 1; + } + + $glob_hostname= mtr_short_hostname(); + + # Find the absolute path to the test directory + $glob_mysql_test_dir= cwd(); + if ( $glob_cygwin_perl ) + { + # Windows programs like 'mysqld' needs Windows paths + $glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`; + chomp($glob_mysql_test_dir); + } + + # In most cases, the base directory we find everything relative to, + # is the parent directory of the "mysql-test" directory. For source + # distributions, TAR binary distributions and some other packages. + $glob_basedir= dirname($glob_mysql_test_dir); + + # In the RPM case, binaries and libraries are installed in the + # default system locations, instead of having our own private base + # directory. And we install "/usr/share/mysql-test". Moving up one + # more directory relative to "mysql-test" gives us a usable base + # directory for RPM installs. + if ( ! $source_dist and ! -d "$glob_basedir/bin" ) + { + $glob_basedir= dirname($glob_basedir); + } + + # Expect mysql-bench to be located adjacent to the source tree, by default + $glob_mysql_bench_dir= "$glob_basedir/../mysql-bench" + unless defined $glob_mysql_bench_dir; + $glob_mysql_bench_dir= undef + unless -d $glob_mysql_bench_dir; + + $path_my_basedir= + $source_dist ? $glob_mysql_test_dir : $glob_basedir; + + $glob_timers= mtr_init_timers(); + + # + # Find the mysqld executable to be able to find the mysqld version + # number as early as possible + # + + # Look for the client binaries directory + $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", + "$glob_basedir/client_debug", + vs_config_dirs('client', ''), + "$glob_basedir/client", + "$glob_basedir/bin/"); + + $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), + "$glob_basedir/sql/mysqld", + "$path_client_bindir/mysqld-max-nt", + "$path_client_bindir/mysqld-max", + "$path_client_bindir/mysqld-nt", + "$path_client_bindir/mysqld", + "$path_client_bindir/mysqld-debug", + "$path_client_bindir/mysqld-max", + "$glob_basedir/libexec/mysqld", + "$glob_basedir/bin/mysqld"); + + # Use the mysqld found above to find out what features are available + collect_mysqld_features(); + if ( $opt_comment ) { print "\n"; @@ -779,17 +760,18 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # Check if we should speed up tests by trying to run on tmpfs # -------------------------------------------------------------------------- - if ( $opt_mem ) + if ( defined $opt_mem ) { mtr_error("Can't use --mem and --vardir at the same time ") if $opt_vardir; mtr_error("Can't use --mem and --tmpdir at the same time ") if $opt_tmpdir; - # Use /dev/shm as the preferred location for vardir and - # thus implicitly also tmpdir. Add other locations to list - my @tmpfs_locations= ("/dev/shm"); - # One could maybe use "mount" to find tmpfs location(s) + # Search through list of locations that are known + # to be "fast disks" to list to find a suitable location + # Use --mem=<dir> as first location to look. + my @tmpfs_locations= ($opt_mem, "/dev/shm", "/tmp"); + foreach my $fs (@tmpfs_locations) { if ( -d $fs ) @@ -838,13 +820,6 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; } - # Ensure a proper error message - mkpath("$opt_vardir"); - unless ( -d $opt_vardir and -w $opt_vardir ) - { - mtr_error("Writable 'var' directory is needed, use the '--vardir' option"); - } - # -------------------------------------------------------------------------- # Set tmpdir # -------------------------------------------------------------------------- @@ -852,14 +827,6 @@ sub command_line_setup () { $opt_tmpdir =~ s,/+$,,; # Remove ending slash if any # -------------------------------------------------------------------------- - # Set socket - # -------------------------------------------------------------------------- - if (!$opt_socket) - { - $opt_socket= $mysqld_variables{'socket'}; - } - - # -------------------------------------------------------------------------- # Check im suport # -------------------------------------------------------------------------- if ( $mysql_version_id < 50000 ) @@ -956,17 +923,17 @@ sub command_line_setup () { } # -------------------------------------------------------------------------- - # Sleep flag + # Big test flags # -------------------------------------------------------------------------- - if ( $opt_sleep ) - { - $opt_sleep_time_after_restart= $opt_sleep; - } + if ( $opt_big_test ) + { + $ENV{'BIG_TEST'}= 1; + } # -------------------------------------------------------------------------- # Gcov flag # -------------------------------------------------------------------------- - if ( $opt_gcov and ! $opt_source_dist ) + if ( $opt_gcov and ! $source_dist ) { mtr_error("Coverage test needs the source - please use source dist"); } @@ -980,8 +947,6 @@ sub command_line_setup () { { # Indicate that we are using debugger $glob_debugger= 1; - # Increase timeouts - $opt_wait_timeout= 300; if ( $opt_extern ) { mtr_error("Can't use --extern when using debugger"); @@ -1047,16 +1012,9 @@ sub command_line_setup () { $opt_suite_timeout*= 6 if $opt_valgrind; } - # Increase times to wait for executables to start if using valgrind - if ( $opt_valgrind ) - { - $opt_sleep_time_after_restart= 10; - $opt_sleep_time_for_delete= 60; - } - if ( ! $opt_user ) { - if ( $glob_use_running_server ) + if ( $opt_extern ) { $opt_user= "test"; } @@ -1238,9 +1196,17 @@ sub command_line_setup () { if ( $opt_extern ) { - $glob_use_running_server= 1; - $opt_skip_rpl= 1; # We don't run rpl test cases - $master->[0]->{'path_sock'}= $opt_socket; + # Turn off features not supported when running with extern server + $opt_skip_rpl= 1; + + # Setup master->[0] with the settings for the extern server + $master->[0]->{'path_sock'}= $opt_socket if $opt_socket; + mtr_report("Using extern server at '$master->[0]->{path_sock}'"); + } + else + { + mtr_error("--socket can only be used in combination with --extern") + if $opt_socket; } $path_timefile= "$opt_vardir/log/mysqltest-time"; @@ -1251,7 +1217,7 @@ sub command_line_setup () { $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; } -sub datadir_setup () { +sub datadir_list_setup () { # Make a list of all data_dirs @data_dir_lst = ( @@ -1281,26 +1247,15 @@ sub datadir_setup () { sub collect_mysqld_features () { - # - # Execute "mysqld --no-defaults --help --verbose", that will - # print out version and a list of all features and settings - # my $found_variable_list_start= 0; - my $spec_file= "$glob_mysql_test_dir/mysqld.spec.$$"; - if ( mtr_run($exe_mysqld, - ["--no-defaults", - "--verbose", - "--help"], - "", "$spec_file", "$spec_file", "") != 0 ) - { - mtr_error("Failed to get version and list of features from %s", - $exe_mysqld); - } - my $F= IO::File->new($spec_file) or - mtr_error("can't open file \"$spec_file\": $!"); + # + # Execute "mysqld --no-defaults --help --verbose" to get a + # of all features and settings + # + my $list= `$exe_mysqld --no-defaults --verbose --help`; - while ( my $line= <$F> ) + foreach my $line (split('\n', $list)) { # First look for version if ( !$mysql_version_id ) @@ -1353,7 +1308,7 @@ sub collect_mysqld_features () { } } } - unlink($spec_file); + mtr_error("Could not find version of MySQL") unless $mysql_version_id; mtr_error("Could not find variabes list") unless $found_variable_list_start; @@ -1437,16 +1392,14 @@ sub executable_setup () { # Look for my_print_defaults $exe_my_print_defaults= - mtr_exe_exists("$path_client_bindir/my_print_defaults", - "$glob_basedir/extra/my_print_defaults", - "$glob_basedir/extra/release/my_print_defaults", - "$glob_basedir/extra/debug/my_print_defaults"); + mtr_exe_exists(vs_config_dirs('extra', 'my_print_defaults'), + "$path_client_bindir/my_print_defaults", + "$glob_basedir/extra/my_print_defaults"); # Look for perror - $exe_perror= mtr_exe_exists("$glob_basedir/extra/perror", - "$path_client_bindir/perror", - "$glob_basedir/extra/release/perror", - "$glob_basedir/extra/debug/perror"); + $exe_perror= mtr_exe_exists(vs_config_dirs('extra', 'perror'), + "$glob_basedir/extra/perror", + "$path_client_bindir/perror"); # Look for the client binaries $exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck"); @@ -1492,22 +1445,20 @@ sub executable_setup () { # Look for the udf_example library $lib_udf_example= - mtr_file_exists("$glob_basedir/sql/.libs/udf_example.so", - "$glob_basedir/sql/release/udf_example.dll", - "$glob_basedir/sql/debug/udf_example.dll"); + mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), + "$glob_basedir/sql/.libs/udf_example.so",); # Look for mysqltest executable if ( $glob_use_embedded_server ) { $exe_mysqltest= - mtr_exe_exists("$glob_basedir/libmysqld/examples/mysqltest_embedded", - "$path_client_bindir/mysqltest_embedded"); + mtr_exe_exists(vs_config_dirs('libmysqld/examples', 'mysqltest_embedded'), + "$glob_basedir/libmysqld/examples/mysqltest_embedded", + "$path_client_bindir/mysqltest_embedded"); } else { $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); - - } # Look for mysql_client_test executable which may _not_ exist in @@ -1516,15 +1467,15 @@ sub executable_setup () { { $exe_mysql_client_test= mtr_exe_maybe_exists( + vs_config_dirs('libmysqld/examples', 'mysql_client_test_embedded'), "$glob_basedir/libmysqld/examples/mysql_client_test_embedded"); } else { $exe_mysql_client_test= - mtr_exe_maybe_exists("$glob_basedir/tests/mysql_client_test", - "$glob_basedir/tests/release/mysql_client_test", - "$glob_basedir/tests/debug/mysql_client_test", - "$glob_basedir/bin"); + mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'), + "$glob_basedir/tests/mysql_client_test", + "$glob_basedir/bin/mysql_client_test"); } } @@ -1598,7 +1549,7 @@ sub environment_setup () { # Setup LD_LIBRARY_PATH so the libraries from this distro/clone # are used in favor of the system installed ones # -------------------------------------------------------------------------- - if ( $opt_source_dist ) + if ( $source_dist ) { push(@ld_library_paths, "$glob_basedir/libmysql/.libs/", "$glob_basedir/libmysql_r/.libs/"); @@ -1629,9 +1580,17 @@ sub environment_setup () { # impossible to add correct supressions, that means if "/usr/lib/debug" # is available, it should be added to # LD_LIBRARY_PATH + # + # But pthread is broken in libc6-dbg on Debian <= 3.1 (see Debian + # bug 399035, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=399035), + # so don't change LD_LIBRARY_PATH on that platform. # -------------------------------------------------------------------------- my $debug_libraries_path= "/usr/lib/debug"; - if ( $opt_valgrind and -d $debug_libraries_path ) + my $deb_version; + if ( $opt_valgrind and -d $debug_libraries_path and + (! -e '/etc/debian_version' or + ($deb_version= mtr_grab_file('/etc/debian_version')) == 0 or + $deb_version > 3.1 ) ) { push(@ld_library_paths, $debug_libraries_path); } @@ -1655,7 +1614,7 @@ sub environment_setup () { $ENV{'UMASK'}= "0660"; # The octal *string* $ENV{'UMASK_DIR'}= "0770"; # The octal *string* $ENV{'LC_COLLATE'}= "C"; - $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; + $ENV{'USE_RUNNING_SERVER'}= $opt_extern; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; $ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; $ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir; @@ -1858,6 +1817,10 @@ sub environment_setup () { # ---------------------------------------------------- $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; + # ---------------------------------------------------- + # Setup env so childs can execute mysqladmin + # ---------------------------------------------------- + $ENV{'MYSQLADMIN'}= $exe_mysqladmin; # ---------------------------------------------------- # Setup env so childs can execute perror @@ -1952,29 +1915,23 @@ sub kill_running_servers () { # This is different from terminating processes we have # started from this run of the script, this is terminating # leftovers from previous runs. - - if ( ! -d $opt_vardir ) - { - if ( -l $opt_vardir and ! -d readlink($opt_vardir) ) - { - mtr_report("Removing $opt_vardir symlink without destination"); - unlink($opt_vardir); - } - # The "var" dir does not exist already - # the processes that mtr_kill_leftovers start will write - # their log files to var/log so it should be created - mkpath("$opt_vardir/log"); - } mtr_kill_leftovers(); } } -sub cleanup_stale_files () { - - my $created_by_mem_file= "$glob_mysql_test_dir/var/created_by_mem"; +# +# Remove var and any directories in var/ created by previous +# tests +# +sub remove_stale_vardir () { mtr_report("Removing Stale Files"); + # Safety! + mtr_error("No, don't remove the vardir when running with --extern") + if $opt_extern; + + mtr_verbose("opt_vardir: $opt_vardir"); if ( $opt_vardir eq $default_vardir ) { # @@ -1983,29 +1940,47 @@ sub cleanup_stale_files () { if ( -l $opt_vardir) { # var is a symlink - if (-f $created_by_mem_file) + + if ( $opt_mem and readlink($opt_vardir) eq $opt_mem ) { # Remove the directory which the link points at + mtr_verbose("Removing " . readlink($opt_vardir)); rmtree(readlink($opt_vardir)); - # Remove the entire "var" dir - rmtree("$opt_vardir/"); + # Remove the "var" symlink + mtr_verbose("unlink($opt_vardir)"); + unlink($opt_vardir); + } + elsif ( $opt_mem ) + { + # Just remove the "var" symlink + mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong"); + + mtr_verbose("unlink($opt_vardir)"); unlink($opt_vardir); } else { # Some users creates a soft link in mysql-test/var to another area - # - allow it + # - allow it, but remove all files in it + mtr_report("WARNING: Using the 'mysql-test/var' symlink"); - rmtree("$opt_vardir/log"); - rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port"); - rmtree("$opt_vardir/run"); - rmtree("$opt_vardir/tmp"); + + # Make sure the directory where it points exist + mtr_error("The destination for symlink $opt_vardir does not exist") + if ! -d readlink($opt_vardir); + + foreach my $bin ( glob("$opt_vardir/*") ) + { + mtr_verbose("Removing bin $bin"); + rmtree($bin); + } } } else { # Remove the entire "var" dir + mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } } @@ -2017,21 +1992,56 @@ sub cleanup_stale_files () { # Remove the var/ dir in mysql-test dir if any # this could be an old symlink that shouldn't be there + mtr_verbose("Removing $default_vardir"); rmtree($default_vardir); # Remove the "var" dir + mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } +} - if ( $opt_mem ) +# +# Create var and the directories needed in var +# +sub setup_vardir() { + mtr_report("Creating Directories"); + + if ( $opt_vardir eq $default_vardir ) { - # Runinng with var as a link to some "memory" location, normally tmpfs - rmtree($opt_mem); - mkpath($opt_mem); - mtr_report("Creating symlink from $opt_vardir to $opt_mem"); - symlink($opt_mem, $opt_vardir); - # Put a small file to recognize this dir was created by --mem - mtr_tofile($created_by_mem_file, $opt_mem); + # + # Running with "var" in mysql-test dir + # + if ( -l $opt_vardir ) + { + # it's a symlink + + # Make sure the directory where it points exist + mtr_error("The destination for symlink $opt_vardir does not exist") + if ! -d readlink($opt_vardir); + } + elsif ( $opt_mem ) + { + # Runinng with "var" as a link to some "memory" location, normally tmpfs + mtr_verbose("Creating $opt_mem"); + mkpath($opt_mem); + + mtr_report("Symlinking 'var' to '$opt_mem'"); + symlink($opt_mem, $opt_vardir); + } + } + + if ( ! -d $opt_vardir ) + { + mtr_verbose("Creating $opt_vardir"); + mkpath($opt_vardir); + } + + # Ensure a proper error message if vardir couldn't be created + unless ( -d $opt_vardir and -w $opt_vardir ) + { + mtr_error("Writable 'var' directory is needed, use the " . + "'--vardir=<path>' option"); } mkpath("$opt_vardir/log"); @@ -2039,10 +2049,9 @@ sub cleanup_stale_files () { mkpath("$opt_vardir/tmp"); mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp"; - # Remove old and create new data dirs + # Create new data dirs foreach my $data_dir (@data_dir_lst) { - rmtree("$data_dir"); mkpath("$data_dir/mysql"); mkpath("$data_dir/test"); } @@ -2142,6 +2151,31 @@ sub check_debug_support ($) { ############################################################################## # +# Helper function to handle configuration-based subdirectories which Visual +# Studio uses for storing binaries. If opt_vs_config is set, this returns +# a path based on that setting; if not, it returns paths for the default +# /release/ and /debug/ subdirectories. +# +# $exe can be undefined, if the directory itself will be used +# +############################################################################### + +sub vs_config_dirs ($$) { + my ($path_part, $exe) = @_; + + $exe = "" if not defined $exe; + + if ($opt_vs_config) + { + return ("$glob_basedir/$path_part/$opt_vs_config/$exe"); + } + + return ("$glob_basedir/$path_part/release/$exe", + "$glob_basedir/$path_part/debug/$exe"); +} + +############################################################################## +# # Start the ndb cluster # ############################################################################## @@ -2525,7 +2559,7 @@ sub run_suite () { mtr_print_line(); if ( ! $glob_debugger and - ! $glob_use_running_server and + ! $opt_extern and ! $glob_use_embedded_server ) { stop_all_servers(); @@ -2554,23 +2588,41 @@ sub run_suite () { sub initialize_servers () { - datadir_setup(); + datadir_list_setup(); - if ( ! $glob_use_running_server ) + if ( $opt_extern ) + { + # Running against an already started server, if the specified + # vardir does not already exist it should be created + if ( ! -d $opt_vardir ) + { + mtr_report("Creating '$opt_vardir'"); + setup_vardir(); + } + else + { + mtr_report("No need to create '$opt_vardir' it already exists"); + } + } + else { kill_running_servers(); if ( ! $opt_start_dirty ) { - cleanup_stale_files(); + remove_stale_vardir(); + setup_vardir(); + mysql_install_db(); if ( $opt_force ) { + # Save a snapshot of the freshly installed db + # to make it possible to restore to a known point in time save_installed_db(); } } - check_running_as_root(); } + check_running_as_root(); } sub mysql_install_db () { @@ -2937,26 +2989,15 @@ sub do_before_run_mysqltest($) unlink("$result_dir/$tname.log"); unlink("$result_dir/$tname.warnings"); - mtr_tonewfile($path_current_test_log,"$tname\n"); # Always tell where we are - - # output current test to ndbcluster log file to enable diagnostics - mtr_tofile($path_ndb_testrun_log,"CURRENT TEST $tname\n"); - - mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - if ( $master->[1]->{'pid'} ) - { - mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - } - if ( $mysql_version_id < 50000 ) { - # Set envirnoment variable NDB_STATUS_OK to 1 + # Set environment variable NDB_STATUS_OK to 1 # if script decided to run mysqltest cluster _is_ installed ok $ENV{'NDB_STATUS_OK'} = "1"; } elsif ( $mysql_version_id < 50100 ) { - # Set envirnoment variable NDB_STATUS_OK to YES + # Set environment variable NDB_STATUS_OK to YES # if script decided to run mysqltest cluster _is_ installed ok $ENV{'NDB_STATUS_OK'} = "YES"; } @@ -2967,9 +3008,9 @@ sub do_after_run_mysqltest($) my $tinfo= shift; my $tname= $tinfo->{'name'}; - mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n"); - # Save info from this testcase run to mysqltest.log + mtr_appendfile_to_file($path_current_test_log, $path_mysqltest_log) + if -f $path_current_test_log; mtr_appendfile_to_file($path_timefile, $path_mysqltest_log) if -f $path_timefile; @@ -2979,6 +3020,26 @@ sub do_after_run_mysqltest($) } +sub run_testcase_mark_logs($) +{ + my ($log_msg)= @_; + + # Write a marker to all log files + + # The file indicating current test name + mtr_tonewfile($path_current_test_log, $log_msg); + + # each mysqld's .err file + foreach my $mysqld (@{$master}, @{$slave}) + { + mtr_tofile($mysqld->{path_myerr}, $log_msg); + } + + # ndbcluster log file + mtr_tofile($path_ndb_testrun_log, $log_msg); + +} + sub find_testcase_skipped_reason($) { my ($tinfo)= @_; @@ -3015,9 +3076,9 @@ sub analyze_testcase_failure_sync_with_master($) mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--silent"); - mtr_add_arg($args, "-v"); mtr_add_arg($args, "--skip-safemalloc"); mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); + mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); mtr_add_arg($args, "--port=%d", $master->[0]->{'port'}); @@ -3080,7 +3141,7 @@ sub run_testcase ($) { # ------------------------------------------------------- $ENV{'TZ'}= $tinfo->{'timezone'}; - mtr_verbose("Starting server with timezone: $tinfo->{'timezone'}"); + mtr_verbose("Setting timezone: $tinfo->{'timezone'}"); my $master_restart= run_testcase_need_master_restart($tinfo); my $slave_restart= run_testcase_need_slave_restart($tinfo); @@ -3088,7 +3149,7 @@ sub run_testcase ($) { if ($master_restart or $slave_restart) { # Can't restart a running server that may be in use - if ( $glob_use_running_server ) + if ( $opt_extern ) { mtr_report_test_name($tinfo); $tinfo->{comment}= "Can't restart a running server"; @@ -3098,6 +3159,10 @@ sub run_testcase ($) { run_testcase_stop_servers($tinfo, $master_restart, $slave_restart); } + + # Write to all log files to indicate start of testcase + run_testcase_mark_logs("CURRENT_TEST: $tinfo->{name}\n"); + my $died= mtr_record_dead_children(); if ($died or $master_restart or $slave_restart) { @@ -3250,7 +3315,7 @@ sub report_failure_and_restart ($) { my $tinfo= shift; mtr_report_test_failed($tinfo); - mtr_show_failed_diff($tinfo->{'name'}); + mtr_show_failed_diff($tinfo->{'result_file'}); print "\n"; if ( $opt_force ) { @@ -3267,7 +3332,7 @@ sub report_failure_and_restart ($) { print "Aborting: $tinfo->{'name'} failed in $test_mode mode. "; print "To continue, re-run with '--force'.\n"; if ( ! $glob_debugger and - ! $glob_use_running_server and + ! $opt_extern and ! $glob_use_embedded_server ) { stop_all_servers(); @@ -3388,6 +3453,11 @@ sub mysqld_arguments ($$$$$) { if ( $opt_valgrind_mysqld ) { mtr_add_arg($args, "%s--skip-safemalloc", $prefix); + + if ( $mysql_version_id < 50100 ) + { + mtr_add_arg($args, "%s--skip-bdb", $prefix); + } } my $pidfile; @@ -3434,6 +3504,17 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } + + if ( $mysql_version_id <= 50106 ) + { + # Force mysqld to use log files up until 5.1.6 + mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); + } + else + { + # Turn on logging, will be sent to tables + mtr_add_arg($args, "%s--log=", $prefix); + } } if ( $type eq 'slave' ) @@ -3451,8 +3532,6 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--log-slave-updates", $prefix); } - mtr_add_arg($args, "%s--log=%s", $prefix, - $slave->[$idx]->{'path_mylog'}); mtr_add_arg($args, "%s--master-retry-count=10", $prefix); mtr_add_arg($args, "%s--pid-file=%s", $prefix, $slave->[$idx]->{'path_pid'}); @@ -3513,6 +3592,18 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } + + if ( $mysql_version_id <= 50106 ) + { + # Force mysqld to use log files up until 5.1.6 + mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); + } + else + { + # Turn on logging, will be sent to tables + mtr_add_arg($args, "%s--log=", $prefix); + } + } # end slave if ( $opt_debug ) @@ -3589,7 +3680,6 @@ sub mysqld_arguments ($$$$$) { elsif ( $type eq 'master' ) { mtr_add_arg($args, "%s--open-files-limit=1024", $prefix); - mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); } return $args; @@ -3838,10 +3928,17 @@ sub run_testcase_need_master_restart($) } elsif( ! $master->[0]->{'pid'} ) { - $do_restart= 1; - mtr_verbose("Restart master: master is not started"); + if ( $opt_extern ) + { + $do_restart= 0; + mtr_verbose("No restart: using extern master"); + } + else + { + $do_restart= 1; + mtr_verbose("Restart master: master is not started"); + } } - return $do_restart; } @@ -4087,8 +4184,6 @@ sub run_testcase_start_servers($) { return 1; } } - mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - mysqld_start($master->[1],$tinfo->{'master_opt'},[]); } @@ -4116,8 +4211,6 @@ sub run_testcase_start_servers($) { # ---------------------------------------------------------------------- if ( $tinfo->{'slave_num'} ) { - mtr_tofile($slave->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - restore_slave_databases($tinfo->{'slave_num'}); do_before_start_slave($tinfo); @@ -4196,9 +4289,9 @@ sub run_check_testcase ($$) { mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--silent"); - mtr_add_arg($args, "-v"); mtr_add_arg($args, "--skip-safemalloc"); mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); + mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); mtr_add_arg($args, "--socket=%s", $mysqld->{'path_sock'}); mtr_add_arg($args, "--port=%d", $mysqld->{'port'}); @@ -4279,9 +4372,9 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--no-defaults"); mtr_add_arg($args, "--silent"); - mtr_add_arg($args, "-v"); mtr_add_arg($args, "--skip-safemalloc"); mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); + mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); if ($tinfo->{'component_id'} eq 'im') { @@ -4332,11 +4425,6 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir); } - if ( $opt_big_test ) - { - mtr_add_arg($args, "--big-test"); - } - if ( $opt_compress ) { mtr_add_arg($args, "--compress"); @@ -4366,13 +4454,11 @@ sub run_mysqltest ($) { if ( $opt_ssl ) { # Turn on SSL for _all_ test cases if option --ssl was used - mtr_add_arg($args, "--ssl", - $glob_mysql_test_dir); + mtr_add_arg($args, "--ssl"); } elsif ( $opt_ssl_supported ) { - mtr_add_arg($args, "--skip-ssl", - $glob_mysql_test_dir); + mtr_add_arg($args, "--skip-ssl"); } # ---------------------------------------------------------------------- @@ -4698,6 +4784,8 @@ Options to control what engine/variation to run bench Run the benchmark suite small-bench Run the benchmarks with --small-tests --small-tables with-ndbcluster Use cluster as default table type for benchmark + vs-config Visual Studio configuration used to create executables + (default: MTR_VS_CONFIG environment variable) Options to control directories to use benchdir=DIR The directory where the benchmark suite is stored @@ -4707,9 +4795,12 @@ Options to control directories to use vardir=DIR The directory where files generated from the test run is stored (default: ./var). Specifying a ramdisk or tmpfs will speed up tests. - mem=DIR Run testsuite in "memory" using tmpfs if - available(default: /dev/shm) - + mem Run testsuite in "memory" using tmpfs or ramdisk + Attempts to find a suitable location + using a builtin list of standard locations + for tmpfs (/dev/shm) + The option can also be set using environment + variable MTR_MEM=[DIR] Options to control what test suites or cases to run @@ -4724,9 +4815,8 @@ Options to control what test suites or cases to run skip-rpl Skip the replication test cases. skip-im Don't start IM, and skip the IM test cases skip-test=PREFIX Skip test cases which name are prefixed with PREFIX - big-test Pass "--big-test" to mysqltest which will set the - environment variable BIG_TEST, which can be checked - from test cases. + big-test Set the environment variable BIG_TEST, which can be + checked from test cases. Options that specify ports @@ -4746,10 +4836,11 @@ Options that pass on options Options to run test on running server - extern Use running server for tests FIXME DANGEROUS + extern Use running server for tests ndb-connectstring=STR Use running cluster, and connect using STR ndb-connectstring-slave=STR Use running slave cluster, and connect using STR - user=USER User for connect to server + user=USER User for connection to extern server + socket=PATH Socket for connection to extern server Options for debugging the product @@ -4798,23 +4889,15 @@ Misc options unified-diff | udiff When presenting differences, use unified diff testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout) - suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout) + suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout) + warnings | log-warnings Pass --log-warnings to mysqld + sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time Deprecated options with-openssl Deprecated option for ssl -Options not yet described, or that I want to look into more - local - netware - sleep=SECONDS - socket=PATH - user-test=s - wait-timeout=SECONDS - warnings - log-warnings - HERE mtr_exit(1); diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index e9c9c873750..6c670af88a2 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -528,6 +528,127 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys drop table t1; +drop table if exists t1; +create table t1 (a int, key(a)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +"this used not to disable the index" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +alter table t1 add b char(10), disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 add c decimal(10,2), enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +"this however did" +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +desc t1; +Field Type Null Key Default Extra +a bigint(20) YES MUL NULL +b char(10) YES NULL +c decimal(10,2) YES NULL +alter table t1 add d decimal(15,5); +"The key should still be disabled" +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +drop table t1; +"Now will test with one unique index" +create table t1(a int, b char(10), unique(a)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 enable keys; +"If no copy on noop change, this won't touch the data file" +"Unique index, no change" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +"Change the type implying data copy" +"Unique index, no change" +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a bigint; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +drop table t1; +"Now will test with one unique and one non-unique index" +create table t1(a int, b char(10), unique(a), key(b)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +"If no copy on noop change, this won't touch the data file" +"The non-unique index will be disabled" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE +"Change the type implying data copy" +"The non-unique index will be disabled" +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +"Change again the type, but leave the indexes as_is" +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +"Try the same. When data is no copied on similar tables, this is noop" +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +drop table t1; create database mysqltest1; create table t1 (c1 int); alter table t1 rename mysqltest1.t1; @@ -543,3 +664,14 @@ ERROR 3D000: No database selected alter table test.t1 rename test.t1; use test; drop table t1; +DROP TABLE IF EXISTS bug24219; +DROP TABLE IF EXISTS bug24219_2; +CREATE TABLE bug24219 (a INT, INDEX(a)); +SHOW INDEX FROM bug24219; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +bug24219 1 a 1 a A NULL NULL NULL YES BTREE +ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS; +SHOW INDEX FROM bug24219_2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE disabled +DROP TABLE bug24219_2; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 035d98d2b74..d4f9a4f0c56 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -181,12 +181,12 @@ date format datetime 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 10:20:10 -10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 -10:20:10 %T 0000-00-00 10:20:10 -10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 -10:20:10AM %r 0000-00-00 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 +10:20:10 %H:%i:%s 0000-00-00 00:00:00 +10:20:10 %h:%i:%s.%f 0000-00-00 00:00:00 +10:20:10 %T 0000-00-00 00:00:00 +10:20:10AM %h:%i:%s%p 0000-00-00 00:00:00 +10:20:10AM %r 0000-00-00 00:00:00 +10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 00:00:00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 @@ -203,6 +203,13 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 @@ -243,12 +250,12 @@ date format time 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -265,6 +272,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 @@ -274,12 +288,12 @@ date format time2 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -296,6 +310,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 @@ -530,4 +551,13 @@ DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896) NULL Warnings: Warning 1292 Truncated incorrect datetime value: '%Y-%m-%d %H:%i:%s' +select str_to_date('04 /30/2004', '%m /%d/%Y'); +str_to_date('04 /30/2004', '%m /%d/%Y') +2004-04-30 +select str_to_date('04/30 /2004', '%m /%d /%Y'); +str_to_date('04/30 /2004', '%m /%d /%Y') +2004-04-30 +select str_to_date('04/30/2004 ', '%m/%d/%Y '); +str_to_date('04/30/2004 ', '%m/%d/%Y ') +2004-04-30 "End of 4.1 tests" diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 6cdf4063291..7334c9b2da4 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -566,3 +566,62 @@ a b 3 2 2 3 DROP TABLE t1; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (id INT NOT NULL, fruit_id INT NOT NULL, fruit_name varchar(20) +default NULL); +INSERT INTO t1 VALUES (1,1,'ORANGE'); +INSERT INTO t1 VALUES (2,2,'APPLE'); +INSERT INTO t1 VALUES (3,2,'APPLE'); +INSERT INTO t1 VALUES (4,3,'PEAR'); +SELECT DISTINCT fruit_id, fruit_name INTO @v1, @v2 FROM t1 WHERE fruit_name = +'APPLE'; +SELECT @v1, @v2; +@v1 @v2 +2 APPLE +SELECT DISTINCT fruit_id, fruit_name INTO @v3, @v4 FROM t1 GROUP BY fruit_id, +fruit_name HAVING fruit_name = 'APPLE'; +SELECT @v3, @v4; +@v3 @v4 +2 APPLE +SELECT DISTINCT @v5:= fruit_id, @v6:= fruit_name INTO @v7, @v8 FROM t1 WHERE +fruit_name = 'APPLE'; +SELECT @v5, @v6, @v7, @v8; +@v5 @v6 @v7 @v8 +2 APPLE 2 APPLE +SELECT DISTINCT @v5 + fruit_id, CONCAT(@v6, fruit_name) INTO @v9, @v10 FROM t1 +WHERE fruit_name = 'APPLE'; +SELECT @v5, @v6, @v7, @v8, @v9, @v10; +@v5 @v6 @v7 @v8 @v9 @v10 +2 APPLE 2 APPLE 4 APPLEAPPLE +SELECT DISTINCT @v11:= @v5 + fruit_id, @v12:= CONCAT(@v6, fruit_name) INTO +@v13, @v14 FROM t1 WHERE fruit_name = 'APPLE'; +SELECT @v11, @v12, @v13, @v14; +@v11 @v12 @v13 @v14 +4 APPLEAPPLE 4 APPLEAPPLE +SELECT DISTINCT @v13, @v14 INTO @v15, @v16 FROM t1 WHERE fruit_name = 'APPLE'; +SELECT @v15, @v16; +@v15 @v16 +4 APPLEAPPLE +SELECT DISTINCT 2 + 2, 'Bob' INTO @v17, @v18 FROM t1 WHERE fruit_name = +'APPLE'; +SELECT @v17, @v18; +@v17 @v18 +4 Bob +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 (fruit_id INT NOT NULL, fruit_name varchar(20) +default NULL); +SELECT DISTINCT fruit_id, fruit_name INTO OUTFILE +'../tmp/data1.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../tmp/data1.tmp' INTO TABLE t2; +SELECT DISTINCT @v19:= fruit_id, @v20:= fruit_name INTO OUTFILE +'../tmp/data2.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../tmp/data2.tmp' INTO TABLE t2; +SELECT @v19, @v20; +@v19 @v20 +2 APPLE +SELECT * FROM t2; +fruit_id fruit_name +2 APPLE +2 APPLE +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result index 8a28312b348..39ec94bc3aa 100644 --- a/mysql-test/r/func_test.result +++ b/mysql-test/r/func_test.result @@ -183,3 +183,78 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; 5 mod 3 5 mod -3 -5 mod 3 -5 mod -3 2 2 -2 -2 +select (12%0) <=> null as '1'; +1 +1 +select (12%0) is null as '1'; +1 +1 +select 12%0 as 'NULL'; +NULL +NULL +select 12%2 as '0'; +0 +0 +select 12%NULL as 'NULL'; +NULL +NULL +select 12 % null as 'NULL'; +NULL +NULL +select null % 12 as 'NULL'; +NULL +NULL +select null % 0 as 'NULL'; +NULL +NULL +select 0 % null as 'NULL'; +NULL +NULL +select null % null as 'NULL'; +NULL +NULL +select (12 mod 0) <=> null as '1'; +1 +1 +select (12 mod 0) is null as '1'; +1 +1 +select 12 mod 0 as 'NULL'; +NULL +NULL +select 12 mod 2 as '0'; +0 +0 +select 12 mod null as 'NULL'; +NULL +NULL +select null mod 12 as 'NULL'; +NULL +NULL +select null mod 0 as 'NULL'; +NULL +NULL +select 0 mod null as 'NULL'; +NULL +NULL +select null mod null as 'NULL'; +NULL +NULL +select mod(12.0, 0) as 'NULL'; +NULL +NULL +select mod(12, 0.0) as 'NULL'; +NULL +NULL +select mod(12, NULL) as 'NULL'; +NULL +NULL +select mod(12.0, NULL) as 'NULL'; +NULL +NULL +select mod(NULL, 2) as 'NULL'; +NULL +NULL +select mod(NULL, 2.0) as 'NULL'; +NULL +NULL diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 9fbe1814b56..fdfb42c878d 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -851,4 +851,7 @@ union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); H 5 +select last_day('0000-00-00'); +last_day('0000-00-00') +NULL End of 4.1 tests diff --git a/mysql-test/r/mysqladmin.result b/mysql-test/r/mysqladmin.result new file mode 100644 index 00000000000..57927f8aa67 --- /dev/null +++ b/mysql-test/r/mysqladmin.result @@ -0,0 +1,4 @@ +mysqld is alive +mysqladmin: unknown variable 'database=db1' +Warning: mysqladmin: unknown variable 'loose-database=db2' +mysqld is alive diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a63863977b0..3ddb82d4a8d 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -512,6 +512,12 @@ mysqltest: At line 1: End of line junk detected: "write_file filename "; mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' +mysqltest: At line 1: Missing required argument 'mode' to command 'chmod' +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: Missing required argument 'file' to command 'chmod' +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: You must write a 4 digit octal number for mode hello hello hello diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 95050163787..f157bbc602d 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -274,7 +274,7 @@ a double 0 drop table t1,t2,t3; select 1e-308, 1.00000001e-300, 100000000e-300; 1e-308 1.00000001e-300 100000000e-300 -0 1.00000001e-300 1e-292 +1e-308 1.00000001e-300 1e-292 select 10e307; 10e307 1e+308 diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 9bd34c2a610..f4624eda053 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -362,6 +362,103 @@ alter table t1 add unique ( a(1) ); drop table t1; # +# Bug #24395: ALTER TABLE DISABLE KEYS doesn't work when modifying the table +# +# This problem happens if the data change is compatible. +# Changing to the same type is compatible for example. +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, key(a)); +show indexes from t1; +--echo "this used not to disable the index" +alter table t1 modify a int, disable keys; +show indexes from t1; + +alter table t1 enable keys; +show indexes from t1; + +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +alter table t1 enable keys; +show indexes from t1; + +alter table t1 add b char(10), disable keys; +show indexes from t1; + +alter table t1 add c decimal(10,2), enable keys; +show indexes from t1; + +--echo "this however did" +alter table t1 disable keys; +show indexes from t1; + +desc t1; + +alter table t1 add d decimal(15,5); +--echo "The key should still be disabled" +show indexes from t1; + +drop table t1; + +--echo "Now will test with one unique index" +create table t1(a int, b char(10), unique(a)); +show indexes from t1; +alter table t1 disable keys; +show indexes from t1; +alter table t1 enable keys; + +--echo "If no copy on noop change, this won't touch the data file" +--echo "Unique index, no change" +alter table t1 modify a int, disable keys; +show indexes from t1; + +--echo "Change the type implying data copy" +--echo "Unique index, no change" +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +alter table t1 modify a bigint; +show indexes from t1; + +alter table t1 modify a int; +show indexes from t1; + +drop table t1; + +--echo "Now will test with one unique and one non-unique index" +create table t1(a int, b char(10), unique(a), key(b)); +show indexes from t1; +alter table t1 disable keys; +show indexes from t1; +alter table t1 enable keys; + + +--echo "If no copy on noop change, this won't touch the data file" +--echo "The non-unique index will be disabled" +alter table t1 modify a int, disable keys; +show indexes from t1; +alter table t1 enable keys; +show indexes from t1; + +--echo "Change the type implying data copy" +--echo "The non-unique index will be disabled" +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +--echo "Change again the type, but leave the indexes as_is" +alter table t1 modify a int; +show indexes from t1; +--echo "Try the same. When data is no copied on similar tables, this is noop" +alter table t1 modify a int; +show indexes from t1; + +drop table t1; + + +# # Bug#11493 - Alter table rename to default database does not work without # db name qualifying # @@ -392,4 +489,22 @@ alter table test.t1 rename test.t1; use test; drop table t1; +# +# Bug#24219 - ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash +# +--disable_warnings +DROP TABLE IF EXISTS bug24219; +DROP TABLE IF EXISTS bug24219_2; +--enable_warnings + +CREATE TABLE bug24219 (a INT, INDEX(a)); + +SHOW INDEX FROM bug24219; + +ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS; + +SHOW INDEX FROM bug24219_2; + +DROP TABLE bug24219_2; + # End of 4.1 tests diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 922d047eac8..7e74c128dee 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -317,4 +317,12 @@ SELECT TIME_FORMAT("25:00:00", '%l %p'); # SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); +# +# Bug #22029: str_to_date returning NULL +# + +select str_to_date('04 /30/2004', '%m /%d/%Y'); +select str_to_date('04/30 /2004', '%m /%d /%Y'); +select str_to_date('04/30/2004 ', '%m/%d/%Y '); + --echo "End of 4.1 tests" diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 2a87427a2b6..a057eee8e37 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -389,4 +389,69 @@ explain SELECT DISTINCT a, b FROM t1 ORDER BY b; SELECT DISTINCT a, b FROM t1 ORDER BY b; DROP TABLE t1; +# +#Bug #20836: Selecting into variables results in wrong results being returned +# +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (id INT NOT NULL, fruit_id INT NOT NULL, fruit_name varchar(20) +default NULL); + +INSERT INTO t1 VALUES (1,1,'ORANGE'); +INSERT INTO t1 VALUES (2,2,'APPLE'); +INSERT INTO t1 VALUES (3,2,'APPLE'); +INSERT INTO t1 VALUES (4,3,'PEAR'); + +SELECT DISTINCT fruit_id, fruit_name INTO @v1, @v2 FROM t1 WHERE fruit_name = +'APPLE'; +SELECT @v1, @v2; + +SELECT DISTINCT fruit_id, fruit_name INTO @v3, @v4 FROM t1 GROUP BY fruit_id, +fruit_name HAVING fruit_name = 'APPLE'; +SELECT @v3, @v4; + +SELECT DISTINCT @v5:= fruit_id, @v6:= fruit_name INTO @v7, @v8 FROM t1 WHERE +fruit_name = 'APPLE'; +SELECT @v5, @v6, @v7, @v8; + +SELECT DISTINCT @v5 + fruit_id, CONCAT(@v6, fruit_name) INTO @v9, @v10 FROM t1 +WHERE fruit_name = 'APPLE'; +SELECT @v5, @v6, @v7, @v8, @v9, @v10; + +SELECT DISTINCT @v11:= @v5 + fruit_id, @v12:= CONCAT(@v6, fruit_name) INTO +@v13, @v14 FROM t1 WHERE fruit_name = 'APPLE'; +SELECT @v11, @v12, @v13, @v14; + +SELECT DISTINCT @v13, @v14 INTO @v15, @v16 FROM t1 WHERE fruit_name = 'APPLE'; +SELECT @v15, @v16; + +SELECT DISTINCT 2 + 2, 'Bob' INTO @v17, @v18 FROM t1 WHERE fruit_name = +'APPLE'; +SELECT @v17, @v18; + +--disable_warnings +DROP TABLE IF EXISTS t2; +--enable_warnings + +CREATE TABLE t2 (fruit_id INT NOT NULL, fruit_name varchar(20) +default NULL); + +SELECT DISTINCT fruit_id, fruit_name INTO OUTFILE +'../tmp/data1.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../tmp/data1.tmp' INTO TABLE t2; +--exec rm $MYSQL_TEST_DIR/var/tmp/data1.tmp + +SELECT DISTINCT @v19:= fruit_id, @v20:= fruit_name INTO OUTFILE +'../tmp/data2.tmp' FROM t1 WHERE fruit_name = 'APPLE'; +LOAD DATA INFILE '../tmp/data2.tmp' INTO TABLE t2; +--exec rm $MYSQL_TEST_DIR/var/tmp/data2.tmp + +SELECT @v19, @v20; +SELECT * FROM t2; + +DROP TABLE t1; +DROP TABLE t2; + # End of 4.1 tests diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 2ad64b6c5a6..99519b54ca6 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -108,4 +108,36 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; +# +# Bug#23411: The "%" (MOD) operator is not documented; MOD-ing zero returns strange result +# Manual: "Division by zero produces a NULL result" +# +select (12%0) <=> null as '1'; +select (12%0) is null as '1'; +select 12%0 as 'NULL'; +select 12%2 as '0'; +select 12%NULL as 'NULL'; +select 12 % null as 'NULL'; +select null % 12 as 'NULL'; +select null % 0 as 'NULL'; +select 0 % null as 'NULL'; +select null % null as 'NULL'; + +select (12 mod 0) <=> null as '1'; +select (12 mod 0) is null as '1'; +select 12 mod 0 as 'NULL'; +select 12 mod 2 as '0'; +select 12 mod null as 'NULL'; +select null mod 12 as 'NULL'; +select null mod 0 as 'NULL'; +select 0 mod null as 'NULL'; +select null mod null as 'NULL'; + +select mod(12.0, 0) as 'NULL'; +select mod(12, 0.0) as 'NULL'; +select mod(12, NULL) as 'NULL'; +select mod(12.0, NULL) as 'NULL'; +select mod(NULL, 2) as 'NULL'; +select mod(NULL, 2.0) as 'NULL'; + # End of 4.1 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 76465c3542b..fa12c45db04 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -486,4 +486,10 @@ union union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); +# +# Bug #23653: crash if last_day('0000-00-00') +# + +select last_day('0000-00-00'); + --echo End of 4.1 tests diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test new file mode 100644 index 00000000000..7c016fd7416 --- /dev/null +++ b/mysql-test/t/mysqladmin.test @@ -0,0 +1,32 @@ +# +# Test "mysqladmin ping" +# + +--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + + +# +# Bug#10608 mysqladmin breaks on "database" variable in my.cnf +# + +# When mysqladmin finds database in .cnf file it shall fail +--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf +[client] +database=db1 +EOF + +--replace_regex /\/.*mysqladmin/mysqladmin/ +--error 7 +--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + + +# When mysqladmin finds "loose-database" in .cnf file it shall print +# a warning and continue +--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf +[client] +loose-database=db2 +EOF + +--replace_regex /Warning: .*mysqladmin/Warning: mysqladmin/ +--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 3c20b38722f..c06d51d9d49 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1522,6 +1522,46 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- +# test for chmod +# ---------------------------------------------------------------------------- +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp; +# The below write fails, but --error is not implemented +# for write_file +#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +#test should fail +#EOF + +chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp; +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +test2 +EOF + +remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; + +--error 1 +--exec echo "chmod ;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1 + + +# ---------------------------------------------------------------------------- # test for perl # ---------------------------------------------------------------------------- --perl diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index dfc3fb3d39c..3f87186ccc3 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -59,11 +59,15 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; -static void default_reporter(enum loglevel level __attribute__((unused)), +static void default_reporter(enum loglevel level, const char *format, ...) { va_list args; va_start(args, format); + if (level == WARNING_LEVEL) + fprintf(stderr, "%s", "Warning: "); + else if (level == INFORMATION_LEVEL) + fprintf(stderr, "%s", "Info: "); vfprintf(stderr, format, args); va_end(args); } diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 56807a81d7c..361affae247 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -120,9 +120,6 @@ then fi cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host" -if test ! -z "$password" ; then - cmd="$cmd --password=$password" -fi if test ! -z "$port"; then cmd="$cmd --port=$port" fi @@ -178,11 +175,22 @@ then s_echo "" fi +run_cmd() { + # Password argument is added here to allow for spaces in password. + + if test ! -z "$password" + then + cat $sql_file | $cmd --password="$password" + else + cat $sql_file | $cmd + fi +} + if test $verbose = 0 then - cat $sql_file | $cmd > /dev/null 2>&1 + run_cmd > /dev/null 2>&1 else - cat $sql_file | $cmd > /dev/null + run_cmd > /dev/null fi if test $? = 0 then diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 0d8ad167ff5..2d3d71e646c 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -350,7 +350,10 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, l_time->year > 9999 || l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || l_time->minute > 59 || l_time->second > 59 || - (!(flags & TIME_FUZZY_DATE) && (l_time->month == 0 || l_time->day == 0))) + (!(flags & TIME_FUZZY_DATE) && + (l_time->month == 0 || l_time->day == 0)) || + (l_time->year == 0 && l_time->month == 0 && l_time->day == 0 && + (l_time->hour != 0 || l_time->minute != 0 || l_time->second != 0))) { /* Only give warning for a zero date if there is some garbage after */ if (!not_zero_date) /* If zero date */ diff --git a/sql/item_func.cc b/sql/item_func.cc index 1af49179aee..117ae19137b 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -96,7 +96,7 @@ Item_func::Item_func(THD *thd, Item_func *item) /* - Resolve references to table column for a function and it's argument + Resolve references to table column for a function and its argument SYNOPSIS: fix_fields() @@ -707,6 +707,7 @@ longlong Item_func_mod::val_int() void Item_func_mod::fix_length_and_dec() { Item_num_op::fix_length_and_dec(); + maybe_null= 1; } diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index e2d2a074ffc..d6465406c68 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -289,15 +289,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, for (; ptr != end && val != val_end; ptr++) { + /* Skip pre-space between each argument */ + while (val != val_end && my_isspace(cs, *val)) + val++; + if (*ptr == '%' && ptr+1 != end) { int val_len; char *tmp; - /* Skip pre-space between each argument */ - while (val != val_end && my_isspace(cs, *val)) - val++; - val_len= (uint) (val_end - val); switch (*++ptr) { /* Year */ @@ -3053,7 +3053,8 @@ String *Item_func_str_to_date::val_str(String *str) bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date) { - if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE)) + if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) || + (ltime->month == 0)) return 1; uint month_idx= ltime->month-1; ltime->day= days_in_month[month_idx]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3327224be46..cd0ddc00624 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -274,7 +274,7 @@ bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_character_set_client_handshake= 1; bool lower_case_table_names_used= 0; bool server_id_supplied = 0; -bool opt_endinfo,using_udf_functions, locked_in_memory; +bool opt_endinfo, using_udf_functions, locked_in_memory; bool opt_using_transactions, using_update_log; bool volatile abort_loop, select_thread_in_use, signal_thread_in_use; bool volatile ready_to_exit, shutdown_in_progress, grant_option; @@ -2015,13 +2015,24 @@ later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\ mysqld that is not statically linked.\n"); #endif - if (test_flags & TEST_CORE_ON_SIGNAL) - { - fprintf(stderr, "Writing a core file\n"); - fflush(stderr); - write_core(sig); - } - exit(1); + if (locked_in_memory) + { + fprintf(stderr, "\n\ +The \"--memlock\" argument, which was enabled, uses system calls that are\n\ +unreliable and unstable on some operating systems and operating-system\n\ +versions (notably, some versions of Linux). This crash could be due to use\n\ +of those buggy OS calls. You should consider whether you really need the\n\ +\"--memlock\" parameter and/or consult the OS distributer about \"mlockall\"\n\ +bugs.\n"); + } + + if (test_flags & TEST_CORE_ON_SIGNAL) + { + fprintf(stderr, "Writing a core file\n"); + fflush(stderr); + write_core(sig); + } + exit(1); } #ifndef SA_RESETHAND diff --git a/sql/sql_class.cc b/sql/sql_class.cc index fc9597cba87..c8d90848f6e 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1372,37 +1372,20 @@ bool select_exists_subselect::send_data(List<Item> &items) int select_dumpvar::prepare(List<Item> &list, SELECT_LEX_UNIT *u) { - List_iterator_fast<Item> li(list); - List_iterator_fast<LEX_STRING> gl(var_list); - Item *item; - LEX_STRING *ls; + unit= u; + if (var_list.elements != list.elements) { my_error(ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT, MYF(0)); return 1; } - unit=u; - while ((item=li++)) - { - ls= gl++; - Item_func_set_user_var *xx = new Item_func_set_user_var(*ls,item); - /* - Item_func_set_user_var can't substitute something else on its place => - 0 can be passed as last argument (reference on item) - */ - xx->fix_fields(thd,(TABLE_LIST*) thd->lex->select_lex.table_list.first, - 0); - xx->fix_length_and_dec(); - vars.push_back(xx); - } return 0; } void select_dumpvar::cleanup() { - vars.empty(); - row_count=0; + row_count= 0; } @@ -1744,12 +1727,14 @@ Statement_map::~Statement_map() bool select_dumpvar::send_data(List<Item> &items) { - List_iterator_fast<Item_func_set_user_var> li(vars); - Item_func_set_user_var *xx; + List_iterator_fast<LEX_STRING> var_li(var_list); + List_iterator<Item> it(items); + Item *item; + LEX_STRING *ls; DBUG_ENTER("send_data"); if (unit->offset_limit_cnt) - { // Using limit offset,count + { // using limit offset,count unit->offset_limit_cnt--; DBUG_RETURN(0); } @@ -1758,10 +1743,13 @@ bool select_dumpvar::send_data(List<Item> &items) my_error(ER_TOO_MANY_ROWS, MYF(0)); DBUG_RETURN(1); } - while ((xx=li++)) + while ((ls= var_li++) && (item= it++)) { - xx->check(); - xx->update(); + Item_func_set_user_var *suv= new Item_func_set_user_var(*ls, item); + suv->fix_fields(thd, (TABLE_LIST *) thd->lex->select_lex.table_list.first, + 0); + suv->check(); + suv->update(); } DBUG_RETURN(0); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 16abfe2b6b6..05105bfc86a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1579,8 +1579,7 @@ class select_dumpvar :public select_result_interceptor { ha_rows row_count; public: List<LEX_STRING> var_list; - List<Item_func_set_user_var> vars; - select_dumpvar(void) { var_list.empty(); vars.empty(); row_count=0;} + select_dumpvar() { var_list.empty(); row_count= 0;} ~select_dumpvar() {} int prepare(List<Item> &list, SELECT_LEX_UNIT *u); bool send_data(List<Item> &items); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index da66b556b5e..f82dd627101 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -34,11 +34,12 @@ const char *primary_key_name="PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); static int copy_data_between_tables(TABLE *from,TABLE *to, - List<create_field> &create, - enum enum_duplicates handle_duplicates, + List<create_field> &create, + enum enum_duplicates handle_duplicates, bool ignore, - uint order_num, ORDER *order, - ha_rows *copied,ha_rows *deleted); + uint order_num, ORDER *order, + ha_rows *copied, ha_rows *deleted, + enum enum_enable_or_disable keys_onoff); /* @@ -2837,6 +2838,54 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, /* + Manages enabling/disabling of indexes for ALTER TABLE + + SYNOPSIS + alter_table_manage_keys() + table Target table + indexes_were_disabled Whether the indexes of the from table + were disabled + keys_onoff ENABLE | DISABLE | LEAVE_AS_IS + + RETURN VALUES + FALSE OK + TRUE Error +*/ + +static +bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, + enum enum_enable_or_disable keys_onoff) +{ + int error= 0; + DBUG_ENTER("alter_table_manage_keys"); + DBUG_PRINT("enter", ("table=%p were_disabled=%d on_off=%d", + table, indexes_were_disabled, keys_onoff)); + + switch (keys_onoff) { + case ENABLE: + error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + break; + case LEAVE_AS_IS: + if (!indexes_were_disabled) + break; + /* fall-through: disabled indexes */ + case DISABLE: + error= table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + } + + if (error == HA_ERR_WRONG_COMMAND) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->table_name); + error= 0; + } else if (error) + table->file->print_error(error, MYF(0)); + + DBUG_RETURN(error); +} + + +/* Alter table */ @@ -2949,8 +2998,35 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->proc_info="setup"; if (alter_info->is_simple && !table->tmp_table) { - error=0; - if (new_name != table_name || new_db != db) + switch (alter_info->keys_onoff) { + case LEAVE_AS_IS: + error= 0; + break; + case ENABLE: + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + VOID(pthread_mutex_unlock(&LOCK_open)); + error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + case DISABLE: + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + VOID(pthread_mutex_unlock(&LOCK_open)); + error= table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + } + + if (error == HA_ERR_WRONG_COMMAND) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), + table->table_name); + error= 0; + } + + if (!error && (new_name != table_name || new_db != db)) { thd->proc_info="rename"; VOID(pthread_mutex_lock(&LOCK_open)); @@ -2971,27 +3047,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, VOID(pthread_mutex_unlock(&LOCK_open)); } - if (!error) - { - switch (alter_info->keys_onoff) { - case LEAVE_AS_IS: - break; - case ENABLE: - VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); - error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - case DISABLE: - VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); - error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - } - } if (error == HA_ERR_WRONG_COMMAND) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, @@ -2999,6 +3054,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, table->table_name); error=0; } + if (!error) { mysql_update_log.write(thd, thd->query, thd->query_length); @@ -3368,7 +3424,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (!new_table->is_view) error=copy_data_between_tables(table,new_table,create_list, handle_duplicates, ignore, - order_num, order, &copied, &deleted); + order_num, order, &copied, &deleted, + alter_info->keys_onoff); + /* + No need to have call to alter_table_manage_keys() in the else because + in 4.1 we always copy data, except for views. In 5.0 it could happen + that no data is copied and only frm is modified. Then we have to handle + alter_info->keys_onoff outside of copy_data_between_tables + */ thd->last_insert_id=next_insert_id; // Needed for correct log thd->count_cuted_fields= CHECK_FIELD_IGNORE; @@ -3591,7 +3654,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, bool ignore, uint order_num, ORDER *order, ha_rows *copied, - ha_rows *deleted) + ha_rows *deleted, + enum enum_enable_or_disable keys_onoff) { int error; Copy_field *copy,*copy_end; @@ -3623,6 +3687,10 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->external_lock(thd, F_WRLCK)) DBUG_RETURN(-1); + + /* We need external lock before we can disable/enable keys */ + alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff); + from->file->info(HA_STATUS_VARIABLE); to->file->start_bulk_insert(from->file->records); diff --git a/strings/strtod.c b/strings/strtod.c index f298e265d7f..79ba458c009 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -31,7 +31,6 @@ #define MAX_DBL_EXP 308 #define MAX_RESULT_FOR_MAX_EXP 1.7976931348623157 -#define MIN_RESULT_FOR_MIN_EXP 2.225073858507202 static double scaler10[] = { 1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90 }; @@ -161,26 +160,15 @@ double my_strtod(const char *str, char **end_ptr, int *error) order= exp + (neg_exp ? -1 : 1) * (ndigits - 1); if (order < 0) order= -order; - if (order >= MAX_DBL_EXP && result) + if (order >= MAX_DBL_EXP && !neg_exp && result) { double c; /* Compute modulus of C (see comment above) */ c= result / scaler * 10.0; - if (neg_exp) + if (order > MAX_DBL_EXP || c > MAX_RESULT_FOR_MAX_EXP) { - if (order > MAX_DBL_EXP || c < MIN_RESULT_FOR_MIN_EXP) - { - result= 0.0; - goto done; - } - } - else - { - if (order > MAX_DBL_EXP || c > MAX_RESULT_FOR_MAX_EXP) - { - overflow= 1; - goto done; - } + overflow= 1; + goto done; } } |