summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-04-29 16:04:43 -0700
committerigor@olga.mysql.com <>2007-04-29 16:04:43 -0700
commitce0be732d08b4966115486191fc37af5e1478b00 (patch)
treead655f83591da9e2ddefe8be314cbb25a66a1ab8 /sql/item_func.h
parent2d8037610c7c767e698b66bfb85f2a021d9e124b (diff)
downloadmariadb-git-ce0be732d08b4966115486191fc37af5e1478b00.tar.gz
Fixed bug #24856: the result set of a ROLLUP query with DISTINCT could lack
some rollup rows (rows with NULLs for grouping attributes) if GROUP BY list contained constant expressions. This happened because the results of constant expressions were not put in the temporary table used for duplicate elimination. In fact a constant item from the GROUP BY list of a ROLLUP query can be replaced for an Item_null_result object when a rollup row is produced . Now the JOIN::rollup_init function wraps any constant item referenced in the GROYP BY list of a ROLLUP query into an Item_func object of a special class that is never detected as constant item. This ensures creation of fields for such constant items in temporary tables and guarantees right results when the result of the rollup operation first has to be written into a temporary table, e.g. in the cases when duplicate elimination is required.
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index 467b88eda76..ebe3a589aa1 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -590,6 +590,31 @@ public:
};
+/*
+ Objects of this class are used for ROLLUP queries to wrap up
+ each constant item referred to in GROUP BY list.
+*/
+
+class Item_func_rollup_const :public Item_func
+{
+public:
+ Item_func_rollup_const(Item *a) :Item_func(a)
+ { name= a->name; }
+ double val() { return args[0]->val(); }
+ longlong val_int() { return args[0]->val_int(); }
+ String *val_str(String *str) { return args[0]->val_str(str); }
+ const char *func_name() const { return "rollup_const"; }
+ bool const_item() const { return 0; }
+ Item_result result_type() const { return args[0]->result_type(); }
+ void fix_length_and_dec()
+ {
+ collation= args[0]->collation;
+ max_length= args[0]->max_length;
+ decimals=args[0]->decimals;
+ }
+};
+
+
class Item_func_length :public Item_int_func
{
String value;