summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <jcole@tetra.spaceapes.com>2001-01-27 03:24:05 -0600
committerunknown <jcole@tetra.spaceapes.com>2001-01-27 03:24:05 -0600
commit882f16d0369b4cd0742ac37650a71fc6f3b00a57 (patch)
tree26c80620cd60c2689d8eb1f3eca78b805558f0f8 /sql
parent77be4587507b753c647d86d1231def8e7d3313fc (diff)
downloadmariadb-git-882f16d0369b4cd0742ac37650a71fc6f3b00a57.tar.gz
Added --temp-pool option to mysqld. This will cause temporary files
created to use a small set of filenames, to try and avoid problems in the Linux kernel. mysys/Makefile.am: Added my_bitmap.c mysys/my_init.c: my_bitmap code added mysys/mysys_priv.h: my_bitmap sql/mysql_priv.h: temp pool stuff. sql/mysqld.cc: --temp-pool option added sql/sql_select.cc: temp pool stuff sql/table.h: temp pool
Diffstat (limited to 'sql')
-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
4 files changed, 44 insertions, 5 deletions
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 62ee256b9da..b8a502ad2a4 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);
@@ -1498,6 +1501,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 */
@@ -2370,7 +2376,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[] = {
@@ -2501,6 +2508,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
@@ -2874,6 +2882,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__
@@ -3049,6 +3058,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;
};