Commit 6aa163bc authored by Olivier Bertrand's avatar Olivier Bertrand

- Continue working on the JDBC table type

  Suppress the jpath option
  add the connect_jvm_path and connect_class_path global variables
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jdbccat.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h
  modified:   storage/connect/tabjdbc.cpp
  modified:   storage/connect/tabjdbc.h

- Add the envar UDF
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/jsonudf.h

- Fix MDEV-9950
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/plgdbutl.cpp
parent 2323cf00
...@@ -193,12 +193,13 @@ extern "C" { ...@@ -193,12 +193,13 @@ extern "C" {
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
char *JvmPath; char *JvmPath;
char *ClassPath;
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
#if defined(__WIN__) #if defined(__WIN__)
CRITICAL_SECTION parsec; // Used calling the Flex parser CRITICAL_SECTION parsec; // Used calling the Flex parser
#else // !__WIN__ #else // !__WIN__
pthread_mutex_t parmut; pthread_mutex_t parmut = PTHREAD_MUTEX_INITIALIZER;
#endif // !__WIN__ #endif // !__WIN__
/***********************************************************************/ /***********************************************************************/
...@@ -5156,7 +5157,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5156,7 +5157,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
PJPARM sjp= NULL; PJPARM sjp= NULL;
char *jpath= NULL;
char *driver= NULL; char *driver= NULL;
char *url= NULL; char *url= NULL;
char *tabtyp = NULL; char *tabtyp = NULL;
...@@ -5223,7 +5223,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5223,7 +5223,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
cnc= (!*ucnc || *ucnc == 'y' || *ucnc == 'Y' || atoi(ucnc) != 0); cnc= (!*ucnc || *ucnc == 'y' || *ucnc == 'Y' || atoi(ucnc) != 0);
#endif #endif
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
jpath= GetListOption(g, "Jpath", topt->oplist, NULL);
driver= GetListOption(g, "Driver", topt->oplist, NULL); driver= GetListOption(g, "Driver", topt->oplist, NULL);
url= GetListOption(g, "URL", topt->oplist, NULL); url= GetListOption(g, "URL", topt->oplist, NULL);
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL); tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
...@@ -5510,15 +5509,14 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5510,15 +5509,14 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case FNC_NO: case FNC_NO:
case FNC_COL: case FNC_COL:
if (src) { if (src) {
qrp= JDBCSrcCols(g, jpath, (char*)src, sjp); qrp= JDBCSrcCols(g, (char*)src, sjp);
src= NULL; // for next tests src= NULL; // for next tests
} else } else
qrp= JDBCColumns(g, jpath, shm, tab, NULL, qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
mxr, fnc == FNC_COL, sjp);
break; break;
case FNC_TABLE: case FNC_TABLE:
qrp= JDBCTables(g, dsn, shm, tab, tabtyp, mxr, true, sjp); qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
break; break;
#if 0 #if 0
case FNC_DSN: case FNC_DSN:
...@@ -5526,7 +5524,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5526,7 +5524,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break; break;
#endif // 0 #endif // 0
case FNC_DRIVER: case FNC_DRIVER:
qrp= JDBCDrivers(g, jpath, mxr, true); qrp= JDBCDrivers(g, mxr, true);
break; break;
default: default:
sprintf(g->Message, "invalid catfunc %s", fncn); sprintf(g->Message, "invalid catfunc %s", fncn);
...@@ -6853,6 +6851,12 @@ static MYSQL_SYSVAR_STR(jvm_path, JvmPath, ...@@ -6853,6 +6851,12 @@ static MYSQL_SYSVAR_STR(jvm_path, JvmPath,
"Path to the directory where is the JVM lib", "Path to the directory where is the JVM lib",
// check_jvm_path, update_jvm_path, // check_jvm_path, update_jvm_path,
NULL, NULL, NULL); NULL, NULL, NULL);
static MYSQL_SYSVAR_STR(class_path, ClassPath,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Java class path",
// check_class_path, update_class_path,
NULL, NULL, NULL);
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
...@@ -6873,7 +6877,10 @@ static struct st_mysql_sys_var* connect_system_variables[]= { ...@@ -6873,7 +6877,10 @@ static struct st_mysql_sys_var* connect_system_variables[]= {
MYSQL_SYSVAR(errmsg_dir_path), MYSQL_SYSVAR(errmsg_dir_path),
#endif // XMSG #endif // XMSG
MYSQL_SYSVAR(json_grp_size), MYSQL_SYSVAR(json_grp_size),
#if defined(JDBC_SUPPORT)
MYSQL_SYSVAR(jvm_path), MYSQL_SYSVAR(jvm_path),
MYSQL_SYSVAR(class_path),
#endif // JDBC_SUPPORT
NULL NULL
}; };
......
...@@ -21,9 +21,9 @@ typedef struct jdbc_parms { ...@@ -21,9 +21,9 @@ typedef struct jdbc_parms {
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop); char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK #endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info); //PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *jpath, char *db, char *table, PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table,
char *colpat, int maxres, bool info, PJPARM sop); char *colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *jpath, char *src, PJPARM sop); PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *jpath, char *db, char *tabpat, PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop); char *tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, char *jpath, int maxres, bool info); PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
This diff is collapsed.
...@@ -32,15 +32,6 @@ ...@@ -32,15 +32,6 @@
typedef unsigned char *PUCHAR; typedef unsigned char *PUCHAR;
#endif // !__WIN__ #endif // !__WIN__
// Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1
//efine SQL_FIELD_FLAG_NULL 0x2
// Update options flags
//efine SQL_SETPOSUPDATES 0x0001
//efine SQL_POSITIONEDSQL 0x0002
//efine SQL_GDBOUND 0x0004
enum JCATINFO { enum JCATINFO {
CAT_TAB = 1, // JDBC Tables CAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns CAT_COL = 2, // JDBC Columns
...@@ -82,7 +73,7 @@ class JDBConn : public BLOCK { ...@@ -82,7 +73,7 @@ class JDBConn : public BLOCK {
public: public:
JDBConn(PGLOBAL g, TDBJDBC *tdbp); JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PSZ jpath, PJPARM sop); int Open(PJPARM sop);
int Rewind(char *sql); int Rewind(char *sql);
void Close(void); void Close(void);
PQRYRES AllocateResult(PGLOBAL g); PQRYRES AllocateResult(PGLOBAL g);
......
...@@ -5027,3 +5027,30 @@ void json_serialize_deinit(UDF_INIT* initid) ...@@ -5027,3 +5027,30 @@ void json_serialize_deinit(UDF_INIT* initid)
{ {
JsonFreeMem((PGLOBAL)initid->ptr); JsonFreeMem((PGLOBAL)initid->ptr);
} // end of json_serialize_deinit } // end of json_serialize_deinit
/*********************************************************************************/
/* Utility function returning an environment variable value. */
/*********************************************************************************/
my_bool envar_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
if (args->arg_count != 1) {
strcpy(message, "Unique argument must be an environment variable name");
return true;
} else
return false;
} // end of envar_init
char *envar(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *)
{
char *str, name[256];
int n = MY_MIN(args->lengths[0], sizeof(name) - 1);
memcpy(name, args->args[0], n);
name[n] = 0;
str = getenv(name);
*res_length = (str) ? strlen(str) : 0;
return str;
} // end of envar
...@@ -218,8 +218,12 @@ extern "C" { ...@@ -218,8 +218,12 @@ extern "C" {
DllExport my_bool json_serialize_init(UDF_INIT*, UDF_ARGS*, char*); DllExport my_bool json_serialize_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *json_serialize(UDF_EXEC_ARGS); DllExport char *json_serialize(UDF_EXEC_ARGS);
DllExport void json_serialize_deinit(UDF_INIT*); DllExport void json_serialize_deinit(UDF_INIT*);
DllExport my_bool envar_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *envar(UDF_EXEC_ARGS);
} // extern "C" } // extern "C"
/*********************************************************************************/ /*********************************************************************************/
/* Structure JPN. Used to make the locate path. */ /* Structure JPN. Used to make the locate path. */
/*********************************************************************************/ /*********************************************************************************/
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 1998-2015 */ /* (C) Copyright to the author Olivier BERTRAND 1998-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
......
...@@ -95,7 +95,7 @@ bool ExactInfo(void); ...@@ -95,7 +95,7 @@ bool ExactInfo(void);
/***********************************************************************/ /***********************************************************************/
JDBCDEF::JDBCDEF(void) JDBCDEF::JDBCDEF(void)
{ {
Jpath = Driver = Url = Tabname = Tabschema = Username = NULL; Driver = Url = Tabname = Tabschema = Username = NULL;
Password = Tabcat = Tabtype = Srcdef = Qchar = Qrystr = Sep = NULL; Password = Tabcat = Tabtype = Srcdef = Qchar = Qrystr = Sep = NULL;
Options = Quoted = Maxerr = Maxres = Memory = 0; Options = Quoted = Maxerr = Maxres = Memory = 0;
Scrollable = Xsrc = false; Scrollable = Xsrc = false;
...@@ -106,7 +106,6 @@ JDBCDEF::JDBCDEF(void) ...@@ -106,7 +106,6 @@ JDBCDEF::JDBCDEF(void)
/***********************************************************************/ /***********************************************************************/
bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{ {
Jpath = GetStringCatInfo(g, "Jpath", "");
Driver = GetStringCatInfo(g, "Driver", NULL); Driver = GetStringCatInfo(g, "Driver", NULL);
Desc = Url = GetStringCatInfo(g, "Connect", NULL); Desc = Url = GetStringCatInfo(g, "Connect", NULL);
...@@ -222,7 +221,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp) ...@@ -222,7 +221,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Cnp = NULL; Cnp = NULL;
if (tdp) { if (tdp) {
Jpath = tdp->Jpath;
Ops.Driver = tdp->Driver; Ops.Driver = tdp->Driver;
Ops.Url = tdp->Url; Ops.Url = tdp->Url;
TableName = tdp->Tabname; TableName = tdp->Tabname;
...@@ -241,7 +239,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp) ...@@ -241,7 +239,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Memory = tdp->Memory; Memory = tdp->Memory;
Ops.Scrollable = tdp->Scrollable; Ops.Scrollable = tdp->Scrollable;
} else { } else {
Jpath = NULL;
TableName = NULL; TableName = NULL;
Schema = NULL; Schema = NULL;
Ops.Driver = NULL; Ops.Driver = NULL;
...@@ -286,7 +283,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp) ...@@ -286,7 +283,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp)
{ {
Jcp = tdbp->Jcp; // is that right ? Jcp = tdbp->Jcp; // is that right ?
Cnp = tdbp->Cnp; Cnp = tdbp->Cnp;
Jpath = tdbp->Jpath;
TableName = tdbp->TableName; TableName = tdbp->TableName;
Schema = tdbp->Schema; Schema = tdbp->Schema;
Ops = tdbp->Ops; Ops = tdbp->Ops;
...@@ -684,7 +680,7 @@ int TDBJDBC::Cardinality(PGLOBAL g) ...@@ -684,7 +680,7 @@ int TDBJDBC::Cardinality(PGLOBAL g)
char qry[96], tbn[64]; char qry[96], tbn[64];
JDBConn *jcp = new(g)JDBConn(g, this); JDBConn *jcp = new(g)JDBConn(g, this);
if (jcp->Open(Jpath, &Ops) == RC_FX) if (jcp->Open(&Ops) == RC_FX)
return -1; return -1;
// Table name can be encoded in UTF-8 // Table name can be encoded in UTF-8
...@@ -795,7 +791,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g) ...@@ -795,7 +791,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
else if (Jcp->IsOpen()) else if (Jcp->IsOpen())
Jcp->Close(); Jcp->Close();
if (Jcp->Open(Jpath, &Ops) == RC_FX) if (Jcp->Open(&Ops) == RC_FX)
return true; return true;
else if (Quoted) else if (Quoted)
Quote = Jcp->GetQuoteChar(); Quote = Jcp->GetQuoteChar();
...@@ -1545,7 +1541,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g) ...@@ -1545,7 +1541,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
} else if (Jcp->IsOpen()) } else if (Jcp->IsOpen())
Jcp->Close(); Jcp->Close();
if (Jcp->Open(Jpath, &Ops) == RC_FX) if (Jcp->Open(&Ops) == RC_FX)
return true; return true;
Use = USE_OPEN; // Do it now in case we are recursively called Use = USE_OPEN; // Do it now in case we are recursively called
...@@ -1657,7 +1653,7 @@ void JSRCCOL::WriteColumn(PGLOBAL g) ...@@ -1657,7 +1653,7 @@ void JSRCCOL::WriteColumn(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJDRV::GetResult(PGLOBAL g) PQRYRES TDBJDRV::GetResult(PGLOBAL g)
{ {
return JDBCDrivers(g, Jpath, Maxres, false); return JDBCDrivers(g, Maxres, false);
} // end of GetResult } // end of GetResult
/* ---------------------------TDBJTB class --------------------------- */ /* ---------------------------TDBJTB class --------------------------- */
...@@ -1667,7 +1663,6 @@ PQRYRES TDBJDRV::GetResult(PGLOBAL g) ...@@ -1667,7 +1663,6 @@ PQRYRES TDBJDRV::GetResult(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp) TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
{ {
Jpath = tdp->Jpath;
Schema = tdp->Tabschema; Schema = tdp->Tabschema;
Tab = tdp->Tabname; Tab = tdp->Tabname;
Tabtype = tdp->Tabtype; Tabtype = tdp->Tabtype;
...@@ -1684,7 +1679,7 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp) ...@@ -1684,7 +1679,7 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJTB::GetResult(PGLOBAL g) PQRYRES TDBJTB::GetResult(PGLOBAL g)
{ {
return JDBCTables(g, Jpath, Schema, Tab, Tabtype, Maxres, false, &Ops); return JDBCTables(g, Schema, Tab, Tabtype, Maxres, false, &Ops);
} // end of GetResult } // end of GetResult
/* --------------------------TDBJDBCL class -------------------------- */ /* --------------------------TDBJDBCL class -------------------------- */
...@@ -1694,7 +1689,7 @@ PQRYRES TDBJTB::GetResult(PGLOBAL g) ...@@ -1694,7 +1689,7 @@ PQRYRES TDBJTB::GetResult(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJDBCL::GetResult(PGLOBAL g) PQRYRES TDBJDBCL::GetResult(PGLOBAL g)
{ {
return JDBCColumns(g, Jpath, Schema, Tab, NULL, Maxres, false, &Ops); return JDBCColumns(g, Schema, Tab, NULL, Maxres, false, &Ops);
} // end of GetResult } // end of GetResult
#if 0 #if 0
......
...@@ -31,7 +31,6 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */ ...@@ -31,7 +31,6 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
// Implementation // Implementation
virtual const char *GetType(void) { return "JDBC"; } virtual const char *GetType(void) { return "JDBC"; }
PSZ GetJpath(void) { return Jpath; }
PSZ GetTabname(void) { return Tabname; } PSZ GetTabname(void) { return Tabname; }
PSZ GetTabschema(void) { return Tabschema; } PSZ GetTabschema(void) { return Tabschema; }
PSZ GetTabcat(void) { return Tabcat; } PSZ GetTabcat(void) { return Tabcat; }
...@@ -48,7 +47,6 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */ ...@@ -48,7 +47,6 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
protected: protected:
// Members // Members
PSZ Jpath; /* Java class path */
PSZ Driver; /* JDBC driver */ PSZ Driver; /* JDBC driver */
PSZ Url; /* JDBC driver URL */ PSZ Url; /* JDBC driver URL */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
...@@ -130,7 +128,6 @@ class TDBJDBC : public TDBASE { ...@@ -130,7 +128,6 @@ class TDBJDBC : public TDBASE {
JDBCCOL *Cnp; // Points to count(*) column JDBCCOL *Cnp; // Points to count(*) column
JDBCPARM Ops; // Additional parameters JDBCPARM Ops; // Additional parameters
PSTRG Query; // Constructed SQL query PSTRG Query; // Constructed SQL query
char *Jpath; // Java class path
char *TableName; // Points to JDBC table name char *TableName; // Points to JDBC table name
char *Schema; // Points to JDBC table Schema char *Schema; // Points to JDBC table Schema
char *User; // User connect info char *User; // User connect info
...@@ -282,7 +279,7 @@ class JSRCCOL : public JDBCCOL { ...@@ -282,7 +279,7 @@ class JSRCCOL : public JDBCCOL {
class TDBJDRV : public TDBCAT { class TDBJDRV : public TDBCAT {
public: public:
// Constructor // Constructor
TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres; Jpath = tdp->Jpath;} TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres;}
protected: protected:
// Specific routines // Specific routines
...@@ -290,7 +287,6 @@ class TDBJDRV : public TDBCAT { ...@@ -290,7 +287,6 @@ class TDBJDRV : public TDBCAT {
// Members // Members
int Maxres; // Returned lines limit int Maxres; // Returned lines limit
char *Jpath; // Java class path
}; // end of class TDBJDRV }; // end of class TDBJDRV
/***********************************************************************/ /***********************************************************************/
...@@ -306,7 +302,6 @@ class TDBJTB : public TDBJDRV { ...@@ -306,7 +302,6 @@ class TDBJTB : public TDBJDRV {
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// Members // Members
char *Jpath; // Points to Java classpath
char *Schema; // Points to schema name or NULL char *Schema; // Points to schema name or NULL
char *Tab; // Points to JDBC table name or pattern char *Tab; // Points to JDBC table name or pattern
char *Tabtype; // Points to JDBC table type char *Tabtype; // Points to JDBC table type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment