Skip to content

Commit b2956b2

Browse files
committed
Update version number and date
modified: storage/connect/ha_connect.cc Add conditional SE exception support modified: storage/connect/json.cpp modified: storage/connect/plgdbutl.cpp Change %p in %x in some sprintf functions. This to avoid some compiler warnings. modified: storage/connect/tabwmi.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/value.h Add JavaWrappers.jar to the class path modified: storage/connect/jdbconn.cpp Fix wrong declare (char *buf[256]; --> char buf[256];) modified: storage/connect/xindex.cpp
1 parent d75e5e6 commit b2956b2

File tree

9 files changed

+91
-36
lines changed

9 files changed

+91
-36
lines changed

storage/connect/ha_connect.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@
172172
#define JSONMAX 10 // JSON Default max grp size
173173

174174
extern "C" {
175-
char version[]= "Version 1.05.0002 January 08, 2017";
175+
char version[]= "Version 1.05.0003 February 27, 2017";
176176
#if defined(__WIN__)
177-
char compver[]= "Version 1.05.0002 " __DATE__ " " __TIME__;
177+
char compver[]= "Version 1.05.0003 " __DATE__ " " __TIME__;
178178
char slash= '\\';
179179
#else // !__WIN__
180180
char slash= '/';
@@ -7045,10 +7045,10 @@ maria_declare_plugin(connect)
70457045
PLUGIN_LICENSE_GPL,
70467046
connect_init_func, /* Plugin Init */
70477047
connect_done_func, /* Plugin Deinit */
7048-
0x0104, /* version number (1.04) */
7048+
0x0105, /* version number (1.05) */
70497049
NULL, /* status variables */
70507050
connect_system_variables, /* system variables */
7051-
"1.05.0001", /* string version */
7051+
"1.05.0003", /* string version */
70527052
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
70537053
}
70547054
maria_declare_plugin_end;

storage/connect/jdbconn.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ int JDBConn::Open(PJPARM sop)
826826
jpop->Append(GetPluginDir());
827827
jpop->Append("JdbcInterface.jar");
828828

829+
// All wrappers are pre-compiled in JavaWrappers.jar in the plugin dir
830+
jpop->Append(sep);
831+
jpop->Append(GetPluginDir());
832+
jpop->Append("JavaWrappers.jar");
833+
829834
//================== prepare loading of Java VM ============================
830835
JavaVMInitArgs vm_args; // Initialization arguments
831836
JavaVMOption* options = new JavaVMOption[N]; // JVM invocation options

storage/connect/json.cpp

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*************** json CPP Declares Source Code File (.H) ***************/
2-
/* Name: json.cpp Version 1.2 */
2+
/* Name: json.cpp Version 1.3 */
33
/* */
4-
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
4+
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
55
/* */
66
/* This file contains the JSON classes functions. */
77
/***********************************************************************/
@@ -27,8 +27,33 @@
2727
#define EL "\r\n"
2828
#else
2929
#define EL "\n"
30+
#undef SE_CATCH // Does not work for Linux
3031
#endif
3132

33+
#if defined(SE_CATCH)
34+
/**************************************************************************/
35+
/* This is the support of catching C interrupts to prevent crashes. */
36+
/**************************************************************************/
37+
#include <eh.h>
38+
39+
class SE_Exception {
40+
public:
41+
SE_Exception(unsigned int n, PEXCEPTION_RECORD p) : nSE(n), eRec(p) {}
42+
~SE_Exception() {}
43+
44+
unsigned int nSE;
45+
PEXCEPTION_RECORD eRec;
46+
}; // end of class SE_Exception
47+
48+
void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
49+
{
50+
throw SE_Exception(u, pExp->ExceptionRecord);
51+
} // end of trans_func
52+
53+
char *GetExceptionDesc(PGLOBAL g, unsigned int e);
54+
#endif // SE_CATCH
55+
56+
3257
/***********************************************************************/
3358
/* Parse a json string. */
3459
/* Note: when pretty is not known, the caller set pretty to 3. */
@@ -40,6 +65,9 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
4065
PJSON jsp = NULL;
4166
STRG src;
4267

68+
if (trace)
69+
htrc("ParseJson: s=%.10s len=%d\n", s, len);
70+
4371
if (!s || !len) {
4472
strcpy(g->Message, "Void JSON object");
4573
return NULL;
@@ -53,15 +81,37 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
5381
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
5482
pty[0] = false;
5583

84+
5685
// Save stack and allocation environment and prepare error return
5786
if (g->jump_level == MAX_JUMP) {
5887
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
5988
return NULL;
6089
} // endif jump_level
6190

62-
if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
63-
goto err;
64-
} // endif rc
91+
#if defined(SE_CATCH)
92+
// Let's try to recover from any kind of interrupt
93+
_se_translator_function f = _set_se_translator(trans_func);
94+
95+
try {
96+
#endif // SE_CATCH --------------------- try section --------------------
97+
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
98+
goto err;
99+
} // endif rc
100+
101+
#if defined(SE_CATCH) // ------------- end of try section -----------------
102+
} catch (SE_Exception e) {
103+
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
104+
GetExceptionDesc(g, e.nSE), e.nSE);
105+
_set_se_translator(f);
106+
goto err;
107+
} catch (...) {
108+
strcpy(g->Message, "Exception doing setjmp");
109+
_set_se_translator(f);
110+
goto err;
111+
} // end of try-catches
112+
113+
_set_se_translator(f);
114+
#endif // SE_CATCH
65115

66116
for (i = 0; i < len; i++)
67117
switch (s[i]) {
@@ -140,7 +190,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
140190
strcpy(g->Message, "More than one item in file");
141191

142192
err:
143-
g->jump_level--;
193+
g->jump_level--;
144194
return NULL;
145195
} // end of ParseJson
146196

@@ -390,14 +440,14 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
390440
// if (charset == utf8) {
391441
char xs[5];
392442
uint hex;
393-
443+
394444
xs[0] = s[++i];
395445
xs[1] = s[++i];
396446
xs[2] = s[++i];
397447
xs[3] = s[++i];
398448
xs[4] = 0;
399449
hex = strtoul(xs, NULL, 16);
400-
450+
401451
if (hex < 0x80) {
402452
p[n] = (uchar)hex;
403453
} else if (hex < 0x800) {
@@ -414,7 +464,7 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
414464
} else {
415465
char xs[3];
416466
UINT hex;
417-
467+
418468
i += 2;
419469
xs[0] = s[++i];
420470
xs[1] = s[++i];
@@ -468,7 +518,7 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src)
468518
case '.':
469519
if (!found_digit || has_dot || has_e)
470520
goto err;
471-
521+
472522
has_dot = true;
473523
break;
474524
case 'e':
@@ -769,7 +819,7 @@ bool JOUTSTR::Escape(const char *s)
769819

770820
for (unsigned int i = 0; s[i]; i++)
771821
switch (s[i]) {
772-
case '"':
822+
case '"':
773823
case '\\':
774824
case '\t':
775825
case '\n':
@@ -1057,7 +1107,7 @@ void JARRAY::InitArray(PGLOBAL g)
10571107
int i;
10581108
PJVAL jvp, *pjvp = &First;
10591109

1060-
for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
1110+
for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
10611111
if (!jvp->Del)
10621112
Size++;
10631113

@@ -1191,8 +1241,8 @@ bool JARRAY::IsNull(void)
11911241
/***********************************************************************/
11921242
JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
11931243
{
1194-
Jsp = NULL;
1195-
Value = AllocateValue(g, valp);
1244+
Jsp = NULL;
1245+
Value = AllocateValue(g, valp);
11961246
Next = NULL;
11971247
Del = false;
11981248
} // end of JVALUE constructor
@@ -1297,7 +1347,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
12971347
} // end of GetText
12981348

12991349
void JVALUE::SetValue(PJSON jsp)
1300-
{
1350+
{
13011351
if (jsp && jsp->GetType() == TYPE_JVAL) {
13021352
Jsp = jsp->GetJsp();
13031353
Value = jsp->GetValue();

storage/connect/plgdbutl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/********** PlgDBUtl Fpe C++ Program Source Code File (.CPP) ***********/
22
/* PROGRAM NAME: PLGDBUTL */
33
/* ------------- */
4-
/* Version 3.9 */
4+
/* Version 4.0 */
55
/* */
66
/* COPYRIGHT: */
77
/* ---------- */
8-
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
8+
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
99
/* */
1010
/* WHAT THIS PROGRAM DOES: */
1111
/* ----------------------- */
@@ -1123,7 +1123,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
11231123
return amn;
11241124
} // end of GetAmName
11251125

1126-
#if defined(__WIN__) && !defined(NOCATCH)
1126+
#if defined(SE_CATCH)
11271127
/***********************************************************************/
11281128
/* GetExceptionDesc: return the description of an exception code. */
11291129
/***********************************************************************/
@@ -1211,7 +1211,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e)
12111211

12121212
return p;
12131213
} // end of GetExceptionDesc
1214-
#endif // __WIN__ && !NOCATCH
1214+
#endif // SE_CATCH
12151215

12161216
/***********************************************************************/
12171217
/* PlgDBalloc: allocates or suballocates memory conditionally. */

storage/connect/tabmul.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class TDBDIR : public TDBASE {
134134
int iFile; // Index of currently retrieved file
135135
#if defined(__WIN__)
136136
_finddata_t FileData; // Find data structure
137-
int Hsearch; // Search handle
137+
intptr_t Hsearch; // Search handle
138138
char Drive[_MAX_DRIVE]; // Drive name
139139
#else // !__WIN__
140140
struct stat Fileinfo; // File info structure
@@ -184,7 +184,7 @@ class TDBSDR : public TDBDIR {
184184
struct _Sub_Dir *Next;
185185
struct _Sub_Dir *Prev;
186186
#if defined(__WIN__)
187-
int H; // Search handle
187+
intptr_t H; // Search handle
188188
#else // !__WIN__
189189
DIR *D;
190190
#endif // !__WIN__

storage/connect/tabwmi.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)
6363

6464
if (FAILED(res)) {
6565
sprintf(g->Message, "Failed to initialize COM library. "
66-
"Error code = %p", res);
66+
"Error code = %x", res);
6767
return NULL;
6868
} // endif res
6969

@@ -86,7 +86,7 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)
8686
(void**) &loc);
8787
if (FAILED(res)) {
8888
sprintf(g->Message, "Failed to create Locator. "
89-
"Error code = %p", res);
89+
"Error code = %x", res);
9090
CoUninitialize();
9191
return NULL;
9292
} // endif res
@@ -95,7 +95,7 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)
9595
NULL, NULL, NULL, 0, NULL, NULL, &wp->Svc);
9696

9797
if (FAILED(res)) {
98-
sprintf(g->Message, "Could not connect. Error code = %p", res);
98+
sprintf(g->Message, "Could not connect. Error code = %x", res);
9999
loc->Release();
100100
CoUninitialize();
101101
return NULL;
@@ -424,7 +424,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
424424

425425
if (FAILED(Res)) {
426426
sprintf(g->Message, "Failed to initialize COM library. "
427-
"Error code = %p", Res);
427+
"Error code = %x", Res);
428428
return true; // Program has failed.
429429
} // endif Res
430430

@@ -437,7 +437,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
437437

438438
if (FAILED(Res)) {
439439
sprintf(g->Message, "Failed to create Locator. "
440-
"Error code = %p", Res);
440+
"Error code = %x", Res);
441441
CoUninitialize();
442442
return true; // Program has failed.
443443
} // endif Res
@@ -449,7 +449,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
449449
NULL, NULL,0, NULL, 0, 0, &Svc);
450450

451451
if (FAILED(Res)) {
452-
sprintf(g->Message, "Could not connect. Error code = %p", Res);
452+
sprintf(g->Message, "Could not connect. Error code = %x", Res);
453453
loc->Release();
454454
CoUninitialize();
455455
return true; // Program has failed.
@@ -464,7 +464,7 @@ bool TDBWMI::Initialize(PGLOBAL g)
464464
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
465465

466466
if (FAILED(Res)) {
467-
sprintf(g->Message, "Could not set proxy. Error code = 0x", Res);
467+
sprintf(g->Message, "Could not set proxy. Error code = %x", Res);
468468
Svc->Release();
469469
CoUninitialize();
470470
return true; // Program has failed.
@@ -574,7 +574,7 @@ bool TDBWMI::GetWMIInfo(PGLOBAL g)
574574
NULL, &Enumerator);
575575

576576
if (FAILED(Rc)) {
577-
sprintf(g->Message, "Query %s failed. Error code = %p", cmd, Rc);
577+
sprintf(g->Message, "Query %s failed. Error code = %x", cmd, Rc);
578578
Svc->Release();
579579
CoUninitialize();
580580
return true; // Program has failed.

storage/connect/tabxml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ bool TDBXML::Initialize(PGLOBAL g)
931931
if (rc)
932932
sprintf(g->Message, "%s: %s", MSG(COM_ERROR), buf);
933933
else
934-
sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error());
934+
sprintf(g->Message, "%s hr=%x", MSG(COM_ERROR), e.Error());
935935

936936
goto error;
937937
#endif // __WIN__

storage/connect/value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ class DllExport TYPVAL<PSZ>: public VALUE {
271271
virtual void Reset(void) {*Strp = 0;}
272272
virtual int GetValLen(void) {return Len;};
273273
virtual int GetValPrec() {return (Ci) ? 1 : 0;}
274-
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
274+
virtual int GetSize(void) {return (Strp) ? (int)strlen(Strp) : 0;}
275275
virtual PSZ GetCharValue(void) {return Strp;}
276276
virtual char GetTinyValue(void);
277277
virtual uchar GetUTinyValue(void);

storage/connect/xindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
27382738
} // endif nbr
27392739

27402740
} else {
2741-
char *buf[256];
2741+
char buf[256];
27422742
DWORD drc = GetLastError();
27432743

27442744
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |

0 commit comments

Comments
 (0)