summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <jani@ua141d10.elisa.omakaista.fi>2005-03-01 22:19:19 +0200
committerunknown <jani@ua141d10.elisa.omakaista.fi>2005-03-01 22:19:19 +0200
commit53bfeb48442ed04c8498cb4118b3715fd1dbeb42 (patch)
tree701e55a57172693eb5cc80b3d8c70b8a5e5305f2 /sql
parent425573747f54cf54187a0985e21fddf580c8e924 (diff)
downloadmariadb-git-53bfeb48442ed04c8498cb4118b3715fd1dbeb42.tar.gz
Fix for Bug#5615 and merge from 4.1
mysql-test/r/func_group.result: Added some tests and fix for Bug#5615. mysql-test/r/show_check.result: Fix for Bug#5615. mysql-test/t/func_group.test: Added some tests. sql/item_sum.cc: Fix for Bug#5615. sql/item_sum.h: Fix for Bug#5615. sql/sql_select.cc: Fix for Bug#5615. sql/sql_select.h: Fix for Bug#5615.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_sum.cc18
-rw-r--r--sql/item_sum.h3
-rw-r--r--sql/sql_select.cc8
-rw-r--r--sql/sql_select.h4
4 files changed, 26 insertions, 7 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index b4a53ba0f80..dbba02c3cf7 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -22,6 +22,7 @@
#endif
#include "mysql_priv.h"
+#include "sql_select.h"
Item_sum::Item_sum(List<Item> &list)
:arg_count(list.elements)
@@ -303,6 +304,21 @@ Item_sum_hybrid::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
return FALSE;
}
+Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table,
+ uint convert_blob_length)
+{
+ if (args[0]->type() == Item::FIELD_ITEM)
+ {
+ Field *field= ((Item_field*) args[0])->field;
+
+ if ((field= create_tmp_field_from_field(current_thd, field, this, table,
+ 0, convert_blob_length)))
+ field->flags&= ~NOT_NULL_FLAG;
+ return field;
+ }
+ return Item_sum::create_tmp_field(group, table, convert_blob_length);
+}
+
/***********************************************************************
** reset and add of sum_func
@@ -2075,8 +2091,6 @@ my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf)
** COUNT(DISTINCT ...)
****************************************************************************/
-#include "sql_select.h"
-
int simple_str_key_cmp(void* arg, byte* key1, byte* key2)
{
Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg;
diff --git a/sql/item_sum.h b/sql/item_sum.h
index 81f5d45e42e..fead45f1881 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -94,7 +94,6 @@ public:
Item *get_tmp_table_item(THD *thd);
virtual Field *create_tmp_field(bool group, TABLE *table,
uint convert_blob_length);
-
bool walk (Item_processor processor, byte *argument);
};
@@ -525,6 +524,8 @@ protected:
void cleanup();
bool any_value() { return was_values; }
void no_rows_in_result();
+ Field *create_tmp_field(bool group, TABLE *table,
+ uint convert_blob_length);
};
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index cbe7937355c..e886c658444 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7593,10 +7593,10 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
new_created field
*/
-static Field* create_tmp_field_from_field(THD *thd, Field* org_field,
- Item *item, TABLE *table,
- bool modify_item,
- uint convert_blob_length)
+Field* create_tmp_field_from_field(THD *thd, Field* org_field,
+ Item *item, TABLE *table,
+ bool modify_item,
+ uint convert_blob_length)
{
Field *new_field;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 0f26207b391..1b7893dbc7c 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -399,6 +399,10 @@ void copy_funcs(Item **func_ptr);
bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
int error, bool ignore_last_dupp_error);
uint find_shortest_key(TABLE *table, const key_map *usable_keys);
+Field* create_tmp_field_from_field(THD *thd, Field* org_field,
+ Item *item, TABLE *table,
+ bool modify_item,
+ uint convert_blob_length);
/* functions from opt_sum.cc */
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);