summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/manual.texi5
-rw-r--r--client/mysql.cc4
-rw-r--r--client/mysqladmin.c4
-rw-r--r--client/mysqldump.c4
-rw-r--r--client/mysqlshow.c4
-rw-r--r--client/mysqltest.c4
-rw-r--r--include/my_bitmap.h35
-rw-r--r--mysys/Makefile.am2
-rw-r--r--mysys/my_bitmap.c60
-rw-r--r--mysys/my_init.c10
-rw-r--r--mysys/mysys_priv.h1
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--sql/mysqld.cc14
-rw-r--r--sql/sql_select.cc29
-rw-r--r--sql/table.h2
15 files changed, 173 insertions, 9 deletions
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 <my_bitmap.h>
+
+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<bitmap_size) && (bit_found==MY_BIT_NONE); i++) {
+ if(bitmap[i] == 0xff) continue;
+ for(b=0; (b<8) && (bit_found==MY_BIT_NONE); b++)
+ if((bitmap[i] & 1<<b) == 0) {
+ bit_found = (i*8)+b;
+ bitmap[i] |= 1<<b;
+ };
+ };
+ pthread_mutex_unlock(&LOCK_bitmap);
+
+ return bit_found;
+};
+
+void bitmap_clear_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);
+ };
+};
+
diff --git a/mysys/my_init.c b/mysys/my_init.c
index a9c8b49a257..384fab5d53c 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -48,6 +48,7 @@ static my_bool win32_init_tcp_ip();
static my_bool my_init_done=0;
+
static ulong atoi_octal(const char *str)
{
long int tmp;
@@ -76,6 +77,7 @@ void my_init(void)
#ifndef __WIN__
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
+ pthread_mutex_init(&LOCK_bitmap, NULL);
#endif
{
DBUG_ENTER("my_init");
@@ -127,7 +129,12 @@ void my_end(int infoflag)
#ifdef HAVE_GETRUSAGE
struct rusage rus;
if (!getrusage(RUSAGE_SELF, &rus))
- fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %ld, Integral resident set size %ld\nNon physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\nBlocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\nVouluntary context switches %ld, Invouluntary context switches %ld\n",
+ fprintf(info_file,"\n\
+User time %.2f, System time %.2f\n\
+Maximum resident set size %ld, Integral resident set size %ld\n\
+Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\
+Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\
+Voluntary context switches %ld, Involuntary context switches %ld\n",
(rus.ru_utime.tv_sec * SCALE_SEC +
rus.ru_utime.tv_usec / SCALE_USEC) / 100.0,
(rus.ru_stime.tv_sec * SCALE_SEC +
@@ -159,6 +166,7 @@ void my_end(int infoflag)
pthread_mutex_destroy(&THR_LOCK_keycache);
pthread_mutex_destroy(&THR_LOCK_malloc);
pthread_mutex_destroy(&THR_LOCK_open);
+ pthread_mutex_destroy(&LOCK_bitmap);
DBUG_POP(); /* Must be done before my_thread_end */
my_thread_end();
my_thread_global_end();
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 86c32202e99..20fda270658 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -25,6 +25,7 @@
#ifdef THREAD
extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache,
THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset;
+extern pthread_mutex_t LOCK_bitmap;
#else /* THREAD */
#define pthread_mutex_lock(A)
#define pthread_mutex_unlock(A)
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index d3f208aa6de..4c83d70abf1 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -73,6 +73,7 @@ void kill_one_thread(THD *thd, ulong id);
#ifndef MYSQLD_NET_RETRY_COUNT
#define MYSQLD_NET_RETRY_COUNT 10 // Abort read after this many int.
#endif
+#define TEMP_POOL_SIZE 128
/* The following parameters is to decide when to use an extra cache to
optimise seeks when reading a big table in sorted order */
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (16L*1024*1024)
@@ -507,7 +508,8 @@ 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 bool use_temp_pool;
extern char f_fyllchar;
extern uchar *days_in_month;
extern DATE_FORMAT dayord;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index f9c4d10f46f..a5d16ac6751 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -287,6 +287,9 @@ I_List<THD> 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 <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" };
@@ -3276,14 +3277,28 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &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<Item> &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<Item> &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<Item> &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;
};