From ee2b4ec959b5813eb2105ea068ae3f725b106a3b Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 18 Mar 2005 16:12:25 -0800 Subject: [PATCH 01/12] Eliminate warnings noticed by VC7. This includes fixing my_mmap() on Windows to call CreateFileMapping() with correct arguments, and propogating the introduction of query_id_t to everywhere query ids are passed around. (Bug #8826) --- libmysql/libmysql.c | 2 +- myisam/mi_open.c | 4 ++-- myisam/mi_packrec.c | 2 +- mysys/my_mmap.c | 7 +++++-- sql/field.cc | 7 ++++--- sql/field.h | 2 +- sql/ha_berkeley.cc | 4 ++-- sql/ha_innodb.h | 2 +- sql/handler.cc | 7 ++++++- sql/handler.h | 2 +- sql/item.cc | 6 +++--- sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 2 +- sql/item_strfunc.cc | 2 +- sql/item_subselect.cc | 2 +- sql/log.cc | 10 +++++----- sql/mysql_priv.h | 15 +++++++-------- sql/opt_range.cc | 1 + sql/set_var.cc | 2 +- sql/sql_cache.cc | 1 - sql/sql_class.h | 7 ++++--- sql/sql_db.cc | 3 ++- sql/sql_help.cc | 1 - sql/sql_insert.cc | 6 +++--- sql/sql_lex.h | 2 ++ sql/sql_select.cc | 3 +-- sql/sql_select.h | 2 +- sql/sql_table.cc | 2 +- sql/sql_update.cc | 4 ++-- sql/table.h | 2 +- strings/ctype-simple.c | 2 +- strings/ctype-ucs2.c | 2 +- strings/ctype-utf8.c | 4 ++-- 33 files changed, 66 insertions(+), 56 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 9746cb222fa..f3809c9257e 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3608,7 +3608,7 @@ static void fetch_long_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, if (is_unsigned) data= ulonglong2double(value); else - data= value; + data= (double)value; doublestore(buffer, data); *param->error= is_unsigned ? ((ulonglong) value) != ((ulonglong) (*(double*) buffer)) : diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 504bc33ecc1..d65a46a92fb 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -1090,10 +1090,10 @@ char *mi_keyseg_read(char *ptr, HA_KEYSEG *keyseg) keyseg->null_pos = mi_uint4korr(ptr); ptr +=4; keyseg->charset=0; /* Will be filled in later */ if (keyseg->null_bit) - keyseg->bit_pos= keyseg->null_pos + (keyseg->null_bit == 7); + keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7)); else { - keyseg->bit_pos= keyseg->null_pos; + keyseg->bit_pos= (uint16)keyseg->null_pos; keyseg->null_pos= 0; } return ptr; diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index cc62614cb07..4b512dd89dd 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -1212,7 +1212,7 @@ my_bool _mi_memmap_file(MI_INFO *info) DBUG_RETURN(0); } file_map=(byte*) - my_mmap(0,share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN,PROT_READ, + my_mmap(0,(size_t)(share->state.state.data_file_length+MEMMAP_EXTRA_MARGIN),PROT_READ, MAP_SHARED | MAP_NORESERVE,info->dfile,0L); if (file_map == (byte*) MAP_FAILED) { diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c index a111c3dc571..cd84630a761 100644 --- a/mysys/my_mmap.c +++ b/mysys/my_mmap.c @@ -46,11 +46,14 @@ void *my_mmap(void *addr, size_t len, int prot, DWORD flProtect=0; HANDLE hFileMap; LPVOID ptr; + HANDLE hFile= (HANDLE)_get_osfhandle(fd); + if (hFile == INVALID_HANDLE_VALUE) + return MAP_FAILED; flProtect|=SEC_COMMIT; - hFileMap=CreateFileMapping(fd, NULL, &mmap_security_attributes, - PAGE_READWRITE, 0, len, 0); + hFileMap=CreateFileMapping(hFile, &mmap_security_attributes, + PAGE_READWRITE, 0, len, NULL); if (hFileMap == 0) return MAP_FAILED; diff --git a/sql/field.cc b/sql/field.cc index b6dd00d62a7..84024a63266 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2451,14 +2451,15 @@ static bool test_if_minus(CHARSET_INFO *cs, int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { + ulong tmp_scan; longlong tmp; long store_tmp; int error; char *end; - tmp= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); - len-= tmp; - from+= tmp; + tmp_scan= cs->cset->scan(cs, from, from+len, MY_SEQ_SPACES); + len-= tmp_scan; + from+= tmp_scan; end= (char*) from+len; tmp= cs->cset->my_strtoll10(cs, from, &end, &error); diff --git a/sql/field.h b/sql/field.h index 5b13ba1042a..16fa4a58d0c 100644 --- a/sql/field.h +++ b/sql/field.h @@ -49,7 +49,7 @@ public: struct st_table *orig_table; // Pointer to original table const char **table_name, *field_name; LEX_STRING comment; - ulong query_id; // For quick test of used fields + query_id_t query_id; // For quick test of used fields /* Field is part of the following keys */ key_map key_start,part_of_key,part_of_sortkey; /* diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index a6cc05e1fdb..da4d34e6060 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -1548,7 +1548,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key, do_prev= 1; } if (key_len == key_info->key_length && - !table->key_info[active_index].flags & HA_END_SPACE_KEY) + !(table->key_info[active_index].flags & HA_END_SPACE_KEY)) { if (find_flag == HA_READ_AFTER_KEY) key_info->handler.bdb_return_if_eq= 1; @@ -1646,7 +1646,7 @@ int ha_berkeley::index_next_same(byte * buf, const byte *key, uint keylen) &LOCK_status); bzero((char*) &row,sizeof(row)); if (keylen == table->key_info[active_index].key_length && - !table->key_info[active_index].flags & HA_END_SPACE_KEY) + !(table->key_info[active_index].flags & HA_END_SPACE_KEY)) error=read_row(cursor->c_get(cursor, &last_key, &row, DB_NEXT_DUP), (char*) buf, active_index, &row, &last_key, 1); else diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index e1ed3a486cf..6ad385ae848 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -47,7 +47,7 @@ class ha_innobase: public handler THD* user_thd; /* the thread handle of the user currently using the handle; this is set in external_lock function */ - ulong last_query_id; /* the latest query id where the + query_id_t last_query_id; /* the latest query id where the handle was used */ THR_LOCK_DATA lock; INNOBASE_SHARE *share; diff --git a/sql/handler.cc b/sql/handler.cc index df0d7704163..36c14660a95 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -416,7 +416,12 @@ int ha_init() } #endif DBUG_ASSERT(total_ha < MAX_HA); - opt_using_transactions= total_ha>opt_bin_log; + /* + Check if there is a transaction-capable storage engine besides the + binary log (which is considered a transaction-capable storage engine in + counting total_ha) + */ + opt_using_transactions= total_ha>(ulong)opt_bin_log; savepoint_alloc_size+= sizeof(SAVEPOINT); return error; } diff --git a/sql/handler.h b/sql/handler.h index c8e1d75f2f7..f6d876fe0ad 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -379,7 +379,7 @@ typedef struct st_savepoint SAVEPOINT; extern ulong savepoint_alloc_size; /* Forward declaration for condition pushdown to storage engine */ -typedef struct Item COND; +typedef class Item COND; typedef struct st_ha_check_opt { diff --git a/sql/item.cc b/sql/item.cc index 64fc2696f1f..e5793e349ff 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -178,7 +178,7 @@ bool Item::val_bool() { switch(result_type()) { case INT_RESULT: - return val_int(); + return val_int() != 0; case DECIMAL_RESULT: { my_decimal decimal_value; @@ -1217,7 +1217,7 @@ bool Item_field::val_bool_result() return FALSE; switch (result_field->result_type()) { case INT_RESULT: - return result_field->val_int(); + return result_field->val_int() != 0; case DECIMAL_RESULT: { my_decimal decimal_value; @@ -3946,7 +3946,7 @@ bool Item_ref::val_bool_result() return 0; switch (result_field->result_type()) { case INT_RESULT: - return result_field->val_int(); + return result_field->val_int() != 0; case DECIMAL_RESULT: { my_decimal decimal_value; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c0cb0704852..9850b01561e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1720,7 +1720,7 @@ void Item_func_coalesce::fix_length_and_dec() decimals= 0; break; case ROW_RESULT: - defaullt: + default: DBUG_ASSERT(0); } } diff --git a/sql/item_func.cc b/sql/item_func.cc index 5eb87c2e92b..53c0cf4c05a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -882,7 +882,7 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value) } case REAL_RESULT: { - double result= int_op(); + double result= (double)int_op(); double2my_decimal(E_DEC_FATAL_ERROR, result, decimal_value); break; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 81120bbe3f7..3fe1b819f36 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2888,7 +2888,7 @@ String *Item_func_uuid::val_str(String *str) with a clock_seq value (initialized random below), we use a separate randominit() here */ - randominit(&uuid_rand, tmp + (ulong) thd, tmp + query_id); + randominit(&uuid_rand, tmp + (ulong) thd, tmp + (ulong)query_id); for (i=0; i < (int)sizeof(mac); i++) mac[i]=(uchar)(my_rnd(&uuid_rand)*255); } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 46b2770a12a..378144c707c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -675,7 +675,7 @@ bool Item_exists_subselect::val_bool() reset(); return 0; } - return value; + return value != 0; } diff --git a/sql/log.cc b/sql/log.cc index 43786990797..af1e59df255 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2505,7 +2505,7 @@ int TC_LOG_MMAP::open(const char *opt_name) goto err; } - data= (uchar *)my_mmap(0, file_length, PROT_READ|PROT_WRITE, + data= (uchar *)my_mmap(0, (size_t)file_length, PROT_READ|PROT_WRITE, MAP_NOSYNC|MAP_SHARED, fd, 0); if (data == MAP_FAILED) { @@ -2514,7 +2514,7 @@ int TC_LOG_MMAP::open(const char *opt_name) } inited=2; - npages=file_length/tc_log_page_size; + npages=(uint)file_length/tc_log_page_size; DBUG_ASSERT(npages >= 3); // to guarantee non-empty pool if (!(pages=(PAGE *)my_malloc(npages*sizeof(PAGE), MYF(MY_WME|MY_ZEROFILL)))) goto err; @@ -2540,7 +2540,7 @@ int TC_LOG_MMAP::open(const char *opt_name) goto err; memcpy(data, tc_log_magic, sizeof(tc_log_magic)); - data[sizeof(tc_log_magic)]= total_ha_2pc; + data[sizeof(tc_log_magic)]= (uchar)total_ha_2pc; my_msync(fd, data, tc_log_page_size, MS_SYNC); inited=5; @@ -2794,7 +2794,7 @@ void TC_LOG_MMAP::close() case 3: my_free((gptr)pages, MYF(0)); case 2: - my_munmap(data, file_length); + my_munmap(data, (size_t)file_length); case 1: my_close(fd, MYF(0)); } @@ -2842,7 +2842,7 @@ int TC_LOG_MMAP::recover() goto err2; hash_free(&xids); - bzero(data, file_length); + bzero(data, (size_t)file_length); return 0; err2: diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index ba9f382fc33..dfa945c3fd3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -44,6 +44,13 @@ typedef ulonglong table_map; /* Used for table bits in join */ typedef Bitmap<64> key_map; /* Used for finding keys */ typedef ulong key_part_map; /* Used for finding key parts */ +/* query_id */ +typedef ulonglong query_id_t; +extern query_id_t query_id; + +/* increment query_id and return it. */ +inline query_id_t next_query_id() { return query_id++; } + /* useful constants */ extern const key_map key_map_empty; extern const key_map key_map_full; @@ -1300,14 +1307,6 @@ SQL_CRYPT *get_crypt_for_frm(void); #include "sql_view.h" -/* query_id */ - -typedef ulonglong query_id_t; -extern query_id_t query_id; - -/* increment query_id and return it. */ -inline query_id_t next_query_id() { return query_id++; } - /* Some inline functions for more speed */ inline bool add_item_to_list(THD *thd, Item *item) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index fe1780b92a7..85cd35a5673 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1407,6 +1407,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* Never called */ } }; class TRP_ROR_INTERSECT; diff --git a/sql/set_var.cc b/sql/set_var.cc index 23dbb22399b..0c9483b2783 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -2652,7 +2652,7 @@ bool sys_var_max_user_conn::update(THD *thd, set_var *var) { DBUG_ASSERT(var->type == OPT_GLOBAL); pthread_mutex_lock(&LOCK_global_system_variables); - max_user_connections= var->save_result.ulonglong_value; + max_user_connections= (uint)var->save_result.ulonglong_value; pthread_mutex_unlock(&LOCK_global_system_variables); return 0; } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 5fa161257c7..4a4f61f985c 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2225,7 +2225,6 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block, n= register_tables_from_list(tables_used, 0, block_table); -err: if (n) { DBUG_PRINT("qcache", ("failed at table %d", (int) n)); diff --git a/sql/sql_class.h b/sql/sql_class.h index ffb7a9ab12d..6d6ac810fbf 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1168,8 +1168,8 @@ public: from table are necessary for this select, to check if it's necessary to update auto-updatable fields (like auto_increment and timestamp). */ - ulong query_id; - ulong warn_id, version, options, thread_id, col_access; + query_id_t query_id, warn_id; + ulong version, options, thread_id, col_access; /* Statement id is thread-wide. This counter is used to generate ids */ ulong statement_id_counter; @@ -1797,7 +1797,8 @@ class user_var_entry public: LEX_STRING name; char *value; - ulong length, update_query_id, used_query_id; + ulong length; + query_id_t update_query_id, used_query_id; Item_result type; double val_real(my_bool *null_value); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 8a0ed1d5b87..1f345a28d2c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -875,12 +875,13 @@ err: static my_bool rm_dir_w_symlink(const char *org_path, my_bool send_error) { - char tmp_path[FN_REFLEN], tmp2_path[FN_REFLEN], *pos; + char tmp_path[FN_REFLEN], *pos; char *path= tmp_path; DBUG_ENTER("rm_dir_w_symlink"); unpack_filename(tmp_path, org_path); #ifdef HAVE_READLINK int error; + char tmp2_path[FN_REFLEN]; /* Remove end FN_LIBCHAR as this causes problem on Linux in readlink */ pos= strend(path); diff --git a/sql/sql_help.cc b/sql/sql_help.cc index fa3e2070a28..3c8e8e55c1f 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -763,7 +763,6 @@ bool mysqld_help(THD *thd, const char *mask) } send_eof(thd); -end: DBUG_RETURN(FALSE); error: DBUG_RETURN(TRUE); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index e2ab7ea12c5..691c7c1a98b 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -31,7 +31,7 @@ static void end_delayed_insert(THD *thd); extern "C" pthread_handler_decl(handle_delayed_insert,arg); static void unlink_blobs(register TABLE *table); #endif -static bool check_view_insertability(TABLE_LIST *view, ulong query_id); +static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id); /* Define to force use of my_malloc() if the allocated memory block is big */ @@ -538,7 +538,7 @@ abort: TRUE - can't be used for insert */ -static bool check_view_insertability(TABLE_LIST *view, ulong query_id) +static bool check_view_insertability(TABLE_LIST *view, query_id_t query_id) { uint num= view->view->select_lex.item_list.elements; TABLE *table= view->table; @@ -546,7 +546,7 @@ static bool check_view_insertability(TABLE_LIST *view, ulong query_id) *trans_end= trans_start + num; Field_translator *trans; Field **field_ptr= table->field; - ulong other_query_id= query_id - 1; + query_id_t other_query_id= query_id - 1; DBUG_ENTER("check_key_in_view"); DBUG_ASSERT(view->table != 0 && view->field_translation != 0); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index afd48943439..00e30bd320b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -892,6 +892,8 @@ struct st_lex_local: public st_lex } static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } + static void operator delete(void *ptr, MEM_ROOT *mem_root) + { /* Never called */ } }; void lex_init(void); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2bb4cef1247..90d088183b5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6646,7 +6646,6 @@ static COND *build_equal_items(THD *thd, COND *cond, { if (table->on_expr) { - Item *expr; List *join_list= table->nested_join ? &table->nested_join->join_list : NULL; /* @@ -8545,7 +8544,7 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, seg->type= ((keyinfo->key_part[i].key_type & FIELDFLAG_BINARY) ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2); - seg->bit_start= field->pack_length() - table->s->blob_ptr_size; + seg->bit_start= (uint8)(field->pack_length() - table->s->blob_ptr_size); seg->flag= HA_BLOB_PART; seg->length=0; // Whole blob in unique constraint } diff --git a/sql/sql_select.h b/sql/sql_select.h index 02e1dde8a7f..353f1fc5157 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -351,7 +351,7 @@ class Cursor: public Sql_alloc, public Item_arena MYSQL_LOCK *lock; TABLE *derived_tables; /* List of items created during execution */ - ulong query_id; + query_id_t query_id; public: select_send result; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8295e2f07ab..82d887891cf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2052,7 +2052,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, thd->no_warnings_for_error= 0; table->next_global= next_global_table; /* if view are unsupported */ - if (table->view && !view_operator_func) + if (table->view && view_operator_func == NULL) { result_code= HA_ADMIN_NOT_IMPLEMENTED; goto send_result; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3ee656b00ce..bb0ac31bdc7 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -29,7 +29,7 @@ static bool safe_update_on_fly(JOIN_TAB *join_tab, List *fields); /* Return 0 if row hasn't changed */ -static bool compare_record(TABLE *table, ulong query_id) +static bool compare_record(TABLE *table, query_id_t query_id) { if (table->s->blob_fields + table->s->varchar_fields == 0) return cmp_record(table,record[1]); @@ -125,7 +125,7 @@ int mysql_update(THD *thd, uint want_privilege; #endif uint table_count= 0; - ulong query_id=thd->query_id, timestamp_query_id; + query_id_t query_id=thd->query_id, timestamp_query_id; ha_rows updated, found; key_map old_used_keys; TABLE *table; diff --git a/sql/table.h b/sql/table.h index 49ead2cb0b7..4312e09cfe3 100644 --- a/sql/table.h +++ b/sql/table.h @@ -188,7 +188,7 @@ struct st_table { ORDER *group; const char *alias; /* alias or table name */ uchar *null_flags; - ulong query_id; + query_id_t query_id; ha_rows quick_rows[MAX_KEY]; key_part_map const_key_parts[MAX_KEY]; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 61e7cf1571b..91888771c80 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -894,7 +894,7 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), while (long_val != 0) { long quo= long_val/10; - *--p = '0' + (long_val - quo*10); + *--p = '0' + (char)(long_val - quo*10); long_val= quo; } diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index 797bc9f9047..72483ce5c4c 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1049,7 +1049,7 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), while (long_val != 0) { long quo= long_val/10; - *--p = '0' + (long_val - quo*10); + *--p = '0' + (char)(long_val - quo*10); long_val= quo; } diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 187e5cb9e4a..3b52577c358 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -2264,8 +2264,8 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, plane=(wc>>8) & 0xFF; wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - *dst++= wc >> 8; - *dst++= wc & 0xFF; + *dst++= (uchar)(wc >> 8); + *dst++= (uchar)(wc & 0xFF); } From 954ef465bc3af1ee9f82e15994925e752cb3df90 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 18 Mar 2005 16:14:49 -0800 Subject: [PATCH 02/12] Removed MyISAM RAID from the Linux "Max" RPMs (patch from lenz, reapplied by jimw) --- support-files/mysql.spec.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b062930041a..bad340e9de1 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -214,7 +214,6 @@ Optional MySQL server binary that supports additional features like: - CSV Storage Engine - Example Storage Engine - Federated Storage Engine - - MyISAM RAID - User Defined Functions (UDFs). To activate this binary, just install this package in addition to @@ -328,7 +327,6 @@ BuildMySQL "--enable-shared \ --with-berkeley-db \ --with-innodb \ --with-ndbcluster \ - --with-raid \ --with-archive \ --with-csv-storage-engine \ --with-example-storage-engine \ @@ -694,9 +692,14 @@ fi # itself - note that they must be ordered by date (important when # merging BK trees) %changelog +* Fri Mar 18 2005 Lenz Grimmer + +- Disabled RAID in the Max binaries once and for all (it has finally been + removed from the source tree) + * Sun Feb 20 2005 Petr Chardin -- Install MySQL Instance Manager together with mysqld, toch mysqlmanager +- Install MySQL Instance Manager together with mysqld, touch mysqlmanager password file * Mon Feb 14 2005 Lenz Grimmer From 7de90716b0ebd78bf53dbb5d1327efe329139006 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 18 Mar 2005 16:15:33 -0800 Subject: [PATCH 03/12] Fix Windows compile errors. --- sql/item_sum.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b18653ed5a4..dd95a83a921 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -2128,7 +2128,7 @@ my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf) int simple_str_key_cmp(void* arg, byte* key1, byte* key2) { Field *f= (Field*) arg; - return f->cmp(key1, key2); + return f->cmp((const char*)key1, (const char*)key2); } /* @@ -2158,16 +2158,12 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2) } -C_MODE_START - static int count_distinct_walk(void *elem, unsigned int count, void *arg) { (*((ulonglong*)arg))++; return 0; } -C_MODE_END - void Item_sum_count_distinct::cleanup() { From 146994ed4c41f761ea34ff72fd2b21ca44a27ef6 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 18 Mar 2005 16:17:10 -0800 Subject: [PATCH 04/12] Fix 'kill' test to actually test that the connection has been killed. --- mysql-test/r/kill.result | 6 ++++++ mysql-test/t/kill.test | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/kill.result b/mysql-test/r/kill.result index f57c134b6d0..2413834be4f 100644 --- a/mysql-test/r/kill.result +++ b/mysql-test/r/kill.result @@ -5,6 +5,12 @@ select ((@id := kill_id) - kill_id) from t1; ((@id := kill_id) - kill_id) 0 kill @id; +select ((@id := kill_id) - kill_id) from t1; +((@id := kill_id) - kill_id) +0 +select @id != connection_id(); +@id != connection_id() +1 select 4; 4 4 diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 8a9d96d4946..8492a2a2f8e 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -27,8 +27,9 @@ kill @id; --sleep 5 # verify that con1 is doning a reconnect connection con1; -ping -ping +--ping +--ping +select ((@id := kill_id) - kill_id) from t1; select @id != connection_id(); #make sure the server is still alive From 31ecea8a0fadaf817dce3177efc287d6ffbbeeba Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Fri, 18 Mar 2005 16:18:06 -0800 Subject: [PATCH 05/12] Manually import InnoDB fix into build tree. --- innobase/include/data0type.ic | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/innobase/include/data0type.ic b/innobase/include/data0type.ic index bf04e1c9b27..a87a08ca582 100644 --- a/innobase/include/data0type.ic +++ b/innobase/include/data0type.ic @@ -195,10 +195,12 @@ dtype_get_pad_char( || type->mtype == DATA_BINARY || type->mtype == DATA_FIXBINARY || type->mtype == DATA_MYSQL - || type->mtype == DATA_VARMYSQL) { + || type->mtype == DATA_VARMYSQL + || (type->mtype == DATA_BLOB + && (type->prtype & DATA_BINARY_TYPE) == 0)) { /* Space is the padding character for all char and binary - strings */ + strings, and starting from 5.0.3, also for TEXT strings. */ return((ulint)' '); } From 8ed6b8f82c385956f4dcd250447216450796643e Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Sat, 19 Mar 2005 18:16:38 +0300 Subject: [PATCH 06/12] Cleanup, remove some -ansi -pedancit warnings (mysql_client_test.c) --- tests/mysql_client_test.c | 168 +++++++++++++++++++++++++++----------- 1 file changed, 122 insertions(+), 46 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index d3f19391ee5..073c30b1e4d 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -2293,7 +2293,9 @@ session_id char(9) NOT NULL, \ "(\"abj\", 1, 2, 3, 2003-08-30), " "(\"abk\", 1, 2, 3, 2003-08-30), " "(\"abl\", 1, 2, 3, 2003-08-30), " - "(\"abq\", 1, 2, 3, 2003-08-30), " + "(\"abq\", 1, 2, 3, 2003-08-30) "); + myquery(rc); + rc= mysql_query(mysql, "INSERT INTO test_select VALUES " "(\"abw\", 1, 2, 3, 2003-08-30), " "(\"abe\", 1, 2, 3, 2003-08-30), " "(\"abr\", 1, 2, 3, 2003-08-30), " @@ -4165,40 +4167,40 @@ static void test_prepare_ext() rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_prepare_ext"); myquery(rc); - sql= (char *)"CREATE TABLE test_prepare_ext\ - (\ - c1 tinyint, \ - c2 smallint, \ - c3 mediumint, \ - c4 int, \ - c5 integer, \ - c6 bigint, \ - c7 float, \ - c8 double, \ - c9 double precision, \ - c10 real, \ - c11 decimal(7, 4), \ - c12 numeric(8, 4), \ - c13 date, \ - c14 datetime, \ - c15 timestamp(14), \ - c16 time, \ - c17 year, \ - c18 bit, \ - c19 bool, \ - c20 char, \ - c21 char(10), \ - c22 varchar(30), \ - c23 tinyblob, \ - c24 tinytext, \ - c25 blob, \ - c26 text, \ - c27 mediumblob, \ - c28 mediumtext, \ - c29 longblob, \ - c30 longtext, \ - c31 enum('one', 'two', 'three'), \ - c32 set('monday', 'tuesday', 'wednesday'))"; + sql= (char *)"CREATE TABLE test_prepare_ext" + "(" + " c1 tinyint," + " c2 smallint," + " c3 mediumint," + " c4 int," + " c5 integer," + " c6 bigint," + " c7 float," + " c8 double," + " c9 double precision," + " c10 real," + " c11 decimal(7, 4)," + " c12 numeric(8, 4)," + " c13 date," + " c14 datetime," + " c15 timestamp(14)," + " c16 time," + " c17 year," + " c18 bit," + " c19 bool," + " c20 char," + " c21 char(10)," + " c22 varchar(30)," + " c23 tinyblob," + " c24 tinytext," + " c25 blob," + " c26 text," + " c27 mediumblob," + " c28 mediumtext," + " c29 longblob," + " c30 longtext," + " c31 enum('one', 'two', 'three')," + " c32 set('monday', 'tuesday', 'wednesday'))"; rc= mysql_query(mysql, sql); myquery(rc); @@ -10782,7 +10784,7 @@ static void test_view() ulong length = 0L; long is_null = 0L; const char *query= - "SELECT COUNT(*) FROM v1 WHERE `SERVERNAME`=?"; + "SELECT COUNT(*) FROM v1 WHERE SERVERNAME=?"; myheader("test_view"); @@ -10791,13 +10793,38 @@ static void test_view() rc = mysql_query(mysql, "DROP VIEW IF EXISTS v1,t1,t2,t3"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE `t1` ( `SERVERGRP` varchar(20) character set latin1 collate latin1_bin NOT NULL default '', `DBINSTANCE` varchar(20) character set latin1 collate latin1_bin NOT NULL default '', PRIMARY KEY (`SERVERGRP`)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + rc= mysql_query(mysql,"CREATE TABLE t1 (" + " SERVERGRP varchar(20) NOT NULL default '', " + " DBINSTANCE varchar(20) NOT NULL default '', " + " PRIMARY KEY (SERVERGRP)) " + " CHARSET=latin1 collate=latin1_bin"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE `t2` ( `SERVERNAME` varchar(20) character set latin1 collate latin1_bin NOT NULL default '', `SERVERGRP` varchar(20) character set latin1 collate latin1_bin NOT NULL default '', PRIMARY KEY (`SERVERNAME`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + rc= mysql_query(mysql,"CREATE TABLE t2 (" + " SERVERNAME varchar(20) NOT NULL, " + " SERVERGRP varchar(20) NOT NULL, " + " PRIMARY KEY (SERVERNAME)) " + " CHARSET=latin1 COLLATE latin1_bin"); myquery(rc); - rc= mysql_query(mysql,"CREATE TABLE `t3` ( `SERVERGRP` varchar(20) character set latin1 collate latin1_bin NOT NULL default '', `TABNAME` varchar(30) character set latin1 collate latin1_bin NOT NULL default '', `MAPSTATE` char(1) character set latin1 collate latin1_bin NOT NULL default '', `ACTSTATE` char(1) character set latin1 collate latin1_bin NOT NULL default '', `LOCAL_NAME` varchar(30) character set latin1 collate latin1_bin NOT NULL default '', `CHG_DATE` varchar(8) character set latin1 collate latin1_bin NOT NULL default '00000000', `CHG_TIME` varchar(6) character set latin1 collate latin1_bin NOT NULL default '000000', `MXUSER` varchar(12) character set latin1 collate latin1_bin NOT NULL default '', PRIMARY KEY (`SERVERGRP`,`TABNAME`,`MAPSTATE`,`ACTSTATE`,`LOCAL_NAME`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + rc= mysql_query(mysql, + "CREATE TABLE t3 (" + " SERVERGRP varchar(20) BINARY NOT NULL, " + " TABNAME varchar(30) NOT NULL, MAPSTATE char(1) NOT NULL, " + " ACTSTATE char(1) NOT NULL , " + " LOCAL_NAME varchar(30) NOT NULL, " + " CHG_DATE varchar(8) NOT NULL default '00000000', " + " CHG_TIME varchar(6) NOT NULL default '000000', " + " MXUSER varchar(12) NOT NULL default '', " + " PRIMARY KEY (SERVERGRP, TABNAME, MAPSTATE, ACTSTATE, " + " LOCAL_NAME)) CHARSET=latin1 COLLATE latin1_bin"); myquery(rc); - rc= mysql_query(mysql,"CREATE VIEW v1 AS select sql_no_cache T0001.SERVERNAME AS `SERVERNAME`,T0003.TABNAME AS `TABNAME`,T0003.LOCAL_NAME AS `LOCAL_NAME`,T0002.DBINSTANCE AS `DBINSTANCE` from t2 T0001 join t1 T0002 join t3 T0003 where ((T0002.SERVERGRP = T0001.SERVERGRP) and (T0002.SERVERGRP = T0003.SERVERGRP) and (T0003.MAPSTATE = _latin1'A') and (T0003.ACTSTATE = _latin1' '))"); + rc= mysql_query(mysql,"CREATE VIEW v1 AS select sql_no_cache" + " T0001.SERVERNAME AS SERVERNAME, T0003.TABNAME AS" + " TABNAME,T0003.LOCAL_NAME AS LOCAL_NAME,T0002.DBINSTANCE AS" + " DBINSTANCE from t2 T0001 join t1 T0002 join t3 T0003 where" + " ((T0002.SERVERGRP = T0001.SERVERGRP) and" + " (T0002.SERVERGRP = T0003.SERVERGRP)" + " and (T0003.MAPSTATE = _latin1'A') and" + " (T0003.ACTSTATE = _latin1' '))"); myquery(rc); stmt= mysql_stmt_init(mysql); @@ -10878,7 +10905,11 @@ static void test_view_2where() MYSQL_BIND bind[8]; char parms[8][100]; ulong length[8]; - const char *query= "SELECT `RELID` ,`REPORT` ,`HANDLE` ,`LOG_GROUP` ,`USERNAME` ,`VARIANT` ,`TYPE` ,`VERSION` ,`ERFDAT` ,`ERFTIME` ,`ERFNAME` ,`AEDAT` ,`AETIME` ,`AENAME` ,`DEPENDVARS` ,`INACTIVE` FROM `V_LTDX` WHERE `MANDT` = ? AND `RELID` = ? AND `REPORT` = ? AND `HANDLE` = ? AND `LOG_GROUP` = ? AND `USERNAME` IN ( ? , ? ) AND `TYPE` = ?"; + const char *query= + "select relid, report, handle, log_group, username, variant, type, " + "version, erfdat, erftime, erfname, aedat, aetime, aename, dependvars, " + "inactive from V_LTDX where mandt = ? and relid = ? and report = ? and " + "handle = ? and log_group = ? and username in ( ? , ? ) and type = ?"; myheader("test_view_2where"); @@ -10886,9 +10917,38 @@ static void test_view_2where() myquery(rc); rc= mysql_query(mysql, "DROP VIEW IF EXISTS V_LTDX"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE `LTDX` ( `MANDT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', `RELID` char(2) character set latin1 collate latin1_bin NOT NULL default '', `REPORT` varchar(40) character set latin1 collate latin1_bin NOT NULL default '', `HANDLE` varchar(4) character set latin1 collate latin1_bin NOT NULL default '', `LOG_GROUP` varchar(4) character set latin1 collate latin1_bin NOT NULL default '', `USERNAME` varchar(12) character set latin1 collate latin1_bin NOT NULL default '', `VARIANT` varchar(12) character set latin1 collate latin1_bin NOT NULL default '', `TYPE` char(1) character set latin1 collate latin1_bin NOT NULL default '', `SRTF2` int(11) NOT NULL default '0', `VERSION` varchar(6) character set latin1 collate latin1_bin NOT NULL default '000000', `ERFDAT` varchar(8) character set latin1 collate latin1_bin NOT NULL default '00000000', `ERFTIME` varchar(6) character set latin1 collate latin1_bin NOT NULL default '000000', `ERFNAME` varchar(12) character set latin1 collate latin1_bin NOT NULL default '', `AEDAT` varchar(8) character set latin1 collate latin1_bin NOT NULL default '00000000', `AETIME` varchar(6) character set latin1 collate latin1_bin NOT NULL default '000000', `AENAME` varchar(12) character set latin1 collate latin1_bin NOT NULL default '', `DEPENDVARS` varchar(10) character set latin1 collate latin1_bin NOT NULL default '', `INACTIVE` char(1) character set latin1 collate latin1_bin NOT NULL default '', `CLUSTR` smallint(6) NOT NULL default '0', `CLUSTD` blob, PRIMARY KEY (`MANDT`,`RELID`,`REPORT`,`HANDLE`,`LOG_GROUP`,`USERNAME`,`VARIANT`,`TYPE`,`SRTF2`)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + rc= mysql_query(mysql, + "CREATE TABLE LTDX (MANDT char(3) NOT NULL default '000', " + " RELID char(2) NOT NULL, REPORT varchar(40) NOT NULL," + " HANDLE varchar(4) NOT NULL, LOG_GROUP varchar(4) NOT NULL," + " USERNAME varchar(12) NOT NULL," + " VARIANT varchar(12) NOT NULL," + " TYPE char(1) NOT NULL, SRTF2 int(11) NOT NULL," + " VERSION varchar(6) NOT NULL default '000000'," + " ERFDAT varchar(8) NOT NULL default '00000000'," + " ERFTIME varchar(6) NOT NULL default '000000'," + " ERFNAME varchar(12) NOT NULL," + " AEDAT varchar(8) NOT NULL default '00000000'," + " AETIME varchar(6) NOT NULL default '000000'," + " AENAME varchar(12) NOT NULL," + " DEPENDVARS varchar(10) NOT NULL," + " INACTIVE char(1) NOT NULL, CLUSTR smallint(6) NOT NULL," + " CLUSTD blob," + " PRIMARY KEY (MANDT, RELID, REPORT, HANDLE, LOG_GROUP, " + "USERNAME, VARIANT, TYPE, SRTF2))" + " CHARSET=latin1 COLLATE latin1_bin"); myquery(rc); - rc= mysql_query(mysql, "CREATE VIEW V_LTDX AS select T0001.MANDT AS `MANDT`,T0001.RELID AS `RELID`,T0001.REPORT AS `REPORT`,T0001.HANDLE AS `HANDLE`,T0001.LOG_GROUP AS `LOG_GROUP`,T0001.USERNAME AS `USERNAME`,T0001.VARIANT AS `VARIANT`,T0001.TYPE AS `TYPE`,T0001.VERSION AS `VERSION`,T0001.ERFDAT AS `ERFDAT`,T0001.ERFTIME AS `ERFTIME`,T0001.ERFNAME AS `ERFNAME`,T0001.AEDAT AS `AEDAT`,T0001.AETIME AS `AETIME`,T0001.AENAME AS `AENAME`,T0001.DEPENDVARS AS `DEPENDVARS`,T0001.INACTIVE AS `INACTIVE` from LTDX T0001 where (T0001.SRTF2 = 0)"); + rc= mysql_query(mysql, + "CREATE VIEW V_LTDX AS select T0001.MANDT AS " + " MANDT,T0001.RELID AS RELID,T0001.REPORT AS " + " REPORT,T0001.HANDLE AS HANDLE,T0001.LOG_GROUP AS " + " LOG_GROUP,T0001.USERNAME AS USERNAME,T0001.VARIANT AS " + " VARIANT,T0001.TYPE AS TYPE,T0001.VERSION AS " + " VERSION,T0001.ERFDAT AS ERFDAT,T0001.ERFTIME AS " + " ERFTIME,T0001.ERFNAME AS ERFNAME,T0001.AEDAT AS " + " AEDAT,T0001.AETIME AS AETIME,T0001.AENAME AS " + " AENAME,T0001.DEPENDVARS AS DEPENDVARS,T0001.INACTIVE AS " + " INACTIVE from LTDX T0001 where (T0001.SRTF2 = 0)"); myquery(rc); for (i=0; i < 8; i++) { strcpy(parms[i], "1"); @@ -11085,9 +11145,26 @@ static void test_view_insert_fields() myquery(rc); rc= mysql_query(mysql, "DROP VIEW IF EXISTS t1, v1"); myquery(rc); - rc= mysql_query(mysql, "CREATE TABLE t1 ( K1C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K3C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', F1C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '', F2I4 int(11) NOT NULL default '0', F3N5 varchar(5) character set latin1 collate latin1_bin NOT NULL default '00000', F4I4 int(11) NOT NULL default '0', F5C8 varchar(8) character set latin1 collate latin1_bin NOT NULL default '', F6N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000', F7F8 double NOT NULL default '0', F8F8 double NOT NULL default '0', F9D8 decimal(8,2) NOT NULL default '0.00', PRIMARY KEY (K1C4,K2C4,K3C4,K4N4)) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + rc= mysql_query(mysql, + "CREATE TABLE t1 (K1C4 varchar(4) NOT NULL," + "K2C4 varchar(4) NOT NULL, K3C4 varchar(4) NOT NULL," + "K4N4 varchar(4) NOT NULL default '0000'," + "F1C4 varchar(4) NOT NULL, F2I4 int(11) NOT NULL," + "F3N5 varchar(5) NOT NULL default '00000'," + "F4I4 int(11) NOT NULL default '0', F5C8 varchar(8) NOT NULL," + "F6N4 varchar(4) NOT NULL default '0000'," + "F7F8 double NOT NULL default '0'," + "F8F8 double NOT NULL default '0'," + "F9D8 decimal(8,2) NOT NULL default '0.00'," + "PRIMARY KEY (K1C4,K2C4,K3C4,K4N4)) " + "CHARSET=latin1 COLLATE latin1_bin"); myquery(rc); - rc= mysql_query(mysql, "CREATE VIEW v1 AS select sql_no_cache K1C4 AS `K1C4`,K2C4 AS `K2C4`,K3C4 AS `K3C4`,K4N4 AS `K4N4`,F1C4 AS `F1C4`,F2I4 AS `F2I4`,F3N5 AS `F3N5`,F7F8 AS `F7F8`,F6N4 AS `F6N4`,F5C8 AS `F5C8`,F9D8 AS `F9D8` from t1 T0001"); + rc= mysql_query(mysql, + "CREATE VIEW v1 AS select sql_no_cache " + " K1C4 AS K1C4, K2C4 AS K2C4, K3C4 AS K3C4, K4N4 AS K4N4, " + " F1C4 AS F1C4, F2I4 AS F2I4, F3N5 AS F3N5," + " F7F8 AS F7F8, F6N4 AS F6N4, F5C8 AS F5C8, F9D8 AS F9D8" + " from t1 T0001"); for (i= 0; i < 11; i++) { @@ -12582,7 +12659,6 @@ static void test_bug7990() static void test_view_sp_list_fields() { - MYSQL_STMT *stmt; int rc; MYSQL_RES *res; From 947065ddabd9bf0f38e1bd1a0ce5241c2961bf64 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Sat, 19 Mar 2005 18:39:26 +0300 Subject: [PATCH 07/12] Clean up the warning inside sanity():decimal.c in valgrind-max builds. --- sql/my_decimal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/my_decimal.h b/sql/my_decimal.h index c02b0cb4c8b..a2cc61cf8d4 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -85,7 +85,7 @@ public: { len= DECIMAL_BUFF_LENGTH; buf= buffer; -#if !defined(HAVE_purify) && !defined(DBUG_OFF) +#if !defined(DBUG_OFF) /* Set buffer to 'random' value to find wrong buffer usage */ for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++) buffer[i]= i; From df12e29955a0421f131e2239ef042eb1add225c6 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Sat, 19 Mar 2005 23:12:50 -0800 Subject: [PATCH 08/12] func_group.test, func_group.result: Added a test case for bug #9210. sql_select.cc: Fixed bug #9210. The function calc_group_buffer did not cover the case when the GROUP BY expression was decimal. Slightly optimized the other code. --- mysql-test/r/func_group.result | 59 ++++++++++++++++++++++++++++++++++ mysql-test/t/func_group.test | 23 +++++++++++++ sql/sql_select.cc | 48 ++++++++++++++++----------- 3 files changed, 111 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 81663cd9d66..3e06018226d 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -888,3 +888,62 @@ SELECT COUNT(DISTINCT a) FROM t1; COUNT(DISTINCT a) 2 DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 (a, b, c) VALUES +(1,1,1), (1,1,2), (1,1,3), +(1,2,1), (1,2,2), (1,2,3), +(1,3,1), (1,3,2), (1,3,3), +(2,1,1), (2,1,2), (2,1,3), +(2,2,1), (2,2,2), (2,2,3), +(2,3,1), (2,3,2), (2,3,3), +(3,1,1), (3,1,2), (3,1,3), +(3,2,1), (3,2,2), (3,2,3), +(3,3,1), (3,3,2), (3,3,3); +SELECT b/c as v, a FROM t1 ORDER BY v; +v a +0.33333 3 +0.33333 1 +0.33333 2 +0.50000 1 +0.50000 2 +0.50000 3 +0.66667 2 +0.66667 1 +0.66667 3 +1.00000 3 +1.00000 2 +1.00000 3 +1.00000 1 +1.00000 2 +1.00000 3 +1.00000 2 +1.00000 1 +1.00000 1 +1.50000 3 +1.50000 2 +1.50000 1 +2.00000 1 +2.00000 3 +2.00000 2 +3.00000 3 +3.00000 2 +3.00000 1 +SELECT b/c as v, SUM(a) FROM t1 GROUP BY v; +v SUM(a) +0.33333 6 +0.50000 6 +0.66667 6 +1.00000 18 +1.50000 6 +2.00000 6 +3.00000 6 +SELECT SUM(a) FROM t1 GROUP BY b/c; +SUM(a) +6 +6 +6 +18 +6 +6 +6 +DROP TABLE t1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 0f03eae7e12..9b6f91067d4 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -601,3 +601,26 @@ INSERT INTO t1 (a) VALUES ("A"), ("a"), ("a "), ("a "), ("B"), ("b"), ("b "), ("b "); SELECT COUNT(DISTINCT a) FROM t1; DROP TABLE t1; + +# +# Test for buf #9210: GROUP BY with expression if a decimal type +# + +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 (a, b, c) VALUES + (1,1,1), (1,1,2), (1,1,3), + (1,2,1), (1,2,2), (1,2,3), + (1,3,1), (1,3,2), (1,3,3), + (2,1,1), (2,1,2), (2,1,3), + (2,2,1), (2,2,2), (2,2,3), + (2,3,1), (2,3,2), (2,3,3), + (3,1,1), (3,1,2), (3,1,3), + (3,2,1), (3,2,2), (3,2,3), + (3,3,1), (3,3,2), (3,3,3); + +SELECT b/c as v, a FROM t1 ORDER BY v; +SELECT b/c as v, SUM(a) FROM t1 GROUP BY v; +SELECT SUM(a) FROM t1 GROUP BY b/c; + +DROP TABLE t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 811ba863a76..1e05400e88e 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11891,7 +11891,8 @@ calc_group_buffer(JOIN *join,ORDER *group) join->group= 1; for (; group ; group=group->next) { - Field *field=(*group->item)->get_tmp_table_field(); + Item *group_item= *group->item; + Field *field= group_item->get_tmp_table_field(); if (field) { if (field->type() == FIELD_TYPE_BLOB) @@ -11901,27 +11902,36 @@ calc_group_buffer(JOIN *join,ORDER *group) else key_length+= field->pack_length(); } - else if ((*group->item)->result_type() == REAL_RESULT) - key_length+=sizeof(double); - else if ((*group->item)->result_type() == INT_RESULT) - key_length+=sizeof(longlong); - else if ((*group->item)->result_type() == STRING_RESULT) - { - /* - Group strings are taken as varstrings and require an length field. - A field is not yet created by create_tmp_field() - and the sizes should match up. - */ - key_length+= (*group->item)->max_length + HA_KEY_BLOB_LENGTH; - } else - { - /* This case should never be choosen */ - DBUG_ASSERT(0); - join->thd->fatal_error(); + { + switch (group_item->result_type()) { + case REAL_RESULT: + key_length+= sizeof(double); + break; + case INT_RESULT: + key_length+= sizeof(longlong); + break; + case DECIMAL_RESULT: + key_length+= my_decimal_get_binary_size(group_item->max_length - + (group_item->decimals ? 1 : 0), + group_item->decimals); + break; + case STRING_RESULT: + /* + Group strings are taken as varstrings and require an length field. + A field is not yet created by create_tmp_field() + and the sizes should match up. + */ + key_length+= group_item->max_length + HA_KEY_BLOB_LENGTH; + break; + default: + /* This case should never be choosen */ + DBUG_ASSERT(0); + join->thd->fatal_error(); + } } parts++; - if ((*group->item)->maybe_null) + if (group_item->maybe_null) null_parts++; } join->tmp_table_param.group_length=key_length+null_parts; From eeb42a8d3853e08ef9d60005f7fb2b45edb11506 Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Sun, 20 Mar 2005 14:38:51 +0100 Subject: [PATCH 09/12] Import Heikki's patch which was applied to the main tree only. --- mysql-test/r/endspace.result | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/r/endspace.result b/mysql-test/r/endspace.result index e9396c9a6ed..0e68418a80f 100644 --- a/mysql-test/r/endspace.result +++ b/mysql-test/r/endspace.result @@ -201,10 +201,12 @@ teststring select text1, length(text1) from t1 where text1='teststring' or text1 like 'teststring_%'; text1 length(text1) teststring 11 +teststring 10 teststring 11 select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t'; text1 length(text1) teststring 11 +teststring 10 teststring 11 select concat('|', text1, '|') from t1 order by text1; concat('|', text1, '|') From c87912c8da17ee9734b1b37cbc59c76bc68f41d2 Mon Sep 17 00:00:00 2001 From: "dlenev@brandersnatch.localdomain" <> Date: Sun, 20 Mar 2005 20:29:03 +0300 Subject: [PATCH 10/12] Fix for spurious failures of sp.test on many platforms (aka Bug #9161 "Warnings on 'drop procedure' platform-specific"). In mysqltest we should not issue "SHOW WARNINGS" until we have not read results from all statements in multi-statement. Otherwise such "SHOW WARNINGS" will either cause "Packets out of order" error and thus will ruin current connection (but we may not notice this as it happened in sp.test because we ignore errors from such auxilary SHOW WARNINGS and use auto-reconnecting connections) or will succeed but consume first packet from next statement in multi-statement sequence (this happens if "SHOW WARNINGS" is issued when this packet is already received by client. Packet is thrown away by net_clear() call which is issued when "SHOW WARNINGS" is sent to server). In our case sp.test failed because usually we had first situation but sometimes second situation occured causing warning to pop-up. --- client/mysqltest.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index f6f6f469e8c..c1ff16e5d88 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2746,8 +2746,13 @@ static int run_query_normal(MYSQL* mysql, struct st_query* q, int flags) append_result(ds, res); } - /* Add all warnings to the result */ - if (!disable_warnings && mysql_warning_count(mysql)) + /* + Add all warnings to the result. We can't do this if we are in + the middle of processing results from multi-statement, because + this will break protocol. + */ + if (!disable_warnings && !mysql_more_results(mysql) && + mysql_warning_count(mysql)) { MYSQL_RES *warn_res=0; uint count= mysql_warning_count(mysql); @@ -3363,6 +3368,13 @@ static void run_query_stmt_handle_warnings(MYSQL *mysql, DYNAMIC_STRING *ds) if (!disable_warnings && (count= mysql_warning_count(mysql))) { + /* + If one day we will support execution of multi-statements + through PS API we should not issue SHOW WARNINGS until + we have not read all results... + */ + DBUG_ASSERT(!mysql_more_results(mysql)); + if (mysql_real_query(mysql, "SHOW WARNINGS", 13) == 0) { MYSQL_RES *warn_res= mysql_store_result(mysql); From 0ae33dfd36cf8b6ec4d74e144fb4761a581afca2 Mon Sep 17 00:00:00 2001 From: "patg@krsna." <> Date: Sun, 20 Mar 2005 23:17:35 -0800 Subject: [PATCH 11/12] Federated Storage Handler - test and result fix. --- mysql-test/r/federated.result | 2 +- mysql-test/t/federated.test | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index a012550ef5f..6c815e94b7c 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -106,7 +106,7 @@ CREATE TABLE federated.`t1%` ( `name` varchar(32) NOT NULL default '' ) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 -COMMENT='mysql://root@127.0.0.1:9308/federated/t1%'; +COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1%'; INSERT INTO federated.`t1%` (id, name) VALUES (1, 'foo'); INSERT INTO federated.`t1%` (id, name) VALUES (2, 'fee'); SELECT * FROM federated.`t1%`; diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index db7e712bd5f..6a0e0bdac79 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -125,6 +125,7 @@ SELECT * FROM federated.t1; DELETE FROM federated.t1; DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT eval CREATE TABLE federated.`t1%` ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' From 3e8045c662686c4fd47c39033b00b6e5240d1d58 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Mon, 21 Mar 2005 12:57:42 +0300 Subject: [PATCH 12/12] Fix a valgrind warning in decimal.c:sanity() --- sql/my_decimal.h | 2 +- strings/decimal.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/my_decimal.h b/sql/my_decimal.h index a2cc61cf8d4..44530acd0cc 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -85,7 +85,7 @@ public: { len= DECIMAL_BUFF_LENGTH; buf= buffer; -#if !defined(DBUG_OFF) +#if !defined (HAVE_purify) && !defined(DBUG_OFF) /* Set buffer to 'random' value to find wrong buffer usage */ for (uint i= 0; i < DECIMAL_BUFF_LENGTH; i++) buffer[i]= i; diff --git a/strings/decimal.c b/strings/decimal.c index 90e64ae892f..f288a93eb5e 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -139,8 +139,12 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={ 999900000, 999990000, 999999000, 999999900, 999999990 }; +#ifdef HAVE_purify +#define sanity(d) DBUG_ASSERT((d)->len > 0) +#else #define sanity(d) DBUG_ASSERT((d)->len >0 && ((d)->buf[0] | \ (d)->buf[(d)->len-1] | 1)) +#endif #define FIX_INTG_FRAC_ERROR(len, intg1, frac1, error) \ do \