diff --git a/.bzrignore b/.bzrignore index 608a414ae20..460ea002bff 100644 --- a/.bzrignore +++ b/.bzrignore @@ -396,6 +396,7 @@ libmysqld/gstream.cc libmysqld/ha_archive.cc libmysqld/ha_berkeley.cc libmysqld/ha_example.cc +libmysqld/ha_federated.cc libmysqld/ha_heap.cc libmysqld/ha_innobase.cc libmysqld/ha_innodb.cc @@ -1036,6 +1037,7 @@ test/tools/verify_index test_xml tests/client_test tests/connect_test +tests/mysql_client_test thread_test tmp/* tools/my_vsnprintf.c diff --git a/client/mysql.cc b/client/mysql.cc index e178f79bcf3..046cba536be 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -44,7 +44,7 @@ #include #endif -const char *VER= "14.7"; +const char *VER= "14.8"; /* Don't try to make a nice table if the data is too big */ #define MAX_COLUMN_LENGTH 1024 @@ -144,6 +144,7 @@ static char *current_host,*current_db,*current_user=0,*opt_password=0, *current_prompt=0, *delimiter_str= 0, *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static char *histfile; +static char *histfile_tmp; static String glob_buffer,old_buffer; static String processed_prompt; static char *full_username=0,*part_username=0,*default_prompt=0; @@ -442,6 +443,13 @@ int main(int argc,char *argv[]) if (verbose) tee_fprintf(stdout, "Reading history-file %s\n",histfile); read_history(histfile); + if (!(histfile_tmp= (char*) my_malloc((uint) strlen(histfile) + 5, + MYF(MY_WME)))) + { + fprintf(stderr, "Couldn't allocate memory for temp histfile!\n"); + exit(1); + } + sprintf(histfile_tmp, "%s.TMP", histfile); } } #endif @@ -470,7 +478,8 @@ sig_handler mysql_end(int sig) /* write-history */ if (verbose) tee_fprintf(stdout, "Writing history-file %s\n",histfile); - write_history(histfile); + if (!write_history(histfile_tmp)) + my_rename(histfile_tmp, histfile, MYF(MY_WME)); } batch_readline_end(status.line_buff); completion_hash_free(&ht); @@ -485,6 +494,7 @@ sig_handler mysql_end(int sig) my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_mysql_unix_port,MYF(MY_ALLOW_ZERO_PTR)); my_free(histfile,MYF(MY_ALLOW_ZERO_PTR)); + my_free(histfile_tmp,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_db,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_host,MYF(MY_ALLOW_ZERO_PTR)); my_free(current_user,MYF(MY_ALLOW_ZERO_PTR)); @@ -1430,12 +1440,6 @@ static void build_completion_hash(bool rehash, bool write_info) if (status.batch || quick || !current_db) DBUG_VOID_RETURN; // We don't need completion in batches - if (tables) - { - mysql_free_result(tables); - tables=0; - } - /* hash SQL commands */ while (cmd->name) { add_word(&ht,(char*) cmd->name); @@ -1681,8 +1685,8 @@ static int com_server_help(String *buffer __attribute__((unused)), else if (num_fields >= 2 && num_rows) { init_pager(); - char last_char; - + char last_char= 0; + int num_name= 0, num_cat= 0; LINT_INIT(num_name); LINT_INIT(num_cat); @@ -1693,7 +1697,6 @@ static int com_server_help(String *buffer __attribute__((unused)), put_info("To make a more specific request, please type 'help ',\nwhere is one of the following", INFO_INFO); num_name= 0; num_cat= 1; - last_char= '_'; } else if ((cur= mysql_fetch_row(result))) { @@ -1703,7 +1706,7 @@ static int com_server_help(String *buffer __attribute__((unused)), num_cat= 2; print_help_item(&cur,1,2,&last_char); } - + while ((cur= mysql_fetch_row(result))) print_help_item(&cur,num_name,num_cat,&last_char); tee_fprintf(PAGER, "\n"); diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 7036deab2fe..45daa64705a 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -781,9 +781,11 @@ static int check_master_version(MYSQL* mysql, if (mysql_query(mysql, "SELECT VERSION()") || !(res = mysql_store_result(mysql))) { + char errmsg[FN_REFLEN]; + + strmake(errmsg, mysql_error(mysql), sizeof(errmsg) - 1); mysql_close(mysql); - die("Error checking master version: %s", - mysql_error(mysql)); + die("Error checking master version: %s", errmsg); } if (!(row = mysql_fetch_row(res))) { diff --git a/client/mysqldump.c b/client/mysqldump.c index 9b707af6107..757521fe935 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2436,8 +2436,7 @@ static const char *check_if_ignore_table(const char *table_name) fprintf(stderr, "Error: Couldn't read status information for table %s (%s)\n", table_name, mysql_error(sock)); - if (res) - mysql_free_result(res); + mysql_free_result(res); return 0; /* assume table is ok */ } if (!(row[1])) @@ -2448,7 +2447,7 @@ static const char *check_if_ignore_table(const char *table_name) strcmp(row[1], (result= "MRG_ISAM"))) result= 0; } - mysql_free_result(res); + mysql_free_result(res); return result; } diff --git a/client/mysqltest.c b/client/mysqltest.c index 9e887f61160..4d03746a5e5 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -733,9 +733,10 @@ VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw, die("Empty variable"); } length= (uint) (var_name - save_var_name); + if (length >= MAX_VAR_NAME) + die("Too long variable name: %s", save_var_name); - if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length)) && - length < MAX_VAR_NAME) + if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length))) { char buff[MAX_VAR_NAME+1]; strmake(buff, save_var_name, length); diff --git a/config/ac-macros/ha_ndbcluster.m4 b/config/ac-macros/ha_ndbcluster.m4 index 751a11d1895..dc5e0e73558 100644 --- a/config/ac-macros/ha_ndbcluster.m4 +++ b/config/ac-macros/ha_ndbcluster.m4 @@ -64,8 +64,8 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [ AC_ARG_WITH([ndb-ccflags], [ --with-ndb-ccflags Extra CC options for ndb compile], - [ndb_cxxflags_fix=$withval], - [ndb_cxxflags_fix=]) + [ndb_cxxflags_fix="$ndb_cxxflags_fix $withval"], + [ndb_cxxflags_fix=$ndb_cxxflags_fix]) AC_MSG_CHECKING([for NDB Cluster options]) AC_MSG_RESULT([]) diff --git a/configure.in b/configure.in index e20edf97a72..fbbf3918c45 100644 --- a/configure.in +++ b/configure.in @@ -962,6 +962,7 @@ esac MAX_C_OPTIMIZE="-O3" MAX_CXX_OPTIMIZE="-O3" +ndb_cxxflags_fix= case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in # workaround for Sun Forte/x86 see BUG#4681 *solaris*-i?86-no) @@ -2571,6 +2572,15 @@ EOF AC_CONFIG_SUBDIRS(innobase) fi +case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc-$have_ndbcluster in + *solaris*-i?86-no-yes) + # ndb fail for whatever strange reason to link Sun Forte/x86 + # unless using incremental linker + CXXFLAGS="$CXXFLAGS -xildon" + ;; + *) ;; +esac + if test X"$have_ndbcluster" = Xyes then if test X"$mysql_cv_compress" != Xyes diff --git a/extra/comp_err.c b/extra/comp_err.c index a02eea4e510..baed28a0350 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -35,6 +35,7 @@ #define HEADER_LENGTH 32 /* Length of header in errmsg.sys */ #define DEFAULT_CHARSET_DIR "../sql/share/charsets" #define ER_PREFIX "ER_" +#define WARN_PREFIX "WARN_" static char *OUTFILE= (char*) "errmsg.sys"; static char *HEADERFILE= (char*) "mysqld_error.h"; static char *NAMEFILE= (char*) "mysqld_ername.h"; @@ -453,7 +454,7 @@ static int parse_input_file(const char *file_name, struct errors **top_error, DBUG_RETURN(0); continue; } - if (is_prefix(str, ER_PREFIX)) + if (is_prefix(str, ER_PREFIX) || is_prefix(str, WARN_PREFIX)) { if (!(current_error= parse_error_string(str, rcount))) { diff --git a/include/keycache.h b/include/keycache.h index 26ee0ccadb1..a292a69b0a3 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -88,12 +88,13 @@ typedef struct st_key_cache ulong param_division_limit; /* min. percentage of warm blocks */ ulong param_age_threshold; /* determines when hot block is downgraded */ - /* Statistics variables */ + /* Statistics variables. These are reset in reset_key_cache_counters(). */ ulong global_blocks_changed; /* number of currently dirty blocks */ ulong global_cache_w_requests;/* number of write requests (write hits) */ ulong global_cache_write; /* number of writes from the cache to files */ ulong global_cache_r_requests;/* number of read requests (read hits) */ ulong global_cache_read; /* number of reads from files to the cache */ + int blocks; /* max number of blocks in the cache */ my_bool in_init; /* Set to 1 in MySQL during init/resize */ } KEY_CACHE; @@ -132,5 +133,7 @@ extern my_bool multi_key_cache_set(const byte *key, uint length, KEY_CACHE *key_cache); extern void multi_key_cache_change(KEY_CACHE *old_data, KEY_CACHE *new_data); +extern int reset_key_cache_counters(const char *name, + KEY_CACHE *key_cache); C_MODE_END #endif /* _keycache_h */ diff --git a/include/my_global.h b/include/my_global.h index e8f93ee5d7a..21ba4331cb1 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1084,7 +1084,7 @@ do { doubleget_union _tmp; \ #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) -#define doublestore(T,V) do { *(T)= ((byte *) &V)[4];\ +#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\ *(((char*)T)+1)=(char) ((byte *) &V)[5];\ *(((char*)T)+2)=(char) ((byte *) &V)[6];\ *(((char*)T)+3)=(char) ((byte *) &V)[7];\ diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index 4c2a501a08a..8559df16d08 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -1022,7 +1022,8 @@ calculate_sizes_again: /* Now, try the insert */ - *rec = page_cur_insert_rec_low(page_cursor, entry, index, NULL, mtr); + *rec = page_cur_insert_rec_low(page_cursor, entry, index, + NULL, NULL, mtr); if (!(*rec)) { /* If the record did not fit, reorganize */ btr_page_reorganize(page, index, mtr); diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 3c496bae5b4..b6f79ad10b4 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -81,6 +81,17 @@ dict_create_sys_tables_tuple( dfield_set_data(dfield, ptr, 8); /* 7: MIX_LEN --------------------------*/ + + /* Track corruption reported on mailing list Jan 14, 2005 */ + if (table->mix_len != 0 && table->mix_len != 0x80000000) { + fprintf(stderr, +"InnoDB: Error: mix_len is %lu in table %s\n", (ulong)table->mix_len, + table->name); + mem_analyze_corruption((byte*)&(table->mix_len)); + + ut_error; + } + dfield = dtuple_get_nth_field(entry, 5); ptr = mem_heap_alloc(heap, 4); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 12749f7704f..800d7dcd9e9 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2920,9 +2920,9 @@ loop: constraint_name = NULL; if (ptr1 < ptr2) { - /* The user has specified a constraint name. Pick it so + /* The user may have specified a constraint name. Pick it so that we can store 'databasename/constraintname' as the id of - the id of the constraint to system tables. */ + of the constraint to system tables. */ ptr = ptr1; ptr = dict_accept(ptr, "CONSTRAINT", &success); @@ -2959,6 +2959,10 @@ loop: ptr = dict_accept(ptr, "FOREIGN", &success); + if (!success) { + goto loop; + } + if (!isspace(*ptr)) { goto loop; } diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index 18910acb01d..17b53a7a140 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -728,6 +728,7 @@ dict_load_table( ulint space; ulint n_cols; ulint err; + ulint mix_len; mtr_t mtr; #ifdef UNIV_SYNC_DEBUG @@ -775,6 +776,22 @@ dict_load_table( return(NULL); } + /* Track a corruption bug reported on the MySQL mailing list Jan 14, + 2005: mix_len had a value different from 0 */ + + field = rec_get_nth_field_old(rec, 7, &len); + ut_a(len == 4); + + mix_len = mach_read_from_4(field); + + if (mix_len != 0 && mix_len != 0x80000000) { + ut_print_timestamp(stderr); + + fprintf(stderr, + " InnoDB: table %s has a nonsensical mix len %lu\n", + name, (ulong)mix_len); + } + #if MYSQL_VERSION_ID < 50003 /* Starting from MySQL 5.0.3, the high-order bit of MIX_LEN is the "compact format" flag. */ diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c index f2d0790892e..9b2f7ffe575 100644 --- a/innobase/fil/fil0fil.c +++ b/innobase/fil/fil0fil.c @@ -480,28 +480,33 @@ fil_node_open_file( ut_a(node->n_pending == 0); ut_a(node->open == FALSE); - /* printf("Opening file %s\n", node->name); */ - - if (space->purpose == FIL_LOG) { - node->handle = os_file_create(node->name, OS_FILE_OPEN, - OS_FILE_AIO, OS_LOG_FILE, &ret); - } else if (node->is_raw_disk) { - node->handle = os_file_create(node->name, - OS_FILE_OPEN_RAW, - OS_FILE_AIO, OS_DATA_FILE, &ret); - } else { - node->handle = os_file_create(node->name, OS_FILE_OPEN, - OS_FILE_AIO, OS_DATA_FILE, &ret); - } - - ut_a(ret); - - node->open = TRUE; - - system->n_open++; - if (node->size == 0) { + /* It must be a single-table tablespace and we do not know the + size of the file yet. First we open the file in the normal + mode, no async I/O here, for simplicity. Then do some checks, + and close the file again. + NOTE that we could not use the simple file read function + os_file_read() in Windows to read from a file opened for + async I/O! */ + + node->handle = os_file_create_simple_no_error_handling( + node->name, OS_FILE_OPEN, + OS_FILE_READ_ONLY, &success); + if (!success) { + /* The following call prints an error message */ + os_file_get_last_error(TRUE); + + ut_print_timestamp(stderr); + + fprintf(stderr, +" InnoDB: Fatal error: cannot open %s\n." +"InnoDB: Have you deleted .ibd files under a running mysqld server?\n", + node->name); + ut_a(0); + } + ut_a(space->purpose != FIL_LOG); + ut_a(space->id != 0); os_file_get_size(node->handle, &size_low, &size_high); @@ -511,15 +516,10 @@ fil_node_open_file( node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE); #else - /* It must be a single-table tablespace and we do not know the - size of the file yet */ - - ut_a(space->id != 0); - if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) { fprintf(stderr, "InnoDB: Error: the size of single-table tablespace file %s\n" -"InnoDB: is only %lu %lu, should be at least %lu!", node->name, +"InnoDB: is only %lu %lu, should be at least %lu!\n", node->name, (ulong) size_high, (ulong) size_low, (ulong) (4 * UNIV_PAGE_SIZE)); @@ -539,6 +539,10 @@ fil_node_open_file( ut_free(buf2); + /* Close the file now that we have read the space id from it */ + + os_file_close(node->handle); + if (space_id == ULINT_UNDEFINED || space_id == 0) { fprintf(stderr, "InnoDB: Error: tablespace id %lu in file %s is not sensible\n", @@ -566,6 +570,30 @@ fil_node_open_file( space->size += node->size; } + /* printf("Opening file %s\n", node->name); */ + + /* Open the file for reading and writing, in Windows normally in the + unbuffered async I/O mode, though global variables may make + os_file_create() to fall back to the normal file I/O mode. */ + + if (space->purpose == FIL_LOG) { + node->handle = os_file_create(node->name, OS_FILE_OPEN, + OS_FILE_AIO, OS_LOG_FILE, &ret); + } else if (node->is_raw_disk) { + node->handle = os_file_create(node->name, + OS_FILE_OPEN_RAW, + OS_FILE_AIO, OS_DATA_FILE, &ret); + } else { + node->handle = os_file_create(node->name, OS_FILE_OPEN, + OS_FILE_AIO, OS_DATA_FILE, &ret); + } + + ut_a(ret); + + node->open = TRUE; + + system->n_open++; + if (space->purpose == FIL_TABLESPACE && space->id != 0) { /* Put the node to the LRU list */ UT_LIST_ADD_FIRST(LRU, system->LRU, node); @@ -4129,7 +4157,8 @@ fil_flush_file_spaces( space = UT_LIST_GET_FIRST(system->space_list); while (space) { - if (space->purpose == purpose) { + if (space->purpose == purpose && !space->is_being_deleted) { + space->n_pending_flushes++; /* prevent dropping of the space while we are flushing */ diff --git a/innobase/include/page0cur.h b/innobase/include/page0cur.h index a693931968e..7c6ff081c6d 100644 --- a/innobase/include/page0cur.h +++ b/innobase/include/page0cur.h @@ -144,6 +144,7 @@ page_cur_rec_insert( page_cur_t* cursor, /* in: a page cursor */ rec_t* rec, /* in: record to insert */ dict_index_t* index, /* in: record descriptor */ + ulint* offsets,/* in: rec_get_offsets(rec, index) */ mtr_t* mtr); /* in: mini-transaction handle */ /*************************************************************** Inserts a record next to page cursor. Returns pointer to inserted record if @@ -160,6 +161,7 @@ page_cur_insert_rec_low( dtuple_t* tuple, /* in: pointer to a data tuple or NULL */ dict_index_t* index, /* in: record descriptor */ rec_t* rec, /* in: pointer to a physical record or NULL */ + ulint* offsets,/* in: rec_get_offsets(rec, index) or NULL */ mtr_t* mtr); /* in: mini-transaction handle */ /***************************************************************** Copies records from page to a newly created page, from a given record onward, diff --git a/innobase/include/page0cur.ic b/innobase/include/page0cur.ic index 03010fbd766..e99d799b372 100644 --- a/innobase/include/page0cur.ic +++ b/innobase/include/page0cur.ic @@ -195,7 +195,7 @@ page_cur_tuple_insert( dict_index_t* index, /* in: record descriptor */ mtr_t* mtr) /* in: mini-transaction handle */ { - return(page_cur_insert_rec_low(cursor, tuple, index, NULL, mtr)); + return(page_cur_insert_rec_low(cursor, tuple, index, NULL, NULL, mtr)); } /*************************************************************** @@ -211,8 +211,10 @@ page_cur_rec_insert( page_cur_t* cursor, /* in: a page cursor */ rec_t* rec, /* in: record to insert */ dict_index_t* index, /* in: record descriptor */ + ulint* offsets,/* in: rec_get_offsets(rec, index) */ mtr_t* mtr) /* in: mini-transaction handle */ { - return(page_cur_insert_rec_low(cursor, NULL, index, rec, mtr)); + return(page_cur_insert_rec_low(cursor, NULL, index, rec, + offsets, mtr)); } diff --git a/innobase/include/rem0rec.h b/innobase/include/rem0rec.h index ab89b912523..c430def684a 100644 --- a/innobase/include/rem0rec.h +++ b/innobase/include/rem0rec.h @@ -133,6 +133,27 @@ rec_set_status( rec_t* rec, /* in: physical record */ ulint bits); /* in: info bits */ +/********************************************************** +The following function is used to retrieve the info and status +bits of a record. (Only compact records have status bits.) */ +UNIV_INLINE +ulint +rec_get_info_and_status_bits( +/*=========================*/ + /* out: info bits */ + rec_t* rec, /* in: physical record */ + ibool comp); /* in: TRUE=compact page format */ +/********************************************************** +The following function is used to set the info and status +bits of a record. (Only compact records have status bits.) */ +UNIV_INLINE +void +rec_set_info_and_status_bits( +/*=========================*/ + rec_t* rec, /* in: physical record */ + ibool comp, /* in: TRUE=compact page format */ + ulint bits); /* in: info bits */ + /********************************************************** The following function tells if record is delete marked. */ UNIV_INLINE diff --git a/innobase/include/rem0rec.ic b/innobase/include/rem0rec.ic index 7d35e8e4110..ca69b9ca871 100644 --- a/innobase/include/rem0rec.ic +++ b/innobase/include/rem0rec.ic @@ -520,6 +520,53 @@ rec_set_status( REC_NEW_STATUS_MASK, REC_NEW_STATUS_SHIFT); } +/********************************************************** +The following function is used to retrieve the info and status +bits of a record. (Only compact records have status bits.) */ +UNIV_INLINE +ulint +rec_get_info_and_status_bits( +/*==============*/ + /* out: info bits */ + rec_t* rec, /* in: physical record */ + ibool comp) /* in: TRUE=compact page format */ +{ + ulint bits; +#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \ +& (REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT) +# error "REC_NEW_STATUS_MASK and REC_INFO_BITS_MASK overlap" +#endif + if (comp) { + bits = rec_get_info_bits(rec, TRUE) | rec_get_status(rec); + } else { + bits = rec_get_info_bits(rec, FALSE); + ut_ad(!(bits & ~(REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT))); + } + return(bits); +} +/********************************************************** +The following function is used to set the info and status +bits of a record. (Only compact records have status bits.) */ +UNIV_INLINE +void +rec_set_info_and_status_bits( +/*==============*/ + rec_t* rec, /* in: physical record */ + ibool comp, /* in: TRUE=compact page format */ + ulint bits) /* in: info bits */ +{ +#if (REC_NEW_STATUS_MASK >> REC_NEW_STATUS_SHIFT) \ +& (REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT) +# error "REC_NEW_STATUS_MASK and REC_INFO_BITS_MASK overlap" +#endif + if (comp) { + rec_set_status(rec, bits & REC_NEW_STATUS_MASK); + } else { + ut_ad(!(bits & ~(REC_INFO_BITS_MASK >> REC_INFO_BITS_SHIFT))); + } + rec_set_info_bits(rec, comp, bits & ~REC_NEW_STATUS_MASK); +} + /********************************************************** The following function tells if record is delete marked. */ UNIV_INLINE diff --git a/innobase/include/univ.i b/innobase/include/univ.i index 80024f71992..c413c3bc67e 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -80,8 +80,10 @@ memory is read outside the allocated blocks. */ /* Make a non-inline debug version */ +#ifdef DBUG_ON +# define UNIV_DEBUG +#endif /* DBUG_ON */ /* -#define UNIV_DEBUG #define UNIV_MEM_DEBUG #define UNIV_IBUF_DEBUG #define UNIV_SYNC_DEBUG diff --git a/innobase/log/log0recv.c b/innobase/log/log0recv.c index 35dc9a06020..40a7deee604 100644 --- a/innobase/log/log0recv.c +++ b/innobase/log/log0recv.c @@ -2897,11 +2897,6 @@ recv_recovery_from_checkpoint_finish(void) int i; os_thread_id_t recovery_thread_id; - /* Rollback the uncommitted transactions which have no user session */ - - fprintf(stderr, - "InnoDB: Starting to apply log records to the database...\n"); - /* Apply the hashed log records to the respective file pages */ if (srv_force_recovery < SRV_FORCE_NO_LOG_REDO) { @@ -2938,6 +2933,9 @@ recv_recovery_from_checkpoint_finish(void) recv_sys_free(); #endif if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) { + /* Rollback the uncommitted transactions which have no user + session */ + os_thread_create(trx_rollback_or_clean_all_without_sess, (void *)&i, &recovery_thread_id); } diff --git a/innobase/os/os0thread.c b/innobase/os/os0thread.c index 12a8abf3069..91061bc8459 100644 --- a/innobase/os/os0thread.c +++ b/innobase/os/os0thread.c @@ -88,7 +88,7 @@ os_thread_create( /*=============*/ /* out: handle to the thread */ #ifndef __WIN__ - os_posix_f_t start_f, + os_posix_f_t start_f, #else ulint (*start_f)(void*), /* in: pointer to function from which to start */ diff --git a/innobase/page/page0cur.c b/innobase/page/page0cur.c index 53c3c573b8e..fc94fc4b1e0 100644 --- a/innobase/page/page0cur.c +++ b/innobase/page/page0cur.c @@ -605,8 +605,8 @@ page_cur_insert_rec_write_log( log_end = &log_ptr[5 + 1 + 5 + 5 + MLOG_BUF_MARGIN]; } - if ((rec_get_info_bits(insert_rec, index->table->comp) != - rec_get_info_bits(cursor_rec, index->table->comp)) + if ((rec_get_info_and_status_bits(insert_rec, index->table->comp) != + rec_get_info_and_status_bits(cursor_rec, index->table->comp)) || (extra_size != cur_extra_size) || (rec_size != cur_rec_size)) { @@ -622,7 +622,8 @@ page_cur_insert_rec_write_log( if (extra_info_yes) { /* Write the info bits */ mach_write_to_1(log_ptr, - rec_get_info_bits(insert_rec, index->table->comp)); + rec_get_info_and_status_bits(insert_rec, + index->table->comp)); log_ptr++; /* Write the record origin offset */ @@ -673,7 +674,7 @@ page_cur_parse_insert_rec( byte buf1[1024]; byte* buf; byte* ptr2 = ptr; - ulint info_bits = 0; /* remove warning */ + ulint info_and_status_bits = 0; /* remove warning */ page_cur_t cursor; mem_heap_t* heap = NULL; ulint offsets_[100] = { 100, }; @@ -723,7 +724,7 @@ page_cur_parse_insert_rec( return(NULL); } - info_bits = mach_read_from_1(ptr); + info_and_status_bits = mach_read_from_1(ptr); ptr++; ptr = mach_parse_compressed(ptr, end_ptr, &origin_offset); @@ -768,7 +769,8 @@ page_cur_parse_insert_rec( ULINT_UNDEFINED, &heap); if (extra_info_yes == 0) { - info_bits = rec_get_info_bits(cursor_rec, index->table->comp); + info_and_status_bits = rec_get_info_and_status_bits( + cursor_rec, index->table->comp); origin_offset = rec_offs_extra_size(offsets); mismatch_index = rec_offs_size(offsets) - end_seg_len; } @@ -783,11 +785,12 @@ page_cur_parse_insert_rec( if (mismatch_index >= UNIV_PAGE_SIZE) { fprintf(stderr, - "Is short %lu, info_bits %lu, offset %lu, " + "Is short %lu, info_and_status_bits %lu, offset %lu, " "o_offset %lu\n" "mismatch index %lu, end_seg_len %lu\n" "parsed len %lu\n", - (ulong) is_short, (ulong) info_bits, (ulong) offset, + (ulong) is_short, (ulong) info_and_status_bits, + (ulong) offset, (ulong) origin_offset, (ulong) mismatch_index, (ulong) end_seg_len, (ulong) (ptr - ptr2)); @@ -803,21 +806,14 @@ page_cur_parse_insert_rec( ut_memcpy(buf, rec_get_start(cursor_rec, offsets), mismatch_index); ut_memcpy(buf + mismatch_index, ptr, end_seg_len); - rec_set_info_bits(buf + origin_offset, index->table->comp, info_bits); - - /* Set the status bits for new-style records. */ - if (index->table->comp) { - /* Leaf pages (level 0) contain ordinary records; - non-leaf pages contain node pointer records. */ - ulint level = page_header_get_field( - buf_frame_align(cursor_rec), PAGE_LEVEL); - rec_set_status(buf + origin_offset, - level ? REC_STATUS_NODE_PTR : REC_STATUS_ORDINARY); - } + rec_set_info_and_status_bits(buf + origin_offset, index->table->comp, + info_and_status_bits); page_cur_position(cursor_rec, &cursor); - page_cur_rec_insert(&cursor, buf + origin_offset, index, mtr); + offsets = rec_get_offsets(buf + origin_offset, index, offsets, + ULINT_UNDEFINED, &heap); + page_cur_rec_insert(&cursor, buf + origin_offset, index, offsets, mtr); if (buf != buf1) { @@ -846,6 +842,7 @@ page_cur_insert_rec_low( dtuple_t* tuple, /* in: pointer to a data tuple or NULL */ dict_index_t* index, /* in: record descriptor */ rec_t* rec, /* in: pointer to a physical record or NULL */ + ulint* offsets,/* in: rec_get_offsets(rec, index) or NULL */ mtr_t* mtr) /* in: mini-transaction handle */ { byte* insert_buf = NULL; @@ -863,8 +860,6 @@ page_cur_insert_rec_low( rec_t* owner_rec; ulint n_owned; mem_heap_t* heap = NULL; - ulint offsets_[100] = { 100, }; - ulint* offsets = offsets_; ibool comp = index->table->comp; ut_ad(cursor && mtr); @@ -882,8 +877,11 @@ page_cur_insert_rec_low( if (tuple != NULL) { rec_size = rec_get_converted_size(index, tuple); } else { - offsets = rec_get_offsets(rec, index, offsets, + if (!offsets) { + offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap); + } + ut_ad(rec_offs_validate(rec, index, offsets)); rec_size = rec_offs_size(offsets); } @@ -1131,8 +1129,6 @@ page_copy_rec_list_end_to_created_page( slot_index = 0; n_recs = 0; - heap = mem_heap_create(100); - /* should be do ... until, comment by Jani */ while (rec != page_get_supremum_rec(page)) { offsets = rec_get_offsets(rec, index, offsets, diff --git a/innobase/page/page0page.c b/innobase/page/page0page.c index d71c243e7c5..901c8cd0831 100644 --- a/innobase/page/page0page.c +++ b/innobase/page/page0page.c @@ -463,6 +463,9 @@ page_copy_rec_list_end_no_locks( page_cur_t cur1; page_cur_t cur2; rec_t* sup; + mem_heap_t* heap = NULL; + ulint offsets_[100] = { 100, }; + ulint* offsets = offsets_; page_cur_position(rec, &cur1); @@ -483,8 +486,11 @@ page_copy_rec_list_end_no_locks( sup = page_get_supremum_rec(page); while (sup != page_cur_get_rec(&cur1)) { - if (!page_cur_rec_insert(&cur2, - page_cur_get_rec(&cur1), index, mtr)) { + rec_t* cur1_rec = page_cur_get_rec(&cur1); + offsets = rec_get_offsets(cur1_rec, index, offsets, + ULINT_UNDEFINED, &heap); + if (!page_cur_rec_insert(&cur2, cur1_rec, index, + offsets, mtr)) { /* Track an assertion failure reported on the mailing list on June 18th, 2003 */ @@ -503,7 +509,11 @@ page_copy_rec_list_end_no_locks( page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur2); } -} + + if (heap) { + mem_heap_free(heap); + } +} /***************************************************************** Copies records from page to new_page, from a given record onward, @@ -553,6 +563,9 @@ page_copy_rec_list_start( page_cur_t cur1; page_cur_t cur2; rec_t* old_end; + mem_heap_t* heap = NULL; + ulint offsets_[100] = { 100, }; + ulint* offsets = offsets_; page_cur_set_before_first(page, &cur1); @@ -570,8 +583,13 @@ page_copy_rec_list_start( /* Copy records from the original page to the new page */ while (page_cur_get_rec(&cur1) != rec) { - ut_a(page_cur_rec_insert(&cur2, - page_cur_get_rec(&cur1), index, mtr)); + rec_t* ins_rec; + rec_t* cur1_rec = page_cur_get_rec(&cur1); + offsets = rec_get_offsets(cur1_rec, index, offsets, + ULINT_UNDEFINED, &heap); + ins_rec = page_cur_rec_insert(&cur2, cur1_rec, index, + offsets, mtr); + ut_a(ins_rec); page_cur_move_to_next(&cur1); page_cur_move_to_next(&cur2); @@ -584,7 +602,11 @@ page_copy_rec_list_start( page_update_max_trx_id(new_page, page_get_max_trx_id(page)); btr_search_move_or_delete_hash_entries(new_page, page, index); -} + + if (heap) { + mem_heap_free(heap); + } +} /************************************************************** Writes a log record of a record list end or start deletion. */ diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 4650db7abad..aab0f5affa7 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -1120,7 +1120,6 @@ row_ins_check_foreign_constraint( dict_table_t* check_table; dict_index_t* check_index; ulint n_fields_cmp; - ibool unique_search; rec_t* rec; btr_pcur_t pcur; ibool moved; @@ -1240,14 +1239,6 @@ run_again: dtuple_set_n_fields_cmp(entry, foreign->n_fields); - if (dict_index_get_n_unique(check_index) <= foreign->n_fields) { - /* We can just set a LOCK_REC_NOT_GAP type lock */ - - unique_search = TRUE; - } else { - unique_search = FALSE; - } - btr_pcur_open(check_index, entry, PAGE_CUR_GE, BTR_SEARCH_LEAF, &pcur, &mtr); @@ -1289,18 +1280,14 @@ run_again: break; } } else { - /* Found a matching record */ - ulint lock_type; + /* Found a matching record. Lock only + a record because we can allow inserts + into gaps */ - if (unique_search) { - lock_type = LOCK_REC_NOT_GAP; - } else { - lock_type = LOCK_ORDINARY; - } + err = row_ins_set_shared_rec_lock( + LOCK_REC_NOT_GAP, rec, + check_index, offsets, thr); - err = row_ins_set_shared_rec_lock(lock_type, - rec, check_index, offsets, thr); - if (err != DB_SUCCESS) { break; diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index c5dc1de0c5a..50dedebe119 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -65,8 +65,9 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ my_compress.lo array.lo my_once.lo list.lo my_net.lo \ charset.lo charset-def.lo hash.lo mf_iocache.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \ - my_pread.lo mf_cache.lo md5.lo sha1.lo\ - my_getopt.lo my_gethostbyname.lo my_port.lo + my_pread.lo mf_cache.lo md5.lo sha1.lo \ + my_getopt.lo my_gethostbyname.lo my_port.lo \ + my_rename.lo sqlobjects = net.lo sql_cmn_objects = pack.lo client.lo my_time.lo diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 7c6b4e31ab5..c6815d2a5ce 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3077,7 +3077,7 @@ static my_bool int_is_null_false= 0; values and mysql_stmt_execute() the statement. See also: mysql_stmt_send_long_data() for sending long text/blob - data in pieces, examples in tests/client_test.c. + data in pieces, examples in tests/mysql_client_test.c. Next steps you might want to make: - execute statement with mysql_stmt_execute(), - reset statement using mysql_stmt_reset() or reprepare it with diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index ba646e282b5..d70d7330e55 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -1,6 +1,7 @@ -noinst_PROGRAMS = mysqltest mysql client_test -client_sources = $(mysqltest_SOURCES) $(mysql_SOURCES) -tests_sources= $(client_test_SOURCES) +noinst_PROGRAMS = mysql +bin_PROGRAMS = mysqltest_embedded mysql_client_test_embedded +client_sources = $(mysqltest_embedded_SOURCES) $(mysql_SOURCES) +tests_sources= $(mysql_client_test_embedded_SOURCES) link_sources: for f in $(client_sources); do \ @@ -19,16 +20,16 @@ INCLUDES = @MT_INCLUDES@ -I$(top_srcdir)/include -I$(srcdir) \ LIBS = @LIBS@ @WRAPLIBS@ @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysqld.a @innodb_system_libs@ @LIBDL@ $(CXXLDFLAGS) -mysqltest_LINK = $(CXXLINK) -mysqltest_SOURCES = mysqltest.c -mysqltest_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a +mysqltest_embedded_LINK = $(CXXLINK) +mysqltest_embedded_SOURCES = mysqltest.c +mysqltest_embedded_LDADD = $(LDADD) $(top_builddir)/regex/libregex.a mysql_SOURCES = mysql.cc readline.cc completion_hash.cc \ my_readline.h sql_string.h completion_hash.h mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) -client_test_LINK = $(CXXLINK) -client_test_SOURCES = client_test.c +mysql_client_test_embedded_LINK = $(CXXLINK) +mysql_client_test_embedded_SOURCES = mysql_client_test.c clean: rm -f $(client_sources) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index c38bffed665..4e66bd92a94 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -346,11 +346,12 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbe->flags & FTB_FLAG_NO || /* 2 */ ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ { - FTB_EXPR *top_ftbe=ftbe->up->up; + FTB_EXPR *top_ftbe=ftbe->up; ftbw->docid[0]=HA_OFFSET_ERROR; - for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) - if (!(ftbe->flags & FTB_FLAG_NO)) - ftbe->yweaks++; + for (ftbe=(FTB_EXPR *)ftbw; + ftbe != top_ftbe && !(ftbe->flags & FTB_FLAG_NO); + ftbe=ftbe->up) + ftbe->up->yweaks++; ftbe=0; break; } @@ -364,7 +365,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) else reset_tree(& ftb->no_dupes); } - + if (_ft2_search(ftb, ftbw, 1)) return; } diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 62d15c03266..a8a27858d79 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -184,21 +184,14 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) my_malloc((length+OFFSET_TABLE_SIZE)*sizeof(uint16)+ (uint) (share->pack.header_length+7), MYF(MY_WME | MY_ZEROFILL)))) - { - my_free((gptr) share->decode_trees,MYF(0)); goto err1; - } tmp_buff=share->decode_tables+length; disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE); if (my_read(file,disk_cache, (uint) (share->pack.header_length-sizeof(header)), MYF(MY_NABP))) - { - my_free((gptr) share->decode_trees,MYF(0)); - my_free((gptr) share->decode_tables,MYF(0)); goto err2; - } huff_tree_bits=max_bit(trees ? trees-1 : 0); init_bit_buffer(&bit_buff, (uchar*) disk_cache, diff --git a/myisam/rt_index.c b/myisam/rt_index.c index bdf5ee9c60f..97554dca4e6 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -948,15 +948,14 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) /* check for redundant root (not leaf, 1 child) and eliminate */ if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) goto err1; - if (!_mi_fetch_keypage(info, keyinfo, old_root, DFLT_INIT_HITS, + if (!_mi_fetch_keypage(info, keyinfo, old_root, DFLT_INIT_HITS, info->buff, 0)) goto err1; nod_flag = mi_test_if_nod(info->buff); page_size = mi_getint(info->buff); - if (nod_flag && (page_size == 2 + key_length + - (nod_flag ? nod_flag : info->s->base.rec_reflength))) + if (nod_flag && (page_size == 2 + key_length + nod_flag)) { - my_off_t new_root = _mi_kpos(nod_flag, + my_off_t new_root = _mi_kpos(nod_flag, rt_PAGE_FIRST_KEY(info->buff, nod_flag)); if (_mi_dispose(info, keyinfo, old_root, DFLT_INIT_HITS)) goto err1; diff --git a/myisam/sort.c b/myisam/sort.c index 09dd45f388c..9d2af2e8c70 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -162,7 +162,10 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, { if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, maxbuffer/2)) + { my_free((gptr) sort_keys,MYF(0)); + sort_keys= 0; + } else break; } diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index a6cbea2d1e5..1e3052de8e8 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -198,6 +198,13 @@ LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$LD_LIBRARY_PATH" DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$DYLD_LIBRARY_PATH" export LD_LIBRARY_PATH DYLD_LIBRARY_PATH +# +# Allow anyone in the group to see the generated database files +# +UMASK=0660 +UMASK_DIR=0770 +export UMASK UMASK_DIR + MASTER_RUNNING=0 MASTER1_RUNNING=0 MASTER_MYPORT=9306 @@ -241,6 +248,7 @@ USE_EMBEDDED_SERVER="" RESULT_EXT="" TEST_MODE="default" +NDB_MGM_EXTRA_OPTS= NDB_MGMD_EXTRA_OPTS= NDBD_EXTRA_OPTS= @@ -264,6 +272,8 @@ while test $# -gt 0; do --ndb-connectstring=*) USE_NDBCLUSTER="--ndbcluster" ; USE_RUNNING_NDBCLUSTER=`$ECHO "$1" | $SED -e "s;--ndb-connectstring=;;"` ;; + --ndb_mgm-extra-opts=*) + NDB_MGM_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgm-extra-opts=;;"` ;; --ndb_mgmd-extra-opts=*) NDB_MGMD_EXTRA_OPTS=`$ECHO "$1" | $SED -e "s;--ndb_mgmd-extra-opts=;;"` ;; --ndbd-extra-opts=*) @@ -470,7 +480,8 @@ SMALL_SERVER="--key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M" export MASTER_MYPORT MASTER_MYPORT1 SLAVE_MYPORT MYSQL_TCP_PORT MASTER_MYSOCK MASTER_MYSOCK1 NDBCLUSTER_BASE_PORT=`expr $NDBCLUSTER_PORT + 2` -NDBCLUSTER_OPTS="--port=$NDBCLUSTER_PORT --port-base=$NDBCLUSTER_BASE_PORT --data-dir=$MYSQL_TEST_DIR/var --ndb_mgmd-extra-opts=\"$NDB_MGMD_EXTRA_OPTS\" --ndbd-extra-opts=\"$NDBD_EXTRA_OPTS\"" +NDBCLUSTER_OPTS="--port=$NDBCLUSTER_PORT --port-base=$NDBCLUSTER_BASE_PORT --data-dir=$MYSQL_TEST_DIR/var --ndb_mgm-extra-opts=$NDB_MGM_EXTRA_OPTS --ndb_mgmd-extra-opts=$NDB_MGMD_EXTRA_OPTS --ndbd-extra-opts=$NDBD_EXTRA_OPTS" +NDB_BACKUP_DIR=$MYSQL_TEST_DIR/var/ndbcluster-$NDBCLUSTER_PORT if [ x$SOURCE_DIST = x1 ] ; then MY_BASEDIR=$MYSQL_TEST_DIR @@ -496,13 +507,13 @@ DASH72=`$ECHO '-------------------------------------------------------'|$CUT -c # on binary, use what is installed if [ x$SOURCE_DIST = x1 ] ; then if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then - if [ -f "$BASEDIR/libmysqld/examples/mysqltest" ] ; then - MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest" + if [ -f "$BASEDIR/libmysqld/examples/mysqltest_embedded" ] ; then + MYSQL_TEST="$VALGRIND $BASEDIR/libmysqld/examples/mysqltest_embedded" else - echo "Fatal error: Cannot find embedded server 'mysqltest'" 1>&2 + echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2 exit 1 fi - TESTS_BINDIR="$BASEDIR/libmysqld/examples" + MYSQL_CLIENT_TEST="$BASEDIR/libmysqld/examples/mysql_client_test_embedded" else MYSQLD="$VALGRIND $BASEDIR/sql/mysqld" if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then @@ -512,7 +523,7 @@ if [ x$SOURCE_DIST = x1 ] ; then else MYSQL_TEST="$BASEDIR/client/mysqltest" fi - TESTS_BINDIR="$BASEDIR/tests" + MYSQL_CLIENT_TEST="$BASEDIR/tests/mysql_client_test" fi if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump" @@ -542,6 +553,14 @@ if [ x$SOURCE_DIST = x1 ] ; then NDB_TOOLS_DIR="$BASEDIR/ndb/tools" NDB_MGM="$BASEDIR/ndb/src/mgmclient/ndb_mgm" else + + # We have a binary installation. Note that this can be both from + # unpacking a MySQL AB binary distribution (created using + # "scripts/make_binary_distribution", and from a "make install". + # Unfortunately the structure differs a bit, for a "make install" + # currently all binaries are in "bin", for a MySQL AB packaging + # some are in "tests". + if test -x "$BASEDIR/libexec/mysqld" then MYSQLD="$VALGRIND $BASEDIR/libexec/mysqld" @@ -575,7 +594,23 @@ else else LANGUAGE="$BASEDIR/share/english/" CHARSETSDIR="$BASEDIR/share/charsets" - fi + fi + if [ "x$USE_EMBEDDED_SERVER" = "x1" ] ; then + if [ -f "$CLIENT_BINDIR/mysqltest_embedded" ] ; then + MYSQL_TEST="$VALGRIND $CLIENT_BINDIR/mysqltest_embedded" + else + echo "Fatal error: Cannot find embedded server 'mysqltest_embedded'" 1>&2 + exit 1 + fi + if [ -d "$BASEDIR/tests/mysql_client_test_embedded" ] ; then + MYSQL_CLIENT_TEST="$TESTS_BINDIR/mysql_client_test_embedded" + else + MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test_embedded" + fi + else + MYSQL_TEST="$CLIENT_BINDIR/mysqltest" + MYSQL_CLIENT_TEST="$CLIENT_BINDIR/mysql_client_test" + fi fi if [ -z "$MASTER_MYSQLD" ] @@ -609,15 +644,16 @@ then EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --user=root" fi - +MYSQL_CLIENT_TEST="$MYSQL_CLIENT_TEST --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent" MYSQL_DUMP="$MYSQL_DUMP --no-defaults -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --local-load=$MYSQL_TMP_DIR $EXTRA_MYSQLBINLOG_OPT" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL="$MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_DUMP MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES -export CLIENT_BINDIR TESTS_BINDIR CHARSETSDIR +export CLIENT_BINDIR MYSQL_CLIENT_TEST CHARSETSDIR export NDB_TOOLS_DIR export NDB_MGM +export NDB_BACKUP_DIR MYSQL_TEST_ARGS="--no-defaults --socket=$MASTER_MYSOCK --database=$DB \ --user=$DBUSER --password=$DBPASSWD --silent -v --skip-safemalloc \ @@ -736,6 +772,17 @@ skip_test() { $ECHO "$RES$RES_SPACE [ skipped ]" } + +disable_test() { + USERT=" ...." + SYST=" ...." + REALT=" ...." + pname=`$ECHO "$1 "|$CUT -c 1-24` + RES="$pname" + skip_inc + $ECHO "$RES$RES_SPACE [ disabled ] $2" +} + report_stats () { if [ $TOT_FAIL = 0 ]; then $ECHO "All $TOT_TEST tests were successful." @@ -1382,6 +1429,12 @@ run_testcase () if [ -n "$RESULT_EXT" -a \( x$RECORD = x1 -o -f "$result_file$RESULT_EXT" \) ] ; then result_file="$result_file$RESULT_EXT" fi + if [ -e "$TESTDIR/$tname.disabled" ] + then + comment=`$CAT $TESTDIR/$tname.disabled`; + disable_test $tname "$comment" + return + fi if [ "$USE_MANAGER" = 1 ] ; then many_slaves=`$EXPR \( \( $tname : rpl_failsafe \) != 0 \) \| \( \( $tname : rpl_chain_temp_table \) != 0 \)` fi @@ -1547,6 +1600,12 @@ run_testcase () fi fi fi + + if [ "x$START_AND_EXIT" = "x1" ] ; then + echo "Servers started, exiting" + exit + fi + cd $MYSQL_TEST_DIR if [ -f $tf ] ; then @@ -1682,10 +1741,6 @@ then mysql_loadstd fi -if [ "x$START_AND_EXIT" = "x1" ] ; then - echo "Servers started, exiting" - exit -fi $ECHO "Starting Tests" diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh index a86e482b2ab..16bb3a9b122 100644 --- a/mysql-test/ndb/ndbcluster.sh +++ b/mysql-test/ndb/ndbcluster.sh @@ -58,6 +58,7 @@ ndb_con_op=105000 ndb_dmem=80M ndb_imem=24M +NDB_MGM_EXTRA_OPTS= NDB_MGMD_EXTRA_OPTS= NDBD_EXTRA_OPTS= @@ -97,6 +98,9 @@ while test $# -gt 0; do --port-base=*) port_base=`echo "$1" | sed -e "s;--port-base=;;"` ;; + --ndb_mgm-extra-opts=*) + NDB_MGM_EXTRA_OPTS=`echo "$1" | sed -e "s;--ndb_mgm-extra-opts=;;"` + ;; --ndb_mgmd-extra-opts=*) NDB_MGMD_EXTRA_OPTS=`echo "$1" | sed -e "s;--ndb_mgmd-extra-opts=;;"` ;; @@ -130,7 +134,7 @@ if [ ! -x "$exec_waiter" ]; then exit 1 fi -exec_mgmtclient="$exec_mgmtclient --no-defaults" +exec_mgmtclient="$exec_mgmtclient --no-defaults $NDB_MGM_EXTRA_OPTS" exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $NDB_MGMD_EXTRA_OPTS" exec_ndb="$exec_ndb --no-defaults $NDBD_EXTRA_OPTS" exec_waiter="$exec_waiter --no-defaults" @@ -178,8 +182,8 @@ fi # Edit file system path and ports in config file if [ $initial_ndb ] ; then - rm -f $fs_ndb/ndb_* -sed \ + rm -f $fs_ndb/ndb_* 2>&1 | cat > /dev/null + sed \ -e s,"CHOOSE_MaxNoOfOrderedIndexes","$ndb_no_ord",g \ -e s,"CHOOSE_MaxNoOfConcurrentOperations","$ndb_con_op",g \ -e s,"CHOOSE_DataMemory","$ndb_dmem",g \ diff --git a/mysql-test/r/ctype_mb.result b/mysql-test/r/ctype_mb.result index 88941d11aad..f6e14e1a78f 100644 --- a/mysql-test/r/ctype_mb.result +++ b/mysql-test/r/ctype_mb.result @@ -33,7 +33,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 1 key_a 1 a A NULL 9 NULL YES BTREE +t1 1 key_a 1 a A NULL 3 NULL YES BTREE ALTER TABLE t1 CHANGE a a CHAR(4); SHOW CREATE TABLE t1; Table Create Table @@ -53,5 +53,5 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SHOW KEYS FROM t1; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 1 key_a 1 a A NULL 9 NULL YES BTREE +t1 1 key_a 1 a A NULL 3 NULL YES BTREE DROP TABLE t1; diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index a85cfd4181c..f50cae79608 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -148,6 +148,9 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B a b select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); a b +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); +a b +Full-text indexes are called collections select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); a b select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result index 3be73f6cc6a..cfd8f78a77c 100644 --- a/mysql-test/r/lowercase_table2.result +++ b/mysql-test/r/lowercase_table2.result @@ -1,4 +1,4 @@ -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; CREATE TABLE T1 (a int); @@ -131,3 +131,13 @@ show tables like 't1%'; Tables_in_test (t1%) t1 drop table t1; +create temporary table tT(a int(11), b varchar(8)); +insert into tT values (1, 'abc'); +select * from tT; +a b +1 abc +alter table tT add index (a); +select * from tT; +a b +1 abc +drop table tT; diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9cc89ee4cc..d9397ad42e1 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -1,4 +1,4 @@ -drop table if exists t1, t2, t3, t4, t5, t6, t7; +drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; CREATE TABLE t1 ( a int unsigned NOT NULL PRIMARY KEY, b int unsigned not null, diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result new file mode 100644 index 00000000000..8e4449b1996 --- /dev/null +++ b/mysql-test/r/ndb_restore.result @@ -0,0 +1,249 @@ +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +CREATE TABLE `t1` ( +`capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, +`goaledatta` char(2) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); +CREATE TABLE `t2` ( +`capgotod` smallint(5) unsigned NOT NULL auto_increment, +`gotod` smallint(5) unsigned NOT NULL default '0', +`goaledatta` char(2) default NULL, +`maturegarbagefa` varchar(32) default NULL, +`descrpooppo` varchar(64) default NULL, +`svcutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capgotod`), +KEY `i_quadaddsvr` (`gotod`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t2` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); +CREATE TABLE `t3` ( +`CapGoaledatta` smallint(5) unsigned NOT NULL default '0', +`capgotod` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); +CREATE TABLE `t4` ( +`capfa` bigint(20) unsigned NOT NULL auto_increment, +`realm` varchar(32) NOT NULL default '', +`authpwchap` varchar(32) default NULL, +`fa` varchar(32) NOT NULL default '', +`payyingatta` tinyint(4) NOT NULL default '0', +`status` char(1) default NULL, +PRIMARY KEY (`fa`,`realm`), +KEY `capfa` (`capfa`), +KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t4` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); +CREATE TABLE `t5` ( +`capfa` bigint(20) unsigned NOT NULL default '0', +`gotod` smallint(5) unsigned NOT NULL default '0', +`orderutonsa` varchar(64) NOT NULL default '', +PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); +CREATE TABLE `t6` ( +`capfa_parent` bigint(20) unsigned NOT NULL default '0', +`capfa_child` bigint(20) unsigned NOT NULL default '0', +`relatta` smallint(5) unsigned NOT NULL default '0', +PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t6` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); +CREATE TABLE `t7` ( +`dardpo` char(15) NOT NULL default '', +`dardtestard` tinyint(3) unsigned NOT NULL default '0', +`FastFA` char(5) NOT NULL default '', +`FastCode` char(6) NOT NULL default '', +`Fastca` char(1) NOT NULL default '', +`Fastmag` char(1) NOT NULL default '', +`Beareratta` char(2) NOT NULL default '', +PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); +CREATE TABLE `t8` ( +`kattjame` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`aaaproxysessfa` varchar(255) default NULL, +`autologonallowed` char(1) default NULL, +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`acctoutputoctets` bigint(20) unsigned default NULL, +`acctinputoctets` bigint(20) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), +KEY `squardporoot` (`squardporoot`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); +CREATE TABLE `t9` ( +`kattjame` varchar(32) NOT NULL default '', +`kattjame_entered` varchar(32) NOT NULL default '', +`realm` varchar(32) NOT NULL default '', +`realm_entered` varchar(32) NOT NULL default '', +`maturegarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa` varchar(32) NOT NULL default '', +`hunderaaarbagefa_parent` varchar(32) NOT NULL default '', +`gest` varchar(16) default NULL, +`hassetino` varchar(16) NOT NULL default '', +`squardporoot` varchar(15) NOT NULL default '', +`naspo` varchar(15) default NULL, +`beareratta` char(2) default NULL, +`fastCode` varchar(6) default NULL, +`fastFA` varchar(5) default NULL, +`fastca` char(1) default NULL, +`fastmag` char(1) default NULL, +`lastupdate` datetime default NULL, +`hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', +`accthassetitime` int(10) unsigned default NULL, +`actcoutpuocttets` bigint(20) unsigned default NULL, +`actinputocctets` bigint(20) unsigned default NULL, +`terminateraste` tinyint(3) unsigned default NULL, +PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); +create table t1_c engine=ndbcluster as select * from t1; +create table t2_c engine=ndbcluster as select * from t2; +create table t3_c engine=ndbcluster as select * from t3; +create table t4_c engine=ndbcluster as select * from t4; +create table t5_c engine=ndbcluster as select * from t5; +create table t6_c engine=ndbcluster as select * from t6; +create table t7_c engine=ndbcluster as select * from t7; +create table t8_c engine=ndbcluster as select * from t8; +create table t9_c engine=ndbcluster as select * from t9; +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +show tables; +Tables_in_test +t1 +t2 +t3 +t4 +t5 +t6 +t7 +t8 +t9 +t8_c +t9_c +t1_c +t7_c +t6_c +t5_c +t4_c +t3_c +t2_c +select count(*) from t1; +count(*) +5 +select count(*) from t1_c; +count(*) +5 +select count(*) +from (select * from t1 union +select * from t1_c) a; +count(*) +5 +select count(*) from t2; +count(*) +6 +select count(*) from t2_c; +count(*) +6 +select count(*) +from (select * from t2 union +select * from t2_c) a; +count(*) +6 +select count(*) from t3; +count(*) +4 +select count(*) from t3_c; +count(*) +4 +select count(*) +from (select * from t3 union +select * from t3_c) a; +count(*) +4 +select count(*) from t4; +count(*) +22 +select count(*) from t4_c; +count(*) +22 +select count(*) +from (select * from t4 union +select * from t4_c) a; +count(*) +22 +select count(*) from t5; +count(*) +3 +select count(*) from t5_c; +count(*) +3 +select count(*) +from (select * from t5 union +select * from t5_c) a; +count(*) +3 +select count(*) from t6; +count(*) +8 +select count(*) from t6_c; +count(*) +8 +select count(*) +from (select * from t6 union +select * from t6_c) a; +count(*) +8 +select count(*) from t7; +count(*) +5 +select count(*) from t7_c; +count(*) +5 +select count(*) +from (select * from t7 union +select * from t7_c) a; +count(*) +5 +select count(*) from t8; +count(*) +3 +select count(*) from t8_c; +count(*) +3 +select count(*) +from (select * from t8 union +select * from t8_c) a; +count(*) +3 +select count(*) from t9; +count(*) +3 +select count(*) from t9_c; +count(*) +3 +select count(*) +from (select * from t9 union +select * from t9_c) a; +count(*) +3 +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index cfd296fd44b..b1847636790 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -1,7 +1,7 @@ drop table if exists t1, t2, t3, t4; drop table if exists t1, t2, t3, t4; start slave; -ERROR HY000: File 'TESTDIR/var/slave-data/master.info' not found (Errcode: 13) +Got one of the listed errors start slave; ERROR HY000: Could not initialize master info structure; more error messages can be found in the MySQL error log change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root'; diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 5a2f26a7105..2520beb1d77 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -246,3 +246,11 @@ SELECT FOUND_ROWS(); FOUND_ROWS() 0 DROP TABLE t1; +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5); +SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2; +a +a +SELECT FOUND_ROWS(); +FOUND_ROWS() +1 diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index f28317ce947..72a763db1b1 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -814,14 +814,14 @@ DROP TABLE t1; CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6)); INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello '); INSERT INTO t1 (col1) VALUES ('hellobob'); -ERROR 01000: Data truncated for column 'col1' at row 1 +ERROR 22001: Data too long for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('hellobob'); ERROR 01000: Data truncated for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES ('hello '); Warnings: Note 1265 Data truncated for column 'col2' at row 1 UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he'; -ERROR 01000: Data truncated for column 'col1' at row 2 +ERROR 22001: Data too long for column 'col1' at row 2 UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he'; ERROR 01000: Data truncated for column 'col2' at row 2 INSERT IGNORE INTO t1 VALUES ('hellobob', 'hellobob'); diff --git a/mysql-test/t/client_test.test b/mysql-test/t/client_test.test deleted file mode 100644 index 29e7c23ab35..00000000000 --- a/mysql-test/t/client_test.test +++ /dev/null @@ -1,4 +0,0 @@ -# Skip when testing the embedded server ---source include/not_embedded.inc ---disable_result_log ---exec $TESTS_BINDIR/client_test --no-defaults --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test old mode 100755 new mode 100644 diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test old mode 100755 new mode 100644 diff --git a/mysql-test/t/federated.disabled b/mysql-test/t/federated.disabled new file mode 100644 index 00000000000..5ad728b6f10 --- /dev/null +++ b/mysql-test/t/federated.disabled @@ -0,0 +1 @@ +Patrick Galbraith should fix this diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 008e965297f..62dcecaff68 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -67,6 +67,7 @@ select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); # bug#2708, bug#3870 crash diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test index a4eaeac4ef4..237dcd29950 100644 --- a/mysql-test/t/lowercase_table2.test +++ b/mysql-test/t/lowercase_table2.test @@ -10,7 +10,7 @@ show variables like "lower_case_table_names"; enable_query_log; --disable_warnings -DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3,tT; DROP DATABASE IF EXISTS `TEST_$1`; DROP DATABASE IF EXISTS `test_$1`; --enable_warnings @@ -100,3 +100,14 @@ show tables like 'T1%'; alter table t1 add index (A); show tables like 't1%'; drop table t1; + +# +# Bug #7261: Alter table loses temp table +# + +create temporary table tT(a int(11), b varchar(8)); +insert into tT values (1, 'abc'); +select * from tT; +alter table tT add index (a); +select * from tT; +drop table tT; diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test new file mode 100644 index 00000000000..86aecf43cbd --- /dev/null +++ b/mysql-test/t/mysql_client_test.test @@ -0,0 +1,3 @@ +# We run with different binaries for normal and --embedded-server +--disable_result_log +--exec $MYSQL_CLIENT_TEST diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index f235d1ffc30..d585ac107bc 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -1,7 +1,7 @@ -- source include/have_ndb.inc --disable_warnings -drop table if exists t1, t2, t3, t4, t5, t6, t7; +drop table if exists t1, t2, t3, t4, t5, t6, t7, t8; --enable_warnings # diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test new file mode 100644 index 00000000000..09939ec119d --- /dev/null +++ b/mysql-test/t/ndb_restore.test @@ -0,0 +1,209 @@ +-- source include/have_ndb.inc + +--disable_warnings +use test; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--enable_warnings + +CREATE TABLE `t1` ( + `capgoaledatta` smallint(5) unsigned NOT NULL auto_increment, + `goaledatta` char(2) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + PRIMARY KEY (`capgoaledatta`,`goaledatta`,`maturegarbagefa`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t1` VALUES (2,'3','q3plus.qt'),(4,'4','q3plus.qt'),(1,'3','q3.net'),(3,'4','q3.net'),(3,'20','threetrees.qt'); + +CREATE TABLE `t2` ( + `capgotod` smallint(5) unsigned NOT NULL auto_increment, + `gotod` smallint(5) unsigned NOT NULL default '0', + `goaledatta` char(2) default NULL, + `maturegarbagefa` varchar(32) default NULL, + `descrpooppo` varchar(64) default NULL, + `svcutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capgotod`), + KEY `i_quadaddsvr` (`gotod`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t2` VALUES (5,4,'','q3.net','addavp:MK_CASELECTOR=1','postorod rattoaa'),(2,1,'4','','addavp:MK_BRANDTAD=345','REDS Brandtad'),(3,2,'4','q3.net','execorder','fixedRatediPO REDS'),(1,1,'3','','addavp:MK_BRANDTAD=123','TEST Brandtad'),(6,5,'','told.q3.net','addavp:MK_BRANDTAD=123','Brandtad Toldzone'),(4,3,'3','q3.net','addavp:MK_POOLHINT=2','ratedi PO TEST'); + +CREATE TABLE `t3` ( + `CapGoaledatta` smallint(5) unsigned NOT NULL default '0', + `capgotod` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capgotod`,`CapGoaledatta`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t3` VALUES (5,3),(2,4),(5,4),(1,3); + +CREATE TABLE `t4` ( + `capfa` bigint(20) unsigned NOT NULL auto_increment, + `realm` varchar(32) NOT NULL default '', + `authpwchap` varchar(32) default NULL, + `fa` varchar(32) NOT NULL default '', + `payyingatta` tinyint(4) NOT NULL default '0', + `status` char(1) default NULL, + PRIMARY KEY (`fa`,`realm`), + KEY `capfa` (`capfa`), + KEY `i_quadentity` (`fa`,`realm`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t4` VALUES (18,'john.smith','q3.net','dessjohn.smith',0,NULL),(21,'quad_katt_with_brandtad','q3.net','acne',0,NULL),(22,'quad_katt_carattoaa','q3.net','acne',0,NULL),(26,'436462612809','sqasdt.q3.net','N/A',0,'6'),(19,'john','smith.qt','dessjohn',0,NULL),(33,'436643196120','sqasdt.q3.net','N/A',1,'6'),(28,'436642900019','sqasdt.q3.net','N/A',0,'6'),(30,'436462900209','sqasdt.q3.net','N/A',0,'6'),(16,'436640006666','sqasdt.q3.net','',0,NULL),(19,'dette','el-redun.com','dessdette',0,NULL),(12,'quad_kattPP','q3.net','acne',2,NULL),(14,'436640008888','sqasdt.q3.net','',0,NULL),(29,'463624900028','sqasdt.q3.net','N/A',0,'6'),(15,'436640099099','sqasdt.q3.net','',0,NULL),(13,'pap','q3plus.qt','acne',1,NULL),(19,'436642612091','sqasdt.q3.net','N/A',0,'6'),(12,'quad_katt','q3.net','acne',0,NULL),(11,'quad_kattVK','q3.net','acne',1,NULL),(32,'463641969502','sqasdt.q3.net','N/A',1,'6'),(20,'joe','q3.net','joedesswd',0,NULL),(29,'436642900034','sqasdt.q3.net','N/A',0,'6'),(25,'contind','armerde.qt','acne',1,NULL); + +CREATE TABLE `t5` ( + `capfa` bigint(20) unsigned NOT NULL default '0', + `gotod` smallint(5) unsigned NOT NULL default '0', + `orderutonsa` varchar(64) NOT NULL default '', + PRIMARY KEY (`capfa`,`gotod`,`orderutonsa`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t5` VALUES (21,2,''),(21,1,''),(22,4,''); + +CREATE TABLE `t6` ( + `capfa_parent` bigint(20) unsigned NOT NULL default '0', + `capfa_child` bigint(20) unsigned NOT NULL default '0', + `relatta` smallint(5) unsigned NOT NULL default '0', + PRIMARY KEY (`capfa_child`,`capfa_parent`,`relatta`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t6` VALUES (15,16,0),(19,20,0),(18326932092909551615,30,0),(26,29,0),(18326932092909551615,29,0),(19,18,0),(26,28,0),(12,14,0); + +CREATE TABLE `t7` ( + `dardpo` char(15) NOT NULL default '', + `dardtestard` tinyint(3) unsigned NOT NULL default '0', + `FastFA` char(5) NOT NULL default '', + `FastCode` char(6) NOT NULL default '', + `Fastca` char(1) NOT NULL default '', + `Fastmag` char(1) NOT NULL default '', + `Beareratta` char(2) NOT NULL default '', + PRIMARY KEY (`dardpo`,`dardtestard`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t7` VALUES ('2.6.2.4',24,'CECHP','54545','0','0','5'),('2.2.5.4',26,'CANFA','33223','1','1','4'),('4.3.2.4',28,'ITALD','54222','1','0','5'),('129..0.0.eins',28,'G','99999','1','1','5'),('1.1.1.1',24,'AUTPT','32323','0','1','3'); + +CREATE TABLE `t8` ( + `kattjame` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `aaaproxysessfa` varchar(255) default NULL, + `autologonallowed` char(1) default NULL, + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `acctoutputoctets` bigint(20) unsigned default NULL, + `acctinputoctets` bigint(20) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`), + KEY `squardporoot` (`squardporoot`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t8` VALUES ('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643196120','436643196929','8956234534568968','5524595699','uxasmt21.net.acne.qt/481889229462692422','','1.1.1.1','2.2.4.6','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565),('4545435545','john','q3.net','q3.net','acne.li','436643196120','436643196929','45345234568968','995696699','uxasmt21.net.acne.qt/481889229462692423','','1.1.1.1','2.2.9.8','2','86989','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8821923,169,3565),('versteckter_q3net_katt','joe','q3.net','elredun.com','q3.net','436643196120','436643196939','91341234568968','695595699','uxasmt21.net.acne.qt/481889229462692421','','1.1.1.1','2.5.2.5','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',1923123,9569,6565); + +CREATE TABLE `t9` ( + `kattjame` varchar(32) NOT NULL default '', + `kattjame_entered` varchar(32) NOT NULL default '', + `realm` varchar(32) NOT NULL default '', + `realm_entered` varchar(32) NOT NULL default '', + `maturegarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa` varchar(32) NOT NULL default '', + `hunderaaarbagefa_parent` varchar(32) NOT NULL default '', + `gest` varchar(16) default NULL, + `hassetino` varchar(16) NOT NULL default '', + `squardporoot` varchar(15) NOT NULL default '', + `naspo` varchar(15) default NULL, + `beareratta` char(2) default NULL, + `fastCode` varchar(6) default NULL, + `fastFA` varchar(5) default NULL, + `fastca` char(1) default NULL, + `fastmag` char(1) default NULL, + `lastupdate` datetime default NULL, + `hassetistart` datetime NOT NULL default '0000-00-00 00:00:00', + `accthassetitime` int(10) unsigned default NULL, + `actcoutpuocttets` bigint(20) unsigned default NULL, + `actinputocctets` bigint(20) unsigned default NULL, + `terminateraste` tinyint(3) unsigned default NULL, + PRIMARY KEY (`kattjame`,`hunderaaarbagefa`,`hassetistart`,`hassetino`) +) ENGINE=myisam DEFAULT CHARSET=latin1; +INSERT INTO `t9` VALUES ('3g4jh8gar2t','joe','q3.net','elredun.com','q3.net','436643316120','436643316939','91341234568968','695595699','1.1.1.1','2.2.6.2','3','86989','34','x','x','2012-03-12 18:35:04','2012-12-05 12:35:04',3123123,9569,6565,1),('4tt45345235','pap','q3plus.qt','q3plus.qt','q3.net','436643316120','436643316939','8956234534568968','5254595969','1.1.1.1','8.6.2.2','4','86989','34','x','x','2012-03-12 12:55:34','2012-12-05 11:20:04',3223433,3369,9565,2),('4545435545','john','q3.net','q3.net','acne.li','436643316120','436643316939','45345234568968','995696699','1.1.1.1','2.9.9.2','2','86998','34','x','x','2012-03-12 11:35:03','2012-12-05 08:50:04',8823123,169,3565,3); + +create table t1_c engine=ndbcluster as select * from t1; +create table t2_c engine=ndbcluster as select * from t2; +create table t3_c engine=ndbcluster as select * from t3; +create table t4_c engine=ndbcluster as select * from t4; +create table t5_c engine=ndbcluster as select * from t5; +create table t6_c engine=ndbcluster as select * from t6; +create table t7_c engine=ndbcluster as select * from t7; +create table t8_c engine=ndbcluster as select * from t8; +create table t9_c engine=ndbcluster as select * from t9; + + +--exec $NDB_MGM --no-defaults -e "start backup" > /dev/null +drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 1 -m -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 > /tmp/ndb_restore.out +--exec $NDB_TOOLS_DIR/ndb_restore --no-defaults -b 1 -n 2 -r --print --print_meta $NDB_BACKUP_DIR/BACKUP/BACKUP-1 > /tmp/ndb_restore.out + +show tables; + + +select count(*) from t1; +select count(*) from t1_c; +select count(*) + from (select * from t1 union + select * from t1_c) a; + +select count(*) from t2; +select count(*) from t2_c; +select count(*) + from (select * from t2 union + select * from t2_c) a; + +select count(*) from t3; +select count(*) from t3_c; +select count(*) + from (select * from t3 union + select * from t3_c) a; + +select count(*) from t4; +select count(*) from t4_c; +select count(*) + from (select * from t4 union + select * from t4_c) a; + +select count(*) from t5; +select count(*) from t5_c; +select count(*) + from (select * from t5 union + select * from t5_c) a; + +select count(*) from t6; +select count(*) from t6_c; +select count(*) + from (select * from t6 union + select * from t6_c) a; + +select count(*) from t7; +select count(*) from t7_c; +select count(*) + from (select * from t7 union + select * from t7_c) a; + +select count(*) from t8; +select count(*) from t8_c; +select count(*) + from (select * from t8 union + select * from t8_c) a; + +select count(*) from t9; +select count(*) from t9_c; +select count(*) + from (select * from t9 union + select * from t9_c) a; + +--disable_warnings +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; +--enable_warnings diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 63ddf495347..2b5c72d16d2 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -24,7 +24,7 @@ drop table if exists t1, t2, t3, t4; # START SLAVE will fail because it can't read the file (mode 000) # (system error 13) --replace_result $MYSQL_TEST_DIR TESTDIR ---error 1105 +--error 1105,1105 start slave; system chmod 600 var/slave-data/master.info; # It will fail again because the file is empty so the slave cannot get valuable diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index 943174462e3..d31d7d0b02e 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -166,3 +166,12 @@ INSERT INTO t1 VALUES (0), (0), (1), (2); SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a = 0 GROUP BY a HAVING a > 10; SELECT FOUND_ROWS(); DROP TABLE t1; + +# +# Bug #7945: group by + distinct with constant expression + limit +# + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5); +SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2; +SELECT FOUND_ROWS(); diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 2ccc3e672c7..df3f6b49f84 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -565,12 +565,12 @@ DROP TABLE t1; CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6)); INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello '); ---error 1265 +--error 1400 INSERT INTO t1 (col1) VALUES ('hellobob'); --error 1265 INSERT INTO t1 (col2) VALUES ('hellobob'); INSERT INTO t1 (col2) VALUES ('hello '); ---error 1265 +--error 1400 UPDATE t1 SET col1 ='hellobob' WHERE col1 ='he'; --error 1265 UPDATE t1 SET col2 ='hellobob' WHERE col2 ='he'; diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index bf7ed7ab6b6..4967b60cd68 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -352,6 +352,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, MYF(0)))) break; my_large_free(keycache->block_mem, MYF(0)); + keycache->block_mem= 0; } if (blocks < 8) { @@ -2444,6 +2445,41 @@ static int flush_all_key_blocks(KEY_CACHE *keycache) } +/* + Reset the counters of a key cache. + + SYNOPSIS + reset_key_cache_counters() + name the name of a key cache + key_cache pointer to the key kache to be reset + + DESCRIPTION + This procedure is used by process_key_caches() to reset the counters of all + currently used key caches, both the default one and the named ones. + + RETURN + 0 on success (always because it can't fail) +*/ + +int reset_key_cache_counters(const char *name, KEY_CACHE *key_cache) +{ + DBUG_ENTER("reset_key_cache_counters"); + if (!key_cache->key_cache_inited) + { + DBUG_PRINT("info", ("Key cache %s not initialized.", name)); + DBUG_RETURN(0); + } + DBUG_PRINT("info", ("Resetting counters for key cache %s.", name)); + + key_cache->global_blocks_changed= 0; /* Key_blocks_not_flushed */ + key_cache->global_cache_r_requests= 0; /* Key_read_requests */ + key_cache->global_cache_read= 0; /* Key_reads */ + key_cache->global_cache_w_requests= 0; /* Key_write_requests */ + key_cache->global_cache_write= 0; /* Key_writes */ + DBUG_RETURN(0); +} + + #ifndef DBUG_OFF /* Test if disk-cache is ok diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index fee3096de52..38fef31fdd4 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -275,7 +275,11 @@ static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data) if (entry->data == old_data) { if (new_data == hash->default_value) + { + if ((*entry->prev= entry->next)) + entry->next->prev= entry->prev; hash_delete(&hash->hash, (byte*) entry); + } else entry->data= new_data; } diff --git a/mysys/my_open.c b/mysys/my_open.c index ca5c0d8683f..a5cd3811bbf 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -69,7 +69,7 @@ File my_open(const char *FileName, int Flags, myf MyFlags) my_close() fd File sescriptor myf Special Flags - + */ int my_close(File fd, myf MyFlags) @@ -79,7 +79,12 @@ int my_close(File fd, myf MyFlags) DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); pthread_mutex_lock(&THR_LOCK_open); - if ((err = close(fd))) + do + { + err= close(fd); + } while (err == -1 && errno == EINTR); + + if (err) { DBUG_PRINT("error",("Got error %d on close",err)); my_errno=errno; diff --git a/mysys/my_sync.c b/mysys/my_sync.c index 317ca039346..bd372f03c87 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -40,15 +40,19 @@ int my_sync(File fd, myf my_flags) DBUG_ENTER("my_sync"); DBUG_PRINT("my",("Fd: %d my_flags: %d", fd, my_flags)); + do + { #if defined(HAVE_FDATASYNC) - res= fdatasync(fd); + res= fdatasync(fd); #elif defined(HAVE_FSYNC) - res=fsync(fd); + res= fsync(fd); #elif defined(__WIN__) res= _commit(fd); #else - res= 0; /* No sync (strange OS) */ + res= 0; /* No sync (strange OS) */ #endif + } while (res == -1 && errno == EINTR); + if (res) { if (!(my_errno= errno)) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index caef1caaf3d..19611a6027a 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -248,7 +248,7 @@ void thr_end_alarm(thr_alarm_t *alarmed) if (alarm_data->malloced) my_free((gptr) alarm_data,MYF(0)); found++; -#ifndef DBUG_OFF +#ifdef DBUG_OFF break; #endif } diff --git a/ndb/examples/Makefile b/ndb/examples/Makefile index 87a821773ec..965dc3ec29f 100644 --- a/ndb/examples/Makefile +++ b/ndb/examples/Makefile @@ -4,7 +4,8 @@ BIN_DIRS := ndbapi_simple_example \ ndbapi_retries_example \ ndbapi_simple_index_example \ ndbapi_event_example \ - ndbapi_scan_example + ndbapi_scan_example \ + mgmapi_logevent_example bins: $(patsubst %, _bins_%, $(BIN_DIRS)) diff --git a/ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp b/ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp index abd8089a286..5ec1fba6314 100644 --- a/ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp +++ b/ndb/examples/mgmapi_logevent_example/mgmapi_logevent.cpp @@ -42,8 +42,13 @@ int main() { NdbMgmHandle h; - NdbLogEventHandle l; - int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; + NdbLogEventHandle le; + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, + 15, NDB_MGM_EVENT_CATEGORY_CONNECTION, + 15, NDB_MGM_EVENT_CATEGORY_NODE_RESTART, + 15, NDB_MGM_EVENT_CATEGORY_STARTUP, + 15, NDB_MGM_EVENT_CATEGORY_ERROR, + 0 }; struct ndb_logevent event; ndb_init(); @@ -56,48 +61,79 @@ int main() } if (ndb_mgm_connect(h,0,0,0)) MGMERROR(h); - l= ndb_mgm_create_logevent_handle(h, filter); - if ( l == 0 ) MGMERROR(h); + le= ndb_mgm_create_logevent_handle(h, filter); + if ( le == 0 ) MGMERROR(h); while (1) { int timeout= 5000; - int r= ndb_logevent_get_next(l,&event,timeout); + int r= ndb_logevent_get_next(le,&event,timeout); if (r == 0) printf("No event within %d milliseconds\n", timeout); else if (r < 0) - LOGEVENTERROR(l) + LOGEVENTERROR(le) else { - printf("Event %d from node ID %d\n", - event.type, - event.source_nodeid); - printf("Category %d, severity %d, level %d\n", - event.category, - event.severity, - event.level); switch (event.type) { case NDB_LE_BackupStarted: - printf("BackupStartded\n"); - printf("Starting node ID: %d\n", event.BackupStarted.starting_node); - printf("Backup ID: %d\n", event.BackupStarted.backup_id); + printf("Node %d: BackupStarted\n", event.source_nodeid); + printf(" Starting node ID: %d\n", event.BackupStarted.starting_node); + printf(" Backup ID: %d\n", event.BackupStarted.backup_id); break; case NDB_LE_BackupCompleted: - printf("BackupCompleted\n"); - printf("Backup ID: %d\n", event.BackupStarted.backup_id); + printf("Node %d: BackupCompleted\n", event.source_nodeid); + printf(" Backup ID: %d\n", event.BackupStarted.backup_id); break; case NDB_LE_BackupAborted: + printf("Node %d: BackupAborted\n", event.source_nodeid); break; case NDB_LE_BackupFailedToStart: + printf("Node %d: BackupFailedToStart\n", event.source_nodeid); break; + + case NDB_LE_NodeFailCompleted: + printf("Node %d: NodeFailCompleted\n", event.source_nodeid); + break; + case NDB_LE_ArbitResult: + printf("Node %d: ArbitResult\n", event.source_nodeid); + printf(" code %d, arbit_node %d\n", + event.ArbitResult.code & 0xffff, + event.ArbitResult.arbit_node); + break; + case NDB_LE_DeadDueToHeartbeat: + printf("Node %d: DeadDueToHeartbeat\n", event.source_nodeid); + printf(" node %d\n", event.DeadDueToHeartbeat.node); + break; + + case NDB_LE_Connected: + printf("Node %d: Connected\n", event.source_nodeid); + printf(" node %d\n", event.Connected.node); + break; + case NDB_LE_Disconnected: + printf("Node %d: Disconnected\n", event.source_nodeid); + printf(" node %d\n", event.Disconnected.node); + break; + case NDB_LE_NDBStartCompleted: + printf("Node %d: StartCompleted\n", event.source_nodeid); + printf(" version %d.%d.%d\n", + event.NDBStartCompleted.version >> 16 & 0xff, + event.NDBStartCompleted.version >> 8 & 0xff, + event.NDBStartCompleted.version >> 0 & 0xff); + break; + case NDB_LE_ArbitState: + printf("Node %d: ArbitState\n", event.source_nodeid); + printf(" code %d, arbit_node %d\n", + event.ArbitState.code & 0xffff, + event.ArbitResult.arbit_node); + break; + default: - printf("Unexpected event\n"); break; } } } - ndb_mgm_destroy_logevent_handle(&l); + ndb_mgm_destroy_logevent_handle(&le); ndb_mgm_destroy_handle(&h); ndb_end(0); return 0; diff --git a/ndb/examples/ndbapi_async_example/ndbapi_async.cpp b/ndb/examples/ndbapi_async_example/ndbapi_async.cpp index 16731411c76..aa745f4d28d 100644 --- a/ndb/examples/ndbapi_async_example/ndbapi_async.cpp +++ b/ndb/examples/ndbapi_async_example/ndbapi_async.cpp @@ -57,16 +57,15 @@ /** * Helper sleep function */ -int +static void milliSleep(int milliseconds){ - int result = 0; - struct timespec sleeptime; + struct timeval sleeptime; sleeptime.tv_sec = milliseconds / 1000; - sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000; - result = nanosleep(&sleeptime, NULL); - return result; + sleeptime.tv_usec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000; + select(0, 0, 0, 0, &sleeptime); } + /** * error printout macro */ diff --git a/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp b/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp index bb19eaaf1d6..f0dc74bf3f5 100644 --- a/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp +++ b/ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp @@ -72,18 +72,17 @@ #include // Used for cout #include +#include /** * Helper sleep function */ -int +static void milliSleep(int milliseconds){ - int result = 0; - struct timespec sleeptime; + struct timeval sleeptime; sleeptime.tv_sec = milliseconds / 1000; - sleeptime.tv_nsec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000; - result = nanosleep(&sleeptime, NULL); - return result; + sleeptime.tv_usec = (milliseconds - (sleeptime.tv_sec * 1000)) * 1000000; + select(0, 0, 0, 0, &sleeptime); } diff --git a/ndb/include/mgmapi/ndb_logevent.h b/ndb/include/mgmapi/ndb_logevent.h index 3ca744bcc2e..d5744b0fffe 100644 --- a/ndb/include/mgmapi/ndb_logevent.h +++ b/ndb/include/mgmapi/ndb_logevent.h @@ -286,101 +286,125 @@ extern "C" { */ union { /* CONNECT */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } Connected; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } Disconnected; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } CommunicationClosed; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } CommunicationOpened; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; unsigned version; } ConnectedApiVersion; /* CHECKPOINT */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned gci; } GlobalCheckpointStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned gci; } GlobalCheckpointCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned lci; unsigned keep_gci; unsigned restore_gci; } LocalCheckpointStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned lci; } LocalCheckpointCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned data; } LCPStoppedInCalcKeepGci; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; unsigned table_id; unsigned fragment_id; } LCPFragmentCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned acc_count; unsigned tup_count; } UndoLogBlocked; /* STARTUP */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned version; } NDBStartStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned version; } NDBStartCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } STTORRYRecieved; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned phase; unsigned starttype; } StartPhaseCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned own_id; unsigned president_id; unsigned dynamic_id; } CM_REGCONF; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned own_id; unsigned other_id; unsigned cause; } CM_REGREF; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned own_id; unsigned left_id; unsigned right_id; unsigned dynamic_id; } FIND_NEIGHBOURS; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned stoptype; } NDBStopStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } NDBStopAborted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; unsigned keep_gci; unsigned completed_gci; unsigned restorable_gci; } StartREDOLog; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned log_part; unsigned start_mb; unsigned stop_mb; unsigned gci; } StartLog; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned block; unsigned data1; @@ -396,48 +420,70 @@ extern "C" { } UNDORecordsExecuted; /* NODERESTART */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } NR_CopyDict; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } NR_CopyDistr; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned dest_node; } NR_CopyFragsStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned dest_node; unsigned table_id; unsigned fragment_id; } NR_CopyFragDone; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned dest_node; } NR_CopyFragsCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned block; /* 0 = all */ unsigned failed_node; unsigned completing_node; /* 0 = all */ } NodeFailCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned failed_node; unsigned failure_state; } NODE_FAILREP; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { + unsigned code; /* code & state << 16 */ + unsigned arbit_node; + unsigned ticket_0; + unsigned ticket_1; /* TODO */ } ArbitState; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { + unsigned code; /* code & state << 16 */ + unsigned arbit_node; + unsigned ticket_0; + unsigned ticket_1; /* TODO */ } ArbitResult; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } GCP_TakeoverStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } GCP_TakeoverCompleted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { } LCP_TakeoverStarted; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned state; } LCP_TakeoverCompleted; /* STATISTIC */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned trans_count; unsigned commit_count; @@ -450,23 +496,29 @@ extern "C" { unsigned scan_count; unsigned range_scan_count; } TransReportCounters; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned ops; } OperationReportCounters; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned table_id; } TableCreated; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned mean_loop_count; } JobStatistic; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned to_node; unsigned mean_sent_bytes; } SendBytesStatistic; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned from_node; unsigned mean_received_bytes; } ReceiveBytesStatistic; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { int gth; unsigned page_size_kb; @@ -476,32 +528,40 @@ extern "C" { } MemoryUsage; /* ERROR */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned to_node; unsigned code; } TransporterError; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned to_node; unsigned code; } TransporterWarning; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; unsigned count; } MissedHeartbeat; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } DeadDueToHeartbeat; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { /* TODO */ } WarningEvent; /* INFO */ + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } SentHeartbeat; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { unsigned node; } CreateLogBytes; + /** Log event specific data for for corresponding NDB_LE_ log event */ struct { /* TODO */ } InfoEvent; diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index 43883cc91f2..d1c29adef4f 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -308,13 +308,6 @@ NdbRecAttr::arraySize() const return theArraySize; } -inline -Int64 -NdbRecAttr::int64_value() const -{ - return *(Int64*)theRef; -} - inline Int32 NdbRecAttr::int32_value() const @@ -336,13 +329,6 @@ NdbRecAttr::char_value() const return *(char*)theRef; } -inline -Uint64 -NdbRecAttr::u_64_value() const -{ - return *(Uint64*)theRef; -} - inline Uint32 NdbRecAttr::u_32_value() const @@ -364,20 +350,6 @@ NdbRecAttr::u_char_value() const return *(Uint8*)theRef; } -inline -float -NdbRecAttr::float_value() const -{ - return *(float*)theRef; -} - -inline -double -NdbRecAttr::double_value() const -{ - return *(double*)theRef; -} - inline void NdbRecAttr::release() diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 32a170d27a4..5a534b36b59 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -789,7 +789,8 @@ EventLogger::getText(char * dst, size_t dst_len, BaseString::snprintf(dst, dst_len, "Node %u: ", nodeId); pos= strlen(dst); } - textF(dst,dst_len,theData); + if (dst_len-pos > 0) + textF(dst+pos,dst_len-pos,theData); return dst; } diff --git a/ndb/src/common/util/strdup.c b/ndb/src/common/util/strdup.c index afe2306427e..d8f4d99bd28 100644 --- a/ndb/src/common/util/strdup.c +++ b/ndb/src/common/util/strdup.c @@ -21,8 +21,8 @@ char * strdup(const char *s){ void *p2; - p2 = malloc(strlen(s)+1); - strcpy(p2, s); + if ((p2 = malloc(strlen(s)+1))) + strcpy(p2, s); return p2; } #endif diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index b579c37c842..cf0b1419697 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -2976,6 +2976,8 @@ void Dbdih::execCOPY_FRAGREF(Signal* signal) SystemError * const sysErr = (SystemError*)&signal->theData[0]; sysErr->errorCode = SystemError::CopyFragRefError; sysErr->errorRef = reference(); + sysErr->data1 = errorCode; + sysErr->data2 = 0; sendSignal(cntrRef, GSN_SYSTEM_ERROR, signal, SystemError::SignalLength, JBB); return; @@ -4492,6 +4494,8 @@ void Dbdih::handleTakeOverNewMaster(Signal* signal, Uint32 takeOverPtrI) SystemError * const sysErr = (SystemError*)&signal->theData[0]; sysErr->errorCode = SystemError::CopyFragRefError; sysErr->errorRef = reference(); + sysErr->data1= 0; + sysErr->data2= __LINE__; sendSignal(cntrRef, GSN_SYSTEM_ERROR, signal, SystemError::SignalLength, JBB); } diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 2872960f90a..f7585ec3ab5 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -1158,7 +1158,7 @@ ndb_mgm_set_loglevel_node(NdbMgmHandle handle, int nodeId, int ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[], - int structured) + int parsable) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_listen_event"); const ParserRow stat_reply[] = { @@ -1181,7 +1181,8 @@ ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[], Properties args; - args.put("structured", structured); + if (parsable) + args.put("parsable", parsable); { BaseString tmp; for(int i = 0; filter[i] != 0; i += 2){ diff --git a/ndb/src/mgmapi/ndb_logevent.cpp b/ndb/src/mgmapi/ndb_logevent.cpp index 89ca9a50883..2817abcfdbb 100644 --- a/ndb/src/mgmapi/ndb_logevent.cpp +++ b/ndb/src/mgmapi/ndb_logevent.cpp @@ -197,10 +197,16 @@ struct Ndb_logevent_body_row ndb_logevent_body[]= { ROW( NODE_FAILREP, "failure_state", 2, failure_state), /* TODO */ -// ROW( ArbitState), + ROW( ArbitState, "code", 1, code), + ROW( ArbitState, "arbit_node", 2, arbit_node), + ROW( ArbitState, "ticket_0", 3, ticket_0), + ROW( ArbitState, "ticket_1", 4, ticket_1), /* TODO */ -// ROW( ArbitResult), + ROW( ArbitResult, "code", 1, code), + ROW( ArbitResult, "arbit_node", 2, arbit_node), + ROW( ArbitResult, "ticket_0", 3, ticket_0), + ROW( ArbitResult, "ticket_1", 4, ticket_1), // ROW( GCP_TakeoverStarted), diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index bb48f08dda0..286264e070f 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -389,7 +389,7 @@ CommandInterpreter::CommandInterpreter(const char *_host,int verbose) } m_mgmsrv2 = ndb_mgm_create_handle(); if(m_mgmsrv2 == NULL) { - ndbout_c("Cannot create handle to management server."); + ndbout_c("Cannot create 2:nd handle to management server."); exit(-1); } if (ndb_mgm_set_connectstring(m_mgmsrv, _host)) @@ -459,6 +459,8 @@ event_thread_run(void* m) my_thread_init(); + DBUG_ENTER("event_thread_run"); + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; int fd = ndb_mgm_listen_event(handle, filter); if (fd > 0) @@ -486,17 +488,20 @@ event_thread_run(void* m) bool CommandInterpreter::connect() { + DBUG_ENTER("CommandInterpreter::connect"); if(!m_connected) { if(!ndb_mgm_connect(m_mgmsrv, try_reconnect-1, 5, 1)) { const char *host= ndb_mgm_get_connected_host(m_mgmsrv); unsigned port= ndb_mgm_get_connected_port(m_mgmsrv); - if(!ndb_mgm_set_connectstring(m_mgmsrv2, - BaseString(host).appfmt(":%d",port).c_str()) - && + BaseString constr; + constr.assfmt("%s:%d",host,port); + if(!ndb_mgm_set_connectstring(m_mgmsrv2, constr.c_str()) && !ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1)) { + DBUG_PRINT("info",("2:ndb connected to Management Server ok at: %s:%d", + host, port)); assert(m_event_thread == 0); assert(do_event_thread == 0); do_event_thread= 0; @@ -507,6 +512,7 @@ CommandInterpreter::connect() NDB_THREAD_PRIO_LOW); if (m_event_thread != 0) { + DBUG_PRINT("info",("Thread created ok, waiting for started...")); int iter= 1000; // try for 30 seconds while(do_event_thread == 0 && iter-- > 0) @@ -516,15 +522,25 @@ CommandInterpreter::connect() do_event_thread == 0 || do_event_thread == -1) { + DBUG_PRINT("warning",("thread not started")); printf("Warning, event thread startup failed, degraded printouts as result\n"); do_event_thread= 0; } } else { + DBUG_PRINT("warning", + ("Could not do 2:nd connect to mgmtserver for event listening")); + DBUG_PRINT("info", ("code: %d, msg: %s", + ndb_mgm_get_latest_error(m_mgmsrv2), + ndb_mgm_get_latest_error_msg(m_mgmsrv2))); printf("Warning, event connect failed, degraded printouts as result\n"); + printf("code: %d, msg: %s\n", + ndb_mgm_get_latest_error(m_mgmsrv2), + ndb_mgm_get_latest_error_msg(m_mgmsrv2)); } m_connected= true; + DBUG_PRINT("info",("Connected to Management Server at: %s:%d", host, port)); if (m_verbose) { printf("Connected to Management Server at: %s:%d\n", @@ -532,7 +548,7 @@ CommandInterpreter::connect() } } } - return m_connected; + DBUG_RETURN(m_connected); } bool diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 57f896e7e42..30ba5c112fa 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -281,3 +281,35 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) return out; } + +Int64 +NdbRecAttr::int64_value() const +{ + Int64 val; + memcpy(&val,theRef,8); + return val; +} + +Uint64 +NdbRecAttr::u_64_value() const +{ + Uint64 val; + memcpy(&val,theRef,8); + return val; +} + +float +NdbRecAttr::float_value() const +{ + float val; + memcpy(&val,theRef,sizeof(val)); + return val; +} + +double +NdbRecAttr::double_value() const +{ + double val; + memcpy(&val,theRef,sizeof(val)); + return val; +} diff --git a/ndb/test/ndbapi/flexAsynch.cpp b/ndb/test/ndbapi/flexAsynch.cpp index fc50cc99acf..d840993470c 100644 --- a/ndb/test/ndbapi/flexAsynch.cpp +++ b/ndb/test/ndbapi/flexAsynch.cpp @@ -16,6 +16,7 @@ +#include #include "NdbApi.hpp" #include #include diff --git a/ndb/test/ndbapi/flexBench.cpp b/ndb/test/ndbapi/flexBench.cpp index 71ceb468a63..728188ab28d 100644 --- a/ndb/test/ndbapi/flexBench.cpp +++ b/ndb/test/ndbapi/flexBench.cpp @@ -49,6 +49,7 @@ Arguments: * *************************************************** */ +#include #include "NdbApi.hpp" #include diff --git a/ndb/test/ndbapi/flexHammer.cpp b/ndb/test/ndbapi/flexHammer.cpp index aa783d00d20..49629dac875 100644 --- a/ndb/test/ndbapi/flexHammer.cpp +++ b/ndb/test/ndbapi/flexHammer.cpp @@ -47,6 +47,7 @@ Revision history: * *************************************************** */ +#include #include #include diff --git a/ndb/test/ndbapi/slow_select.cpp b/ndb/test/ndbapi/slow_select.cpp index 3febae2c8eb..8d615fa5771 100644 --- a/ndb/test/ndbapi/slow_select.cpp +++ b/ndb/test/ndbapi/slow_select.cpp @@ -1,4 +1,5 @@ +#include #include #include #include diff --git a/ndb/test/run-test/atrt-mysql-test-run b/ndb/test/run-test/atrt-mysql-test-run index c30a4defc7f..2ebc11b0070 100755 --- a/ndb/test/run-test/atrt-mysql-test-run +++ b/ndb/test/run-test/atrt-mysql-test-run @@ -5,8 +5,8 @@ p=`pwd` cd $MYSQL_BASE_DIR/mysql-test ./mysql-test-run --with-ndbcluster --ndb-connectstring=$NDB_CONNECTSTRING $* | tee $p/output.txt -f=`grep -c '[ fail ]' $p/output.txt` -o=`grep -c '[ pass ]' $p/output.txt` +f=`grep -c '\[ fail \]' $p/output.txt` +o=`grep -c '\[ pass \]' $p/output.txt` if [ $o -gt 0 -a $f -eq 0 ] then diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index ae195cc0c0c..89675acb59f 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -1,3 +1,11 @@ +max-time: 25000 +cmd: atrt-mysql-test-run +args: --force + +max-time: 600 +cmd: atrt-testBackup +args: -n BackupOne T1 T6 T3 I3 + # BASIC FUNCTIONALITY max-time: 500 cmd: testBasic diff --git a/ndb/test/run-test/daily-devel-tests.txt b/ndb/test/run-test/daily-devel-tests.txt index 9527df600f0..5c9b36fb836 100644 --- a/ndb/test/run-test/daily-devel-tests.txt +++ b/ndb/test/run-test/daily-devel-tests.txt @@ -1,7 +1,3 @@ -max-time: 25000 -cmd: atrt-mysql-test-run -args: --force - # # INDEX # @@ -22,10 +18,6 @@ args: -n CreateLoadDrop T1 T10 # # BACKUP # -max-time: 600 -cmd: atrt-testBackup -args: -n BackupOne T1 T6 T3 I3 - max-time: 1000 cmd: atrt-testBackup args: -n BackupBank T6 diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 2fee787bbed..44edb34295a 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -14,6 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include "HugoCalculator.hpp" #include #include diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 69f9092f1fd..f246f70b8c4 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -126,6 +126,8 @@ else client/.libs/mysqltest client/.libs/mysqlcheck \ client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \ client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \ + tests/.libs/mysql_client_test libmysqld/examples/mysql_client_test_embedded \ + libmysqld/examples/mysqltest_embedded \ "; fi @@ -186,7 +188,7 @@ fi if [ $BASE_SYSTEM != "netware" ] ; then if [ -d tests ] ; then - $CP tests/client_test tests/*.res tests/*.tst tests/*.pl $BASE/tests + $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests fi if [ -d man ] ; then $CP man/*.1 $BASE/man/man1 diff --git a/sql/field.cc b/sql/field.cc index a1dc02eba4a..7d0e69681c0 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -117,7 +117,7 @@ bool Field::check_int(const char *str, int length, const char *int_end, { if (!my_isspace(cs,*str)) { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); return 1; } } @@ -662,7 +662,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) from++; if (from == end) { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); is_cuted_fields_incr=1; } else if (*from == '+' || *from == '-') // Found some sign ? @@ -738,7 +738,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) for (;from != end && my_isspace(&my_charset_bin, *from); from++) ; if (from != end) // If still something left, warn { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); is_cuted_fields_incr=1; } } @@ -917,7 +917,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) { if (!is_cuted_fields_incr) set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + WARN_DATA_TRUNCATED, 1); return 0; } continue; @@ -939,7 +939,7 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) This is a note, not a warning, as we don't want to abort when we cut decimals in strict mode */ - set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); } return 0; } @@ -2367,8 +2367,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs) table->in_use->count_cuted_fields)) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - (error ? ER_WARN_DATA_OUT_OF_RANGE : ER_WARN_DATA_TRUNCATED), - 1); + (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); error= 1; } Field_float::store(nr); @@ -2656,8 +2655,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs) table->in_use->count_cuted_fields)) { set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - (error ? ER_WARN_DATA_OUT_OF_RANGE : ER_WARN_DATA_TRUNCATED), - 1); + (error ? ER_WARN_DATA_OUT_OF_RANGE : WARN_DATA_TRUNCATED), 1); error= 1; } Field_double::store(nr); @@ -3024,7 +3022,7 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs) if (error || !have_smth_to_conv) { error= 1; - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_DATETIME, 1); } @@ -3104,7 +3102,7 @@ int Field_timestamp::store(longlong nr) } else if (error) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, + WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN @@ -3337,14 +3335,14 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs) { tmp=0L; error= 1; - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_TIME, 1); } else { if (error) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, + WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_TIME, 1); if (ltime.month) @@ -3700,7 +3698,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs) tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day); if (error) - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_DATE, 1); #ifdef WORDS_BIGENDIAN @@ -3896,7 +3894,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs) tmp= l_time.day + l_time.month*32 + l_time.year*16*32; if (error) - set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, from, len, MYSQL_TIMESTAMP_DATE, 1); int3store(ptr,tmp); @@ -3909,7 +3907,7 @@ int Field_newdate::store(double nr) { (void) Field_newdate::store((longlong) -1); set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE); + WARN_DATA_TRUNCATED, nr, MYSQL_TIMESTAMP_DATE); return 1; } else @@ -3968,7 +3966,7 @@ int Field_newdate::store_time(TIME *ltime,timestamp_type type) { tmp=0; error= 1; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } int3store(ptr,tmp); return error; @@ -4124,7 +4122,7 @@ int Field_datetime::store(longlong nr) if (error) set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, initial_nr, + WARN_DATA_TRUNCATED, initial_nr, MYSQL_TIMESTAMP_DATETIME, 1); #ifdef WORDS_BIGENDIAN @@ -4154,7 +4152,7 @@ int Field_datetime::store_time(TIME *ltime,timestamp_type type) { tmp=0; error= 1; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } #ifdef WORDS_BIGENDIAN if (table->s->db_low_byte_first) @@ -4370,8 +4368,12 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) error= 1; } if (error) - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); - + { + if (table->in_use->abort_on_warning) + set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); + else + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + } return error; } @@ -4724,7 +4726,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) error= 1; } if (error) - set_warning(level, ER_WARN_DATA_TRUNCATED, 1); + set_warning(level, WARN_DATA_TRUNCATED, 1); return error; } @@ -5325,7 +5327,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) bmove(ptr+packlength,(char*) &from,sizeof(char*)); } if (error) - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); return 0; } @@ -5911,11 +5913,11 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) if (err || end != from+length || tmp > typelib->count) { tmp=0; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } } else - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } store_type((ulonglong) tmp); return err; @@ -5933,7 +5935,7 @@ int Field_enum::store(longlong nr) int error= 0; if ((uint) nr > typelib->count || nr == 0) { - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); nr=0; error=1; } @@ -6092,11 +6094,11 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs) tmp > (ulonglong) (((longlong) 1 << typelib->count) - (longlong) 1)) { tmp=0; - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } } else if (got_warning) - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); store_type(tmp); return err; } @@ -6109,7 +6111,7 @@ int Field_set::store(longlong nr) (longlong) 1)) { nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1); - set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); + set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); error=1; } store_type((ulonglong) nr); diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 07cc90283b7..002f059f70b 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -121,8 +121,7 @@ set_field_to_null(Field *field) field->reset(); if (current_thd->count_cuted_fields == CHECK_FIELD_WARN) { - field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); return 0; } if (!current_thd->no_errors) @@ -230,7 +229,7 @@ static void do_copy_not_null(Copy_field *copy) if (*copy->from_null_ptr & copy->from_bit) { copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + WARN_DATA_TRUNCATED, 1); copy->to_field->reset(); } else @@ -336,7 +335,7 @@ static void do_cut_string(Copy_field *copy) if (!my_isspace(system_charset_info, *ptr)) // QQ: ucs incompatible { copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + WARN_DATA_TRUNCATED, 1); break; } } @@ -360,7 +359,7 @@ static void do_varstring1(Copy_field *copy) length=copy->to_length - 1; if (current_thd->count_cuted_fields) copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + WARN_DATA_TRUNCATED, 1); } *(uchar*) copy->to_ptr= (uchar) length; memcpy(copy->to_ptr+1, copy->from_ptr + 1, length); @@ -375,7 +374,7 @@ static void do_varstring2(Copy_field *copy) length=copy->to_length-HA_KEY_BLOB_LENGTH; if (current_thd->count_cuted_fields) copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, - ER_WARN_DATA_TRUNCATED, 1); + WARN_DATA_TRUNCATED, 1); } int2store(copy->to_ptr,length); memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH, diff --git a/sql/item_create.cc b/sql/item_create.cc index cec6de3eede..8a5aeb6c9b7 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -358,22 +358,19 @@ Item *create_func_sin(Item* a) Item *create_func_sha(Item* a) { - return new Item_func_sha(a); + return new Item_func_sha(a); } - + Item *create_func_space(Item *a) { CHARSET_INFO *cs= current_thd->variables.collation_connection; Item *sp; - + if (cs->mbminlen > 1) { + uint dummy_errors; sp= new Item_string("",0,cs); - if (sp) - { - uint dummy_errors; - sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); - } + sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); } else { diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 5d018b22055..f9843692b7b 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2519,6 +2519,9 @@ String* Item_func_export_set::val_str(String* str) case 3: sep_buf.set(",", 1, default_charset()); sep = &sep_buf; + break; + default: + DBUG_ASSERT(0); // cannot happen } null_value=0; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0c1cd3cbad3..32813454fef 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2131,20 +2131,25 @@ void Item_char_typecast::print(String *str) String *Item_char_typecast::val_str(String *str) { DBUG_ASSERT(fixed == 1); - String *res, *res1; + String *res; uint32 length; - if (!charset_conversion && !(res= args[0]->val_str(str))) +#if 0 + if (!charset_conversion) { - null_value= 1; - return 0; + if (!(res= args[0]->val_str(str))) + { + null_value= 1; + return 0; + } } else +#endif { // Convert character set if differ uint dummy_errors; - if (!(res1= args[0]->val_str(&tmp_value)) || - str->copy(res1->ptr(), res1->length(), res1->charset(), + if (!(res= args[0]->val_str(&tmp_value)) || + str->copy(res->ptr(), res->length(), res->charset(), cast_cs, &dummy_errors)) { null_value= 1; @@ -2154,13 +2159,13 @@ String *Item_char_typecast::val_str(String *str) } res->set_charset(cast_cs); - + /* Cut the tail if cast with length and the result is longer than cast length, e.g. CAST('string' AS CHAR(1)) */ - if (cast_length >= 0 && + if (cast_length >= 0 && (res->length() > (length= (uint32) res->charpos(cast_length)))) { // Safe even if const arg if (!res->alloced_length()) @@ -2169,7 +2174,7 @@ String *Item_char_typecast::val_str(String *str) res= &str_value; } res->length((uint) length); - } + } null_value= 0; return res; } diff --git a/sql/log.cc b/sql/log.cc index d57a6b49762..6c97581d144 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2257,9 +2257,9 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, DBUG_ENTER("print_buffer_to_nt_eventlog"); buffptr= buff; - if (length > (uint)(buffLen-4)) + if (length > (uint)(buffLen-5)) { - char *newBuff= new char[length + 4]; + char *newBuff= new char[length + 5]; strcpy(newBuff, buff); buffptr= newBuff; } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 322b38abe13..5a222a1ce10 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1064,7 +1064,6 @@ extern struct system_variables global_system_variables; extern struct system_variables max_system_variables; extern struct system_status_var global_status_var; extern struct rand_struct sql_rand; -extern KEY_CACHE *sql_key_cache; extern const char *opt_date_time_formats[]; extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 58bcbfd641c..db18c275a4d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -395,7 +395,6 @@ struct system_status_var global_status_var; MY_TMPDIR mysql_tmpdir_list; MY_BITMAP temp_pool; -KEY_CACHE *sql_key_cache; CHARSET_INFO *system_charset_info, *files_charset_info ; CHARSET_INFO *national_charset_info, *table_alias_charset; @@ -1867,14 +1866,14 @@ We will try our best to scrape up some info that will hopefully help diagnose\n\ the problem, but since we have already crashed, something is definitely wrong\n\ and this may fail.\n\n"); fprintf(stderr, "key_buffer_size=%lu\n", - (ulong) sql_key_cache->key_cache_mem_size); + (ulong) dflt_key_cache->key_cache_mem_size); fprintf(stderr, "read_buffer_size=%ld\n", global_system_variables.read_buff_size); fprintf(stderr, "max_used_connections=%ld\n", max_used_connections); fprintf(stderr, "max_connections=%ld\n", max_connections); fprintf(stderr, "threads_connected=%d\n", thread_count); fprintf(stderr, "It is possible that mysqld could use up to \n\ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = %ld K\n\ -bytes of memory\n", ((ulong) sql_key_cache->key_cache_mem_size + +bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + (global_system_variables.read_buff_size + global_system_variables.sortbuff_size) * max_connections)/ 1024); @@ -2141,12 +2140,12 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) case SIGHUP: if (!abort_loop) { + mysql_print_status((THD*) 0); // Print some debug info reload_acl_and_cache((THD*) 0, (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | REFRESH_GRANT | REFRESH_THREADS | REFRESH_HOSTS), (TABLE_LIST*) 0, NULL); // Flush logs - mysql_print_status((THD*) 0); // Send debug some info } break; #ifdef USE_ONE_SIGNAL_HAND @@ -2820,8 +2819,6 @@ server."); /* call ha_init_key_cache() on all key caches to init them */ process_key_caches(&ha_init_key_cache); - /* We must set dflt_key_cache in case we are using ISAM tables */ - dflt_key_cache= sql_key_cache; #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && !defined(EMBEDDED_LIBRARY) if (locked_in_memory && !getuid()) @@ -3034,6 +3031,18 @@ You should consider changing lower_case_table_names to 1 or 2", lower_case_table_names= 2; } } + else if (lower_case_table_names == 2 && + !(lower_case_file_system= + (test_if_case_insensitive(mysql_real_data_home) == 1))) + { + if (global_system_variables.log_warnings) + sql_print_warning("\ +You have forced lower_case_table_names to 2 through a command-line \ +option, even though your file system '%s' is case sensitive. This means \ +that you can create a table that you can then no longer access. \ +You should consider changing lower_case_table_names to 0.", + mysql_real_data_home); + } select_thread=pthread_self(); select_thread_in_use=1; @@ -5882,10 +5891,10 @@ static void mysql_init_variables(void) threads.empty(); thread_cache.empty(); key_caches.empty(); - multi_keycache_init(); - if (!(sql_key_cache= get_or_create_key_cache(default_key_cache_base.str, + if (!(dflt_key_cache= get_or_create_key_cache(default_key_cache_base.str, default_key_cache_base.length))) exit(1); + multi_keycache_init(); /* set key_cache_hash.default_value = dflt_key_cache */ /* Initialize structures that is used when processing options */ replicate_rewrite_db.empty(); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e67a9881bba..c3b84564504 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -778,6 +778,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() DBUG_PRINT("info", ("Freeing separate handler %p (free=%d)", file, free_file)); file->reset(); + file->external_lock(current_thd, F_UNLCK); file->close(); } } @@ -929,6 +930,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) DBUG_RETURN(0); } + THD *thd= current_thd; if (!(file= get_new_handler(head, head->s->db_type))) goto failure; DBUG_PRINT("info", ("Allocated new handler %p", file)); @@ -937,11 +939,14 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) /* Caller will free the memory */ goto failure; } + if (file->external_lock(thd, F_RDLCK)) + goto failure; if (file->extra(HA_EXTRA_KEYREAD) || file->extra(HA_EXTRA_RETRIEVE_PRIMARY_KEY) || init() || reset()) { + file->external_lock(thd, F_UNLCK); file->close(); goto failure; } diff --git a/sql/set_var.cc b/sql/set_var.cc index 6cbf305e856..552d2692c3c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2238,7 +2238,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) if (!tmp) // Zero size means delete { - if (key_cache == sql_key_cache) + if (key_cache == dflt_key_cache) goto end; // Ignore default key cache if (key_cache->key_cache_inited) // If initied @@ -2252,7 +2252,7 @@ bool sys_var_key_buffer_size::update(THD *thd, set_var *var) base_name->length, &list); key_cache->in_init= 1; pthread_mutex_unlock(&LOCK_global_system_variables); - error= reassign_keycache_tables(thd, key_cache, sql_key_cache); + error= reassign_keycache_tables(thd, key_cache, dflt_key_cache); pthread_mutex_lock(&LOCK_global_system_variables); key_cache->in_init= 0; } @@ -3039,8 +3039,8 @@ int set_var_password::check(THD *thd) if (!user->host.str) user->host.str= (char*) thd->host_or_ip; /* Returns 1 as the function sends error to client */ - return check_change_password(thd, user->host.str, user->user.str, password) ? - 1 : 0; + return check_change_password(thd, user->host.str, user->user.str, + password, strlen(password)) ? 1 : 0; #else return 0; #endif diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 3cdcef7c8ee..7826be85679 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -4900,7 +4900,7 @@ ER_WARN_DATA_OUT_OF_RANGE 22003 ger "Daten abgeschnitten, außerhalb des Wertebereichs für Spalte '%s' in Zeile %ld" por "Dado truncado, fora de alcance para coluna '%s' na linha %ld" spa "Datos truncados, fuera de gama para columna '%s' en la línea %ld" -ER_WARN_DATA_TRUNCATED 01000 +WARN_DATA_TRUNCATED 01000 eng "Data truncated for column '%s' at row %ld" ger "Daten abgeschnitten für Spalte '%s' in Zeile %ld" por "Dado truncado para coluna '%s' na linha %ld" @@ -5312,3 +5312,5 @@ ER_PROC_AUTO_GRANT_FAIL eng "Failed to grant EXECUTE and ALTER ROUTINE privileges" ER_PROC_AUTO_REVOKE_FAIL eng "Failed to revoke all privileges to dropped routine" +ER_DATA_TOO_LONG 22001 + eng "Data too long for column '%s' at row %ld" diff --git a/sql/slave.cc b/sql/slave.cc index 5332dbf9c5b..0c5ebe0744a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2610,18 +2610,19 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, init_abort_pos_wait= abort_pos_wait; /* - We'll need to + We'll need to handle all possible log names comparisons (e.g. 999 vs 1000). - We use ulong for string->number conversion ; this is no + We use ulong for string->number conversion ; this is no stronger limitation than in find_uniq_filename in sql/log.cc */ ulong log_name_extension; char log_name_tmp[FN_REFLEN]; //make a char[] from String - char *end= strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), - FN_REFLEN-1)); + + strmake(log_name_tmp, log_name->ptr(), min(log_name->length(), FN_REFLEN-1)); + char *p= fn_ext(log_name_tmp); char *p_end; - if (!*p || log_pos<0) + if (!*p || log_pos<0) { error= -2; //means improper arguments goto err; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index bcad0e627f4..f9d95b2cde5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -1240,6 +1240,10 @@ bool acl_check_host(const char *host, const char *ip) thd THD host hostname for the user user user name + new_password new password + + NOTE: + new_password cannot be NULL RETURN VALUE 0 OK @@ -1247,7 +1251,7 @@ bool acl_check_host(const char *host, const char *ip) */ bool check_change_password(THD *thd, const char *host, const char *user, - char *new_password) + char *new_password, uint new_password_len) { if (!initialized) { @@ -1296,12 +1300,13 @@ bool check_change_password(THD *thd, const char *host, const char *user, bool change_password(THD *thd, const char *host, const char *user, char *new_password) { + uint new_password_len= strlen(new_password); DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", host,user,new_password)); DBUG_ASSERT(host != 0); // Ensured by parent - if (check_change_password(thd, host, user, new_password)) + if (check_change_password(thd, host, user, new_password, new_password_len)) DBUG_RETURN(1); VOID(pthread_mutex_lock(&acl_cache->lock)); @@ -1313,7 +1318,6 @@ bool change_password(THD *thd, const char *host, const char *user, DBUG_RETURN(1); } /* update loaded acl entry: */ - uint new_password_len= new_password ? strlen(new_password) : 0; set_user_salt(acl_user, new_password, new_password_len); if (update_user_table(thd, @@ -3241,7 +3245,7 @@ end: SYNOPSIS grant_reload() - thd Thread handler + thd Thread handler (can be NULL) NOTES Locked tables are checked by acl_init and doesn't have to be checked here diff --git a/sql/sql_acl.h b/sql/sql_acl.h index b129ffcdcf8..3a9df84a35d 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -176,7 +176,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, const char *passwd, int acl_getroot_no_password(THD *thd); bool acl_check_host(const char *host, const char *ip); bool check_change_password(THD *thd, const char *host, const char *user, - char *password); + char *password, uint password_len); bool change_password(THD *thd, const char *host, const char *user, char *password); bool mysql_grant(THD *thd, const char *db, List &user_list, diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 6a9a9e51231..ce58c585061 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -70,6 +70,9 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, field_info **f_info; DBUG_ENTER("proc_analyse_init"); + if (!pc) + DBUG_RETURN(0); + if (!(param = param->next)) { pc->max_tree_elements = MAX_TREE_ELEMENTS; @@ -81,33 +84,30 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val_real() < 0) { - delete pc; my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); - DBUG_RETURN(0); + goto err; } pc->max_tree_elements = (uint) (*param->item)->val_int(); param = param->next; if (param->next) // no third parameter possible { my_error(ER_WRONG_PARAMCOUNT_TO_PROCEDURE, MYF(0), proc_name); - DBUG_RETURN(0); + goto err; } // second parameter if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val_real() < 0) { - delete pc; my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); - DBUG_RETURN(0); + goto err; } pc->max_treemem = (uint) (*param->item)->val_int(); } else if ((*param->item)->type() != Item::INT_ITEM || (*param->item)->val_real() < 0) { - delete pc; my_error(ER_WRONG_PARAMETERS_TO_PROCEDURE, MYF(0), proc_name); - DBUG_RETURN(0); + goto err; } // if only one parameter was given, it will be the value of max_tree_elements else @@ -116,34 +116,39 @@ proc_analyse_init(THD *thd, ORDER *param, select_result *result, pc->max_treemem = MAX_TREEMEM; } - if (!pc || !(pc->f_info = (field_info**) - sql_alloc(sizeof(field_info*)*field_list.elements))) - DBUG_RETURN(0); + if (!(pc->f_info= + (field_info**)sql_alloc(sizeof(field_info*)*field_list.elements))) + goto err; pc->f_end = pc->f_info + field_list.elements; pc->fields = field_list; - List_iterator_fast it(pc->fields); - f_info = pc->f_info; - - Item *item; - while ((item = it++)) { - if (item->result_type() == INT_RESULT) + List_iterator_fast it(pc->fields); + f_info = pc->f_info; + + Item *item; + while ((item = it++)) { - // Check if fieldtype is ulonglong - if (item->type() == Item::FIELD_ITEM && - ((Item_field*) item)->field->type() == FIELD_TYPE_LONGLONG && - ((Field_longlong*) ((Item_field*) item)->field)->unsigned_flag) - *f_info++ = new field_ulonglong(item, pc); - else - *f_info++ = new field_longlong(item, pc); + if (item->result_type() == INT_RESULT) + { + // Check if fieldtype is ulonglong + if (item->type() == Item::FIELD_ITEM && + ((Item_field*) item)->field->type() == FIELD_TYPE_LONGLONG && + ((Field_longlong*) ((Item_field*) item)->field)->unsigned_flag) + *f_info++ = new field_ulonglong(item, pc); + else + *f_info++ = new field_longlong(item, pc); + } + if (item->result_type() == REAL_RESULT) + *f_info++ = new field_real(item, pc); + if (item->result_type() == STRING_RESULT) + *f_info++ = new field_str(item, pc); } - if (item->result_type() == REAL_RESULT) - *f_info++ = new field_real(item, pc); - if (item->result_type() == STRING_RESULT) - *f_info++ = new field_str(item, pc); } DBUG_RETURN(pc); +err: + delete pc; + DBUG_RETURN(0); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fc41643e8d4..3fb2fac5b27 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -261,13 +261,19 @@ void free_io_cache(TABLE *table) DBUG_VOID_RETURN; } - /* Close all tables which aren't in use by any thread */ +/* + Close all tables which aren't in use by any thread + + THD can be NULL, but then if_wait_for_refresh must be FALSE + and tables must be NULL. +*/ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, TABLE_LIST *tables) { bool result=0; DBUG_ENTER("close_cached_tables"); + DBUG_ASSERT(thd || (!if_wait_for_refresh && !tables)); VOID(pthread_mutex_lock(&LOCK_open)); if (!tables) @@ -343,7 +349,6 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, VOID(pthread_mutex_unlock(&LOCK_open)); if (if_wait_for_refresh) { - THD *thd=current_thd; pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; thd->mysys_var->current_cond= 0; @@ -2401,11 +2406,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables, strxnmov(buff,sizeof(buff)-1,db,".",table_name,NullS); table_name=buff; } - if (report_error == REPORT_ALL_ERRORS || - report_error == REPORT_EXCEPT_NON_UNIQUE) - my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where); - else - return (Field*) not_found_field; + my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, thd->where); } else if (report_error == REPORT_ALL_ERRORS || diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f4345f8ce28..c08d3eae0e1 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1164,12 +1164,12 @@ void Query_cache::invalidate(THD *thd, TABLE_LIST *tables_used, DBUG_ASSERT(!using_transactions || tables_used->table!=0); if (tables_used->derived) continue; - if (using_transactions && - (tables_used->table->file->table_cache_type() == + if (using_transactions && + (tables_used->table->file->table_cache_type() == HA_CACHE_TBL_TRANSACT)) - /* + /* Tables_used->table can't be 0 in transaction. - Only 'drop' invalidate not opened table, but 'drop' + Only 'drop' invalidate not opened table, but 'drop' force transaction finish. */ thd->add_changed_table(tables_used->table); @@ -1217,7 +1217,7 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used) */ void Query_cache::invalidate_locked_for_write(TABLE_LIST *tables_used) { - DBUG_ENTER("Query_cache::invalidate (changed table list)"); + DBUG_ENTER("Query_cache::invalidate_locked_for_write"); if (query_cache_size > 0 && tables_used) { STRUCT_LOCK(&structure_guard_mutex); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 26929ebc432..cbd4f9049d3 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -227,7 +227,7 @@ void del_dbopt(const char *path) } -/* +/* Create database options file: DESCRIPTION @@ -246,10 +246,10 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) if (!create->default_table_charset) create->default_table_charset= thd->variables.collation_server; - + if (put_dbopt(path, create)) return 1; - + if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { ulong length; @@ -531,21 +531,21 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) if ((error=write_db_opt(thd, path, create_info))) goto exit; - /* + /* Change options if current database is being altered TODO: Delete this code */ if (thd->db && !strcmp(thd->db,db)) { - thd->db_charset= (create_info && create_info->default_table_charset) ? - create_info->default_table_charset : + thd->db_charset= create_info->default_table_charset ? + create_info->default_table_charset : thd->variables.collation_server; thd->variables.collation_database= thd->db_charset; } if (mysql_bin_log.is_open()) { - Query_log_event qinfo(thd, thd->query, thd->query_length, 0, + Query_log_event qinfo(thd, thd->query, thd->query_length, 0, /* suppress_use */ TRUE); /* @@ -627,12 +627,12 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) pthread_mutex_lock(&LOCK_open); remove_db_from_cache(db); pthread_mutex_unlock(&LOCK_open); - + error= -1; if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0)) >= 0) { ha_drop_database(path); - query_cache_invalidate1(db); + query_cache_invalidate1(db); error = 0; } } @@ -643,7 +643,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) my_casedn_str(files_charset_info, tmp_db); db= tmp_db; } - if (!silent && deleted>=0 && thd) + if (!silent && deleted>=0) { const char *query; ulong query_length; @@ -693,7 +693,7 @@ exit: have 'if (data_buf) free(data_buf)' data_buf is !=0 so this makes a DOUBLE free(). Side effects of this double free() are, randomly (depends on the machine), - when the slave is replicating a DROP DATABASE: + when the slave is replicating a DROP DATABASE: - garbage characters in the error message: "Error 'Can't drop database 'test2'; database doesn't exist' on query 'h4zI©'" diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 2f6e74225fd..43e82ff57c9 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1603,9 +1603,6 @@ void st_select_lex::print_limit(THD *thd, String *str) return; } - if (!thd) - thd= current_thd; - if (explicit_limit) { str->append(" limit ", 7); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b7a75a0bdd6..c0bcaf771a5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -897,14 +897,16 @@ static int check_connection(THD *thd) char *user= end; char *passwd= strend(user)+1; char *db= passwd; - char db_buff[NAME_LEN+1]; // buffer to store db in utf8 + char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char user_buff[USERNAME_LENGTH+1]; // buffer to store user in utf8 - /* + uint dummy_errors; + + /* Old clients send null-terminated string as password; new clients send the size (1 byte) + string (not null-terminated). Hence in case of empty password both send '\0'. */ - uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? + uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? *passwd++ : strlen(passwd); db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? db + passwd_len + 1 : 0; @@ -912,7 +914,6 @@ static int check_connection(THD *thd) /* Since 4.1 all database names are stored in utf8 */ if (db) { - uint dummy_errors; db_buff[copy_and_convert(db_buff, sizeof(db_buff)-1, system_charset_info, db, strlen(db), @@ -920,14 +921,10 @@ static int check_connection(THD *thd) db= db_buff; } - if (user) - { - uint dummy_errors; - user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1, - system_charset_info, user, strlen(user), - thd->charset(), &dummy_errors)]= '\0'; - user= user_buff; - } + user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1, + system_charset_info, user, strlen(user), + thd->charset(), &dummy_errors)]= '\0'; + user= user_buff; if (thd->user) x_free(thd->user); @@ -3349,12 +3346,12 @@ unsent_create_error: /* If in a slave thread : ALTER DATABASE DB may not be preceded by USE DB. - For that reason, maybe db_ok() in sql/slave.cc did not check the + For that reason, maybe db_ok() in sql/slave.cc did not check the do_db/ignore_db. And as this query involves no tables, tables_ok() above was not called. So we have to check rules again here. */ #ifdef HAVE_REPLICATION - if (thd->slave_thread && + if (thd->slave_thread && (!db_ok(db, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(db))) { @@ -3467,8 +3464,7 @@ unsent_create_error: case SQLCOM_GRANT: { if (check_access(thd, lex->grant | lex->grant_tot_col | GRANT_ACL, - ((first_table && first_table->db) ? - first_table->db : select_lex->db), + first_table ? first_table->db : select_lex->db, first_table ? &first_table->grant.privilege : 0, first_table ? 0 : 1, 0)) goto error; @@ -5381,7 +5377,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, Initialize a new table list for a nested join SYNOPSIS - init_table_list() + init_nested_join() thd current thread DESCRIPTION @@ -5867,6 +5863,7 @@ void kill_one_thread(THD *thd, ulong id, bool only_kill_query) my_error(error, MYF(0), id); } + /* Clear most status variables */ static void refresh_status(void) @@ -5876,17 +5873,6 @@ static void refresh_status(void) { if (ptr->type == SHOW_LONG) *(ulong*) ptr->value= 0; - else if (ptr->type == SHOW_KEY_CACHE_LONG) - { - /* - Reset value in 'default' key cache. - This needs to be recoded when we have thread specific key values - */ - char *value= (((char*) sql_key_cache) + - (uint) ((char*) (ptr->value) - - (char*) &dflt_key_cache_var)); - *(ulong*) value= 0; - } else if (ptr->type == SHOW_LONG_STATUS) { THD *thd= current_thd; @@ -5895,6 +5881,8 @@ static void refresh_status(void) bzero((char*) &thd->status_var, sizeof(thd->status_var)); } } + /* Reset the counters of all key caches (default and named). */ + process_key_caches(reset_key_cache_counters); pthread_mutex_unlock(&LOCK_status); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index dba0b844de7..acb7d8f48f1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -4473,9 +4473,15 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, x = used key parts (1 <= x <= c) */ double rec_per_key; +#if 0 if (!(rec_per_key=(double) keyinfo->rec_per_key[keyinfo->key_parts-1])) rec_per_key=(double) s->records/rec+1; +#else + rec_per_key= keyinfo->rec_per_key[keyinfo->key_parts-1] ? + (double) keyinfo->rec_per_key[keyinfo->key_parts-1] : + (double) s->records/rec+1; +#endif if (!s->records) tmp=0; @@ -10768,13 +10774,14 @@ remove_duplicates(JOIN *join, TABLE *entry,List &fields, Item *having) field_count++; } - if (!field_count) - { // only const items + if (!field_count && !(join->select_options & OPTION_FOUND_ROWS)) + { // only const items with no OPTION_FOUND_ROWS join->unit->select_limit_cnt= 1; // Only send first row DBUG_RETURN(0); } Field **first_field=entry->field+entry->s->fields - field_count; - offset=entry->field[entry->s->fields - field_count]->offset(); + offset= field_count ? + entry->field[entry->s->fields - field_count]->offset() : 0; reclength=entry->s->reclength-offset; free_io_cache(entry); // Safety @@ -12958,7 +12965,7 @@ static void print_join(THD *thd, String *str, List *tables) { TABLE_LIST *curr= *tbl; if (curr->outer_join) - str->append(" left join ", 11); // MySQL converg right to left joins + str->append(" left join ", 11); // MySQL converts right to left joins else if (curr->straight) str->append(" straight_join ", 15); else diff --git a/sql/sql_show.cc b/sql/sql_show.cc index c7b4b61ca33..b909e9cec1b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1512,7 +1512,7 @@ static bool show_status_array(THD *thd, const char *wild, #endif /* HAVE_OPENSSL */ case SHOW_KEY_CACHE_LONG: case SHOW_KEY_CACHE_CONST_LONG: - value= (value-(char*) &dflt_key_cache_var)+ (char*) sql_key_cache; + value= (value-(char*) &dflt_key_cache_var)+ (char*) dflt_key_cache; end= int10_to_str(*(long*) value, buff, 10); break; case SHOW_UNDEF: // Show never happen @@ -2607,7 +2607,8 @@ static int get_schema_stat_record(THD *thd, struct st_table_list *tables, key_part->length != show_table->field[key_part->fieldnr-1]->key_length())) { - table->field[10]->store((longlong) key_part->length); + table->field[10]->store((longlong) key_part->length / + key_part->field->charset()->mbmaxlen); table->field[10]->set_notnull(); } uint flags= key_part->field ? key_part->field->flags : 0; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 5f8e6cf1f5a..88e840d1c4e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1977,10 +1977,10 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, for (table= tables; table; table= table->next_local) { char table_name[NAME_LEN*2+2]; - char* db = (table->db) ? table->db : thd->db; + char* db = table->db; bool fatal_error=0; - strxmov(table_name,db ? db : "",".",table->table_name,NullS); + strxmov(table_name, db, ".", table->table_name, NullS); thd->open_options|= extra_open_options; table->lock_type= lock_type; /* open only one table from local list of command */ @@ -3375,7 +3375,8 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, } /* Remove link to old table and rename the new one */ close_temporary_table(thd, table->s->db, table_name); - if (rename_temporary_table(thd, new_table, new_db, new_alias)) + /* Should pass the 'new_name' as we store table name in the cache */ + if (rename_temporary_table(thd, new_table, new_db, new_name)) { // Fatal error close_temporary_table(thd,new_db,tmp_name); my_free((gptr) new_table,MYF(0)); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index d2220cd67c3..f9ad513ea6a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -120,7 +120,7 @@ int mysql_update(THD *thd, bool used_key_is_modified, transactional_table, log_delayed; int res; int error=0; - uint used_index; + uint used_index= MAX_KEY; #ifndef NO_EMBEDDED_ACCESS_CHECKS uint want_privilege; #endif @@ -134,7 +134,6 @@ int mysql_update(THD *thd, SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_update"); - LINT_INIT(used_index); LINT_INIT(timestamp_query_id); if (open_tables(thd, table_list, &table_count)) @@ -273,7 +272,7 @@ int mysql_update(THD *thd, matching rows before updating the table! */ table->file->extra(HA_EXTRA_RETRIEVE_ALL_COLS); - if ( (used_index != MAX_KEY) && old_used_keys.is_set(used_index)) + if (used_index < MAX_KEY && old_used_keys.is_set(used_index)) { table->key_read=1; table->file->extra(HA_EXTRA_KEYREAD); diff --git a/sql/table.cc b/sql/table.cc index a030da95db4..82ad32341c0 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -342,12 +342,14 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0))); if (my_read(file,(byte*) head,288,MYF(MY_NABP))) goto err; +#ifdef HAVE_CRYPTED_FRM if (crypted) { crypted->decode((char*) head+256,288-256); if (sint2korr(head+284) != 0) // Should be 0 goto err; // Wrong password } +#endif share->fields= uint2korr(head+258); pos= uint2korr(head+260); /* Length of all screens */ @@ -375,12 +377,14 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, pos+ (uint) (n_length+int_length+com_length)); if (read_string(file,(gptr*) &disk_buff,read_length)) goto err; /* purecov: inspected */ +#ifdef HAVE_CRYPTED_FRM if (crypted) { crypted->decode((char*) disk_buff,read_length); delete crypted; crypted=0; } +#endif strpos= disk_buff+pos; share->intervals= (TYPELIB*) (field_ptr+share->fields+1); diff --git a/sql/tztime.cc b/sql/tztime.cc index b9b9e4821c4..4b769aed40c 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1861,7 +1861,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) { ttid= (uint)table->field[1]->val_int(); - if (ttid > TZ_MAX_TYPES) + if (ttid >= TZ_MAX_TYPES) { sql_print_error("Error while loading time zone description from " "mysql.time_zone_transition_type table: too big " diff --git a/tests/Makefile.am b/tests/Makefile.am index b3693aedecb..b4dda0ab6e8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \ pmail.pl mail_to_db.pl table_types.pl \ udf_test udf_test.res myisam-big-rows.tst -bin_PROGRAMS = client_test +bin_PROGRAMS = mysql_client_test noinst_PROGRAMS = insert_test select_test thread_test # @@ -36,9 +36,9 @@ INCLUDES = -I$(top_srcdir)/include $(openssl_includes) LIBS = @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ \ $(top_builddir)/libmysql/libmysqlclient.la -client_test_LDADD= $(LDADD) $(CXXLDFLAGS) \ +mysql_client_test_LDADD= $(LDADD) $(CXXLDFLAGS) \ $(top_builddir)/mysys/libmysys.a -client_test_SOURCES= client_test.c +mysql_client_test_SOURCES= mysql_client_test.c insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) diff --git a/tests/client_test.c b/tests/mysql_client_test.c similarity index 99% rename from tests/client_test.c rename to tests/mysql_client_test.c index 8be970aed29..3cbc9918d6c 100644 --- a/tests/client_test.c +++ b/tests/mysql_client_test.c @@ -11406,6 +11406,12 @@ static void test_bug5194() if (bind == 0 || query == 0 || param_str == 0) { fprintf(stderr, "Can't allocate enough memory for query structs\n"); + if (bind) + free(bind); + if (query) + free(query); + if (param_str) + free(param_str); return; } diff --git a/vio/viosocket.c b/vio/viosocket.c index de50dabba5f..858faac4f1e 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -142,23 +142,29 @@ int vio_fastsend(Vio * vio __attribute__((unused))) int r=0; DBUG_ENTER("vio_fastsend"); -#ifdef IPTOS_THROUGHPUT +#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__) { -#ifndef __EMX__ int tos = IPTOS_THROUGHPUT; - if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) -#endif /* !__EMX__ */ - { - int nodelay = 1; - if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, - sizeof(nodelay))) { - DBUG_PRINT("warning", - ("Couldn't set socket option for fast send")); - r= -1; - } - } + r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)); + } +#endif /* IPTOS_THROUGHPUT && !__EMX__ */ + if (!r) + { +#ifdef __WIN__ + BOOL nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay, + sizeof(nodelay)); +#else + int nodelay = 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay, + sizeof(nodelay)); +#endif /* __WIN__ */ + } + if (r) + { + DBUG_PRINT("warning", ("Couldn't set socket option for fast send")); + r= -1; } -#endif /* IPTOS_THROUGHPUT */ DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); }