Skip to content

Commit

Permalink
Update version number and date
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
Buggynours committed Mar 2, 2017
1 parent d75e5e6 commit b2956b2
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 36 deletions.
8 changes: 4 additions & 4 deletions storage/connect/ha_connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@
#define JSONMAX 10 // JSON Default max grp size

extern "C" {
char version[]= "Version 1.05.0002 January 08, 2017";
char version[]= "Version 1.05.0003 February 27, 2017";
#if defined(__WIN__)
char compver[]= "Version 1.05.0002 " __DATE__ " " __TIME__;
char compver[]= "Version 1.05.0003 " __DATE__ " " __TIME__;
char slash= '\\';
#else // !__WIN__
char slash= '/';
Expand Down Expand Up @@ -7045,10 +7045,10 @@ maria_declare_plugin(connect)
PLUGIN_LICENSE_GPL,
connect_init_func, /* Plugin Init */
connect_done_func, /* Plugin Deinit */
0x0104, /* version number (1.04) */
0x0105, /* version number (1.05) */
NULL, /* status variables */
connect_system_variables, /* system variables */
"1.05.0001", /* string version */
"1.05.0003", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
}
maria_declare_plugin_end;
5 changes: 5 additions & 0 deletions storage/connect/jdbconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,11 @@ int JDBConn::Open(PJPARM sop)
jpop->Append(GetPluginDir());
jpop->Append("JdbcInterface.jar");

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

//================== prepare loading of Java VM ============================
JavaVMInitArgs vm_args; // Initialization arguments
JavaVMOption* options = new JavaVMOption[N]; // JVM invocation options
Expand Down
80 changes: 65 additions & 15 deletions storage/connect/json.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*************** json CPP Declares Source Code File (.H) ***************/
/* Name: json.cpp Version 1.2 */
/* Name: json.cpp Version 1.3 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2015 */
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */
/* */
/* This file contains the JSON classes functions. */
/***********************************************************************/
Expand All @@ -27,8 +27,33 @@
#define EL "\r\n"
#else
#define EL "\n"
#undef SE_CATCH // Does not work for Linux
#endif

#if defined(SE_CATCH)
/**************************************************************************/
/* This is the support of catching C interrupts to prevent crashes. */
/**************************************************************************/
#include <eh.h>

class SE_Exception {
public:
SE_Exception(unsigned int n, PEXCEPTION_RECORD p) : nSE(n), eRec(p) {}
~SE_Exception() {}

unsigned int nSE;
PEXCEPTION_RECORD eRec;
}; // end of class SE_Exception

void trans_func(unsigned int u, _EXCEPTION_POINTERS* pExp)
{
throw SE_Exception(u, pExp->ExceptionRecord);
} // end of trans_func

char *GetExceptionDesc(PGLOBAL g, unsigned int e);
#endif // SE_CATCH


/***********************************************************************/
/* Parse a json string. */
/* Note: when pretty is not known, the caller set pretty to 3. */
Expand All @@ -40,6 +65,9 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
PJSON jsp = NULL;
STRG src;

if (trace)
htrc("ParseJson: s=%.10s len=%d\n", s, len);

if (!s || !len) {
strcpy(g->Message, "Void JSON object");
return NULL;
Expand All @@ -53,15 +81,37 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma)
if (s[0] == '[' && (s[1] == '\n' || (s[1] == '\r' && s[2] == '\n')))
pty[0] = false;


// Save stack and allocation environment and prepare error return
if (g->jump_level == MAX_JUMP) {
strcpy(g->Message, MSG(TOO_MANY_JUMPS));
return NULL;
} // endif jump_level

if ((rc= setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // endif rc
#if defined(SE_CATCH)
// Let's try to recover from any kind of interrupt
_se_translator_function f = _set_se_translator(trans_func);

try {
#endif // SE_CATCH --------------------- try section --------------------
if ((rc = setjmp(g->jumper[++g->jump_level])) != 0) {
goto err;
} // endif rc

#if defined(SE_CATCH) // ------------- end of try section -----------------
} catch (SE_Exception e) {
sprintf(g->Message, "ParseJson: exception doing setjmp: %s (rc=%hd)",
GetExceptionDesc(g, e.nSE), e.nSE);
_set_se_translator(f);
goto err;
} catch (...) {
strcpy(g->Message, "Exception doing setjmp");
_set_se_translator(f);
goto err;
} // end of try-catches

_set_se_translator(f);
#endif // SE_CATCH

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

err:
g->jump_level--;
g->jump_level--;
return NULL;
} // end of ParseJson

Expand Down Expand Up @@ -390,14 +440,14 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
// if (charset == utf8) {
char xs[5];
uint hex;

xs[0] = s[++i];
xs[1] = s[++i];
xs[2] = s[++i];
xs[3] = s[++i];
xs[4] = 0;
hex = strtoul(xs, NULL, 16);

if (hex < 0x80) {
p[n] = (uchar)hex;
} else if (hex < 0x800) {
Expand All @@ -414,7 +464,7 @@ char *ParseString(PGLOBAL g, int& i, STRG& src)
} else {
char xs[3];
UINT hex;

i += 2;
xs[0] = s[++i];
xs[1] = s[++i];
Expand Down Expand Up @@ -468,7 +518,7 @@ PVAL ParseNumeric(PGLOBAL g, int& i, STRG& src)
case '.':
if (!found_digit || has_dot || has_e)
goto err;

has_dot = true;
break;
case 'e':
Expand Down Expand Up @@ -769,7 +819,7 @@ bool JOUTSTR::Escape(const char *s)

for (unsigned int i = 0; s[i]; i++)
switch (s[i]) {
case '"':
case '"':
case '\\':
case '\t':
case '\n':
Expand Down Expand Up @@ -1057,7 +1107,7 @@ void JARRAY::InitArray(PGLOBAL g)
int i;
PJVAL jvp, *pjvp = &First;

for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
for (Size = 0, jvp = First; jvp; jvp = jvp->Next)
if (!jvp->Del)
Size++;

Expand Down Expand Up @@ -1191,8 +1241,8 @@ bool JARRAY::IsNull(void)
/***********************************************************************/
JVALUE::JVALUE(PGLOBAL g, PVAL valp) : JSON()
{
Jsp = NULL;
Value = AllocateValue(g, valp);
Jsp = NULL;
Value = AllocateValue(g, valp);
Next = NULL;
Del = false;
} // end of JVALUE constructor
Expand Down Expand Up @@ -1297,7 +1347,7 @@ PSZ JVALUE::GetText(PGLOBAL g, PSZ text)
} // end of GetText

void JVALUE::SetValue(PJSON jsp)
{
{
if (jsp && jsp->GetType() == TYPE_JVAL) {
Jsp = jsp->GetJsp();
Value = jsp->GetValue();
Expand Down
8 changes: 4 additions & 4 deletions storage/connect/plgdbutl.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/********** PlgDBUtl Fpe C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: PLGDBUTL */
/* ------------- */
/* Version 3.9 */
/* Version 4.0 */
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* (C) Copyright to the author Olivier BERTRAND 1998-2017 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
Expand Down Expand Up @@ -1123,7 +1123,7 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
return amn;
} // end of GetAmName

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

return p;
} // end of GetExceptionDesc
#endif // __WIN__ && !NOCATCH
#endif // SE_CATCH

/***********************************************************************/
/* PlgDBalloc: allocates or suballocates memory conditionally. */
Expand Down
4 changes: 2 additions & 2 deletions storage/connect/tabmul.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class TDBDIR : public TDBASE {
int iFile; // Index of currently retrieved file
#if defined(__WIN__)
_finddata_t FileData; // Find data structure
int Hsearch; // Search handle
intptr_t Hsearch; // Search handle
char Drive[_MAX_DRIVE]; // Drive name
#else // !__WIN__
struct stat Fileinfo; // File info structure
Expand Down Expand Up @@ -184,7 +184,7 @@ class TDBSDR : public TDBDIR {
struct _Sub_Dir *Next;
struct _Sub_Dir *Prev;
#if defined(__WIN__)
int H; // Search handle
intptr_t H; // Search handle
#else // !__WIN__
DIR *D;
#endif // !__WIN__
Expand Down
16 changes: 8 additions & 8 deletions storage/connect/tabwmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PWMIUT InitWMI(PGLOBAL g, char *nsp, char *classname)

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

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

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

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

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

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

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

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

if (FAILED(Rc)) {
sprintf(g->Message, "Query %s failed. Error code = %p", cmd, Rc);
sprintf(g->Message, "Query %s failed. Error code = %x", cmd, Rc);
Svc->Release();
CoUninitialize();
return true; // Program has failed.
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/tabxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ bool TDBXML::Initialize(PGLOBAL g)
if (rc)
sprintf(g->Message, "%s: %s", MSG(COM_ERROR), buf);
else
sprintf(g->Message, "%s hr=%p", MSG(COM_ERROR), e.Error());
sprintf(g->Message, "%s hr=%x", MSG(COM_ERROR), e.Error());

goto error;
#endif // __WIN__
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class DllExport TYPVAL<PSZ>: public VALUE {
virtual void Reset(void) {*Strp = 0;}
virtual int GetValLen(void) {return Len;};
virtual int GetValPrec() {return (Ci) ? 1 : 0;}
virtual int GetSize(void) {return (Strp) ? strlen(Strp) : 0;}
virtual int GetSize(void) {return (Strp) ? (int)strlen(Strp) : 0;}
virtual PSZ GetCharValue(void) {return Strp;}
virtual char GetTinyValue(void);
virtual uchar GetUTinyValue(void);
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/xindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ bool XHUGE::Read(PGLOBAL g, void *buf, int n, int size)
} // endif nbr

} else {
char *buf[256];
char buf[256];
DWORD drc = GetLastError();

FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
Expand Down

0 comments on commit b2956b2

Please sign in to comment.