@@ -1948,9 +1948,65 @@ int dump_leaf_key(void* key_arg,
19481948 void* item_arg);
19491949C_MODE_END
19501950
1951- class Item_func_group_concat : public Item_sum
1951+ class Item_sum_str : public Item_sum
19521952{
1953+ public:
1954+ Item_sum_str (THD *thd)
1955+ : Item_sum(thd)
1956+ {}
1957+
1958+ Item_sum_str (THD *thd, Item_sum_str *item)
1959+ : Item_sum(thd, item)
1960+ {}
1961+
1962+ Item_sum_str (THD *thd, Item *item_par)
1963+ : Item_sum(thd, item_par)
1964+ {}
1965+
1966+ bool fix_fields (THD *, Item **) override ;
1967+
1968+ longlong val_int () override
1969+ {
1970+ String *res;
1971+ char *end_ptr;
1972+ int error;
1973+ if (!(res= val_str (&str_value)))
1974+ return (longlong) 0 ;
1975+ end_ptr= (char *) res->ptr ()+ res->length ();
1976+ return my_strtoll10 (res->ptr (), &end_ptr, &error);
1977+ }
1978+
1979+ double val_real () override
1980+ {
1981+ int error;
1982+ const char *end;
1983+ String *res;
1984+ if (!(res= val_str (&str_value)))
1985+ return 0.0 ;
1986+ end= res->ptr () + res->length ();
1987+ return (my_strtod (res->ptr (), (char **) &end, &error));
1988+ }
1989+
1990+ my_decimal *val_decimal (my_decimal *decimal_value) override
1991+ {
1992+ return val_decimal_from_string (decimal_value);
1993+ }
1994+
1995+ bool get_date (THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
1996+ {
1997+ return get_date_from_string (thd, ltime, fuzzydate);
1998+ }
1999+
2000+ void no_rows_in_result () override {}
2001+ void reset_field () override { DBUG_ASSERT (0 ); } // not used
2002+ void update_field () override { DBUG_ASSERT (0 ); } // not used
2003+
19532004protected:
2005+ virtual bool fix_fields_impl (THD *, Item **) = 0;
2006+ };
2007+
2008+ class Item_func_group_concat : public Item_sum_str
2009+ {
19542010 TMP_TABLE_PARAM *tmp_table_param;
19552011 String result;
19562012 String *separator;
@@ -2030,27 +2086,8 @@ class Item_func_group_concat : public Item_sum
20302086 virtual String *get_str_from_field (Item *i, Field *f, String *tmp,
20312087 const uchar *key, size_t offset)
20322088 { return f->val_str (tmp, key + offset); }
2033- virtual void cut_max_length (String *result,
2034- uint old_length, uint max_length) const ;
20352089 bool uses_non_standard_aggregator_for_distinct () const override
20362090 { return distinct; }
2037-
2038- public:
2039- // Methods used by ColumnStore
2040- bool get_distinct () const { return distinct; }
2041- uint get_count_field () const { return arg_count_field; }
2042- uint get_order_field () const { return arg_count_order; }
2043- const String* get_separator () const { return separator; }
2044- ORDER** get_order () const { return order; }
2045-
2046- public:
2047- Item_func_group_concat (THD *thd, Name_resolution_context *context_arg,
2048- bool is_distinct, List<Item> *is_select,
2049- const SQL_I_List<ORDER> &is_order, String *is_separator,
2050- bool limit_clause, Item *row_limit, Item *offset_limit);
2051-
2052- Item_func_group_concat (THD *thd, Item_func_group_concat *item);
2053- ~Item_func_group_concat ();
20542091 void cleanup () override ;
20552092
20562093 enum Sumfunctype sum_func () const override {return GROUP_CONCAT_FUNC;}
@@ -2070,56 +2107,44 @@ class Item_func_group_concat : public Item_sum
20702107 {
20712108 return add (skip_nulls ());
20722109 }
2073- void reset_field () override { DBUG_ASSERT (0 ); } // not used
2074- void update_field () override { DBUG_ASSERT (0 ); } // not used
2075- bool fix_fields (THD *,Item **) override ;
2110+ bool fix_fields_impl (THD *,Item **) override ;
20762111 bool setup (THD *thd) override ;
20772112 void make_unique () override ;
2078- double val_real () override
2079- {
2080- int error;
2081- const char *end;
2082- String *res;
2083- if (!(res= val_str (&str_value)))
2084- return 0.0 ;
2085- end= res->ptr () + res->length ();
2086- return (my_strtod (res->ptr (), (char **) &end, &error));
2087- }
2088- longlong val_int () override
2089- {
2090- String *res;
2091- char *end_ptr;
2092- int error;
2093- if (!(res= val_str (&str_value)))
2094- return (longlong) 0 ;
2095- end_ptr= (char *) res->ptr ()+ res->length ();
2096- return my_strtoll10 (res->ptr (), &end_ptr, &error);
2097- }
2098- my_decimal *val_decimal (my_decimal *decimal_value) override
2099- {
2100- return val_decimal_from_string (decimal_value);
2101- }
2102- bool get_date (THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override
2103- {
2104- return get_date_from_string (thd, ltime, fuzzydate);
2105- }
2106- String *val_str (String *str) override ;
21072113 Item *copy_or_same (THD* thd) override ;
2108- void no_rows_in_result () override {}
21092114 void print (String *str, enum_query_type query_type) override ;
21102115 bool change_context_processor (void *cntx) override
21112116 { context= (Name_resolution_context *)cntx; return FALSE ; }
21122117 Item *do_get_copy (THD *thd) const override
21132118 { return get_item_copy<Item_func_group_concat>(thd, this ); }
2119+
2120+ protected:
2121+ virtual void cut_max_length (String *result,
2122+ uint old_length, uint max_length) const ;
2123+ String *val_str (String *str) override ;
2124+
2125+ public:
2126+ // Methods used by ColumnStore
2127+ bool get_distinct () const { return distinct; }
2128+ uint get_count_field () const { return arg_count_field; }
2129+ uint get_order_field () const { return arg_count_order; }
2130+ const String* get_separator () const { return separator; }
2131+ ORDER** get_order () const { return order; }
2132+
2133+ Item_func_group_concat (THD *thd, Name_resolution_context *context_arg,
2134+ bool is_distinct, List<Item> *is_select,
2135+ const SQL_I_List<ORDER> &is_order, String *is_separator,
2136+ bool limit_clause, Item *row_limit, Item *offset_limit);
2137+
2138+ Item_func_group_concat (THD *thd, Item_func_group_concat *item);
2139+ ~Item_func_group_concat ();
21142140 qsort_cmp2 get_comparator_function_for_distinct ();
21152141 qsort_cmp2 get_comparator_function_for_order_by ();
21162142 uchar* get_record_pointer ();
21172143 uint get_null_bytes ();
2118-
21192144};
21202145
21212146
2122- class Item_func_collect :public Item_sum_int // XXX why *int* ???
2147+ class Item_func_collect : public Item_sum_str
21232148{
21242149 uint32 srid;
21252150 bool has_cached_result;
@@ -2136,27 +2161,13 @@ class Item_func_collect :public Item_sum_int // XXX why *int* ???
21362161 void remove () override ;
21372162 bool list_contains_element (String* wkb);
21382163
2139- public:
2140- Item_func_collect (THD *thd, bool is_distinct, Item *item_par);
2141- Item_func_collect (THD *thd, bool is_distinct, Item_func_collect *item);
2142-
2143- bool fix_length_and_dec (THD *thd) override
2144- {
2145- Item_sum_int::fix_length_and_dec (thd);
2146- base_flags|= item_base_t ::MAYBE_NULL;
2147- return false ;
2148- }
21492164 enum Sumfunctype sum_func () const override
21502165 {
21512166 return GEOMETRY_COLLECT_FUNC;
21522167 }
2153- void no_rows_in_result () override {; }
21542168 const Type_handler *type_handler () const override
21552169 { return &type_handler_string; }
2156- longlong val_int () override { return 0 ; }
21572170 String *val_str (String*str) override ;
2158- void reset_field () override {DBUG_ASSERT (0 );}
2159- void update_field () override {DBUG_ASSERT (0 );}
21602171 LEX_CSTRING func_name_cstring () const override
21612172 {
21622173 return { STRING_WITH_LEN (" st_collect(" ) };
@@ -2169,5 +2180,14 @@ class Item_func_collect :public Item_sum_int // XXX why *int* ???
21692180 {
21702181 return true ;
21712182 }
2183+
2184+ bool fix_fields_impl (THD *,Item **) override
2185+ {
2186+ return FALSE ;
2187+ }
2188+
2189+ public:
2190+ Item_func_collect (THD *thd, bool is_distinct, Item *item_par);
2191+ Item_func_collect (THD *thd, bool is_distinct, Item_func_collect *item);
21722192};
21732193#endif /* ITEM_SUM_INCLUDED */
0 commit comments