diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_sum.cc | 4 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 8 | ||||
-rw-r--r-- | sql/sql_class.h | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 19 | ||||
-rw-r--r-- | sql/sys_vars.cc | 22 |
5 files changed, 35 insertions, 21 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index cb2d3e839b8..35e8dea46a7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -38,8 +38,8 @@ ulonglong Item_sum::ram_limitation(THD *thd) { - return MY_MIN(thd->variables.tmp_table_size, - thd->variables.max_heap_table_size); + return MY_MIN(thd->variables.tmp_memory_table_size, + thd->variables.max_heap_table_size); } diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 027d696a14f..0b01925ba93 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -4238,13 +4238,13 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd) field->set_table_name(&table->alias); } - if (thd->variables.tmp_table_size == ~ (ulonglong) 0) // No limit + if (thd->variables.tmp_memory_table_size == ~ (ulonglong) 0) // No limit share->max_rows= ~(ha_rows) 0; else share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ? - MY_MIN(thd->variables.tmp_table_size, - thd->variables.max_heap_table_size) : - thd->variables.tmp_table_size) / + MY_MIN(thd->variables.tmp_memory_table_size, + thd->variables.max_heap_table_size) : + thd->variables.tmp_memory_table_size) / share->reclength); set_if_bigger(share->max_rows,1); // For dummy start options diff --git a/sql/sql_class.h b/sql/sql_class.h index 0a1be8c13c8..8052e28fbb4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -536,7 +536,8 @@ typedef struct system_variables uint dynamic_variables_size; /* how many bytes are in use */ ulonglong max_heap_table_size; - ulonglong tmp_table_size; + ulonglong tmp_memory_table_size; + ulonglong tmp_disk_table_size; ulonglong long_query_time; ulonglong max_statement_time; ulonglong optimizer_switch; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6c56f0115ca..540271bc961 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -16703,7 +16703,7 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, if (blob_count || using_unique_constraint || (thd->variables.big_tables && !(select_options & SELECT_SMALL_RESULT)) || (select_options & TMP_TABLE_FORCE_MYISAM) - || thd->variables.tmp_table_size == 0) + || thd->variables.tmp_memory_table_size == 0) { share->db_plugin= ha_lock_engine(0, TMP_ENGINE_HTON); table->file= get_new_handler(share, &table->mem_root, @@ -16867,14 +16867,14 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, param->recinfo= recinfo; // Pointer to after last field store_record(table,s->default_values); // Make empty default record - if (thd->variables.tmp_table_size == ~ (ulonglong) 0) // No limit + if (thd->variables.tmp_memory_table_size == ~ (ulonglong) 0) // No limit share->max_rows= ~(ha_rows) 0; else share->max_rows= (ha_rows) (((share->db_type() == heap_hton) ? - MY_MIN(thd->variables.tmp_table_size, + MY_MIN(thd->variables.tmp_memory_table_size, thd->variables.max_heap_table_size) : - thd->variables.tmp_table_size) / - share->reclength); + thd->variables.tmp_memory_table_size) / + share->reclength); set_if_bigger(share->max_rows,1); // For dummy start options /* Push the LIMIT clause to the temporary table creation, so that we @@ -17412,10 +17412,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, } } bzero((char*) &create_info,sizeof(create_info)); - - /* Use long data format, to ensure we never get a 'table is full' error */ - if (!(options & SELECT_SMALL_RESULT)) - create_info.data_file_length= ~(ulonglong) 0; + create_info.data_file_length= table->in_use->variables.tmp_disk_table_size; /* The logic for choosing the record format: @@ -17611,9 +17608,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *keyinfo, } MI_CREATE_INFO create_info; bzero((char*) &create_info,sizeof(create_info)); - - if (!(options & SELECT_SMALL_RESULT)) - create_info.data_file_length= ~(ulonglong) 0; + create_info.data_file_length= table->in_use->variables.tmp_disk_table_size; if ((error=mi_create(share->table_name.str, share->keys, &keydef, (uint) (*recinfo-start_recinfo), diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 9ab5e42755e..2c74ad5cb29 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3421,12 +3421,30 @@ static Sys_var_tx_read_only Sys_tx_read_only( static Sys_var_ulonglong Sys_tmp_table_size( "tmp_table_size", + "Alias for tmp_memory_table_size. " "If an internal in-memory temporary table exceeds this size, MySQL " - "will automatically convert it to an on-disk MyISAM or Aria table", - SESSION_VAR(tmp_table_size), CMD_LINE(REQUIRED_ARG), + "will automatically convert it to an on-disk MyISAM or Aria table.", + SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), BLOCK_SIZE(1)); +static Sys_var_ulonglong Sys_tmp_memory_table_size( + "tmp_memory_table_size", + "If an internal in-memory temporary table exceeds this size, MySQL " + "will automatically convert it to an on-disk MyISAM or Aria table. " + "Same as tmp_table_size.", + SESSION_VAR(tmp_memory_table_size), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(16*1024*1024), + BLOCK_SIZE(1)); + +static Sys_var_ulonglong Sys_tmp_disk_table_size( + "tmp_disk_table_size", + "Max size for data for an internal temporary on-disk MyISAM or Aria table.", + SESSION_VAR(tmp_disk_table_size), CMD_LINE(REQUIRED_ARG), + VALID_RANGE(1024, (ulonglong)~(intptr)0), + DEFAULT((ulonglong)~(intptr)0), + BLOCK_SIZE(1)); + static Sys_var_mybool Sys_timed_mutexes( "timed_mutexes", "Specify whether to time mutexes. Deprecated, has no effect.", |