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