diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2016-01-25 14:10:09 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2016-01-25 14:10:09 +0100 |
commit | 8fb34ea8c1ed6cbc01df54c5167fc927805561ba (patch) | |
tree | 8cd993a449817208fa8a022ab8c06b8a9a2a8484 /storage/connect/jsonudf.cpp | |
parent | ddd62ba24aa0c6f35b86a53ab6c3c97c67689ee6 (diff) | |
download | mariadb-git-8fb34ea8c1ed6cbc01df54c5167fc927805561ba.tar.gz |
- Fix to MDEV-9446 (using Json UDFs when CONNECT is not installed)
modified: storage/connect/ha_connect.cc
modified: storage/connect/jsonudf.cpp
modified: storage/connect/jsonudf.h
modified: storage/connect/mysql-test/connect/r/json_udf.result
modified: storage/connect/mysql-test/connect/t/json_udf.inc
modified: storage/connect/mysql-test/connect/t/json_udf.test
modified: storage/connect/mysql-test/connect/t/json_udf2.inc
Diffstat (limited to 'storage/connect/jsonudf.cpp')
-rw-r--r-- | storage/connect/jsonudf.cpp | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 40685ae0f0e..eae872b81cc 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -31,6 +31,8 @@ uint GetJsonGrpSize(void); static int IsJson(UDF_ARGS *args, uint i); static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); +static uint JsonGrpSize = 10; + /* ----------------------------------- JSNX ------------------------------------ */ /*********************************************************************************/ @@ -1040,6 +1042,14 @@ static void SetChanged(PBSON bsp) } /* end of SetChanged */ /*********************************************************************************/ +/* Replaces GetJsonGrpSize not usable when CONNECT is not installed. */ +/*********************************************************************************/ +static uint GetJsonGroupSize(void) +{ + return (JsonGrpSize) ? JsonGrpSize : GetJsonGrpSize(); +} // end of GetJsonGroupSize + +/*********************************************************************************/ /* Program for SubSet re-initialization of the memory pool. */ /*********************************************************************************/ static my_bool JsonSubSet(PGLOBAL g) @@ -2394,11 +2404,50 @@ void json_object_list_deinit(UDF_INIT* initid) } // end of json_object_list_deinit /*********************************************************************************/ +/* Set the value of JsonGrpSize. */ +/*********************************************************************************/ +my_bool jsonset_grp_size_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 1 || args->arg_type[0] != INT_RESULT) { + strcpy(message, "This function must have 1 integer argument"); + return true; + } else + return false; + +} // end of jsonset_grp_size_init + +long long jsonset_grp_size(UDF_INIT *initid, UDF_ARGS *args, char *, char *) +{ + long long n = *(long long*)args->args[0]; + + JsonGrpSize = (uint)n; + return (long long)GetJsonGroupSize(); +} // end of jsonset_grp_size + +/*********************************************************************************/ +/* Get the value of JsonGrpSize. */ +/*********************************************************************************/ +my_bool jsonget_grp_size_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 0) { + strcpy(message, "This function must have no arguments"); + return true; + } else + return false; + +} // end of jsonget_grp_size_init + +long long jsonget_grp_size(UDF_INIT *initid, UDF_ARGS *args, char *, char *) +{ + return (long long)GetJsonGroupSize(); +} // end of jsonget_grp_size + +/*********************************************************************************/ /* Make a Json array from values coming from rows. */ /*********************************************************************************/ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { - unsigned long reslen, memlen, n = GetJsonGrpSize(); + unsigned long reslen, memlen, n = GetJsonGroupSize(); if (args->arg_count != 1) { strcpy(message, "This function can only accept 1 argument"); @@ -2458,7 +2507,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*) PlugSubSet(g, g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)new(g) JARRAY; - g->N = GetJsonGrpSize(); + g->N = GetJsonGroupSize(); } // end of json_array_grp_clear void json_array_grp_deinit(UDF_INIT* initid) @@ -2471,7 +2520,7 @@ void json_array_grp_deinit(UDF_INIT* initid) /*********************************************************************************/ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) { - unsigned long reslen, memlen, n = GetJsonGrpSize(); + unsigned long reslen, memlen, n = GetJsonGroupSize(); if (args->arg_count != 2) { strcpy(message, "This function requires 2 arguments (key, value)"); @@ -2529,7 +2578,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*) PlugSubSet(g, g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)new(g) JOBJECT; - g->N = GetJsonGrpSize(); + g->N = GetJsonGroupSize(); } // end of json_object_grp_clear void json_object_grp_deinit(UDF_INIT* initid) |