summaryrefslogtreecommitdiff
path: root/sql/item_jsonfunc.h
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2019-10-14 14:24:22 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2019-10-14 14:24:22 +0400
commitba8e5e689c8a1756573c9cbf6a59e9ec32d86457 (patch)
tree28767f4bb6609bea651a179da5214129438f0be7 /sql/item_jsonfunc.h
parentb1c2c4ee1b246144033c95d849d59ed0a1192829 (diff)
downloadmariadb-git-ba8e5e689c8a1756573c9cbf6a59e9ec32d86457.tar.gz
MDEV-16620 JSON_ARRAYAGG and JSON_OBJECTAGG.
Ison_objectagg implemented.
Diffstat (limited to 'sql/item_jsonfunc.h')
-rw-r--r--sql/item_jsonfunc.h55
1 files changed, 54 insertions, 1 deletions
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index eadfbba7f29..e61d0875056 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -527,7 +527,6 @@ public:
class Item_func_json_arrayagg : public Item_func_group_concat
{
public:
-
Item_func_json_arrayagg(THD *thd, Name_resolution_context *context_arg,
bool is_distinct, List<Item> *is_select,
const SQL_I_List<ORDER> &is_order, String *is_separator,
@@ -536,6 +535,8 @@ public:
is_separator, limit_clause, row_limit, offset_limit)
{
}
+ Item_func_json_arrayagg(THD *thd, Item_func_json_arrayagg *item);
+ bool is_json_type() { return true; }
const char *func_name() const { return "json_arrayagg("; }
enum Sumfunctype sum_func() const {return JSON_ARRAYAGG_FUNC;}
@@ -548,6 +549,58 @@ public:
{
return Item_func_group_concat::add(false);
}
+ Item *get_copy(THD *thd)
+ { return get_item_copy<Item_func_json_arrayagg>(thd, this); }
+};
+
+
+class Item_func_json_objectagg : public Item_sum
+{
+ String result;
+public:
+ Item_func_json_objectagg(THD *thd, Item *key, Item *value) :
+ Item_sum(thd, key, value)
+ {
+ result.append("{");
+ }
+
+ Item_func_json_objectagg(THD *thd, Item_func_json_objectagg *item);
+ bool is_json_type() { return true; }
+ void cleanup();
+
+ enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;}
+ const char *func_name() const { return "json_objectagg("; }
+ const Type_handler *type_handler() const
+ {
+ if (too_big_for_varchar())
+ return &type_handler_blob;
+ return &type_handler_varchar;
+ }
+ void clear();
+ bool add();
+ void reset_field() { DBUG_ASSERT(0); } // not used
+ void update_field() { DBUG_ASSERT(0); } // not used
+ bool fix_fields(THD *,Item **);
+
+ double val_real()
+ { return 0.0; }
+ longlong val_int()
+ { return 0; }
+ my_decimal *val_decimal(my_decimal *decimal_value)
+ {
+ my_decimal_set_zero(decimal_value);
+ return decimal_value;
+ }
+ bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
+ {
+ return get_date_from_string(thd, ltime, fuzzydate);
+ }
+ String* val_str(String* str);
+ Item *copy_or_same(THD* thd);
+ void no_rows_in_result() {}
+ void print(String *str, enum_query_type query_type);
+ Item *get_copy(THD *thd)
+ { return get_item_copy<Item_func_json_objectagg>(thd, this); }
};