summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2012-08-24 13:57:39 +0200
committerunknown <knielsen@knielsen-hq.org>2012-08-24 13:57:39 +0200
commitcaa535eb9fa97bd7c2190292bb4a3a3c1aaa71e3 (patch)
tree443fee6698968975faaeadba6ca0d5a532667b18 /sql
parent6c3a756dd92af851f421bd9791d4b6b95063b484 (diff)
parente44a800d91a887119d3b612276b37f09b076fee1 (diff)
downloadmariadb-git-caa535eb9fa97bd7c2190292bb4a3a3c1aaa71e3.tar.gz
Merge from 5.3
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc12
-rw-r--r--sql/item_cmpfunc.cc19
-rw-r--r--sql/opt_subselect.cc12
3 files changed, 32 insertions, 11 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 03379f2738a..04b223b7db0 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -103,6 +103,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
int error;
ulong memory_available= thd->variables.sortbuff_size;
ulong min_sort_memory;
+ ulong sort_buff_sz;
uint maxbuffer;
BUFFPEK *buffpek;
ha_rows num_rows= HA_POS_ERROR;
@@ -193,19 +194,21 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
goto err;
min_sort_memory= max(MIN_SORT_MEMORY, param.sort_length * MERGEBUFF2);
+ set_if_bigger(min_sort_memory, sizeof(BUFFPEK*)*MERGEBUFF2);
if (!table_sort.sort_keys)
{
while (memory_available >= min_sort_memory)
{
ulong keys= memory_available / (param.rec_length + sizeof(char*));
table_sort.keys= (uint) min(num_rows, keys);
+ sort_buff_sz= table_sort.keys*(param.rec_length+sizeof(char*));
+ set_if_bigger(sort_buff_sz, param.rec_length * MERGEBUFF2);
DBUG_EXECUTE_IF("make_sort_keys_alloc_fail",
DBUG_SET("+d,simulate_out_of_memory"););
if ((table_sort.sort_keys=
- (uchar**) my_malloc(table_sort.keys*(param.rec_length+sizeof(char*)),
- MYF(0))))
+ (uchar**) my_malloc(sort_buff_sz, MYF(0))))
break;
ulong old_memory_available= memory_available;
memory_available= memory_available/4*3;
@@ -1259,9 +1262,8 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
to_start_filepos= my_b_tell(to_file);
strpos= sort_buffer;
org_max_rows=max_rows= param->max_rows;
-
- /* The following will fire if there is not enough space in sort_buffer */
- DBUG_ASSERT(maxcount!=0);
+
+ set_if_bigger(maxcount, 1);
if (unique_buff)
{
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 8cfbcb97144..d950c0c1443 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -3089,6 +3089,15 @@ void Item_func_case::fix_length_and_dec()
return;
}
}
+ /*
+ Set cmp_context of all WHEN arguments. This prevents
+ Item_field::equal_fields_propagator() from transforming a
+ zerofill argument into a string constant. Such a change would
+ require rebuilding cmp_items.
+ */
+ for (i= 0; i < ncases; i+= 2)
+ args[i]->cmp_context= item_cmp_type(left_result_type,
+ args[i]->result_type());
}
if (else_expr_num == -1 || args[else_expr_num]->maybe_null)
@@ -4069,6 +4078,16 @@ void Item_func_in::fix_length_and_dec()
}
}
}
+ /*
+ Set cmp_context of all arguments. This prevents
+ Item_field::equal_fields_propagator() from transforming a zerofill integer
+ argument into a string constant. Such a change would require rebuilding
+ cmp_itmes.
+ */
+ for (arg= args + 1, arg_end= args + arg_count; arg != arg_end ; arg++)
+ {
+ arg[0]->cmp_context= item_cmp_type(left_result_type, arg[0]->result_type());
+ }
max_length= 1;
}
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index 8d1cbeba5f4..e70e5a784ba 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -160,18 +160,18 @@
3.2.1 Non-merged semi-joins and join optimization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For join optimization purposes, non-merged semi-join nests are similar to
- base tables - they've got one JOIN_TAB, which can be accessed with one of
- two methods:
+ base tables. Each such nest is represented by one one JOIN_TAB, which has
+ two possible access strategies:
- full table scan (representing SJ-Materialization-Scan strategy)
- eq_ref-like table lookup (representing SJ-Materialization-Lookup)
Unlike regular base tables, non-merged semi-joins have:
- non-zero JOIN_TAB::startup_cost, and
- join_tab->table->is_filled_at_execution()==TRUE, which means one
- cannot do const table detection or range analysis or other table data-
- dependent inferences
- // instead, get_delayed_table_estimates() runs optimization on the nest so that
- // we get an idea about temptable size
+ cannot do const table detection, range analysis or other dataset-dependent
+ optimizations.
+ Instead, get_delayed_table_estimates() will run optimization for the
+ subquery and produce an E(materialized table size).
3.2.2 Merged semi-joins and join optimization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~