Commit 2bd94951 authored by Sergei Golubchik's avatar Sergei Golubchik

Merge branch 'connect/10.0' into 10.0

1.04.0008
parents 077f29a9 a2934d27
package wrappers;
import java.sql.*;
import java.util.Hashtable;
import org.apache.commons.dbcp2.BasicDataSource;
public class ApacheInterface extends JdbcInterface {
static Hashtable<String,BasicDataSource> pool = new Hashtable<String, BasicDataSource>();
public ApacheInterface() {
this(true);
} // end of default constructor
public ApacheInterface(boolean b) {
super(b);
} // end of constructor
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
BasicDataSource ds = null;
if (DEBUG)
System.out.println("Connecting to Apache data source");
try {
CheckURL(url, null);
if ((ds = pool.get(url)) == null) {
ds = new BasicDataSource();
ds.setDriverClassName(parms[0]);
ds.setUrl(url);
ds.setUsername(parms[2]);
ds.setPassword(parms[3]);
pool.put(url, ds);
} // endif ds
// Get a connection from the data source
conn = ds.getConnection();
// Get the data base meta data object
dbmd = conn.getMetaData();
// Get a statement from the connection
stmt = GetStmt(fsize, scrollable);
} catch (SQLException se) {
SetErrmsg(se);
rc = -2;
} catch (Exception e) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of JdbcConnect
} // end of class ApacheInterface
...@@ -235,25 +235,29 @@ ENDIF(CONNECT_WITH_ODBC) ...@@ -235,25 +235,29 @@ ENDIF(CONNECT_WITH_ODBC)
# #
# JDBC # JDBC
# #
IF(APPLE)
OPTION(CONNECT_WITH_JDBC "Compile CONNECT storage engine with JDBC support" ON) OPTION(CONNECT_WITH_JDBC "some comment" OFF)
ELSE()
OPTION(CONNECT_WITH_JDBC "some comment" ON)
ENDIF()
IF(CONNECT_WITH_JDBC) 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 1.6) FIND_PACKAGE(Java 1.6)
FIND_PACKAGE(JNI) FIND_PACKAGE(JNI)
IF (JAVA_FOUND AND JNI_FOUND) IF (JAVA_FOUND AND JNI_FOUND)
INCLUDE(UseJava)
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH}) INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2}) 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} SET(CONNECT_SOURCES ${CONNECT_SOURCES}
JdbcInterface.java JdbcInterface.class jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h
JdbcDSInterface.java JdbcDSInterface.class JdbcInterface.java ApacheInterface.java MariadbInterface.java
JdbcApacheInterface.java JdbcApacheInterface.class MysqlInterface.java OracleInterface.java PostgresqlInterface.java)
jdbconn.cpp tabjdbc.cpp jdbconn.h tabjdbc.h jdbccat.h) # 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)
add_definitions(-DJDBC_SUPPORT) add_definitions(-DJDBC_SUPPORT)
ELSE() ELSE()
SET(JDBC_LIBRARY "") SET(JDBC_LIBRARY "")
......
package wrappers;
import java.io.BufferedReader;
import java.io.Console;
import java.io.IOException;
import java.io.InputStreamReader;
public class Client {
static boolean DEBUG = true;
static final Console c = System.console();
static JdbcInterface jdi = null;
public static void main(String[] args) {
int rc, n, ncol, i = 0, fsize = 0;
boolean scrollable = false;
String s;
String[] parms = new String[4];
if (args.length > 0)
try {
i = Integer.parseInt(args[i]);
} catch (NumberFormatException e) {
i = 0;
} // end try/catch
switch (i) {
case 1:
jdi = new ApacheInterface(DEBUG);
break;
case 2:
jdi = new MysqlInterface(DEBUG);
break;
case 3:
jdi = new MariadbInterface(DEBUG);
break;
case 4:
jdi = new OracleInterface(DEBUG);
break;
case 5:
jdi = new PostgresqlInterface(DEBUG);
break;
default:
jdi = new JdbcInterface(DEBUG);
} // endswitch i
parms[0] = getLine("Driver: ", false);
parms[1] = getLine("URL: ", false);
parms[2] = getLine("User: ", false);
parms[3] = getLine("Password: ", true);
s = getLine("Fsize: ", false);
fsize = (s != null) ? Integer.parseInt(s) : 0;
s = getLine("Scrollable: ", false);
scrollable = (s != null) ? s.toLowerCase().charAt(0) != 'n' : false;
rc = jdi.JdbcConnect(parms, fsize, scrollable);
if (rc == 0) {
String query;
System.out.println("Successfully connected to " + parms[1]);
while ((query = getLine("Query: ", false)) != null) {
n = jdi.Execute(query);
System.out.println("Returned n = " + n);
if ((ncol = jdi.GetResult()) > 0)
PrintResult(ncol);
else
System.out.println("Affected rows = " + n);
} // endwhile
rc = jdi.JdbcDisconnect();
System.out.println("Disconnect returned " + rc);
} else
System.out.println(jdi.GetErrmsg() + " rc=" + rc);
} // end of main
private static void PrintResult(int ncol) {
// Get result set meta data
int i;
String columnName;
// Get the column names; column indices start from 1
for (i = 1; i <= ncol; i++) {
columnName = jdi.ColumnName(i);
if (columnName == null)
return;
// Get the name of the column's table name
//String tableName = rsmd.getTableName(i);
if (i > 1)
System.out.print("\t");
System.out.print(columnName);
} // endfor i
System.out.println();
// Loop through the result set
while (jdi.ReadNext() > 0) {
for (i = 1; i <= ncol; i++) {
if (i > 1)
System.out.print("\t");
if (DEBUG)
System.out.print("(" + jdi.ColumnType(i, null) + ")");
switch (jdi.ColumnType(i, null)) {
case java.sql.Types.VARCHAR:
case java.sql.Types.LONGVARCHAR:
case java.sql.Types.CHAR:
System.out.print(jdi.StringField(i, null));
break;
case java.sql.Types.INTEGER:
System.out.print(jdi.IntField(i, null));
break;
case java.sql.Types.BIGINT:
System.out.print(jdi.BigintField(i, null));
break;
case java.sql.Types.TIMESTAMP:
System.out.print(jdi.TimestampField(i, null));
break;
case java.sql.Types.TIME:
System.out.print(jdi.TimeField(i, null));
break;
case java.sql.Types.DATE:
System.out.print(jdi.DateField(i, null));
break;
case java.sql.Types.SMALLINT:
System.out.print(jdi.IntField(i, null));
break;
case java.sql.Types.DOUBLE:
case java.sql.Types.REAL:
case java.sql.Types.FLOAT:
case java.sql.Types.DECIMAL:
System.out.print(jdi.DoubleField(i, null));
break;
case java.sql.Types.BOOLEAN:
System.out.print(jdi.BooleanField(i, null));
default:
break;
} // endswitch Type
} // endfor i
System.out.println();
} // end while rs
} // end of PrintResult
// ==================================================================
private static String getLine(String p, boolean b) {
String response;
if (c != null) {
// Standard console mode
if (b) {
response = new String(c.readPassword(p));
} else
response = c.readLine(p);
} else {
// For instance when testing from Eclipse
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print(p);
try {
// Cannot suppress echo for password entry
response = in.readLine();
} catch (IOException e) {
response = "";
} // end of try/catch
} // endif c
return (response.isEmpty()) ? null : response;
} // end of getLine
} // end of class Client
This diff is collapsed.
This diff is collapsed.
package wrappers;
import java.math.*; import java.math.*;
import java.sql.*; import java.sql.*;
//import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Hashtable;
import java.util.List; import java.util.List;
//import java.io.File;
//import java.lang.reflect.Field; import javax.sql.DataSource;
public class JdbcInterface { public class JdbcInterface {
// This is used by DS classes
static Hashtable<String,DataSource> dst = null;
boolean DEBUG = false; boolean DEBUG = false;
boolean CatisSchema = false;
String Errmsg = "No error"; String Errmsg = "No error";
Connection conn = null; Connection conn = null;
DatabaseMetaData dbmd = null; DatabaseMetaData dbmd = null;
...@@ -18,14 +24,14 @@ public class JdbcInterface { ...@@ -18,14 +24,14 @@ public class JdbcInterface {
// === Constructors/finalize ========================================= // === Constructors/finalize =========================================
public JdbcInterface() { public JdbcInterface() {
this(true); this(false);
} // end of default constructor } // end of default constructor
public JdbcInterface(boolean b) { public JdbcInterface(boolean b) {
DEBUG = b; DEBUG = b;
} // end of constructor } // end of constructor
private void SetErrmsg(Exception e) { protected void SetErrmsg(Exception e) {
if (DEBUG) if (DEBUG)
System.out.println(e.getMessage()); System.out.println(e.getMessage());
...@@ -38,6 +44,22 @@ public class JdbcInterface { ...@@ -38,6 +44,22 @@ public class JdbcInterface {
Errmsg = "No error"; Errmsg = "No error";
return err; return err;
} // end of GetErrmsg } // 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) { public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0; int rc = 0;
...@@ -58,6 +80,8 @@ public class JdbcInterface { ...@@ -58,6 +80,8 @@ public class JdbcInterface {
if (DEBUG) if (DEBUG)
System.out.println("URL=" + parms[1]); System.out.println("URL=" + parms[1]);
CheckURL(parms[1], null);
if (parms[2] != null && !parms[2].isEmpty()) { if (parms[2] != null && !parms[2].isEmpty()) {
if (DEBUG) if (DEBUG)
...@@ -74,27 +98,7 @@ public class JdbcInterface { ...@@ -74,27 +98,7 @@ public class JdbcInterface {
dbmd = conn.getMetaData(); dbmd = conn.getMetaData();
// Get a statement from the connection // Get a statement from the connection
if (scrollable) stmt = GetStmt(fsize, scrollable);
stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
else
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
if (DEBUG)
System.out.println("Statement type = " + stmt.getResultSetType()
+ " concurrency = " + stmt.getResultSetConcurrency());
if (DEBUG) // Get the fetch size of a statement
System.out.println("Default fetch size = " + stmt.getFetchSize());
if (fsize != 0) {
// Set the fetch size
stmt.setFetchSize(fsize);
if (DEBUG)
System.out.println("New fetch size = " + stmt.getFetchSize());
} // endif fsize
} catch(ClassNotFoundException e) { } catch(ClassNotFoundException e) {
SetErrmsg(e); SetErrmsg(e);
rc = -1; rc = -1;
...@@ -109,6 +113,34 @@ public class JdbcInterface { ...@@ -109,6 +113,34 @@ public class JdbcInterface {
return rc; return rc;
} // end of JdbcConnect } // end of JdbcConnect
protected Statement GetStmt(int fsize, boolean scrollable) throws SQLException, Exception {
Statement stmt = null;
if (scrollable)
stmt = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
else
stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
if (DEBUG)
System.out.println("Statement type = " + stmt.getResultSetType()
+ " concurrency = " + stmt.getResultSetConcurrency());
if (DEBUG) // Get the fetch size of a statement
System.out.println("Default fetch size = " + stmt.getFetchSize());
if (fsize != 0) {
// Set the fetch size
stmt.setFetchSize(fsize);
if (DEBUG)
System.out.println("New fetch size = " + stmt.getFetchSize());
} // endif fsize
return stmt;
} // end of GetStmt
public int CreatePrepStmt(String sql) { public int CreatePrepStmt(String sql) {
int rc = 0; int rc = 0;
...@@ -227,7 +259,9 @@ public class JdbcInterface { ...@@ -227,7 +259,9 @@ public class JdbcInterface {
// Cancel pending statement // Cancel pending statement
if (stmt != null) if (stmt != null)
try { try {
System.out.println("Cancelling statement"); if (DEBUG)
System.out.println("Cancelling statement");
stmt.cancel(); stmt.cancel();
} catch(SQLException se) { } catch(SQLException se) {
SetErrmsg(se); SetErrmsg(se);
...@@ -307,11 +341,15 @@ public class JdbcInterface { ...@@ -307,11 +341,15 @@ public class JdbcInterface {
} // end of GetMaxValue } // end of GetMaxValue
public int GetColumns(String[] parms) { public int GetColumns(String[] parms) {
int ncol = 0; int ncol = -1;
try { try {
if (rs != null) rs.close(); 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) { if (rs != null) {
rsmd = rs.getMetaData(); rsmd = rs.getMetaData();
...@@ -326,7 +364,7 @@ public class JdbcInterface { ...@@ -326,7 +364,7 @@ public class JdbcInterface {
} // end of GetColumns } // end of GetColumns
public int GetTables(String[] parms) { public int GetTables(String[] parms) {
int ncol = 0; int ncol = -1;
String[] typ = null; String[] typ = null;
if (parms[3] != null) { if (parms[3] != null) {
...@@ -336,7 +374,11 @@ public class JdbcInterface { ...@@ -336,7 +374,11 @@ public class JdbcInterface {
try { try {
if (rs != null) rs.close(); 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) { if (rs != null) {
rsmd = rs.getMetaData(); rsmd = rs.getMetaData();
...@@ -599,40 +641,43 @@ public class JdbcInterface { ...@@ -599,40 +641,43 @@ public class JdbcInterface {
return false; return false;
} // end of BooleanField } // end of BooleanField
public Date DateField(int n, String name) { public int DateField(int n, String name) {
if (rs == null) { if (rs == null) {
System.out.println("No result set"); System.out.println("No result set");
} else try { } else try {
return (n > 0) ? rs.getDate(n) : rs.getDate(name); Date d = (n > 0) ? rs.getDate(n) : rs.getDate(name);
return (d != null) ? (int)(d.getTime() / 1000) : 0;
} catch (SQLException se) { } catch (SQLException se) {
SetErrmsg(se); SetErrmsg(se);
} //end try/catch } //end try/catch
return null; return 0;
} // end of DateField } // end of DateField
public Time TimeField(int n, String name) { public int TimeField(int n, String name) {
if (rs == null) { if (rs == null) {
System.out.println("No result set"); System.out.println("No result set");
} else try { } else try {
return (n > 0) ? rs.getTime(n) : rs.getTime(name); Time t = (n > 0) ? rs.getTime(n) : rs.getTime(name);
return (t != null) ? (int)(t.getTime() / 1000) : 0;
} catch (SQLException se) { } catch (SQLException se) {
SetErrmsg(se); SetErrmsg(se);
} //end try/catch } //end try/catch
return null; return 0;
} // end of TimeField } // end of TimeField
public Timestamp TimestampField(int n, String name) { public int TimestampField(int n, String name) {
if (rs == null) { if (rs == null) {
System.out.println("No result set"); System.out.println("No result set");
} else try { } else try {
return (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name); Timestamp ts = (n > 0) ? rs.getTimestamp(n) : rs.getTimestamp(name);
return (ts != null) ? (int)(ts.getTime() / 1000) : 0;
} catch (SQLException se) { } catch (SQLException se) {
SetErrmsg(se); SetErrmsg(se);
} //end try/catch } //end try/catch
return null; return 0;
} // end of TimestampField } // end of TimestampField
public String ObjectField(int n, String name) { public String ObjectField(int n, String name) {
...@@ -710,3 +755,4 @@ public class JdbcInterface { ...@@ -710,3 +755,4 @@ public class JdbcInterface {
*/ */
} // end of class JdbcInterface } // end of class JdbcInterface
package wrappers;
import java.sql.*;
import java.util.Hashtable;
import javax.sql.DataSource;
import org.mariadb.jdbc.MariaDbDataSource;
public class MariadbInterface extends JdbcInterface {
public MariadbInterface() {
this(true);
} // end of default constructor
public MariadbInterface(boolean b) {
super(b);
if (dst == null)
dst = new Hashtable<String, DataSource>();
} // end of default constructor
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
DataSource ds = null;
MariaDbDataSource ads = null;
if (DEBUG)
System.out.println("Connecting to MariaDB data source");
try {
CheckURL(url, "mariadb");
if ((ds = dst.get(url)) == null) {
ads = new MariaDbDataSource();
ads.setUrl(url);
if (parms[2] != null)
ads.setUser(parms[2]);
if (parms[3] != null)
ads.setPassword(parms[3]);
ds = ads;
dst.put(url, ds);
} // endif ds
// Get a connection from the data source
conn = ds.getConnection();
// Get the data base meta data object
dbmd = conn.getMetaData();
// Get a statement from the connection
stmt = GetStmt(fsize, scrollable);
} catch (SQLException se) {
SetErrmsg(se);
rc = -2;
} catch( Exception e ) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of JdbcConnect
}
package wrappers;
import java.sql.*;
import java.util.Hashtable;
import javax.sql.DataSource;
import com.mysql.cj.jdbc.MysqlDataSource;
public class MysqlInterface extends JdbcInterface {
public MysqlInterface() {
this(true);
} // end of default constructor
public MysqlInterface(boolean b) {
super(b);
if (dst == null)
dst = new Hashtable<String, DataSource>();
} // end of default constructor
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
DataSource ds = null;
MysqlDataSource mds = null;
if (DEBUG)
System.out.println("Connecting to MySQL data source");
try {
CheckURL(url, "mysql");
if ((ds = dst.get(url)) == null) {
mds = new MysqlDataSource();
mds.setUrl(url);
if (parms[2] != null)
mds.setUser(parms[2]);
if (parms[3] != null)
mds.setPassword(parms[3]);
ds = mds;
dst.put(url, ds);
} // endif ds
// Get a connection from the data source
conn = ds.getConnection();
// Get the data base meta data object
dbmd = conn.getMetaData();
// Get a statement from the connection
stmt = GetStmt(fsize, scrollable);
} catch (SQLException se) {
SetErrmsg(se);
rc = -2;
} catch( Exception e ) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of JdbcConnect
} // end of class MysqlInterface
package wrappers;
import java.sql.*;
import java.util.Hashtable;
import javax.sql.DataSource;
import oracle.jdbc.pool.OracleDataSource;
public class OracleInterface extends JdbcInterface {
public OracleInterface() {
this(true);
} // end of OracleInterface constructor
public OracleInterface(boolean b) {
super(b);
if (dst == null)
dst = new Hashtable<String, DataSource>();
} // end of OracleInterface constructor
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
DataSource ds = null;
OracleDataSource ods = null;
if (DEBUG)
System.out.println("Connecting to Oracle data source");
try {
CheckURL(url, "oracle");
if ((ds = dst.get(url)) == null) {
ods = new OracleDataSource();
ods.setURL(url);
if (parms[2] != null)
ods.setUser(parms[2]);
if (parms[3] != null)
ods.setPassword(parms[3]);
ds = ods;
dst.put(url, ds);
} // endif ds
// Get a connection from the data source
conn = ds.getConnection();
// Get the data base meta data object
dbmd = conn.getMetaData();
// Get a statement from the connection
stmt = GetStmt(fsize, scrollable);
} catch (SQLException se) {
SetErrmsg(se);
rc = -2;
} catch( Exception e ) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of JdbcConnect
} // end of class OracleInterface
package wrappers;
import java.sql.*;
import java.util.Hashtable;
import javax.sql.DataSource;
import org.postgresql.jdbc2.optional.PoolingDataSource;
public class PostgresqlInterface extends JdbcInterface {
public PostgresqlInterface() {
this(true);
} // end of constructor
public PostgresqlInterface(boolean b) {
super(b);
if (dst == null)
dst = new Hashtable<String, DataSource>();
} // end of constructor
@Override
public int JdbcConnect(String[] parms, int fsize, boolean scrollable) {
int rc = 0;
String url = parms[1];
DataSource ds = null;
PoolingDataSource pds = null;
if (DEBUG)
System.out.println("Connecting to Postgresql data source");
try {
CheckURL(url, "postgresql");
if ((ds = dst.get(url)) == null) {
pds = new PoolingDataSource();
pds.setUrl(url);
if (parms[2] != null)
pds.setUser(parms[2]);
if (parms[3] != null)
pds.setPassword(parms[3]);
ds = pds;
dst.put(url, ds);
} // endif ds
// Get a connection from the data source
conn = ds.getConnection();
// Get the data base meta data object
dbmd = conn.getMetaData();
// Get a statement from the connection
stmt = GetStmt(fsize, scrollable);
} catch (SQLException se) {
SetErrmsg(se);
rc = -2;
} catch( Exception e ) {
SetErrmsg(e);
rc = -3;
} // end try/catch
return rc;
} // end of JdbcConnect
} // end of class PostgresqlInterface
...@@ -65,7 +65,8 @@ class TDBDOX: public TDBDOS { ...@@ -65,7 +65,8 @@ class TDBDOX: public TDBDOS {
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*, friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*); bool*, key_part_map*);
friend class ha_connect; friend class ha_connect;
}; // end of class TDBDOX TDBDOX() : TDBDOS((PGLOBAL)0, (PTDBDOS)0) {} /* Never called */
}; // end of class TDBDOX
class XKPDEF: public KPARTDEF { class XKPDEF: public KPARTDEF {
friend class TDBDOX; friend class TDBDOX;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier Bertrand 1995-2012 */ /* (C) Copyright to the author Olivier Bertrand 1995-2016 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -721,8 +721,8 @@ int CSORT::Qsortc(void) ...@@ -721,8 +721,8 @@ int CSORT::Qsortc(void)
void CSORT::Qstc(int *base, int *max) void CSORT::Qstc(int *base, int *max)
{ {
register int *i, *j, *jj, *lt, *eq, *gt, *mid; register int *i, *j, *jj, *lt, *eq, *gt, *mid;
int c, lo, hi, rc; int c = 0, lo, hi, rc;
size_t zlo, zhi, cnm; size_t zlo, zhi, cnm;
zlo = zhi = cnm = 0; // Avoid warning message zlo = zhi = cnm = 0; // Avoid warning message
...@@ -774,8 +774,11 @@ void CSORT::Qstc(int *base, int *max) ...@@ -774,8 +774,11 @@ void CSORT::Qstc(int *base, int *max)
/*****************************************************************/ /*****************************************************************/
/* Small group. Do special quicker processing. */ /* Small group. Do special quicker processing. */
/*****************************************************************/ /*****************************************************************/
if ((rc = Qcompare(base, (i = base + 1))) > 0) if ((rc = Qcompare(base, (i = base + 1))) > 0) {
c = *base, *base = *i, *i = c; c = *base;
*base = *i;
*i = c;
} // endif rc
if (Pof) if (Pof)
Pof[base - Pex] = Pof[i - Pex] = (rc) ? 1 : 2; Pof[base - Pex] = Pof[i - Pex] = (rc) ? 1 : 2;
......
...@@ -171,9 +171,9 @@ ...@@ -171,9 +171,9 @@
#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 May 08, 2016"; char version[]= "Version 1.04.0008 August 10, 2016";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.04.0006 " __DATE__ " " __TIME__; char compver[]= "Version 1.04.0008 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
#else // !__WIN__ #else // !__WIN__
char slash= '/'; char slash= '/';
...@@ -195,7 +195,6 @@ extern "C" { ...@@ -195,7 +195,6 @@ extern "C" {
#if defined(JDBC_SUPPORT) #if defined(JDBC_SUPPORT)
char *JvmPath; char *JvmPath;
char *ClassPath; char *ClassPath;
char *Wrapper;
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
#if defined(__WIN__) #if defined(__WIN__)
...@@ -211,7 +210,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info); ...@@ -211,7 +210,7 @@ PQRYRES OEMColumns(PGLOBAL g, PTOS topt, char *tab, char *db, bool info);
PQRYRES VirColumns(PGLOBAL g, bool info); PQRYRES VirColumns(PGLOBAL g, bool info);
PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info); PQRYRES JSONColumns(PGLOBAL g, char *db, PTOS topt, bool info);
PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, 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); void PushWarning(PGLOBAL g, THD *thd, int level);
bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host, bool CheckSelf(PGLOBAL g, TABLE_SHARE *s, const char *host,
const char *db, char *tab, const char *src, int port); const char *db, char *tab, const char *src, int port);
...@@ -220,6 +219,7 @@ USETEMP UseTemp(void); ...@@ -220,6 +219,7 @@ USETEMP UseTemp(void);
int GetConvSize(void); int GetConvSize(void);
TYPCONV GetTypeConv(void); TYPCONV GetTypeConv(void);
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
char *GetJavaWrapper(void);
uint GetWorkSize(void); uint GetWorkSize(void);
void SetWorkSize(uint); void SetWorkSize(uint);
extern "C" const char *msglang(void); extern "C" const char *msglang(void);
...@@ -332,6 +332,15 @@ static MYSQL_THDVAR_UINT(json_grp_size, ...@@ -332,6 +332,15 @@ static MYSQL_THDVAR_UINT(json_grp_size,
"max number of rows for JSON aggregate functions.", "max number of rows for JSON aggregate functions.",
NULL, NULL, JSONMAX, 1, INT_MAX, 1); 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) #if defined(XMSG) || defined(NEWMSG)
const char *language_names[]= const char *language_names[]=
{ {
...@@ -384,6 +393,12 @@ extern "C" const char *msglang(void) ...@@ -384,6 +393,12 @@ extern "C" const char *msglang(void)
return language_names[THDVAR(current_thd, msg_lang)]; return language_names[THDVAR(current_thd, msg_lang)];
} // end of msglang } // end of msglang
#else // !XMSG && !NEWMSG #else // !XMSG && !NEWMSG
#if defined(JDBC_SUPPORT)
char *GetJavaWrapper(void)
{return connect_hton ? THDVAR(current_thd, java_wrapper) : (char*)"wrappers/JdbcInterface";}
#endif // JDBC_SUPPORT
extern "C" const char *msglang(void) extern "C" const char *msglang(void)
{ {
#if defined(FRENCH) #if defined(FRENCH)
...@@ -1123,7 +1138,7 @@ bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef) ...@@ -1123,7 +1138,7 @@ bool GetBooleanTableOption(PGLOBAL g, PTOS options, char *opname, bool bdef)
/****************************************************************************/ /****************************************************************************/
int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef) int GetIntegerTableOption(PGLOBAL g, PTOS options, char *opname, int idef)
{ {
ulonglong opval= NO_IVAL; ulonglong opval= (ulonglong) NO_IVAL;
if (!options) if (!options)
return idef; return idef;
...@@ -5508,7 +5523,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5508,7 +5523,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break; break;
case FNC_TABLE: case FNC_TABLE:
qrp= ODBCTables(g, dsn, shm, tab, mxr, true, sop); qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
break; break;
case FNC_DSN: case FNC_DSN:
qrp= ODBCDataSources(g, mxr, true); qrp= ODBCDataSources(g, mxr, true);
...@@ -5633,6 +5648,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5633,6 +5648,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
} else { } else {
char *schem= NULL; char *schem= NULL;
char *tn= NULL;
// Not a catalog table // Not a catalog table
if (!qrp->Nblin) { if (!qrp->Nblin) {
...@@ -5649,7 +5665,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5649,7 +5665,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
typ= len= prec= dec= 0; typ= len= prec= dec= 0;
tm= NOT_NULL_FLAG; tm= NOT_NULL_FLAG;
cnm= (char*)"noname"; cnm= (char*)"noname";
dft= xtra= key= fmt= NULL; dft= xtra= key= fmt= tn= NULL;
v= ' '; v= ' ';
rem= NULL; rem= NULL;
...@@ -5669,7 +5685,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5669,7 +5685,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
typ= crp->Kdata->GetIntValue(i); typ= crp->Kdata->GetIntValue(i);
v = (crp->Nulls) ? crp->Nulls[i] : 0; v = (crp->Nulls) ? crp->Nulls[i] : 0;
break; break;
case FLD_PREC: case FLD_TYPENAME:
tn= crp->Kdata->GetCharValue(i);
break;
case FLD_PREC:
// PREC must be always before LENGTH // PREC must be always before LENGTH
len= prec= crp->Kdata->GetIntValue(i); len= prec= crp->Kdata->GetIntValue(i);
break; break;
...@@ -5713,8 +5732,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5713,8 +5732,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break; break;
case FLD_SCHEM: case FLD_SCHEM:
#if defined(ODBC_SUPPORT) #if defined(ODBC_SUPPORT) || defined(JDBC_SUPPORT)
if (ttp == TAB_ODBC && crp->Kdata) { if ((ttp == TAB_ODBC || ttp == TAB_JDBC) && crp->Kdata) {
if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) { if (schem && stricmp(schem, crp->Kdata->GetCharValue(i))) {
sprintf(g->Message, sprintf(g->Message,
"Several %s tables found, specify DBNAME", tab); "Several %s tables found, specify DBNAME", tab);
...@@ -5724,7 +5743,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5724,7 +5743,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
schem= crp->Kdata->GetCharValue(i); schem= crp->Kdata->GetCharValue(i);
} // endif ttp } // endif ttp
#endif // ODBC_SUPPORT #endif // ODBC_SUPPORT || JDBC_SUPPORT
default: default:
break; // Ignore break; // Ignore
} // endswitch Fld } // endswitch Fld
...@@ -5777,7 +5796,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd, ...@@ -5777,7 +5796,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
int plgtyp; int plgtyp;
// typ must be PLG type, not SQL type // 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) { if (GetTypeConv() == TPC_SKIP) {
// Skip this column // Skip this column
sprintf(g->Message, "Column %s skipped (unsupported type %d)", sprintf(g->Message, "Column %s skipped (unsupported type %d)",
...@@ -6875,12 +6894,6 @@ static MYSQL_SYSVAR_STR(class_path, ClassPath, ...@@ -6875,12 +6894,6 @@ static MYSQL_SYSVAR_STR(class_path, ClassPath,
"Java class path", "Java class path",
// check_class_path, update_class_path, // check_class_path, update_class_path,
NULL, NULL, NULL); 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, "JdbcInterface");
#endif // JDBC_SUPPORT #endif // JDBC_SUPPORT
...@@ -6922,7 +6935,7 @@ maria_declare_plugin(connect) ...@@ -6922,7 +6935,7 @@ maria_declare_plugin(connect)
0x0104, /* version number (1.04) */ 0x0104, /* version number (1.04) */
NULL, /* status variables */ NULL, /* status variables */
connect_system_variables, /* system variables */ connect_system_variables, /* system variables */
"1.04.0006", /* string version */ "1.04.0008", /* string version */
MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */ MariaDB_PLUGIN_MATURITY_GAMMA /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
This diff is collapsed.
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
//efine MAX_FNAME_LEN 256 // Max size of field names //efine MAX_FNAME_LEN 256 // Max size of field names
//efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo //efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names //efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string //efine MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name //efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL #define DEFAULT_FIELD_TYPE 0 // TYPE_NULL
...@@ -46,9 +46,9 @@ enum JCATINFO { ...@@ -46,9 +46,9 @@ enum JCATINFO {
typedef struct tagJCATPARM { typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer PQRYRES Qrp; // Result set pointer
PUCHAR DB; // Database (Schema) char *DB; // Database (Schema)
PUCHAR Tab; // Table name or pattern char *Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern char *Pat; // Table type or column pattern
} JCATPARM; } JCATPARM;
typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *); typedef jint(JNICALL *CRTJVM) (JavaVM **, void **, void *);
...@@ -169,12 +169,15 @@ protected: ...@@ -169,12 +169,15 @@ protected:
jmethodID intfldid; // The IntField method ID jmethodID intfldid; // The IntField method ID
jmethodID dblfldid; // The DoubleField method ID jmethodID dblfldid; // The DoubleField method ID
jmethodID fltfldid; // The FloatField 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 jmethodID bigfldid; // The BigintField method ID
//DWORD m_LoginTimeout; //DWORD m_LoginTimeout;
//DWORD m_QueryTimeout; //DWORD m_QueryTimeout;
//DWORD m_UpdateOptions; //DWORD m_UpdateOptions;
char *Msg; char *Msg;
char *m_Wrap;
char m_IDQuoteChar[2]; char m_IDQuoteChar[2];
PSZ m_Driver; PSZ m_Driver;
PSZ m_Url; PSZ m_Url;
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
uint GetJsonGrpSize(void); uint GetJsonGrpSize(void);
static int IsJson(UDF_ARGS *args, uint i); static int IsJson(UDF_ARGS *args, uint i);
static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i); static PSZ MakePSZ(PGLOBAL g, UDF_ARGS *args, int i);
static char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error);
static char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *is_null, char *error);
static uint JsonGrpSize = 10; static uint JsonGrpSize = 10;
...@@ -1302,7 +1306,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj, ...@@ -1302,7 +1306,7 @@ static my_bool CalcLen(UDF_ARGS *args, my_bool obj,
{ {
char fn[_MAX_PATH]; char fn[_MAX_PATH];
unsigned long i, k, m, n; unsigned long i, k, m, n;
long fl= 0, j = -1; long fl = 0, j = -1;
reslen = args->arg_count + 2; reslen = args->arg_count + 2;
...@@ -2126,7 +2130,7 @@ my_bool json_object_nonull_init(UDF_INIT *initid, UDF_ARGS *args, ...@@ -2126,7 +2130,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, char *json_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
unsigned long *res_length, char *, char *) unsigned long *res_length, char *, char *)
{ {
char *str= 0; char *str = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
if (!g->Xchk) { if (!g->Xchk) {
...@@ -2699,7 +2703,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -2699,7 +2703,7 @@ char *json_item_merge(UDF_INIT *initid, UDF_ARGS *args, char *result,
} // endif Xchk } // endif Xchk
if (!CheckMemory(g, initid, args, 2, false, false, true)) { if (!CheckMemory(g, initid, args, 2, false, false, true)) {
PJSON top= 0; PJSON top = NULL;
PJVAL jvp; PJVAL jvp;
PJSON jsp[2] = {NULL, NULL}; PJSON jsp[2] = {NULL, NULL};
...@@ -4899,7 +4903,7 @@ char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4899,7 +4903,7 @@ char *bin_handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result,
my_bool b = true; my_bool b = true;
PJSON jsp; PJSON jsp;
PJSNX jsx; PJSNX jsx;
PJVAL jvp= 0; PJVAL jvp = NULL;
PBSON bsp = NULL; PBSON bsp = NULL;
PGLOBAL g = (PGLOBAL)initid->ptr; PGLOBAL g = (PGLOBAL)initid->ptr;
PGLOBAL gb = GetMemPtr(g, args, 0); PGLOBAL gb = GetMemPtr(g, args, 0);
......
SET GLOBAL time_zone='+1:00';
CREATE DATABASE connect; CREATE DATABASE connect;
USE connect; USE connect;
CREATE TABLE t2 ( CREATE TABLE t2 (
...@@ -99,8 +100,8 @@ George San Jose 1981-08-10 2010-06-02 ...@@ -99,8 +100,8 @@ George San Jose 1981-08-10 2010-06-02
Sam Chicago 1979-11-22 2007-10-10 Sam Chicago 1979-11-22 2007-10-10
James Dallas 1992-05-13 2009-12-14 James Dallas 1992-05-13 2009-12-14
Bill Boston 1986-09-11 2008-02-10 Bill Boston 1986-09-11 2008-02-10
Donald Atlanta 1999-04-01 2016-03-31 Donald Atlanta 1999-03-31 2016-03-30
Mick New York 1980-01-20 2002-09-11 Mick New York 1980-01-20 2002-09-10
Tom Seatle 2002-03-15 1970-01-01 Tom Seatle 2002-03-15 1970-01-01
DROP TABLE t3; DROP TABLE t3;
# #
...@@ -110,7 +111,7 @@ CREATE TABLE t3 ( ...@@ -110,7 +111,7 @@ CREATE TABLE t3 (
name CHAR(9) NOT NULL, name CHAR(9) NOT NULL,
city CHAR(12) NOT NULL, city CHAR(12) NOT NULL,
age INT(2)) age INT(2))
engine=CONNECT table_type=FIX file_name='girls.txt'; ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='girls.txt' ENDING=1;
SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN connect.boys b where g.city = b.city; SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN connect.boys b where g.city = b.city;
name name city name name city
Mary John Boston Mary John Boston
...@@ -167,8 +168,11 @@ serialno name sex title manager department secretary salary ...@@ -167,8 +168,11 @@ serialno name sex title manager department secretary salary
00137 BROWNY 1 ENGINEER 40567 0319 12345 10500.00 00137 BROWNY 1 ENGINEER 40567 0319 12345 10500.00
73111 WHEELFOR 1 SALESMAN 70012 0318 24888 10030.00 73111 WHEELFOR 1 SALESMAN 70012 0318 24888 10030.00
00023 MARTIN 1 ENGINEER 40567 0319 12345 10000.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; 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; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -180,7 +184,7 @@ t1 CREATE TABLE `t1` ( ...@@ -180,7 +184,7 @@ t1 CREATE TABLE `t1` (
`department` char(4) NOT NULL, `department` char(4) NOT NULL,
`secretary` char(5) NOT NULL, `secretary` char(5) NOT NULL,
`salary` double(12,2) 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; SELECT * FROM t1;
serialno name sex title manager department secretary salary serialno name sex title manager department secretary salary
74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00 74200 BANCROFT 2 SALESMAN 70012 0318 24888 9600.00
...@@ -260,10 +264,8 @@ DROP TABLE t2; ...@@ -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'; 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; SELECT * FROM t1;
Table_Cat Table_Schema Table_Name Table_Type Remark Table_Cat Table_Schema Table_Name Table_Type Remark
connect NULL tx1 BASE TABLE connect NULL tx1 TABLE
DROP TABLE t1; DROP TABLE t1;
DROP TABLE connect.tx1; DROP TABLE connect.tx1;
DROP DATABASE connect; DROP DATABASE connect;
SET GLOBAL connect_jvm_path=NULL; SET GLOBAL time_zone=SYSTEM;
SET GLOBAL connect_class_path=NULL;
SET GLOBAL time_zone = SYSTEM;
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 (a int, b char(10)); CREATE TABLE t1 (a int, b char(10));
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
SELECT * FROM t1; SELECT * FROM t1;
...@@ -10,6 +11,7 @@ NULL NULL ...@@ -10,6 +11,7 @@ NULL NULL
# #
# Testing errors # Testing errors
# #
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC
CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown'; CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=unknown';
SELECT * FROM t1; SELECT * FROM t1;
...@@ -32,15 +34,13 @@ t1 CREATE TABLE `t1` ( ...@@ -32,15 +34,13 @@ t1 CREATE TABLE `t1` (
`y` char(10) DEFAULT NULL `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 ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`=JDBC
SELECT * FROM t1; SELECT * FROM t1;
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list' ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Unknown column 'x' in 'field list'' from CONNECT
Query is : SELECT x, y FROM t1' from CONNECT
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int, b char(10)) ENGINE=CONNECT TABLE_TYPE=JDBC 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'; CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root';
ALTER TABLE t1 RENAME t1backup; ALTER TABLE t1 RENAME t1backup;
SELECT * FROM t1; SELECT * FROM t1;
ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Table 'test.t1' doesn't exist ERROR HY000: Got error 174 'ExecuteQuery: java.sql.SQLSyntaxErrorException: Table 'test.t1' doesn't exist' from CONNECT
Query is : SELECT a, b FROM t1' from CONNECT
ALTER TABLE t1backup RENAME t1; ALTER TABLE t1backup RENAME t1;
DROP TABLE t1; DROP TABLE t1;
# #
...@@ -201,16 +201,15 @@ SHOW CREATE TABLE t1; ...@@ -201,16 +201,15 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` date DEFAULT NULL, `a` date DEFAULT NULL,
`b` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `b` datetime DEFAULT NULL,
`c` time DEFAULT NULL, `c` time DEFAULT NULL,
`d` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `d` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`e` date DEFAULT NULL `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' ) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='jdbc:mysql://127.0.0.1:SLAVE_PORT/test?user=root' `TABLE_TYPE`='JDBC'
SELECT * FROM t1; SELECT * FROM t1;
a b c d e 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;
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL connect_jvm_path=NULL; SET GLOBAL time_zone=SYSTEM;
SET GLOBAL connect_class_path=NULL; SET GLOBAL time_zone=SYSTEM;
SET GLOBAL time_zone = SYSTEM;
-- source jdbconn.inc -- source jdbconn.inc
SET GLOBAL time_zone='+1:00';
let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt --copy_file $MTR_SUITE_DIR/std_data/girls.txt $MYSQLD_DATADIR/test/girls.txt
...@@ -80,7 +81,7 @@ CREATE TABLE t3 ( ...@@ -80,7 +81,7 @@ CREATE TABLE t3 (
name CHAR(9) NOT NULL, name CHAR(9) NOT NULL,
city CHAR(12) NOT NULL, city CHAR(12) NOT NULL,
age INT(2)) age INT(2))
engine=CONNECT table_type=FIX file_name='girls.txt'; ENGINE=CONNECT TABLE_TYPE=FIX FILE_NAME='girls.txt' ENDING=1;
SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN connect.boys b where g.city = b.city; SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN connect.boys b where g.city = b.city;
SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN t1 b where g.city = b.city; SELECT g.name, b.name, g.city FROM t3 g STRAIGHT_JOIN t1 b where g.city = b.city;
DROP TABLE t1, t3, connect.boys; DROP TABLE t1, t3, connect.boys;
...@@ -102,9 +103,12 @@ CREATE TABLE emp ( ...@@ -102,9 +103,12 @@ CREATE TABLE emp (
ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1; ENGINE=connect TABLE_TYPE=fix FILE_NAME='employee.dat' ENDING=1;
SELECT * FROM emp; SELECT * FROM emp;
--echo #
--echo # Option Driver is required to find the Driver class inside the executable jar file
--echo #
USE test; USE test;
--replace_result $PORT PORT --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 --replace_result $PORT PORT
--eval SHOW CREATE TABLE t1 --eval SHOW CREATE TABLE t1
SELECT * FROM t1; SELECT * FROM t1;
...@@ -113,7 +117,7 @@ SELECT name, title, salary FROM t1 WHERE sex = 1; ...@@ -113,7 +117,7 @@ SELECT name, title, salary FROM t1 WHERE sex = 1;
DROP TABLE t1, connect.emp; DROP TABLE t1, connect.emp;
# #
# Testing remote command execution # Testing remote command execution (Driver option is no more necessary)
# #
--replace_result $PORT PORT --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' --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; ...@@ -139,5 +143,5 @@ DROP TABLE connect.tx1;
--remove_file $MYSQLD_DATADIR/connect/employee.dat --remove_file $MYSQLD_DATADIR/connect/employee.dat
DROP DATABASE connect; DROP DATABASE connect;
--remove_file $MYSQLD_DATADIR/test/girls.txt --remove_file $MYSQLD_DATADIR/test/girls.txt
SET GLOBAL time_zone=SYSTEM;
-- source jdbconn_cleanup.inc -- source jdbconn_cleanup.inc
...@@ -8,6 +8,8 @@ connection master; ...@@ -8,6 +8,8 @@ connection master;
-- source jdbconn.inc -- source jdbconn.inc
connection slave; connection slave;
SET GLOBAL time_zone='+1:00';
CREATE TABLE t1 (a int, b char(10)); CREATE TABLE t1 (a int, b char(10));
INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03'); INSERT INTO t1 VALUES (NULL,NULL),(0,'test00'),(1,'test01'),(2,'test02'),(3,'test03');
SELECT * FROM t1; SELECT * FROM t1;
...@@ -16,6 +18,7 @@ SELECT * FROM t1; ...@@ -16,6 +18,7 @@ SELECT * FROM t1;
--echo # Testing errors --echo # Testing errors
--echo # --echo #
connection master; connection master;
SET GLOBAL time_zone='+1:00';
# Bad user name # Bad user name
# Suppress "mysql_real_connect failed:" (printed in _DEBUG build) # Suppress "mysql_real_connect failed:" (printed in _DEBUG build)
...@@ -173,7 +176,9 @@ DROP TABLE t1; ...@@ -173,7 +176,9 @@ DROP TABLE t1;
connection slave; connection slave;
DROP TABLE t1; DROP TABLE t1;
SET GLOBAL time_zone=SYSTEM;
connection master; connection master;
SET GLOBAL time_zone=SYSTEM;
-- source jdbconn_cleanup.inc -- source jdbconn_cleanup.inc
...@@ -12,19 +12,20 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES ...@@ -12,19 +12,20 @@ if (!`SELECT count(*) FROM INFORMATION_SCHEMA.TABLES
} }
DROP TABLE t1; DROP TABLE t1;
# This is specific and explains why this test is disabled. # You cand edit this file to reflect what is the required files location on your machine.
# You should 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) # 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: # The complete class path send when creating the Java Virtual Machine is, in that order:
# 1 - The current directory. # 1 - The current directory.
# 2 - The paths of the connect_class_path global variable. # 2 - The paths of the connect_class_path global variable.
# 3 - The paths of the CLASSPATH environment 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. # In this test we use an executable jar file that contains all what is needed.
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'; 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'; #CREATE FUNCTION envar RETURNS STRING SONAME 'ha_connect.dll';
#SELECT envar('CLASSPATH'); #SELECT envar('CLASSPATH');
......
--disable_query_log
--disable_warnings --disable_warnings
#DROP FUNCTION envar; #DROP FUNCTION envar;
SET GLOBAL connect_jvm_path=NULL; SET GLOBAL connect_jvm_path=NULL;
SET GLOBAL connect_class_path=NULL; SET GLOBAL connect_class_path=NULL;
SET GLOBAL time_zone = SYSTEM; SET GLOBAL time_zone = SYSTEM;
--enable_warnings --enable_warnings
--enable_query_log
...@@ -21,5 +21,5 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table, ...@@ -21,5 +21,5 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *db, char *table,
char *colpat, int maxres, bool info, POPARM sop); char *colpat, int maxres, bool info, POPARM sop);
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop); PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
int maxres, bool info, POPARM sop); char *tabtyp, int maxres, bool info, POPARM sop);
PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info); PQRYRES ODBCDrivers(PGLOBAL g, int maxres, bool info);
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
extern "C" HINSTANCE s_hModule; // Saved module handle extern "C" HINSTANCE s_hModule; // Saved module handle
#endif // __WIN__ #endif // __WIN__
TYPCONV GetTypeConv();
int GetConvSize(); int GetConvSize();
/***********************************************************************/ /***********************************************************************/
...@@ -135,9 +136,13 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w) ...@@ -135,9 +136,13 @@ int TranslateSQLType(int stp, int prec, int& len, char& v, bool& w)
case SQL_WLONGVARCHAR: // (-10) case SQL_WLONGVARCHAR: // (-10)
w = true; w = true;
case SQL_LONGVARCHAR: // (-1) case SQL_LONGVARCHAR: // (-1)
v = 'V'; if (GetTypeConv() == TPC_YES) {
type = TYPE_STRING; v = 'V';
len = MY_MIN(abs(len), GetConvSize()); type = TYPE_STRING;
len = MY_MIN(abs(len), GetConvSize());
} else
type = TYPE_ERROR;
break; break;
case SQL_NUMERIC: // 2 case SQL_NUMERIC: // 2
case SQL_DECIMAL: // 3 case SQL_DECIMAL: // 3
...@@ -606,7 +611,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info) ...@@ -606,7 +611,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info)
/* an ODBC database that will be retrieved by GetData commands. */ /* an ODBC database that will be retrieved by GetData commands. */
/**************************************************************************/ /**************************************************************************/
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
int maxres, bool info, POPARM sop) char *tabtyp, int maxres, bool info, POPARM sop)
{ {
int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING, int buftyp[] = {TYPE_STRING, TYPE_STRING, TYPE_STRING,
TYPE_STRING, TYPE_STRING}; TYPE_STRING, TYPE_STRING};
...@@ -668,7 +673,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat, ...@@ -668,7 +673,7 @@ PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *db, char *tabpat,
if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp))) if (!(cap = AllocCatInfo(g, CAT_TAB, db, tabpat, qrp)))
return NULL; return NULL;
//cap->Pat = (PUCHAR)tabtyp; cap->Pat = (PUCHAR)tabtyp;
if (trace) if (trace)
htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol); htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol);
...@@ -1752,7 +1757,7 @@ bool ODBConn::BindParam(ODBCCOL *colp) ...@@ -1752,7 +1757,7 @@ bool ODBConn::BindParam(ODBCCOL *colp)
void *buf; void *buf;
int buftype = colp->GetResultType(); int buftype = colp->GetResultType();
SQLUSMALLINT n = colp->GetRank(); SQLUSMALLINT n = colp->GetRank();
SQLSMALLINT ct, sqlt, dec, nul; SQLSMALLINT ct, sqlt, dec, nul __attribute__((unused));
SQLULEN colsize; SQLULEN colsize;
SQLLEN len; SQLLEN len;
SQLLEN *strlen = colp->GetStrLen(); SQLLEN *strlen = colp->GetStrLen();
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
//efine MAX_FNAME_LEN 256 // Max size of field names //efine MAX_FNAME_LEN 256 // Max size of field names
#define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo #define MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names //efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string #define MAX_CONNECT_LEN 1024 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name //efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type #define DEFAULT_FIELD_TYPE SQL_TYPE_NULL // pick "C" data type to match SQL data type
......
...@@ -96,7 +96,7 @@ bool ExactInfo(void); ...@@ -96,7 +96,7 @@ bool ExactInfo(void);
/***********************************************************************/ /***********************************************************************/
JDBCDEF::JDBCDEF(void) JDBCDEF::JDBCDEF(void)
{ {
Driver = Url = Tabname = Tabschema = Username = NULL; Driver = Url = Wrapname =Tabname = Tabschema = Username = Colpat = NULL;
Password = Tabcat = Tabtype = Srcdef = Qchar = Qrystr = Sep = NULL; Password = Tabcat = Tabtype = Srcdef = Qchar = Qrystr = Sep = NULL;
Options = Quoted = Maxerr = Maxres = Memory = 0; Options = Quoted = Maxerr = Maxres = Memory = 0;
Scrollable = Xsrc = false; Scrollable = Xsrc = false;
...@@ -233,11 +233,18 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -233,11 +233,18 @@ bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL))) if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
Read_Only = true; Read_Only = true;
Wrapname = GetStringCatInfo(g, "Wrapper", NULL);
Tabcat = GetStringCatInfo(g, "Qualifier", NULL); Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat); Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
Tabschema = GetStringCatInfo(g, "Dbname", NULL); Tabschema = GetStringCatInfo(g, "Dbname", NULL);
Tabschema = GetStringCatInfo(g, "Schema", Tabschema); Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
Tabtype = GetStringCatInfo(g, "Tabtype", NULL);
if (Catfunc == FNC_COL)
Colpat = GetStringCatInfo(g, "Colpat", NULL);
if (Catfunc == FNC_TABLE)
Tabtype = GetStringCatInfo(g, "Tabtype", NULL);
Qrystr = GetStringCatInfo(g, "Query_String", "?"); Qrystr = GetStringCatInfo(g, "Query_String", "?");
Sep = GetStringCatInfo(g, "Separator", NULL); Sep = GetStringCatInfo(g, "Separator", NULL);
Xsrc = GetBoolCatInfo("Execsrc", FALSE); Xsrc = GetBoolCatInfo("Execsrc", FALSE);
...@@ -325,6 +332,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp) ...@@ -325,6 +332,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
if (tdp) { if (tdp) {
Ops.Driver = tdp->Driver; Ops.Driver = tdp->Driver;
Ops.Url = tdp->Url; Ops.Url = tdp->Url;
WrapName = tdp->Wrapname;
TableName = tdp->Tabname; TableName = tdp->Tabname;
Schema = tdp->Tabschema; Schema = tdp->Tabschema;
Ops.User = tdp->Username; Ops.User = tdp->Username;
...@@ -341,6 +349,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp) ...@@ -341,6 +349,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
Memory = tdp->Memory; Memory = tdp->Memory;
Ops.Scrollable = tdp->Scrollable; Ops.Scrollable = tdp->Scrollable;
} else { } else {
WrapName = NULL;
TableName = NULL; TableName = NULL;
Schema = NULL; Schema = NULL;
Ops.Driver = NULL; Ops.Driver = NULL;
...@@ -386,6 +395,7 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp) ...@@ -386,6 +395,7 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp)
{ {
Jcp = tdbp->Jcp; // is that right ? Jcp = tdbp->Jcp; // is that right ?
Cnp = tdbp->Cnp; Cnp = tdbp->Cnp;
WrapName = tdbp->WrapName;
TableName = tdbp->TableName; TableName = tdbp->TableName;
Schema = tdbp->Schema; Schema = tdbp->Schema;
Ops = tdbp->Ops; Ops = tdbp->Ops;
...@@ -512,9 +522,10 @@ bool TDBJDBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -512,9 +522,10 @@ bool TDBJDBC::MakeSQL(PGLOBAL g, bool cnt)
if (Catalog && *Catalog) if (Catalog && *Catalog)
catp = Catalog; catp = Catalog;
if (tablep->GetSchema()) //if (tablep->GetSchema())
schmp = (char*)tablep->GetSchema(); // schmp = (char*)tablep->GetSchema();
else if (Schema && *Schema) //else
if (Schema && *Schema)
schmp = Schema; schmp = Schema;
if (catp) { if (catp) {
...@@ -596,9 +607,10 @@ bool TDBJDBC::MakeInsert(PGLOBAL g) ...@@ -596,9 +607,10 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
if (catp) if (catp)
len += strlen(catp) + 1; len += strlen(catp) + 1;
if (tablep->GetSchema()) //if (tablep->GetSchema())
schmp = (char*)tablep->GetSchema(); // schmp = (char*)tablep->GetSchema();
else if (Schema && *Schema) //else
if (Schema && *Schema)
schmp = Schema; schmp = Schema;
if (schmp) if (schmp)
...@@ -1787,12 +1799,20 @@ PQRYRES TDBJTB::GetResult(PGLOBAL g) ...@@ -1787,12 +1799,20 @@ PQRYRES TDBJTB::GetResult(PGLOBAL g)
/* --------------------------TDBJDBCL class -------------------------- */ /* --------------------------TDBJDBCL class -------------------------- */
/***********************************************************************/
/* TDBJDBCL class constructor. */
/***********************************************************************/
TDBJDBCL::TDBJDBCL(PJDBCDEF tdp) : TDBJTB(tdp)
{
Colpat = tdp->Colpat;
} // end of TDBJDBCL constructor
/***********************************************************************/ /***********************************************************************/
/* GetResult: Get the list of JDBC table columns. */ /* GetResult: Get the list of JDBC table columns. */
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBJDBCL::GetResult(PGLOBAL g) PQRYRES TDBJDBCL::GetResult(PGLOBAL g)
{ {
return JDBCColumns(g, Schema, Tab, NULL, Maxres, false, &Ops); return JDBCColumns(g, Schema, Tab, Colpat, Maxres, false, &Ops);
} // end of GetResult } // end of GetResult
#if 0 #if 0
......
...@@ -26,6 +26,7 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */ ...@@ -26,6 +26,7 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
friend class TDBXJDC; friend class TDBXJDC;
friend class TDBJDRV; friend class TDBJDRV;
friend class TDBJTB; friend class TDBJTB;
friend class TDBJDBCL;
public: public:
// Constructor // Constructor
JDBCDEF(void); JDBCDEF(void);
...@@ -53,11 +54,13 @@ protected: ...@@ -53,11 +54,13 @@ protected:
PSZ Driver; /* JDBC driver */ PSZ Driver; /* JDBC driver */
PSZ Url; /* JDBC driver URL */ PSZ Url; /* JDBC driver URL */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
PSZ Wrapname; /* Java wrapper name */
PSZ Tabschema; /* External table schema */ PSZ Tabschema; /* External table schema */
PSZ Username; /* User connect name */ PSZ Username; /* User connect name */
PSZ Password; /* Password connect info */ PSZ Password; /* Password connect info */
PSZ Tabcat; /* External table catalog */ PSZ Tabcat; /* External table catalog */
PSZ Tabtype; /* External table type */ PSZ Tabtype; /* External table type */
PSZ Colpat; /* Catalog column pattern */
PSZ Srcdef; /* The source table SQL definition */ PSZ Srcdef; /* The source table SQL definition */
PSZ Qchar; /* Identifier quoting character */ PSZ Qchar; /* Identifier quoting character */
PSZ Qrystr; /* The original query */ PSZ Qrystr; /* The original query */
...@@ -131,6 +134,7 @@ protected: ...@@ -131,6 +134,7 @@ protected:
JDBCCOL *Cnp; // Points to count(*) column JDBCCOL *Cnp; // Points to count(*) column
JDBCPARM Ops; // Additional parameters JDBCPARM Ops; // Additional parameters
PSTRG Query; // Constructed SQL query PSTRG Query; // Constructed SQL query
char *WrapName; // Points to Java wrapper name
char *TableName; // Points to JDBC table name char *TableName; // Points to JDBC table name
char *Schema; // Points to JDBC table Schema char *Schema; // Points to JDBC table Schema
char *User; // User connect info char *User; // User connect info
...@@ -317,14 +321,15 @@ protected: ...@@ -317,14 +321,15 @@ protected:
class TDBJDBCL : public TDBJTB { class TDBJDBCL : public TDBJTB {
public: public:
// Constructor // Constructor
TDBJDBCL(PJDBCDEF tdp) : TDBJTB(tdp) {} TDBJDBCL(PJDBCDEF tdp);
protected: protected:
// Specific routines // Specific routines
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// No additional Members // Members
}; // end of class TDBJCL char *Colpat; // Points to catalog column pattern
}; // end of class TDBJDBCL
#if 0 #if 0
/***********************************************************************/ /***********************************************************************/
......
/************* Tabodbc C++ Program Source Code File (.CPP) *************/ /************* Tabodbc C++ Program Source Code File (.CPP) *************/
/* PROGRAM NAME: TABODBC */ /* PROGRAM NAME: TABODBC */
/* ------------- */ /* ------------- */
/* Version 3.0 */ /* Version 3.1 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
...@@ -96,7 +96,7 @@ bool ExactInfo(void); ...@@ -96,7 +96,7 @@ bool ExactInfo(void);
ODBCDEF::ODBCDEF(void) ODBCDEF::ODBCDEF(void)
{ {
Connect = Tabname = Tabschema = Username = Password = NULL; Connect = Tabname = Tabschema = Username = Password = NULL;
Tabcat = Srcdef = Qchar = Qrystr = Sep = NULL; Tabcat = Colpat = Srcdef = Qchar = Qrystr = Sep = NULL;
Catver = Options = Cto = Qto = Quoted = Maxerr = Maxres = Memory = 0; Catver = Options = Cto = Qto = Quoted = Maxerr = Maxres = Memory = 0;
Scrollable = Xsrc = UseCnc = false; Scrollable = Xsrc = UseCnc = false;
} // end of ODBCDEF constructor } // end of ODBCDEF constructor
...@@ -120,7 +120,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -120,7 +120,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
Tabschema = GetStringCatInfo(g, "Schema", Tabschema); Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
Tabcat = GetStringCatInfo(g, "Qualifier", NULL); Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat); Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
Username = GetStringCatInfo(g, "User", NULL); Username = GetStringCatInfo(g, "User", NULL);
Password = GetStringCatInfo(g, "Password", NULL); Password = GetStringCatInfo(g, "Password", NULL);
if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL))) if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
...@@ -141,7 +141,13 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) ...@@ -141,7 +141,13 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if ((Scrollable = GetBoolCatInfo("Scrollable", false)) && !Elemt) if ((Scrollable = GetBoolCatInfo("Scrollable", false)) && !Elemt)
Elemt = 1; // Cannot merge SQLFetch and SQLExtendedFetch Elemt = 1; // Cannot merge SQLFetch and SQLExtendedFetch
UseCnc = GetBoolCatInfo("UseDSN", false); if (Catfunc == FNC_COL)
Colpat = GetStringCatInfo(g, "Colpat", NULL);
if (Catfunc == FNC_TABLE)
Tabtyp = GetStringCatInfo(g, "Tabtype", NULL);
UseCnc = GetBoolCatInfo("UseDSN", false);
// Memory was Boolean, it is now integer // Memory was Boolean, it is now integer
if (!(Memory = GetIntCatInfo("Memory", 0))) if (!(Memory = GetIntCatInfo("Memory", 0)))
...@@ -452,9 +458,14 @@ bool TDBODBC::MakeSQL(PGLOBAL g, bool cnt) ...@@ -452,9 +458,14 @@ bool TDBODBC::MakeSQL(PGLOBAL g, bool cnt)
if (Catalog && *Catalog) if (Catalog && *Catalog)
catp = Catalog; catp = Catalog;
if (tablep->GetSchema()) // Following lines are commented because of MSDEV-10520
schmp = (char*)tablep->GetSchema(); // Indeed the schema in the tablep is the local table database and
else if (Schema && *Schema) // is normally not related to the remote table database.
// TODO: Try to remember why this was done and if it was useful in some case.
//if (tablep->GetSchema())
// schmp = (char*)tablep->GetSchema();
//else
if (Schema && *Schema)
schmp = Schema; schmp = Schema;
if (catp) { if (catp) {
...@@ -535,9 +546,10 @@ bool TDBODBC::MakeInsert(PGLOBAL g) ...@@ -535,9 +546,10 @@ bool TDBODBC::MakeInsert(PGLOBAL g)
if (catp) if (catp)
len += strlen(catp) + 1; len += strlen(catp) + 1;
if (tablep->GetSchema()) //if (tablep->GetSchema())
schmp = (char*)tablep->GetSchema(); // schmp = (char*)tablep->GetSchema();
else if (Schema && *Schema) //else
if (Schema && *Schema)
schmp = Schema; schmp = Schema;
if (schmp) if (schmp)
...@@ -681,7 +693,7 @@ bool TDBODBC::MakeCommand(PGLOBAL g) ...@@ -681,7 +693,7 @@ bool TDBODBC::MakeCommand(PGLOBAL g)
} else { } else {
sprintf(g->Message, "Cannot use this %s command", sprintf(g->Message, "Cannot use this %s command",
(Mode == MODE_UPDATE) ? "UPDATE" : "DELETE"); (Mode == MODE_UPDATE) ? "UPDATE" : "DELETE");
return NULL; return false;
} // endif p } // endif p
Query = new(g) STRING(g, 0, stmt); Query = new(g) STRING(g, 0, stmt);
...@@ -1768,6 +1780,7 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp) ...@@ -1768,6 +1780,7 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
Dsn = tdp->GetConnect(); Dsn = tdp->GetConnect();
Schema = tdp->GetTabschema(); Schema = tdp->GetTabschema();
Tab = tdp->GetTabname(); Tab = tdp->GetTabname();
Tabtyp = tdp->Tabtyp;
Ops.User = tdp->Username; Ops.User = tdp->Username;
Ops.Pwd = tdp->Password; Ops.Pwd = tdp->Password;
Ops.Cto = tdp->Cto; Ops.Cto = tdp->Cto;
...@@ -1780,17 +1793,25 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp) ...@@ -1780,17 +1793,25 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBOTB::GetResult(PGLOBAL g) PQRYRES TDBOTB::GetResult(PGLOBAL g)
{ {
return ODBCTables(g, Dsn, Schema, Tab, Maxres, false, &Ops); return ODBCTables(g, Dsn, Schema, Tab, Tabtyp, Maxres, false, &Ops);
} // end of GetResult } // end of GetResult
/* ---------------------------TDBOCL class --------------------------- */ /* ---------------------------TDBOCL class --------------------------- */
/***********************************************************************/
/* TDBOCL class constructor. */
/***********************************************************************/
TDBOCL::TDBOCL(PODEF tdp) : TDBOTB(tdp)
{
Colpat = tdp->Colpat;
} // end of TDBOTB constructor
/***********************************************************************/ /***********************************************************************/
/* GetResult: Get the list of ODBC table columns. */ /* GetResult: Get the list of ODBC table columns. */
/***********************************************************************/ /***********************************************************************/
PQRYRES TDBOCL::GetResult(PGLOBAL g) PQRYRES TDBOCL::GetResult(PGLOBAL g)
{ {
return ODBCColumns(g, Dsn, Schema, Tab, NULL, Maxres, false, &Ops); return ODBCColumns(g, Dsn, Schema, Tab, Colpat, Maxres, false, &Ops);
} // end of GetResult } // end of GetResult
/* ------------------------ End of Tabodbc --------------------------- */ /* ------------------------ End of Tabodbc --------------------------- */
...@@ -25,7 +25,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -25,7 +25,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
friend class TDBXDBC; friend class TDBXDBC;
friend class TDBDRV; friend class TDBDRV;
friend class TDBOTB; friend class TDBOTB;
public: friend class TDBOCL;
public:
// Constructor // Constructor
ODBCDEF(void); ODBCDEF(void);
...@@ -54,7 +55,9 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -54,7 +55,9 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
PSZ Username; /* User connect name */ PSZ Username; /* User connect name */
PSZ Password; /* Password connect info */ PSZ Password; /* Password connect info */
PSZ Tabcat; /* External table catalog */ PSZ Tabcat; /* External table catalog */
PSZ Srcdef; /* The source table SQL definition */ PSZ Tabtyp; /* Catalog table type */
PSZ Colpat; /* Catalog column pattern */
PSZ Srcdef; /* The source table SQL definition */
PSZ Qchar; /* Identifier quoting character */ PSZ Qchar; /* Identifier quoting character */
PSZ Qrystr; /* The original query */ PSZ Qrystr; /* The original query */
PSZ Sep; /* Decimal separator */ PSZ Sep; /* Decimal separator */
...@@ -326,7 +329,8 @@ class TDBOTB : public TDBDRV { ...@@ -326,7 +329,8 @@ class TDBOTB : public TDBDRV {
char *Dsn; // Points to connection string char *Dsn; // Points to connection string
char *Schema; // Points to schema name or NULL char *Schema; // Points to schema name or NULL
char *Tab; // Points to ODBC table name or pattern char *Tab; // Points to ODBC table name or pattern
ODBCPARM Ops; // Additional parameters char *Tabtyp; // Points to ODBC table type
ODBCPARM Ops; // Additional parameters
}; // end of class TDBOTB }; // end of class TDBOTB
/***********************************************************************/ /***********************************************************************/
...@@ -335,13 +339,14 @@ class TDBOTB : public TDBDRV { ...@@ -335,13 +339,14 @@ class TDBOTB : public TDBDRV {
class TDBOCL : public TDBOTB { class TDBOCL : public TDBOTB {
public: public:
// Constructor // Constructor
TDBOCL(PODEF tdp) : TDBOTB(tdp) {} TDBOCL(PODEF tdp);
protected: protected:
// Specific routines // Specific routines
virtual PQRYRES GetResult(PGLOBAL g); virtual PQRYRES GetResult(PGLOBAL g);
// No additional Members // Members
char *Colpat; // Points to column pattern
}; // end of class TDBOCL }; // end of class TDBOCL
#endif // !NODBC #endif // !NODBC
...@@ -1198,7 +1198,7 @@ bool XINDEX::MapInit(PGLOBAL g) ...@@ -1198,7 +1198,7 @@ bool XINDEX::MapInit(PGLOBAL g)
const char *ftype; const char *ftype;
BYTE *mbase; BYTE *mbase;
char fn[_MAX_PATH]; char fn[_MAX_PATH];
int *nv, k, n, id = -1; int *nv, nv0, k, n, id = -1;
bool estim; bool estim;
PCOL colp; PCOL colp;
PXCOL prev = NULL, kcp = NULL; PXCOL prev = NULL, kcp = NULL;
...@@ -1288,25 +1288,26 @@ bool XINDEX::MapInit(PGLOBAL g) ...@@ -1288,25 +1288,26 @@ bool XINDEX::MapInit(PGLOBAL g)
if (nv[0] >= MAX_INDX) { if (nv[0] >= MAX_INDX) {
// New index format // New index format
Srtd = nv[7] != 0; Srtd = nv[7] != 0;
nv[0] -= MAX_INDX; nv0 = nv[0] - MAX_INDX;
mbase += NZ * sizeof(int); mbase += NZ * sizeof(int);
} else { } else {
Srtd = false; Srtd = false;
mbase += (NZ - 1) * sizeof(int); mbase += (NZ - 1) * sizeof(int);
nv0 = nv[0];
} // endif nv } // endif nv
if (trace) if (trace)
htrc("nv=%d %d %d %d %d %d %d %d\n", htrc("nv=%d %d %d %d %d %d %d %d\n",
nv[0], nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd); nv0, nv[1], nv[2], nv[3], nv[4], nv[5], nv[6], Srtd);
// The test on ID was suppressed because MariaDB can change an index ID // The test on ID was suppressed because MariaDB can change an index ID
// when other indexes are added or deleted // when other indexes are added or deleted
if (/*nv[0] != ID ||*/ nv[1] != Nk) { if (/*nv0 != ID ||*/ nv[1] != Nk) {
// Not this index // Not this index
sprintf(g->Message, MSG(BAD_INDEX_FILE), fn); sprintf(g->Message, MSG(BAD_INDEX_FILE), fn);
if (trace) if (trace)
htrc("nv[0]=%d ID=%d nv[1]=%d Nk=%d\n", nv[0], ID, nv[1], Nk); htrc("nv0=%d ID=%d nv[1]=%d Nk=%d\n", nv0, ID, nv[1], Nk);
goto err; goto err;
} // endif nv } // endif nv
......
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