diff --git a/Docs/manual.texi b/Docs/manual.texi index df903a22191..7672af71694 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -40812,7 +40812,9 @@ not yet 100 % confident in this code. @node News-3.23.33, News-3.23.32, News-3.23.x, News-3.23.x @appendixsubsec Changes in release 3.23.33 -@itemize bullet +@itemize @bullet +@item +Changed clients to use TCP/IP when -P or --port option is specified. @item Fixed bug in replication that broke slave server start with existing @code{master.info}. This fixes a bug introduced in 3.23.32. @@ -40840,7 +40842,6 @@ Extended @code{mysqltest} to take care of the timing issues in the test suite. @end itemize - @node News-3.23.32, News-3.23.31, News-3.23.33, News-3.23.x @appendixsubsec Changes in release 3.23.32 @itemize @bullet diff --git a/client/mysql.cc b/client/mysql.cc index d0300344ba4..11bf5640020 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -692,6 +692,10 @@ static int get_options(int argc, char **argv) skip_column_names=1; break; case 'P': + if(!current_host) { + my_free(current_host, MYF(MY_ALLOW_ZERO_PTR)); + current_host=my_strdup("127.0.0.1", MYF(MY_WME)); + }; opt_mysql_port= (unsigned int) atoi(optarg); break; case 'S': diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 2a9d47edf44..b17559aafd6 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -185,6 +185,10 @@ int main(int argc,char *argv[]) interval=atoi(optarg); break; case 'P': + if(!host) { + my_free(host, MYF(MY_ALLOW_ZERO_PTR)); + host=my_strdup("127.0.0.1", MYF(MY_WME)); + }; tcp_port= (unsigned int) atoi(optarg); break; case 'r': diff --git a/client/mysqldump.c b/client/mysqldump.c index efb632cf5e4..c5ae758541c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -344,6 +344,10 @@ static int get_options(int *argc,char ***argv) tty_password=1; break; case 'P': + if(!current_host) { + my_free(current_host, MYF(MY_ALLOW_ZERO_PTR)); + current_host=my_strdup("127.0.0.1", MYF(MY_WME)); + }; opt_mysql_port= (unsigned int) atoi(optarg); break; case 'S': diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 8fffe02a52f..f341108d8d4 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -238,6 +238,10 @@ get_options(int *argc,char ***argv) break; #endif case 'P': + if(!host) { + my_free(host, MYF(MY_ALLOW_ZERO_PTR)); + host=my_strdup("127.0.0.1", MYF(MY_WME)); + }; opt_mysql_port= (unsigned int) atoi(optarg); break; case 'S': diff --git a/client/mysqltest.c b/client/mysqltest.c index 953f770240b..7c708254f1c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1154,6 +1154,10 @@ int parse_args(int argc, char **argv) tty_password=1; break; case 'P': + if(!host) { + my_free(host, MYF(MY_ALLOW_ZERO_PTR)); + host=my_strdup("127.0.0.1", MYF(MY_WME)); + }; port = atoi(optarg); break; case 'S': diff --git a/include/my_bitmap.h b/include/my_bitmap.h new file mode 100644 index 00000000000..6c86a79fe45 --- /dev/null +++ b/include/my_bitmap.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +#ifndef _my_bitmap_h_ +#define _my_bitmap_h_ + +#define MY_BIT_NONE ~(uint)0 + +#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); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 7615b85fa29..6674132bdca 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ my_quick.c my_lockmem.c my_static.c \ getopt.c getopt1.c getvar.c my_mkdir.c \ default.c my_compress.c checksum.c raid.cc my_net.c \ - my_vsnprintf.c charset.c + my_vsnprintf.c charset.c my_bitmap.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c libmysys_a_LIBADD = @THREAD_LOBJECTS@ diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c new file mode 100644 index 00000000000..1434f472f98 --- /dev/null +++ b/mysys/my_bitmap.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* + Handling of uchar arrays as large bitmaps. +*/ + +#include "mysys_priv.h" +#include + +pthread_mutex_t LOCK_bitmap; + +void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) { + if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) { + pthread_mutex_lock(&LOCK_bitmap); + bitmap[bitmap_bit / 8] |= (1 << bitmap_bit % 8); + pthread_mutex_unlock(&LOCK_bitmap); + }; +}; + +uint bitmap_set_next(uchar *bitmap, uint bitmap_size) { + uint bit_found = MY_BIT_NONE; + int i, b; + + pthread_mutex_lock(&LOCK_bitmap); + for(i=0; (i threads,thread_cache; time_t start_time; +uchar temp_pool[TEMP_POOL_SIZE]; +bool use_temp_pool; + pthread_key(MEM_ROOT*,THR_MALLOC); pthread_key(THD*, THR_THD); pthread_key(NET*, THR_NET); @@ -1533,6 +1536,9 @@ 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 */ @@ -2405,7 +2411,8 @@ enum options { OPT_INNOBASE_LOG_GROUP_HOME_DIR, OPT_INNOBASE_LOG_ARCH_DIR, OPT_INNOBASE_LOG_ARCHIVE, OPT_INNOBASE_FLUSH_LOG_AT_TRX_COMMIT, OPT_SAFE_SHOW_DB, - OPT_GEMINI_SKIP + OPT_GEMINI_SKIP, + OPT_TEMP_POOL }; static struct option long_options[] = { @@ -2536,6 +2543,7 @@ static struct option long_options[] = { #ifdef __WIN__ {"standalone", no_argument, 0, (int) OPT_STANDALONE}, #endif + {"temp-pool", no_argument, 0, (int) OPT_TEMP_POOL}, {"tmpdir", required_argument, 0, 't'}, {"use-locking", no_argument, 0, (int) OPT_USE_LOCKING}, #ifdef USE_SYMDIR @@ -2912,6 +2920,7 @@ static void usage(void) Don't give threads different priorities.\n\ --socket=... Socket file to use for connection\n\ -t, --tmpdir=path Path for temporary files\n\ + --temp-pool Use a pool of temporary files\n\ -u, --user=user_name Run mysqld daemon as user\n\ -V, --version output version information and exit"); #ifdef __WIN__ @@ -3087,6 +3096,9 @@ static void get_options(int argc,char **argv) case 't': mysql_tmpdir=optarg; break; + case OPT_TEMP_POOL: + use_temp_pool=1; + break; case 'u': mysqld_user=optarg; break; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2d8373ec067..16d525f0ea7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -30,6 +30,7 @@ #include #include #include +#include const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "MAYBE_REF","ALL","range","index","fulltext" }; @@ -3276,14 +3277,28 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, KEY_PART_INFO *key_part_info; Item_result_field **copy_func; MI_COLUMNDEF *recinfo; + uint temp_pool_slot; + DBUG_ENTER("create_tmp_table"); DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d allow_distinct_limit: %d group: %d", (int) distinct, (int) save_sum_fields, (int) allow_distinct_limit,test(group))); statistic_increment(created_tmp_tables, &LOCK_status); - sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, - thd->thread_id, thd->tmp_table++); + + if(use_temp_pool) { + temp_pool_slot = bitmap_set_next(temp_pool, TEMP_POOL_SIZE); + if(temp_pool_slot != MY_BIT_NONE) // we got a slot + sprintf(path, "%s%s_%lx_%i", mysql_tmpdir, tmp_file_prefix, + current_pid, temp_pool_slot); + else // if we run out of slots in the pool, fall back to old behavior + sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, + thd->thread_id, thd->tmp_table++); + } else { + sprintf(path,"%s%s%lx_%lx_%x",mysql_tmpdir,tmp_file_prefix,current_pid, + thd->thread_id, thd->tmp_table++); + }; + if (group) { if (!param->quick_group) @@ -3310,10 +3325,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, param->group_length : 0, NullS)) { + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, 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); my_free((gptr) table,MYF(0)); /* purecov: inspected */ DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3333,6 +3350,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, table->map=1; table->tmp_table=1; table->db_low_byte_first=1; // True for HEAP and MyISAM + table->temp_pool_slot = temp_pool_slot; + /* Calculate with type of fields we will need in heap table */ @@ -3626,7 +3645,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, DBUG_RETURN(table); err: - free_tmp_table(thd,table); /* purecov: inspected */ + free_tmp_table(thd,table); /* purecov: inspected */ + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, temp_pool_slot); DBUG_RETURN(NULL); /* purecov: inspected */ } @@ -3773,6 +3793,9 @@ free_tmp_table(THD *thd, TABLE *entry) delete *ptr; my_free((gptr) entry->record[0],MYF(0)); free_io_cache(entry); + + bitmap_clear_bit(temp_pool, TEMP_POOL_SIZE, entry->temp_pool_slot); + my_free((gptr) entry,MYF(0)); thd->proc_info=save_proc_info; diff --git a/sql/table.h b/sql/table.h index 8121271b479..c709be6a08c 100644 --- a/sql/table.h +++ b/sql/table.h @@ -119,6 +119,8 @@ struct st_table { key_part_map const_key_parts[MAX_KEY]; ulong query_id; + uint temp_pool_slot; + THD *in_use; /* Which thread uses this */ struct st_table *next,*prev; };