Commit a7867410 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix crash with JsonContains UDF + BSON development

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