1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge remote-tracking branch 'connect/10.2' into 10.2

This commit is contained in:
Oleksandr Byelkin
2019-08-30 16:52:43 +02:00
37 changed files with 1994 additions and 1497 deletions

View File

@@ -689,7 +689,7 @@ public:
/* Cache of the result of is_expensive(). */ /* Cache of the result of is_expensive(). */
int8 is_expensive_cache; int8 is_expensive_cache;
/* Reuse size, only used by SP local variable assignment, otherwize 0 */ /* Reuse size, only used by SP local variable assignment, otherwise 0 */
uint rsize; uint rsize;
protected: protected:

View File

@@ -1982,7 +1982,7 @@ before_trg_err:
/****************************************************************************** /******************************************************************************
Check that all fields with arn't null_fields are used Check that there aren't any null_fields
******************************************************************************/ ******************************************************************************/

View File

@@ -73,7 +73,15 @@ ELSE(NOT UNIX)
tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h) tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h)
# Add exception handling to the CONNECT project) # Add exception handling to the CONNECT project)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
SET(IPHLPAPI_LIBRARY iphlpapi.lib) SET(IPHLPAPI_LIBRARY iphlpapi.lib)
IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
# Connect does not work with clang-cl
RETURN()
ENDIF()
ENDIF(UNIX) ENDIF(UNIX)
@@ -114,7 +122,6 @@ IF(CONNECT_WITH_LIBXML2)
FIND_PACKAGE(LibXml2) FIND_PACKAGE(LibXml2)
IF (LIBXML2_FOUND) IF (LIBXML2_FOUND)
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below
SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) SET(XML_LIBRARY ${LIBXML2_LIBRARIES})
SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h) SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h)
add_definitions(-DLIBXML2_SUPPORT) add_definitions(-DLIBXML2_SUPPORT)
@@ -308,6 +315,30 @@ IF(CONNECT_WITH_MONGO)
ENDIF(CONNECT_WITH_MONGO) ENDIF(CONNECT_WITH_MONGO)
#
# REST
#
OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)
IF(CONNECT_WITH_REST)
MESSAGE(STATUS "=====> REST support is ON")
FIND_PACKAGE(cpprestsdk)
IF (cpprestsdk_FOUND)
MESSAGE(STATUS "=====> cpprestsdk found")
IF(UNIX)
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
# If needed edit next line to set the path to libcpprest.so
SET(REST_LIBRARY -lcpprest)
MESSAGE (STATUS ${REST_LIBRARY})
ENDIF(UNIX)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
ELSE(NOT cpprestsdk_FOUND)
MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST)
# #
# XMAP # XMAP
# #
@@ -327,24 +358,16 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
COMPONENT connect-engine COMPONENT connect-engine
RECOMPILE_FOR_EMBEDDED RECOMPILE_FOR_EMBEDDED
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY} LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY}) ${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY} ${REST_LIBRARY})
IF(NOT TARGET connect) IF(NOT TARGET connect)
RETURN() RETURN()
ENDIF() ENDIF()
# Don't link with bundled zlib and systel libxml2 at the same time.
# System libxml2 uses system zlib, might conflict with the bundled one.
IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB)
GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES)
LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR})
SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS})
ENDIF()
IF(WIN32) IF(WIN32)
IF (libmongoc-1.0_FOUND) IF (libmongoc-1.0_FOUND)
SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS
"/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll") "/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll")
ENDIF(libmongoc-1.0_FOUND) ENDIF(libmongoc-1.0_FOUND)
ENDIF(WIN32) ENDIF(WIN32)
@@ -371,3 +394,4 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar ${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine) DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
ENDIF() ENDIF()

View File

@@ -1,7 +1,7 @@
/************* Array C++ Functions Source Code File (.CPP) *************/ /************* Array C++ Functions Source Code File (.CPP) *************/
/* Name: ARRAY.CPP Version 2.3 */ /* Name: ARRAY.CPP Version 2.3 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */ /* (C) Copyright to the author Olivier BERTRAND 2005-2019 */
/* */ /* */
/* This file contains the XOBJECT derived class ARRAY functions. */ /* This file contains the XOBJECT derived class ARRAY functions. */
/* ARRAY is used for elaborate type of processing, such as sorting */ /* ARRAY is used for elaborate type of processing, such as sorting */
@@ -67,7 +67,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp); // avoid gcc warning
/* MakeValueArray: Makes a value array from a value list. */ /* MakeValueArray: Makes a value array from a value list. */
/***********************************************************************/ /***********************************************************************/
PARRAY MakeValueArray(PGLOBAL g, PPARM pp) PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
{ {
int n, valtyp = 0; int n, valtyp = 0;
size_t len = 0; size_t len = 0;
PARRAY par; PARRAY par;
@@ -82,8 +82,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
if ((valtyp = pp->Type) != TYPE_STRING) if ((valtyp = pp->Type) != TYPE_STRING)
len = 1; len = 1;
if (trace(1)) xtrc(1, "valtyp=%d len=%d\n", valtyp, len);
htrc("valtyp=%d len=%d\n", valtyp, len);
/*********************************************************************/ /*********************************************************************/
/* Firstly check the list and count the number of values in it. */ /* Firstly check the list and count the number of values in it. */
@@ -127,13 +126,13 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
// Integer stored inside pp->Value // Integer stored inside pp->Value
par->AddValue(g, parmp->Intval); par->AddValue(g, parmp->Intval);
break; break;
} // endswitch valtyp } // endswitch valtyp
/*********************************************************************/ /*********************************************************************/
/* Send back resulting array. */ /* Send back resulting array. */
/*********************************************************************/ /*********************************************************************/
return par; return par;
} // end of MakeValueArray } // end of MakeValueArray
/* -------------------------- Class ARRAY ---------------------------- */ /* -------------------------- Class ARRAY ---------------------------- */
@@ -151,6 +150,9 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
Type = type; Type = type;
Xsize = -1; Xsize = -1;
Len = 1; Len = 1;
X = 0;
Inf = 0;
Sup = 0;
switch (type) { switch (type) {
case TYPE_STRING: case TYPE_STRING:
@@ -281,130 +283,109 @@ void ARRAY::Empty(void)
/* Add a string element to an array. */ /* Add a string element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, PSZ strp) bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
{ {
if (Type != TYPE_STRING) { if (Type != TYPE_STRING) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR"); sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR");
return true; return true;
} // endif Type } // endif Type
if (trace(1)) xtrc(1, " adding string(%d): '%s'\n", Nval, strp);
htrc(" adding string(%d): '%s'\n", Nval, strp);
//Value->SetValue_psz(strp);
//Vblp->SetValue(valp, Nval++);
Vblp->SetValue(strp, Nval++); Vblp->SetValue(strp, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a char pointer element to an array. */ /* Add a char pointer element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, void *p) bool ARRAY::AddValue(PGLOBAL g, void *p)
{ {
if (Type != TYPE_PCHAR) { if (Type != TYPE_PCHAR) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR"); sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR");
return true; return true;
} // endif Type } // endif Type
if (trace(1))
htrc(" adding pointer(%d): %p\n", Nval, p);
xtrc(1, " adding pointer(%d): %p\n", Nval, p);
Vblp->SetValue((PSZ)p, Nval++); Vblp->SetValue((PSZ)p, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a short integer element to an array. */ /* Add a short integer element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, short n) bool ARRAY::AddValue(PGLOBAL g, short n)
{ {
if (Type != TYPE_SHORT) { if (Type != TYPE_SHORT) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT"); sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT");
return true; return true;
} // endif Type } // endif Type
if (trace(1)) xtrc(1, " adding SHORT(%d): %hd\n", Nval, n);
htrc(" adding SHORT(%d): %hd\n", Nval, n);
//Value->SetValue(n);
//Vblp->SetValue(valp, Nval++);
Vblp->SetValue(n, Nval++); Vblp->SetValue(n, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add an integer element to an array. */ /* Add an integer element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, int n) bool ARRAY::AddValue(PGLOBAL g, int n)
{ {
if (Type != TYPE_INT) { if (Type != TYPE_INT) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER"); sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER");
return true; return true;
} // endif Type } // endif Type
if (trace(1)) xtrc(1, " adding int(%d): %d\n", Nval, n);
htrc(" adding int(%d): %d\n", Nval, n);
//Value->SetValue(n);
//Vblp->SetValue(valp, Nval++);
Vblp->SetValue(n, Nval++); Vblp->SetValue(n, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a double float element to an array. */ /* Add a double float element to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, double d) bool ARRAY::AddValue(PGLOBAL g, double d)
{ {
if (Type != TYPE_DOUBLE) { if (Type != TYPE_DOUBLE) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE"); sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE");
return true; return true;
} // endif Type } // endif Type
if (trace(1))
htrc(" adding float(%d): %lf\n", Nval, d);
xtrc(1, " adding float(%d): %lf\n", Nval, d);
Value->SetValue(d); Value->SetValue(d);
Vblp->SetValue(Value, Nval++); Vblp->SetValue(Value, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add the value of a XOBJECT block to an array. */ /* Add the value of a XOBJECT block to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, PXOB xp) bool ARRAY::AddValue(PGLOBAL g, PXOB xp)
{ {
if (Type != xp->GetResultType()) { if (Type != xp->GetResultType()) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), sprintf(g->Message, MSG(ADD_BAD_TYPE),
GetTypeName(xp->GetResultType()), GetTypeName(Type)); GetTypeName(xp->GetResultType()), GetTypeName(Type));
return true; return true;
} // endif Type } // endif Type
if (trace(1)) xtrc(1, " adding (%d) from xp=%p\n", Nval, xp);
htrc(" adding (%d) from xp=%p\n", Nval, xp); Vblp->SetValue(xp->GetValue(), Nval++);
return false;
//AddValue(xp->GetValue()); } // end of AddValue
Vblp->SetValue(xp->GetValue(), Nval++);
return false;
} // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Add a value to an array. */ /* Add a value to an array. */
/***********************************************************************/ /***********************************************************************/
bool ARRAY::AddValue(PGLOBAL g, PVAL vp) bool ARRAY::AddValue(PGLOBAL g, PVAL vp)
{ {
if (Type != vp->GetType()) { if (Type != vp->GetType()) {
sprintf(g->Message, MSG(ADD_BAD_TYPE), sprintf(g->Message, MSG(ADD_BAD_TYPE),
GetTypeName(vp->GetType()), GetTypeName(Type)); GetTypeName(vp->GetType()), GetTypeName(Type));
return true; return true;
} // endif Type } // endif Type
if (trace(1))
htrc(" adding (%d) from vp=%p\n", Nval, vp);
xtrc(1, " adding (%d) from vp=%p\n", Nval, vp);
Vblp->SetValue(vp, Nval++); Vblp->SetValue(vp, Nval++);
return false; return false;
} // end of AddValue } // end of AddValue
/***********************************************************************/ /***********************************************************************/
/* Retrieve the nth value of the array. */ /* Retrieve the nth value of the array. */
@@ -973,7 +954,7 @@ int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
/* MakeArrayList: Makes a value list from an SQL IN array (in work). */ /* MakeArrayList: Makes a value list from an SQL IN array (in work). */
/***********************************************************************/ /***********************************************************************/
PSZ ARRAY::MakeArrayList(PGLOBAL g) PSZ ARRAY::MakeArrayList(PGLOBAL g)
{ {
char *p, *tp; char *p, *tp;
int i; int i;
size_t z, len = 2; size_t z, len = 2;
@@ -988,11 +969,9 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
Value->SetValue_pvblk(Vblp, i); Value->SetValue_pvblk(Vblp, i);
Value->Prints(g, tp, z); Value->Prints(g, tp, z);
len += strlen(tp); len += strlen(tp);
} // enfor i } // enfor i
if (trace(1))
htrc("Arraylist: len=%d\n", len);
xtrc(1, "Arraylist: len=%d\n", len);
p = (char *)PlugSubAlloc(g, NULL, len); p = (char *)PlugSubAlloc(g, NULL, len);
strcpy(p, "("); strcpy(p, "(");
@@ -1001,19 +980,17 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
Value->Prints(g, tp, z); Value->Prints(g, tp, z);
strcat(p, tp); strcat(p, tp);
strcat(p, (++i == Nval) ? ")" : ","); strcat(p, (++i == Nval) ? ")" : ",");
} // enfor i } // enfor i
if (trace(1))
htrc("Arraylist: newlen=%d\n", strlen(p));
xtrc(1, "Arraylist: newlen=%d\n", strlen(p));
return p; return p;
} // end of MakeArrayList } // end of MakeArrayList
/***********************************************************************/ /***********************************************************************/
/* Make file output of ARRAY contents. */ /* Make file output of ARRAY contents. */
/***********************************************************************/ /***********************************************************************/
void ARRAY::Printf(PGLOBAL g, FILE *f, uint n) void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
{ {
char m[64]; char m[64];
int lim = MY_MIN(Nval,10); int lim = MY_MIN(Nval,10);
@@ -1035,19 +1012,19 @@ void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
} else } else
fprintf(f, "%sVALLST: numval=%d\n", m, Nval); fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
} // end of Printf } // end of Printf
/***********************************************************************/ /***********************************************************************/
/* Make string output of ARRAY contents. */ /* Make string output of ARRAY contents. */
/***********************************************************************/ /***********************************************************************/
void ARRAY::Prints(PGLOBAL, char *ps, uint z) void ARRAY::Prints(PGLOBAL, char *ps, uint z)
{ {
if (z < 16) if (z < 16)
return; return;
sprintf(ps, "ARRAY: type=%d\n", Type); sprintf(ps, "ARRAY: type=%d\n", Type);
// More to be implemented later // More to be implemented later
} // end of Prints } // end of Prints
/* -------------------------- Class MULAR ---------------------------- */ /* -------------------------- Class MULAR ---------------------------- */

View File

@@ -38,9 +38,7 @@ typedef class BLOCK *PBLOCK;
class DllExport BLOCK { class DllExport BLOCK {
public: public:
void * operator new(size_t size, PGLOBAL g, void *p = NULL) { void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
if (trace(256)) xtrc(256, "New BLOCK: size=%d g=%p p=%p\n", size, g, p);
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
return (PlugSubAlloc(g, p, size)); return (PlugSubAlloc(g, p, size));
} // end of new } // end of new

View File

@@ -33,6 +33,7 @@
/* plgdbsem.h is header containing the DB applic. declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/ /***********************************************************************/
#define DONT_DEFINE_VOID #define DONT_DEFINE_VOID
#include <my_global.h>
#include "handler.h" #include "handler.h"
#undef OFFSET #undef OFFSET

View File

@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/**************** Cnt H Declares Source Code File (.H) *****************/ /**************** Cnt H Declares Source Code File (.H) *****************/
/* Name: CONNECT.H Version 2.4 */ /* Name: CONNECT.H Version 2.4 */

View File

@@ -224,6 +224,7 @@ DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *MakePtr(void *, OFFSET); DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...); DllExport void htrc(char const *fmt, ...);
DllExport void xtrc(uint, char const* fmt, ...);
DllExport uint GetTraceValue(void); DllExport uint GetTraceValue(void);
#if defined(__cplusplus) #if defined(__cplusplus)

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/** @file ha_connect.h /** @file ha_connect.h
Author Olivier Bertrand Author Olivier Bertrand

View File

@@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
} }
for (key = section->key; key; key = key->next) for (key = section->key; key; key = key->next)
if (key->name[0]) { if (key->name && key->name[0]) {
fprintf(file, "%s", SVP(key->name)); fprintf(file, "%s", SVP(key->name));
if (key->value) if (key->value)

View File

@@ -813,4 +813,3 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
return fld; return fld;
} // end of GetColumnValue } // end of GetColumnValue

View File

@@ -1,6 +1,6 @@
/****************** jsonudf C++ Program Source Code File (.CPP) ******************/ /****************** jsonudf C++ Program Source Code File (.CPP) ******************/
/* PROGRAM NAME: jsonudf Version 1.7 */ /* PROGRAM NAME: jsonudf Version 1.8 */
/* (C) Copyright to the author Olivier BERTRAND 2015-2018 */ /* (C) Copyright to the author Olivier BERTRAND 2015-2019 */
/* This program are the JSON User Defined Functions . */ /* This program are the JSON User Defined Functions . */
/*********************************************************************************/ /*********************************************************************************/
@@ -1686,7 +1686,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
} // endif *s } // endif *s
if (n < 1) if (n < 1)
return "Key"; return (PCSZ) "Key";
if (!b) { if (!b) {
if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) { if ((p = (PSZ)PlgDBSubAlloc(g, NULL, n + 1))) {
@@ -1703,7 +1703,7 @@ static PCSZ MakeKey(PGLOBAL g, UDF_ARGS *args, int i)
return s; return s;
} // endif count } // endif count
return "Key"; return (PCSZ) "Key";
} // end of MakeKey } // end of MakeKey
/*********************************************************************************/ /*********************************************************************************/

View File

@@ -1035,7 +1035,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np)
// If name has the format m[n] only m is taken as node name // If name has the format m[n] only m is taken as node name
if ((p = strchr(pn, '['))) if ((p = strchr(pn, '[')))
p = BufAlloc(g, pn, p - pn); p = BufAlloc(g, pn, int(p - pn));
else else
p = pn; p = pn;

View File

@@ -0,0 +1,33 @@
/***********************************************************************/
/* Definitions needed by the included files. */
/***********************************************************************/
#if !defined(MY_GLOBAL_H)
#define MY_GLOBAL_H
typedef unsigned int uint;
typedef unsigned int uint32;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned long DWORD;
typedef char *LPSTR;
typedef const char *LPCSTR;
typedef int BOOL;
#if defined(_WINDOWS)
typedef void *HANDLE;
#else
typedef int HANDLE;
#endif
typedef char *PSZ;
typedef const char *PCSZ;
typedef unsigned char BYTE;
typedef unsigned char uchar;
typedef long long longlong;
typedef unsigned long long ulonglong;
typedef char my_bool;
struct charset_info_st {};
typedef const charset_info_st CHARSET_INFO;
#define FALSE 0
#define TRUE 1
#define Item char
#define MY_MAX(a,b) ((a>b)?(a):(b))
#define MY_MIN(a,b) ((a<b)?(a):(b))
#endif // MY_GLOBAL_H

View File

@@ -16,9 +16,9 @@
/*************** Mycat CC Program Source Code File (.CC) ***************/ /*************** Mycat CC Program Source Code File (.CC) ***************/
/* PROGRAM NAME: MYCAT */ /* PROGRAM NAME: MYCAT */
/* ------------- */ /* ------------- */
/* Version 1.6 */ /* Version 1.7 */
/* */ /* */
/* Author: Olivier Bertrand 2012 - 2018 */ /* Author: Olivier Bertrand 2012 - 2019 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -93,6 +93,9 @@
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
#include "tabzip.h" #include "tabzip.h"
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
#if defined(REST_SUPPORT)
#include "tabrest.h"
#endif // Rest_SUPPORT
#include "mycat.h" #include "mycat.h"
/***********************************************************************/ /***********************************************************************/
@@ -121,7 +124,7 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "DOS")) ? TAB_DOS : (!stricmp(type, "DOS")) ? TAB_DOS
: (!stricmp(type, "FIX")) ? TAB_FIX : (!stricmp(type, "FIX")) ? TAB_FIX
: (!stricmp(type, "BIN")) ? TAB_BIN : (!stricmp(type, "BIN")) ? TAB_BIN
: (!stricmp(type, "CSV")) ? TAB_CSV : (!stricmp(type, "CSV")) ? TAB_CSV
: (!stricmp(type, "FMT")) ? TAB_FMT : (!stricmp(type, "FMT")) ? TAB_FMT
: (!stricmp(type, "DBF")) ? TAB_DBF : (!stricmp(type, "DBF")) ? TAB_DBF
#if defined(XML_SUPPORT) #if defined(XML_SUPPORT)
@@ -133,30 +136,30 @@ TABTYPE GetTypeID(const char *type)
: (!stricmp(type, "ODBC")) ? TAB_ODBC : (!stricmp(type, "ODBC")) ? TAB_ODBC
#endif #endif
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
: (!stricmp(type, "JDBC")) ? TAB_JDBC : (!stricmp(type, "JDBC")) ? TAB_JDBC
#endif #endif
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
: (!stricmp(type, "MONGO") && MongoEnabled()) ? TAB_MONGO : (!stricmp(type, "MONGO") && MongoEnabled()) ? TAB_MONGO
#endif #endif
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL : (!stricmp(type, "MYSQL")) ? TAB_MYSQL
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL : (!stricmp(type, "MYPRX")) ? TAB_MYSQL
: (!stricmp(type, "DIR")) ? TAB_DIR : (!stricmp(type, "DIR")) ? TAB_DIR
#if defined(__WIN__) #if defined(__WIN__)
: (!stricmp(type, "MAC")) ? TAB_MAC : (!stricmp(type, "MAC")) ? TAB_MAC
: (!stricmp(type, "WMI")) ? TAB_WMI : (!stricmp(type, "WMI")) ? TAB_WMI
#endif #endif
: (!stricmp(type, "TBL")) ? TAB_TBL : (!stricmp(type, "TBL")) ? TAB_TBL
: (!stricmp(type, "XCOL")) ? TAB_XCL : (!stricmp(type, "XCOL")) ? TAB_XCL
: (!stricmp(type, "OCCUR")) ? TAB_OCCUR : (!stricmp(type, "OCCUR")) ? TAB_OCCUR
: (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy : (!stricmp(type, "CATLG")) ? TAB_PRX // Legacy
: (!stricmp(type, "PROXY")) ? TAB_PRX : (!stricmp(type, "PROXY")) ? TAB_PRX
: (!stricmp(type, "PIVOT")) ? TAB_PIVOT : (!stricmp(type, "PIVOT")) ? TAB_PIVOT
: (!stricmp(type, "VIR")) ? TAB_VIR : (!stricmp(type, "VIR")) ? TAB_VIR
: (!stricmp(type, "JSON")) ? TAB_JSON : (!stricmp(type, "JSON")) ? TAB_JSON
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
: (!stricmp(type, "ZIP")) ? TAB_ZIP : (!stricmp(type, "ZIP")) ? TAB_ZIP
#endif #endif
: (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY; : (!stricmp(type, "OEM")) ? TAB_OEM : TAB_NIY;
} // end of GetTypeID } // end of GetTypeID
/***********************************************************************/ /***********************************************************************/
@@ -170,14 +173,15 @@ bool IsFileType(TABTYPE type)
case TAB_DOS: case TAB_DOS:
case TAB_FIX: case TAB_FIX:
case TAB_BIN: case TAB_BIN:
case TAB_CSV: case TAB_CSV:
case TAB_FMT: case TAB_FMT:
case TAB_DBF: case TAB_DBF:
case TAB_XML: case TAB_XML:
case TAB_INI: case TAB_INI:
case TAB_VEC: case TAB_VEC:
case TAB_JSON: case TAB_JSON:
// case TAB_ZIP: case TAB_REST:
// case TAB_ZIP:
isfile= true; isfile= true;
break; break;
default: default:
@@ -301,9 +305,9 @@ int GetIndexType(TABTYPE type)
break; break;
case TAB_MYSQL: case TAB_MYSQL:
case TAB_ODBC: case TAB_ODBC:
case TAB_JDBC: case TAB_JDBC:
case TAB_MONGO: case TAB_MONGO:
xtyp= 2; xtyp= 2;
break; break;
case TAB_VIR: case TAB_VIR:
xtyp= 3; xtyp= 3;
@@ -452,7 +456,7 @@ CATALOG::CATALOG(void)
memset(&Ctb, 0, sizeof(CURTAB)); memset(&Ctb, 0, sizeof(CURTAB));
Cbuf= NULL; Cbuf= NULL;
Cblen= 0; Cblen= 0;
DefHuge= false; DefHuge= false;
} // end of CATALOG constructor } // end of CATALOG constructor
/* -------------------------- Class MYCAT ---------------------------- */ /* -------------------------- Class MYCAT ---------------------------- */
@@ -462,7 +466,7 @@ CATALOG::CATALOG(void)
/***********************************************************************/ /***********************************************************************/
MYCAT::MYCAT(PHC hc) : CATALOG() MYCAT::MYCAT(PHC hc) : CATALOG()
{ {
Hc= hc; Hc= hc;
DefHuge= false; DefHuge= false;
} // end of MYCAT constructor } // end of MYCAT constructor
@@ -479,16 +483,23 @@ void MYCAT::Reset(void)
/***********************************************************************/ /***********************************************************************/
PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep, PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep,
LPCSTR type, PRELDEF *) LPCSTR type, PRELDEF *)
{ {
if (trace(1)) PRELDEF tdp= NULL;
printf("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type));
// If not specified get the type of this table if (trace(1))
if (!type) htrc("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type));
type= Hc->GetStringOption("Type","*");
return MakeTableDesc(g, tablep, type); // If not specified get the type of this table
} // end of GetTableDesc //if (!type)
// type= Hc->GetStringOption("Type","*");
tdp= MakeTableDesc(g, tablep, type);
if (trace(1))
htrc("GetTableDesc: tdp=%p\n", tdp);
return tdp;
} // end of GetTableDesc
/***********************************************************************/ /***********************************************************************/
/* MakeTableDesc: make a table/view description. */ /* MakeTableDesc: make a table/view description. */
@@ -497,18 +508,22 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep,
PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am) PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
{ {
TABTYPE tc; TABTYPE tc;
LPCSTR name = (PSZ)PlugDup(g, tablep->GetName()); LPCSTR name= (PSZ)PlugDup(g, tablep->GetName());
LPCSTR schema = (PSZ)PlugDup(g, tablep->GetSchema()); LPCSTR schema= (PSZ)PlugDup(g, tablep->GetSchema());
PRELDEF tdp= NULL; PRELDEF tdp= NULL;
if (trace(1)) if (trace(1))
printf("MakeTableDesc: name=%s schema=%s am=%s\n", htrc("MakeTableDesc: name=%s schema=%s am=%s\n",
name, SVP(schema), SVP(am)); name, SVP(schema), SVP(am));
/*********************************************************************/ /*********************************************************************/
/* Get a unique enum identifier for types. */ /* Get a unique enum identifier for types. */
/*********************************************************************/ /*********************************************************************/
tc= GetTypeID(am); if (!am) {
tc= Hc->GetRealType();
am= Hc->GetStringOption("Type","*");
} else
tc= GetTypeID(am);
switch (tc) { switch (tc) {
case TAB_FIX: case TAB_FIX:
@@ -523,46 +538,52 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
case TAB_XML: tdp= new(g) XMLDEF; break; case TAB_XML: tdp= new(g) XMLDEF; break;
#endif // XML_SUPPORT #endif // XML_SUPPORT
#if defined(VCT_SUPPORT) #if defined(VCT_SUPPORT)
case TAB_VEC: tdp = new(g) VCTDEF; break; case TAB_VEC: tdp = new(g) VCTDEF; break;
#endif // VCT_SUPPORT #endif // VCT_SUPPORT
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break; case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT
#if defined(JAVA_SUPPORT) #if defined(JAVA_SUPPORT)
case TAB_JDBC: tdp= new(g) JDBCDEF; break; case TAB_JDBC: tdp= new(g) JDBCDEF; break;
#endif // JAVA_SUPPORT #endif // JAVA_SUPPORT
#if defined(__WIN__) #if defined(__WIN__)
case TAB_MAC: tdp= new(g) MACDEF; break; case TAB_MAC: tdp= new(g) MACDEF; break;
case TAB_WMI: tdp= new(g) WMIDEF; break; case TAB_WMI: tdp= new(g) WMIDEF; break;
#endif // __WIN__ #endif // __WIN__
case TAB_OEM: tdp= new(g) OEMDEF; break; case TAB_OEM: tdp= new(g) OEMDEF; break;
case TAB_TBL: tdp= new(g) TBLDEF; break; case TAB_TBL: tdp= new(g) TBLDEF; break;
case TAB_XCL: tdp= new(g) XCLDEF; break; case TAB_XCL: tdp= new(g) XCLDEF; break;
case TAB_PRX: tdp= new(g) PRXDEF; break; case TAB_PRX: tdp= new(g) PRXDEF; break;
case TAB_OCCUR: tdp= new(g) OCCURDEF; break; case TAB_OCCUR: tdp= new(g) OCCURDEF; break;
case TAB_MYSQL: tdp= new(g) MYSQLDEF; break; case TAB_MYSQL: tdp= new(g) MYSQLDEF; break;
case TAB_PIVOT: tdp= new(g) PIVOTDEF; break; case TAB_PIVOT: tdp= new(g) PIVOTDEF; break;
case TAB_VIR: tdp= new(g) VIRDEF; break; case TAB_VIR: tdp= new(g) VIRDEF; break;
case TAB_JSON: tdp= new(g) JSONDEF; break; case TAB_JSON: tdp= new(g) JSONDEF; break;
#if defined(ZIP_SUPPORT) #if defined(ZIP_SUPPORT)
case TAB_ZIP: tdp = new(g) ZIPDEF; break; case TAB_ZIP: tdp = new(g) ZIPDEF; break;
#endif // ZIP_SUPPORT #endif // ZIP_SUPPORT
#if defined(REST_SUPPORT)
case TAB_REST: tdp= new (g) RESTDEF; break;
#endif // REST_SUPPORT
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
case TAB_MONGO: case TAB_MONGO:
if (MongoEnabled()) { if (MongoEnabled()) {
tdp = new(g) MGODEF; tdp = new(g) MGODEF;
break; break;
} // endif enabled } // endif enabled
// fall through // fall through
#endif // JAVA_SUPPORT || CMGO_SUPPORT #endif // JAVA_SUPPORT || CMGO_SUPPORT
default: default:
sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name); sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
} // endswitch } // endswitch
// Do make the table/view definition // Do make the table/view definition
if (tdp && tdp->Define(g, this, name, schema, am)) if (tdp && tdp->Define(g, this, name, schema, am))
tdp= NULL; tdp= NULL;
if (trace(1))
htrc("Table %s made\n", am);
return tdp; return tdp;
} // end of MakeTableDesc } // end of MakeTableDesc
@@ -575,26 +596,29 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
PTDB tdbp= NULL; PTDB tdbp= NULL;
// LPCSTR name= tablep->GetName(); // LPCSTR name= tablep->GetName();
if (trace(1)) if (trace(1))
printf("GetTableDB: name=%s\n", tablep->GetName()); htrc("GetTableDB: name=%s\n", tablep->GetName());
// Look for the description of the requested table // Look for the description of the requested table
tdp= GetTableDesc(g, tablep, type); tdp= GetTableDesc(g, tablep, type);
if (tdp) { if (tdp) {
if (trace(1)) if (trace(1))
printf("tdb=%p type=%s\n", tdp, tdp->GetType()); htrc("tdb=%p type=%s\n", tdp, tdp->GetType());
if (tablep->GetSchema()) if (tablep->GetSchema())
tdp->Database = SetPath(g, tablep->GetSchema()); tdp->Database = SetPath(g, tablep->GetSchema());
if (trace(2))
htrc("Going to get table...\n");
tdbp= tdp->GetTable(g, mode); tdbp= tdp->GetTable(g, mode);
} // endif tdp } // endif tdp
if (tdbp) { if (tdbp) {
if (trace(1)) if (trace(1))
printf("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(), htrc("tdbp=%p name=%s amtype=%d\n", tdbp, tdbp->GetName(),
tdbp->GetAmType()); tdbp->GetAmType());
tablep->SetTo_Tdb(tdbp); tablep->SetTo_Tdb(tdbp);
tdbp->SetTable(tablep); tdbp->SetTable(tablep);
tdbp->SetMode(mode); tdbp->SetMode(mode);

View File

@@ -14,7 +14,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/**************** MYCAT H Declares Source Code File (.H) ***************/ /**************** MYCAT H Declares Source Code File (.H) ***************/
/* Name: MYCAT.H Version 2.3 */ /* Name: MYCAT.H Version 2.4 */
/* Author: Olivier Bertrand */ /* Author: Olivier Bertrand */
/* This file contains the CONNECT plugin MYCAT class definitions. */ /* This file contains the CONNECT plugin MYCAT class definitions. */
/***********************************************************************/ /***********************************************************************/
@@ -50,6 +50,8 @@ struct ha_table_option_struct {
const char *filter; const char *filter;
const char *oplist; const char *oplist;
const char *data_charset; const char *data_charset;
const char *http;
const char *uri;
ulonglong lrecl; ulonglong lrecl;
ulonglong elements; ulonglong elements;
//ulonglong estimate; //ulonglong estimate;

View File

@@ -1,4 +1,4 @@
SET GLOBAL connect_class_path='C:/MariaDB-10.0/MariaDB/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar;C:/Jconnectors/postgresql-42.2.1.jar'; SET GLOBAL connect_class_path='C:/MariaDB-10.2/MariaDB/storage/connect/mysql-test/connect/std_data/JavaWrappers.jar;C:/Jconnectors/postgresql-42.2.1.jar';
CREATE TABLE t2 ( CREATE TABLE t2 (
command varchar(128) not null, command varchar(128) not null,
number int(5) not null flag=1, number int(5) not null flag=1,

View File

@@ -51,14 +51,14 @@ WEB XQuery Kick Start en Per Bothner 2003 49.99
WEB XQuery Kick Start en Kurt Cagle 2003 49.99 WEB XQuery Kick Start en Kurt Cagle 2003 49.99
WEB Learning XML en Erik T. Ray 2003 39.95 WEB Learning XML en Erik T. Ray 2003 39.95
Warnings: Warnings:
Warning 1105 Mutiple values limited to 3 Warning 1105 Multiple values limited to 3
# One line lost because the where clause is applied only on the first 3 rows # One line lost because the where clause is applied only on the first 3 rows
SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%';
category title author price category title author price
CHILDREN Harry Potter J K. Rowling 29.99 CHILDREN Harry Potter J K. Rowling 29.99
WEB XQuery Kick Start James McGovern 49.99 WEB XQuery Kick Start James McGovern 49.99
Warnings: Warnings:
Warning 1105 Mutiple values limited to 3 Warning 1105 Multiple values limited to 3
# #
# Testing concatenated values # Testing concatenated values
# #
@@ -91,12 +91,12 @@ CHILDREN Harry Potter en J K. Rowling 2005 29.99
WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99 WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99
WEB Learning XML en Erik T. Ray 2003 39.95 WEB Learning XML en Erik T. Ray 2003 39.95
Warnings: Warnings:
Warning 1105 Mutiple values limited to 4 Warning 1105 Multiple values limited to 4
# The where clause is applied on the concatenated column result # The where clause is applied on the concatenated column result
SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%';
category title author price category title author price
CHILDREN Harry Potter J K. Rowling 29.99 CHILDREN Harry Potter J K. Rowling 29.99
WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99 WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99
Warnings: Warnings:
Warning 1105 Mutiple values limited to 4 Warning 1105 Multiple values limited to 4
DROP TABLE bookstore; DROP TABLE bookstore;

View File

@@ -49,14 +49,14 @@ WEB XQuery Kick Start en Per Bothner 2003 49.99
WEB XQuery Kick Start en Kurt Cagle 2003 49.99 WEB XQuery Kick Start en Kurt Cagle 2003 49.99
WEB Learning XML en Erik T. Ray 2003 39.95 WEB Learning XML en Erik T. Ray 2003 39.95
Warnings: Warnings:
Warning 1105 Mutiple values limited to 3 Warning 1105 Multiple values limited to 3
# One line lost because the where clause is applied only on the first 3 rows # One line lost because the where clause is applied only on the first 3 rows
SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%';
category title author price category title author price
CHILDREN Harry Potter J K. Rowling 29.99 CHILDREN Harry Potter J K. Rowling 29.99
WEB XQuery Kick Start James McGovern 49.99 WEB XQuery Kick Start James McGovern 49.99
Warnings: Warnings:
Warning 1105 Mutiple values limited to 3 Warning 1105 Multiple values limited to 3
# #
# Testing concatenated values # Testing concatenated values
# #
@@ -89,12 +89,12 @@ CHILDREN Harry Potter en J K. Rowling 2005 29.99
WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99 WEB XQuery Kick Start en James McGovern, Per Bothner, Kurt Cagle, James Linn 2003 49.99
WEB Learning XML en Erik T. Ray 2003 39.95 WEB Learning XML en Erik T. Ray 2003 39.95
Warnings: Warnings:
Warning 1105 Mutiple values limited to 4 Warning 1105 Multiple values limited to 4
# The where clause is applied on the concatenated column result # The where clause is applied on the concatenated column result
SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%'; SELECT category, title, author, price FROM bookstore WHERE author LIKE 'J%';
category title author price category title author price
CHILDREN Harry Potter J K. Rowling 29.99 CHILDREN Harry Potter J K. Rowling 29.99
WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99 WEB XQuery Kick Start James McGovern, Per Bothner, Kurt Cagle, James Linn 49.99
Warnings: Warnings:
Warning 1105 Mutiple values limited to 4 Warning 1105 Multiple values limited to 4
DROP TABLE bookstore; DROP TABLE bookstore;

View File

@@ -3,7 +3,11 @@
#define __OSUTIL_H__ #define __OSUTIL_H__
#if defined(UNIX) || defined(UNIV_LINUX) #if defined(UNIX) || defined(UNIV_LINUX)
#if defined(MARIADB)
#include "my_global.h" #include "my_global.h"
#else
#include "mini-global.h"
#endif
#include <errno.h> #include <errno.h>
#include <stddef.h> #include <stddef.h>
#include "os.h" #include "os.h"

View File

@@ -1,7 +1,7 @@
/************** PlgDBSem H Declares Source Code File (.H) **************/ /************** PlgDBSem H Declares Source Code File (.H) **************/
/* Name: PLGDBSEM.H Version 3.7 */ /* Name: PLGDBSEM.H Version 3.8 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2019 */
/* */ /* */
/* This file contains the CONNECT storage engine definitions. */ /* This file contains the CONNECT storage engine definitions. */
/***********************************************************************/ /***********************************************************************/
@@ -82,6 +82,7 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
TAB_JDBC = 26, /* Table accessed via JDBC */ TAB_JDBC = 26, /* Table accessed via JDBC */
TAB_ZIP = 27, /* ZIP file info table */ TAB_ZIP = 27, /* ZIP file info table */
TAB_MONGO = 28, /* Table retrieved from MongoDB */ TAB_MONGO = 28, /* Table retrieved from MongoDB */
TAB_REST = 29, /* Table retrieved from Rest */
TAB_NIY = 30}; /* Table not implemented yet */ TAB_NIY = 30}; /* Table not implemented yet */
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
@@ -400,6 +401,7 @@ typedef class VCTDEF *PVCTDEF;
typedef class PIVOTDEF *PPIVOTDEF; typedef class PIVOTDEF *PPIVOTDEF;
typedef class DOMDEF *PDOMDEF; typedef class DOMDEF *PDOMDEF;
typedef class DIRDEF *PDIRDEF; typedef class DIRDEF *PDIRDEF;
typedef class RESTDEF *PRESTDEF;
typedef class OEMDEF *POEMDEF; typedef class OEMDEF *POEMDEF;
typedef class COLCRT *PCOLCRT; typedef class COLCRT *PCOLCRT;
typedef class COLDEF *PCOLDEF; typedef class COLDEF *PCOLDEF;

View File

@@ -2,11 +2,11 @@
/* */ /* */
/* PROGRAM NAME: PLUGUTIL */ /* PROGRAM NAME: PLUGUTIL */
/* ------------- */ /* ------------- */
/* Version 3.0 */ /* Version 3.1 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1993-2017 */ /* (C) Copyright to the author Olivier BERTRAND 1993-2019 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@@ -110,22 +110,32 @@ ACTIVITY defActivity = { /* Describes activity and language */
#include "rcmsg.h" #include "rcmsg.h"
#endif // UNIX #endif // UNIX
/**************************************************************************/
/* Conditional tracing output function. */
/**************************************************************************/
void xtrc(uint x, char const *fmt, ...)
{
if (GetTraceValue() & x) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
} // endif x
} // end of xtrc
/**************************************************************************/ /**************************************************************************/
/* Tracing output function. */ /* Tracing output function. */
/**************************************************************************/ /**************************************************************************/
void htrc(char const *fmt, ...) void htrc(char const* fmt, ...)
{ {
va_list ap; va_list ap;
va_start (ap, fmt); va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
//if (trace == 1) va_end(ap);
// vfprintf(debug, fmt, ap); } // end of htrc
//else
vfprintf(stderr, fmt, ap);
va_end (ap);
} // end of htrc
/***********************************************************************/ /***********************************************************************/
/* Plug initialization routine. */ /* Plug initialization routine. */

View File

@@ -81,51 +81,51 @@ RELDEF::RELDEF(void)
/* This function return a pointer to the Table Option Struct. */ /* This function return a pointer to the Table Option Struct. */
/***********************************************************************/ /***********************************************************************/
PTOS RELDEF::GetTopt(void) PTOS RELDEF::GetTopt(void)
{ {
return Hc->GetTableOptionStruct(); return Hc->GetTableOptionStruct();
} // end of GetTopt } // end of GetTopt
/***********************************************************************/ /***********************************************************************/
/* This function sets an integer table information. */ /* This function sets an integer table information. */
/***********************************************************************/ /***********************************************************************/
bool RELDEF::SetIntCatInfo(PCSZ what, int n) bool RELDEF::SetIntCatInfo(PCSZ what, int n)
{ {
return Hc->SetIntegerOption(what, n); return Hc->SetIntegerOption(what, n);
} // end of SetIntCatInfo } // end of SetIntCatInfo
/***********************************************************************/ /***********************************************************************/
/* This function returns integer table information. */ /* This function returns integer table information. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetIntCatInfo(PCSZ what, int idef) int RELDEF::GetIntCatInfo(PCSZ what, int idef)
{ {
int n= Hc->GetIntegerOption(what); int n= Hc->GetIntegerOption(what);
return (n == NO_IVAL) ? idef : n; return (n == NO_IVAL) ? idef : n;
} // end of GetIntCatInfo } // end of GetIntCatInfo
/***********************************************************************/ /***********************************************************************/
/* This function returns Boolean table information. */ /* This function returns Boolean table information. */
/***********************************************************************/ /***********************************************************************/
bool RELDEF::GetBoolCatInfo(PCSZ what, bool bdef) bool RELDEF::GetBoolCatInfo(PCSZ what, bool bdef)
{ {
bool b= Hc->GetBooleanOption(what, bdef); bool b= Hc->GetBooleanOption(what, bdef);
return b; return b;
} // end of GetBoolCatInfo } // end of GetBoolCatInfo
/***********************************************************************/ /***********************************************************************/
/* This function returns size catalog information. */ /* This function returns size catalog information. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef) int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef)
{ {
char c; char c;
PCSZ s; PCSZ s;
int i, n= 0; int i, n= 0;
if (!(s= Hc->GetStringOption(what))) if (!(s= Hc->GetStringOption(what)))
s= sdef; s= sdef;
if ((i= sscanf(s, " %d %c ", &n, &c)) == 2) if ((i= sscanf(s, " %d %c ", &n, &c)) == 2)
switch (toupper(c)) { switch (toupper(c)) {
case 'M': case 'M':
n *= 1024; n *= 1024;
@@ -141,41 +141,41 @@ int RELDEF::GetSizeCatInfo(PCSZ what, PCSZ sdef)
/* This function sets char table information in buf. */ /* This function sets char table information in buf. */
/***********************************************************************/ /***********************************************************************/
int RELDEF::GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size) int RELDEF::GetCharCatInfo(PCSZ what, PCSZ sdef, char *buf, int size)
{ {
PCSZ s= Hc->GetStringOption(what); PCSZ s= Hc->GetStringOption(what);
strncpy(buf, ((s) ? s : sdef), size); strncpy(buf, ((s) ? s : sdef), size);
return size; return size;
} // end of GetCharCatInfo } // end of GetCharCatInfo
/***********************************************************************/ /***********************************************************************/
/* To be used by any TDB's. */ /* To be used by any TDB's. */
/***********************************************************************/ /***********************************************************************/
bool RELDEF::Partitioned(void) bool RELDEF::Partitioned(void)
{ {
return Hc->IsPartitioned(); return Hc->IsPartitioned();
} // end of Partitioned } // end of Partitioned
/***********************************************************************/ /***********************************************************************/
/* This function returns string table information. */ /* This function returns string table information. */
/* Default parameter is "*" to get the handler default. */ /* Default parameter is "*" to get the handler default. */
/***********************************************************************/ /***********************************************************************/
char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef) char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef)
{ {
char *sval = NULL; char *sval = NULL;
PCSZ name, s= Hc->GetStringOption(what, sdef); PCSZ name, s= Hc->GetStringOption(what, sdef);
if (s) { if (s) {
if (!Hc->IsPartitioned() || if (!Hc->IsPartitioned() ||
(stricmp(what, "filename") && stricmp(what, "tabname") (stricmp(what, "filename") && stricmp(what, "tabname")
&& stricmp(what, "connect"))) && stricmp(what, "connect")))
sval= PlugDup(g, s); sval= PlugDup(g, s);
else else
sval= (char*)s; sval= (char*)s;
} else if (!stricmp(what, "filename")) { } else if (!stricmp(what, "filename")) {
// Return default file name // Return default file name
PCSZ ftype= Hc->GetStringOption("Type", "*"); PCSZ ftype= Hc->GetStringOption("Type", "*");
int i, n; int i, n;
if (IsFileType(GetTypeID(ftype))) { if (IsFileType(GetTypeID(ftype))) {
@@ -196,8 +196,8 @@ char *RELDEF::GetStringCatInfo(PGLOBAL g, PCSZ what, PCSZ sdef)
} // endif s } // endif s
return sval; return sval;
} // end of GetStringCatInfo } // end of GetStringCatInfo
/* --------------------------- Class TABDEF -------------------------- */ /* --------------------------- Class TABDEF -------------------------- */
@@ -224,13 +224,13 @@ TABDEF::TABDEF(void)
/* Define: initialize the table definition block from XDB file. */ /* Define: initialize the table definition block from XDB file. */
/***********************************************************************/ /***********************************************************************/
bool TABDEF::Define(PGLOBAL g, PCATLG cat, bool TABDEF::Define(PGLOBAL g, PCATLG cat,
LPCSTR name, LPCSTR schema, LPCSTR am) LPCSTR name, LPCSTR schema, LPCSTR am)
{ {
int poff = 0; int poff = 0;
Hc = ((MYCAT*)cat)->GetHandler(); Hc = ((MYCAT*)cat)->GetHandler();
Name = (PSZ)name; Name = (PSZ)name;
Schema = (PSZ)Hc->GetDBName(schema); Schema = (PSZ)Hc->GetDBName(schema);
Cat = cat; Cat = cat;
Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL)); Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
Elemt = GetIntCatInfo("Elements", 0); Elemt = GetIntCatInfo("Elements", 0);
@@ -263,14 +263,14 @@ PCSZ TABDEF::GetPath(void)
/* This function returns column table information. */ /* This function returns column table information. */
/***********************************************************************/ /***********************************************************************/
int TABDEF::GetColCatInfo(PGLOBAL g) int TABDEF::GetColCatInfo(PGLOBAL g)
{ {
char *type= GetStringCatInfo(g, "Type", "*"); char *type= GetStringCatInfo(g, "Type", "*");
char c, fty, eds; char c, fty, eds;
int i, n, loff, poff, nof, nlg; int i, n, loff, poff, nof, nlg;
void *field= NULL; void *field= NULL;
TABTYPE tc; TABTYPE tc;
PCOLDEF cdp, lcdp= NULL, tocols= NULL; PCOLDEF cdp, lcdp= NULL, tocols= NULL;
PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO)); PCOLINFO pcf= (PCOLINFO)PlugSubAlloc(g, NULL, sizeof(COLINFO));
memset(pcf, 0, sizeof(COLINFO)); memset(pcf, 0, sizeof(COLINFO));
@@ -278,33 +278,33 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
tc= (Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX; tc= (Catfunc == FNC_NO) ? GetTypeID(type) : TAB_PRX;
// Take care of the column definitions // Take care of the column definitions
i= poff= nof= nlg= 0; i= poff= nof= nlg= 0;
#if defined(__WIN__) #if defined(__WIN__)
// Offsets of HTML and DIR tables start from 0, DBF at 1 // Offsets of HTML and DIR tables start from 0, DBF at 1
loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0; loff= (tc == TAB_DBF) ? 1 : (tc == TAB_XML || tc == TAB_DIR) ? -1 : 0;
#else // !__WIN__ #else // !__WIN__
// Offsets of HTML tables start from 0, DIR and DBF at 1 // Offsets of HTML tables start from 0, DIR and DBF at 1
loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0; loff = (tc == TAB_DBF || tc == TAB_DIR) ? 1 : (tc == TAB_XML) ? -1 : 0;
#endif // !__WIN__ #endif // !__WIN__
while (true) { while (true) {
// Default Offset depends on table type // Default Offset depends on table type
switch (tc) { switch (tc) {
case TAB_DOS: case TAB_DOS:
case TAB_FIX: case TAB_FIX:
case TAB_BIN: case TAB_BIN:
case TAB_VEC: case TAB_VEC:
case TAB_DBF: case TAB_DBF:
poff= loff + nof; // Default next offset poff= loff + nof; // Default next offset
nlg= MY_MAX(nlg, poff); // Default lrecl nlg= MY_MAX(nlg, poff); // Default lrecl
break; break;
case TAB_CSV: case TAB_CSV:
case TAB_FMT: case TAB_FMT:
nlg+= nof; nlg+= nof;
case TAB_DIR: case TAB_DIR:
case TAB_XML: case TAB_XML:
poff= loff + (pcf->Flags & U_VIRTUAL ? 0 : 1); poff= loff + (pcf->Flags & U_VIRTUAL ? 0 : 1);
break; break;
case TAB_INI: case TAB_INI:
case TAB_MAC: case TAB_MAC:
@@ -316,39 +316,39 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
poff = 0; // Offset represents an independant flag poff = 0; // Offset represents an independant flag
break; break;
default: // VCT PLG ODBC JDBC MYSQL WMI... default: // VCT PLG ODBC JDBC MYSQL WMI...
poff = 0; // NA poff = 0; // NA
break; break;
} // endswitch tc } // endswitch tc
// do { // do {
field= Hc->GetColumnOption(g, field, pcf); field= Hc->GetColumnOption(g, field, pcf);
// } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/)); // } while (field && (*pcf->Name =='*' /*|| pcf->Flags & U_VIRTUAL*/));
if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) { if (tc == TAB_DBF && pcf->Type == TYPE_DATE && !pcf->Datefmt) {
// DBF date format defaults to 'YYYMMDD' // DBF date format defaults to 'YYYMMDD'
pcf->Datefmt= "YYYYMMDD"; pcf->Datefmt= "YYYYMMDD";
pcf->Length= 8; pcf->Length= 8;
} // endif tc } // endif tc
if (!field) if (!field)
break; break;
// Allocate the column description block // Allocate the column description block
cdp= new(g) COLDEF; cdp= new(g) COLDEF;
if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0) if ((nof= cdp->Define(g, NULL, pcf, poff)) < 0)
return -1; // Error, probably unhandled type return -1; // Error, probably unhandled type
else else
loff= cdp->GetOffset(); loff= cdp->GetOffset();
switch (tc) { switch (tc) {
case TAB_VEC: case TAB_VEC:
cdp->SetOffset(0); // Not to have shift cdp->SetOffset(0); // Not to have shift
case TAB_BIN: case TAB_BIN:
// BIN/VEC are packed by default // BIN/VEC are packed by default
if (nof) { if (nof) {
// Field width is the internal representation width // Field width is the internal representation width
// that can also depend on the column format // that can also depend on the column format
fty = cdp->Decode ? 'C' : 'X'; fty = cdp->Decode ? 'C' : 'X';
eds = 0; eds = 0;
n = 0; n = 0;
@@ -371,38 +371,38 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
if (n) if (n)
nof = n; nof = n;
else switch (fty) { else switch (fty) {
case 'X': case 'X':
if (eds && IsTypeChar(cdp->Buf_Type)) if (eds && IsTypeChar(cdp->Buf_Type))
nof = sizeof(longlong); nof = sizeof(longlong);
else else
nof= cdp->Clen; nof= cdp->Clen;
break; break;
case 'C': break; case 'C': break;
case 'R': case 'R':
case 'F': nof = sizeof(float); break; case 'F': nof = sizeof(float); break;
case 'I': nof = sizeof(int); break; case 'I': nof = sizeof(int); break;
case 'D': nof = sizeof(double); break; case 'D': nof = sizeof(double); break;
case 'S': nof = sizeof(short); break; case 'S': nof = sizeof(short); break;
case 'T': nof = sizeof(char); break; case 'T': nof = sizeof(char); break;
case 'G': nof = sizeof(longlong); break; case 'G': nof = sizeof(longlong); break;
default: /* Wrong format */ default: /* Wrong format */
sprintf(g->Message, "Invalid format %c", fty); sprintf(g->Message, "Invalid format %c", fty);
return -1; return -1;
} // endswitch fty } // endswitch fty
} // endif nof } // endif nof
default: default:
break; break;
} // endswitch tc } // endswitch tc
if (lcdp) if (lcdp)
lcdp->SetNext(cdp); lcdp->SetNext(cdp);
else else
tocols= cdp; tocols= cdp;
lcdp= cdp; lcdp= cdp;
i++; i++;
} // endwhile } // endwhile
@@ -410,19 +410,19 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
if (i != GetDegree()) if (i != GetDegree())
SetDegree(i); SetDegree(i);
if (GetDefType() == TYPE_AM_DOS) { if (GetDefType() == TYPE_AM_DOS) {
int ending, recln= 0; int ending, recln= 0;
// Was commented because sometimes ending is 0 even when // Was commented because sometimes ending is 0 even when
// not specified (for instance if quoted is specified) // not specified (for instance if quoted is specified)
// if ((ending= Hc->GetIntegerOption("Ending")) < 0) { // if ((ending= Hc->GetIntegerOption("Ending")) < 0) {
if ((ending= Hc->GetIntegerOption("Ending")) <= 0) { if ((ending= Hc->GetIntegerOption("Ending")) <= 0) {
ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF; ending= (tc == TAB_BIN || tc == TAB_VEC) ? 0 : CRLF;
Hc->SetIntegerOption("Ending", ending); Hc->SetIntegerOption("Ending", ending);
} // endif ending } // endif ending
// Calculate the default record size // Calculate the default record size
switch (tc) { switch (tc) {
case TAB_FIX: case TAB_FIX:
case TAB_BIN: case TAB_BIN:
recln= nlg + ending; // + length of line ending recln= nlg + ending; // + length of line ending
@@ -443,26 +443,30 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
case TAB_CSV: case TAB_CSV:
case TAB_FMT: case TAB_FMT:
// The number of separators (assuming an extra one can exist) // The number of separators (assuming an extra one can exist)
// recln= poff * ((qotd) ? 3 : 1); to be investigated // recln= poff * ((qotd) ? 3 : 1); to be investigated
recln= nlg + poff * 3; // To be safe recln= nlg + poff * 3; // To be safe
default: default:
break; break;
} // endswitch tc } // endswitch tc
// lrecl must be at least recln to avoid buffer overflow // lrecl must be at least recln to avoid buffer overflow
if (trace(1)) if (trace(1))
htrc("Lrecl: Calculated=%d defined=%d\n", htrc("Lrecl: Calculated=%d defined=%d\n",
recln, Hc->GetIntegerOption("Lrecl")); recln, Hc->GetIntegerOption("Lrecl"));
recln = MY_MAX(recln, Hc->GetIntegerOption("Lrecl")); recln = MY_MAX(recln, Hc->GetIntegerOption("Lrecl"));
Hc->SetIntegerOption("Lrecl", recln); Hc->SetIntegerOption("Lrecl", recln);
((PDOSDEF)this)->SetLrecl(recln); ((PDOSDEF)this)->SetLrecl(recln);
} // endif Lrecl
// Attach the column definition to the tabdef if (trace(1))
SetCols(tocols); htrc("Lrecl set to %d\n", recln);
return poff;
} // end of GetColCatInfo } // endif Lrecl
// Attach the column definition to the tabdef
SetCols(tocols);
return poff;
} // end of GetColCatInfo
/***********************************************************************/ /***********************************************************************/
/* SetIndexInfo: retrieve index description from the table structure. */ /* SetIndexInfo: retrieve index description from the table structure. */
@@ -487,15 +491,16 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
PCATLG cat = Cat; PCATLG cat = Cat;
/*********************************************************************/ /*********************************************************************/
/* Ensure that the .dll doesn't have a path. */ /* Ensure that the module name doesn't have a path. */
/* This is done to ensure that only approved dll from the system */ /* This is done to ensure that only approved libs from the system */
/* directories are used (to make this even remotely secure). */ /* directories are used (to make this even remotely secure). */
/*********************************************************************/ /*********************************************************************/
if (check_valid_path(Module, strlen(Module))) { if (check_valid_path(Module, strlen(Module))) {
strcpy(g->Message, "Module cannot contain a path"); strcpy(g->Message, "Module cannot contain a path");
return NULL; return NULL;
} else } else
PlugSetPath(soname, Module, GetPluginDir()); // PlugSetPath(soname, Module, GetPluginDir()); // Crashes on Fedora
strncat(strcpy(soname, GetPluginDir()), Module, _MAX_PATH);
#if defined(__WIN__) #if defined(__WIN__)
// Is the DLL already loaded? // Is the DLL already loaded?
@@ -522,24 +527,24 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
// Get the function returning an instance of the external DEF class // Get the function returning an instance of the external DEF class
if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) {
char buf[256]; char buf[256];
DWORD rc = GetLastError(); DWORD rc = GetLastError();
sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname); sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0,
(LPTSTR)buf, sizeof(buf), NULL); (LPTSTR)buf, sizeof(buf), NULL);
strcat(strcat(g->Message, ": "), buf); strcat(strcat(g->Message, ": "), buf);
FreeLibrary((HMODULE)Hdll); FreeLibrary((HMODULE)Hdll);
return NULL; return NULL;
} // endif getdef } // endif getdef
#else // !__WIN__ #else // !__WIN__
const char *error = NULL; const char *error = NULL;
#if 0 // Don't know what all this stuff does #if 0 // Don't know what all this stuff does
Dl_info dl_info; Dl_info dl_info;
// The OEM lib must retrieve exported CONNECT variables // The OEM lib must retrieve exported CONNECT variables
if (dladdr(&connect_hton, &dl_info)) { if (dladdr(&connect_hton, &dl_info)) {
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
error = dlerror(); error = dlerror();
@@ -626,7 +631,7 @@ bool OEMDEF::DefineAM(PGLOBAL g, LPCSTR, int)
char *desc = (char*)PlugSubAlloc(g, NULL, strlen(Module) char *desc = (char*)PlugSubAlloc(g, NULL, strlen(Module)
+ strlen(Subtype) + 3); + strlen(Subtype) + 3);
sprintf(desc, "%s(%s)", Module, Subtype); sprintf(desc, "%s(%s)", Module, Subtype);
Desc = desc; Desc = desc;
return false; return false;
} // end of DefineAM } // end of DefineAM
@@ -701,17 +706,17 @@ PTDB OEMDEF::GetTable(PGLOBAL g, MODE mode)
txfp = new(g) FIXFAM(defp); txfp = new(g) FIXFAM(defp);
} else if (rfm == RECFM_VCT) { } else if (rfm == RECFM_VCT) {
#if defined(VCT_SUPPORT) #if defined(VCT_SUPPORT)
assert(Pxdef->GetDefType() == TYPE_AM_VCT); assert(Pxdef->GetDefType() == TYPE_AM_VCT);
if (map) if (map)
txfp = new(g) VCMFAM((PVCTDEF)defp); txfp = new(g) VCMFAM((PVCTDEF)defp);
else else
txfp = new(g) VCTFAM((PVCTDEF)defp); txfp = new(g) VCTFAM((PVCTDEF)defp);
#else // !VCT_SUPPORT #else // !VCT_SUPPORT
strcpy(g->Message, "VCT no more supported"); strcpy(g->Message, "VCT no more supported");
return NULL; return NULL;
#endif // !VCT_SUPPORT #endif // !VCT_SUPPORT
} // endif's } // endif's
((PTDBDOS)tdbp)->SetTxfp(txfp); ((PTDBDOS)tdbp)->SetTxfp(txfp);
} // endif Txfp } // endif Txfp

4
storage/connect/rest.def Normal file
View File

@@ -0,0 +1,4 @@
LIBRARY REST2
EXPORTS
GetREST @1
ColREST @2

33
storage/connect/rest.h Normal file
View File

@@ -0,0 +1,33 @@
/***********************************************************************/
/* Definitions needed by the included files. */
/***********************************************************************/
#if !defined(MY_GLOBAL_H)
#define MY_GLOBAL_H
typedef unsigned int uint;
typedef unsigned int uint32;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned long DWORD;
typedef char *LPSTR;
typedef const char *LPCSTR;
typedef int BOOL;
#if defined(_WINDOWS)
typedef void *HANDLE;
#else
typedef int HANDLE;
#endif
typedef char *PSZ;
typedef const char *PCSZ;
typedef unsigned char BYTE;
typedef unsigned char uchar;
typedef long long longlong;
typedef unsigned long long ulonglong;
typedef char my_bool;
struct charset_info_st {};
typedef const charset_info_st CHARSET_INFO;
#define FALSE 0
#define TRUE 1
#define Item char
#define MY_MAX(a,b) ((a>b)?(a):(b))
#define MY_MIN(a,b) ((a<b)?(a):(b))
#endif // MY_GLOBAL_H

View File

@@ -0,0 +1,94 @@
/************* Restget C++ Program Source Code File (.CPP) *************/
/* Adapted from the sample program of the Casablanca tutorial. */
/* Copyright Olivier Bertrand 2019. */
/***********************************************************************/
#include <cpprest/filestream.h>
#include <cpprest/http_client.h>
#if defined(MARIADB)
#include <my_global.h>
#else
#include "mini-global.h"
#define _OS_H_INCLUDED // Prevent os.h to be called
#endif
using namespace utility::conversions; // String conversions utilities
using namespace web; // Common features like URIs.
using namespace web::http; // Common HTTP functionality
using namespace web::http::client; // HTTP client features
using namespace concurrency::streams; // Asynchronous streams
#include "global.h"
/***********************************************************************/
/* Make a local copy of the requested file. */
/***********************************************************************/
int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn)
{
int rc = 0;
bool xt = trace(515);
auto fileStream = std::make_shared<ostream>();
if (!http || !fn) {
strcpy(g->Message, "Missing http or filename");
return 2;
} // endif
if (xt)
htrc("restGetFile: fn=%s\n", fn);
// Open stream to output file.
pplx::task<void> requestTask = fstream::open_ostream(to_string_t(fn))
.then([=](ostream outFile) {
*fileStream= outFile;
if (xt)
htrc("Outfile isopen=%d\n", outFile.is_open());
// Create http_client to send the request.
http_client client(to_string_t(http));
if (uri) {
// Build request URI and start the request.
uri_builder builder(to_string_t(uri));
return client.request(methods::GET, builder.to_string());
} else
return client.request(methods::GET);
})
// Handle response headers arriving.
.then([=](http_response response) {
if (xt)
htrc("Received response status code:%u\n",
response.status_code());
// Write response body into the file.
return response.body().read_to_end(fileStream->streambuf());
})
// Close the file stream.
.then([=](size_t n) {
if (xt)
htrc("Return size=%u\n", n);
return fileStream->close();
});
// Wait for all the outstanding I/O to complete and handle any exceptions
try {
requestTask.wait();
if (xt)
htrc("In Wait\n");
} catch (const std::exception &e) {
if (xt)
htrc("Error exception: %s\n", e.what());
sprintf(g->Message, "Error exception: %s", e.what());
rc= 1;
} // end try/catch
if (xt)
htrc("restget done: rc=%d\n", rc);
return rc;
} // end of restGetFile

View File

@@ -193,7 +193,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
if (tdp->Zipped) if (tdp->Zipped)
tcvp = new(g)TDBCSV(tdp, new(g)UNZFAM(tdp)); tcvp = new(g)TDBCSV(tdp, new(g)UNZFAM(tdp));
else else
#endif #endif // ZIP_SUPPORT
tcvp = new(g) TDBCSV(tdp, new(g) DOSFAM(tdp)); tcvp = new(g) TDBCSV(tdp, new(g) DOSFAM(tdp));
tcvp->SetMode(MODE_READ); tcvp->SetMode(MODE_READ);

View File

@@ -641,7 +641,9 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
Cnp->InitValue(g); Cnp->InitValue(g);
if ((n = Jcp->GetResultSize(Query->GetStr(), Cnp)) < 0) { if ((n = Jcp->GetResultSize(Query->GetStr(), Cnp)) < 0) {
sprintf(g->Message, "Cannot get result size rc=%d", n); char* msg = PlugDup(g, g->Message);
sprintf(g->Message, "Get result size: %s (rc=%d)", msg, n);
return true; return true;
} else if (n) { } else if (n) {
Jcp->m_Rows = n; Jcp->m_Rows = n;

File diff suppressed because it is too large Load Diff

201
storage/connect/tabrest.cpp Normal file
View File

@@ -0,0 +1,201 @@
/*************** Rest C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: Rest Version 1.5 */
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2019 */
/* This program is the REST Web API support for MariaDB. */
/* When compiled without MARIADB defined, it is the EOM module code. */
/***********************************************************************/
/***********************************************************************/
/* Definitions needed by the included files. */
/***********************************************************************/
#if defined(MARIADB)
#include <my_global.h> // All MariaDB stuff
#else // !MARIADB OEM module
#include "mini-global.h"
#define _MAX_PATH 260
#if !defined(__WIN__)
#define __stdcall
#endif // !__WIN__
#define _OS_H_INCLUDED // Prevent os.h to be called
#endif // !MARIADB
/***********************************************************************/
/* Include application header files: */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing the DB application declarations. */
/* (x)table.h is header containing the TDBASE declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
#include "xtable.h"
#include "filamtxt.h"
#include "tabdos.h"
#include "plgxml.h"
#include "tabxml.h"
#include "tabjson.h"
#include "tabfmt.h"
#include "tabrest.h"
/***********************************************************************/
/* Get the file from the Web. */
/***********************************************************************/
int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn);
#if defined(__WIN__)
static PCSZ slash = "\\";
#else // !__WIN__
static PCSZ slash = "/";
#define stricmp strcasecmp
#endif // !__WIN__
#if !defined(MARIADB)
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
int TDB::Tnum;
int DTVAL::Shift;
int CSORT::Limit = 0;
double CSORT::Lg2 = log(2.0);
size_t CSORT::Cpn[1000] = { 0 };
/***********************************************************************/
/* These functions are exported from the REST library. */
/***********************************************************************/
extern "C" {
PTABDEF __stdcall GetREST(PGLOBAL, void*);
PQRYRES __stdcall ColREST(PGLOBAL, PTOS, char*, char*, bool);
} // extern "C"
/***********************************************************************/
/* This function returns a table definition class. */
/***********************************************************************/
PTABDEF __stdcall GetREST(PGLOBAL g, void *memp)
{
return new(g, memp) RESTDEF;
} // end of GetREST
#endif // !MARIADB
/***********************************************************************/
/* Return the columns definition to MariaDB. */
/***********************************************************************/
#if defined(MARIADB)
PQRYRES RESTColumns(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
#else // !MARIADB
PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
#endif // !MARIADB
{
PQRYRES qrp= NULL;
char filename[_MAX_PATH + 1]; // MAX PATH ???
PCSZ http, uri, fn, ftype;
http = GetStringTableOption(g, tp, "Http", NULL);
uri = GetStringTableOption(g, tp, "Uri", NULL);
fn = GetStringTableOption(g, tp, "Filename", "rest.json");
#if defined(MARIADB)
ftype = GetStringTableOption(g, tp, "Type", "JSON");
#else // !MARIADB
// OEM tables must specify the file type
ftype = GetStringTableOption(g, tp, "Ftype", "JSON");
#endif // !MARIADB
// We used the file name relative to recorded datapath
strcat(strcat(strcat(strcpy(filename, "."), slash), db), slash);
strncat(filename, fn, _MAX_PATH);
// Retrieve the file from the web and copy it locally
if (http && restGetFile(g, http, uri, filename)) {
// sprintf(g->Message, "Failed to get file at %s", http);
} else if (!stricmp(ftype, "XML"))
qrp = XMLColumns(g, db, tab, tp, info);
else if (!stricmp(ftype, "JSON"))
qrp = JSONColumns(g, db, NULL, tp, info);
else if (!stricmp(ftype, "CSV"))
qrp = CSVColumns(g, NULL, tp, info);
else
sprintf(g->Message, "Usupported file type %s", ftype);
return qrp;
} // end of RESTColumns
/* -------------------------- Class RESTDEF -------------------------- */
/***********************************************************************/
/* DefineAM: define specific AM block values. */
/***********************************************************************/
bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
char filename[_MAX_PATH + 1];
int rc = 0, n;
LPCSTR ftype;
#if defined(MARIADB)
ftype = GetStringCatInfo(g, "Type", "JSON");
#else // !MARIADB
// OEM tables must specify the file type
ftype = GetStringCatInfo(g, "Ftype", "JSON");
#endif // !MARIADB
if (trace(515))
htrc("ftype = %s am = %s\n", ftype, SVP(am));
n = (!stricmp(ftype, "JSON")) ? 1
: (!stricmp(ftype, "XML")) ? 2
: (!stricmp(ftype, "CSV")) ? 3 : 0;
if (n == 0) {
htrc("DefineAM: Unsupported REST table type %s", am);
sprintf(g->Message, "Unsupported REST table type %s", am);
return true;
} // endif n
Http = GetStringCatInfo(g, "Http", NULL);
Uri = GetStringCatInfo(g, "Uri", NULL);
Fn = GetStringCatInfo(g, "Filename", "rest.json");
// We used the file name relative to recorded datapath
//PlugSetPath(filename, Fn, GetPath());
strncat(strcpy(filename, GetPath()), Fn, _MAX_PATH);
// Retrieve the file from the web and copy it locally
rc = restGetFile(g, Http, Uri, filename);
if (trace(515))
htrc("Return from restGetFile: rc=%d\n", rc);
if (rc)
return true;
else switch (n) {
case 1: Tdp = new (g) JSONDEF; break;
case 2: Tdp = new (g) XMLDEF; break;
case 3: Tdp = new (g) CSVDEF; break;
default: Tdp = NULL;
} // endswitch n
// Do make the table/view definition
if (Tdp && Tdp->Define(g, Cat, Name, Schema, "REST"))
Tdp = NULL; // Error occured
if (trace(515))
htrc("Tdp defined\n", rc);
// Return true in case of error
return (Tdp == NULL);
} // end of DefineAM
/***********************************************************************/
/* GetTable: makes a new Table Description Block. */
/***********************************************************************/
PTDB RESTDEF::GetTable(PGLOBAL g, MODE m)
{
if (trace(515))
htrc("REST GetTable mode=%d\n", m);
if (m != MODE_READ && m != MODE_READX) {
strcpy(g->Message, "REST tables are currently read only");
return NULL;
} // endif m
return Tdp->GetTable(g, m); // Leave file type do the job
} // end of GetTable
/* ---------------------- End of Class RESTDEF ----------------------- */

29
storage/connect/tabrest.h Normal file
View File

@@ -0,0 +1,29 @@
/*************** TabRest H Declares Source Code File (.H) **************/
/* Name: tabrest.h Version 1.0 */
/* (C) Copyright to the author Olivier BERTRAND 2019 */
/* This file contains the common tabrest classes declares. */
/***********************************************************************/
#pragma once
/***********************************************************************/
/* Restest table. */
/***********************************************************************/
class RESTDEF : public TABDEF { /* Table description */
public:
// Constructor
RESTDEF(void) { Tdp = NULL; Http = Uri = Fn = NULL; }
// Implementation
virtual const char *GetType(void) { return "REST"; }
// Methods
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
virtual PTDB GetTable(PGLOBAL g, MODE m);
protected:
// Members
PRELDEF Tdp;
PCSZ Http; /* Web connection HTTP */
PCSZ Uri; /* Web connection URI */
PCSZ Fn; /* The intermediate file name */
}; // end of class RESTDEF

View File

@@ -232,7 +232,7 @@ bool TDBTBL::InitTableList(PGLOBAL g)
{ {
int n; int n;
uint sln; uint sln;
char *scs; const char *scs;
PTABLE tp, tabp; PTABLE tp, tabp;
PCOL colp; PCOL colp;
PTBLDEF tdp = (PTBLDEF)To_Def; PTBLDEF tdp = (PTBLDEF)To_Def;
@@ -281,7 +281,7 @@ bool TDBTBL::InitTableList(PGLOBAL g)
} // endfor tp } // endfor tp
hc->get_table()->s->connect_string.str = scs; hc->get_table()->s->connect_string.str = (char*)scs;
hc->get_table()->s->connect_string.length = sln; hc->get_table()->s->connect_string.length = sln;
//NumTables = n; //NumTables = n;

View File

@@ -1880,7 +1880,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
if (N > Tdbp->Limit) { if (N > Tdbp->Limit) {
N = Tdbp->Limit; N = Tdbp->Limit;
sprintf(g->Message, "Mutiple values limited to %d", Tdbp->Limit); sprintf(g->Message, "Multiple values limited to %d", Tdbp->Limit);
PushWarning(g, Tdbp); PushWarning(g, Tdbp);
} // endif N } // endif N

View File

@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/** /**
@file user_connect.cc @file user_connect.cc

View File

@@ -11,7 +11,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/** @file user_connect.h /** @file user_connect.h

View File

@@ -1,4 +1,3 @@
# Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@@ -145,3 +144,6 @@ elseif(UNIX)
# On unix-like platforms the library is almost always called libz # On unix-like platforms the library is almost always called libz
set_target_properties(zlib PROPERTIES OUTPUT_NAME z) set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
endif() endif()
RESTRICT_SYMBOL_EXPORTS(zlib)