Commit a575d90f authored by Olivier Bertrand's avatar Olivier Bertrand

Fold all json UDF names to lower case

  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/value.cpp
parent 9c6405fe
...@@ -16,8 +16,12 @@ ...@@ -16,8 +16,12 @@
#include "jsonudf.h" #include "jsonudf.h"
#define MEMFIX 4096 #define MEMFIX 4096
#if defined(connect_EXPORTS)
#define PUSH_WARNING(M) \ #define PUSH_WARNING(M) \
push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, M) push_warning(current_thd, Sql_condition::WARN_LEVEL_WARN, 0, M)
#else
#define PUSH_WARNING(M) htrc(M)
#endif
#define M 7 #define M 7
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
...@@ -855,7 +859,7 @@ inline void JsonMemSave(PGLOBAL g) ...@@ -855,7 +859,7 @@ inline void JsonMemSave(PGLOBAL g)
} /* end of JsonMemSave */ } /* end of JsonMemSave */
/*********************************************************************************/ /*********************************************************************************/
/* Program for freeing the memory pools. */ /* Program for freeing the memory pools. */
/*********************************************************************************/ /*********************************************************************************/
inline void JsonFreeMem(PGLOBAL g) inline void JsonFreeMem(PGLOBAL g)
{ {
...@@ -896,7 +900,7 @@ static my_bool CheckPath(PGLOBAL g, UDF_ARGS *args, PJSON top, PJVAL& jvp, int n ...@@ -896,7 +900,7 @@ static my_bool CheckPath(PGLOBAL g, UDF_ARGS *args, PJSON top, PJVAL& jvp, int n
if (args->arg_type[i] == STRING_RESULT) { if (args->arg_type[i] == STRING_RESULT) {
// A path to a subset of the json tree is given // A path to a subset of the json tree is given
char *path = MakePSZ(g, args, i); char *path = MakePSZ(g, args, i);
PJSNX jsx = new(g)JSNX(g, top, TYPE_STRING); PJSNX jsx = new(g) JSNX(g, top, TYPE_STRING);
if (jsx->SetJpath(g, path)) if (jsx->SetJpath(g, path))
return true; return true;
...@@ -1358,20 +1362,20 @@ static PJVAL MakeValue(PGLOBAL g, UDF_ARGS *args, uint i) ...@@ -1358,20 +1362,20 @@ static PJVAL MakeValue(PGLOBAL g, UDF_ARGS *args, uint i)
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json value containing the parameter. */ /* Make a Json value containing the parameter. */
/*********************************************************************************/ /*********************************************************************************/
my_bool JsonValue_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jsonvalue_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count > 1) { if (args->arg_count > 1) {
strcpy(message, "JsonValue cannot accept more than 1 argument"); strcpy(message, "jsonvalue cannot accept more than 1 argument");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of JsonValue_init } // end of jsonvalue_init
char *JsonValue(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jsonvalue(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -1399,20 +1403,20 @@ char *JsonValue(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1399,20 +1403,20 @@ char *JsonValue(UDF_INIT *initid, UDF_ARGS *args, char *result,
void JsonValue_deinit(UDF_INIT* initid) void JsonValue_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of JsonValue_deinit } // end of jsonvalue_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json array containing all the parameters. */ /* Make a Json array containing all the parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Array_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_array_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Json_Array_init } // end of json_array_init
char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -1440,33 +1444,33 @@ char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1440,33 +1444,33 @@ char *Json_Array(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Array } // end of json_array
void Json_Array_deinit(UDF_INIT* initid) void json_array_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Array_deinit } // end of json_array_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add one or several values to a Json array. */ /* Add one or several values to a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Array_Add_Values_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Array_Add must have at least 2 arguments"); strcpy(message, "json_array_add_values must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Array_Add first argument must be a json string"); strcpy(message, "json_array_add_values first argument must be a json string");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Array_Add_Values_init } // end of json_array_add_values_init
char *Json_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str = NULL; char *str = NULL;
...@@ -1507,33 +1511,33 @@ char *Json_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1507,33 +1511,33 @@ char *Json_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Array_Add_Values } // end of json_array_add_values
void Json_Array_Add_Values_deinit(UDF_INIT* initid) void json_array_add_values_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Array_Add_Values_deinit } // end of json_array_add_values_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add one value to a Json array. */ /* Add one value to a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Array_Add must have at least 2 arguments"); strcpy(message, "json_array_add must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Array_Add first argument must be a json item"); strcpy(message, "json_array_add first argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Array_Add_init } // end of json_array_add_init
char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
...@@ -1589,36 +1593,36 @@ char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1589,36 +1593,36 @@ char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Array_Add } // end of json_array_add
void Json_Array_Add_deinit(UDF_INIT* initid) void json_array_add_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Array_Add_deinit } // end of json_array_add_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Delete a value from a Json array. */ /* Delete a value from a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Array_Delete must have at lest 2 arguments"); strcpy(message, "json_array_delete must have at lest 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Array_Delete first argument must be a json item"); strcpy(message, "json_array_delete first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != INT_RESULT) { } else if (args->arg_type[1] != INT_RESULT) {
strcpy(message, "Json_Array_Delete second argument is not an integer (index)"); strcpy(message, "json_array_delete second argument is not an integer (index)");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Array_Delete_init } // end of json_array_delete_init
char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
...@@ -1662,25 +1666,25 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1662,25 +1666,25 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = (str) ? strlen(str) : 0; *res_length = (str) ? strlen(str) : 0;
return str; return str;
} // end of Json_Array_Delete } // end of json_array_delete
void Json_Array_Delete_deinit(UDF_INIT* initid) void json_array_delete_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Array_Delete_deinit } // end of json_array_delete_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json Oject containing all the parameters. */ /* Make a Json Oject containing all the parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_object_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, true, reslen, memlen); CalcLen(args, true, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Json_Object_init } // end of json_object_init
char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str = NULL; char *str = NULL;
...@@ -1706,26 +1710,26 @@ char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1706,26 +1710,26 @@ char *Json_Object(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object } // end of json_object
void Json_Object_deinit(UDF_INIT* initid) void json_object_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_deinit } // end of json_object_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json Oject containing all not null parameters. */ /* Make a Json Oject containing all not null parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_Nonull_init(UDF_INIT *initid, UDF_ARGS *args, my_bool json_object_nonull_init(UDF_INIT *initid, UDF_ARGS *args,
char *message) char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, true, reslen, memlen); CalcLen(args, true, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Json_Object_Nonull_init } // end of json_object_nonull_init
char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -1753,33 +1757,33 @@ char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1753,33 +1757,33 @@ char *Json_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object_Nonull } // end of json_object_nonull
void Json_Object_Nonull_deinit(UDF_INIT* initid) void json_object_nonull_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_nonull_deinit } // end of json_object_nonull_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add or replace a value in a Json Object. */ /* Add or replace a value in a Json Object. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Object_Add must have at least 2 arguments"); strcpy(message, "json_object_add must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Object_Add first argument must be a json item"); strcpy(message, "json_object_add first argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Object_Add_init } // end of json_object_add_init
char *Json_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
char *key, *str = NULL; char *key, *str = NULL;
...@@ -1822,36 +1826,36 @@ char *Json_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1822,36 +1826,36 @@ char *Json_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object_Add } // end of json_object_add
void Json_Object_Add_deinit(UDF_INIT* initid) void json_object_add_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_Add_deinit } // end of json_object_add_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Delete a value from a Json object. */ /* Delete a value from a Json object. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Object_Delete must have 2 or 3 arguments"); strcpy(message, "json_object_delete must have 2 or 3 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Object_Delete first argument must be a json item"); strcpy(message, "json_object_delete first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Json_Object_Delete second argument must be a key string"); strcpy(message, "json_object_delete second argument must be a key string");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Object_Delete_init } // end of json_object_delete_init
char *Json_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
...@@ -1894,33 +1898,33 @@ char *Json_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1894,33 +1898,33 @@ char *Json_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object_Delete } // end of json_object_delete
void Json_Object_Delete_deinit(UDF_INIT* initid) void json_object_delete_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_Delete_deinit } // end of json_object_delete_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Returns an array of the Json object keys. */ /* Returns an array of the Json object keys. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_List_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_object_list_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count != 1) { if (args->arg_count != 1) {
strcpy(message, "Json_Object_List must have 1 arguments"); strcpy(message, "json_object_list must have 1 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Object_List argument must be a json item"); strcpy(message, "json_object_list argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Object_List_init } // end of json_object_list_init
char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *str = NULL; char *str = NULL;
...@@ -1960,22 +1964,22 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1960,22 +1964,22 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object_List } // end of json_object_list
void Json_Object_List_deinit(UDF_INIT* initid) void json_object_list_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_List_deinit } // end of json_object_list_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json array from values coming from rows. */ /* Make a Json array from values coming from rows. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) 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 = GetJsonGrpSize();
if (args->arg_count != 1) { if (args->arg_count != 1) {
strcpy(message, "Json_Array_Grp can only accept 1 argument"); strcpy(message, "json_array_grp can only accept 1 argument");
return true; return true;
} else if (IsJson(args, 0) == 3) { } else if (IsJson(args, 0) == 3) {
strcpy(message, "Json_Array_Grp does not support Jbin argument"); strcpy(message, "Json_Array_Grp does not support Jbin argument");
...@@ -1995,9 +1999,9 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1995,9 +1999,9 @@ my_bool Json_Array_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
g->Activityp = (PACTIVITY)new(g) JARRAY; g->Activityp = (PACTIVITY)new(g) JARRAY;
g->N = (int)n; g->N = (int)n;
return false; return false;
} // end of Json_Array_Grp_init } // end of json_array_grp_init
void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) void json_array_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
PJAR arp = (PJAR)g->Activityp; PJAR arp = (PJAR)g->Activityp;
...@@ -2005,9 +2009,9 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) ...@@ -2005,9 +2009,9 @@ void Json_Array_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
if (g->N-- > 0) if (g->N-- > 0)
arp->AddValue(g, MakeValue(g, args, 0)); arp->AddValue(g, MakeValue(g, args, 0));
} // end of Json_Array_Grp_add } // end of json_array_grp_add
char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, char *json_array_grp(UDF_INIT *initid, UDF_ARGS *, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -2024,34 +2028,34 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, ...@@ -2024,34 +2028,34 @@ char *Json_Array_Grp(UDF_INIT *initid, UDF_ARGS *, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Array_Grp } // end of json_array_grp
void Json_Array_Grp_clear(UDF_INIT *initid, char*, char*) void json_array_grp_clear(UDF_INIT *initid, char*, char*)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
PlugSubSet(g, g->Sarea, g->Sarea_Size); PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)new(g) JARRAY; g->Activityp = (PACTIVITY)new(g) JARRAY;
g->N = GetJsonGrpSize(); g->N = GetJsonGrpSize();
} // end of Json_Array_Grp_clear } // end of json_array_grp_clear
void Json_Array_Grp_deinit(UDF_INIT* initid) void json_array_grp_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Array_Grp_deinit } // end of json_array_grp_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json object from values coming from rows. */ /* Make a Json object from values coming from rows. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) 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 = GetJsonGrpSize();
if (args->arg_count != 2) { if (args->arg_count != 2) {
strcpy(message, "Json_Object_Grp can only accept 2 arguments"); strcpy(message, "json_object_grp can only accept 2 arguments");
return true; return true;
} else if (IsJson(args, 0) == 3) { } else if (IsJson(args, 0) == 3) {
strcpy(message, "Json_Object_Grp does not support Jbin arguments"); strcpy(message, "json_object_grp does not support Jbin arguments");
return true; return true;
} else } else
CalcLen(args, true, reslen, memlen); CalcLen(args, true, reslen, memlen);
...@@ -2068,9 +2072,9 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2068,9 +2072,9 @@ my_bool Json_Object_Grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
g->Activityp = (PACTIVITY)new(g) JOBJECT; g->Activityp = (PACTIVITY)new(g) JOBJECT;
g->N = (int)n; g->N = (int)n;
return false; return false;
} // end of Json_Object_Grp_init } // end of json_object_grp_init
void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) void json_object_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
PJOB objp = (PJOB)g->Activityp; PJOB objp = (PJOB)g->Activityp;
...@@ -2078,9 +2082,9 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*) ...@@ -2078,9 +2082,9 @@ void Json_Object_Grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
if (g->N-- > 0) if (g->N-- > 0)
objp->SetValue(g, MakeValue(g, args, 0), MakePSZ(g, args, 1)); objp->SetValue(g, MakeValue(g, args, 0), MakePSZ(g, args, 1));
} // end of Json_Object_Grp_add } // end of json_object_grp_add
char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, char *json_object_grp(UDF_INIT *initid, UDF_ARGS *, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -2095,45 +2099,45 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result, ...@@ -2095,45 +2099,45 @@ char *Json_Object_Grp(UDF_INIT *initid, UDF_ARGS *, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Object_Grp } // end of json_object_grp
void Json_Object_Grp_clear(UDF_INIT *initid, char*, char*) void json_object_grp_clear(UDF_INIT *initid, char*, char*)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
PlugSubSet(g, g->Sarea, g->Sarea_Size); PlugSubSet(g, g->Sarea, g->Sarea_Size);
g->Activityp = (PACTIVITY)new(g) JOBJECT; g->Activityp = (PACTIVITY)new(g) JOBJECT;
g->N = GetJsonGrpSize(); g->N = GetJsonGrpSize();
} // end of Json_Object_Grp_clear } // end of json_object_grp_clear
void Json_Object_Grp_deinit(UDF_INIT* initid) void json_object_grp_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Object_Grp_deinit } // end of json_object_grp_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Merge two arrays or objects. */ /* Merge two arrays or objects. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Item_Merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_item_merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Item_Merge must have at least 2 arguments"); strcpy(message, "json_item_merge must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Json_Item_Merge first argument must be a json item"); strcpy(message, "json_item_merge first argument must be a json item");
return true; return true;
} else if (!IsJson(args, 1)) { } else if (!IsJson(args, 1)) {
strcpy(message, "Json_Item_Merge second argument must be a json item"); strcpy(message, "json_item_merge second argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Item_Merge_init } // end of json_item_merge_init
char *Json_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
...@@ -2183,26 +2187,26 @@ char *Json_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2183,26 +2187,26 @@ char *Json_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Item_Merge } // end of json_item_merge
void Json_Item_Merge_deinit(UDF_INIT* initid) void json_item_merge_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Item_Merge_deinit } // end of json_item_merge_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Get a Json item from a Json document. */ /* Get a Json item from a Json document. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
int n = IsJson(args, 0); int n = IsJson(args, 0);
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Get_Item must have at least 2 arguments"); strcpy(message, "json_get_item must have at least 2 arguments");
return true; return true;
} else if (!n && args->arg_type[0] != STRING_RESULT) { } else if (!n && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "Json_Get_Item first argument must be a json item"); strcpy(message, "json_get_item first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a string (jpath)"); strcpy(message, "Second argument is not a string (jpath)");
...@@ -2222,9 +2226,9 @@ my_bool Json_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2222,9 +2226,9 @@ my_bool Json_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += args->lengths[0] * 3; memlen += args->lengths[0] * 3;
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Get_Item_init } // end of json_get_item_init
char *Json_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str = NULL; char *str = NULL;
...@@ -2264,7 +2268,7 @@ char *Json_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2264,7 +2268,7 @@ char *Json_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result,
jsp = (PJSON)g->Xchk; jsp = (PJSON)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length); jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
if (jsx->SetJpath(g, path, true)) { if (jsx->SetJpath(g, path, true)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
...@@ -2291,26 +2295,26 @@ char *Json_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2291,26 +2295,26 @@ char *Json_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Get_Item } // end of json_get_item
void Json_Get_Item_deinit(UDF_INIT* initid) void json_get_item_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Get_Item_deinit } // end of json_get_item_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Get a string value from a Json item. */ /* Get a string value from a Json item. */
/*********************************************************************************/ /*********************************************************************************/
my_bool JsonGetString_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jsonget_string_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
int n = IsJson(args, 0); int n = IsJson(args, 0);
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "JsonGetString must have at least 2 arguments"); strcpy(message, "jsonget_string must have at least 2 arguments");
return true; return true;
} else if (!n && args->arg_type[0] != STRING_RESULT) { } else if (!n && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "JsonGetString first argument must be a json item"); strcpy(message, "jsonget_string first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a string (jpath)"); strcpy(message, "Second argument is not a string (jpath)");
...@@ -2330,9 +2334,9 @@ my_bool JsonGetString_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2330,9 +2334,9 @@ my_bool JsonGetString_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += args->lengths[0] * 3; memlen += args->lengths[0] * 3;
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of JsonGetString_init } // end of jsonget_string_init
char *JsonGetString(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str = NULL; char *str = NULL;
...@@ -2372,7 +2376,7 @@ char *JsonGetString(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2372,7 +2376,7 @@ char *JsonGetString(UDF_INIT *initid, UDF_ARGS *args, char *result,
jsp = (PJSON)g->Xchk; jsp = (PJSON)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length); jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
...@@ -2399,25 +2403,25 @@ char *JsonGetString(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2399,25 +2403,25 @@ char *JsonGetString(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of JsonGetString } // end of jsonget_string
void JsonGetString_deinit(UDF_INIT* initid) void jsonget_string_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of JsonGetString_deinit } // end of jsonget_string_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Get an integer value from a Json item. */ /* Get an integer value from a Json item. */
/*********************************************************************************/ /*********************************************************************************/
my_bool JsonGetInt_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jsonget_int_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count != 2) { if (args->arg_count != 2) {
strcpy(message, "JsonGetInt must have 2 arguments"); strcpy(message, "jsonget_int must have 2 arguments");
return true; return true;
} else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "JsonGetInt first argument must be a json item"); strcpy(message, "jsonget_int first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a (jpath) string"); strcpy(message, "Second argument is not a (jpath) string");
...@@ -2429,9 +2433,9 @@ my_bool JsonGetInt_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2429,9 +2433,9 @@ my_bool JsonGetInt_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += 1000; // TODO: calculate this memlen += 1000; // TODO: calculate this
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of JsonGetInt_init } // end of jsonget_int_init
long long JsonGetInt(UDF_INIT *initid, UDF_ARGS *args, long long jsonget_int(UDF_INIT *initid, UDF_ARGS *args,
char *is_null, char *error) char *is_null, char *error)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -2476,7 +2480,7 @@ long long JsonGetInt(UDF_INIT *initid, UDF_ARGS *args, ...@@ -2476,7 +2480,7 @@ long long JsonGetInt(UDF_INIT *initid, UDF_ARGS *args,
jsp = (PJSON)g->Xchk; jsp = (PJSON)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
jsx = new(g)JSNX(g, jsp, TYPE_BIGINT); jsx = new(g) JSNX(g, jsp, TYPE_BIGINT);
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
...@@ -2507,25 +2511,25 @@ long long JsonGetInt(UDF_INIT *initid, UDF_ARGS *args, ...@@ -2507,25 +2511,25 @@ long long JsonGetInt(UDF_INIT *initid, UDF_ARGS *args,
if (g->Mrr) *error = 1; if (g->Mrr) *error = 1;
*is_null = 1; *is_null = 1;
return 0LL; return 0LL;
} // end of JsonGetInt } // end of jsonget_int
void JsonGetInt_deinit(UDF_INIT* initid) void jsonget_int_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of JsonGetInt_deinit } // end of jsonget_int_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Get a double value from a Json item. */ /* Get a double value from a Json item. */
/*********************************************************************************/ /*********************************************************************************/
my_bool JsonGetReal_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jsonget_real_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "JsonGetReal must have at least 2 arguments"); strcpy(message, "jsonget_real must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "JsonGetReal first argument must be a json item"); strcpy(message, "jsonget_real first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a (jpath) string"); strcpy(message, "Second argument is not a (jpath) string");
...@@ -2546,9 +2550,9 @@ my_bool JsonGetReal_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2546,9 +2550,9 @@ my_bool JsonGetReal_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += 1000; // TODO: calculate this memlen += 1000; // TODO: calculate this
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of JsonGetReal_init } // end of jsonget_real_init
double JsonGetReal(UDF_INIT *initid, UDF_ARGS *args, double jsonget_real(UDF_INIT *initid, UDF_ARGS *args,
char *is_null, char *error) char *is_null, char *error)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -2592,7 +2596,7 @@ double JsonGetReal(UDF_INIT *initid, UDF_ARGS *args, ...@@ -2592,7 +2596,7 @@ double JsonGetReal(UDF_INIT *initid, UDF_ARGS *args,
jsp = (PJSON)g->Xchk; jsp = (PJSON)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
jsx = new(g)JSNX(g, jsp, TYPE_DOUBLE); jsx = new(g) JSNX(g, jsp, TYPE_DOUBLE);
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
...@@ -2623,25 +2627,25 @@ double JsonGetReal(UDF_INIT *initid, UDF_ARGS *args, ...@@ -2623,25 +2627,25 @@ double JsonGetReal(UDF_INIT *initid, UDF_ARGS *args,
if (g->Mrr) *error = 1; if (g->Mrr) *error = 1;
*is_null = 1; *is_null = 1;
return 0.0; return 0.0;
} // end of JsonGetReal } // end of jsonget_real
void JsonGetReal_deinit(UDF_INIT* initid) void jsonget_real_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of JsonGetReal_deinit } // end of jsonget_real_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Locate a value in a Json tree. */ /* Locate a value in a Json tree. */
/*********************************************************************************/ /*********************************************************************************/
my_bool JsonLocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen, more = 1000; unsigned long reslen, memlen, more = 1000;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Locate must have at least 2 arguments"); strcpy(message, "jsonlocate must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "Json_Locate first argument must be a json item"); strcpy(message, "jsonlocate first argument must be a json item");
return true; return true;
} else if (args->arg_count > 2 && args->arg_type[2] != INT_RESULT) { } else if (args->arg_count > 2 && args->arg_type[2] != INT_RESULT) {
strcpy(message, "Third argument is not an integer (rank)"); strcpy(message, "Third argument is not an integer (rank)");
...@@ -2659,9 +2663,9 @@ my_bool JsonLocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2659,9 +2663,9 @@ my_bool JsonLocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += 1000; // TODO: calculate this memlen += 1000; // TODO: calculate this
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of JsonLocate_init } // end of jsonlocate_init
char *JsonLocate(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *path = NULL; char *path = NULL;
...@@ -2728,7 +2732,7 @@ char *JsonLocate(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2728,7 +2732,7 @@ char *JsonLocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1; k = (args->arg_count > 2) ? (int)*(long long*)args->args[2] : 1;
jsx = new(g)JSNX(g, jsp, TYPE_STRING); jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->Locate(g, jsp, jvp2, k); path = jsx->Locate(g, jsp, jvp2, k);
if (initid->const_item) if (initid->const_item)
...@@ -2750,25 +2754,25 @@ char *JsonLocate(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2750,25 +2754,25 @@ char *JsonLocate(UDF_INIT *initid, UDF_ARGS *args, char *result,
*error = 1; *error = 1;
*is_null = 1; *is_null = 1;
return NULL; return NULL;
} // end of JsonLocate } // end of jsonlocate
void Json_Locate_deinit(UDF_INIT* initid) void json_locate_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of JsonLocate_deinit } // end of jsonlocate_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Locate all occurences of a value in a Json tree. */ /* Locate all occurences of a value in a Json tree. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Locate_All_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_locate_all_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen, more = 1000; unsigned long reslen, memlen, more = 1000;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Json_Locate_All must have at least 2 arguments"); strcpy(message, "json_locate_all must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) { } else if (!IsJson(args, 0) && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "Json_Locate_All first argument must be a json item"); strcpy(message, "json_locate_all first argument must be a json item");
return true; return true;
} else if (args->arg_count > 2 && args->arg_type[2] != INT_RESULT) { } else if (args->arg_count > 2 && args->arg_type[2] != INT_RESULT) {
strcpy(message, "Third argument is not an integer (Depth)"); strcpy(message, "Third argument is not an integer (Depth)");
...@@ -2786,9 +2790,9 @@ my_bool Json_Locate_All_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2786,9 +2790,9 @@ my_bool Json_Locate_All_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += 1000; // TODO: calculate this memlen += 1000; // TODO: calculate this
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Locate_All_init } // end of json_locate_all_init
char *Json_Locate_All(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *path = NULL; char *path = NULL;
...@@ -2857,7 +2861,7 @@ char *Json_Locate_All(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2857,7 +2861,7 @@ char *Json_Locate_All(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (args->arg_count > 2) if (args->arg_count > 2)
mx = (int)*(long long*)args->args[2]; mx = (int)*(long long*)args->args[2];
jsx = new(g)JSNX(g, jsp, TYPE_STRING); jsx = new(g) JSNX(g, jsp, TYPE_STRING);
path = jsx->LocateAll(g, jsp, jvp2, mx); path = jsx->LocateAll(g, jsp, jvp2, mx);
if (initid->const_item) if (initid->const_item)
...@@ -2879,25 +2883,25 @@ char *Json_Locate_All(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2879,25 +2883,25 @@ char *Json_Locate_All(UDF_INIT *initid, UDF_ARGS *args, char *result,
*error = 1; *error = 1;
*is_null = 1; *is_null = 1;
return NULL; return NULL;
} // end of Json_Locate_All } // end of json_locate_all
void Json_Locate_All_deinit(UDF_INIT* initid) void json_locate_all_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Locate_All_deinit } // end of json_locate_all_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Returns a json file as a json string. */ /* Returns a json file as a json string. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_file_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen, fl, more = 1024; unsigned long reslen, memlen, fl, more = 1024;
if (args->arg_count < 1 || args->arg_count > 4) { if (args->arg_count < 1 || args->arg_count > 4) {
strcpy(message, "Json_File only accepts 1 to 4 arguments"); strcpy(message, "json_file only accepts 1 to 4 arguments");
return true; return true;
} else if (args->arg_type[0] != STRING_RESULT) { } else if (args->arg_type[0] != STRING_RESULT) {
strcpy(message, "Json_File first argument must be a (string) file name"); strcpy(message, "json_file first argument must be a (string) file name");
return true; return true;
} else if (args->arg_count > 1 && args->arg_type[1] != INT_RESULT) { } else if (args->arg_count > 1 && args->arg_type[1] != INT_RESULT) {
strcpy(message, "Second argument is not an integer (check)"); strcpy(message, "Second argument is not an integer (check)");
...@@ -2926,9 +2930,9 @@ my_bool Json_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2926,9 +2930,9 @@ my_bool Json_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += more; memlen += more;
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Json_File_init } // end of json_file_init
char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *str, *fn; char *str, *fn;
...@@ -3022,25 +3026,25 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3022,25 +3026,25 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_File } // end of json_file
void Json_File_deinit(UDF_INIT* initid) void json_file_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_File_deinit } // end of json_file_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a json file from a json item. */ /* Make a json file from a json item. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jfile_Make_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jfile_make_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen, more = 1024; unsigned long reslen, memlen, more = 1024;
if (args->arg_count < 2 || args->arg_count > 3) { if (args->arg_count < 2 || args->arg_count > 3) {
strcpy(message, "JsonMakeFile only accepts 2 or 3 arguments"); strcpy(message, "jfile_make only accepts 2 or 3 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "JsonMakeFile first argument must be a json item"); strcpy(message, "jfile_make first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument must be a (string) file name"); strcpy(message, "Second argument must be a (string) file name");
...@@ -3052,9 +3056,9 @@ my_bool Jfile_Make_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3052,9 +3056,9 @@ my_bool Jfile_Make_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jfile_Make_init } // end of jfile_make_init
char *Jfile_Make(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str, *fn, *msg; char *str, *fn, *msg;
...@@ -3101,25 +3105,25 @@ char *Jfile_Make(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3101,25 +3105,25 @@ char *Jfile_Make(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Jfile_Make } // end of jfile_make
void Jfile_Make_deinit(UDF_INIT* initid) void jfile_make_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jfile_Make_deinit } // end of jfile_make_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make and return a binary Json array containing all the parameters. */ /* Make and return a binary Json array containing all the parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Array_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_array_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Jbin_Array_init } // end of jbin_array_init
char *Jbin_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -3146,33 +3150,33 @@ char *Jbin_Array(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3146,33 +3150,33 @@ char *Jbin_Array(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Array } // end of jbin_array
void Jbin_Array_deinit(UDF_INIT* initid) void jbin_array_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Array_deinit } // end of jbin_array_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add one or several values to a Json array. */ /* Add one or several values to a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Array_Add_Values_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_array_add_values_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Array_Add must have at least 2 arguments"); strcpy(message, "jbin_array_add_values must have at least 2 arguments");
return true; return true;
} else if (IsJson(args, 0) != 1) { } else if (IsJson(args, 0) != 1) {
strcpy(message, "Jbin_Array_Add first argument must be a json string"); strcpy(message, "jbin_array_add_values first argument must be a json string");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Array_Add_Values_init } // end of jbin_array_add_values_init
char *Jbin_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -3206,33 +3210,33 @@ char *Jbin_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3206,33 +3210,33 @@ char *Jbin_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Array_Add_Values } // end of jbin_array_add_values
void Jbin_Array_Add_Values_deinit(UDF_INIT* initid) void jbin_array_add_values_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Array_Add_Values_deinit } // end of jbin_array_add_values_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add one value to a Json array. */ /* Add one value to a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_array_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Array_Add must have at least 2 arguments"); strcpy(message, "jbin_array_add must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Array_Add first argument must be a json item"); strcpy(message, "jbin_array_add first argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Array_Add_init } // end of jbin_array_add_init
char *Jbin_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_array_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
int n = 2; int n = 2;
...@@ -3286,36 +3290,36 @@ char *Jbin_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3286,36 +3290,36 @@ char *Jbin_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Array_Add } // end of jbin_array_add
void Jbin_Array_Add_deinit(UDF_INIT* initid) void jbin_array_add_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Array_Add_deinit } // end of jbin_array_add_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Delete a value from a Json array. */ /* Delete a value from a Json array. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_array_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Array_Delete must have at lest 2 arguments"); strcpy(message, "jbin_array_delete must have at lest 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Array_Delete first argument must be a json item"); strcpy(message, "jbin_array_delete first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != INT_RESULT) { } else if (args->arg_type[1] != INT_RESULT) {
strcpy(message, "Jbin_Array_Delete second argument is not an integer (index)"); strcpy(message, "jbin_array_delete second argument is not an integer (index)");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Array_Delete_init } // end of jbin_array_delete_init
char *Jbin_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_array_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
PJSON top = NULL; PJSON top = NULL;
...@@ -3358,25 +3362,25 @@ char *Jbin_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3358,25 +3362,25 @@ char *Jbin_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Array_Delete } // end of jbin_array_delete
void Jbin_Array_Delete_deinit(UDF_INIT* initid) void jbin_array_delete_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Array_Delete_deinit } // end of jbin_array_delete_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json Oject containing all the parameters. */ /* Make a Json Oject containing all the parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Object_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_object_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, true, reslen, memlen); CalcLen(args, true, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Jbin_Object_init } // end of jbin_object_init
char *Jbin_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -3402,25 +3406,25 @@ char *Jbin_Object(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3402,25 +3406,25 @@ char *Jbin_Object(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Object } // end of jbin_object
void Jbin_Object_deinit(UDF_INIT* initid) void jbin_object_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Object_deinit } // end of jbin_object_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Make a Json Oject containing all not null parameters. */ /* Make a Json Oject containing all not null parameters. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Object_Nonull_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_object_nonull_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
CalcLen(args, true, reslen, memlen); CalcLen(args, true, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Jbin_Object_Nonull_init } // end of jbin_object_nonull_init
char *Jbin_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -3448,33 +3452,33 @@ char *Jbin_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3448,33 +3452,33 @@ char *Jbin_Object_Nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Object_Nonull } // end of jbin_object_nonull
void Jbin_Object_Nonull_deinit(UDF_INIT* initid) void jbin_object_nonull_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Object_nonull_deinit } // end of jbin_object_nonull_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Add or replace a value in a Json Object. */ /* Add or replace a value in a Json Object. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Object_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_object_add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Object_Add must have at least 2 arguments"); strcpy(message, "jbin_object_add must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Object_Add first argument must be a json item"); strcpy(message, "jbin_object_add first argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Object_Add_init } // end of jbin_object_add_init
char *Jbin_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_object_add(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
PJSON top = NULL; PJSON top = NULL;
...@@ -3518,36 +3522,36 @@ char *Jbin_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3518,36 +3522,36 @@ char *Jbin_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Object_Add } // end of jbin_object_add
void Jbin_Object_Add_deinit(UDF_INIT* initid) void jbin_object_add_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Object_Add_deinit } // end of jbin_object_add_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Delete a value from a Json object. */ /* Delete a value from a Json object. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Object_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_object_delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Object_Delete must have 2 or 3 arguments"); strcpy(message, "jbin_object_delete must have 2 or 3 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Object_Delete first argument must be a json item"); strcpy(message, "jbin_object_delete first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Jbin_Object_Delete second argument must be a key string"); strcpy(message, "jbin_object_delete second argument must be a key string");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Object_Delete_init } // end of jbin_object_delete_init
char *Jbin_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
PJSON top = NULL; PJSON top = NULL;
...@@ -3590,33 +3594,33 @@ char *Jbin_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3590,33 +3594,33 @@ char *Jbin_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Object_Delete } // end of jbin_object_delete
void Jbin_Object_Delete_deinit(UDF_INIT* initid) void jbin_object_delete_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Object_Delete_deinit } // end of jbin_object_delete_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Returns an array of the Json object keys. */ /* Returns an array of the Json object keys. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Object_List_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_object_list_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count != 1) { if (args->arg_count != 1) {
strcpy(message, "Jbin_Object_List must have 1 arguments"); strcpy(message, "jbin_object_list must have 1 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Object_List argument must be a json item"); strcpy(message, "jbin_object_list argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Jbin_Object_List_init } // end of jbin_object_list_init
char *Jbin_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_object_list(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
PJAR jarp = NULL; PJAR jarp = NULL;
...@@ -3647,26 +3651,26 @@ char *Jbin_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3647,26 +3651,26 @@ char *Jbin_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Object_List } // end of jbin_object_list
void Jbin_Object_List_deinit(UDF_INIT* initid) void jbin_object_list_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Object_List_deinit } // end of jbin_object_list_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Get a Json item from a Json document. */ /* Get a Json item from a Json document. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_get_item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
int n = IsJson(args, 0); int n = IsJson(args, 0);
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Get_Item must have at least 2 arguments"); strcpy(message, "jbin_get_item must have at least 2 arguments");
return true; return true;
} else if (!n && args->arg_type[0] != STRING_RESULT) { } else if (!n && args->arg_type[0] != STRING_RESULT) {
strcpy(message, "Jbin_Get_Item first argument must be a json item"); strcpy(message, "jbin_get_item first argument must be a json item");
return true; return true;
} else if (args->arg_type[1] != STRING_RESULT) { } else if (args->arg_type[1] != STRING_RESULT) {
strcpy(message, "Second argument is not a string (jpath)"); strcpy(message, "Second argument is not a string (jpath)");
...@@ -3686,9 +3690,9 @@ my_bool Jbin_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3686,9 +3690,9 @@ my_bool Jbin_Get_Item_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
memlen += args->lengths[0] * 3; memlen += args->lengths[0] * 3;
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Get_Item_init } // end of jbin_get_item_init
char *Jbin_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *) unsigned long *res_length, char *is_null, char *)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -3728,7 +3732,7 @@ char *Jbin_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3728,7 +3732,7 @@ char *Jbin_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result,
jsp = (PJSON)g->Xchk; jsp = (PJSON)g->Xchk;
path = MakePSZ(g, args, 1); path = MakePSZ(g, args, 1);
jsx = new(g)JSNX(g, jsp, TYPE_STRING, initid->max_length); jsx = new(g) JSNX(g, jsp, TYPE_STRING, initid->max_length);
if (jsx->SetJpath(g, path, true)) { if (jsx->SetJpath(g, path, true)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
...@@ -3758,36 +3762,36 @@ char *Jbin_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3758,36 +3762,36 @@ char *Jbin_Get_Item(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Get_Item } // end of jbin_get_item
void Jbin_Get_Item_deinit(UDF_INIT* initid) void jbin_get_item_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Get_Item_deinit } // end of jbin_get_item_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Merge two arrays or objects. */ /* Merge two arrays or objects. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_Item_Merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_item_merge_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count < 2) { if (args->arg_count < 2) {
strcpy(message, "Jbin_Item_Merge must have at least 2 arguments"); strcpy(message, "jbin_item_merge must have at least 2 arguments");
return true; return true;
} else if (!IsJson(args, 0)) { } else if (!IsJson(args, 0)) {
strcpy(message, "Jbin_Item_Merge first argument must be a json item"); strcpy(message, "jbin_item_merge first argument must be a json item");
return true; return true;
} else if (!IsJson(args, 1)) { } else if (!IsJson(args, 1)) {
strcpy(message, "Jbin_Item_Merge second argument must be a json item"); strcpy(message, "jbin_item_merge second argument must be a json item");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen, true); CalcLen(args, false, reslen, memlen, true);
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Jbin_Item_Merge_init } // end of jbin_item_merge_init
char *Jbin_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *error) unsigned long *res_length, char *, char *error)
{ {
PJSON top = NULL; PJSON top = NULL;
...@@ -3835,25 +3839,25 @@ char *Jbin_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3835,25 +3839,25 @@ char *Jbin_Item_Merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_Item_Merge } // end of jbin_item_merge
void Jbin_Item_Merge_deinit(UDF_INIT* initid) void jbin_item_merge_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_Item_Merge_deinit } // end of jbin_item_merge_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Returns a json file as a json item. */ /* Returns a json file as a json item. */
/*********************************************************************************/ /*********************************************************************************/
my_bool Jbin_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool jbin_file_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen, fl, more = 1024; unsigned long reslen, memlen, fl, more = 1024;
if (args->arg_count < 1 || args->arg_count > 3) { if (args->arg_count < 1 || args->arg_count > 3) {
strcpy(message, "Jbin_File only accepts 1 to 3 arguments"); strcpy(message, "jbin_file only accepts 1 to 3 arguments");
return true; return true;
} else if (args->arg_type[0] != STRING_RESULT || !args->args[0]) { } else if (args->arg_type[0] != STRING_RESULT || !args->args[0]) {
strcpy(message, "Jbin_File first argument must be a constant string (file name)"); strcpy(message, "jbin_file first argument must be a constant string (file name)");
return true; return true;
} else if (args->arg_count > 1 && args->arg_type[1] != INT_RESULT) { } else if (args->arg_count > 1 && args->arg_type[1] != INT_RESULT) {
strcpy(message, "Second argument is not an integer (pretty)"); strcpy(message, "Second argument is not an integer (pretty)");
...@@ -3873,9 +3877,9 @@ my_bool Jbin_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -3873,9 +3877,9 @@ my_bool Jbin_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
more += fl * M; more += fl * M;
memlen += more; memlen += more;
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Jbin_File_init } // end of jbin_file_init
char *Jbin_File(UDF_INIT *initid, UDF_ARGS *args, char *result, char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error) unsigned long *res_length, char *is_null, char *error)
{ {
char *fn, *memory; char *fn, *memory;
...@@ -3967,33 +3971,33 @@ char *Jbin_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -3967,33 +3971,33 @@ char *Jbin_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = sizeof(BSON); *res_length = sizeof(BSON);
return (char*)bsp; return (char*)bsp;
} // end of Jbin_File } // end of jbin_file
void Jbin_File_deinit(UDF_INIT* initid) void jbin_file_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Jbin_File_deinit } // end of jbin_file_deinit
/*********************************************************************************/ /*********************************************************************************/
/* Serialize a Json document. . */ /* Serialize a Json document. . */
/*********************************************************************************/ /*********************************************************************************/
my_bool Json_Serialize_init(UDF_INIT *initid, UDF_ARGS *args, char *message) my_bool json_serialize_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{ {
unsigned long reslen, memlen; unsigned long reslen, memlen;
if (args->arg_count != 1) { if (args->arg_count != 1) {
strcpy(message, "Json_Serialize must have 1 argument"); strcpy(message, "json_serialize must have 1 argument");
return true; return true;
} else if (IsJson(args, 0) != 3) { } else if (IsJson(args, 0) != 3) {
strcpy(message, "Json_Serialize argument must be a Jbin tree"); strcpy(message, "json_serialize argument must be a Jbin tree");
return true; return true;
} else } else
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
return JsonInit(initid, args, message, false, reslen, memlen); return JsonInit(initid, args, message, false, reslen, memlen);
} // end of Json_Serialize_init } // end of json_serialize_init
char *Json_Serialize(UDF_INIT *initid, UDF_ARGS *args, char *result, char *json_serialize(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str; char *str;
...@@ -4014,9 +4018,9 @@ char *Json_Serialize(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4014,9 +4018,9 @@ char *Json_Serialize(UDF_INIT *initid, UDF_ARGS *args, char *result,
*res_length = strlen(str); *res_length = strlen(str);
return str; return str;
} // end of Json_Serialize } // end of json_serialize
void Json_Serialize_deinit(UDF_INIT* initid) void json_serialize_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of Json_Serialize_deinit } // end of json_serialize_deinit
...@@ -33,145 +33,145 @@ typedef class JOUTPATH *PJTP; ...@@ -33,145 +33,145 @@ typedef class JOUTPATH *PJTP;
typedef class JOUTALL *PJTA; typedef class JOUTALL *PJTA;
extern "C" { extern "C" {
DllExport my_bool JsonValue_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonvalue_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *JsonValue(UDF_EXEC_ARGS); DllExport char *jsonvalue(UDF_EXEC_ARGS);
DllExport void JsonValue_deinit(UDF_INIT*); DllExport void jsonvalue_deinit(UDF_INIT*);
DllExport my_bool Json_Array_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array(UDF_EXEC_ARGS); DllExport char *json_array(UDF_EXEC_ARGS);
DllExport void Json_Array_deinit(UDF_INIT*); DllExport void json_array_deinit(UDF_INIT*);
DllExport my_bool Json_Array_Add_Values_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array_Add_Values(UDF_EXEC_ARGS); DllExport char *json_array_add_values(UDF_EXEC_ARGS);
DllExport void Json_Array_Add_Values_deinit(UDF_INIT*); DllExport void json_array_add_values_deinit(UDF_INIT*);
DllExport my_bool Json_Array_Add_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array_Add(UDF_EXEC_ARGS); DllExport char *json_array_add(UDF_EXEC_ARGS);
DllExport void Json_Array_Add_deinit(UDF_INIT*); DllExport void json_array_add_deinit(UDF_INIT*);
DllExport my_bool Json_Array_Delete_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Array_Delete(UDF_EXEC_ARGS); DllExport char *json_array_delete(UDF_EXEC_ARGS);
DllExport void Json_Array_Delete_deinit(UDF_INIT*); DllExport void json_array_delete_deinit(UDF_INIT*);
DllExport my_bool Json_Object_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object(UDF_EXEC_ARGS); DllExport char *json_object(UDF_EXEC_ARGS);
DllExport void Json_Object_deinit(UDF_INIT*); DllExport void json_object_deinit(UDF_INIT*);
DllExport my_bool Json_Object_Nonull_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object_Nonull(UDF_EXEC_ARGS); DllExport char *json_object_nonull(UDF_EXEC_ARGS);
DllExport void Json_Object_Nonull_deinit(UDF_INIT*); DllExport void json_object_nonull_deinit(UDF_INIT*);
DllExport my_bool Json_Object_Add_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object_Add(UDF_EXEC_ARGS); DllExport char *json_object_add(UDF_EXEC_ARGS);
DllExport void Json_Object_Add_deinit(UDF_INIT*); DllExport void json_object_add_deinit(UDF_INIT*);
DllExport my_bool Json_Object_Delete_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object_Delete(UDF_EXEC_ARGS); DllExport char *json_object_delete(UDF_EXEC_ARGS);
DllExport void Json_Object_Delete_deinit(UDF_INIT*); DllExport void json_object_delete_deinit(UDF_INIT*);
DllExport my_bool Json_Object_List_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_list_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Object_List(UDF_EXEC_ARGS); DllExport char *json_object_list(UDF_EXEC_ARGS);
DllExport void Json_Object_List_deinit(UDF_INIT*); DllExport void json_object_list_deinit(UDF_INIT*);
DllExport my_bool Json_Array_Grp_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_array_grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void Json_Array_Grp_add(UDF_INIT *, UDF_ARGS *, char *, char *); DllExport void json_array_grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *Json_Array_Grp(UDF_EXEC_ARGS); DllExport char *json_array_grp(UDF_EXEC_ARGS);
DllExport void Json_Array_Grp_clear(UDF_INIT *, char *, char *); DllExport void json_array_grp_clear(UDF_INIT *, char *, char *);
DllExport void Json_Array_Grp_deinit(UDF_INIT*); DllExport void json_array_grp_deinit(UDF_INIT*);
DllExport my_bool Json_Object_Grp_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_object_grp_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport void Json_Object_Grp_add(UDF_INIT *, UDF_ARGS *, char *, char *); DllExport void json_object_grp_add(UDF_INIT *, UDF_ARGS *, char *, char *);
DllExport char *Json_Object_Grp(UDF_EXEC_ARGS); DllExport char *json_object_grp(UDF_EXEC_ARGS);
DllExport void Json_Object_Grp_clear(UDF_INIT *, char *, char *); DllExport void json_object_grp_clear(UDF_INIT *, char *, char *);
DllExport void Json_Object_Grp_deinit(UDF_INIT*); DllExport void json_object_grp_deinit(UDF_INIT*);
DllExport my_bool Json_Get_Item_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_get_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Get_Item(UDF_EXEC_ARGS); DllExport char *json_get_item(UDF_EXEC_ARGS);
DllExport void Json_Get_Item_deinit(UDF_INIT*); DllExport void json_get_item_deinit(UDF_INIT*);
DllExport my_bool Json_Item_Merge_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_item_merge_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Item_Merge(UDF_EXEC_ARGS); DllExport char *json_item_merge(UDF_EXEC_ARGS);
DllExport void Json_Item_Merge_deinit(UDF_INIT*); DllExport void json_item_merge_deinit(UDF_INIT*);
DllExport my_bool JsonGetString_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonget_string_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *JsonGetString(UDF_EXEC_ARGS); DllExport char *jsonget_string(UDF_EXEC_ARGS);
DllExport void JsonGetString_deinit(UDF_INIT*); DllExport void jsonget_string_deinit(UDF_INIT*);
DllExport my_bool JsonGetInt_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonget_int_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long JsonGetInt(UDF_INIT*, UDF_ARGS*, char*, char*); DllExport long long jsonget_int(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void JsonGetInt_deinit(UDF_INIT*); DllExport void jsonget_int_deinit(UDF_INIT*);
DllExport my_bool JsonGetReal_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonget_real_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport double JsonGetReal(UDF_INIT*, UDF_ARGS*, char*, char*); DllExport double jsonget_real(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void JsonGetReal_deinit(UDF_INIT*); DllExport void jsonget_real_deinit(UDF_INIT*);
DllExport my_bool JsonLocate_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonlocate_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *JsonLocate(UDF_EXEC_ARGS); DllExport char *jsonlocate(UDF_EXEC_ARGS);
DllExport void JsonLocate_deinit(UDF_INIT*); DllExport void jsonlocate_deinit(UDF_INIT*);
DllExport my_bool Json_Locate_All_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_locate_all_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Locate_All(UDF_EXEC_ARGS); DllExport char *json_locate_all(UDF_EXEC_ARGS);
DllExport void Json_Locate_All_deinit(UDF_INIT*); DllExport void json_locate_all_deinit(UDF_INIT*);
DllExport my_bool Json_File_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_file_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_File(UDF_EXEC_ARGS); DllExport char *json_file(UDF_EXEC_ARGS);
DllExport void Json_File_deinit(UDF_INIT*); DllExport void json_file_deinit(UDF_INIT*);
DllExport my_bool Jfile_Make_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jfile_make_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jfile_Make(UDF_EXEC_ARGS); DllExport char *jfile_make(UDF_EXEC_ARGS);
DllExport void Jfile_Make_deinit(UDF_INIT*); DllExport void jfile_make_deinit(UDF_INIT*);
DllExport my_bool Jbin_Array_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_array_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Array(UDF_EXEC_ARGS); DllExport char *jbin_array(UDF_EXEC_ARGS);
DllExport void Jbin_Array_deinit(UDF_INIT*); DllExport void jbin_array_deinit(UDF_INIT*);
DllExport my_bool Jbin_Array_Add_Values_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_array_add_values_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Array_Add_Values(UDF_EXEC_ARGS); DllExport char *jbin_array_add_values(UDF_EXEC_ARGS);
DllExport void Jbin_Array_Add_Values_deinit(UDF_INIT*); DllExport void jbin_array_add_values_deinit(UDF_INIT*);
DllExport my_bool Jbin_Array_Add_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_array_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Array_Add(UDF_EXEC_ARGS); DllExport char *jbin_array_add(UDF_EXEC_ARGS);
DllExport void Jbin_Array_Add_deinit(UDF_INIT*); DllExport void jbin_array_add_deinit(UDF_INIT*);
DllExport my_bool Jbin_Array_Delete_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_array_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Array_Delete(UDF_EXEC_ARGS); DllExport char *jbin_array_delete(UDF_EXEC_ARGS);
DllExport void Jbin_Array_Delete_deinit(UDF_INIT*); DllExport void jbin_array_delete_deinit(UDF_INIT*);
DllExport my_bool Jbin_Object_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_object_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Object(UDF_EXEC_ARGS); DllExport char *jbin_object(UDF_EXEC_ARGS);
DllExport void Jbin_Object_deinit(UDF_INIT*); DllExport void jbin_object_deinit(UDF_INIT*);
DllExport my_bool Jbin_Object_Nonull_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_object_nonull_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Object_Nonull(UDF_EXEC_ARGS); DllExport char *jbin_object_nonull(UDF_EXEC_ARGS);
DllExport void Jbin_Object_Nonull_deinit(UDF_INIT*); DllExport void jbin_object_nonull_deinit(UDF_INIT*);
DllExport my_bool Jbin_Object_Add_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_object_add_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Object_Add(UDF_EXEC_ARGS); DllExport char *jbin_object_add(UDF_EXEC_ARGS);
DllExport void Jbin_Object_Add_deinit(UDF_INIT*); DllExport void jbin_object_add_deinit(UDF_INIT*);
DllExport my_bool Jbin_Object_Delete_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_object_delete_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Object_Delete(UDF_EXEC_ARGS); DllExport char *jbin_object_delete(UDF_EXEC_ARGS);
DllExport void Jbin_Object_Delete_deinit(UDF_INIT*); DllExport void jbin_object_delete_deinit(UDF_INIT*);
DllExport my_bool Jbin_Object_List_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_object_list_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Object_List(UDF_EXEC_ARGS); DllExport char *jbin_object_list(UDF_EXEC_ARGS);
DllExport void Jbin_Object_List_deinit(UDF_INIT*); DllExport void jbin_object_list_deinit(UDF_INIT*);
DllExport my_bool Jbin_Get_Item_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_get_item_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Get_Item(UDF_EXEC_ARGS); DllExport char *jbin_get_item(UDF_EXEC_ARGS);
DllExport void Jbin_Get_Item_deinit(UDF_INIT*); DllExport void jbin_get_item_deinit(UDF_INIT*);
DllExport my_bool Jbin_Item_Merge_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_item_merge_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_Item_Merge(UDF_EXEC_ARGS); DllExport char *jbin_item_merge(UDF_EXEC_ARGS);
DllExport void Jbin_Item_Merge_deinit(UDF_INIT*); DllExport void jbin_item_merge_deinit(UDF_INIT*);
DllExport my_bool Jbin_File_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jbin_file_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Jbin_File(UDF_EXEC_ARGS); DllExport char *jbin_file(UDF_EXEC_ARGS);
DllExport void Jbin_File_deinit(UDF_INIT*); DllExport void jbin_file_deinit(UDF_INIT*);
DllExport my_bool Json_Serialize_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_serialize_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *Json_Serialize(UDF_EXEC_ARGS); DllExport char *json_serialize(UDF_EXEC_ARGS);
DllExport void Json_Serialize_deinit(UDF_INIT*); DllExport void json_serialize_deinit(UDF_INIT*);
} // extern "C" } // extern "C"
/*********************************************************************************/ /*********************************************************************************/
......
...@@ -14,14 +14,14 @@ SELECT Json_Array(56,3.1416,'My name is "Foo"',NULL); ...@@ -14,14 +14,14 @@ SELECT Json_Array(56,3.1416,'My name is "Foo"',NULL);
Json_Array(56,3.1416,'My name is "Foo"',NULL) Json_Array(56,3.1416,'My name is "Foo"',NULL)
[56,3.141600,"My name is \"Foo\"",null] [56,3.141600,"My name is \"Foo\"",null]
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL)) Array; SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL)) Array;
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add must have at least 2 arguments ERROR HY000: Can't initialize function 'json_array_add'; json_array_add must have at least 2 arguments
SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array; SELECT Json_Array_Add(Json_Array(56,3.1416,'foo',NULL),'One more') Array;
Array Array
[56,3.141600,"foo",null,"One more"] [56,3.141600,"foo",null,"One more"]
SELECT Json_Array_Add(JsonValue('one value'),'One more'); SELECT Json_Array_Add(JsonValue('one value'),'One more');
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add first argument must be a json item ERROR HY000: Can't initialize function 'json_array_add'; json_array_add first argument must be a json item
SELECT Json_Array_Add('one value','One more'); SELECT Json_Array_Add('one value','One more');
ERROR HY000: Can't initialize function 'Json_Array_Add'; Json_Array_Add first argument must be a json item ERROR HY000: Can't initialize function 'json_array_add'; json_array_add first argument must be a json item
SELECT Json_Array_Add('one value' json_,'One more'); SELECT Json_Array_Add('one value' json_,'One more');
Json_Array_Add('one value' json_,'One more') Json_Array_Add('one value' json_,'One more')
NULL NULL
...@@ -30,7 +30,7 @@ Warning 1105 Error 2 opening one value ...@@ -30,7 +30,7 @@ Warning 1105 Error 2 opening one value
Warning 1105 Void JSON object Warning 1105 Void JSON object
Warning 1105 First argument is not an array Warning 1105 First argument is not an array
SELECT JsonValue(56,3.1416,'foo',NULL); SELECT JsonValue(56,3.1416,'foo',NULL);
ERROR HY000: Can't initialize function 'JsonValue'; JsonValue cannot accept more than 1 argument ERROR HY000: Can't initialize function 'jsonvalue'; jsonvalue cannot accept more than 1 argument
SELECT JsonValue(3.1416); SELECT JsonValue(3.1416);
JsonValue(3.1416) JsonValue(3.1416)
3.141600 3.141600
...@@ -79,7 +79,7 @@ Json_Object(AUTHOR, TITLE, DATEPUB) ...@@ -79,7 +79,7 @@ Json_Object(AUTHOR, TITLE, DATEPUB)
{"AUTHOR":"Jean-Christophe Bernadac","TITLE":"Construire une application XML","DATEPUB":1999} {"AUTHOR":"Jean-Christophe Bernadac","TITLE":"Construire une application XML","DATEPUB":1999}
{"AUTHOR":"William J. Pardi","TITLE":"XML en Action","DATEPUB":1999} {"AUTHOR":"William J. Pardi","TITLE":"XML en Action","DATEPUB":1999}
SELECT Json_Array_Grp(TITLE, DATEPUB) FROM t1; SELECT Json_Array_Grp(TITLE, DATEPUB) FROM t1;
ERROR HY000: Can't initialize function 'Json_Array_Grp'; Json_Array_Grp can only accept 1 argument ERROR HY000: Can't initialize function 'json_array_grp'; json_array_grp can only accept 1 argument
SELECT Json_Array_Grp(TITLE) FROM t1; SELECT Json_Array_Grp(TITLE) FROM t1;
Json_Array_Grp(TITLE) Json_Array_Grp(TITLE)
["Construire une application XML","XML en Action"] ["Construire une application XML","XML en Action"]
...@@ -145,7 +145,7 @@ Json_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Object(SERIALNO, NAME, SALARY ...@@ -145,7 +145,7 @@ Json_Object(DEPARTMENT, TITLE, Json_Array_Grp(Json_Object(SERIALNO, NAME, SALARY
{"DEPARTMENT":"2452","TITLE":"SCIENTIST","EMPLOYES":[{"SERIALNO":"34567","NAME":"BIGHEAD","SALARY":8000.000000},{"SERIALNO":"36666","NAME":"BIGHORN","SALARY":11000.000000}]} {"DEPARTMENT":"2452","TITLE":"SCIENTIST","EMPLOYES":[{"SERIALNO":"34567","NAME":"BIGHEAD","SALARY":8000.000000},{"SERIALNO":"36666","NAME":"BIGHORN","SALARY":11000.000000}]}
{"DEPARTMENT":"2452","TITLE":"SECRETARY","EMPLOYES":[{"SERIALNO":"11111","NAME":"CHERRY","SALARY":4500.000000}]} {"DEPARTMENT":"2452","TITLE":"SECRETARY","EMPLOYES":[{"SERIALNO":"11111","NAME":"CHERRY","SALARY":4500.000000}]}
SELECT Json_Object_Grp(SALARY) FROM t1; SELECT Json_Object_Grp(SALARY) FROM t1;
ERROR HY000: Can't initialize function 'Json_Object_Grp'; Json_Object_Grp can only accept 2 arguments ERROR HY000: Can't initialize function 'json_object_grp'; json_object_grp can only accept 2 arguments
SELECT Json_Object_Grp(SALARY, NAME) FROM t1; SELECT Json_Object_Grp(SALARY, NAME) FROM t1;
Json_Object_Grp(SALARY, NAME) Json_Object_Grp(SALARY, NAME)
{"BANCROFT":9600.000000,"SMITH":9000.000000,"MERCHANT":8700.000000,"FUNNIGUY":8500.000000,"BUGHAPPY":8500.000000,"BIGHEAD":8000.000000,"SHRINKY":7500.000000,"WALTER":7400.000000,"FODDERMAN":7000.000000,"TONGHO":6800.000000,"SHORTSIGHT":5500.000000,"MESSIFUL":5000.500000,"HONEY":4900.000000,"GOOSEPEN":4700.000000,"CHERRY":4500.000000,"MONAPENNY":3800.000000,"KITTY":3000.450000,"PLUMHEAD":2800.000000,"STRONG":23000.000000,"BULLOZER":14800.000000,"WERTHER":14500.000000,"QUINN":14000.000000,"ORELLY":13400.000000,"BIGHORN":11000.000000,"BROWNY":10500.000000,"WHEELFOR":10030.000000,"MARTIN":10000.000000} {"BANCROFT":9600.000000,"SMITH":9000.000000,"MERCHANT":8700.000000,"FUNNIGUY":8500.000000,"BUGHAPPY":8500.000000,"BIGHEAD":8000.000000,"SHRINKY":7500.000000,"WALTER":7400.000000,"FODDERMAN":7000.000000,"TONGHO":6800.000000,"SHORTSIGHT":5500.000000,"MESSIFUL":5000.500000,"HONEY":4900.000000,"GOOSEPEN":4700.000000,"CHERRY":4500.000000,"MONAPENNY":3800.000000,"KITTY":3000.450000,"PLUMHEAD":2800.000000,"STRONG":23000.000000,"BULLOZER":14800.000000,"WERTHER":14500.000000,"QUINN":14000.000000,"ORELLY":13400.000000,"BIGHORN":11000.000000,"BROWNY":10500.000000,"WHEELFOR":10030.000000,"MARTIN":10000.000000}
......
...@@ -9,13 +9,13 @@ if (!$HA_CONNECT_SO) { ...@@ -9,13 +9,13 @@ if (!$HA_CONNECT_SO) {
--skip Needs a dynamically built ha_connect.so --skip Needs a dynamically built ha_connect.so
} }
CREATE FUNCTION Json_Array RETURNS STRING SONAME 'ha_connect'; CREATE FUNCTION json_array RETURNS STRING SONAME 'ha_connect';
CREATE FUNCTION Json_Array_Add RETURNS STRING SONAME 'ha_connect'; CREATE FUNCTION json_array_add RETURNS STRING SONAME 'ha_connect';
CREATE FUNCTION Json_Object RETURNS STRING SONAME 'ha_connect'; CREATE FUNCTION json_object RETURNS STRING SONAME 'ha_connect';
CREATE FUNCTION Json_Object_Nonull RETURNS STRING SONAME 'ha_connect'; CREATE FUNCTION json_object_nonull RETURNS STRING SONAME 'ha_connect';
CREATE FUNCTION JsonValue RETURNS STRING SONAME 'ha_connect'; CREATE FUNCTION jsonvalue RETURNS STRING SONAME 'ha_connect';
CREATE AGGREGATE FUNCTION Json_Array_Grp RETURNS STRING SONAME 'ha_connect'; CREATE AGGREGATE FUNCTION json_array_grp RETURNS STRING SONAME 'ha_connect';
CREATE AGGREGATE FUNCTION Json_Object_Grp RETURNS STRING SONAME 'ha_connect'; CREATE AGGREGATE FUNCTION json_object_grp RETURNS STRING SONAME 'ha_connect';
--enable_query_log --enable_query_log
...@@ -2440,6 +2440,7 @@ void DTVAL::SetTimeShift(void) ...@@ -2440,6 +2440,7 @@ void DTVAL::SetTimeShift(void)
} // end of SetTimeShift } // end of SetTimeShift
#if defined(connect_EXPORTS)
// Added by Alexander Barkov // Added by Alexander Barkov
static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime) static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime)
{ {
...@@ -2461,6 +2462,9 @@ static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm) ...@@ -2461,6 +2462,9 @@ static struct tm *gmtime_mysql(const time_t *timep, struct tm *tm)
TIME_to_localtime(tm, &ltime); TIME_to_localtime(tm, &ltime);
return tm; return tm;
} // end of gmtime_mysql } // end of gmtime_mysql
#else
#define gmtime_mysql(T,B) gmtime((const time_t *)T)
#endif
/***********************************************************************/ /***********************************************************************/
/* GetGmTime: returns a pointer to a static tm structure obtained */ /* GetGmTime: returns a pointer to a static tm structure obtained */
...@@ -2489,6 +2493,7 @@ struct tm *DTVAL::GetGmTime(struct tm *tm_buffer) ...@@ -2489,6 +2493,7 @@ struct tm *DTVAL::GetGmTime(struct tm *tm_buffer)
return datm; return datm;
} // end of GetGmTime } // end of GetGmTime
#if defined(connect_EXPORTS)
// Added by Alexander Barkov // Added by Alexander Barkov
static time_t mktime_mysql(struct tm *ptm) static time_t mktime_mysql(struct tm *ptm)
{ {
...@@ -2499,6 +2504,9 @@ static time_t mktime_mysql(struct tm *ptm) ...@@ -2499,6 +2504,9 @@ static time_t mktime_mysql(struct tm *ptm)
time_t t= TIME_to_timestamp(current_thd, &ltime, &error_code); time_t t= TIME_to_timestamp(current_thd, &ltime, &error_code);
return error_code ? (time_t) -1 : t; return error_code ? (time_t) -1 : t;
} }
#else
#define mktime_mysql mktime
#endif
/***********************************************************************/ /***********************************************************************/
/* MakeTime: calculates a date value from a tm structures using the */ /* MakeTime: calculates a date value from a tm structures using the */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment