Commit 175ef097 authored by Olivier Bertrand's avatar Olivier Bertrand

Handle is_null and error arguments

Fix wrong calling sequence for RESULT_INT and RESULT_REAL functions.
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h
parent f741fcc9
...@@ -1465,7 +1465,7 @@ my_bool Json_Array_Add_Values_init(UDF_INIT *initid, UDF_ARGS *args, char *messa ...@@ -1465,7 +1465,7 @@ my_bool Json_Array_Add_Values_init(UDF_INIT *initid, UDF_ARGS *args, char *messa
} // 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 *, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1498,7 +1498,12 @@ char *Json_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1498,7 +1498,12 @@ char *Json_Array_Add_Values(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else } else
str = (char*)g->Xchk; str = (char*)g->Xchk;
*res_length = (str) ? strlen(str) : 0; if (!str) {
*res_length = 0;
*is_null = 1;
} else
*res_length = strlen(str);
return str; return str;
} // end of Json_Array_Add_Values } // end of Json_Array_Add_Values
...@@ -1527,7 +1532,7 @@ my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1527,7 +1532,7 @@ my_bool Json_Array_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1565,8 +1570,10 @@ char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1565,8 +1570,10 @@ char *Json_Array_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
arp->AddValue(g, MakeValue(g, args, 1), x); arp->AddValue(g, MakeValue(g, args, 1), x);
arp->InitArray(g); arp->InitArray(g);
str = MakeResult(g, args, top, n); str = MakeResult(g, args, top, n);
} else } else {
PUSH_WARNING("First argument is not an array"); PUSH_WARNING("First argument is not an array");
if (g->Mrr) *error = 1;
} // endif jvp
} // endif CheckMemory } // endif CheckMemory
...@@ -1610,7 +1617,7 @@ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1610,7 +1617,7 @@ my_bool Json_Array_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1636,8 +1643,10 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1636,8 +1643,10 @@ char *Json_Array_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
arp->DeleteValue(n); arp->DeleteValue(n);
arp->InitArray(g); arp->InitArray(g);
str = MakeResult(g, args, top); str = MakeResult(g, args, top);
} else } else {
PUSH_WARNING("First argument is not an array"); PUSH_WARNING("First argument is not an array");
if (g->Mrr) *error = 1;
} // endif jvp
} // endif CheckMemory } // endif CheckMemory
...@@ -1769,7 +1778,7 @@ my_bool Json_Object_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1769,7 +1778,7 @@ my_bool Json_Object_Add_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *) unsigned long *res_length, char *, char *error)
{ {
char *key, *str = NULL; char *key, *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1794,8 +1803,10 @@ char *Json_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1794,8 +1803,10 @@ char *Json_Object_Add(UDF_INIT *initid, UDF_ARGS *args, char *result,
key = MakeKey(g, args, 1); key = MakeKey(g, args, 1);
jobp->SetValue(g, jvp, key); jobp->SetValue(g, jvp, key);
str = MakeResult(g, args, top); str = MakeResult(g, args, top);
} else } else {
PUSH_WARNING("First argument is not an object"); PUSH_WARNING("First argument is not an object");
if (g->Mrr) *error = 1;
} // endif jvp
} // endif CheckMemory } // endif CheckMemory
...@@ -1839,7 +1850,7 @@ my_bool Json_Object_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1839,7 +1850,7 @@ my_bool Json_Object_Delete_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *) unsigned long *res_length, char *, char *error)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1864,8 +1875,10 @@ char *Json_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1864,8 +1875,10 @@ char *Json_Object_Delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
jobp = jvp->GetObject(); jobp = jvp->GetObject();
jobp->DeleteKey(key); jobp->DeleteKey(key);
str = MakeResult(g, args, top); str = MakeResult(g, args, top);
} else } else {
PUSH_WARNING("First argument is not an object"); PUSH_WARNING("First argument is not an object");
if (g->Mrr) *error = 1;
} // endif jvp
} // endif CheckMemory } // endif CheckMemory
...@@ -1906,7 +1919,7 @@ my_bool Json_Object_List_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -1906,7 +1919,7 @@ my_bool Json_Object_List_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *, char *) unsigned long *res_length, char *is_null, char *error)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -1922,9 +1935,10 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1922,9 +1935,10 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!(str = Serialize(g, jarp, NULL, 0))) if (!(str = Serialize(g, jarp, NULL, 0)))
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
} else } else {
PUSH_WARNING("First argument is not an object"); PUSH_WARNING("First argument is not an object");
if (g->Mrr) *error = 1;
} // endif jvp
} // endif CheckMemory } // endif CheckMemory
...@@ -1937,7 +1951,12 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -1937,7 +1951,12 @@ char *Json_Object_List(UDF_INIT *initid, UDF_ARGS *args, char *result,
} else } else
str = (char*)g->Xchk; str = (char*)g->Xchk;
*res_length = (str) ? strlen(str) : 0; if (!str) {
*is_null = 1;
*res_length = 0;
} else
*res_length = strlen(str);
return str; return str;
} // end of Json_Object_List } // end of Json_Object_List
...@@ -2118,7 +2137,7 @@ my_bool Json_Get_String_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2118,7 +2137,7 @@ my_bool Json_Get_String_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Get_String_init } // end of Json_Get_String_init
char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result, char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str = NULL; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -2161,6 +2180,7 @@ char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2161,6 +2180,7 @@ char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
*is_null = 1;
return NULL; return NULL;
} // endif SetJpath } // endif SetJpath
...@@ -2176,7 +2196,12 @@ char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2176,7 +2196,12 @@ char *Json_Get_String(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif CheckMemory } // endif CheckMemory
fin: fin:
*res_length = (str) ? strlen(str) : 0; if (!str) {
*is_null = 1;
*res_length = 0;
} else
*res_length = strlen(str);
return str; return str;
} // end of Json_Get_String } // end of Json_Get_String
...@@ -2208,14 +2233,19 @@ my_bool Json_Get_Int_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2208,14 +2233,19 @@ my_bool Json_Get_Int_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Get_Int_init } // end of Json_Get_Int_init
long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result, long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args,
unsigned long *res_length, char *, char *) char *is_null, char *error)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
if (g->N) if (g->N) {
return (g->Xchk) ? *(long long*)g->Xchk : NULL; if (!g->Xchk) {
else if (g->Alchecked) *is_null = 1;
return 0LL;
} else
return *(long long*)g->Xchk;
} else if (g->Alchecked)
g->N = 1; g->N = 1;
if (!CheckMemory(g, initid, args, 1, false)) { if (!CheckMemory(g, initid, args, 1, false)) {
...@@ -2231,7 +2261,9 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2231,7 +2261,9 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result,
if ((p = jvp->GetString())) { if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) { if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
return NULL; if (g->Mrr) *error = 1;
*is_null = 1;
return 0;
} // endif jsp } // endif jsp
} else } else
...@@ -2250,14 +2282,16 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2250,14 +2282,16 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
return NULL; *is_null = 1;
return 0;
} // endif SetJpath } // endif SetJpath
jsx->ReadValue(g); jsx->ReadValue(g);
if (jsx->GetValue()->IsNull()) { if (jsx->GetValue()->IsNull()) {
PUSH_WARNING("Value not found"); PUSH_WARNING("Value not found");
return NULL; *is_null = 1;
return 0;
} // endif IsNull } // endif IsNull
n = jsx->GetValue()->GetBigintValue(); n = jsx->GetValue()->GetBigintValue();
...@@ -2270,9 +2304,11 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2270,9 +2304,11 @@ long long Json_Get_Int(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Alchecked } // endif Alchecked
return n; return n;
} else } // endif CheckMemory
return NULL;
if (g->Mrr) *error = 1;
*is_null = 1;
return 0LL;
} // end of Json_Get_Int } // end of Json_Get_Int
void Json_Get_Int_deinit(UDF_INIT* initid) void Json_Get_Int_deinit(UDF_INIT* initid)
...@@ -2311,14 +2347,19 @@ my_bool Json_Get_Real_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2311,14 +2347,19 @@ my_bool Json_Get_Real_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return JsonInit(initid, args, message, true, reslen, memlen); return JsonInit(initid, args, message, true, reslen, memlen);
} // end of Json_Get_Real_init } // end of Json_Get_Real_init
double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result, double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args,
unsigned long *res_length, char *, char *) char *is_null, char *error)
{ {
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
if (g->N) if (g->N) {
return (g->Xchk) ? *(double*)g->Xchk : NULL; if (!g->Xchk) {
else if (g->Alchecked) *is_null = 1;
return 0.0;
} else
return *(double*)g->Xchk;
} else if (g->Alchecked)
g->N = 1; g->N = 1;
if (!CheckMemory(g, initid, args, 1, false)) { if (!CheckMemory(g, initid, args, 1, false)) {
...@@ -2334,7 +2375,8 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2334,7 +2375,8 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result,
if ((p = jvp->GetString())) { if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) { if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
return NULL; *is_null = 1;
return 0.0;
} // endif jsp } // endif jsp
} else } else
...@@ -2353,14 +2395,16 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2353,14 +2395,16 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (jsx->SetJpath(g, path)) { if (jsx->SetJpath(g, path)) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
return NULL; *is_null = 1;
return 0.0;
} // endif SetJpath } // endif SetJpath
jsx->ReadValue(g); jsx->ReadValue(g);
if (jsx->GetValue()->IsNull()) { if (jsx->GetValue()->IsNull()) {
PUSH_WARNING("Value not found"); PUSH_WARNING("Value not found");
return NULL; *is_null = 1;
return 0.0;
} // endif IsNull } // endif IsNull
d = jsx->GetValue()->GetFloatValue(); d = jsx->GetValue()->GetFloatValue();
...@@ -2373,9 +2417,11 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2373,9 +2417,11 @@ double Json_Get_Real(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Alchecked } // endif Alchecked
return d; return d;
} else } // endif CheckMemory
return NULL;
if (g->Mrr) *error = 1;
*is_null = 1;
return 0.0;
} // end of Json_Get_Real } // end of Json_Get_Real
void Json_Get_Real_deinit(UDF_INIT* initid) void Json_Get_Real_deinit(UDF_INIT* initid)
...@@ -2409,15 +2455,22 @@ my_bool Json_Locate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2409,15 +2455,22 @@ my_bool Json_Locate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Locate_init } // end of Json_Locate_init
char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result, char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *is_null, char *error)
{ {
char *path = NULL; char *path = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
if (g->N) { if (g->N) {
if (g->Xchk) {
path = (char*)g->Xchk; path = (char*)g->Xchk;
*res_length = (path) ? strlen(path) : 0; *res_length = strlen(path);
return path; return path;
} else {
*res_length = 0;
*is_null = 1;
return NULL;
} // endif Xchk
} else if (g->Alchecked) } else if (g->Alchecked)
g->N = 1; g->N = 1;
...@@ -2431,11 +2484,15 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2431,11 +2484,15 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Save stack and allocation environment and prepare error return // Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) { if (g->jump_level == MAX_JUMP) {
PUSH_WARNING(MSG(TOO_MANY_JUMPS)); PUSH_WARNING(MSG(TOO_MANY_JUMPS));
*error = 1;
*is_null = 1;
return NULL; return NULL;
} // endif jump_level } // endif jump_level
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) { if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
*error = 1;
path = NULL;
goto err; goto err;
} // endif rc } // endif rc
...@@ -2445,7 +2502,6 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2445,7 +2502,6 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result,
if ((p = jvp->GetString())) { if ((p = jvp->GetString())) {
if (!(jsp = ParseJson(g, p, strlen(p)))) { if (!(jsp = ParseJson(g, p, strlen(p)))) {
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
goto err; goto err;
} // endif jsp } // endif jsp
...@@ -2469,11 +2525,19 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2469,11 +2525,19 @@ char *Json_Locate(UDF_INIT *initid, UDF_ARGS *args, char *result,
err: err:
g->jump_level--; g->jump_level--;
*res_length = (path) ? strlen(path) : 0;
return path; if (!path) {
*res_length = 0;
*is_null = 1;
} else } else
return NULL; *res_length = strlen(path);
return path;
} // endif CheckMemory
*error = 1;
*is_null = 1;
return NULL;
} // end of Json_Locate } // end of Json_Locate
void Json_Locate_deinit(UDF_INIT* initid) void Json_Locate_deinit(UDF_INIT* initid)
...@@ -2524,7 +2588,7 @@ my_bool Json_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2524,7 +2588,7 @@ my_bool Json_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // 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 *, char *) unsigned long *res_length, char *is_null, char *error)
{ {
char *str, *fn; char *str, *fn;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
...@@ -2559,6 +2623,8 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2559,6 +2623,8 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int)rc, fn); sprintf(g->Message, MSG(OPEN_MODE_ERROR), "map", (int)rc, fn);
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
if (g->Mrr) *error = 1;
*is_null = 1;
return NULL; return NULL;
} // endif hFile } // endif hFile
...@@ -2570,12 +2636,15 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2570,12 +2636,15 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (!len) { // Empty or deleted file if (!len) { // Empty or deleted file
CloseFileHandle(hFile); CloseFileHandle(hFile);
*is_null = 1;
return NULL; return NULL;
} // endif len } // endif len
if (!memory) { if (!memory) {
CloseFileHandle(hFile); CloseFileHandle(hFile);
sprintf(g->Message, MSG(MAP_VIEW_ERROR), fn, GetLastError()); sprintf(g->Message, MSG(MAP_VIEW_ERROR), fn, GetLastError());
PUSH_WARNING(g->Message);
*is_null = 1;
return NULL; return NULL;
} // endif Memory } // endif Memory
...@@ -2604,8 +2673,13 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2604,8 +2673,13 @@ char *Json_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
// Keep result of constant function // Keep result of constant function
g->Xchk = str; g->Xchk = str;
fin: fin:
*res_length = (str) ? strlen(str) : 0; if (!str) {
*res_length = 0;
*is_null = 1;
} else
*res_length = strlen(str);
return str; return str;
} // end of Json_File } // end of Json_File
...@@ -2640,7 +2714,7 @@ my_bool Json_Make_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -2640,7 +2714,7 @@ my_bool Json_Make_File_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
} // end of Json_Make_File_init } // end of Json_Make_File_init
char *Json_Make_File(UDF_INIT *initid, UDF_ARGS *args, char *result, char *Json_Make_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *is_null, char *)
{ {
char *str, *fn, *msg; char *str, *fn, *msg;
int pretty; int pretty;
...@@ -2679,7 +2753,12 @@ char *Json_Make_File(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2679,7 +2753,12 @@ char *Json_Make_File(UDF_INIT *initid, UDF_ARGS *args, char *result,
g->Xchk = str; g->Xchk = str;
fin: fin:
*res_length = (str) ? strlen(str) : 0; if (!str) {
*res_length = 0;
*is_null = 1;
} else
*res_length = strlen(str);
return str; return str;
} // end of Json_Make_File } // end of Json_Make_File
......
...@@ -89,11 +89,11 @@ extern "C" { ...@@ -89,11 +89,11 @@ extern "C" {
DllExport void Json_Get_String_deinit(UDF_INIT*); DllExport void Json_Get_String_deinit(UDF_INIT*);
DllExport my_bool Json_Get_Int_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool Json_Get_Int_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long Json_Get_Int(UDF_EXEC_ARGS); DllExport long long Json_Get_Int(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void Json_Get_Int_deinit(UDF_INIT*); DllExport void Json_Get_Int_deinit(UDF_INIT*);
DllExport my_bool Json_Get_Real_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool Json_Get_Real_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport double Json_Get_Real(UDF_EXEC_ARGS); DllExport double Json_Get_Real(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void Json_Get_Real_deinit(UDF_INIT*); DllExport void Json_Get_Real_deinit(UDF_INIT*);
DllExport my_bool Json_Locate_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool Json_Locate_init(UDF_INIT*, UDF_ARGS*, char*);
......
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