summaryrefslogtreecommitdiff
path: root/sql/item_create.cc
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2019-05-17 11:53:58 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2019-05-17 11:53:58 +0400
commitcd16d6d518761d144844f9f6294744f2aa42c715 (patch)
tree2908fd297353eb7d96b5b095e5408c5ae3a05d23 /sql/item_create.cc
parentda6e55f022ffc85889f5d8d62cb1c3d4fe94a195 (diff)
downloadmariadb-git-cd16d6d518761d144844f9f6294744f2aa42c715.tar.gz
MDEV-13992 Implement JSON_MERGE_PATCH.
JSON_MERGE_PATCH implemented. Added JSON_MERGE_PRESERVE as a synonim for the JSON_MERGE.
Diffstat (limited to 'sql/item_create.cc')
-rw-r--r--sql/item_create.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 6e98bccbfb2..4b7400eb0c0 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -2049,6 +2049,19 @@ protected:
};
+class Create_func_json_merge_patch : public Create_native_func
+{
+public:
+ virtual Item *create_native(THD *thd, LEX_STRING name, List<Item> *item_list);
+
+ static Create_func_json_merge_patch s_singleton;
+
+protected:
+ Create_func_json_merge_patch() {}
+ virtual ~Create_func_json_merge_patch() {}
+};
+
+
class Create_func_json_quote : public Create_func_arg1
{
public:
@@ -5414,6 +5427,30 @@ Create_func_json_merge::create_native(THD *thd, LEX_STRING name,
}
+Create_func_json_merge_patch Create_func_json_merge_patch::s_singleton;
+
+Item*
+Create_func_json_merge_patch::create_native(THD *thd, LEX_STRING name,
+ List<Item> *item_list)
+{
+ Item *func;
+ int arg_count;
+
+ if (item_list == NULL ||
+ (arg_count= item_list->elements) < 2) // json, json
+ {
+ my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name.str);
+ func= NULL;
+ }
+ else
+ {
+ func= new (thd->mem_root) Item_func_json_merge_patch(thd, *item_list);
+ }
+
+ return func;
+}
+
+
Create_func_json_contains Create_func_json_contains::s_singleton;
Item*
@@ -6825,6 +6862,8 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("JSON_LENGTH") }, BUILDER(Create_func_json_length)},
{ { C_STRING_WITH_LEN("JSON_LOOSE") }, BUILDER(Create_func_json_loose)},
{ { C_STRING_WITH_LEN("JSON_MERGE") }, BUILDER(Create_func_json_merge)},
+ { { C_STRING_WITH_LEN("JSON_MERGE_PATCH") }, BUILDER(Create_func_json_merge_patch)},
+ { { C_STRING_WITH_LEN("JSON_MERGE_PRESERVE") }, BUILDER(Create_func_json_merge)},
{ { C_STRING_WITH_LEN("JSON_QUERY") }, BUILDER(Create_func_json_query)},
{ { C_STRING_WITH_LEN("JSON_QUOTE") }, BUILDER(Create_func_json_quote)},
{ { C_STRING_WITH_LEN("JSON_OBJECT") }, BUILDER(Create_func_json_object)},