diff options
-rw-r--r-- | .bzrignore | 2 | ||||
-rw-r--r-- | include/my_bitmap.h | 1 | ||||
-rw-r--r-- | include/myisam.h | 81 | ||||
-rw-r--r-- | myisam/mi_check.c | 33 | ||||
-rw-r--r-- | myisam/mi_create.c | 2 | ||||
-rw-r--r-- | myisam/mi_delete.c | 2 | ||||
-rw-r--r-- | myisam/mi_extra.c | 4 | ||||
-rw-r--r-- | myisam/mi_open.c | 16 | ||||
-rw-r--r-- | myisam/mi_preload.c | 2 | ||||
-rw-r--r-- | myisam/mi_rsame.c | 2 | ||||
-rw-r--r-- | myisam/mi_rsamepos.c | 2 | ||||
-rw-r--r-- | myisam/mi_search.c | 2 | ||||
-rw-r--r-- | myisam/mi_update.c | 2 | ||||
-rw-r--r-- | myisam/mi_write.c | 15 | ||||
-rw-r--r-- | myisam/myisamchk.c | 16 | ||||
-rw-r--r-- | myisam/myisamdef.h | 4 | ||||
-rw-r--r-- | myisam/myisamlog.c | 2 | ||||
-rw-r--r-- | myisam/myisampack.c | 12 | ||||
-rw-r--r-- | myisam/sort.c | 2 | ||||
-rw-r--r-- | mysql-test/r/federated.result | 319 | ||||
-rw-r--r-- | mysql-test/r/information_schema.result | 30 | ||||
-rw-r--r-- | mysql-test/t/federated.test | 141 | ||||
-rw-r--r-- | mysql-test/t/information_schema.test | 18 | ||||
-rw-r--r-- | mysys/my_bitmap.c | 31 | ||||
-rw-r--r-- | sql/ha_federated.cc | 58 | ||||
-rw-r--r-- | sql/ha_federated.h | 54 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 10 | ||||
-rw-r--r-- | sql/log_event.cc | 2 | ||||
-rw-r--r-- | sql/sql_bitmap.h | 9 | ||||
-rw-r--r-- | sql/sql_parse.cc | 10 | ||||
-rw-r--r-- | sql/sql_show.cc | 22 |
31 files changed, 382 insertions, 524 deletions
diff --git a/.bzrignore b/.bzrignore index 9c6cf2c965c..ca4cade7f09 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1117,3 +1117,5 @@ vio/test-sslclient vio/test-sslserver vio/viotest-ssl ndb/src/dummy.cpp +innobase/mkinstalldirs +mkinstalldirs diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 84a5d8bd18a..f4fe28266e4 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -54,6 +54,7 @@ extern void bitmap_clear_all(MY_BITMAP *map); extern void bitmap_clear_bit(MY_BITMAP *map, uint bitmap_bit); extern void bitmap_free(MY_BITMAP *map); extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2); +extern void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit); extern void bitmap_set_all(MY_BITMAP *map); extern void bitmap_set_bit(MY_BITMAP *map, uint bitmap_bit); extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size); diff --git a/include/myisam.h b/include/myisam.h index 7d3f0e0c801..03194fe42ae 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -35,14 +35,26 @@ extern "C" { /* defines used by myisam-funktions */ -/* The following defines can be increased if necessary */ -#define MI_MAX_KEY 64 /* Max allowed keys */ -#define MI_MAX_KEY_SEG 16 /* Max segments for key */ -#define MI_MAX_KEY_LENGTH 1000 +/* + There is a hard limit for the maximum number of keys as there are only + 8 bits in the index file header for the number of keys in a table. + This means that 0..255 keys can exist for a table. The idea of + MI_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on + a MyISAM table for which one has more keys than MyISAM is normally + compiled for. If you don't have this, you will get a core dump when + running myisamchk compiled for 128 keys on a table with 255 keys. +*/ +#define MI_MAX_POSSIBLE_KEY 255 /* For myisam_chk */ +#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */ +/* + The following defines can be increased if necessary. + BUT: MI_MAX_KEY must be <= MI_MAX_POSSIBLE_KEY. +*/ +#define MI_MAX_KEY 64 /* Max allowed keys */ +#define MI_MAX_KEY_SEG 16 /* Max segments for key */ +#define MI_MAX_KEY_LENGTH 1000 #define MI_MAX_KEY_BUFF (MI_MAX_KEY_LENGTH+MI_MAX_KEY_SEG*6+8+8) -#define MI_MAX_POSSIBLE_KEY_BUFF (1024+6+6) /* For myisam_chk */ -#define MI_MAX_POSSIBLE_KEY 64 /* For myisam_chk */ #define MI_MAX_MSG_BUF 1024 /* used in CHECK TABLE, REPAIR TABLE */ #define MI_NAME_IEXT ".MYI" #define MI_NAME_DEXT ".MYD" @@ -56,6 +68,63 @@ extern "C" { #define mi_portable_sizeof_char_ptr 8 +/* + In the following macros '_keyno_' is 0 .. keys-1. + If there can be more keys than bits in the key_map, the highest bit + is for all upper keys. They cannot be switched individually. + This means that clearing of high keys is ignored, setting one high key + sets all high keys. +*/ +#define MI_KEYMAP_BITS (8 * SIZEOF_LONG_LONG) +#define MI_KEYMAP_HIGH_MASK (ULL(1) << (MI_KEYMAP_BITS - 1)) +#define mi_get_mask_all_keys_active(_keys_) \ + (((_keys_) < MI_KEYMAP_BITS) ? \ + ((ULL(1) << (_keys_)) - ULL(1)) : \ + (~ ULL(0))) + +#if MI_MAX_KEY > MI_KEYMAP_BITS + +#define mi_is_key_active(_keymap_,_keyno_) \ + (((_keyno_) < MI_KEYMAP_BITS) ? \ + test((_keymap_) & (ULL(1) << (_keyno_))) : \ + test((_keymap_) & MI_KEYMAP_HIGH_MASK)) +#define mi_set_key_active(_keymap_,_keyno_) \ + (_keymap_)|= (((_keyno_) < MI_KEYMAP_BITS) ? \ + (ULL(1) << (_keyno_)) : \ + MI_KEYMAP_HIGH_MASK) +#define mi_clear_key_active(_keymap_,_keyno_) \ + (_keymap_)&= (((_keyno_) < MI_KEYMAP_BITS) ? \ + (~ (ULL(1) << (_keyno_))) : \ + (~ (ULL(0))) /*ignore*/ ) + +#else + +#define mi_is_key_active(_keymap_,_keyno_) \ + test((_keymap_) & (ULL(1) << (_keyno_))) +#define mi_set_key_active(_keymap_,_keyno_) \ + (_keymap_)|= (ULL(1) << (_keyno_)) +#define mi_clear_key_active(_keymap_,_keyno_) \ + (_keymap_)&= (~ (ULL(1) << (_keyno_))) + +#endif + +#define mi_is_any_key_active(_keymap_) \ + test((_keymap_)) +#define mi_is_all_keys_active(_keymap_,_keys_) \ + ((_keymap_) == mi_get_mask_all_keys_active(_keys_)) +#define mi_set_all_keys_active(_keymap_,_keys_) \ + (_keymap_)= mi_get_mask_all_keys_active(_keys_) +#define mi_clear_all_keys_active(_keymap_) \ + (_keymap_)= 0 +#define mi_intersect_keys_active(_to_,_from_) \ + (_to_)&= (_from_) +#define mi_is_any_intersect_keys_active(_keymap1_,_keys_,_keymap2_) \ + ((_keymap1_) & (_keymap2_) & \ + mi_get_mask_all_keys_active(_keys_)) +#define mi_copy_keys_active(_to_,_maxkeys_,_from_) \ + (_to_)= (mi_get_mask_all_keys_active(_maxkeys_) & \ + (_from_)) + /* Param to/from mi_info */ typedef struct st_mi_isaminfo /* Struct from h_info */ diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 9e003a18dac..1db829808a9 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -282,7 +282,7 @@ int chk_size(MI_CHECK *param, register MI_INFO *info) if ((skr=(my_off_t) info->state->key_file_length) != size) { /* Don't give error if file generated by myisampack */ - if (skr > size && info->s->state.key_map) + if (skr > size && mi_is_any_key_active(info->s->state.key_map)) { error=1; mi_check_print_error(param, @@ -379,7 +379,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) rec_per_key_part+=keyinfo->keysegs, key++, keyinfo++) { param->key_crc[key]=0; - if (!(((ulonglong) 1 << key) & share->state.key_map)) + if (! mi_is_key_active(share->state.key_map, key)) { /* Remember old statistics for key */ memcpy((char*) rec_per_key_part, @@ -507,7 +507,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) (int) ((my_off_t2double(key_totlength) - my_off_t2double(all_keydata))*100.0/ my_off_t2double(key_totlength))); - else if (all_totaldata != 0L && share->state.key_map) + else if (all_totaldata != 0L && mi_is_any_key_active(share->state.key_map)) puts(""); } if (param->key_file_blocks != info->state->key_file_length && @@ -1034,7 +1034,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) for (key=0,keyinfo= info->s->keyinfo; key < info->s->base.keys; key++,keyinfo++) { - if ((((ulonglong) 1 << key) & info->s->state.key_map)) + if (mi_is_key_active(info->s->state.key_map, key)) { if(!(keyinfo->flag & HA_FULLTEXT)) { @@ -1298,8 +1298,8 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, */ if (param->testflag & T_CREATE_MISSING_KEYS) - share->state.key_map= ((((ulonglong) 1L << share->base.keys)-1) & - param->keys_in_use); + mi_copy_keys_active(share->state.key_map, share->base.keys, + param->keys_in_use); info->state->key_file_length=share->base.keystart; @@ -1461,7 +1461,7 @@ static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff, key=info->lastkey+info->s->base.max_key_length; for (i=0 ; i < info->s->base.keys ; i++) { - if (((ulonglong) 1 << i) & info->s->state.key_map) + if (mi_is_key_active(info->s->state.key_map, i)) { if (info->s->keyinfo[i].flag & HA_FULLTEXT ) { @@ -1492,7 +1492,7 @@ static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff, info->errkey=(int) i; /* This key was found */ while ( i-- > 0 ) { - if (((ulonglong) 1 << i) & info->s->state.key_map) + if (mi_is_key_active(info->s->state.key_map, i)) { if (info->s->keyinfo[i].flag & HA_FULLTEXT) { @@ -1529,7 +1529,7 @@ int movepoint(register MI_INFO *info, byte *record, my_off_t oldpos, key=info->lastkey+info->s->base.max_key_length; for (i=0 ; i < info->s->base.keys; i++) { - if (i != prot_key && (((ulonglong) 1 << i) & info->s->state.key_map)) + if (i != prot_key && mi_is_key_active(info->s->state.key_map, i)) { key_length=_mi_make_key(info,i,key,record,oldpos); if (info->s->keyinfo[i].flag & HA_NOSAME) @@ -1628,7 +1628,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) for (key= 0,keyinfo= &share->keyinfo[0]; key < share->base.keys ; key++,keyinfo++) { - if (!(((ulonglong) 1 << key) & share->state.key_map)) + if (! mi_is_key_active(info->s->state.key_map, key)) continue; if (share->state.key_root[key] != HA_OFFSET_ERROR) @@ -2023,7 +2023,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, sort_param.read_cache=param->read_cache; sort_param.keyinfo=share->keyinfo+sort_param.key; sort_param.seg=sort_param.keyinfo->seg; - if (!(((ulonglong) 1 << sort_param.key) & key_map)) + if (! mi_is_key_active(key_map, sort_param.key)) { /* Remember old statistics for key */ memcpy((char*) rec_per_key_part, @@ -2084,7 +2084,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, if (param->testflag & T_STATISTICS) update_key_parts(sort_param.keyinfo, rec_per_key_part, sort_param.unique, (ulonglong) info->state->records); - share->state.key_map|=(ulonglong) 1 << sort_param.key; + mi_set_key_active(share->state.key_map, sort_param.key); if (sort_param.fix_datafile) { @@ -2405,7 +2405,7 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, sort_param[i].key=key; sort_param[i].keyinfo=share->keyinfo+key; sort_param[i].seg=sort_param[i].keyinfo->seg; - if (!(((ulonglong) 1 << key) & key_map)) + if (! mi_is_key_active(key_map, key)) { /* Remember old statistics for key */ memcpy((char*) rec_per_key_part, @@ -3917,8 +3917,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, { byte *record; if (!info->s->base.auto_key || - !(((ulonglong) 1 << (info->s->base.auto_key-1) - & info->s->state.key_map))) + ! mi_is_key_active(info->s->state.key_map, info->s->base.auto_key - 1)) { if (!(param->testflag & T_VERY_SILENT)) mi_check_print_info(param, @@ -4070,7 +4069,7 @@ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows) if (!(key->flag & (HA_NOSAME | HA_SPATIAL | HA_AUTO_KEY)) && ! mi_too_big_key_for_sort(key,rows) && info->s->base.auto_key != i+1) { - share->state.key_map&= ~ ((ulonglong) 1 << i); + mi_clear_key_active(share->state.key_map, i); info->update|= HA_STATE_CHANGED; } } @@ -4094,7 +4093,7 @@ my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, mi_repair_by_sort only works if we have at least one key. If we don't have any keys, we should use the normal repair. */ - if (!key_map) + if (! mi_is_any_key_active(key_map)) return FALSE; /* Can't use sort */ for (i=0 ; i < share->base.keys ; i++,key++) { diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 33b344405ec..560535f2933 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -508,7 +508,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, mi_int2store(share.state.header.key_parts,key_segs); mi_int2store(share.state.header.unique_key_parts,unique_key_parts); - share.state.key_map = ((ulonglong) 1 << keys)-1; + mi_set_all_keys_active(share.state.key_map, keys); share.base.keystart = share.state.state.key_file_length= MY_ALIGN(info_length, myisam_block_size); share.base.max_key_block_length=max_key_block_length; diff --git a/myisam/mi_delete.c b/myisam/mi_delete.c index cc4a17182f7..60a07254e82 100644 --- a/myisam/mi_delete.c +++ b/myisam/mi_delete.c @@ -74,7 +74,7 @@ int mi_delete(MI_INFO *info,const byte *record) old_key=info->lastkey2; for (i=0 ; i < share->base.keys ; i++ ) { - if (((ulonglong) 1 << i) & info->s->state.key_map) + if (mi_is_key_active(info->s->state.key_map, i)) { info->s->keyinfo[i].version++; if (info->s->keyinfo[i].flag & HA_FULLTEXT ) diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index ba32bb9115a..bfe1748af01 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -244,7 +244,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) error=1; /* Not possibly if not lock */ break; } - if (share->state.key_map) + if (mi_is_any_key_active(share->state.key_map)) { MI_KEYDEF *key=share->keyinfo; uint i; @@ -252,7 +252,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { if (!(key->flag & HA_NOSAME) && info->s->base.auto_key != i+1) { - share->state.key_map&= ~ ((ulonglong) 1 << i); + mi_clear_key_active(share->state.key_map, i); info->update|= HA_STATE_CHANGED; } } diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 74b97a65609..82663e0c318 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -192,14 +192,14 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } share->state_diff_length=len-MI_STATE_INFO_SIZE; - mi_state_info_read(disk_cache, &share->state); + mi_state_info_read((uchar*) disk_cache, &share->state); len= mi_uint2korr(share->state.header.base_info_length); if (len != MI_BASE_INFO_SIZE) { DBUG_PRINT("warning",("saved_base_info_length: %d base_info_length: %d", len,MI_BASE_INFO_SIZE)) } - disk_pos=my_n_base_info_read(disk_cache+base_pos, &share->base); + disk_pos=my_n_base_info_read((uchar*) disk_cache + base_pos, &share->base); share->state.state_length=base_pos; if (!(open_flags & HA_OPEN_FOR_REPAIR) && @@ -863,7 +863,7 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) } -char *mi_state_info_read(char *ptr, MI_STATE_INFO *state) +char *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state) { uint i,keys,key_parts,key_blocks; memcpy_fixed(&state->header,ptr, sizeof(state->header)); @@ -929,7 +929,7 @@ uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead) } else if (my_read(file, buff, state->state_length,MYF(MY_NABP))) return (MY_FILE_ERROR); - mi_state_info_read(buff, state); + mi_state_info_read((uchar*) buff, state); } return 0; } @@ -974,7 +974,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base) } -char *my_n_base_info_read(char *ptr, MI_BASE_INFO *base) +char *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base) { base->keystart = mi_sizekorr(ptr); ptr +=8; base->max_data_file_length = mi_sizekorr(ptr); ptr +=8; @@ -1204,7 +1204,7 @@ int mi_disable_indexes(MI_INFO *info) { MYISAM_SHARE *share= info->s; - share->state.key_map= 0; + mi_clear_all_keys_active(share->state.key_map); return 0; } @@ -1240,7 +1240,7 @@ int mi_enable_indexes(MI_INFO *info) error= HA_ERR_CRASHED; } else - share->state.key_map= ((ulonglong) 1L << share->base.keys) - 1; + mi_set_all_keys_active(share->state.key_map, share->base.keys); return error; } @@ -1265,6 +1265,6 @@ int mi_indexes_are_disabled(MI_INFO *info) { MYISAM_SHARE *share= info->s; - return (! share->state.key_map && share->base.keys); + return (! mi_is_any_key_active(share->state.key_map) && share->base.keys); } diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 317ab4ad7fe..d63399b519d 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -51,7 +51,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) my_off_t pos= share->base.keystart; DBUG_ENTER("mi_preload"); - if (!keys || !key_map || key_file_length == pos) + if (!keys || !mi_is_any_key_active(key_map) || key_file_length == pos) DBUG_RETURN(0); block_length= keyinfo[0].block_length; diff --git a/myisam/mi_rsame.c b/myisam/mi_rsame.c index 56c8d1226ca..321097744b9 100644 --- a/myisam/mi_rsame.c +++ b/myisam/mi_rsame.c @@ -30,7 +30,7 @@ int mi_rsame(MI_INFO *info, byte *record, int inx) { DBUG_ENTER("mi_rsame"); - if (inx != -1 && ! (((ulonglong) 1 << inx) & info->s->state.key_map)) + if (inx != -1 && ! mi_is_key_active(info->s->state.key_map, inx)) { DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); } diff --git a/myisam/mi_rsamepos.c b/myisam/mi_rsamepos.c index a1d96fb7104..35cdd41e297 100644 --- a/myisam/mi_rsamepos.c +++ b/myisam/mi_rsamepos.c @@ -32,7 +32,7 @@ int mi_rsame_with_pos(MI_INFO *info, byte *record, int inx, my_off_t filepos) { DBUG_ENTER("mi_rsame_with_pos"); - if (inx < -1 || ! (((ulonglong) 1 << inx) & info->s->state.key_map)) + if (inx < -1 || ! mi_is_key_active(info->s->state.key_map, inx)) { DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); } diff --git a/myisam/mi_search.c b/myisam/mi_search.c index c669a8be8f8..ed61bbfe41a 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -29,7 +29,7 @@ int _mi_check_index(MI_INFO *info, int inx) { if (inx == -1) /* Use last index */ inx=info->lastinx; - if (inx < 0 || ! (((ulonglong) 1 << inx) & info->s->state.key_map)) + if (inx < 0 || ! mi_is_key_active(info->s->state.key_map, inx)) { my_errno=HA_ERR_WRONG_INDEX; return -1; diff --git a/myisam/mi_update.c b/myisam/mi_update.c index cda60694008..ab23f2e6da9 100644 --- a/myisam/mi_update.c +++ b/myisam/mi_update.c @@ -87,7 +87,7 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) changed=0; for (i=0 ; i < share->base.keys ; i++) { - if (((ulonglong) 1 << i) & share->state.key_map) + if (mi_is_key_active(share->state.key_map, i)) { if (share->keyinfo[i].flag & HA_FULLTEXT ) { diff --git a/myisam/mi_write.c b/myisam/mi_write.c index dd062b79769..c8f9aa84a41 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -101,7 +101,7 @@ int mi_write(MI_INFO *info, byte *record) buff=info->lastkey2; for (i=0 ; i < share->base.keys ; i++) { - if (((ulonglong) 1 << i) & share->state.key_map) + if (mi_is_key_active(share->state.key_map, i)) { bool local_lock_tree= (lock_tree && !(info->bulk_insert && @@ -175,7 +175,7 @@ err: info->errkey= (int) i; while ( i-- > 0) { - if (((ulonglong) 1 << i) & share->state.key_map) + if (mi_is_key_active(share->state.key_map, i)) { bool local_lock_tree= (lock_tree && !(info->bulk_insert && @@ -944,20 +944,21 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows) MI_KEYDEF *key=share->keyinfo; bulk_insert_param *params; uint i, num_keys, total_keylength; - ulonglong key_map=0; + ulonglong key_map; DBUG_ENTER("_mi_init_bulk_insert"); DBUG_PRINT("enter",("cache_size: %lu", cache_size)); DBUG_ASSERT(!info->bulk_insert && (!rows || rows >= MI_MIN_ROWS_TO_USE_BULK_INSERT)); + mi_clear_all_keys_active(key_map); for (i=total_keylength=num_keys=0 ; i < share->base.keys ; i++) { - if (!(key[i].flag & HA_NOSAME) && share->base.auto_key != i+1 - && test(share->state.key_map & ((ulonglong) 1 << i))) + if (! (key[i].flag & HA_NOSAME) && (share->base.auto_key != i + 1) && + mi_is_key_active(share->state.key_map, i)) { num_keys++; - key_map |=((ulonglong) 1 << i); + mi_set_key_active(key_map, i); total_keylength+=key[i].maxlength+TREE_ELEMENT_EXTRA_SIZE; } } @@ -981,7 +982,7 @@ int mi_init_bulk_insert(MI_INFO *info, ulong cache_size, ha_rows rows) params=(bulk_insert_param *)(info->bulk_insert+share->base.keys); for (i=0 ; i < share->base.keys ; i++) { - if (test(key_map & ((ulonglong) 1 << i))) + if (mi_is_key_active(key_map, i)) { params->info=info; params->keynr=i; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 519e123e9da..4856d93b320 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -871,8 +871,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) MI_STATE_INFO_SIZE || mi_uint2korr(share->state.header.base_info_length) != MI_BASE_INFO_SIZE || - ((param->keys_in_use & ~share->state.key_map) & - (((ulonglong) 1L << share->base.keys)-1)) || + mi_is_any_intersect_keys_active(param->keys_in_use, share->base.keys, + ~share->state.key_map) || test_if_almost_full(info) || info->s->state.header.file_version[3] != myisam_file_magic[3] || (set_collation && @@ -939,8 +939,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) if (param->testflag & T_REP_ANY) { ulonglong tmp=share->state.key_map; - share->state.key_map= (((ulonglong) 1 << share->base.keys)-1) - & param->keys_in_use; + mi_copy_keys_active(share->state.key_map, share->base.keys, + param->keys_in_use); if (tmp != share->state.key_map) info->update|=HA_STATE_CHANGED; } @@ -961,7 +961,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) if (!error) { if ((param->testflag & (T_REP_BY_SORT | T_REP_PARALLEL)) && - (share->state.key_map || + (mi_is_any_key_active(share->state.key_map) || (rep_quick && !param->keys_in_use && !recreate)) && mi_test_if_sort_rep(info, info->state->records, info->s->state.key_map, @@ -1037,7 +1037,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) llstr(info->state->records,llbuff), llstr(info->state->del,llbuff2)); error =chk_status(param,info); - share->state.key_map &=param->keys_in_use; + mi_intersect_keys_active(share->state.key_map, param->keys_in_use); error =chk_size(param,info); if (!error || !(param->testflag & (T_FAST | T_FORCE_CREATE))) error|=chk_del(param, info,param->testflag); @@ -1266,7 +1266,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name) } printf("Recordlength: %13d\n",(int) share->base.pack_reclength); - if (share->state.key_map != (((ulonglong) 1 << share->base.keys) -1)) + if (! mi_is_all_keys_active(share->state.key_map, share->base.keys)) { longlong2str(share->state.key_map,buff,2); printf("Using only keys '%s' of %d possibly keys\n", @@ -1448,7 +1448,7 @@ static int mi_sort_records(MI_CHECK *param, temp_buff=0; new_file= -1; - if (!(((ulonglong) 1 << sort_key) & share->state.key_map)) + if (! mi_is_key_active(share->state.key_map, sort_key)) { mi_check_print_warning(param, "Can't sort table '%s' on key %d; No such key", diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 5688b377d3d..74463ec065a 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -676,10 +676,10 @@ extern void _mi_unmap_file(MI_INFO *info); extern uint save_pack_length(byte *block_buff,ulong length); uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite); -char *mi_state_info_read(char *ptr, MI_STATE_INFO *state); +char *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state); uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead); uint mi_base_info_write(File file, MI_BASE_INFO *base); -char *my_n_base_info_read(char *ptr, MI_BASE_INFO *base); +char *my_n_base_info_read(uchar *ptr, MI_BASE_INFO *base); int mi_keyseg_write(File file, const HA_KEYSEG *keyseg); char *mi_keyseg_read(char *ptr, HA_KEYSEG *keyseg); uint mi_keydef_write(File file, MI_KEYDEF *keydef); diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index dc98d813266..de55b86252c 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -810,7 +810,7 @@ static int find_record_with_key(struct file_info *file_info, byte *record) for (key=0 ; key < info->s->base.keys ; key++) { - if ((((ulonglong) 1 << key) & info->s->state.key_map) && + if (mi_is_key_active(info->s->state.key_map, key) && info->s->keyinfo[key].flag & HA_NOSAME) { VOID(_mi_make_key(info,key,tmp_key,record,0L)); diff --git a/myisam/myisampack.c b/myisam/myisampack.c index daf2bbdf85c..ba48cbf1b62 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -441,9 +441,9 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY))) goto error; - mrg->src_file_has_indexes_disabled|= ((mrg->file[i]->s->state.key_map != - (((ulonglong) 1) << - mrg->file[i]->s->base. keys) - 1)); + mrg->src_file_has_indexes_disabled|= + ! mi_is_all_keys_active(mrg->file[i]->s->state.key_map, + mrg->file[i]->s->base.keys); } /* Check that files are identical */ for (j=0 ; j < count-1 ; j++) @@ -2941,7 +2941,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, share->state.dellink= HA_OFFSET_ERROR; share->state.split=(ha_rows) mrg->records; share->state.version=(ulong) time((time_t*) 0); - if (share->state.key_map != (ULL(1) << share->base.keys) - 1) + if (! mi_is_all_keys_active(share->state.key_map, share->base.keys)) { /* Some indexes are disabled, cannot use current key_file_length value @@ -2955,7 +2955,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, original file so "myisamchk -rq" can use this value (this is necessary because index size cannot be easily calculated for fulltext keys) */ - share->state.key_map=0; + mi_clear_all_keys_active(share->state.key_map); for (key=0 ; key < share->base.keys ; key++) share->state.key_root[key]= HA_OFFSET_ERROR; for (key=0 ; key < share->state.header.max_block_size ; key++) @@ -2995,7 +2995,7 @@ static int save_state_mrg(File file,PACK_MRG_INFO *mrg,my_off_t new_length, } state.dellink= HA_OFFSET_ERROR; state.version=(ulong) time((time_t*) 0); - state.key_map=0; + mi_clear_all_keys_active(state.key_map); state.checksum=crc; if (isam_file->s->base.keys) isamchk_neaded=1; diff --git a/myisam/sort.c b/myisam/sort.c index 9d2af2e8c70..f2f8c8ef7ec 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -479,7 +479,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) } if (!got_error) { - share->state.key_map|=(ulonglong) 1 << sinfo->key; + mi_set_key_active(share->state.key_map, sinfo->key); if (param->testflag & T_STATISTICS) update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique, (ulonglong) info->state->records); diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 1cf4b4707cb..7692991c112 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -150,9 +150,6 @@ INSERT INTO federated.t1 (name, other) VALUES ('Seventh Name', 77777); INSERT INTO federated.t1 (name, other) VALUES ('Eigth Name', 88888); INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999); INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010); -EXPLAIN SELECT * FROM federated.t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 SELECT * FROM federated.t1; id name other created 1 First Name 11111 2004-04-04 04:04:04 @@ -165,32 +162,17 @@ id name other created 8 Eigth Name 88888 2004-04-04 04:04:04 9 Ninth Name 99999 2004-04-04 04:04:04 10 Tenth Name 101010 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 SELECT * FROM federated.t1 WHERE id = 5; id name other created 5 Fifth Name 55555 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; id name other created 6 Sixth Name 66666 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; id name other created 6 Sixth Name 66666 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; id name other created -EXPLAIN SELECT * FROM federated.t1 WHERE name like '%th%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE name like '%th%'; id name other created 3 Third Name 33333 2004-04-04 04:04:04 @@ -209,9 +191,6 @@ UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name'; SELECT * FROM federated.t1 WHERE name = 'Third name'; id name other created 3 Third name 33333 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 ORDER BY id DESC; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort SELECT * FROM federated.t1 ORDER BY id DESC; id name other created 10 Tenth Name 101010 2004-04-04 04:04:04 @@ -224,9 +203,6 @@ id name other created 3 Third name 33333 2004-04-04 04:04:04 2 Second Name 22222 2004-04-04 04:04:04 1 First Name 11111 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 ORDER BY name; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort SELECT * FROM federated.t1 ORDER BY name; id name other created 8 Eigth Name 88888 2004-04-04 04:04:04 @@ -239,9 +215,6 @@ id name other created 6 Sixth Name 66666 2004-04-04 04:04:04 10 Tenth Name 101010 2004-04-04 04:04:04 3 Third name 33333 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 ORDER BY name DESC; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort SELECT * FROM federated.t1 ORDER BY name DESC; id name other created 3 Third name 33333 2004-04-04 04:04:04 @@ -254,9 +227,6 @@ id name other created 1 First Name 11111 2004-04-04 04:04:04 5 Fifth Name 55555 2004-04-04 04:04:04 8 Eigth Name 88888 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 ORDER BY name ASC; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort SELECT * FROM federated.t1 ORDER BY name ASC; id name other created 8 Eigth Name 88888 2004-04-04 04:04:04 @@ -269,9 +239,6 @@ id name other created 6 Sixth Name 66666 2004-04-04 04:04:04 10 Tenth Name 101010 2004-04-04 04:04:04 3 Third name 33333 2004-04-04 04:04:04 -EXPLAIN SELECT * FROM federated.t1 GROUP BY other; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort SELECT * FROM federated.t1 GROUP BY other; id name other created 1 First Name 11111 2004-04-04 04:04:04 @@ -333,9 +300,6 @@ INSERT INTO federated.t1 (name, other, created) VALUES ('Ninth Name', 99999, '2005-03-12 11:00:01'); INSERT INTO federated.t1 (name, other, created) VALUES ('Tenth Name', 101010, '2005-03-12 12:00:01'); -EXPLAIN SELECT * FROM federated.t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 SELECT * FROM federated.t1; id name other created 1 First Name 11111 2004-01-01 01:01:01 @@ -348,33 +312,15 @@ id name other created 8 Eigth Name 88888 2005-03-12 11:00:00 9 Ninth Name 99999 2005-03-12 11:00:01 10 Tenth Name 101010 2005-03-12 12:00:01 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 SELECT * FROM federated.t1 WHERE id = 5; id name other created 5 Fifth Name 55555 2001-02-02 02:02:02 -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref name name 34 const 2 Using where -SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -id name other created -6 Sixth Name 66666 2005-06-06 15:30:00 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 const PRIMARY,name PRIMARY 4 const 1 SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; id name other created 6 Sixth Name 66666 2005-06-06 15:30:00 -EXPLAIN SELECT * FROM federated.t1 WHERE other = 44444; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref other other 4 const 2 SELECT * FROM federated.t1 WHERE other = 44444; id name other created 4 Fourth Name 44444 2003-04-05 00:00:00 -EXPLAIN SELECT * FROM federated.t1 WHERE name like '%th%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE name like '%th%'; id name other created 3 Third Name 33333 2004-02-14 02:14:00 @@ -664,113 +610,49 @@ INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES (9, 'nine Nine', 999999, 999999); INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES (10, 'Tenth ten TEN', 1010101, 1010); -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'two two'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref col2 col2 66 const 2 Using where SELECT * FROM federated.t1 WHERE col2 = 'two two'; id col1 col2 col3 col4 2 2 Two two 22 2222 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'two Two'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref col2 col2 66 const 2 Using where SELECT * FROM federated.t1 WHERE col2 = 'two Two'; id col1 col2 col3 col4 2 2 Two two 22 2222 SELECT * FROM federated.t1 WHERE id = 3; id col1 col2 col3 col4 3 3 three Three 33 33333 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 3; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY PRIMARY 4 const 2 SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; id col1 col2 col3 col4 3 3 three Three 33 33333 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col1 PRIMARY 8 const,const 2 SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; id col1 col2 col3 col4 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col1,col2 PRIMARY 74 const,const,const 2 Using where SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; id col1 col2 col3 col4 4 4 fourfourfour 444 4444444 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col1,col2 PRIMARY 74 const,const,const 2 Using where SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5; id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' -AND col3 = 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col2,col3 PRIMARY 4 const 2 Using where -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' -AND col3 = 5 -AND col4 = 55555; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col2,col3,col4 PRIMARY 4 const 2 Using where SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5 AND col4 = 55555; id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 -AND col2 = 'Two two' AND col3 = 22 -AND col4 = 33; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col2,col3,col4 PRIMARY 4 const 2 Using where SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'Two two' AND col3 = 22 AND col4 = 33; id col1 col2 col3 col4 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 -AND col2 = 'five 5 five five 5' AND col3 = 5 -AND col4 = 55555; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col2,col3,col4 PRIMARY 4 const 2 Using where SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5 AND col4 = 55555; id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') -OR (col2 = 'three Three' AND col3 = 33); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,col2,col3 col2 66 NULL 4 Using where SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') OR (col2 = 'three Three' AND col3 = 33); id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 3 3 three Three 33 33333 -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') -OR (col2 = 'three Three' AND col3 = 33) -OR col4 = 1010; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,col2,col3,col4 NULL NULL NULL 10 Using where -SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') -OR (col2 = 'three Three' AND col3 = 33) -OR col4 = 1010; -id col1 col2 col3 col4 -3 3 three Three 33 33333 -5 5 five 5 five five 5 5 55555 -10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') -OR (col2 = 444 AND col3 = 4444444); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,col2,col3 NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') OR (col2 = 444 AND col3 = 4444444); id col1 col2 col3 col4 -EXPLAIN SELECT * FROM federated.t1 WHERE id = 1 -OR col1 = 10 -OR col2 = 'Two two' -OR col3 = 33 -OR col4 = 4444444; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL PRIMARY,col1,col2,col3,col4 NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE id = 1 OR col1 = 10 OR col2 = 'Two two' @@ -782,9 +664,6 @@ id col1 col2 col3 col4 3 3 three Three 33 33333 4 4 fourfourfour 444 4444444 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE id > 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id > 5; id col1 col2 col3 col4 6 6 six six Sixsix 6666 6 @@ -792,9 +671,6 @@ id col1 col2 col3 col4 8 8 eight eight eight 88888 88 9 9 nine Nine 999999 999999 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE id >= 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id >= 5; id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 @@ -803,18 +679,12 @@ id col1 col2 col3 col4 8 8 eight eight eight 88888 88 9 9 nine Nine 999999 999999 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE id < 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id < 5; id col1 col2 col3 col4 1 1 one One 11 1111 2 2 Two two 22 2222 3 3 three Three 33 33333 4 4 fourfourfour 444 4444444 -EXPLAIN SELECT * FROM federated.t1 WHERE id <= 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id <= 5; id col1 col2 col3 col4 1 1 one One 11 1111 @@ -822,9 +692,6 @@ id col1 col2 col3 col4 3 3 three Three 33 33333 4 4 fourfourfour 444 4444444 5 5 five 5 five five 5 5 55555 -EXPLAIN SELECT * FROM federated.t1 WHERE id != 5; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where SELECT * FROM federated.t1 WHERE id != 5; id col1 col2 col3 col4 1 1 one One 11 1111 @@ -836,26 +703,17 @@ id col1 col2 col3 col4 8 8 eight eight eight 88888 88 9 9 nine Nine 999999 999999 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; id col1 col2 col3 col4 4 4 fourfourfour 444 4444444 5 5 five 5 five five 5 5 55555 6 6 six six Sixsix 6666 6 -EXPLAIN SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; id col1 col2 col3 col4 4 4 fourfourfour 444 4444444 5 5 five 5 five five 5 5 55555 6 6 six six Sixsix 6666 6 7 7 seven Sevenseven 77777 7777 -EXPLAIN SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; id col1 col2 col3 col4 3 3 three Three 33 33333 @@ -863,21 +721,12 @@ id col1 col2 col3 col4 5 5 five 5 five five 5 5 55555 6 6 six six Sixsix 6666 6 7 7 seven Sevenseven 77777 7777 -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using where SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; id col1 col2 col3 col4 1 1 one One 11 1111 2 2 Two two 22 2222 -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; id col1 col2 col3 col4 -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; id col1 col2 col3 col4 1 1 one One 11 1111 @@ -885,15 +734,9 @@ id col1 col2 col3 col4 8 8 eight eight eight 88888 88 9 9 nine Nine 999999 999999 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'three Three'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref col2 col2 66 const 2 Using where SELECT * FROM federated.t1 WHERE col2 = 'three Three'; id col1 col2 col3 col4 3 3 three Three 33 33333 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 > 'one'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range col2 col2 66 NULL 2 Using where SELECT * FROM federated.t1 WHERE col2 > 'one'; id col1 col2 col3 col4 1 1 one One 11 1111 @@ -902,28 +745,16 @@ id col1 col2 col3 col4 6 6 six six Sixsix 6666 6 7 7 seven Sevenseven 77777 7777 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range col2 col2 66 NULL 2 Using where SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; id col1 col2 col3 col4 7 7 seven Sevenseven 77777 7777 6 6 six six Sixsix 6666 6 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range col2 col2 66 NULL 2 Using where SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; id col1 col2 col3 col4 6 6 six six Sixsix 6666 6 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range col2 col2 66 NULL 2 Using where SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; id col1 col2 col3 col4 7 7 seven Sevenseven 77777 7777 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using where SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; id col1 col2 col3 col4 1 1 one One 11 1111 @@ -935,9 +766,6 @@ id col1 col2 col3 col4 7 7 seven Sevenseven 77777 7777 9 9 nine Nine 999999 999999 10 10 Tenth ten TEN 1010101 1010 -EXPLAIN SELECT * FROM federated.t1 WHERE col2 <> 'one One'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range col2 col2 66 NULL 4 Using where SELECT * FROM federated.t1 WHERE col2 <> 'one One'; id col1 col2 col3 col4 4 4 fourfourfour 444 4444444 @@ -987,45 +815,24 @@ INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES ('gggg', 'ggggggggggggggggggg', 'gagagagaga', 'gcgcgcgcgcgcgcgc'); INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES ('hhhh', 'hhhhhhhhhhhhhhhhhhh', 'hahahahaha', 'hchchchchchchchc'); -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'cccc'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY PRIMARY 10 const 2 Using where SELECT * FROM federated.t1 WHERE col1 = 'cccc'; col1 col2 col3 col4 cccc ccccccccccccccccccc cacacacaca cbcbcbcbcbcbcbcb -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref 3key 3key 130 const 2 Using where SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; col1 col2 col3 col4 eeee eeeeeeeeeeeeeeeeeee eaeaeaeaea ecececececececec -EXPLAIN SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref 2key 2key 22 const 2 Using where SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; col1 col2 col3 col4 bbbb bbbbbbbbbbbbbbbbbbb bababababa bcbcbcbcbcbcbcbc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,3key PRIMARY 140 const,const 2 Using where SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; col1 col2 col3 col4 gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,2key PRIMARY 10 const 2 Using where SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; col1 col2 col3 col4 gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref PRIMARY,col4 PRIMARY 10 const 2 Using where SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; col1 col2 col3 col4 ffff fffffffffffffffffff fafafafafa fcfcfcfcfcfcfcfc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 2 Using where SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; col1 col2 col3 col4 cccc ccccccccccccccccccc cacacacaca cbcbcbcbcbcbcbcb @@ -1034,9 +841,6 @@ eeee eeeeeeeeeeeeeeeeeee eaeaeaeaea ecececececececec ffff fffffffffffffffffff fafafafafa fcfcfcfcfcfcfcfc gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc hhhh hhhhhhhhhhhhhhhhhhh hahahahaha hchchchchchchchc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 2 Using where SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; col1 col2 col3 col4 bbbb bbbbbbbbbbbbbbbbbbb bababababa bcbcbcbcbcbcbcbc @@ -1046,22 +850,13 @@ eeee eeeeeeeeeeeeeeeeeee eaeaeaeaea ecececececececec ffff fffffffffffffffffff fafafafafa fcfcfcfcfcfcfcfc gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc hhhh hhhhhhhhhhhhhhhhhhh hahahahaha hchchchchchchchc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 2 Using where SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; col1 col2 col3 col4 aaaa aaaaaaaaaaaaaaaaaaa ababababab acacacacacacacac -EXPLAIN SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 2 Using where SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; col1 col2 col3 col4 aaaa aaaaaaaaaaaaaaaaaaa ababababab acacacacacacacac bbbb bbbbbbbbbbbbbbbbbbb bababababa bcbcbcbcbcbcbcbc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 4 Using where SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; col1 col2 col3 col4 aaaa aaaaaaaaaaaaaaaaaaa ababababab acacacacacacacac @@ -1071,22 +866,13 @@ eeee eeeeeeeeeeeeeeeeeee eaeaeaeaea ecececececececec ffff fffffffffffffffffff fafafafafa fcfcfcfcfcfcfcfc gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc hhhh hhhhhhhhhhhhhhhhhhh hahahahaha hchchchchchchchc -EXPLAIN SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 10 NULL 2 Using where SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; col1 col2 col3 col4 bbbb bbbbbbbbbbbbbbbbbbb bababababa bcbcbcbcbcbcbcbc -EXPLAIN SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; col1 col2 col3 col4 bbbb bbbbbbbbbbbbbbbbbbb bababababa bcbcbcbcbcbcbcbc cccc ccccccccccccccccccc cacacacaca cbcbcbcbcbcbcbcb -EXPLAIN SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; col1 col2 col3 col4 aaaa aaaaaaaaaaaaaaaaaaa ababababab acacacacacacacac @@ -1096,9 +882,6 @@ eeee eeeeeeeeeeeeeeeeeee eaeaeaeaea ecececececececec ffff fffffffffffffffffff fafafafafa fcfcfcfcfcfcfcfc gggg ggggggggggggggggggg gagagagaga gcgcgcgcgcgcgcgc hhhh hhhhhhhhhhhhhhhhhhh hahahahaha hchchchchchchchc -EXPLAIN SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using where SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; col1 col2 col3 col4 DROP TABLE IF EXISTS federated.t1; @@ -1121,11 +904,6 @@ INSERT INTO federated.t1 VALUES ('aaa', '111', 'ccc'); INSERT INTO federated.t1 VALUES ('bbb', '222', 'yyy'); INSERT INTO federated.t1 VALUES ('ccc', '111', 'zzz'); INSERT INTO federated.t1 VALUES ('ccd', '112', 'zzzz'); -EXPLAIN SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 14 NULL 3 Using where; Using index SELECT col3 FROM federated.t1 WHERE ( (col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND (col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); @@ -1133,11 +911,6 @@ col3 ccc yyy zzz -EXPLAIN SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY PRIMARY 20 NULL 6 Using where SELECT col3 FROM federated.t1 WHERE ( (col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND (col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); @@ -1182,13 +955,6 @@ AND floatval IS NULL AND other IS NULL; count(*) 2 -EXPLAIN SELECT count(*) FROM federated.t1 -WHERE id IS NULL -AND name IS NULL -AND floatval IS NULL -AND other IS NULL; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where DROP TABLE IF EXISTS federated.t1; CREATE TABLE federated.t1 ( `blurb_id` int NOT NULL DEFAULT 0, @@ -1230,30 +996,6 @@ ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4); -EXPLAIN SELECT * FROM federated.t1 ORDER BY a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT * FROM federated.t1 ORDER BY b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT * FROM federated.t1 ORDER BY c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT a FROM federated.t1 ORDER BY a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT b FROM federated.t1 ORDER BY b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT a,b FROM federated.t1 ORDER BY b; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort -EXPLAIN SELECT a,b FROM federated.t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 -EXPLAIN SELECT a,b,c FROM federated.t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 4 DROP TABLE IF EXISTS federated.t1; CREATE TABLE federated.t1 (i1 int, i2 int, i3 int, i4 int, i5 int, i6 int, i7 int, i8 int, i9 int, i10 int, i11 int, i12 int, i13 int, i14 int, i15 int, i16 int, i17 @@ -1553,9 +1295,6 @@ values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "PatrickG"); UPDATE federated.t1 SET b=repeat('a',256); UPDATE federated.t1 SET i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0; -EXPLAIN SELECT * FROM federated.t1 WHERE i9=0 and i10=0; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where SELECT * FROM federated.t1 WHERE i9=0 and i10=0; i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20 i21 i22 i23 i24 i25 i26 i27 i28 i29 i30 i31 i32 i33 i34 i35 i36 i37 i38 i39 i40 i41 i42 i43 i44 i45 i46 i47 i48 i49 i50 i51 i52 i53 i54 i55 i56 i57 i58 i59 i60 i61 i62 i63 i64 i65 i66 i67 i68 i69 i70 i71 i72 i73 i74 i75 i76 i77 i78 i79 i80 i81 i82 i83 i84 i85 i86 i87 i88 i89 i90 i91 i92 i93 i94 i95 i96 i97 i98 i99 i100 i101 i102 i103 i104 i105 i106 i107 i108 i109 i110 i111 i112 i113 i114 i115 i116 i117 i118 i119 i120 i121 i122 i123 i124 i125 i126 i127 i128 i129 i130 i131 i132 i133 i134 i135 i136 i137 i138 i139 i140 i141 i142 i143 i144 i145 i146 i147 i148 i149 i150 i151 i152 i153 i154 i155 i156 i157 i158 i159 i160 i161 i162 i163 i164 i165 i166 i167 i168 i169 i170 i171 i172 i173 i174 i175 i176 i177 i178 i179 i180 i181 i182 i183 i184 i185 i186 i187 i188 i189 i190 i191 i192 i193 i194 i195 i196 i197 i198 i199 i200 i201 i202 i203 i204 i205 i206 i207 i208 i209 i210 i211 i212 i213 i214 i215 i216 i217 i218 i219 i220 i221 i222 i223 i224 i225 i226 i227 i228 i229 i230 i231 i232 i233 i234 i235 i236 i237 i238 i239 i240 i241 i242 i243 i244 i245 i246 i247 i248 i249 i250 i251 i252 i253 i254 i255 i256 i257 i258 i259 i260 i261 i262 i263 i264 i265 i266 i267 i268 i269 i270 i271 i272 i273 i274 i275 i276 i277 i278 i279 i280 i281 i282 i283 i284 i285 i286 i287 i288 i289 i290 i291 i292 i293 i294 i295 i296 i297 i298 i299 i300 i301 i302 i303 i304 i305 i306 i307 i308 i309 i310 i311 i312 i313 i314 i315 i316 i317 i318 i319 i320 i321 i322 i323 i324 i325 i326 i327 i328 i329 i330 i331 i332 i333 i334 i335 i336 i337 i338 i339 i340 i341 i342 i343 i344 i345 i346 i347 i348 i349 i350 i351 i352 i353 i354 i355 i356 i357 i358 i359 i360 i361 i362 i363 i364 i365 i366 i367 i368 i369 i370 i371 i372 i373 i374 i375 i376 i377 i378 i379 i380 i381 i382 i383 i384 i385 i386 i387 i388 i389 i390 i391 i392 i393 i394 i395 i396 i397 i398 i399 i400 i401 i402 i403 i404 i405 i406 i407 i408 i409 i410 i411 i412 i413 i414 i415 i416 i417 i418 i419 i420 i421 i422 i423 i424 i425 i426 i427 i428 i429 i430 i431 i432 i433 i434 i435 i436 i437 i438 i439 i440 i441 i442 i443 i444 i445 i446 i447 i448 i449 i450 i451 i452 i453 i454 i455 i456 i457 i458 i459 i460 i461 i462 i463 i464 i465 i466 i467 i468 i469 i470 i471 i472 i473 i474 i475 i476 i477 i478 i479 i480 i481 i482 i483 i484 i485 i486 i487 i488 i489 i490 i491 i492 i493 i494 i495 i496 i497 i498 i499 i500 i501 i502 i503 i504 i505 i506 i507 i508 i509 i510 i511 i512 i513 i514 i515 i516 i517 i518 i519 i520 i521 i522 i523 i524 i525 i526 i527 i528 i529 i530 i531 i532 i533 i534 i535 i536 i537 i538 i539 i540 i541 i542 i543 i544 i545 i546 i547 i548 i549 i550 i551 i552 i553 i554 i555 i556 i557 i558 i559 i560 i561 i562 i563 i564 i565 i566 i567 i568 i569 i570 i571 i572 i573 i574 i575 i576 i577 i578 i579 i580 i581 i582 i583 i584 i585 i586 i587 i588 i589 i590 i591 i592 i593 i594 i595 i596 i597 i598 i599 i600 i601 i602 i603 i604 i605 i606 i607 i608 i609 i610 i611 i612 i613 i614 i615 i616 i617 i618 i619 i620 i621 i622 i623 i624 i625 i626 i627 i628 i629 i630 i631 i632 i633 i634 i635 i636 i637 i638 i639 i640 i641 i642 i643 i644 i645 i646 i647 i648 i649 i650 i651 i652 i653 i654 i655 i656 i657 i658 i659 i660 i661 i662 i663 i664 i665 i666 i667 i668 i669 i670 i671 i672 i673 i674 i675 i676 i677 i678 i679 i680 i681 i682 i683 i684 i685 i686 i687 i688 i689 i690 i691 i692 i693 i694 i695 i696 i697 i698 i699 i700 i701 i702 i703 i704 i705 i706 i707 i708 i709 i710 i711 i712 i713 i714 i715 i716 i717 i718 i719 i720 i721 i722 i723 i724 i725 i726 i727 i728 i729 i730 i731 i732 i733 i734 i735 i736 i737 i738 i739 i740 i741 i742 i743 i744 i745 i746 i747 i748 i749 i750 i751 i752 i753 i754 i755 i756 i757 i758 i759 i760 i761 i762 i763 i764 i765 i766 i767 i768 i769 i770 i771 i772 i773 i774 i775 i776 i777 i778 i779 i780 i781 i782 i783 i784 i785 i786 i787 i788 i789 i790 i791 i792 i793 i794 i795 i796 i797 i798 i799 i800 i801 i802 i803 i804 i805 i806 i807 i808 i809 i810 i811 i812 i813 i814 i815 i816 i817 i818 i819 i820 i821 i822 i823 i824 i825 i826 i827 i828 i829 i830 i831 i832 i833 i834 i835 i836 i837 i838 i839 i840 i841 i842 i843 i844 i845 i846 i847 i848 i849 i850 i851 i852 i853 i854 i855 i856 i857 i858 i859 i860 i861 i862 i863 i864 i865 i866 i867 i868 i869 i870 i871 i872 i873 i874 i875 i876 i877 i878 i879 i880 i881 i882 i883 i884 i885 i886 i887 i888 i889 i890 i891 i892 i893 i894 i895 i896 i897 i898 i899 i900 i901 i902 i903 i904 i905 i906 i907 i908 i909 i910 i911 i912 i913 i914 i915 i916 i917 i918 i919 i920 i921 i922 i923 i924 i925 i926 i927 i928 i929 i930 i931 i932 i933 i934 i935 i936 i937 i938 i939 i940 i941 i942 i943 i944 i945 i946 i947 i948 i949 i950 i951 i952 i953 i954 i955 i956 i957 i958 i959 i960 i961 i962 i963 i964 i965 i966 i967 i968 i969 i970 i971 i972 i973 i974 i975 i976 i977 i978 i979 i980 i981 i982 i983 i984 i985 i986 i987 i988 i989 i990 i991 i992 i993 i994 i995 i996 i997 i998 i999 i1000 b 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa @@ -1645,13 +1384,6 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Lenz', 2, 22222); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Marizio', 3, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1, federated.countries WHERE -federated.t1.country_id = federated.countries.id; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 -1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 2 SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1, federated.countries WHERE @@ -1662,13 +1394,6 @@ Lenz 2 22222 Germany Marizio 3 33333 Italy Monty 4 33333 Finland Sanja 5 33333 Ukraine -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 -1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 2 SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -1679,14 +1404,6 @@ Lenz 2 22222 Germany Marizio 3 33333 Italy Monty 4 33333 Finland Sanja 5 33333 Ukraine -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id -WHERE federated.t1.name = 'Monty'; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE countries ALL PRIMARY NULL NULL NULL 5 -1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 2 Using where SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -1694,13 +1411,6 @@ federated.t1.country_id = federated.countries.id WHERE federated.t1.name = 'Monty'; name country_id other country Monty 4 33333 Finland -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.id; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort -1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -1711,13 +1421,6 @@ id country_id name other country 3 3 Marizio 33333 Italy 4 4 Monty 33333 Finland 5 5 Sanja 33333 Ukraine -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.country; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort -1 SIMPLE countries eq_ref PRIMARY PRIMARY 4 federated.t1.country_id 1 SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -1728,13 +1431,6 @@ id country_id name other country 1 1 Kumar 11111 India 3 3 Marizio 33333 Italy 5 5 Sanja 33333 Ukraine -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 RIGHT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.t1.country_id; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE countries ALL NULL NULL NULL NULL 5 Using temporary; Using filesort -1 SIMPLE t1 ref country_id country_id 4 federated.countries.id 2 SELECT federated.t1.*, federated.countries.country FROM federated.t1 RIGHT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -1746,6 +1442,21 @@ id country_id name other country 4 4 Monty 33333 Finland 5 5 Sanja 33333 Ukraine DROP TABLE federated.countries; +OPTIMIZE TABLE federated.t1; +Table Op Msg_type Msg_text +federated.t1 optimize status OK +REPAIR TABLE federated.t1; +Table Op Msg_type Msg_text +federated.t1 repair status OK +REPAIR TABLE federated.t1 QUICK; +Table Op Msg_type Msg_text +federated.t1 repair status OK +REPAIR TABLE federated.t1 EXTENDED; +Table Op Msg_type Msg_text +federated.t1 repair status OK +REPAIR TABLE federated.t1 USE_FRM; +Table Op Msg_type Msg_text +federated.t1 repair status OK DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 98f3d59485f..2b84dee18c1 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -153,7 +153,7 @@ c varchar(64) utf8_general_ci NO select,insert,update,references select * from information_schema.COLUMNS where table_name="t1" and column_name= "a"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT -NULL mysqltest t1 a 1 NULL YES int NULL NULL 11 0 NULL NULL int(11) select,insert,update,references +NULL mysqltest t1 a 1 NULL YES int NULL NULL 10 NULL NULL NULL int(11) select,insert,update,references show columns from mysqltest.t1 where field like "%a%"; Field Type Null Key Default Extra a int(11) YES NULL @@ -298,6 +298,9 @@ show create function sub2; Function sql_mode Create Function sub2 CREATE FUNCTION `test`.`sub2`(i int) RETURNS int(11) return i+1 +show function status like "sub2"; +Db Name Type Definer Modified Created Security_type Comment +test sub2 FUNCTION mysqltest_1@localhost # # DEFINER drop function sub2; show create procedure sel2; Procedure sql_mode Create Procedure @@ -520,7 +523,7 @@ c float(5,2) NULL NULL 5 2 d decimal(6,4) NULL NULL 6 4 e float NULL NULL 12 NULL f decimal(6,3) NULL NULL 6 3 -g int(11) NULL NULL 11 0 +g int(11) NULL NULL 10 NULL h double(10,3) NULL NULL 10 3 i double NULL NULL 22 NULL drop table t1; @@ -841,3 +844,26 @@ drop procedure p2; show create database information_schema; Database Create Database information_schema CREATE DATABASE `information_schema` /*!40100 DEFAULT CHARACTER SET utf8 */ +create table t1(f1 LONGBLOB, f2 LONGTEXT); +select column_name,data_type,CHARACTER_OCTET_LENGTH, +CHARACTER_MAXIMUM_LENGTH +from information_schema.columns +where table_name='t1'; +column_name data_type CHARACTER_OCTET_LENGTH CHARACTER_MAXIMUM_LENGTH +f1 longblob 4294967295 4294967295 +f2 longtext 4294967295 4294967295 +drop table t1; +create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int, +f5 BIGINT, f6 BIT, f7 bit(64)); +select column_name, NUMERIC_PRECISION, NUMERIC_SCALE +from information_schema.columns +where table_name='t1'; +column_name NUMERIC_PRECISION NUMERIC_SCALE +f1 3 NULL +f2 5 NULL +f3 7 NULL +f4 10 NULL +f5 19 NULL +f6 1 NULL +f7 64 NULL +drop table t1; diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index e0cc4a9945d..255b9dc22d7 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -160,33 +160,22 @@ INSERT INTO federated.t1 (name, other) VALUES ('Ninth Name', 99999); INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010); # basic select -EXPLAIN SELECT * FROM federated.t1; SELECT * FROM federated.t1; # with PRIMARY KEY index_read_idx -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5; SELECT * FROM federated.t1 WHERE id = 5; -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; -EXPLAIN SELECT * FROM federated.t1 WHERE name like '%th%'; SELECT * FROM federated.t1 WHERE name like '%th%'; UPDATE federated.t1 SET name = '3rd name' WHERE id = 3; SELECT * FROM federated.t1 WHERE name = '3rd name'; UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name'; SELECT * FROM federated.t1 WHERE name = 'Third name'; # rnd_post, ::position -EXPLAIN SELECT * FROM federated.t1 ORDER BY id DESC; SELECT * FROM federated.t1 ORDER BY id DESC; -EXPLAIN SELECT * FROM federated.t1 ORDER BY name; SELECT * FROM federated.t1 ORDER BY name; -EXPLAIN SELECT * FROM federated.t1 ORDER BY name DESC; SELECT * FROM federated.t1 ORDER BY name DESC; -EXPLAIN SELECT * FROM federated.t1 ORDER BY name ASC; SELECT * FROM federated.t1 ORDER BY name ASC; -EXPLAIN SELECT * FROM federated.t1 GROUP BY other; SELECT * FROM federated.t1 GROUP BY other; # ::delete_row @@ -248,21 +237,14 @@ INSERT INTO federated.t1 (name, other, created) VALUES ('Tenth Name', 101010, '2005-03-12 12:00:01'); # basic select -EXPLAIN SELECT * FROM federated.t1; SELECT * FROM federated.t1; # with PRIMARY KEY index_read_idx -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5; SELECT * FROM federated.t1 WHERE id = 5; # with regular key index_read -> index_read_idx -EXPLAIN SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; -SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; # regular and PRIMARY KEY index_read_idx -EXPLAIN SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; # with regular key index_read -> index_read_idx -EXPLAIN SELECT * FROM federated.t1 WHERE other = 44444; SELECT * FROM federated.t1 WHERE other = 44444; -EXPLAIN SELECT * FROM federated.t1 WHERE name like '%th%'; SELECT * FROM federated.t1 WHERE name like '%th%'; # update - update_row, index_read_idx UPDATE federated.t1 SET name = '3rd name' WHERE id = 3; @@ -462,99 +444,49 @@ INSERT INTO federated.t1 (col1, col2, col3, col4) INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES (10, 'Tenth ten TEN', 1010101, 1010); -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'two two'; SELECT * FROM federated.t1 WHERE col2 = 'two two'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'two Two'; SELECT * FROM federated.t1 WHERE col2 = 'two Two'; SELECT * FROM federated.t1 WHERE id = 3; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 3; SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' - AND col3 = 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' - AND col3 = 5 - AND col4 = 55555; SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5 AND col4 = 55555; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 - AND col2 = 'Two two' AND col3 = 22 - AND col4 = 33; SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'Two two' AND col3 = 22 AND col4 = 33; -EXPLAIN SELECT * FROM federated.t1 WHERE id = 5 - AND col2 = 'five 5 five five 5' AND col3 = 5 - AND col4 = 55555; SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' AND col3 = 5 AND col4 = 55555; -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') - OR (col2 = 'three Three' AND col3 = 33); SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') OR (col2 = 'three Three' AND col3 = 33); -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') - OR (col2 = 'three Three' AND col3 = 33) - OR col4 = 1010; -SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') - OR (col2 = 'three Three' AND col3 = 33) - OR col4 = 1010; -EXPLAIN SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') - OR (col2 = 444 AND col3 = 4444444); SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') OR (col2 = 444 AND col3 = 4444444); -EXPLAIN SELECT * FROM federated.t1 WHERE id = 1 - OR col1 = 10 - OR col2 = 'Two two' - OR col3 = 33 - OR col4 = 4444444; SELECT * FROM federated.t1 WHERE id = 1 OR col1 = 10 OR col2 = 'Two two' OR col3 = 33 OR col4 = 4444444; -EXPLAIN SELECT * FROM federated.t1 WHERE id > 5; SELECT * FROM federated.t1 WHERE id > 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id >= 5; SELECT * FROM federated.t1 WHERE id >= 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id < 5; SELECT * FROM federated.t1 WHERE id < 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id <= 5; SELECT * FROM federated.t1 WHERE id <= 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id != 5; SELECT * FROM federated.t1 WHERE id != 5; -EXPLAIN SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; -EXPLAIN SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; -EXPLAIN SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; -EXPLAIN SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'three Three'; SELECT * FROM federated.t1 WHERE col2 = 'three Three'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 > 'one'; SELECT * FROM federated.t1 WHERE col2 > 'one'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 <> 'one One'; SELECT * FROM federated.t1 WHERE col2 <> 'one One'; # more multi-column indexes, in the primary key @@ -602,35 +534,20 @@ INSERT INTO federated.t1 (col1, col2, col3, col4) INSERT INTO federated.t1 (col1, col2, col3, col4) VALUES ('hhhh', 'hhhhhhhhhhhhhhhhhhh', 'hahahahaha', 'hchchchchchchchc'); -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'cccc'; SELECT * FROM federated.t1 WHERE col1 = 'cccc'; -EXPLAIN SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; -EXPLAIN SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; -EXPLAIN SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; connection slave; DROP TABLE IF EXISTS federated.t1; @@ -660,17 +577,11 @@ INSERT INTO federated.t1 VALUES ('ccd', '112', 'zzzz'); # let's see what the foreign database says connection slave; -EXPLAIN SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); SELECT col3 FROM federated.t1 WHERE ( (col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND (col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); connection master; -EXPLAIN SELECT col3 FROM federated.t1 WHERE ( -(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND -(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); SELECT col3 FROM federated.t1 WHERE ( (col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND (col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); @@ -711,11 +622,6 @@ WHERE id IS NULL AND name IS NULL AND floatval IS NULL AND other IS NULL; -EXPLAIN SELECT count(*) FROM federated.t1 -WHERE id IS NULL -AND name IS NULL -AND floatval IS NULL -AND other IS NULL; connection slave; DROP TABLE IF EXISTS federated.t1; @@ -764,14 +670,6 @@ eval CREATE TABLE federated.t1 ( COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4); -EXPLAIN SELECT * FROM federated.t1 ORDER BY a; -EXPLAIN SELECT * FROM federated.t1 ORDER BY b; -EXPLAIN SELECT * FROM federated.t1 ORDER BY c; -EXPLAIN SELECT a FROM federated.t1 ORDER BY a; -EXPLAIN SELECT b FROM federated.t1 ORDER BY b; -EXPLAIN SELECT a,b FROM federated.t1 ORDER BY b; -EXPLAIN SELECT a,b FROM federated.t1; -EXPLAIN SELECT a,b,c FROM federated.t1; connection slave; DROP TABLE IF EXISTS federated.t1; @@ -1077,7 +975,6 @@ values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, "PatrickG"); UPDATE federated.t1 SET b=repeat('a',256); UPDATE federated.t1 SET i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0, i10=0; -EXPLAIN SELECT * FROM federated.t1 WHERE i9=0 and i10=0; SELECT * FROM federated.t1 WHERE i9=0 and i10=0; UPDATE federated.t1 SET i50=20; SELECT * FROM federated.t1; @@ -1205,32 +1102,16 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); #inner join -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1, federated.countries WHERE -federated.t1.country_id = federated.countries.id; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1, federated.countries WHERE federated.t1.country_id = federated.countries.id; -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON federated.t1.country_id = federated.countries.id; -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id -WHERE federated.t1.name = 'Monty'; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -1238,32 +1119,17 @@ federated.t1.country_id = federated.countries.id WHERE federated.t1.name = 'Monty'; #left join -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.id; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.id; -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.country; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.country; #right join -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 RIGHT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.t1.country_id; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 RIGHT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -1271,4 +1137,11 @@ ORDER BY federated.t1.country_id; DROP TABLE federated.countries; +# optimize and repair tests +OPTIMIZE TABLE federated.t1; +REPAIR TABLE federated.t1; +REPAIR TABLE federated.t1 QUICK; +REPAIR TABLE federated.t1 EXTENDED; +REPAIR TABLE federated.t1 USE_FRM; + source include/federated_cleanup.inc; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 7c0624b67fd..44c69e3c143 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -157,6 +157,8 @@ select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; show create procedure sel2; show create function sub1; show create function sub2; +--replace_column 5 # 6 # +show function status like "sub2"; connection default; disconnect user1; drop function sub2; @@ -569,3 +571,19 @@ drop procedure p2; # Bug #9434 SHOW CREATE DATABASE information_schema; # show create database information_schema; + +# +# Bug #11057 information_schema: columns table has some questionable contents +# +create table t1(f1 LONGBLOB, f2 LONGTEXT); +select column_name,data_type,CHARACTER_OCTET_LENGTH, + CHARACTER_MAXIMUM_LENGTH +from information_schema.columns +where table_name='t1'; +drop table t1; +create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int, + f5 BIGINT, f6 BIT, f7 bit(64)); +select column_name, NUMERIC_PRECISION, NUMERIC_SCALE +from information_schema.columns +where table_name='t1'; +drop table t1; diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index c70c0fa0754..4a917fc8287 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -339,6 +339,37 @@ void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2) } +/* + Set/clear all bits above a bit. + + SYNOPSIS + bitmap_set_above() + map RETURN The bitmap to change. + from_byte The bitmap buffer byte offset to start with. + use_bit The bit value (1/0) to use for all upper bits. + + NOTE + You can only set/clear full bytes. + The function is meant for the situation that you copy a smaller bitmap + to a bigger bitmap. Bitmap lengths are always multiple of eigth (the + size of a byte). Using 'from_byte' saves multiplication and division + by eight during parameter passing. + + RETURN + void +*/ + +void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit) +{ + uchar use_byte= use_bit ? 0xff : 0; + uchar *to= map->bitmap + from_byte; + uchar *end= map->bitmap + map->bitmap_size; + + while (to < end) + *to++= use_byte; +} + + void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2) { uchar *to=map->bitmap, *from=map2->bitmap, *end; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index c953ff1d7ed..e0e35c6b866 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -495,7 +495,7 @@ static int check_foreign_data_source( query.append(escaped_table_name); query.append(FEDERATED_BTICK); query.append(FEDERATED_WHERE); - query.append(FEDERATED_1EQ0); + query.append(FEDERATED_FALSE); DBUG_PRINT("info", ("check_foreign_data_source query %s", query.c_ptr_quick())); if (mysql_real_query(mysql, query.ptr(), query.length())) @@ -1661,6 +1661,62 @@ int ha_federated::write_row(byte *buf) } +int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt) +{ + char query_buffer[STRING_BUFFER_USUAL_SIZE]; + String query(query_buffer, sizeof(query_buffer), &my_charset_bin); + + DBUG_ENTER("ha_federated::optimize"); + + query.length(0); + + query.set_charset(system_charset_info); + query.append(FEDERATED_OPTIMIZE); + query.append(FEDERATED_BTICK); + query.append(share->table_name, share->table_name_length); + query.append(FEDERATED_BTICK); + + if (mysql_real_query(mysql, query.ptr(), query.length())) + { + my_error(-1, MYF(0), mysql_error(mysql)); + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + + +int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt) +{ + char query_buffer[STRING_BUFFER_USUAL_SIZE]; + String query(query_buffer, sizeof(query_buffer), &my_charset_bin); + + DBUG_ENTER("ha_federated::repair"); + + query.length(0); + + query.set_charset(system_charset_info); + query.append(FEDERATED_REPAIR); + query.append(FEDERATED_BTICK); + query.append(share->table_name, share->table_name_length); + query.append(FEDERATED_BTICK); + if (check_opt->flags & T_QUICK) + query.append(FEDERATED_QUICK); + if (check_opt->flags & T_EXTEND) + query.append(FEDERATED_EXTENDED); + if (check_opt->sql_flags & TT_USEFRM) + query.append(FEDERATED_USE_FRM); + + if (mysql_real_query(mysql, query.ptr(), query.length())) + { + my_error(-1, MYF(0), mysql_error(mysql)); + DBUG_RETURN(-1); + } + + DBUG_RETURN(0); +} + + /* Yes, update_row() does what you expect, it updates a row. old_data will have the previous row record in it, while new_data will have the newest data in diff --git a/sql/ha_federated.h b/sql/ha_federated.h index a12cf14531f..3e55419f266 100644 --- a/sql/ha_federated.h +++ b/sql/ha_federated.h @@ -31,40 +31,83 @@ #define FEDERATED_RECORDS_IN_RANGE 2 #define FEDERATED_INFO " SHOW TABLE STATUS LIKE " +#define FEDERATED_INFO_LEN sizeof(FEDERATED_INFO) #define FEDERATED_SELECT "SELECT " +#define FEDERATED_SELECT_LEN sizeof(FEDERATED_SELECT) #define FEDERATED_WHERE " WHERE " +#define FEDERATED_WHERE_LEN sizeof(FEDERATED_WHERE) #define FEDERATED_FROM " FROM " +#define FEDERATED_FROM_LEN sizeof(FEDERATED_FROM) #define FEDERATED_PERCENT "%" +#define FEDERATED_PERCENT_LEN sizeof(FEDERATED_PERCENT) #define FEDERATED_IS " IS " +#define FEDERATED_IS_LEN sizeof(FEDERATED_IS) #define FEDERATED_NULL " NULL " +#define FEDERATED_NULL_LEN sizeof(FEDERATED_NULL) #define FEDERATED_ISNULL " IS NULL " +#define FEDERATED_ISNULL_LEN sizeof(FEDERATED_ISNULL) #define FEDERATED_LIKE " LIKE " +#define FEDERATED_LIKE_LEN sizeof(FEDERATED_LIKE) #define FEDERATED_TRUNCATE "TRUNCATE " +#define FEDERATED_TRUNCATE_LEN sizeof(FEDERATED_TRUNCATE) #define FEDERATED_DELETE "DELETE " +#define FEDERATED_DELETE_LEN sizeof(FEDERATED_DELETE) #define FEDERATED_INSERT "INSERT INTO " +#define FEDERATED_INSERT_LEN sizeof(FEDERATED_INSERT) +#define FEDERATED_OPTIMIZE "OPTIMIZE TABLE " +#define FEDERATED_OPTIMIZE_LEN sizeof(FEDERATED_OPTIMIZE) +#define FEDERATED_REPAIR "REPAIR TABLE " +#define FEDERATED_REPAIR_LEN sizeof(FEDERATED_REPAIR) +#define FEDERATED_QUICK " QUICK" +#define FEDERATED_QUICK_LEN sizeof(FEDERATED_QUICK) +#define FEDERATED_EXTENDED " EXTENDED" +#define FEDERATED_EXTENDED_LEN sizeof(FEDERATED_EXTENDED) +#define FEDERATED_USE_FRM " USE_FRM" +#define FEDERATED_USE_FRM_LEN sizeof(FEDERATED_USE_FRM) #define FEDERATED_LIMIT1 " LIMIT 1" +#define FEDERATED_LIMIT1_LEN sizeof(FEDERATED_LIMIT1) #define FEDERATED_VALUES "VALUES " +#define FEDERATED_VALUES_LEN sizeof(FEDERATED_VALUES) #define FEDERATED_UPDATE "UPDATE " +#define FEDERATED_UPDATE_LEN sizeof(FEDERATED_UPDATE) #define FEDERATED_SET "SET " +#define FEDERATED_SET_LEN sizeof(FEDERATED_SET) #define FEDERATED_AND " AND " +#define FEDERATED_AND_LEN sizeof(FEDERATED_AND) #define FEDERATED_CONJUNCTION ") AND (" +#define FEDERATED_CONJUNCTION_LEN sizeof(FEDERATED_CONJUNCTION) #define FEDERATED_OR " OR " +#define FEDERATED_OR_LEN sizeof(FEDERATED_OR) #define FEDERATED_NOT " NOT " +#define FEDERATED_NOT_LEN sizeof(FEDERATED_NOT) #define FEDERATED_STAR "* " +#define FEDERATED_STAR_LEN sizeof(FEDERATED_STAR) #define FEDERATED_SPACE " " +#define FEDERATED_SPACE_LEN sizeof(FEDERATED_SPACE) #define FEDERATED_SQUOTE "'" +#define FEDERATED_SQUOTE_LEN sizeof(FEDERATED_SQUOTE) #define FEDERATED_COMMA ", " -#define FEDERATED_DQOUTE '"' -#define FEDERATED_BTICK "`" +#define FEDERATED_COMMA_LEN sizeof(FEDERATED_COMMA) +#define FEDERATED_BTICK "`" +#define FEDERATED_BTICK_LEN sizeof(FEDERATED_BTICK) #define FEDERATED_OPENPAREN " (" +#define FEDERATED_OPENPAREN_LEN sizeof(FEDERATED_OPENPAREN) #define FEDERATED_CLOSEPAREN ") " +#define FEDERATED_CLOSEPAREN_LEN sizeof(FEDERATED_CLOSEPAREN) #define FEDERATED_NE " != " +#define FEDERATED_NE_LEN sizeof(FEDERATED_NE) #define FEDERATED_GT " > " +#define FEDERATED_GT_LEN sizeof(FEDERATED_GT) #define FEDERATED_LT " < " +#define FEDERATED_LT_LEN sizeof(FEDERATED_LT) #define FEDERATED_LE " <= " +#define FEDERATED_LE_LEN sizeof(FEDERATED_LE) #define FEDERATED_GE " >= " +#define FEDERATED_GE_LEN sizeof(FEDERATED_GE) #define FEDERATED_EQ " = " -#define FEDERATED_1EQ0 " 1=0" +#define FEDERATED_EQ_LEN sizeof(FEDERATED_EQ) +#define FEDERATED_FALSE " 1=0" +#define FEDERATED_FALSE_LEN sizeof(FEDERATED_FALSE) /* FEDERATED_SHARE is a structure that will be shared amoung all open handlers @@ -88,7 +131,7 @@ typedef struct st_federated_share { char *socket; char *sport; ushort port; - uint table_name_length,use_count; + uint table_name_length, use_count; pthread_mutex_t mutex; THR_LOCK lock; } FEDERATED_SHARE; @@ -235,6 +278,9 @@ public: void position(const byte *record); //required void info(uint); //required + int repair(THD* thd, HA_CHECK_OPT* check_opt); + int optimize(THD* thd, HA_CHECK_OPT* check_opt); + int delete_all_rows(void); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); //required diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 0d9c32adbfa..e94b697e0bb 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -602,7 +602,7 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) !(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) { ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ? - ((ulonglong) 1L << share->base.keys)-1 : + mi_get_mask_all_keys_active(share->base.keys) : share->state.key_map); uint testflag=param.testflag; if (mi_test_if_sort_rep(file,file->state->records,key_map,0) && @@ -903,7 +903,7 @@ int ha_myisam::enable_indexes(uint mode) { int error; - if (file->s->state.key_map == set_bits(ulonglong, file->s->base.keys)) + if (mi_is_all_keys_active(file->s->state.key_map, file->s->base.keys)) { /* All indexes are enabled already. */ return 0; @@ -1002,8 +1002,8 @@ void ha_myisam::start_bulk_insert(ha_rows rows) if (! rows || (rows > MI_MIN_ROWS_TO_USE_WRITE_CACHE)) mi_extra(file, HA_EXTRA_WRITE_CACHE, (void*) &size); - can_enable_indexes= (file->s->state.key_map == - set_bits(ulonglong, file->s->base.keys)); + can_enable_indexes= mi_is_all_keys_active(file->s->state.key_map, + file->s->base.keys); if (!(specialflag & SPECIAL_SAFE_MODE)) { @@ -1256,7 +1256,7 @@ void ha_myisam::info(uint flag) share->db_options_in_use= info.options; block_size= myisam_block_size; share->keys_in_use.set_prefix(share->keys); - share->keys_in_use.intersect(info.key_map); + share->keys_in_use.intersect_extended(info.key_map); share->keys_for_keyread.intersect(share->keys_in_use); share->db_record_offset= info.record_offset; if (share->key_parts) diff --git a/sql/log_event.cc b/sql/log_event.cc index 0873ee50743..90837f98d6a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -242,7 +242,7 @@ static void print_set_option(FILE* file, uint32 bits_changed, uint32 option, { if (*need_comma) fprintf(file,", "); - fprintf(file,"%s=%d", name, (bool)(flags & option)); + fprintf(file,"%s=%d", name, test(flags & option)); *need_comma= 1; } } diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index bc1484b4fb0..0f5b6dcd35e 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -51,6 +51,14 @@ public: bitmap_init(&map2, (uchar *)&map2buff, sizeof(ulonglong)*8, 0); bitmap_intersect(&map, &map2); } + /* Use highest bit for all bits above sizeof(ulonglong)*8. */ + void intersect_extended(ulonglong map2buff) + { + intersect(map2buff); + if (map.bitmap_size > sizeof(ulonglong)) + bitmap_set_above(&map, sizeof(ulonglong), + test(map2buff & (LL(1) << (sizeof(ulonglong) * 8 - 1)))); + } void subtract(Bitmap& map2) { bitmap_subtract(&map, &map2.map); } void merge(Bitmap& map2) { bitmap_union(&map, &map2.map); } my_bool is_set(uint n) const { return bitmap_is_set(&map, n); } @@ -116,6 +124,7 @@ public: void clear_all() { map=(ulonglong)0; } void intersect(Bitmap<64>& map2) { map&= map2.map; } void intersect(ulonglong map2) { map&= map2; } + void intersect_extended(ulonglong map2) { map&= map2; } void subtract(Bitmap<64>& map2) { map&= ~map2.map; } void merge(Bitmap<64>& map2) { map|= map2.map; } my_bool is_set(uint n) const { return test(map & (((ulonglong)1) << n)); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d8c7507fd35..11d71d5603b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2386,10 +2386,12 @@ mysql_execute_command(THD *thd) select_result *result=lex->result; if (all_tables) { - res= check_table_access(thd, - lex->exchange ? SELECT_ACL | FILE_ACL : - SELECT_ACL, - all_tables, 0); + if (lex->orig_sql_command != SQLCOM_SHOW_STATUS_PROC && + lex->orig_sql_command != SQLCOM_SHOW_STATUS_FUNC) + res= check_table_access(thd, + lex->exchange ? SELECT_ACL | FILE_ACL : + SELECT_ACL, + all_tables, 0); } else res= check_access(thd, diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1608999eaef..80e6bbdf388 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2377,6 +2377,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, { const char *tmp_buff; byte *pos; + bool is_blob; uint flags=field->flags; char tmp[MAX_FIELD_WIDTH]; char tmp1[MAX_FIELD_WIDTH]; @@ -2455,12 +2456,14 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, "NO" : "YES"); table->field[6]->store((const char*) pos, strlen((const char*) pos), cs); - if (field->has_charset()) + is_blob= (field->type() == FIELD_TYPE_BLOB); + if (field->has_charset() || is_blob) { - table->field[8]->store((longlong) field->field_length/ - field->charset()->mbmaxlen); + longlong c_octet_len= is_blob ? (longlong) field->max_length() : + (longlong) field->max_length()/field->charset()->mbmaxlen; + table->field[8]->store(c_octet_len); table->field[8]->set_notnull(); - table->field[9]->store((longlong) field->field_length); + table->field[9]->store((longlong) field->max_length()); table->field[9]->set_notnull(); } @@ -2488,6 +2491,17 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, case FIELD_TYPE_LONG: case FIELD_TYPE_LONGLONG: case FIELD_TYPE_INT24: + { + table->field[10]->store((longlong) field->max_length() - 1); + table->field[10]->set_notnull(); + break; + } + case FIELD_TYPE_BIT: + { + table->field[10]->store((longlong) field->max_length()); + table->field[10]->set_notnull(); + break; + } case FIELD_TYPE_FLOAT: case FIELD_TYPE_DOUBLE: { |