Commit 2323cf00 authored by Olivier Bertrand's avatar Olivier Bertrand

- Make the JVM lib dynamically loaded

  This makes the CONNECT storage engine usable when Java JDK is not installed.
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h

- Typo
  modified:   storage/connect/reldef.cpp
parent 025decfc
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
#include "jdbccat.h" #include "jdbccat.h"
#include "jdbconn.h"
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
#include "xtable.h" #include "xtable.h"
#include "tabmysql.h" #include "tabmysql.h"
...@@ -169,7 +170,7 @@ ...@@ -169,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.04.0006 March 12, 2016"; char version[]= "Version 1.04.0006 May 08, 2016";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__; char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
...@@ -190,6 +191,10 @@ extern "C" { ...@@ -190,6 +191,10 @@ extern "C" {
} // extern "C" } // extern "C"
#endif // XMSG #endif // XMSG
#if defined(JDBC_SUPPORT)
char *JvmPath;
#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__
...@@ -667,6 +672,9 @@ static int connect_init_func(void *p) ...@@ -667,6 +672,9 @@ static int connect_init_func(void *p)
DTVAL::SetTimeShift(); // Initialize time zone shift once for all DTVAL::SetTimeShift(); // Initialize time zone shift once for all
BINCOL::SetEndian(); // Initialize host endian setting BINCOL::SetEndian(); // Initialize host endian setting
#if defined(JDBC_SUPPORT)
JDBConn::SetJVM();
#endif // JDBC_SUPPORT
DBUG_RETURN(0); DBUG_RETURN(0);
} // end of connect_init_func } // end of connect_init_func
...@@ -685,6 +693,10 @@ static int connect_done_func(void *) ...@@ -685,6 +693,10 @@ static int connect_done_func(void *)
XmlCleanupParserLib(); XmlCleanupParserLib();
#endif // LIBXML2_SUPPORT #endif // LIBXML2_SUPPORT
#ifdef JDBC_SUPPORT
JDBConn::ResetJVM();
#endif // JDBC_SUPPORT
#if defined(__WIN__) #if defined(__WIN__)
DeleteCriticalSection((LPCRITICAL_SECTION)&parsec); DeleteCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__ #else // !__WIN__
...@@ -6835,6 +6847,15 @@ static MYSQL_SYSVAR_STR(errmsg_dir_path, msg_path, ...@@ -6835,6 +6847,15 @@ static MYSQL_SYSVAR_STR(errmsg_dir_path, msg_path,
"../../../../storage/connect/"); // for testing "../../../../storage/connect/"); // for testing
#endif // XMSG #endif // XMSG
#if defined(JDBC_SUPPORT)
static MYSQL_SYSVAR_STR(jvm_path, JvmPath,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Path to the directory where is the JVM lib",
// check_jvm_path, update_jvm_path,
NULL, NULL, NULL);
#endif // JDBC_SUPPORT
static struct st_mysql_sys_var* connect_system_variables[]= { static struct st_mysql_sys_var* connect_system_variables[]= {
MYSQL_SYSVAR(xtrace), MYSQL_SYSVAR(xtrace),
MYSQL_SYSVAR(conv_size), MYSQL_SYSVAR(conv_size),
...@@ -6852,6 +6873,7 @@ static struct st_mysql_sys_var* connect_system_variables[]= { ...@@ -6852,6 +6873,7 @@ 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),
MYSQL_SYSVAR(jvm_path),
NULL NULL
}; };
......
This diff is collapsed.
...@@ -60,6 +60,9 @@ typedef struct tagJCATPARM { ...@@ -60,6 +60,9 @@ typedef struct tagJCATPARM {
PUCHAR Pat; // Table type or column pattern PUCHAR Pat; // Table type or column pattern
} JCATPARM; } JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
typedef jint(JNICALL *GETJVM) (JavaVM **, jsize, jsize *);
// JDBC connection to a data source // JDBC connection to a data source
class TDBJDBC; class TDBJDBC;
class JDBCCOL; class JDBCCOL;
...@@ -114,8 +117,11 @@ class JDBConn : public BLOCK { ...@@ -114,8 +117,11 @@ class JDBConn : public BLOCK {
PQRYRES GetMetaData(PGLOBAL g, char *src); PQRYRES GetMetaData(PGLOBAL g, char *src);
public: public:
// Set special options // Set static variables
//void OnSetOptions(HSTMT hstmt); static void SetJVM(void)
{ LibJvm = NULL; CreateJavaVM = NULL; GetCreatedJavaVMs = NULL; }
static void ResetJVM(void);
static bool GetJVM(PGLOBAL g);
// Implementation // Implementation
public: public:
...@@ -126,15 +132,17 @@ class JDBConn : public BLOCK { ...@@ -126,15 +132,17 @@ class JDBConn : public BLOCK {
char *Check(void); char *Check(void);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/); //void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg); //void ThrowDJX(PSZ msg);
//void AllocConnect(DWORD dwOptions);
//void Connect(void);
//bool DriverConnect(DWORD Options);
//void VerifyConnect(void);
//void GetConnectInfo(void);
//void Free(void); //void Free(void);
protected: protected:
// Members // Members
#if defined(__WIN__)
static HANDLE LibJvm; // Handle to the jvm DLL
#else // !__WIN__
static void *LibJvm; // Handle for the jvm shared library
#endif // !__WIN__
static CRTJVM CreateJavaVM;
static GETJVM GetCreatedJavaVMs;
PGLOBAL m_G; PGLOBAL m_G;
TDBJDBC *m_Tdb; TDBJDBC *m_Tdb;
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine) JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
......
...@@ -514,9 +514,10 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) ...@@ -514,9 +514,10 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
} // endif getdef } // endif getdef
#else // !__WIN__ #else // !__WIN__
const char *error = NULL; const char *error = NULL;
Dl_info dl_info;
#if 0 // Don't know what all this stuff does #if 0 // Don't know what all this stuff does
Dl_info dl_info;
// The OEM lib must retrieve exported CONNECT variables // The OEM lib must retrieve exported CONNECT variables
if (dladdr(&connect_hton, &dl_info)) { if (dladdr(&connect_hton, &dl_info)) {
if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) { if (dlopen(dl_info.dli_fname, RTLD_NOLOAD | RTLD_NOW | RTLD_GLOBAL) == 0) {
......
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