Skip to content

Commit 695c1e2

Browse files
committed
Merge remote-tracking branch 'connect/10.2' into 10.2
2 parents b1ac251 + 4df6952 commit 695c1e2

21 files changed

+512
-296
lines changed

storage/connect/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ IF(CONNECT_WITH_JDBC)
275275
JavaWrappers.jar)
276276
add_definitions(-DJAVA_SUPPORT)
277277
IF(CONNECT_WITH_MONGO)
278+
SET(CONNECT_SOURCES ${CONNECT_SOURCES} Mongo2.jar Mongo3.jar)
278279
add_definitions(-DMONGO_SUPPORT)
279280
ENDIF()
280281
ELSE()
@@ -410,5 +411,11 @@ IF(CONNECT_WITH_JDBC AND JAVA_FOUND AND JNI_FOUND)
410411
${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar
411412
${CMAKE_CURRENT_BINARY_DIR}/JdbcInterface.jar
412413
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
414+
IF(CONNECT_WITH_MONGO)
415+
INSTALL(FILES
416+
${CMAKE_CURRENT_SOURCE_DIR}/Mongo2.jar
417+
${CMAKE_CURRENT_SOURCE_DIR}/Mongo3.jar
418+
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
419+
ENDIF()
413420
ENDIF()
414421

storage/connect/Mongo2.jar

609 KB
Binary file not shown.

storage/connect/Mongo3.jar

1.63 MB
Binary file not shown.

storage/connect/bson.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,9 @@ PBVAL BJSON::GetArrayValue(PBVAL bap, int n)
11381138
CheckType(bap, TYPE_JAR);
11391139
int i = 0;
11401140

1141+
if (n < 0)
1142+
n += GetArraySize(bap);
1143+
11411144
for (PBVAL bvp = GetArray(bap); bvp; bvp = GetNext(bvp), i++)
11421145
if (i == n)
11431146
return bvp;
@@ -1348,12 +1351,17 @@ PBVAL BJSON::NewVal(PVAL valp)
13481351
/***********************************************************************/
13491352
/* Sub-allocate and initialize a BVAL from another BVAL. */
13501353
/***********************************************************************/
1351-
PBVAL BJSON::DupVal(PBVAL bvlp) {
1352-
PBVAL bvp = NewVal();
1354+
PBVAL BJSON::DupVal(PBVAL bvlp)
1355+
{
1356+
if (bvlp) {
1357+
PBVAL bvp = NewVal();
1358+
1359+
*bvp = *bvlp;
1360+
bvp->Next = 0;
1361+
return bvp;
1362+
} else
1363+
return NULL;
13531364

1354-
*bvp = *bvlp;
1355-
bvp->Next = 0;
1356-
return bvp;
13571365
} // end of DupVal
13581366

13591367
/***********************************************************************/

storage/connect/bsonudf.cpp

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ BJNX::BJNX(PGLOBAL g) : BDOC(g)
117117
Jp = NULL;
118118
Nodes = NULL;
119119
Value = NULL;
120-
MulVal = NULL;
120+
//MulVal = NULL;
121121
Jpath = NULL;
122122
Buf_Type = TYPE_STRING;
123123
Long = len;
@@ -148,7 +148,7 @@ BJNX::BJNX(PGLOBAL g, PBVAL row, int type, int len, int prec, my_bool wr) : BDOC
148148
Jp = NULL;
149149
Nodes = NULL;
150150
Value = AllocateValue(g, type, len, prec);
151-
MulVal = NULL;
151+
//MulVal = NULL;
152152
Jpath = NULL;
153153
Buf_Type = type;
154154
Long = len;
@@ -273,40 +273,6 @@ my_bool BJNX::SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm)
273273
return true;
274274
} // endif's
275275

276-
#if 0
277-
// For calculated arrays, a local Value must be used
278-
switch (jnp->Op) {
279-
case OP_NUM:
280-
jnp->Valp = AllocateValue(g, TYPE_INT);
281-
break;
282-
case OP_ADD:
283-
case OP_MULT:
284-
case OP_SEP:
285-
if (!IsTypeChar(Buf_Type))
286-
jnp->Valp = AllocateValue(g, Buf_Type, 0, GetPrecision());
287-
else
288-
jnp->Valp = AllocateValue(g, TYPE_DOUBLE, 0, 2);
289-
290-
break;
291-
case OP_MIN:
292-
case OP_MAX:
293-
jnp->Valp = AllocateValue(g, Buf_Type, Long, GetPrecision());
294-
break;
295-
case OP_CNC:
296-
if (IsTypeChar(Buf_Type))
297-
jnp->Valp = AllocateValue(g, TYPE_STRING, Long, GetPrecision());
298-
else
299-
jnp->Valp = AllocateValue(g, TYPE_STRING, 512);
300-
301-
break;
302-
default:
303-
break;
304-
} // endswitch Op
305-
306-
if (jnp->Valp)
307-
MulVal = AllocateValue(g, jnp->Valp);
308-
#endif // 0
309-
310276
return false;
311277
} // end of SetArrayOptions
312278

@@ -452,6 +418,8 @@ PBVAL BJNX::MakeJson(PGLOBAL g, PBVAL bvp, int n)
452418
{
453419
PBVAL vlp, jvp = bvp;
454420

421+
Jb = false;
422+
455423
if (n < Nod -1) {
456424
if (bvp->Type == TYPE_JAR) {
457425
int ars = GetArraySize(bvp);
@@ -3022,7 +2990,7 @@ void bson_object_grp_add(UDF_INIT *initid, UDF_ARGS *args, char*, char*)
30222990
PBVAL bop = (PBVAL)g->Activityp;
30232991

30242992
if (g->N-- > 0)
3025-
bxp->SetKeyValue(bop, bxp->MakeValue(args, 1), MakePSZ(g, args, 0));
2993+
bxp->SetKeyValue(bop, bxp->MakeValue(args, 1), MakePSZ(g, args, 0));
30262994

30272995
} // end of bson_object_grp_add
30282996

@@ -3710,7 +3678,7 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
37103678
PUSH_WARNING("CheckMemory error");
37113679
goto fin;
37123680
} else {
3713-
bnx.Reset();
3681+
bnx.Reset();
37143682
jvp = bnx.MakeValue(args, 0, true);
37153683

37163684
if (g->Mrr) { // First argument is a constant
@@ -4056,7 +4024,7 @@ double bsonget_real(UDF_INIT *initid, UDF_ARGS *args,
40564024
*is_null = 1;
40574025
return 0.0;
40584026
} else {
4059-
bnx.Reset();
4027+
bnx.Reset();
40604028
jvp = bnx.MakeValue(args, 0);
40614029

40624030
if ((p = bnx.GetString(jvp))) {

storage/connect/bsonudf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ typedef struct _jnode {
4141
PSZ Key; // The key used for object
4242
OPVAL Op; // Operator used for this node
4343
PVAL CncVal; // To cont value used for OP_CNC
44-
PVAL Valp; // The internal array VALUE
4544
int Rank; // The rank in array
4645
int Rx; // Read row number
4746
int Nx; // Next to read row number
@@ -153,7 +152,7 @@ class BJNX : public BDOC {
153152
JOUTSTR *Jp;
154153
JNODE *Nodes; // The intermediate objects
155154
PVAL Value;
156-
PVAL MulVal; // To value used by multiple column
155+
//PVAL MulVal; // To value used by multiple column
157156
char *Jpath; // The json path
158157
int Buf_Type;
159158
int Long;

storage/connect/cmgoconn.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ void CMgoConn::mongo_init(bool init)
150150
/***********************************************************************/
151151
bool CMgoConn::Connect(PGLOBAL g)
152152
{
153+
if (!Pcg->Db_name || !Pcg->Coll_name) {
154+
// This would crash in mongoc_client_get_collection
155+
strcpy(g->Message, "Missing DB or collection name");
156+
return true;
157+
} // endif name
158+
153159
if (!IsInit)
154160
#if defined(__WIN__)
155161
__try {

storage/connect/ha_connect.cc

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
#define JSONMAX 10 // JSON Default max grp size
171171

172172
extern "C" {
173-
char version[]= "Version 1.07.0002 January 27, 2021";
173+
char version[]= "Version 1.07.0002 March 22, 2021";
174174
#if defined(__WIN__)
175175
char compver[]= "Version 1.07.0002 " __DATE__ " " __TIME__;
176176
char slash= '\\';
@@ -277,6 +277,10 @@ static handler *connect_create_handler(handlerton *hton,
277277
TABLE_SHARE *table,
278278
MEM_ROOT *mem_root);
279279

280+
static bool checkPrivileges(THD* thd, TABTYPE type, PTOS options,
281+
const char* db, TABLE* table = NULL,
282+
bool quick = false);
283+
280284
static int connect_assisted_discovery(handlerton *hton, THD* thd,
281285
TABLE_SHARE *table_s,
282286
HA_CREATE_INFO *info);
@@ -757,10 +761,10 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR name, LPCSTR dir)
757761
used by the default rename_table and delete_table method in
758762
handler.cc.
759763
760-
For engines that have two file name extentions (separate meta/index file
764+
For engines that have two file name extensions (separate meta/index file
761765
and data file), the order of elements is relevant. First element of engine
762-
file name extentions array should be meta/index file extention. Second
763-
element - data file extention. This order is assumed by
766+
file name extensions array should be meta/index file extension. Second
767+
element - data file extension. This order is assumed by
764768
prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
765769
766770
@see
@@ -1296,9 +1300,9 @@ PCSZ GetStringTableOption(PGLOBAL g, PTOS options, PCSZ opname, PCSZ sdef)
12961300
else if (!stricmp(opname, "Data_charset"))
12971301
opval= options->data_charset;
12981302
else if (!stricmp(opname, "Http") || !stricmp(opname, "URL"))
1299-
opval = options->http;
1303+
opval= options->http;
13001304
else if (!stricmp(opname, "Uri"))
1301-
opval = options->uri;
1305+
opval= options->uri;
13021306

13031307
if (!opval && options->oplist)
13041308
opval= GetListOption(g, opname, options->oplist);
@@ -1612,7 +1616,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
16121616
pcf->Opt= (fop) ? (int)fop->opt : 0;
16131617

16141618
if (fp->field_length >= 0) {
1615-
pcf->Length = fp->field_length;
1619+
pcf->Length= fp->field_length;
16161620

16171621
// length is bytes for Connect, not characters
16181622
if (!strnicmp(chset, "utf8", 4))
@@ -1627,7 +1631,7 @@ void *ha_connect::GetColumnOption(PGLOBAL g, void *field, PCOLINFO pcf)
16271631
pcf->Offset= (int)fop->offset;
16281632
pcf->Freq= (int)fop->freq;
16291633
pcf->Datefmt= (char*)fop->dateformat;
1630-
pcf->Fieldfmt = fop->fieldformat ? (char*)fop->fieldformat
1634+
pcf->Fieldfmt= fop->fieldformat ? (char*)fop->fieldformat
16311635
: fop->jsonpath ? (char*)fop->jsonpath : (char*)fop->xmlpath;
16321636
} else {
16331637
pcf->Offset= -1;
@@ -4510,11 +4514,9 @@ int ha_connect::delete_all_rows()
45104514
} // end of delete_all_rows
45114515

45124516

4513-
bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
4517+
static bool checkPrivileges(THD *thd, TABTYPE type, PTOS options,
4518+
const char *db, TABLE *table, bool quick)
45144519
{
4515-
const char *db= (dbn && *dbn) ? dbn : NULL;
4516-
TABTYPE type=GetRealType(options);
4517-
45184520
switch (type) {
45194521
case TAB_UNDEF:
45204522
// case TAB_CATLG:
@@ -4597,6 +4599,15 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
45974599

45984600
my_printf_error(ER_UNKNOWN_ERROR, "check_privileges failed", MYF(0));
45994601
return true;
4602+
} // end of checkPrivileges
4603+
4604+
// Check whether the user has required (file) privileges
4605+
bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
4606+
{
4607+
const char *db= (dbn && *dbn) ? dbn : NULL;
4608+
TABTYPE type=GetRealType(options);
4609+
4610+
return checkPrivileges(thd, type, options, db, table, quick);
46004611
} // end of check_privileges
46014612

46024613
// Check that two indexes are equivalent
@@ -5390,12 +5401,7 @@ static bool add_field(String* sql, TABTYPE ttp, const char* field_name, int typ,
53905401
int len, int dec, char* key, uint tm, const char* rem,
53915402
char* dft, char* xtra, char* fmt, int flag, bool dbf, char v)
53925403
{
5393-
#if defined(DEVELOPMENT)
5394-
// Some client programs regard CHAR(36) as GUID
5395-
char var = (len > 255 || len == 36) ? 'V' : v;
5396-
#else
53975404
char var = (len > 255) ? 'V' : v;
5398-
#endif
53995405
bool q, error = false;
54005406
const char* type = PLGtoMYSQLtype(typ, dbf, var);
54015407

@@ -5731,6 +5737,29 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
57315737
#endif // REST_SUPPORT
57325738
} // endif ttp
57335739

5740+
if (fn && *fn)
5741+
switch (ttp) {
5742+
case TAB_FMT:
5743+
case TAB_DBF:
5744+
case TAB_XML:
5745+
case TAB_INI:
5746+
case TAB_VEC:
5747+
case TAB_REST:
5748+
case TAB_JSON:
5749+
#if defined(BSON_SUPPORT)
5750+
case TAB_BSON:
5751+
#endif // BSON_SUPPORT
5752+
if (checkPrivileges(thd, ttp, topt, db)) {
5753+
strcpy(g->Message, "This operation requires the FILE privilege");
5754+
rc= HA_ERR_INTERNAL_ERROR;
5755+
goto err;
5756+
} // endif check_privileges
5757+
5758+
break;
5759+
default:
5760+
break;
5761+
} // endswitch ttp
5762+
57345763
if (!tab) {
57355764
if (ttp == TAB_TBL) {
57365765
// Make tab the first table of the list

storage/connect/javaconn.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/************ Javaconn C++ Functions Source Code File (.CPP) ***********/
2-
/* Name: JAVAConn.CPP Version 1.0 */
2+
/* Name: JAVAConn.CPP Version 1.1 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 2017 */
4+
/* (C) Copyright to the author Olivier BERTRAND 2017 - 2021 */
55
/* */
66
/* This file contains the JAVA connection classes functions. */
77
/***********************************************************************/
@@ -400,24 +400,35 @@ bool JAVAConn::Open(PGLOBAL g)
400400
jpop->Append(ClassPath);
401401
} // endif ClassPath
402402

403-
// Java source will be compiled as a jar file installed in the plugin dir
403+
#if 0
404+
// Java source will be compiled as a jar file installed in the plugin dir
404405
jpop->Append(sep);
405406
jpop->Append(GetPluginDir());
406407
jpop->Append("JdbcInterface.jar");
408+
#endif // 0
407409

408410
// All wrappers are pre-compiled in JavaWrappers.jar in the plugin dir
409411
jpop->Append(sep);
410412
jpop->Append(GetPluginDir());
411413
jpop->Append("JavaWrappers.jar");
412414

415+
#if defined(MONGO_SUPPORT)
416+
jpop->Append(sep);
417+
jpop->Append(GetPluginDir());
418+
jpop->Append("Mongo3.jar");
419+
jpop->Append(sep);
420+
jpop->Append(GetPluginDir());
421+
jpop->Append("Mongo2.jar");
422+
#endif // MONGO_SUPPORT
423+
413424
if ((cp = getenv("CLASSPATH"))) {
414425
jpop->Append(sep);
415426
jpop->Append(cp);
416427
} // endif cp
417428

418429
if (trace(1)) {
419-
htrc("ClassPath=%s\n", ClassPath);
420-
htrc("CLASSPATH=%s\n", cp);
430+
htrc("ClassPath=%s\n", ClassPath ? ClassPath : "null");
431+
htrc("CLASSPATH=%s\n", cp ? cp : "null");
421432
htrc("%s\n", jpop->GetStr());
422433
} // endif trace
423434

storage/connect/jmgoconn.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,21 @@ JMgoConn::JMgoConn(PGLOBAL g, PCSZ collname, PCSZ wrapper)
121121
/***********************************************************************/
122122
void JMgoConn::AddJars(PSTRG jpop, char sep)
123123
{
124-
#if defined(BSON_SUPPORT)
124+
#if defined(DEVELOPMENT)
125125
if (m_Version == 2) {
126126
jpop->Append(sep);
127127
// jpop->Append("C:/Eclipse/workspace/MongoWrap2/bin");
128-
jpop->Append(sep);
128+
// jpop->Append(sep);
129129
jpop->Append("C:/mongo-java-driver/mongo-java-driver-2.13.3.jar");
130130
} else {
131131
jpop->Append(sep);
132132
// jpop->Append("C:/Eclipse/workspace/MongoWrap3/bin");
133+
// jpop->Append(sep);
133134
// jpop->Append("C:/Program Files/MariaDB 10.1/lib/plugin/JavaWrappers.jar");
134-
jpop->Append(sep);
135+
// jpop->Append(sep);
135136
jpop->Append("C:/mongo-java-driver/mongo-java-driver-3.4.2.jar");
136137
} // endif m_Version
137-
#endif // BSON_SUPPORT
138+
#endif // DEVELOPMENT
138139
} // end of AddJars
139140

140141
/***********************************************************************/

0 commit comments

Comments
 (0)