summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorevgen@sunlight.local <>2006-03-30 17:14:55 +0400
committerevgen@sunlight.local <>2006-03-30 17:14:55 +0400
commiteb075f2255b1135c062071dd632dcf20a8c5a45f (patch)
treef1381200f8493f09eb4e5d618305dc65a91312e0 /sql
parent2618be804dc33051663434152de0ed002ab45778 (diff)
parent47f9b465649571a9aa9c9062c33d5f7c00e5325e (diff)
downloadmariadb-git-eb075f2255b1135c062071dd632dcf20a8c5a45f.tar.gz
Manual merge
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_heap.cc2
-rw-r--r--sql/item_sum.cc7
-rw-r--r--sql/item_sum.h7
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_select.cc14
-rw-r--r--sql/sql_table.cc2
7 files changed, 27 insertions, 9 deletions
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 739569e305a..79d4575ff1b 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -532,7 +532,7 @@ ha_rows ha_heap::records_in_range(uint inx, key_range *min_key,
return records;
/* Assert that info() did run. We need current statistics here. */
- DBUG_ASSERT(key_stat_version);
+ DBUG_ASSERT(key_stat_version == file->s->key_stat_version);
return key->rec_per_key[key->key_parts-1];
}
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 804adcd022d..4948e60b309 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -2472,6 +2472,7 @@ void Item_sum_count_distinct::make_unique()
{
table=0;
original= 0;
+ force_copy_fields= 1;
tree= 0;
tmp_table_param= 0;
always_null= FALSE;
@@ -2515,6 +2516,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
if (always_null)
return FALSE;
count_field_types(tmp_table_param,list,0);
+ tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0,
@@ -3022,7 +3024,7 @@ Item_func_group_concat(Name_resolution_context *context_arg,
bool distinct_arg, List<Item> *select_list,
SQL_LIST *order_list, String *separator_arg)
:tmp_table_param(0), warning(0),
- separator(separator_arg), tree(0), table(0),
+ force_copy_fields(0), separator(separator_arg), tree(0), table(0),
order(0), context(context_arg),
arg_count_order(order_list ? order_list->elements : 0),
arg_count_field(select_list->elements),
@@ -3075,6 +3077,7 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
:Item_sum(thd, item),
tmp_table_param(item->tmp_table_param),
warning(item->warning),
+ force_copy_fields(item->force_copy_fields),
separator(item->separator),
tree(item->tree),
table(item->table),
@@ -3287,6 +3290,7 @@ bool Item_func_group_concat::setup(THD *thd)
DBUG_RETURN(TRUE);
count_field_types(tmp_table_param,all_fields,0);
+ tmp_table_param->force_copy_fields= force_copy_fields;
DBUG_ASSERT(table == 0);
/*
We have to create a temporary table to get descriptions of fields
@@ -3349,6 +3353,7 @@ void Item_func_group_concat::make_unique()
tmp_table_param= 0;
table=0;
original= 0;
+ force_copy_fields= 1;
tree= 0;
}
diff --git a/sql/item_sum.h b/sql/item_sum.h
index a38530a502c..4bd28d6b1df 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -501,6 +501,7 @@ class Item_sum_count_distinct :public Item_sum_int
TABLE *table;
uint32 *field_lengths;
TMP_TABLE_PARAM *tmp_table_param;
+ bool force_copy_fields;
/*
If there are no blobs, we can use a tree, which
is faster than heap table. In that case, we still use the table
@@ -524,13 +525,14 @@ class Item_sum_count_distinct :public Item_sum_int
public:
Item_sum_count_distinct(List<Item> &list)
:Item_sum_int(list), table(0), field_lengths(0), tmp_table_param(0),
- tree(0), original(0), always_null(FALSE)
+ tree(0), force_copy_fields(0), original(0), always_null(FALSE)
{ quick_group= 0; }
Item_sum_count_distinct(THD *thd, Item_sum_count_distinct *item)
:Item_sum_int(thd, item), table(item->table),
field_lengths(item->field_lengths),
tmp_table_param(item->tmp_table_param),
- tree(item->tree), original(item), tree_key_length(item->tree_key_length),
+ tree(item->tree), force_copy_fields(0), original(item),
+ tree_key_length(item->tree_key_length),
always_null(item->always_null)
{}
~Item_sum_count_distinct();
@@ -1086,6 +1088,7 @@ class Item_func_group_concat : public Item_sum
bool distinct;
bool warning_for_row;
bool always_null;
+ bool force_copy_fields;
bool no_appended;
/*
Following is 0 normal object and pointer to original one for copy
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 9c9d8115402..ca7801039c5 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -706,6 +706,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
bool group, bool modify_item,
bool table_cant_handle_bit_fields,
+ bool make_copy_field,
uint convert_blob_length);
void sp_prepare_create_field(THD *thd, create_field *sql_field);
int prepare_create_field(create_field *sql_field,
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 6189470b88d..c1c1b9eceb3 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1829,11 +1829,12 @@ public:
aggregate functions as normal functions.
*/
bool precomputed_group_by;
+ bool force_copy_fields;
TMP_TABLE_PARAM()
:copy_field(0), group_parts(0),
group_length(0), group_null_parts(0), convert_blob_length(0),
- schema_table(0), precomputed_group_by(0)
+ schema_table(0), precomputed_group_by(0), force_copy_fields(0)
{}
~TMP_TABLE_PARAM()
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2e60bdb96f0..7998449a00b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8294,6 +8294,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item ***copy_func, Field **from_field,
bool group, bool modify_item,
bool table_cant_handle_bit_fields,
+ bool make_copy_field,
uint convert_blob_length)
{
Item::Type orig_type= type;
@@ -8373,7 +8374,13 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case Item::REF_ITEM:
case Item::NULL_ITEM:
case Item::VARBIN_ITEM:
- return create_tmp_field_from_item(thd, item, table, copy_func, modify_item,
+ if (make_copy_field)
+ {
+ DBUG_ASSERT(((Item_result_field*)item)->result_field);
+ *from_field= ((Item_result_field*)item)->result_field;
+ }
+ return create_tmp_field_from_item(thd, item, table, (make_copy_field ? 0 :
+ copy_func), modify_item,
convert_blob_length);
case Item::TYPE_HOLDER:
return ((Item_type_holder *)item)->make_field_by_type(table);
@@ -8445,6 +8452,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Item **copy_func;
MI_COLUMNDEF *recinfo;
uint total_uneven_bit_length= 0;
+ bool force_copy_fields= param->force_copy_fields;
DBUG_ENTER("create_tmp_table");
DBUG_PRINT("enter",("distinct: %d save_sum_fields: %d rows_limit: %lu group: %d",
(int) distinct, (int) save_sum_fields,
@@ -8605,7 +8613,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
Field *new_field=
create_tmp_field(thd, table, arg, arg->type(), &copy_func,
tmp_from_field, group != 0,not_all_columns,
- distinct,
+ distinct, 0,
param->convert_blob_length);
if (!new_field)
goto err; // Should be OOM
@@ -8662,7 +8670,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
create_tmp_field(thd, table, item, type, &copy_func,
tmp_from_field, group != 0,
not_all_columns || group != 0,
- item->marker == 4,
+ item->marker == 4, 0,
param->convert_blob_length);
if (!new_field)
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0fd0c8e25e1..cb556acd5c7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1798,7 +1798,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
field=item->tmp_table_field(&tmp_table);
else
field=create_tmp_field(thd, &tmp_table, item, item->type(),
- (Item ***) 0, &tmp_field, 0, 0, 0, 0);
+ (Item ***) 0, &tmp_field, 0, 0, 0, 0, 0);
if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
((Item_field *)item)->field :