summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2016-05-05 01:03:26 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2016-05-05 01:03:26 +0200
commit80a204f27e91629a97a5d41e06bc8e4128a4ae86 (patch)
tree6d7212f105a3ff633aae64fd36137b92f850c1b4
parentbbdeb911b85ad10ae4a13308492e541384ec9889 (diff)
downloadmariadb-git-80a204f27e91629a97a5d41e06bc8e4128a4ae86.tar.gz
- Try to fix MDEV-9950 (not tested yet)
modified: storage/connect/ha_connect.cc modified: storage/connect/plgdbutl.cpp - Fix Mdev-9997 (Sergey Vojtovitch) modified: storage/connect/inihandl.c - Try to have the JDBC type compiled by CMake modified: storage/connect/CMakeLists.txt - Fixing some bugs in the JDBC table type Use the CONNECTION option for the URL modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/jdbconn.h modified: storage/connect/tabjdbc.cpp - Add the JdbcInterface.class to the project new file: storage/connect/JdbcInterface.class
-rw-r--r--storage/connect/CMakeLists.txt12
-rw-r--r--storage/connect/JdbcInterface.classbin0 -> 15117 bytes
-rw-r--r--storage/connect/JdbcInterface.java2
-rw-r--r--storage/connect/ha_connect.cc19
-rw-r--r--storage/connect/inihandl.c7
-rw-r--r--storage/connect/jdbconn.cpp84
-rw-r--r--storage/connect/jdbconn.h2
-rw-r--r--storage/connect/plgdbutl.cpp29
-rw-r--r--storage/connect/tabjdbc.cpp16
9 files changed, 90 insertions, 81 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt
index 80a5b3bdc60..f4bcbfa9ade 100644
--- a/storage/connect/CMakeLists.txt
+++ b/storage/connect/CMakeLists.txt
@@ -268,12 +268,14 @@ IF(CONNECT_WITH_JDBC)
# TODO: Find how to compile and install the JdbcInterface.java class
# Find required libraries and include directories
- FIND_PACKAGE(JAVA)
- FIND_PACKAGE(JNI)
+ FIND_PACKAGE(Java REQUIRED)
+ FIND_PACKAGE(JNI REQUIRED)
IF (JAVA_FOUND AND JNI_FOUND)
- INCLUDE_DIRECTORIES(${JNI_INCLUDE_DIR})
- SET(JNI_LIBRARY ${JNI_LIBRARIES})
- SET(CONNECT_SOURCES ${CONNECT_SOURCES} JdbcInterface.java
+ INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
+ INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
+ SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY})
+ SET(CONNECT_SOURCES ${CONNECT_SOURCES}
+ JdbcInterface.java JdbcInterface.class
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h)
add_definitions(-DJDBC_SUPPORT)
ELSE()
diff --git a/storage/connect/JdbcInterface.class b/storage/connect/JdbcInterface.class
new file mode 100644
index 00000000000..816f575212b
--- /dev/null
+++ b/storage/connect/JdbcInterface.class
Binary files differ
diff --git a/storage/connect/JdbcInterface.java b/storage/connect/JdbcInterface.java
index 97f86b55a2c..5e01516d0cb 100644
--- a/storage/connect/JdbcInterface.java
+++ b/storage/connect/JdbcInterface.java
@@ -536,7 +536,7 @@ public class JdbcInterface {
System.out.println("No result set");
} else try {
BigDecimal bigDecimal = (n > 0) ? rs.getBigDecimal(n) : rs.getBigDecimal(name);
- return bigDecimal != null ? bigDecimal.longValue() : null;
+ return bigDecimal != null ? bigDecimal.longValue() : 0;
} catch (SQLException se) {
System.out.println(se);
} //end try/catch
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index 9f75d3bf54b..caa07c8cf88 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -190,6 +190,12 @@ extern "C" {
} // extern "C"
#endif // XMSG
+#if defined(__WIN__)
+CRITICAL_SECTION parsec; // Used calling the Flex parser
+#else // !__WIN__
+pthread_mutex_t parmut;
+#endif // !__WIN__
+
/***********************************************************************/
/* Utility functions. */
/***********************************************************************/
@@ -634,6 +640,7 @@ static int connect_init_func(void *p)
#if defined(__WIN__)
sql_print_information("CONNECT: %s", compver);
+ InitializeCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__
sql_print_information("CONNECT: %s", version);
#endif // !__WIN__
@@ -678,8 +685,10 @@ static int connect_done_func(void *)
XmlCleanupParserLib();
#endif // LIBXML2_SUPPORT
-#if !defined(__WIN__)
-//PROFILE_End(); Causes signal 11
+#if defined(__WIN__)
+ DeleteCriticalSection((LPCRITICAL_SECTION)&parsec);
+#else // !__WIN__
+ PROFILE_End();
#endif // !__WIN__
for (pc= user_connect::to_users; pc; pc= pn) {
@@ -5172,7 +5181,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
spc= (!sep) ? ',' : *sep;
qch= topt->qchar ? *topt->qchar : (signed)topt->quoted >= 0 ? '"' : 0;
hdr= (int)topt->header;
- tbl= topt->tablist;
+ tbl= topt->tablist;
col= topt->colist;
if (topt->oplist) {
@@ -5305,8 +5314,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case TAB_JDBC:
if (fnc & FNC_DRIVER) {
ok= true;
- } else if (!url) {
- strcpy(g->Message, "Missing URL");
+ } else if (!url && !(url= strz(g, create_info->connect_string))) {
+ strcpy(g->Message, "Missing URL");
} else {
// Store ODBC additional parameters
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
diff --git a/storage/connect/inihandl.c b/storage/connect/inihandl.c
index 542b807f899..46102557b20 100644
--- a/storage/connect/inihandl.c
+++ b/storage/connect/inihandl.c
@@ -622,13 +622,16 @@ void PROFILE_End(void)
if (trace)
htrc("PROFILE_End: CurProfile=%p N=%d\n", CurProfile, N_CACHED_PROFILES);
+ if (!CurProfile) // Sergey Vojtovich
+ return;
+
/* Close all opened files and free the cache structure */
for (i = 0; i < N_CACHED_PROFILES; i++) {
if (trace)
htrc("MRU=%s i=%d\n", SVP(MRUProfile[i]->filename), i);
- CurProfile = MRUProfile[i];
- PROFILE_ReleaseFile();
+// CurProfile = MRUProfile[i]; Sergey Vojtovich
+// PROFILE_ReleaseFile(); see MDEV-9997
free(MRUProfile[i]);
} // endfor i
diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp
index cf744971c9e..4ad491951a7 100644
--- a/storage/connect/jdbconn.cpp
+++ b/storage/connect/jdbconn.cpp
@@ -741,32 +741,33 @@ JDBConn::JDBConn(PGLOBAL g, TDBJDBC *tdbp)
// } // end of ~JDBConn
-#if 0
/***********************************************************************/
/* Screen for errors. */
/***********************************************************************/
-bool JDBConn::Check(RETCODE rc)
+char *JDBConn::Check(void)
{
- switch (rc) {
- case SQL_SUCCESS_WITH_INFO:
- if (trace) {
- DJX x(rc);
-
- if (x.BuildErrorMessage(this, m_hstmt))
- htrc("JDBC Success With Info, hstmt=%p %s\n",
- m_hstmt, x.GetErrorMessage(0));
-
- } // endif trace
+ if (env->ExceptionCheck()) {
+ char *msg;
+ jthrowable exc = env->ExceptionOccurred();
+ jmethodID tid = env->GetMethodID(env->FindClass("java/lang/Object"),
+ "toString", "()Ljava/lang/String;");
+
+ if (exc != nullptr && tid != nullptr) {
+ jstring s = (jstring)env->CallObjectMethod(exc, tid);
+ const char *utf = env->GetStringUTFChars(s, (jboolean)false);
+ env->DeleteLocalRef(s);
+ msg = PlugDup(m_G, utf);
+ } else
+ msg = "Exception occured";
- // Fall through
- case SQL_SUCCESS:
- case SQL_NO_DATA_FOUND:
- return true;
- } // endswitch rc
+ env->ExceptionClear();
+ return msg;
+ } // endif Check
- return false;
+ return NULL;
} // end of Check
+#if 0
/***********************************************************************/
/* Utility routine. */
/***********************************************************************/
@@ -911,14 +912,10 @@ int JDBConn::Open(PSZ jpath, PJPARM sop)
rc = JNI_GetCreatedJavaVMs(jvms, 1, &jsz);
if (rc == JNI_OK && jsz == 1) {
- JavaVMAttachArgs args;
-
- args.version = JNI_VERSION_1_6;
- args.name = NULL;
- args.group = NULL;
jvm = jvms[0];
- rc = jvm->AttachCurrentThread((void**)&env, &args);
+ rc = jvm->AttachCurrentThread((void**)&env, nullptr);
} // endif rc
+
} // end of block
if (rc == JNI_OK)
@@ -1176,11 +1173,11 @@ void JDBConn::Close()
void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
{
PGLOBAL& g = m_G;
+ char *msg;
jint ctyp;
jlong dtv;
jstring cn, jn = nullptr;
jobject dob;
- jthrowable exc;
jmethodID fldid = nullptr;
if (rank == 0)
@@ -1191,14 +1188,8 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
ctyp = env->CallIntMethod(job, typid, rank, jn);
- if ((exc = env->ExceptionOccurred()) != nullptr) {
- jboolean isCopy = false;
- jmethodID tid = env->GetMethodID(env->FindClass("java/lang/Object"), "toString", "()Ljava/lang/String;");
- jstring s = (jstring)env->CallObjectMethod(exc, tid);
- const char* utf = env->GetStringUTFChars(s, &isCopy);
- sprintf(g->Message, "SetColumnValue: %s", utf);
- env->DeleteLocalRef(s);
- env->ExceptionClear();
+ if ((msg = Check())) {
+ sprintf(g->Message, "Getting ctyp: %s", msg);
longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
} // endif Check
@@ -1305,6 +1296,14 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
val->Reset();
} // endswitch Type
+ if ((msg = Check())) {
+ if (rank == 0)
+ env->DeleteLocalRef(jn);
+
+ sprintf(g->Message, "SetColumnValue: %s rank=%d ctyp=%d", msg, rank, (int)ctyp);
+ longjmp(g->jumper[g->jump_level], TYPE_AM_JDBC);
+ } // endif Check
+
if (rank == 0)
env->DeleteLocalRef(jn);
@@ -1467,6 +1466,7 @@ int JDBConn::ExecuteSQL(void)
bool JDBConn::SetParam(JDBCCOL *colp)
{
PGLOBAL& g = m_G;
+ char *msg;
int rc = false;
PVAL val = colp->GetValue();
jint n, i = (jint)colp->GetRank();
@@ -1477,7 +1477,6 @@ bool JDBConn::SetParam(JDBCCOL *colp)
jclass dat;
jobject datobj;
jstring jst = nullptr;
- jthrowable exc;
jmethodID dtc, setid = nullptr;
switch (val->GetType()) {
@@ -1531,7 +1530,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
setid = env->GetMethodID(jdi, "SetDoubleParm", "(ID)V");
if (setid == nullptr) {
- strcpy(g->Message, "Cannot fing method SetDoubleParm");
+ strcpy(g->Message, "Cannot find method SetDoubleParm");
return true;
} // endif setid
@@ -1565,16 +1564,10 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return true;
} // endswitch Type
- if ((exc = env->ExceptionOccurred()) != nullptr) {
- jboolean isCopy = false;
- jmethodID tid = env->GetMethodID(env->FindClass("java/lang/Object"), "toString", "()Ljava/lang/String;");
- jstring s = (jstring)env->CallObjectMethod(exc, tid);
- const char* utf = env->GetStringUTFChars(s, &isCopy);
- sprintf(g->Message, "SetParam: %s", utf);
- env->DeleteLocalRef(s);
- env->ExceptionClear();
+ if ((msg = Check())) {
+ sprintf(g->Message, "SetParam: col=%s msg=%s", colp->GetName(), msg);
rc = true;
- } // endif exc
+ } // endif msg
if (jst)
env->DeleteLocalRef(jst);
@@ -1987,7 +1980,6 @@ bool JDBConn::SetParam(JDBCCOL *colp)
} // endfor n
// Now fetch the result
- // Extended fetch cannot be used because of STRBLK's
for (i = 0; i < qrp->Maxres; i++) {
if ((rc = Fetch(0)) == 0)
break;
@@ -2001,7 +1993,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
} // endfor i
- if (rc == RC_OK)
+ if (rc > 0)
qrp->Truncated = true;
return i;
diff --git a/storage/connect/jdbconn.h b/storage/connect/jdbconn.h
index 0646fee845b..99720bf55d5 100644
--- a/storage/connect/jdbconn.h
+++ b/storage/connect/jdbconn.h
@@ -123,7 +123,7 @@ public:
// JDBC operations
protected:
-//bool Check(RETCODE rc);
+ char *Check(void);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg);
//void AllocConnect(DWORD dwOptions);
diff --git a/storage/connect/plgdbutl.cpp b/storage/connect/plgdbutl.cpp
index d70eeb32a04..799df7cfc51 100644
--- a/storage/connect/plgdbutl.cpp
+++ b/storage/connect/plgdbutl.cpp
@@ -46,9 +46,9 @@
#else // !__WIN__
#include <unistd.h>
#include <fcntl.h>
-#if defined(THREAD)
+//#if defined(THREAD)
#include <pthread.h>
-#endif // THREAD
+//#endif // THREAD
#include <stdarg.h>
#define BIGMEM 2147483647 // Max int value
#endif // !__WIN__
@@ -70,17 +70,6 @@
#include "rcmsg.h"
/***********************************************************************/
-/* Macro or external routine definition */
-/***********************************************************************/
-#if defined(THREAD)
-#if defined(__WIN__)
-extern CRITICAL_SECTION parsec; // Used calling the Flex parser
-#else // !__WIN__
-extern pthread_mutex_t parmut;
-#endif // !__WIN__
-#endif // THREAD
-
-/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
bool Initdone = false;
@@ -90,6 +79,12 @@ extern "C" {
extern char version[];
} // extern "C"
+#if defined(__WIN__)
+extern CRITICAL_SECTION parsec; // Used calling the Flex parser
+#else // !__WIN__
+extern pthread_mutex_t parmut;
+#endif // !__WIN__
+
// The debug trace used by the main thread
FILE *pfile = NULL;
@@ -702,21 +697,21 @@ PDTP MakeDateFormat(PGLOBAL g, PSZ dfmt, bool in, bool out, int flag)
/* Call the FLEX generated parser. In multi-threading mode the next */
/* instruction is included in an Enter/LeaveCriticalSection bracket. */
/*********************************************************************/
-#if defined(THREAD)
+ //#if defined(THREAD)
#if defined(__WIN__)
EnterCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__
pthread_mutex_lock(&parmut);
#endif // !__WIN__
-#endif // THREAD
+//#endif // THREAD
rc = fmdflex(pdp);
-#if defined(THREAD)
+//#if defined(THREAD)
#if defined(__WIN__)
LeaveCriticalSection((LPCRITICAL_SECTION)&parsec);
#else // !__WIN__
pthread_mutex_unlock(&parmut);
#endif // !__WIN__
-#endif // THREAD
+//#endif // THREAD
if (trace)
htrc("Done: in=%s out=%s rc=%d\n", SVP(pdp->InFmt), SVP(pdp->OutFmt), rc);
diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp
index 97168646ba0..ce73349d9f7 100644
--- a/storage/connect/tabjdbc.cpp
+++ b/storage/connect/tabjdbc.cpp
@@ -108,11 +108,17 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
{
Jpath = GetStringCatInfo(g, "Jpath", "");
Driver = GetStringCatInfo(g, "Driver", NULL);
- Desc = Url = GetStringCatInfo(g, "Url", NULL);
+ Desc = Url = GetStringCatInfo(g, "Connect", NULL);
if (!Url && !Catfunc) {
- sprintf(g->Message, "Missing URL for JDBC table %s", Name);
- return true;
+ // Look in the option list (deprecated)
+ Url = GetStringCatInfo(g, "Url", NULL);
+
+ if (!Url) {
+ sprintf(g->Message, "Missing URL for JDBC table %s", Name);
+ return true;
+ } // endif Url
+
} // endif Connect
Tabname = GetStringCatInfo(g, "Name",
@@ -198,7 +204,7 @@ int JDBCPARM::CheckSize(int rows)
if (Url && rows == 1) {
// Are we connected to a MySQL JDBC connector?
bool b = (!strncmp(Url, "jdbc:mysql:", 11) ||
- !strncmp(Url, "jdbc:mariadb:", 13));
+ !strncmp(Url, "jdbc:mariadb:", 13));
return b ? INT_MIN32 : rows;
} else
return rows;
@@ -1669,6 +1675,8 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
Ops.Url = tdp->Url;
Ops.User = tdp->Username;
Ops.Pwd = tdp->Password;
+ Ops.Fsize = 0;
+ Ops.Scrollable = false;
} // end of TDBJTB constructor
/***********************************************************************/