Commit a7867410 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix crash with JsonContains UDF + BSON development

parent ceacffbb
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#if defined(_DEBUG) #if defined(_DEBUG)
#define CheckType(X,Y) if (!X || X ->Type != Y) throw MSG(VALTYPE_NOMATCH); #define CheckType(X,Y) if (!X || X ->Type != Y) throw MSG(VALTYPE_NOMATCH);
#else #else
#define CheckType(V) #define CheckType(X,Y)
#endif #endif
#if defined(__WIN__) #if defined(__WIN__)
......
...@@ -4066,17 +4066,14 @@ my_bool jsoncontains_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -4066,17 +4066,14 @@ my_bool jsoncontains_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return JsonInit(initid, args, message, false, reslen, memlen, more); return JsonInit(initid, args, message, false, reslen, memlen, more);
} // end of jsoncontains_init } // end of jsoncontains_init
long long jsoncontains(UDF_INIT *initid, UDF_ARGS *args, char *result, long long jsoncontains(UDF_INIT *initid, UDF_ARGS *args, char *, char *error)
unsigned long *res_length, char *is_null, char *error)
{ {
char *p __attribute__((unused)), res[256]; char isn, res[256];
long long n;
unsigned long reslen; unsigned long reslen;
*is_null = 0; isn = 0;
p = jsonlocate(initid, args, res, &reslen, is_null, error); jsonlocate(initid, args, res, &reslen, &isn, error);
n = (*is_null) ? 0LL : 1LL; return (isn) ? 0LL : 1LL;
return n;
} // end of jsoncontains } // end of jsoncontains
void jsoncontains_deinit(UDF_INIT* initid) void jsoncontains_deinit(UDF_INIT* initid)
...@@ -4118,8 +4115,7 @@ my_bool jsoncontains_path_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -4118,8 +4115,7 @@ my_bool jsoncontains_path_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return JsonInit(initid, args, message, true, reslen, memlen, more); return JsonInit(initid, args, message, true, reslen, memlen, more);
} // end of jsoncontains_path_init } // end of jsoncontains_path_init
long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result, long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *, char *error)
unsigned long *res_length, char *is_null, char *error)
{ {
char *p, *path; char *p, *path;
long long n; long long n;
...@@ -4130,7 +4126,6 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4130,7 +4126,6 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
if (g->N) { if (g->N) {
if (!g->Activityp) { if (!g->Activityp) {
*is_null = 1;
return 0LL; return 0LL;
} else } else
return *(long long*)g->Activityp; return *(long long*)g->Activityp;
...@@ -4188,7 +4183,6 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4188,7 +4183,6 @@ long long jsoncontains_path(UDF_INIT *initid, UDF_ARGS *args, char *result,
err: err:
if (g->Mrr) *error = 1; if (g->Mrr) *error = 1;
*is_null = 1;
return 0LL; return 0LL;
} // end of jsoncontains_path } // end of jsoncontains_path
...@@ -6528,8 +6522,7 @@ my_bool countin_init(UDF_INIT *initid, UDF_ARGS *args, char *message) ...@@ -6528,8 +6522,7 @@ my_bool countin_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
return false; return false;
} // end of countin_init } // end of countin_init
long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result, long long countin(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *)
unsigned long *res_length, char *is_null, char *)
{ {
PSZ str1, str2; PSZ str1, str2;
char *s; char *s;
......
...@@ -174,7 +174,7 @@ extern "C" { ...@@ -174,7 +174,7 @@ extern "C" {
DllExport void jsonget_real_deinit(UDF_INIT*); DllExport void jsonget_real_deinit(UDF_INIT*);
DllExport my_bool jsoncontains_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsoncontains_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long jsoncontains(UDF_EXEC_ARGS); DllExport long long jsoncontains(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void jsoncontains_deinit(UDF_INIT*); DllExport void jsoncontains_deinit(UDF_INIT*);
DllExport my_bool jsonlocate_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsonlocate_init(UDF_INIT*, UDF_ARGS*, char*);
...@@ -186,7 +186,7 @@ extern "C" { ...@@ -186,7 +186,7 @@ extern "C" {
DllExport void json_locate_all_deinit(UDF_INIT*); DllExport void json_locate_all_deinit(UDF_INIT*);
DllExport my_bool jsoncontains_path_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool jsoncontains_path_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long jsoncontains_path(UDF_EXEC_ARGS); DllExport long long jsoncontains_path(UDF_INIT*, UDF_ARGS*, char*, char*);
DllExport void jsoncontains_path_deinit(UDF_INIT*); DllExport void jsoncontains_path_deinit(UDF_INIT*);
DllExport my_bool json_set_item_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_set_item_init(UDF_INIT*, UDF_ARGS*, char*);
...@@ -294,7 +294,7 @@ extern "C" { ...@@ -294,7 +294,7 @@ extern "C" {
#endif // DEVELOPMENT #endif // DEVELOPMENT
DllExport my_bool countin_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool countin_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long countin(UDF_EXEC_ARGS); DllExport long long countin(UDF_INIT*, UDF_ARGS*, char*, char*);
} // extern "C" } // extern "C"
......
...@@ -1161,18 +1161,19 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m) ...@@ -1161,18 +1161,19 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
USETEMP tmp = UseTemp(); USETEMP tmp = UseTemp();
bool map = Mapped && Pretty >= 0 && m != MODE_INSERT && bool map = Mapped && Pretty >= 0 && m != MODE_INSERT &&
!(tmp != TMP_NO && m == MODE_UPDATE) && !(tmp != TMP_NO && m == MODE_UPDATE) &&
!(tmp == TMP_FORCE && !(tmp == TMP_FORCE && (m == MODE_UPDATE || m == MODE_DELETE));
(m == MODE_UPDATE || m == MODE_DELETE));
if (Lrecl) { if (Lrecl) {
// Allocate the parse work memory // Allocate the parse work memory
G = PlugInit(NULL, (size_t)Lrecl * 4); G = PlugInit(NULL, (size_t)Lrecl * (Pretty < 0 ? 2 : 4));
} else { } else {
strcpy(g->Message, "LRECL is not defined"); strcpy(g->Message, "LRECL is not defined");
return NULL; return NULL;
} // endif Lrecl } // endif Lrecl
if (Uri) { if (Pretty < 0) { // BJsonfile
txfp = new(g) BINFAM(this);
} else if (Uri) {
if (Driver && toupper(*Driver) == 'C') { if (Driver && toupper(*Driver) == 'C') {
#if defined(CMGO_SUPPORT) #if defined(CMGO_SUPPORT)
txfp = new(g) CMGFAM(this); txfp = new(g) CMGFAM(this);
...@@ -1222,10 +1223,8 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m) ...@@ -1222,10 +1223,8 @@ PTDB BSONDEF::GetTable(PGLOBAL g, MODE m)
sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ"); sprintf(g->Message, MSG(NO_FEAT_SUPPORT), "GZ");
return NULL; return NULL;
#endif // !GZ_SUPPORT #endif // !GZ_SUPPORT
} else if (map) } else if (map) {
txfp = new(g) MAPFAM(this); txfp = new(g) MAPFAM(this);
else if (Pretty < 0) { // BJsonfile
txfp = new(g) BINFAM(this);
} else } else
txfp = new(g) DOSFAM(this); txfp = new(g) DOSFAM(this);
......
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