diff options
author | unknown <monty@donna.mysql.com> | 2001-02-07 17:42:20 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2001-02-07 17:42:20 +0200 |
commit | f816d6f16d5c4df073cf0bed40de07286f6c6cd5 (patch) | |
tree | 513c37217d346353220e5bf7b3bcccd9e135c596 | |
parent | e5f835b101afafa7ded3f2660416c3d8bfa995f6 (diff) | |
download | mariadb-git-f816d6f16d5c4df073cf0bed40de07286f6c6cd5.tar.gz |
Use new bitmap interface
Patches for Armstrong
Removed warnings when using REPAIR TABLE .. EXTENDED
Docs/manual.texi:
Changelog
configure.in:
Added missing -lsocket library on SCO
include/global.h:
Patch for Armstrong
include/my_bitmap.h:
Changed bitmap interface to avoid problem with missing LOCK_bitmap symbol
include/myisampack.h:
Portability fix for Armstrong
mysql-test/t/select.test:
Changed to work with 'mysql test < select.tst'
mysys/my_bitmap.c:
Changed bitmap interface to avoid problem with missing LOCK_bitmap symbol
mysys/my_init.c:
Removed LOCK_bitmap
sql/field.cc:
Patch for Armstrong
sql/filesort.cc:
Patch for Armstrong
sql/ha_myisam.cc:
Removed warnings when using REPAIR TABLE .. EXTENDED
sql/mysql_priv.h:
Use new bitmap interface
sql/mysqld.cc:
Use new bitmap interface
sql/sql_select.cc:
Use new bitmap interface
-rw-r--r-- | Docs/manual.texi | 4 | ||||
-rw-r--r-- | configure.in | 6 | ||||
-rw-r--r-- | include/global.h | 24 | ||||
-rw-r--r-- | include/my_bitmap.h | 25 | ||||
-rw-r--r-- | include/myisampack.h | 25 | ||||
-rw-r--r-- | mysql-test/t/select.test | 6 | ||||
-rw-r--r-- | mysys/my_bitmap.c | 59 | ||||
-rw-r--r-- | mysys/my_init.c | 3 | ||||
-rw-r--r-- | sql/field.cc | 11 | ||||
-rw-r--r-- | sql/filesort.cc | 5 | ||||
-rw-r--r-- | sql/ha_myisam.cc | 3 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 20 | ||||
-rw-r--r-- | sql/sql_select.cc | 11 |
14 files changed, 155 insertions, 50 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index b1cf655437b..93bd7a8e38d 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -41096,6 +41096,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. @itemize @bullet @item +Changed output format of @code{SHOW OPEN TABLES}. +@item Allow @code{SELECT expression LIMIT ...}. @item Added @code{IDENTITY} as a synonym for @code{AUTO_INCREMENT} (like SyBase). @@ -41175,6 +41177,8 @@ not yet 100 % confident in this code. @appendixsubsec Changes in release 3.23.33 @itemize bullet @item +Removed warnings when running @code{REPAIR TABLE .. EXTENDED}. +@item Fixed core-dump bug when using @code{GROUP BY} on an alias, where the alias was the same as an existing column name. @item diff --git a/configure.in b/configure.in index 61a19b67067..828ff2a315d 100644 --- a/configure.in +++ b/configure.in @@ -879,9 +879,9 @@ then MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK if expr "$CC" : ".*gcc.*" then - with_named_thread="-pthread -lnsl" + with_named_thread="-pthread -lsocket -lnsl" else - with_named_thread="-Kthread -lnsl" + with_named_thread="-Kthread -lsocket -lnsl" fi if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null then @@ -923,7 +923,7 @@ then if test -f /usr/lib/libthread.so -o -f /usr/lib/libthreadT.so then MYSQL_REMOVE_SOCKET_FROM_LIBS_HACK - with_named_thread="-Kthread -lnsl" + with_named_thread="-Kthread -lsocket -lnsl" if expr "$SYSTEM_TYPE" : ".*unixware7.0.0" > /dev/null then AC_DEFINE(HAVE_UNIXWARE7_THREADS) diff --git a/include/global.h b/include/global.h index 04b8ddea257..657229497be 100644 --- a/include/global.h +++ b/include/global.h @@ -811,6 +811,28 @@ typedef union { #else #define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) #define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) + +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define doublestore(T,V) { *(T)= ((byte *) &V)[4];\ + *((T)+1)=(char) ((byte *) &V)[5];\ + *((T)+2)=(char) ((byte *) &V)[6];\ + *((T)+3)=(char) ((byte *) &V)[7];\ + *((T)+4)=(char) ((byte *) &V)[0];\ + *((T)+5)=(char) ((byte *) &V)[1];\ + *((T)+6)=(char) ((byte *) &V)[2];\ + *((T)+7)=(char) ((byte *) &V)[3]; } +#define doubleget(V,M) { double def_temp;\ + ((byte*) &def_temp)[0]=(M)[4];\ + ((byte*) &def_temp)[1]=(M)[5];\ + ((byte*) &def_temp)[2]=(M)[6];\ + ((byte*) &def_temp)[3]=(M)[7];\ + ((byte*) &def_temp)[4]=(M)[0];\ + ((byte*) &def_temp)[5]=(M)[1];\ + ((byte*) &def_temp)[6]=(M)[2];\ + ((byte*) &def_temp)[7]=(M)[3];\ + (V) = def_temp; } +#endif /* __FLOAT_WORD_ORDER */ + #define float8get(V,M) doubleget((V),(M)) #define float8store(V,M) doublestore((V),(M)) #endif /* WORDS_BIGENDIAN */ @@ -863,7 +885,7 @@ typedef union { #ifndef doubleget #define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) #define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) -#endif +#endif /* doubleget */ #define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) #define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) diff --git a/include/my_bitmap.h b/include/my_bitmap.h index 6c86a79fe45..370f45576ff 100644 --- a/include/my_bitmap.h +++ b/include/my_bitmap.h @@ -18,18 +18,29 @@ #ifndef _my_bitmap_h_ #define _my_bitmap_h_ -#define MY_BIT_NONE ~(uint)0 +#include <my_pthread.h> + +#define MY_BIT_NONE (~(uint) 0) + +typedef struct st_bitmap +{ + uchar *bitmap; + uint bitmap_size; +#ifdef THREAD + pthread_mutex_t mutex; +#endif +} BITMAP; #ifdef __cplusplus extern "C" { #endif - - extern void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit); - extern uint bitmap_set_next(uchar *bitmap, uint bitmap_size); - extern void bitmap_clear_bit(uchar *bitmap,uint bitmap_size,uint bitmap_bit); - + extern my_bool bitmap_init(BITMAP *bitmap, uint bitmap_size); + extern void bitmap_free(BITMAP *bitmap); + extern void bitmap_set_bit(BITMAP *bitmap, uint bitmap_bit); + extern uint bitmap_set_next(BITMAP *bitmap); + extern void bitmap_clear_bit(BITMAP *bitmap, uint bitmap_bit); #ifdef __cplusplus } #endif -#endif +#endif /* _my_bitmap_h_ */ diff --git a/include/myisampack.h b/include/myisampack.h index 1e63b47fc48..376737ad83e 100644 --- a/include/myisampack.h +++ b/include/myisampack.h @@ -167,6 +167,28 @@ ((byte*) &def_temp)[3]=(M)[0];\ (V)=def_temp; } +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) +#define mi_float8store(T,V) { *(T)= ((byte *) &V)[3];\ + *((T)+1)=(char) ((byte *) &V)[2];\ + *((T)+2)=(char) ((byte *) &V)[1];\ + *((T)+3)=(char) ((byte *) &V)[0];\ + *((T)+4)=(char) ((byte *) &V)[7];\ + *((T)+5)=(char) ((byte *) &V)[6];\ + *((T)+6)=(char) ((byte *) &V)[5];\ + *((T)+7)=(char) ((byte *) &V)[4];} + +#define mi_float8get(V,M) { double def_temp;\ + ((byte*) &def_temp)[0]=(M)[3];\ + ((byte*) &def_temp)[1]=(M)[2];\ + ((byte*) &def_temp)[2]=(M)[1];\ + ((byte*) &def_temp)[3]=(M)[0];\ + ((byte*) &def_temp)[4]=(M)[7];\ + ((byte*) &def_temp)[5]=(M)[6];\ + ((byte*) &def_temp)[6]=(M)[5];\ + ((byte*) &def_temp)[7]=(M)[4];\ + (V)=def_temp; } + +#else #define mi_float8store(T,V) { *(T)= ((byte *) &V)[7];\ *((T)+1)=(char) ((byte *) &V)[6];\ *((T)+2)=(char) ((byte *) &V)[5];\ @@ -186,7 +208,8 @@ ((byte*) &def_temp)[6]=(M)[1];\ ((byte*) &def_temp)[7]=(M)[0];\ (V)=def_temp; } -#endif +#endif /* __FLOAT_WORD_ORDER */ +#endif /* WORDS_BIGENDIAN */ /* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */ diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 79ad5a30491..64976b4efd6 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1291,8 +1291,10 @@ explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle'; # The next should give an error # -!$1072 explain select fld3 from t2 ignore index (fld3,not_used); -!$1072 explain select fld3 from t2 use index (not_used); +-- error 1072 +explain select fld3 from t2 ignore index (fld3,not_used); +-- error 1072 +explain select fld3 from t2 use index (not_used); # # Test sorting with a used key (there is no need for sorting) diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c index 848df42d4d4..2601aa96727 100644 --- a/mysys/my_bitmap.c +++ b/mysys/my_bitmap.c @@ -20,33 +20,58 @@ We assume that the size of the used bitmap is less than ~(uint) 0 TODO: - - create an unique structure for this that includes the mutex and bitmap size - make a init function that will allocate the bitmap and init the mutex - make an end function that will free everything + Make assembler THREAD safe versions of these using test-and-set instructions */ #include "mysys_priv.h" #include <my_bitmap.h> +#include <assert.h> pthread_mutex_t LOCK_bitmap; -void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) +my_bool bitmap_init(BITMAP *map, uint bitmap_size) +{ + if (!(map->bitmap=(uchar*) my_malloc((bitmap_size+7)/8,MYF(MY_WME)))) + return 1; + dbug_assert(bitmap_size != ~(uint) 0); +#ifdef THREAD + pthread_mutex_init(&map->mutex, NULL); +#endif + map->bitmap_size=bitmap_size; + return 0; +} + +void bitmap_free(BITMAP *map) +{ + if (map->bitmap) + { + my_free((char*) map->bitmap, MYF(0)); + map->bitmap=0; +#ifdef THREAD + pthread_mutex_destroy(&map->mutex); +#endif + } +} + +void bitmap_set_bit(BITMAP *map, uint bitmap_bit) { - if (bitmap_bit < bitmap_size*8) + if (bitmap_bit < map->bitmap_size) { - pthread_mutex_lock(&LOCK_bitmap); - bitmap[bitmap_bit / 8] |= (1 << (bitmap_bit & 7)); - pthread_mutex_unlock(&LOCK_bitmap); + pthread_mutex_lock(&map->mutex); + map->bitmap[bitmap_bit / 8] |= (1 << (bitmap_bit & 7)); + pthread_mutex_unlock(&map->mutex); } } -uint bitmap_set_next(uchar *bitmap, uint bitmap_size) + +uint bitmap_set_next(BITMAP *map) { + uchar *bitmap=map->bitmap; uint bit_found = MY_BIT_NONE; + uint bitmap_size=map->bitmap_size; uint i; - pthread_mutex_lock(&LOCK_bitmap); + pthread_mutex_lock(&map->mutex); for (i=0; i < bitmap_size ; i++, bitmap++) { if (*bitmap != 0xff) @@ -64,18 +89,18 @@ uint bitmap_set_next(uchar *bitmap, uint bitmap_size) break; /* Found bit */ } } - pthread_mutex_unlock(&LOCK_bitmap); + pthread_mutex_unlock(&map->mutex); return bit_found; } -void bitmap_clear_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) +void bitmap_clear_bit(BITMAP *map, uint bitmap_bit) { - if (bitmap_bit < bitmap_size*8) + if (bitmap_bit < map->bitmap_size) { - pthread_mutex_lock(&LOCK_bitmap); - bitmap[bitmap_bit / 8] &= ~ (1 << (bitmap_bit & 7)); - pthread_mutex_unlock(&LOCK_bitmap); + pthread_mutex_lock(&map->mutex); + map->bitmap[bitmap_bit / 8] &= ~ (1 << (bitmap_bit & 7)); + pthread_mutex_unlock(&map->mutex); } } diff --git a/mysys/my_init.c b/mysys/my_init.c index d1bacde7983..62e48deb6a1 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -80,8 +80,7 @@ void my_init(void) #ifndef __WIN__ sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif - pthread_mutex_init(&LOCK_bitmap, NULL); -#endif +#endif /* THREAD */ { DBUG_ENTER("my_init"); DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown"); diff --git a/sql/field.cc b/sql/field.cc index 55a98dde0ea..383b3f7776d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2106,8 +2106,14 @@ int Field_double::cmp(const char *a_ptr, const char *b_ptr) else #endif { +/* could this ALWAYS be 2 calls to doubleget() ?? */ +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) + doubleget(a, a_ptr); + doubleget(b, b_ptr); +#else memcpy_fixed(&a,a_ptr,sizeof(double)); memcpy_fixed(&b,b_ptr,sizeof(double)); +#endif } return (a < b) ? -1 : (a > b) ? 1 : 0; } @@ -2127,7 +2133,12 @@ void Field_double::sort_string(char *to,uint length __attribute__((unused))) } else #endif +/* could this ALWAYS be 2 calls to doubleget() ?? */ +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) + doubleget(nr,ptr); +#else memcpy_fixed(&nr,ptr,sizeof(nr)); +#endif change_double_for_sort(nr, (byte*) to); } diff --git a/sql/filesort.cc b/sql/filesort.cc index 3c137a81d05..0d862417af0 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -932,8 +932,13 @@ void change_double_for_sort(double nr,byte *to) #else { uchar *ptr= (uchar*) &nr; +#if (__FLOAT_WORD_ORDER == __BIG_ENDIAN) + tmp[0]= ptr[3]; tmp[1]=ptr[2]; tmp[2]= ptr[1]; tmp[3]=ptr[0]; + tmp[4]= ptr[7]; tmp[5]=ptr[6]; tmp[6]= ptr[5]; tmp[7]=ptr[4]; +#else tmp[0]= ptr[7]; tmp[1]=ptr[6]; tmp[2]= ptr[5]; tmp[3]=ptr[4]; tmp[4]= ptr[3]; tmp[5]=ptr[2]; tmp[6]= ptr[1]; tmp[7]=ptr[0]; +#endif } #endif if (tmp[0] & 128) /* Negative */ diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 60e0c4eec94..1a5721009f5 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -457,7 +457,8 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt) myisamchk_init(¶m); param.thd = thd; param.op_name = (char*) "repair"; - param.testflag = ((check_opt->flags | T_SILENT | T_FORCE_CREATE) | + param.testflag = ((check_opt->flags & ~T_EXTEND) | + T_SILENT | T_FORCE_CREATE | (check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT)); if (check_opt->quick) param.opt_rep_quick++; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 4c83d70abf1..0232fad0411 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -25,6 +25,7 @@ #include <signal.h> #include <thr_lock.h> #include <my_base.h> /* Needed by field.h */ +#include <my_bitmap.h> #include <violite.h> #undef write // remove pthread.h macro definition for EMX @@ -508,7 +509,7 @@ extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count, ha_read_key_count, ha_read_next_count, ha_read_prev_count, ha_read_first_count, ha_read_last_count, ha_read_rnd_count, ha_read_rnd_next_count; -extern uchar temp_pool[TEMP_POOL_SIZE]; +extern BITMAP temp_pool; extern bool use_temp_pool; extern char f_fyllchar; extern uchar *days_in_month; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 812fe2177ac..dcd27ec2852 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -284,8 +284,8 @@ I_List<THD> threads,thread_cache; time_t start_time; -uchar temp_pool[TEMP_POOL_SIZE]; -bool use_temp_pool; +BITMAP temp_pool; +bool use_temp_pool=0; pthread_key(MEM_ROOT*,THR_MALLOC); pthread_key(THD*, THR_THD); @@ -646,6 +646,7 @@ void clean_up(void) free_defaults(defaults_argv); my_free(mysql_tmpdir,MYF(0)); x_free(opt_bin_logname); + bitmap_free(&temp_pool); #ifndef __WIN__ if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist @@ -1073,7 +1074,7 @@ static void init_signals(void) signal(SIGBREAK,SIG_IGN); signal_thread = pthread_self(); } -#else +#else /* if ! __WIN__ && ! __EMX__ */ #ifdef HAVE_LINUXTHREADS static sig_handler write_core(int sig); @@ -1085,8 +1086,8 @@ static sig_handler write_core(int sig); extern char* __bss_start; static char* heap_start, *heap_end; -inline static __volatile__ void print_str(const char* name, - const char* val, int max_len) +inline __volatile__ void print_str(const char* name, + const char* val, int max_len) { fprintf(stderr, "%s at %p ", name, val); if(!PTR_SANE(val)) @@ -1101,7 +1102,7 @@ inline static __volatile__ void print_str(const char* name, fputc('\n', stderr); } -inline static __volatile__ void trace_stack() +inline __volatile__ void trace_stack() { uchar **stack_bottom; uchar** ebp; @@ -1227,7 +1228,9 @@ static void init_signals(void) sa.sa_handler=handle_segfault; #endif sigaction(SIGSEGV, &sa, NULL); +#ifdef SIGBUS sigaction(SIGBUS, &sa, NULL); +#endif sigaction(SIGILL, &sa, NULL); (void) sigemptyset(&set); #ifdef THREAD_SPECIFIC_SIGPIPE @@ -1532,9 +1535,6 @@ int main(int argc, char **argv) if (!mysql_tmpdir || !mysql_tmpdir[0]) mysql_tmpdir=(char*) P_tmpdir; /* purecov: inspected */ - bzero(temp_pool, TEMP_POOL_SIZE); - use_temp_pool = 0; - set_options(); #ifdef __WIN__ /* service parameters can be overwritten by options */ @@ -1641,6 +1641,8 @@ int main(int argc, char **argv) #endif select_thread=pthread_self(); select_thread_in_use=1; + if (use_temp_pool && bitmap_init(&temp_pool,1024)) + unireg_abort(1); /* ** We have enough space for fiddling with the argv, continue diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 539433f5208..6ab286195de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -30,7 +30,6 @@ #include <hash.h> #include <ft_global.h> #include <assert.h> -#include <my_bitmap.h> const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "MAYBE_REF","ALL","range","index","fulltext" }; @@ -3298,7 +3297,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, statistic_increment(created_tmp_tables, &LOCK_status); if (use_temp_pool) - temp_pool_slot = bitmap_set_next(temp_pool, TEMP_POOL_SIZE); + temp_pool_slot = bitmap_set_next(&temp_pool); if (temp_pool_slot != MY_BIT_NONE) // we got a slot sprintf(path, "%s%s_%lx_%i", mysql_tmpdir, tmp_file_prefix, @@ -3336,12 +3335,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, param->group_length : 0, NullS)) { - bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); + bitmap_clear_bit(&temp_pool, temp_pool_slot); DBUG_RETURN(NULL); /* purecov: inspected */ } if (!(param->copy_field=copy=new Copy_field[field_count])) { - bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); + bitmap_clear_bit(&temp_pool, temp_pool_slot); my_free((gptr) table,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3687,7 +3686,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, err: free_tmp_table(thd,table); /* purecov: inspected */ - bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); + bitmap_clear_bit(&temp_pool, temp_pool_slot); DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3835,7 +3834,7 @@ free_tmp_table(THD *thd, TABLE *entry) my_free((gptr) entry->record[0],MYF(0)); free_io_cache(entry); - bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, entry->temp_pool_slot); + bitmap_clear_bit(&temp_pool, entry->temp_pool_slot); my_free((gptr) entry,MYF(0)); thd->proc_info=save_proc_info; |