From fa7bbe5a73bcb96164a20fbb461d82675a2c486e Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Mon, 7 May 2018 00:56:45 +0200 Subject: - Fix MDEV-15735 CONNECT [filamtxt.cpp:429]: Suspicious condition modified: storage/connect/filamtxt.cpp - Fix MDEV-15577 CONNECT engine JDBC remote index prevents UPDATE Fixed in TDBJDBC::OpenDB because query can be null for updates modified: storage/connect/tabjdbc.cpp - Fix wrong updates of 10.3 distribution modified: storage/connect/ha_connect.cc modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp - Typo from 10.3 modified: storage/connect/mycat.cc modified: storage/connect/tabext.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/user_connect.cc --- storage/connect/jsonudf.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index ca51712af0c..b10060c7541 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -41,8 +41,6 @@ static PJSON JsonNew(PGLOBAL g, JTYP type); static PJVAL JvalNew(PGLOBAL g, JTYP type, void *vp = NULL); static PJSNX JsnxNew(PGLOBAL g, PJSON jsp, int type, int len = 64); -void json_array_deinit(UDF_INIT* initid); - static uint JsonGrpSize = 10; /*********************************************************************************/ @@ -1669,7 +1667,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) int j = 0, n = args->attribute_lengths[i]; my_bool b; // true if attribute is zero terminated PSZ p; - const char *s = args->attributes[i]; + PCSZ s = args->attributes[i]; if (s && *s && (n || *s == '\'')) { if ((b = (!n || !s[n]))) @@ -1688,7 +1686,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) } // endif *s if (n < 1) - return (char*) "Key"; + return "Key"; if (!b) { if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { @@ -1702,10 +1700,10 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) } // endif s - return (char*) s; + return s; } // endif count - return (char*) "Key"; + return "Key"; } // end of MakeKey /*********************************************************************************/ -- cgit v1.2.1 From 15194de2c2846fcbb5d9feb7b6d993b281ac6e1f Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Wed, 8 Aug 2018 12:10:30 +0200 Subject: - Fix MDEV-16672 Connect: Warnings with 10.0 filamtxt.cpp: DOSFAM::RenameTempFile: Change sprintf to snprintf. filamvct.cpp: VECFAM::RenameTempFile: Change sprintf to snprintf. javaconn.cpp: Add JAVAConn::GetUTFString function. Use it instead of env->GetStringUTFChars. Fix wrong identation. javaconn.h: Add GetUTFString declaration. jdbconn.cpp: Use GetUTFString function instead of env->GetStringUTFChars. jmgoconn.cpp: Use GetUTFString function instead of env->GetStringUTFChars. Fix wrong identation. jsonudf.cpp: change 139 to BMX line 4631. tabjmg.cpp: Add ReleaseStringUTF. Fix wrong identation. tabpivot.cpp: Fix wrong identation. tabutil.cpp: TDBPRX::GetSubTable: Change sprintf to snprintf. modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/javaconn.cpp modified: storage/connect/javaconn.h modified: storage/connect/jdbconn.cpp modified: storage/connect/jmgoconn.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjmg.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabutil.cpp - Fix MDEV-16895 CONNECT engine's get_error_message can cause buffer overflow and server crash with long queries ha_connect_cc: Update version. get_error_message: Remove charset conversion. modified: storage/connect/ha_connect.cc - Fix a server crash on inserting bigint to a JDBC table JDBConn::SetUUID: Suppress check on ctyp that causes a server crash because ctyp can be negative and this triggers an DEBUG_ASSERT on return. modified: storage/connect/jdbconn.cpp - Delete an assert(qrp) from JCATPARM *AllocCatInfo that is called with qrp=NULL from JDBConn::SetUUID. Also delete a clone of this function that was duplicated in javaconn.cpp. modified: storage/connect/javaconn.cpp modified: storage/connect/jdbconn.cpp - Update some (disabled) tests and results to avoid failure modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/json_java_2.result modified: storage/connect/mysql-test/connect/r/json_java_3.result modified: storage/connect/mysql-test/connect/r/mongo_java_2.result modified: storage/connect/mysql-test/connect/r/mongo_java_3.result modified: storage/connect/mysql-test/connect/r/xml2.result modified: storage/connect/mysql-test/connect/t/json_java_2.test modified: storage/connect/mysql-test/connect/t/json_java_3.test modified: storage/connect/mysql-test/connect/t/mongo_java_2.test modified: storage/connect/mysql-test/connect/t/mongo_java_3.test modified: storage/connect/mysql-test/connect/t/xml2.test --- storage/connect/jsonudf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index b10060c7541..b78d68fddb9 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1620,7 +1620,7 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n, if (AllocSarea(g, ml)) { char errmsg[MAX_STR]; - snprintf(errmsg, sizeof(errmsg)-1, MSG(WORK_AREA), g->Message); + snprintf(errmsg, sizeof(errmsg) - 1, MSG(WORK_AREA), g->Message); strcpy(g->Message, errmsg); return true; } // endif SareaAlloc @@ -1667,7 +1667,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) int j = 0, n = args->attribute_lengths[i]; my_bool b; // true if attribute is zero terminated PSZ p; - PCSZ s = args->attributes[i]; + PCSZ s = args->attributes[i]; if (s && *s && (n || *s == '\'')) { if ((b = (!n || !s[n]))) @@ -4632,7 +4632,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result, bsp = NULL; if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, 139); + strncpy(bsp->Msg, g->Message, BMX); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -5852,3 +5852,4 @@ long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result, free(str2); return n; } // end of countin + -- cgit v1.2.1 From 4a572631aa68d363e517216388dd814bc253b1b6 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 4 Dec 2018 23:26:47 +0100 Subject: - Make PlugSubAlloc to be exportable Suppress unused parameter from PlugSubSet modified: storage/connect/global.h modified: storage/connect/plugutil.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/user_connect.cc - Fix a bug making column catalog XML tables fail modified: storage/connect/tabxml.cpp - Comment out wrong message modified: storage/connect/ha_connect.cc - Update error message when sorting an ODBC table fails modified: storage/connect/tabodbc.cpp - Add error message when gettting an address from an OEM fails. modified: storage/connect/reldef.cpp - Make some modifications useful for OEM module writting Export discovery functions for CSV, JDBC and XML Remove unuseful include from tabjson.h Move TDBXML::data_charset function from header file to source modified: storage/connect/tabfmt.h modified: storage/connect/tabjson.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h - Update test result modified: storage/connect/mysql-test/connect/r/jdbc_oracle.result --- storage/connect/jsonudf.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index b78d68fddb9..42b276b6090 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -3056,7 +3056,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); g->N = (int)n; return false; @@ -3099,7 +3099,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); g->N = GetJsonGroupSize(); } // end of json_array_grp_clear @@ -3133,7 +3133,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); g->N = (int)n; return false; @@ -3170,7 +3170,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); g->N = GetJsonGroupSize(); } // end of json_object_grp_clear @@ -4419,7 +4419,7 @@ char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if (initid->const_item) g->N = 1; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); fn = MakePSZ(g, args, 0); if (args->arg_count > 1) { @@ -5663,7 +5663,7 @@ char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result, if (bsp && !bsp->Changed) goto fin; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Xchk = NULL; fn = MakePSZ(g, args, 0); pretty = (args->arg_count > 2 && args->args[2]) ? (int)*(longlong*)args->args[2] : 3; -- cgit v1.2.1 From 990f8e8146bfccb4739d385752f0127dab74dbdf Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sun, 3 Feb 2019 12:34:30 +0100 Subject: - Fix MDEV-13136: enhance CREATE SERVER MyServerName FOREIGN DATA WRAPPER to work with CONNECT engine modified: storage/connect/tabjdbc.cpp - Add a function to retrieve User variable value (DEVELOPMENT only) modified: storage/connect/ha_connect.cc modified: storage/connect/jsonudf.cpp modified: storage/connect/jsonudf.h modified: storage/connect/tabjdbc.cpp --- storage/connect/jsonudf.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 42b276b6090..3e9b6ad625f 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -5806,6 +5806,52 @@ char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result, return str; } // end of envar +#if defined(DEVELOPMENT) +extern char *GetUserVariable(PGLOBAL g, const uchar *varname); + +/*********************************************************************************/ +/* Utility function returning a user variable value. */ +/*********************************************************************************/ +my_bool uvar_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + unsigned long reslen, memlen; + + if (args->arg_count != 1) { + strcpy(message, "Unique argument must be a user variable name"); + return true; + } else + CalcLen(args, false, reslen, memlen, true); + + initid->maybe_null = true; + return JsonInit(initid, args, message, true, reslen, memlen, 2048); +} // end of uvar_init + +char *uvar(UDF_INIT *initid, UDF_ARGS *args, char *result, + unsigned long *res_length, char *is_null, char *) +{ + char *str, varname[256]; + PGLOBAL g = (PGLOBAL)initid->ptr; + int n = MY_MIN(args->lengths[0], sizeof(varname) - 1); + + PlugSubSet(g->Sarea, g->Sarea_Size); + memcpy(varname, args->args[0], n); + varname[n] = 0; + + if (!(str = GetUserVariable(g, (const uchar*)&varname))) { + *res_length = 0; + *is_null = 1; + } else + *res_length = strlen(str); + + return str; +} // end of uvar + +void uvar_deinit(UDF_INIT* initid) +{ + JsonFreeMem((PGLOBAL)initid->ptr); +} // end of uvar_deinit +#endif // DEVELOPMENT + /*********************************************************************************/ /* Returns the distinct number of B occurences in A. */ /*********************************************************************************/ -- cgit v1.2.1 From ec4795add694349c191b5f2e8d5f1c7e64008441 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Thu, 27 Jun 2019 17:54:28 +0200 Subject: In CONNECT version 1.6.10 NOSQL facility is enhanced by a new way to retrieve NOSQL data. In addition to files and Mongo collections, JSON as well as XML and CSV data can be retrieved from the net as answers from REST queries. Because it uses and external package (cpprestsdk) this is currently available only to MariaDB servers compiled from source. -- Add the REST support when Microsoft Casablanca package (cpprestsdk) is installed. -- Also include some changes specific to MariaDB 10.3. modified: storage/connect/CMakeLists.txt -- Add conditional REST support -- Added string options HTTP and URI. -- Added added internal table type TAB_REST. modified: storage/connect/ha_connect.cc modified: storage/connect/mycat.cc modified: storage/connect/mycat.h modified: storage/connect/plgdbsem.h -- Fix MDEV-19648 Variable connect_conv_size doesn't change -- Change Variable wrong block parameter from 8169 to 1. -- Also change connect_conv_size default value to 1024. modified: storage/connect/ha_connect.cc -- Avoid possible buffer overflow -- In particular by the function ShowValue. modified: storage/connect/tabdos.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/value.cpp modified: storage/connect/value.h -- Add some cast to avoid some compiler warnings modified: storage/connect/filamdbf.cpp -- Fix some C++ error modified: storage/connect/javaconn.cpp modified: storage/connect/jmgoconn.cpp modified: storage/connect/plugutil.cpp -- Miscellaneous Typo and warning suppressing changes modified: storage/connect/connect.cpp modified: storage/connect/connect.h modified: storage/connect/filamvct.cpp modified: storage/connect/inihandl.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/libdoc.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/user_connect.cc modified: storage/connect/user_connect.h -- Update failing test results and disbling modified: storage/connect/mysql-test/connect/disabled.def modified: storage/connect/mysql-test/connect/r/dir.result modified: storage/connect/mysql-test/connect/r/grant.result modified: storage/connect/mysql-test/connect/r/jdbc.result modified: storage/connect/mysql-test/connect/r/jdbc_postgresql.result modified: storage/connect/mysql-test/connect/r/xml.result modified: storage/connect/mysql-test/connect/r/xml2.result modified: storage/connect/mysql-test/connect/r/xml2_mult.result modified: storage/connect/mysql-test/connect/r/xml_mult.result -- Add an option modified: storage/connect/mysql-test/connect/t/grant.test --- storage/connect/jsonudf.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'storage/connect/jsonudf.cpp') diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 3e9b6ad625f..dad86d51040 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1,6 +1,6 @@ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/ -/* PROGRAM NAME: jsonudf Version 1.7 */ -/* (C) Copyright to the author Olivier BERTRAND 2015-2018 */ +/* PROGRAM NAME: jsonudf Version 1.8 */ +/* (C) Copyright to the author Olivier BERTRAND 2015-2019 */ /* This program are the JSON User Defined Functions . */ /*********************************************************************************/ @@ -1686,7 +1686,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) } // endif *s if (n < 1) - return "Key"; + return (PCSZ) "Key"; if (!b) { if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { @@ -1703,7 +1703,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i) return s; } // endif count - return "Key"; + return (PCSZ) "Key"; } // end of MakeKey /*********************************************************************************/ @@ -5819,7 +5819,7 @@ my_bool uvar_init(UDF_INIT *initid, UDF_ARGS *args, char *message) if (args->arg_count != 1) { strcpy(message, "Unique argument must be a user variable name"); return true; - } else + } else CalcLen(args, false, reslen, memlen, true); initid->maybe_null = true; @@ -5898,4 +5898,3 @@ long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result, free(str2); return n; } // end of countin - -- cgit v1.2.1