Commit aae67535 authored by Olivier Bertrand's avatar Olivier Bertrand

- MDEV-11051 place Java classes ApacheInterface and JdbcInterface into single jar file.

  Try to fix the INSTALL command.
  modified:   storage/connect/CMakeLists.txt

- Make some JDBC tests available on Windows
  modified:   storage/connect/mysql-test/connect/t/jdbc.test
  modified:   storage/connect/mysql-test/connect/t/jdbc_new.test
  added:      storage/connect/mysql-test/connect/t/windows.inc
parent 5884aa15
......@@ -20,25 +20,25 @@ SET(CONNECT_SOURCES
ha_connect.cc connect.cc user_connect.cc mycat.cc
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
array.cpp blkfil.cpp colblk.cpp csort.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamvct.cpp filamzip.cpp
filamap.cpp filamdbf.cpp filamfix.cpp filamtxt.cpp filamzip.cpp
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
reldef.cpp tabcol.cpp tabdos.cpp tabfix.cpp tabfmt.cpp tabjson.cpp table.cpp
tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp tabutil.cpp
tabvct.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp
array.h blkfil.h block.h catalog.h checklvl.h colblk.h connect.h csort.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamvct.h filamzip.h
engmsg.h filamap.h filamdbf.h filamfix.h filamtxt.h filamzip.h
filter.h global.h ha_connect.h inihandl.h json.h jsonudf.h maputil.h msgid.h
mycat.h myconn.h myutil.h os.h osutil.h plgcnx.h plgdbsem.h preparse.h reldef.h
resource.h tabcol.h tabdos.h tabfix.h tabfmt.h tabjson.h tabmul.h tabmysql.h
taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvct.h tabvir.h tabxcl.h
taboccur.h tabpivot.h tabsys.h tabtbl.h tabutil.h tabvir.h tabxcl.h
user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
#
# Definitions that are shared for all OSes
#
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT -DVCT_SUPPORT )
add_definitions( -DHUGE_SUPPORT -DZIP_SUPPORT -DPIVOT_SUPPORT )
#
......@@ -89,6 +89,18 @@ ELSE(NOT UNIX)
ENDIF(UNIX)
#
# VCT: the VEC format might be not supported in future versions
#
OPTION(CONNECT_WITH_VCT "Compile CONNECT storage engine with VCT support" ON)
IF(CONNECT_WITH_VCT)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} filamvct.cpp tabvct.cpp filamvct.h tabvct.h)
add_definitions(-DVCT_SUPPORT)
ENDIF(CONNECT_WITH_VCT)
#
# XML
#
......@@ -236,9 +248,9 @@ ENDIF(CONNECT_WITH_ODBC)
# JDBC
#
IF(APPLE)
OPTION(CONNECT_WITH_JDBC "some comment" OFF)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine without JDBC support" OFF)
ELSE()
OPTION(CONNECT_WITH_JDBC "some comment" ON)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
ENDIF()
IF(CONNECT_WITH_JDBC)
......@@ -252,12 +264,15 @@ IF(CONNECT_WITH_JDBC)
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h
JdbcInterface.java ApacheInterface.java MariadbInterface.java
MysqlInterface.java OracleInterface.java PostgresqlInterface.java)
MysqlInterface.java OracleInterface.java PostgresqlInterface.java
JavaWrappers.jar)
# TODO: Find how to compile and install the java wrapper classes
# Find required libraries and include directories
SET (JAVA_SOURCES JdbcInterface.java)
add_jar(JdbcInterface ${JAVA_SOURCES})
install_jar(JdbcInterface DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/JavaWrappers.jar
DESTINATION ${INSTALL_PLUGINDIR} COMPONENT connect-engine)
add_definitions(-DJDBC_SUPPORT)
ELSE()
SET(JDBC_LIBRARY "")
......
This diff was suppressed by a .gitattributes entry.
......@@ -220,6 +220,19 @@ public class JdbcInterface {
} // end of SetTimestampParm
public int SetNullParm(int i, int typ) {
int rc = 0;
try {
pstmt.setNull(i, typ);
} catch (Exception e) {
SetErrmsg(e);
rc = -1;
} // end try/catch
return rc;
} // end of SetNullParm
public int ExecutePrep() {
int n = -3;
......
......@@ -55,9 +55,8 @@
#if defined(__WIN__)
extern "C" HINSTANCE s_hModule; // Saved module handle
#else // !__WIN__
#endif // __WIN__
#define nullptr 0
#endif // !__WIN__
TYPCONV GetTypeConv();
int GetConvSize();
......@@ -1442,7 +1441,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
PGLOBAL& g = m_G;
bool rc = false;
PVAL val = colp->GetValue();
jint n, i = (jint)colp->GetRank();
jint n, jrc = 0, i = (jint)colp->GetRank();
jshort s;
jlong lg;
//jfloat f;
......@@ -1452,69 +1451,74 @@ bool JDBConn::SetParam(JDBCCOL *colp)
jstring jst = nullptr;
jmethodID dtc, setid = nullptr;
switch (val->GetType()) {
case TYPE_STRING:
if (gmID(g, setid, "SetStringParm", "(ILjava/lang/String;)V"))
if (val->GetNullable() && val->IsNull()) {
if (gmID(g, setid, "SetNullParm", "(II)I"))
return true;
jst = env->NewStringUTF(val->GetCharValue());
env->CallVoidMethod(job, setid, i, jst);
break;
case TYPE_INT:
if (gmID(g, setid, "SetIntParm", "(II)V"))
return true;
n = (jint)val->GetIntValue();
env->CallVoidMethod(job, setid, i, n);
break;
case TYPE_TINY:
case TYPE_SHORT:
if (gmID(g, setid, "SetShortParm", "(IS)V"))
return true;
jrc = env->CallIntMethod(job, setid, i, (jint)GetJDBCType(val->GetType()));
} else switch (val->GetType()) {
case TYPE_STRING:
if (gmID(g, setid, "SetStringParm", "(ILjava/lang/String;)V"))
return true;
s = (jshort)val->GetShortValue();
env->CallVoidMethod(job, setid, i, s);
break;
case TYPE_BIGINT:
if (gmID(g, setid, "SetBigintParm", "(IJ)V"))
return true;
jst = env->NewStringUTF(val->GetCharValue());
env->CallVoidMethod(job, setid, i, jst);
break;
case TYPE_INT:
if (gmID(g, setid, "SetIntParm", "(II)V"))
return true;
lg = (jlong)val->GetBigintValue();
env->CallVoidMethod(job, setid, i, lg);
break;
case TYPE_DOUBLE:
case TYPE_DECIM:
if (gmID(g, setid, "SetDoubleParm", "(ID)V"))
return true;
n = (jint)val->GetIntValue();
env->CallVoidMethod(job, setid, i, n);
break;
case TYPE_TINY:
case TYPE_SHORT:
if (gmID(g, setid, "SetShortParm", "(IS)V"))
return true;
d = (jdouble)val->GetFloatValue();
env->CallVoidMethod(job, setid, i, d);
break;
case TYPE_DATE:
if ((dat = env->FindClass("java/sql/Timestamp")) == nullptr) {
strcpy(g->Message, "Cannot find Timestamp class");
return true;
} else if (!(dtc = env->GetMethodID(dat, "<init>", "(J)V"))) {
strcpy(g->Message, "Cannot find Timestamp class constructor");
return true;
} // endif's
s = (jshort)val->GetShortValue();
env->CallVoidMethod(job, setid, i, s);
break;
case TYPE_BIGINT:
if (gmID(g, setid, "SetBigintParm", "(IJ)V"))
return true;
lg = (jlong)val->GetBigintValue() * 1000;
lg = (jlong)val->GetBigintValue();
env->CallVoidMethod(job, setid, i, lg);
break;
case TYPE_DOUBLE:
case TYPE_DECIM:
if (gmID(g, setid, "SetDoubleParm", "(ID)V"))
return true;
if ((datobj = env->NewObject(dat, dtc, lg)) == nullptr) {
strcpy(g->Message, "Cannot make Timestamp object");
return true;
} else if (gmID(g, setid, "SetTimestampParm", "(ILjava/sql/Timestamp;)V"))
d = (jdouble)val->GetFloatValue();
env->CallVoidMethod(job, setid, i, d);
break;
case TYPE_DATE:
if ((dat = env->FindClass("java/sql/Timestamp")) == nullptr) {
strcpy(g->Message, "Cannot find Timestamp class");
return true;
} else if (!(dtc = env->GetMethodID(dat, "<init>", "(J)V"))) {
strcpy(g->Message, "Cannot find Timestamp class constructor");
return true;
} // endif's
lg = (jlong)val->GetBigintValue() * 1000;
if ((datobj = env->NewObject(dat, dtc, lg)) == nullptr) {
strcpy(g->Message, "Cannot make Timestamp object");
return true;
} else if (gmID(g, setid, "SetTimestampParm", "(ILjava/sql/Timestamp;)V"))
return true;
env->CallVoidMethod(job, setid, i, datobj);
break;
default:
sprintf(g->Message, "Parm type %d not supported", val->GetType());
return true;
} // endswitch Type
env->CallVoidMethod(job, setid, i, datobj);
break;
default:
sprintf(g->Message, "Parm type %d not supported", val->GetType());
return true;
} // endswitch Type
if (Check()) {
if (Check(jrc)) {
sprintf(g->Message, "SetParam: col=%s msg=%s", colp->GetName(), Msg);
rc = true;
} // endif msg
......
......@@ -9,8 +9,7 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
#json_udf_bin : broken upstream in --ps (fixed)
jdbc : Variable settings depend on machine configuration
jdbc_new : Variable settings depend on machine configuration
#jdbc : Variable settings depend on machine configuration
#jdbc_new : Variable settings depend on machine configuration
jdbc_oracle : Variable settings depend on machine configuration
jdbc_postgresql : Variable settings depend on machine configuration
......@@ -56,7 +56,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
SELECT * FROM t1;
a b
0 NULL
NULL NULL
0 test00
1 test01
2 test02
......@@ -72,7 +72,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC `TABNAME`='t1'
SELECT * FROM t1;
a b
0 NULL
NULL NULL
0 test00
1 test01
2 test02
......@@ -104,7 +104,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
SELECT * FROM t1;
a b
0 NULL
NULL NULL
0 0
1 0
2 0
......
-- source windows.inc
-- source jdbconn.inc
SET GLOBAL time_zone='+1:00';
......
......@@ -5,6 +5,7 @@ connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connection master;
-- source windows.inc
-- source jdbconn.inc
connection slave;
......
if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") = 0`)
{
skip Need windows;
}
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