Commit b6209dc5 authored by Olivier Bertrand's avatar Olivier Bertrand

- JAVA DEBUG now depends on connect_xtrace

  MySQL and MariaDB drivers use catalog for schema
  modified:   storage/connect/JdbcInterface.java

- Jdbc temporal fields now return time in seconds
  modified:   storage/connect/JdbcInterface.java
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jdbconn.h

- Recognize JDBC temporal types
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jdbconn.cpp

- Test validity of URL
  modified:   storage/connect/ApacheInterface.java
  modified:   storage/connect/JdbcInterface.java
  modified:   storage/connect/MariadbInterface.java
  modified:   storage/connect/MysqlInterface.java
  modified:   storage/connect/OracleInterface.java
  modified:   storage/connect/PostgresqlInterface.java

- Java class files are no more distributed
  A JdbcInterface.jar file is now compiled
  modified:   storage/connect/CMakeLists.txt
  deleted:    storage/connect/wrappers/ApacheInterface.class
  deleted:    storage/connect/wrappers/Client.class
  deleted:    storage/connect/wrappers/JdbcInterface.class
  deleted:    storage/connect/wrappers/MariadbInterface.class
  deleted:    storage/connect/wrappers/MysqlInterface.class
  deleted:    storage/connect/wrappers/OracleInterface.class
  deleted:    storage/connect/wrappers/PostgresqlInterface.class

- Try to find the JVM path using JAVA_HOME or registers (Windows)
  modified:   storage/connect/jdbconn.cpp

- Add Monty's patches
  modified:   storage/connect/connect.h
  modified:   storage/connect/csort.cpp
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jsonudf.cpp

-Change connect_java_wrapper variable from GLOBAL to SESSION
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/jdbconn.cpp

- Modify the tests to be able to run at least jdbc and jdbc_new
  modified:   storage/connect/mysql-test/connect/disabled.def
  modified:   storage/connect/mysql-test/connect/r/jdbc.result
  modified:   storage/connect/mysql-test/connect/r/jdbc_new.result
  modified:   storage/connect/mysql-test/connect/t/jdbc.test
  modified:   storage/connect/mysql-test/connect/t/jdbc_new.test
  modified:   storage/connect/mysql-test/connect/t/jdbconn.inc
  modified:   storage/connect/mysql-test/connect/t/jdbconn_cleanup.inc
  added:      storage/connect/mysql-test/connect/std_data/JdbcMariaDB.jar
parent fc905f15
......@@ -25,8 +25,7 @@ public class ApacheInterface extends JdbcInterface {
System.out.println("Connecting to Apache data source");
try {
if (url == null)
throw new Exception("URL cannot be null");
CheckURL(url, null);
if ((ds = pool.get(url)) == null) {
ds = new BasicDataSource();
......
......@@ -235,31 +235,25 @@ ENDIF(CONNECT_WITH_ODBC)
#
# JDBC
#
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON)
IF(CONNECT_WITH_JDBC)
# TODO: detect Java SDK and the presence of JDBC connectors
# TODO: Find how to compile and install the java wrapper class
# Find required libraries and include directories
FIND_PACKAGE(Java)
FIND_PACKAGE(Java 1.6)
FIND_PACKAGE(JNI)
IF (JAVA_FOUND AND JNI_FOUND)
# INCLUDE(UseJava) failed compile on buildbot Labrador
INCLUDE(UseJava)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY})
# SET(JDBC_LIBRARY ${JAVA_JVM_LIBRARY}) will be dynamically linked
SET(CONNECT_SOURCES ${CONNECT_SOURCES}
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h
JdbcInterface.java wrappers/JdbcInterface.class
ApacheInterface.java wrappers/ApacheInterface.class
MariadbInterface.java wrappers/MariadbInterface.class
MysqlInterface.java wrappers/MysqlInterface.class
OracleInterface.java wrappers/OracleInterface.class
PostgresqlInterface.java wrappers/PostgresqlInterface.class)
# SET (JAVA_SOURCES JdbcInterface.java)
# add_jar(JdbcInterface ${JAVA_SOURCES})
JdbcInterface.java ApacheInterface.java MariadbInterface.java
MysqlInterface.java OracleInterface.java PostgresqlInterface.java)
SET (JAVA_SOURCES JdbcInterface.java)
add_jar(JdbcInterface ${JAVA_SOURCES})
# install_jar(JdbcInterface ${INSTALL_PLUGIN_DIR} COMPONENT CONNECT)
add_definitions(-DJDBC_SUPPORT)
ELSE()
SET(JDBC_LIBRARY "")
......
......@@ -13,6 +13,7 @@ public class JdbcInterface {
static Hashtable<String,DataSource> dst = null;
boolean DEBUG = false;
boolean CatisSchema = false;
String Errmsg = "No error";
Connection conn = null;
DatabaseMetaData dbmd = null;
......@@ -23,7 +24,7 @@ public class JdbcInterface {
// === Constructors/finalize =========================================
public JdbcInterface() {
this(true);
this(false);
} // end of default constructor
public JdbcInterface(boolean b) {
......@@ -43,6 +44,22 @@ public class JdbcInterface {
Errmsg = "No error";
return err;
} // end of GetErrmsg
protected void CheckURL(String url, String vendor) throws Exception {
if (url == null)
throw new Exception("URL cannot be null");
String[] tk = url.split(":", 3);
if (!tk[0].equals("jdbc") || tk[1] == null)
throw new Exception("Invalid URL");
if (vendor != null && !tk[1].equals(vendor))
throw new Exception("Wrong URL for this wrapper");
// Some drivers use Catalog as Schema
CatisSchema = tk[1].equals("mysql") || tk[1].equals("mariadb");
} // end of CatalogIsSchema
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
......@@ -63,6 +80,8 @@ public class JdbcInterface {
if (DEBUG)
System.out.println("URL=" + parms[1]);
CheckURL(parms[1], null);
if (parms[2] != null && !parms[2].isEmpty()) {
if (DEBUG)
......@@ -326,7 +345,11 @@ public class JdbcInterface {
try {
if (rs != null) rs.close();
rs = dbmd.getColumns(parms[0], parms[1], parms[2], parms[3]);
if (CatisSchema)
rs = dbmd.getColumns(parms[1], null, parms[2], parms[3]);
else
rs = dbmd.getColumns(parms[0], parms[1], parms[2], parms[3]);
if (rs != null) {
rsmd = rs.getMetaData();
......@@ -341,7 +364,7 @@ public class JdbcInterface {
} // end of GetColumns
public int GetTables(String[] parms) {
int ncol = 0;
int ncol = -1;
String[] typ = null;
if (parms[3] != null) {
......@@ -351,7 +374,11 @@ public class JdbcInterface {
try {
if (rs != null) rs.close();
rs = dbmd.getTables(parms[0], parms[1], parms[2], typ);
if (CatisSchema)
rs = dbmd.getTables(parms[1], null, parms[2], typ);
else
rs = dbmd.getTables(parms[0], parms[1], parms[2], typ);
if (rs != null) {
rsmd = rs.getMetaData();
......
......@@ -30,8 +30,7 @@ public class MariadbInterface extends JdbcInterface {
System.out.println("Connecting to MariaDB data source");
try {
if (url == null)
throw new Exception("URL cannot be null");
CheckURL(url, "mariadb");
if ((ds = dst.get(url)) == null) {
ads = new MariaDbDataSource();
......
......@@ -30,8 +30,7 @@ public class MysqlInterface extends JdbcInterface {
System.out.println("Connecting to MySQL data source");
try {
if (url == null)
throw new Exception("URL cannot be null");
CheckURL(url, "mysql");
if ((ds = dst.get(url)) == null) {
mds = new MysqlDataSource();
......
......@@ -30,8 +30,7 @@ public class OracleInterface extends JdbcInterface {
System.out.println("Connecting to Oracle data source");
try {
if (url == null)
throw new Exception("URL cannot be null");
CheckURL(url, "oracle");
if ((ds = dst.get(url)) == null) {
ods = new OracleDataSource();
......
......@@ -30,8 +30,7 @@ public class PostgresqlInterface extends JdbcInterface {
System.out.println("Connecting to Postgresql data source");
try {
if (url == null)
throw new Exception("URL cannot be null");
CheckURL(url, "postgresql");
if ((ds = dst.get(url)) == null) {
pds = new PoolingDataSource();
......
......@@ -65,7 +65,8 @@ class TDBDOX: public TDBDOS {
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*);
friend class ha_connect;
}; // end of class TDBDOX
TDBDOX() : TDBDOS((PGLOBAL)0, (PTDBDOS)0) {} /* Never called */
}; // end of class TDBDOX
class XKPDEF: public KPARTDEF {
friend class TDBDOX;
......
......@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier Bertrand 1995-2012 */
/* (C) Copyright to the author Olivier Bertrand 1995-2016 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
......@@ -721,8 +721,8 @@ int CSORT::Qsortc(void)
void CSORT::Qstc(int *base, int *max)
{
register int *i, *j, *jj, *lt, *eq, *gt, *mid;
int c, lo, hi, rc;
size_t zlo, zhi, cnm;
int c = 0, lo, hi, rc;
size_t zlo, zhi, cnm;
zlo = zhi = cnm = 0; // Avoid warning message
......@@ -774,8 +774,11 @@ void CSORT::Qstc(int *base, int *max)
/*****************************************************************/
/* Small group. Do special quicker processing. */
/*****************************************************************/
if ((rc = Qcompare(base, (i = base + 1))) > 0)
c = *base, *base = *i, *i = c;
if ((rc = Qcompare(base, (i = base + 1))) > 0) {
c = *base;
*base = *i;
*i = c;
} // endif rc
if (Pof)
Pof[base - Pex] = Pof[i - Pex] = (rc) ? 1 : 2;
......
......@@ -195,7 +195,6 @@ extern "C" {
#if defined(JDBC_SUPPORT)
char *JvmPath;
char *ClassPath;
char *Wrapper;
#endif // JDBC_SUPPORT
#if defined(__WIN__)
......@@ -211,7 +210,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
PQRYRES VirColumns(PGLOBAL g, bool info);
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info);
PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info);
int TranslateJDBCType(int stp, int prec, int& len, char& v);
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v);
void PushWarning(PGLOBAL g, THD *thd, int level);
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
const char *db, char *tab, const char *src, int port);
......@@ -332,6 +331,15 @@ static MYSQL_THDVAR_UINT(json_grp_size,
"max number of rows for JSON aggregate functions.",
NULL, NULL, JSONMAX, 1, INT_MAX, 1);
#if defined(JDBC_SUPPORT)
// Default java wrapper to use with JDBC tables
static MYSQL_THDVAR_STR(java_wrapper,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Java wrapper class name",
// check_class_path, update_class_path,
NULL, NULL, "wrappers/JdbcInterface");
#endif // JDBC_SUPPORT
#if defined(XMSG) || defined(NEWMSG)
const char *language_names[]=
{
......@@ -384,6 +392,12 @@ extern "C" const char *msglang(void)
return language_names[THDVAR(current_thd, msg_lang)];
} // end of msglang
#else // !XMSG && !NEWMSG
#if defined(JDBC_SUPPORT)
char *GetJavaWrapper(void)
{return connect_hton ? THDVAR(current_thd, java_wrapper) : "wrappers/JdbcInterface";}
#endif // JDBC_SUPPORT
extern "C" const char *msglang(void)
{
#if defined(FRENCH)
......@@ -1123,7 +1137,7 @@ bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef)
/****************************************************************************/
int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
{
ulonglong opval= NO_IVAL;
ulonglong opval= (ulonglong) NO_IVAL;
if (!options)
return idef;
......@@ -5633,6 +5647,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} else {
char *schem= NULL;
char *tn= NULL;
// Not a catalog table
if (!qrp->Nblin) {
......@@ -5649,7 +5664,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
typ= len= prec= dec= 0;
tm= NOT_NULL_FLAG;
cnm= (char*)"noname";
dft= xtra= key= fmt= NULL;
dft= xtra= key= fmt= tn= NULL;
v= ' ';
rem= NULL;
......@@ -5669,7 +5684,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
typ= crp->Kdata->GetIntValue(i);
v = (crp->Nulls) ? crp->Nulls[i] : 0;
break;
case FLD_PREC:
case FLD_TYPENAME:
tn= crp->Kdata->GetCharValue(i);
break;
case FLD_PREC:
// PREC must be always before LENGTH
len= prec= crp->Kdata->GetIntValue(i);
break;
......@@ -5713,8 +5731,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break;
case FLD_SCHEM:
#if defined(ODBC_SUPPORT)
if (ttp == TAB_ODBC && crp->Kdata) {
#if defined(ODBC_SUPPORT) || defined(JDBC_SUPPORT)
if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
sprintf(g->Message,
"Several %s tables found, specify DBNAME", tab);
......@@ -5724,7 +5742,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
schem= crp->Kdata->GetCharValue(i);
} // endif ttp
#endif // ODBC_SUPPORT
#endif // ODBC_SUPPORT || JDBC_SUPPORT
default:
break; // Ignore
} // endswitch Fld
......@@ -5777,7 +5795,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
int plgtyp;
// typ must be PLG type, not SQL type
if (!(plgtyp= TranslateJDBCType(typ, dec, prec, v))) {
if (!(plgtyp= TranslateJDBCType(typ, tn, dec, prec, v))) {
if (GetTypeConv() == TPC_SKIP) {
// Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)",
......@@ -6875,12 +6893,6 @@ static MYSQL_SYSVAR_STR(class_path, ClassPath,
"Java class path",
// check_class_path, update_class_path,
NULL, NULL, NULL);
static MYSQL_SYSVAR_STR(java_wrapper, Wrapper,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC,
"Java wrapper class",
// check_class_path, update_class_path,
NULL, NULL, "wrappers/JdbcInterface");
#endif // JDBC_SUPPORT
......
......@@ -6,6 +6,13 @@
/* This file contains the JDBC connection classes functions. */
/***********************************************************************/
#if defined(__WIN__)
// This is needed for RegGetValue
#define _WINVER 0x0601
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0601
#endif // __WIN__
/***********************************************************************/
/* Include relevant MariaDB header file. */
/***********************************************************************/
......@@ -55,7 +62,8 @@ extern "C" HINSTANCE s_hModule; // Saved module handle
int GetConvSize();
extern char *JvmPath; // The connect_jvm_path global variable value
extern char *ClassPath; // The connect_class_path global variable value
extern char *Wrapper; // The connect_java_wrapper global variable value
char *GetJavaWrapper(void); // The connect_java_wrapper variable value
/***********************************************************************/
/* Static JDBConn objects. */
......@@ -79,7 +87,7 @@ GETDEF JDBConn::GetDefaultJavaVMInitArgs = NULL;
#endif // !_DEBUG
// To avoid gcc warning
int TranslateJDBCType(int stp, int prec, int& len, char& v);
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v);
/***********************************************************************/
/* GetJDBCType: returns the SQL_TYPE corresponding to a PLG type. */
......@@ -107,7 +115,7 @@ static short GetJDBCType(int type)
/***********************************************************************/
/* TranslateJDBCType: translate a JDBC Type to a PLG type. */
/***********************************************************************/
int TranslateJDBCType(int stp, int prec, int& len, char& v)
int TranslateJDBCType(int stp, char *tn, int prec, int& len, char& v)
{
int type;
......@@ -139,17 +147,24 @@ int TranslateJDBCType(int stp, int prec, int& len, char& v)
case 8: // DOUBLE
type = TYPE_DOUBLE;
break;
case 93: // TIMESTAMP
case 93: // TIMESTAMP, DATETIME
type = TYPE_DATE;
len = 19 + ((prec) ? (prec+1) : 0);
v = 'S';
v = (tn && toupper(tn[0]) == 'T') ? 'S' : 'E';
break;
case 91: // TYPE_DATE
case 91: // DATE, YEAR
type = TYPE_DATE;
len = 10;
v = 'D';
if (!tn || toupper(tn[0]) != 'Y') {
len = 10;
v = 'D';
} else {
len = 4;
v = 'Y';
} // endif len
break;
case 92: // TYPE_TIME
case 92: // TIME
type = TYPE_DATE;
len = 8 + ((prec) ? (prec+1) : 0);
v = 'T';
......@@ -378,7 +393,9 @@ PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat, char *tabtyp,
if (info || !qrp)
return qrp;
if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp)))
// Tabpat cannot be null or empty for some drivers
if (!(cap = AllocCatInfo(g, CAT_TAB, db,
(tabpat && *tabpat) ? tabpat : PlugDup(g, "%"), qrp)))
return NULL;
cap->Pat = tabtyp;
......@@ -616,7 +633,7 @@ PQRYRES JDBCPrimaryKeys(PGLOBAL g, JDBConn *op, char *dsn, char *table)
} // end of JDBCPrimaryKeys
#endif // 0
/************************************************Wrapper***********************/
/***********************************************************************/
/* JDBConn construction/destruction. */
/***********************************************************************/
JDBConn::JDBConn(PGLOBAL g, TDBJDBC *tdbp)
......@@ -629,12 +646,13 @@ JDBConn::JDBConn(PGLOBAL g, TDBJDBC *tdbp)
job = nullptr; // The java wrapper class object
xqid = xuid = xid = grs = readid = fetchid = typid = errid = nullptr;
prepid = xpid = pcid = nullptr;
chrfldid = intfldid = dblfldid = fltfldid = datfldid = bigfldid = nullptr;
//m_LoginTimeout = DEFAULT_LOGIN_TIMEOUT;
chrfldid = intfldid = dblfldid = fltfldid = bigfldid = nullptr;
datfldid = timfldid = tspfldid = nullptr;
//m_LoginTimeout = DEFAULT_LOGIN_TIMEOUT;
//m_QueryTimeout = DEFAULT_QUERY_TIMEOUT;
//m_UpdateOptions = 0;
Msg = NULL;
m_Wrap = (tdbp && tdbp->WrapName) ? tdbp->WrapName : Wrapper;
m_Wrap = (tdbp && tdbp->WrapName) ? tdbp->WrapName : GetJavaWrapper();
if (!strchr(m_Wrap, '/')) {
// Add the wrapper package name
......@@ -821,10 +839,32 @@ bool JDBConn::GetJVM(PGLOBAL g)
char soname[512];
#if defined(__WIN__)
if (JvmPath)
if (JvmPath) {
strcat(strcpy(soname, JvmPath), "\\jvm.dll");
else
strcpy(soname, "jvm.dll");
} else if (getenv("JAVA_HOME")) {
strcpy(soname, getenv("JAVA_HOME"));
strcat(soname, "\\bin\\client\\jvm.dll");
} else {
// Try to find it through the registry
char version[16];
char javaKey[64] = "SOFTWARE\\JavaSoft\\Java Runtime Environment";
LONG rc;
DWORD BufferSize = 16;
strcpy(soname, "jvm.dll"); // In case it fails
if ((rc = RegGetValue(HKEY_LOCAL_MACHINE, javaKey, "CurrentVersion",
RRF_RT_ANY, NULL, (PVOID)&version, &BufferSize)) == ERROR_SUCCESS) {
strcat(strcat(javaKey, "\\"), version);
BufferSize = 512;
if ((rc = RegGetValue(HKEY_LOCAL_MACHINE, javaKey, "RuntimeLib",
RRF_RT_ANY, NULL, (PVOID)&soname, &BufferSize)) != ERROR_SUCCESS)
printf("rc=%ld\n", rc);
} // endif rc
} // endelse
// Load the desired shared library
if (!(LibJvm = LoadLibrary(soname))) {
......@@ -860,6 +900,8 @@ bool JDBConn::GetJVM(PGLOBAL g)
if (JvmPath)
strcat(strcpy(soname, JvmPath), "/libjvm.so");
else if (getenv("JAVA_HOME"))
strcat(strcpy(soname, getenv("JAVA_HOME")), "/bin/client/libjvm.so");
else
strcpy(soname, "libjvm.so");
......@@ -1340,31 +1382,22 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
break;
case 91: // DATE
case 92: // TIME
case 93: // TIMESTAMP
if (!gmID(g, datfldid, "TimestampField",
"(ILjava/lang/String;)Ljava/sql/Timestamp;")) {
dob = env->CallObjectMethod(job, datfldid, (jint)rank, jn);
if (dob) {
jclass jts = env->FindClass("java/sql/Timestamp");
if (env->ExceptionCheck()) {
val->Reset();
} else {
jmethodID getTime = env->GetMethodID(jts, "getTime", "()J");
if (getTime != nullptr) {
dtv = env->CallLongMethod(dob, getTime);
val->SetValue((int)(dtv / 1000));
} else
val->Reset();
} // endif check
if (!gmID(g, datfldid, "DateField", "(ILjava/lang/String;)I")) {
val->SetValue((int)env->CallIntMethod(job, datfldid, (jint)rank, jn));
} else
val->Reset();
} else
val->Reset();
break;
case 92: // TIME
if (!gmID(g, timfldid, "TimeField", "(ILjava/lang/String;)I")) {
val->SetValue((int)env->CallIntMethod(job, timfldid, (jint)rank, jn));
} else
val->Reset();
break;
case 93: // TIMESTAMP
if (!gmID(g, tspfldid, "TimestampField", "(ILjava/lang/String;)I")) {
val->SetValue((int)env->CallIntMethod(job, tspfldid, (jint)rank, jn));
} else
val->Reset();
......
......@@ -169,7 +169,9 @@ class JDBConn : public BLOCK {
jmethodID intfldid; // The IntField method ID
jmethodID dblfldid; // The DoubleField method ID
jmethodID fltfldid; // The FloatField method ID
jmethodID datfldid; // The TimestampField method ID
jmethodID datfldid; // The DateField method ID
jmethodID timfldid; // The TimeField method ID
jmethodID tspfldid; // The TimestampField method ID
jmethodID bigfldid; // The BigintField method ID
//DWORD m_LoginTimeout;
//DWORD m_QueryTimeout;
......
......@@ -1302,7 +1302,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj,
{
char fn[_MAX_PATH];
unsigned long i, k, m, n;
long fl= 0, j = -1;
long fl = 0, j = -1;
reslen = args->arg_count + 2;
......@@ -2126,7 +2126,7 @@ my_bool json_object_nonull_init(UDF_INIT *initid, UDF_ARGS *args,
char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *)
{
char *str= 0;
char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr;
if (!g->Xchk) {
......@@ -2699,7 +2699,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Xchk
if (!CheckMemory(g, initid, args, 2, false, false, true)) {
PJSON top= 0;
PJSON top = NULL;
PJVAL jvp;
PJSON jsp[2] = {NULL, NULL};
......@@ -4899,7 +4899,7 @@ char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
my_bool b = true;
PJSON jsp;
PJSNX jsx;
PJVAL jvp= 0;
PJVAL jvp = NULL;
PBSON bsp = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr;
PGLOBAL gb = GetMemPtr(g, args, 0);
......
......@@ -10,7 +10,7 @@
#
##############################################################################
#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
SET GLOBAL time_zone='+1:00';
CREATE DATABASE connect;
USE connect;
CREATE TABLE t2 (
......@@ -99,8 +100,8 @@ George San Jose 1981-08-10 2010-06-02
Sam Chicago 1979-11-22 2007-10-10
James Dallas 1992-05-13 2009-12-14
Bill Boston 1986-09-11 2008-02-10
Donald Atlanta 1999-04-01 2016-03-31
Mick New York 1980-01-20 2002-09-11
Donald Atlanta 1999-03-31 2016-03-30
Mick New York 1980-01-20 2002-09-10
Tom Seatle 2002-03-15 1970-01-01
DROP TABLE t3;
#
......@@ -167,8 +168,11 @@ serialno name sex title manager department secretary salary
00137 BROWNY 1 ENGINEER 40567 0319 12345 10500.00
73111 WHEELFOR 1 SALESMAN 70012 0318 24888 10030.00
00023 MARTIN 1 ENGINEER 40567 0319 12345 10000.00
#
# Option Driver is required to find the Driver class inside the executable jar file
#
USE test;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=emp CONNECTION='jdbc:mariadb://localhost:PORT/connect?user=root';
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=emp CONNECTION='jdbc:mariadb://localhost:PORT/connect?user=root' OPTION_LIST='Driver=org.mariadb.jdbc.Driver';
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
......@@ -180,7 +184,7 @@ t1 CREATE TABLE `t1` (
`department` char(4) NOT NULL,
`secretary` char(5) NOT NULL,
`salary` double(12,2) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mariadb://localhost:PORT/connect?user=root' `TABLE_TYPE`='JDBC' `TABNAME`='emp'
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mariadb://localhost:PORT/connect?user=root' `TABLE_TYPE`='JDBC' `TABNAME`='emp' `OPTION_LIST`='Driver=org.mariadb.jdbc.Driver'
SELECT * FROM t1;
serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
......@@ -260,10 +264,8 @@ DROP TABLE t2;
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables CONNECTION='jdbc:mariadb://localhost:PORT/connect' option_list='User=root,Maxres=50';
SELECT * FROM t1;
Table_Cat Table_Schema Table_Name Table_Type Remark
connect NULL tx1 BASE TABLE
connect NULL tx1 TABLE
DROP TABLE t1;
DROP TABLE connect.tx1;
DROP DATABASE connect;
SET GLOBAL connect_jvm_path=NULL;
SET GLOBAL connect_class_path=NULL;
SET GLOBAL time_zone = SYSTEM;
SET GLOBAL time_zone=SYSTEM;
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 (a int, b char(10));
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
SELECT * FROM t1;
......@@ -32,15 +33,13 @@ t1 CREATE TABLE `t1` (
`y` char(10) DEFAULT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
SELECT * FROM t1;
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'
Query is : SELECT x, y FROM t1' from CONNECT
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT
DROP TABLE t1;
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
ALTER TABLE t1 RENAME t1backup;
SELECT * FROM t1;
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Table 'test.t1' doesn't exist
Query is : SELECT a, b FROM t1' from CONNECT
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Table 'test.t1' doesn't exist' from CONNECT
ALTER TABLE t1backup RENAME t1;
DROP TABLE t1;
#
......@@ -201,16 +200,14 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` date DEFAULT NULL,
`b` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`b` datetime DEFAULT NULL,
`c` time DEFAULT NULL,
`d` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`e` date DEFAULT NULL
`d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`e` year(4) DEFAULT NULL
) 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 c d e
2003-05-27 2003-05-27 10:45:23 10:45:23 2003-05-27 10:45:23 1970-01-01
2003-05-27 2003-05-27 11:45:23 10:45:23 2003-05-27 10:45:23 2003
DROP TABLE t1;
DROP TABLE t1;
SET GLOBAL connect_jvm_path=NULL;
SET GLOBAL connect_class_path=NULL;
SET GLOBAL time_zone = SYSTEM;
SET GLOBAL time_zone=SYSTEM;
This diff was suppressed by a .gitattributes entry.
-- source jdbconn.inc
SET GLOBAL time_zone='+1:00';
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt
......@@ -102,9 +103,12 @@ CREATE TABLE emp (
ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1;
SELECT * FROM emp;
--echo #
--echo # Option Driver is required to find the Driver class inside the executable jar file
--echo #
USE test;
--replace_result $PORT PORT
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=emp CONNECTION='jdbc:mariadb://localhost:$PORT/connect?user=root'
--eval CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC TABNAME=emp CONNECTION='jdbc:mariadb://localhost:$PORT/connect?user=root' OPTION_LIST='Driver=org.mariadb.jdbc.Driver'
--replace_result $PORT PORT
--eval SHOW CREATE TABLE t1
SELECT * FROM t1;
......@@ -113,7 +117,7 @@ SELECT name, title, salary FROM t1 WHERE sex = 1;
DROP TABLE t1, connect.emp;
#
# Testing remote command execution
# Testing remote command execution (Driver option is no more necessary)
#
--replace_result $PORT PORT
--eval CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:$PORT/connect' OPTION_LIST='User=root,Execsrc=1'
......@@ -139,5 +143,5 @@ DROP TABLE connect.tx1;
--remove_file $MYSQLD_DATADIR/connect/employee.dat
DROP DATABASE connect;
--remove_file $MYSQLD_DATADIR/test/girls.txt
SET GLOBAL time_zone=SYSTEM;
-- source jdbconn_cleanup.inc
......@@ -8,6 +8,8 @@ connection master;
-- source jdbconn.inc
connection slave;
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 (a int, b char(10));
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
SELECT * FROM t1;
......@@ -173,6 +175,7 @@ DROP TABLE t1;
connection slave;
DROP TABLE t1;
SET GLOBAL time_zone=SYSTEM;
connection master;
-- source jdbconn_cleanup.inc
......
......@@ -12,19 +12,20 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES
}
DROP TABLE t1;
# This is specific and explains why this test is disabled.
# You should edit this file to reflect what is the required files location on your machine.
# You cand edit this file to reflect what is the required files location on your machine.
# This is the path to the JVM library (dll or so)
SET GLOBAL connect_jvm_path='C:\\Program Files\\Java\\jdk1.8.0_77\\jre\\bin\\client';
# If not set CONNECT will try to use the JAVA_HOME environment variable
# and if not found try to find it in the registers (Windows only)
#SET GLOBAL connect_jvm_path='C:\\Program Files\\Java\\jdk1.8.0_77\\jre\\bin\\client';
# The complete class path send when creating the Java Virtual Machine is, in that order:
# 1 - The current directory.
# 2 - The paths of the connect_class_path global variable.
# 3 - The paths of the CLASSPATH environment variable.
# These are the paths to the needed classes or jar files. The Apache ones are only for the JdbcApacheInterface wrapper.
SET GLOBAL connect_class_path='E:\\MariaDB-10.1\\Connect\\storage\\connect;E:\\MariaDB-10.1\\Connect\\sql\\data\\postgresql-9.4.1208.jar;E:\\Oracle\\ojdbc6.jar;E:\\Apache\\commons-dbcp2-2.1.1\\commons-dbcp2-2.1.1.jar;E:\\Apache\\commons-pool2-2.4.2\\commons-pool2-2.4.2.jar;E:\\Apache\\commons-logging-1.2\\commons-logging-1.2.jar';
# In this test we use an executable jar file that contains all what is needed.
eval SET GLOBAL connect_class_path='$MTR_SUITE_DIR/std_data/JdbcMariaDB.jar';
# On my machine, paths to the JDK classes and to the MySQL and MariaDB drivers are defined in the CLASSPATH environment variable
# Paths to the JDK classes and to the MySQL and MariaDB drivers can be defined in the CLASSPATH environment variable
#CREATE FUNCTION envar RETURNS STRING SONAME 'ha_connect.dll';
#SELECT envar('CLASSPATH');
......
--disable_query_log
--disable_warnings
#DROP FUNCTION envar;
SET GLOBAL connect_jvm_path=NULL;
SET GLOBAL connect_class_path=NULL;
SET GLOBAL time_zone = SYSTEM;
--enable_warnings
--enable_query_log
-- source jdbconn.inc
#
# List available drivers
#
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=drivers;
SELECT * FROM t1;
DROP TABLE t1;
#
# Clean up
#
-- source jdbconn_cleanup.inc
......@@ -1752,7 +1752,7 @@ bool ODBConn::BindParam(ODBCCOL *colp)
void *buf;
int buftype = colp->GetResultType();
SQLUSMALLINT n = colp->GetRank();
SQLSMALLINT ct, sqlt, dec, nul;
SQLSMALLINT ct, sqlt, dec, nul __attribute__((unused));
SQLULEN colsize;
SQLLEN len;
SQLLEN *strlen = colp->GetStrLen();
......
......@@ -687,7 +687,7 @@ bool TDBODBC::MakeCommand(PGLOBAL g)
} else {
sprintf(g->Message, "Cannot use this %s command",
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
return NULL;
return false;
} // endif p
Query = new(g) STRING(g, 0, stmt);
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
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