diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2020-12-17 13:58:13 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2020-12-17 13:58:13 +0100 |
commit | a7867410009ce91e3e710ace0b0d97261170d44a (patch) | |
tree | 36c4c522a2e8257942c4f39eacbdc6a8ed14b588 | |
parent | ceacffbb3b9504c88d0649d472396fa42397a62c (diff) | |
download | mariadb-git-a7867410009ce91e3e710ace0b0d97261170d44a.tar.gz |
- Fix crash with JsonContains UDF + BSON development
-rw-r--r-- | storage/connect/bson.cpp | 2 | ||||
-rw-r--r-- | storage/connect/jsonudf.cpp | 21 | ||||
-rw-r--r-- | storage/connect/jsonudf.h | 6 | ||||
-rw-r--r-- | storage/connect/tabbson.cpp | 13 |
4 files changed, 17 insertions, 25 deletions
diff --git a/storage/connect/bson.cpp b/storage/connect/bson.cpp index 08f4dca46f2..f7d4e5731c5 100644 --- a/storage/connect/bson.cpp +++ b/storage/connect/bson.cpp @@ -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__) diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 0909cb96477..bbe7cba28cc 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -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; diff --git a/storage/connect/jsonudf.h b/storage/connect/jsonudf.h index d99122aa775..689a02ebbc5 100644 --- a/storage/connect/jsonudf.h +++ b/storage/connect/jsonudf.h @@ -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" diff --git a/storage/connect/tabbson.cpp b/storage/connect/tabbson.cpp index 454484fc610..d4e5f09138a 100644 --- a/storage/connect/tabbson.cpp +++ b/storage/connect/tabbson.cpp @@ -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); |