Skip to content

Commit dd30ba4

Browse files
committed
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. -- Add compile flags needed on Windows /MD or /MDd (debug) -- 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 -- Add conditional code based on the preprocessor definition MARIADB -- This to be able to use the same code in CONNECT and EOM modules modified: storage/connect/osutil.h modified: storage/connect/tabrest.cpp -- Add files for the REST OEM module added: storage/connect/mini-global.h added: storage/connect/rest.def -- 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 -- Fix compilation error when ZIP is not supported modified: storage/connect/ha_connect.cc modified: storage/connect/tabfmt.cpp -- Replace PlugSetPath by some concat (crashed on Fedora) + typo modified: storage/connect/reldef.cpp -- 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 -- Add some tracing + typo modified: storage/connect/mycat.cc modified: storage/connect/tabjson.cpp -- Add the xtrc tracing function modified: storage/connect/global.h modified: storage/connect/plugutil.cpp -- Modify tracing to use xtrc and some typo modified: storage/connect/array.cpp modified: storage/connect/block.h -- 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
1 parent 6b1e133 commit dd30ba4

30 files changed

+2086
-1610
lines changed

storage/connect/CMakeLists.txt

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# You should have received a copy of the GNU General Public License
1313
# along with this program; if not, write to the Free Software
14-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
1515

1616
SET(CONNECT_PLUGIN_STATIC "connect")
1717
SET(CONNECT_PLUGIN_DYNAMIC "connect")
@@ -68,7 +68,15 @@ ELSE(NOT UNIX)
6868
tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h)
6969
# Add exception handling to the CONNECT project)
7070
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
71+
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
72+
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
73+
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
74+
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MD")
7175
SET(IPHLPAPI_LIBRARY iphlpapi.lib)
76+
IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
77+
# Connect does not work with clang-cl
78+
RETURN()
79+
ENDIF()
7280
ENDIF(UNIX)
7381

7482

@@ -109,7 +117,6 @@ IF(CONNECT_WITH_LIBXML2)
109117
FIND_PACKAGE(LibXml2)
110118
IF (LIBXML2_FOUND)
111119
INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR})
112-
SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below
113120
SET(XML_LIBRARY ${LIBXML2_LIBRARIES})
114121
SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h)
115122
add_definitions(-DLIBXML2_SUPPORT)
@@ -301,6 +308,30 @@ IF(CONNECT_WITH_MONGO)
301308
ENDIF(CONNECT_WITH_MONGO)
302309

303310

311+
#
312+
# REST
313+
#
314+
315+
OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)
316+
317+
IF(CONNECT_WITH_REST)
318+
MESSAGE(STATUS "=====> REST support is ON")
319+
FIND_PACKAGE(cpprestsdk)
320+
IF (cpprestsdk_FOUND)
321+
MESSAGE(STATUS "=====> cpprestsdk found")
322+
IF(UNIX)
323+
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
324+
# If needed edit next line to set the path to libcpprest.so
325+
SET(REST_LIBRARY -lcpprest)
326+
MESSAGE (STATUS ${REST_LIBRARY})
327+
ENDIF(UNIX)
328+
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h)
329+
add_definitions(-DREST_SUPPORT)
330+
ELSE(NOT cpprestsdk_FOUND)
331+
MESSAGE(STATUS "=====> cpprestsdk package not found")
332+
ENDIF (cpprestsdk_FOUND)
333+
ENDIF(CONNECT_WITH_REST)
334+
304335
#
305336
# XMAP
306337
#
@@ -320,24 +351,16 @@ MYSQL_ADD_PLUGIN(connect ${CONNECT_SOURCES}
320351
COMPONENT connect-engine
321352
RECOMPILE_FOR_EMBEDDED
322353
LINK_LIBRARIES ${ZLIB_LIBRARY} ${XML_LIBRARY} ${ICONV_LIBRARY}
323-
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY})
354+
${ODBC_LIBRARY} ${JDBC_LIBRARY} ${MONGOC_LIBRARY} ${IPHLPAPI_LIBRARY} ${REST_LIBRARY})
324355

325356
IF(NOT TARGET connect)
326357
RETURN()
327358
ENDIF()
328359

329-
# Don't link with bundled zlib and systel libxml2 at the same time.
330-
# System libxml2 uses system zlib, might conflict with the bundled one.
331-
IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB)
332-
GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES)
333-
LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR})
334-
SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS})
335-
ENDIF()
336-
337360
IF(WIN32)
338361
IF (libmongoc-1.0_FOUND)
339-
SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS
340-
"/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll")
362+
SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS
363+
"/DELAYLOAD:libbson-1.0.dll /DELAYLOAD:libmongoc-1.0.dll")
341364
ENDIF(libmongoc-1.0_FOUND)
342365
ENDIF(WIN32)
343366

@@ -364,3 +387,4 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
364387
${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar
365388
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
366389
ENDIF()
390+

storage/connect/array.cpp

Lines changed: 52 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/************* Array C++ Functions Source Code File (.CPP) *************/
22
/* Name: ARRAY.CPP Version 2.3 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
4+
/* (C) Copyright to the author Olivier BERTRAND 2005-2019 */
55
/* */
66
/* This file contains the XOBJECT derived class ARRAY functions. */
77
/* ARRAY is used for elaborate type of processing, such as sorting */
@@ -67,7 +67,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp); // avoid gcc warning
6767
/* MakeValueArray: Makes a value array from a value list. */
6868
/***********************************************************************/
6969
PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
70-
{
70+
{
7171
int n, valtyp = 0;
7272
size_t len = 0;
7373
PARRAY par;
@@ -82,8 +82,7 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
8282
if ((valtyp = pp->Type) != TYPE_STRING)
8383
len = 1;
8484

85-
if (trace(1))
86-
htrc("valtyp=%d len=%d\n", valtyp, len);
85+
xtrc(1, "valtyp=%d len=%d\n", valtyp, len);
8786

8887
/*********************************************************************/
8988
/* Firstly check the list and count the number of values in it. */
@@ -127,13 +126,13 @@ PARRAY MakeValueArray(PGLOBAL g, PPARM pp)
127126
// Integer stored inside pp->Value
128127
par->AddValue(g, parmp->Intval);
129128
break;
130-
} // endswitch valtyp
129+
} // endswitch valtyp
131130

132131
/*********************************************************************/
133132
/* Send back resulting array. */
134133
/*********************************************************************/
135134
return par;
136-
} // end of MakeValueArray
135+
} // end of MakeValueArray
137136

138137
/* -------------------------- Class ARRAY ---------------------------- */
139138

@@ -151,6 +150,9 @@ ARRAY::ARRAY(PGLOBAL g, int type, int size, int length, int prec)
151150
Type = type;
152151
Xsize = -1;
153152
Len = 1;
153+
X = 0;
154+
Inf = 0;
155+
Sup = 0;
154156

155157
switch (type) {
156158
case TYPE_STRING:
@@ -281,130 +283,109 @@ void ARRAY::Empty(void)
281283
/* Add a string element to an array. */
282284
/***********************************************************************/
283285
bool ARRAY::AddValue(PGLOBAL g, PSZ strp)
284-
{
286+
{
285287
if (Type != TYPE_STRING) {
286288
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "CHAR");
287289
return true;
288-
} // endif Type
289-
290-
if (trace(1))
291-
htrc(" adding string(%d): '%s'\n", Nval, strp);
290+
} // endif Type
292291

293-
//Value->SetValue_psz(strp);
294-
//Vblp->SetValue(valp, Nval++);
292+
xtrc(1, " adding string(%d): '%s'\n", Nval, strp);
295293
Vblp->SetValue(strp, Nval++);
296294
return false;
297-
} // end of AddValue
295+
} // end of AddValue
298296

299297
/***********************************************************************/
300298
/* Add a char pointer element to an array. */
301299
/***********************************************************************/
302300
bool ARRAY::AddValue(PGLOBAL g, void *p)
303-
{
301+
{
304302
if (Type != TYPE_PCHAR) {
305303
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "PCHAR");
306304
return true;
307-
} // endif Type
308-
309-
if (trace(1))
310-
htrc(" adding pointer(%d): %p\n", Nval, p);
305+
} // endif Type
311306

307+
xtrc(1, " adding pointer(%d): %p\n", Nval, p);
312308
Vblp->SetValue((PSZ)p, Nval++);
313309
return false;
314-
} // end of AddValue
310+
} // end of AddValue
315311

316312
/***********************************************************************/
317313
/* Add a short integer element to an array. */
318314
/***********************************************************************/
319315
bool ARRAY::AddValue(PGLOBAL g, short n)
320-
{
316+
{
321317
if (Type != TYPE_SHORT) {
322318
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "SHORT");
323319
return true;
324-
} // endif Type
325-
326-
if (trace(1))
327-
htrc(" adding SHORT(%d): %hd\n", Nval, n);
320+
} // endif Type
328321

329-
//Value->SetValue(n);
330-
//Vblp->SetValue(valp, Nval++);
322+
xtrc(1, " adding SHORT(%d): %hd\n", Nval, n);
331323
Vblp->SetValue(n, Nval++);
332324
return false;
333-
} // end of AddValue
325+
} // end of AddValue
334326

335327
/***********************************************************************/
336328
/* Add an integer element to an array. */
337329
/***********************************************************************/
338330
bool ARRAY::AddValue(PGLOBAL g, int n)
339-
{
331+
{
340332
if (Type != TYPE_INT) {
341333
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "INTEGER");
342334
return true;
343-
} // endif Type
335+
} // endif Type
344336

345-
if (trace(1))
346-
htrc(" adding int(%d): %d\n", Nval, n);
347-
348-
//Value->SetValue(n);
349-
//Vblp->SetValue(valp, Nval++);
337+
xtrc(1, " adding int(%d): %d\n", Nval, n);
350338
Vblp->SetValue(n, Nval++);
351339
return false;
352-
} // end of AddValue
340+
} // end of AddValue
353341

354342
/***********************************************************************/
355343
/* Add a double float element to an array. */
356344
/***********************************************************************/
357345
bool ARRAY::AddValue(PGLOBAL g, double d)
358-
{
346+
{
359347
if (Type != TYPE_DOUBLE) {
360348
sprintf(g->Message, MSG(ADD_BAD_TYPE), GetTypeName(Type), "DOUBLE");
361349
return true;
362-
} // endif Type
363-
364-
if (trace(1))
365-
htrc(" adding float(%d): %lf\n", Nval, d);
350+
} // endif Type
366351

352+
xtrc(1, " adding float(%d): %lf\n", Nval, d);
367353
Value->SetValue(d);
368354
Vblp->SetValue(Value, Nval++);
369355
return false;
370-
} // end of AddValue
356+
} // end of AddValue
371357

372358
/***********************************************************************/
373359
/* Add the value of a XOBJECT block to an array. */
374360
/***********************************************************************/
375361
bool ARRAY::AddValue(PGLOBAL g, PXOB xp)
376-
{
377-
if (Type != xp->GetResultType()) {
378-
sprintf(g->Message, MSG(ADD_BAD_TYPE),
379-
GetTypeName(xp->GetResultType()), GetTypeName(Type));
380-
return true;
381-
} // endif Type
382-
383-
if (trace(1))
384-
htrc(" adding (%d) from xp=%p\n", Nval, xp);
362+
{
363+
if (Type != xp->GetResultType()) {
364+
sprintf(g->Message, MSG(ADD_BAD_TYPE),
365+
GetTypeName(xp->GetResultType()), GetTypeName(Type));
366+
return true;
367+
} // endif Type
385368

386-
//AddValue(xp->GetValue());
387-
Vblp->SetValue(xp->GetValue(), Nval++);
388-
return false;
389-
} // end of AddValue
369+
xtrc(1, " adding (%d) from xp=%p\n", Nval, xp);
370+
Vblp->SetValue(xp->GetValue(), Nval++);
371+
return false;
372+
} // end of AddValue
390373

391374
/***********************************************************************/
392375
/* Add a value to an array. */
393376
/***********************************************************************/
394377
bool ARRAY::AddValue(PGLOBAL g, PVAL vp)
395-
{
378+
{
396379
if (Type != vp->GetType()) {
397380
sprintf(g->Message, MSG(ADD_BAD_TYPE),
398381
GetTypeName(vp->GetType()), GetTypeName(Type));
399382
return true;
400-
} // endif Type
401-
402-
if (trace(1))
403-
htrc(" adding (%d) from vp=%p\n", Nval, vp);
383+
} // endif Type
404384

385+
xtrc(1, " adding (%d) from vp=%p\n", Nval, vp);
405386
Vblp->SetValue(vp, Nval++);
406387
return false;
407-
} // end of AddValue
388+
} // end of AddValue
408389

409390
/***********************************************************************/
410391
/* Retrieve the nth value of the array. */
@@ -973,7 +954,7 @@ int ARRAY::BlockTest(PGLOBAL, int opc, int opm,
973954
/* MakeArrayList: Makes a value list from an SQL IN array (in work). */
974955
/***********************************************************************/
975956
PSZ ARRAY::MakeArrayList(PGLOBAL g)
976-
{
957+
{
977958
char *p, *tp;
978959
int i;
979960
size_t z, len = 2;
@@ -988,11 +969,9 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
988969
Value->SetValue_pvblk(Vblp, i);
989970
Value->Prints(g, tp, z);
990971
len += strlen(tp);
991-
} // enfor i
992-
993-
if (trace(1))
994-
htrc("Arraylist: len=%d\n", len);
972+
} // enfor i
995973

974+
xtrc(1, "Arraylist: len=%d\n", len);
996975
p = (char *)PlugSubAlloc(g, NULL, len);
997976
strcpy(p, "(");
998977

@@ -1001,19 +980,17 @@ PSZ ARRAY::MakeArrayList(PGLOBAL g)
1001980
Value->Prints(g, tp, z);
1002981
strcat(p, tp);
1003982
strcat(p, (++i == Nval) ? ")" : ",");
1004-
} // enfor i
1005-
1006-
if (trace(1))
1007-
htrc("Arraylist: newlen=%d\n", strlen(p));
983+
} // enfor i
1008984

985+
xtrc(1, "Arraylist: newlen=%d\n", strlen(p));
1009986
return p;
1010-
} // end of MakeArrayList
987+
} // end of MakeArrayList
1011988

1012989
/***********************************************************************/
1013990
/* Make file output of ARRAY contents. */
1014991
/***********************************************************************/
1015992
void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
1016-
{
993+
{
1017994
char m[64];
1018995
int lim = MY_MIN(Nval,10);
1019996

@@ -1035,19 +1012,19 @@ void ARRAY::Printf(PGLOBAL g, FILE *f, uint n)
10351012
} else
10361013
fprintf(f, "%sVALLST: numval=%d\n", m, Nval);
10371014

1038-
} // end of Printf
1015+
} // end of Printf
10391016

10401017
/***********************************************************************/
10411018
/* Make string output of ARRAY contents. */
10421019
/***********************************************************************/
10431020
void ARRAY::Prints(PGLOBAL, char *ps, uint z)
1044-
{
1021+
{
10451022
if (z < 16)
10461023
return;
10471024

10481025
sprintf(ps, "ARRAY: type=%d\n", Type);
10491026
// More to be implemented later
1050-
} // end of Prints
1027+
} // end of Prints
10511028

10521029
/* -------------------------- Class MULAR ---------------------------- */
10531030

storage/connect/block.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ typedef class BLOCK *PBLOCK;
3838
class DllExport BLOCK {
3939
public:
4040
void * operator new(size_t size, PGLOBAL g, void *p = NULL) {
41-
if (trace(256))
42-
htrc("New BLOCK: size=%d g=%p p=%p\n", size, g, p);
43-
41+
xtrc(256, "New BLOCK: size=%d g=%p p=%p\n", size, g, p);
4442
return (PlugSubAlloc(g, p, size));
4543
} // end of new
4644

0 commit comments

Comments
 (0)