Commit afecdd24 authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix and error causing remote indexing to fail when for not unique index.

  Was experienced with MYSQL, ODBC and JDBC tables.
  modified:   storage/connect/connect.cc

- Fix MDEV-9966 (zero lines returned)
  modified:   storage/connect/ha_connect.cc
  modified:   storage/federatedx/ha_federatedx.cc

- Typo
  modified:   storage/connect/odbconn.cpp
  modified:   storage/connect/reldef.cpp
  modified:   storage/connect/tabmysql.cpp

- Add new table type JDBC
  modified:   storage/connect/ha_connect.cc
  modified:   storage/connect/mycat.cc
  modified:   storage/connect/plgdbsem.h
  modified:   storage/connect/plgdbutl.cpp
  modified:   storage/connect/tabodbc.cpp
  added:      storage/connect/jdbccat.h
  added:      storage/connect/jdbconn.cpp
  added:      storage/connect/jdbconn.h
  added:      storage/connect/tabjdbc.cpp
  added:      storage/connect/tabjdbc.h
parent a1b2a28e
......@@ -752,7 +752,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
return RC_FX;
} else if (x == 2) {
// Remote index
if (ptdb->ReadKey(g, op, kr))
if (op != OP_SAME && ptdb->ReadKey(g, op, kr))
return RC_FX;
goto rnd;
......
This diff is collapsed.
// Timeout and net wait defaults
#define DEFAULT_LOGIN_TIMEOUT -1 // means do not set
#define DEFAULT_QUERY_TIMEOUT -1 // means do not set
typedef struct jdbc_parms {
int CheckSize(int rows);
char *Driver; // JDBC driver
char *Url; // Driver URL
char *User; // User connect info
char *Pwd; // Password connect info
//int Cto; // Connect timeout
//int Qto; // Query timeout
int Fsize; // Fetch size
bool Scrollable; // Scrollable cursor
} JDBCPARM, *PJPARM;
/***********************************************************************/
/* JDBC catalog function prototypes. */
/***********************************************************************/
#if defined(PROMPT_OK)
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
#endif // PROMPT_OK
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
PQRYRES JDBCColumns(PGLOBAL g, char *jpath, char *db, char *table,
char *colpat, int maxres, bool info, PJPARM sop);
PQRYRES JDBCSrcCols(PGLOBAL g, char *jpath, char *src, PJPARM sop);
PQRYRES JDBCTables(PGLOBAL g, char *jpath, char *db, char *tabpat,
char *tabtyp, int maxres, bool info, PJPARM sop);
PQRYRES JDBCDrivers(PGLOBAL g, char *jpath, int maxres, bool info);
This diff is collapsed.
/***********************************************************************/
/* JDBConn.h : header file for the JDBC connection classes. */
/***********************************************************************/
//nclude <windows.h> /* Windows include file */
//nclude <windowsx.h> /* Message crackers */
/***********************************************************************/
/* Included C-definition files required by the interface. */
/***********************************************************************/
#include "block.h"
/***********************************************************************/
/* JDBC interface. */
/***********************************************************************/
#include <jni.h>
/***********************************************************************/
/* Constants and defines. */
/***********************************************************************/
// Miscellaneous sizing info
#define MAX_NUM_OF_MSG 10 // Max number of error messages
//efine MAX_CURRENCY 30 // Max size of Currency($) string
#define MAX_TNAME_LEN 32 // Max size of table names
//efine MAX_FNAME_LEN 256 // Max size of field names
//efine MAX_STRING_INFO 256 // Max size of string from SQLGetInfo
//efine MAX_DNAME_LEN 256 // Max size of Recordset names
#define MAX_CONNECT_LEN 512 // Max size of Connect string
//efine MAX_CURSOR_NAME 18 // Max size of a cursor name
#define DEFAULT_FIELD_TYPE 0 // TYPE_NULL
#if !defined(__WIN__)
typedef unsigned char *PUCHAR;
#endif // !__WIN__
// Field Flags, used to indicate status of fields
//efine SQL_FIELD_FLAG_DIRTY 0x1
//efine SQL_FIELD_FLAG_NULL 0x2
// Update options flags
//efine SQL_SETPOSUPDATES 0x0001
//efine SQL_POSITIONEDSQL 0x0002
//efine SQL_GDBOUND 0x0004
enum JCATINFO {
CAT_TAB = 1, // JDBC Tables
CAT_COL = 2, // JDBC Columns
CAT_KEY = 3, // JDBC PrimaryKeys
//CAT_STAT = 4, // SQLStatistics
//CAT_SPC = 5 // SQLSpecialColumns
};
/***********************************************************************/
/* This structure is used to control the catalog functions. */
/***********************************************************************/
typedef struct tagJCATPARM {
JCATINFO Id; // Id to indicate function
PQRYRES Qrp; // Result set pointer
PUCHAR DB; // Database (Schema)
PUCHAR Tab; // Table name or pattern
PUCHAR Pat; // Table type or column pattern
} JCATPARM;
// JDBC connection to a data source
class TDBJDBC;
class JDBCCOL;
class JDBConn;
class TDBXJDC;
/***********************************************************************/
/* JDBConn class. */
/***********************************************************************/
class JDBConn : public BLOCK {
friend class TDBJDBC;
friend class TDBXJDC;
//friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private:
JDBConn(); // Standard (unused) constructor
public:
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
int Open(PSZ jpath, PJPARM sop);
int Rewind(char *sql);
void Close(void);
PQRYRES AllocateResult(PGLOBAL g);
// Attributes
public:
char *GetQuoteChar(void) { return m_IDQuoteChar; }
// Database successfully opened?
bool IsOpen(void) { return m_Opened; }
//PSZ GetStringInfo(ushort infotype);
int GetMaxValue(int infotype);
//PSZ GetConnect(void) { return m_Connect; }
public:
// Operations
//void SetLoginTimeout(DWORD sec) {m_LoginTimeout = sec;}
//void SetQueryTimeout(DWORD sec) {m_QueryTimeout = sec;}
//void SetUserName(PSZ user) {m_User = user;}
//void SetUserPwd(PSZ pwd) {m_Pwd = pwd;}
int GetResultSize(char *sql, JDBCCOL *colp);
int ExecuteQuery(char *sql);
int ExecuteUpdate(char *sql);
int Fetch(int pos = 0);
int PrepareSQL(char *sql);
//int ExecuteSQL(void);
//bool BindParam(JDBCCOL *colp);
int ExecSQLcommand(char *sql);
void SetColumnValue(int rank, PSZ name, PVAL val);
int GetCatInfo(JCATPARM *cap);
//bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *src);
public:
// Set special options
//void OnSetOptions(HSTMT hstmt);
// Implementation
public:
//virtual ~JDBConn();
// JDBC operations
protected:
//bool Check(RETCODE rc);
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
//void ThrowDJX(PSZ msg);
//void AllocConnect(DWORD dwOptions);
//void Connect(void);
//bool DriverConnect(DWORD Options);
//void VerifyConnect(void);
//void GetConnectInfo(void);
//void Free(void);
protected:
// Static members
//static HENV m_henv;
//static int m_nAlloc; // per-Appl reference to HENV above
// Members
PGLOBAL m_G;
TDBJDBC *m_Tdb;
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
JNIEnv *env; // Pointer to native interface
jclass jdi; // Pointer to the JdbcInterface class
jobject job; // The JdbcInterface class object
jmethodID xqid; // The ExecuteQuery method ID
jmethodID xuid; // The ExecuteUpdate method ID
jmethodID xid; // The Execute method ID
jmethodID grs; // The GetResult method ID
jmethodID readid; // The ReadNext method ID
jmethodID fetchid; // The Fetch method ID
jmethodID typid; // The ColumnType method ID
//DWORD m_LoginTimeout;
//DWORD m_QueryTimeout;
//DWORD m_UpdateOptions;
char m_IDQuoteChar[2];
PSZ m_Driver;
PSZ m_Url;
PSZ m_User;
PSZ m_Pwd;
int m_Ncol;
int m_Aff;
int m_Rows;
int m_Fetch;
int m_RowsetSize;
jboolean m_Updatable;
jboolean m_Transact;
jboolean m_Scrollable;
bool m_Opened;
bool m_Full;
}; // end of JDBConn class definition
......@@ -80,6 +80,10 @@
#define NODBC
#include "tabodbc.h"
#endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT)
#define NJDBC
#include "tabjdbc.h"
#endif // ODBC_SUPPORT
#if defined(PIVOT_SUPPORT)
#include "tabpivot.h"
#endif // PIVOT_SUPPORT
......@@ -140,7 +144,10 @@ TABTYPE GetTypeID(const char *type)
#ifdef ODBC_SUPPORT
: (!stricmp(type, "ODBC")) ? TAB_ODBC
#endif
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL
#ifdef JDBC_SUPPORT
: (!stricmp(type, "JDBC")) ? TAB_JDBC
#endif
: (!stricmp(type, "MYSQL")) ? TAB_MYSQL
: (!stricmp(type, "MYPRX")) ? TAB_MYSQL
: (!stricmp(type, "DIR")) ? TAB_DIR
#ifdef __WIN__
......@@ -301,12 +308,12 @@ int GetIndexType(TABTYPE type)
break;
case TAB_MYSQL:
case TAB_ODBC:
xtyp= 2;
case TAB_JDBC:
xtyp= 2;
break;
case TAB_VIR:
xtyp= 3;
break;
// case TAB_ODBC:
default:
xtyp= 0;
break;
......@@ -558,6 +565,9 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
#if defined(ODBC_SUPPORT)
case TAB_ODBC: tdp= new(g) ODBCDEF; break;
#endif // ODBC_SUPPORT
#if defined(JDBC_SUPPORT)
case TAB_JDBC: tdp= new(g)JDBCDEF; break;
#endif // JDBC_SUPPORT
#if defined(__WIN__)
case TAB_MAC: tdp= new(g) MACDEF; break;
case TAB_WMI: tdp= new(g) WMIDEF; break;
......
......@@ -1458,7 +1458,7 @@ int ODBConn::ExecDirectSQL(char *sql, ODBCCOL *tocols)
n++;
// n can be 0 for query such as Select count(*) from table
if (n && n != (UWORD)ncol)
if (n && n > (UWORD)ncol)
ThrowDBX(MSG(COL_NUM_MISM));
// Now bind the column buffers
......
......@@ -77,7 +77,8 @@ enum TABTYPE {TAB_UNDEF = 0, /* Table of undefined type */
TAB_JSON = 23, /* JSON tables */
TAB_JCT = 24, /* Junction tables NIY */
TAB_DMY = 25, /* DMY Dummy tables NIY */
TAB_NIY = 26}; /* Table not implemented yet */
TAB_JDBC = 26, /* Table accessed via JDBC */
TAB_NIY = 27}; /* Table not implemented yet */
enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_ROWID = 1, /* ROWID type (special column) */
......@@ -109,7 +110,9 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_DIR = 90, /* DIR access method type no */
TYPE_AM_ODBC = 100, /* ODBC access method type no */
TYPE_AM_XDBC = 101, /* XDBC access method type no */
TYPE_AM_OEM = 110, /* OEM access method type no */
TYPE_AM_JDBC = 102, /* JDBC access method type no */
TYPE_AM_XJDC = 103, /* XJDC access method type no */
TYPE_AM_OEM = 110, /* OEM access method type no */
TYPE_AM_TBL = 115, /* TBL access method type no */
TYPE_AM_PIVOT = 120, /* PIVOT access method type no */
TYPE_AM_SRC = 121, /* PIVOT multiple column type no */
......@@ -146,8 +149,9 @@ enum RECFM {RECFM_NAF = -2, /* Not a file */
RECFM_BIN = 2, /* Binary DOS files (also fixed) */
RECFM_VCT = 3, /* VCT formatted files */
RECFM_ODBC = 4, /* Table accessed via ODBC */
RECFM_PLG = 5, /* Table accessed via PLGconn */
RECFM_DBF = 6}; /* DBase formatted file */
RECFM_JDBC = 5, /* Table accessed via JDBC */
RECFM_PLG = 6, /* Table accessed via PLGconn */
RECFM_DBF = 7}; /* DBase formatted file */
enum MISC {DB_TABNO = 1, /* DB routines in Utility Table */
MAX_MULT_KEY = 10, /* Max multiple key number */
......
......@@ -1102,7 +1102,8 @@ char *GetAmName(PGLOBAL g, AMT am, void *memp)
case TYPE_AM_DOM: strcpy(amn, "DOM"); break;
case TYPE_AM_DIR: strcpy(amn, "DIR"); break;
case TYPE_AM_ODBC: strcpy(amn, "ODBC"); break;
case TYPE_AM_MAC: strcpy(amn, "MAC"); break;
case TYPE_AM_JDBC: strcpy(amn, "JDBC"); break;
case TYPE_AM_MAC: strcpy(amn, "MAC"); break;
case TYPE_AM_OEM: strcpy(amn, "OEM"); break;
case TYPE_AM_OUT: strcpy(amn, "OUT"); break;
default: sprintf(amn, "OEM(%d)", am);
......
......@@ -305,7 +305,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
case TAB_OEM:
poff = 0; // Offset represents an independant flag
break;
default: // VCT PLG ODBC MYSQL WMI...
default: // VCT PLG ODBC JDBC MYSQL WMI...
poff = 0; // NA
break;
} // endswitch tc
......
This diff is collapsed.
This diff is collapsed.
......@@ -19,7 +19,7 @@
/* --------------- */
/* TABMYSQL.CPP - Source code */
/* PLGDBSEM.H - DB application declaration file */
/* TABMYSQL.H - TABODBC classes declaration file */
/* TABMYSQL.H - TABMYSQL classes declaration file */
/* GLOBAL.H - Global declaration file */
/* */
/* REQUIRED LIBRARIES: */
......
......@@ -97,8 +97,8 @@ ODBCDEF::ODBCDEF(void)
{
Connect = Tabname = Tabschema = Username = Password = NULL;
Tabcat = Srcdef = Qchar = Qrystr = Sep = NULL;
Catver = Options = Cto = Qto = Quoted = Maxerr = Maxres = 0;
Scrollable = Memory = Xsrc = UseCnc = false;
Catver = Options = Cto = Qto = Quoted = Maxerr = Maxres = Memory = 0;
Scrollable = Xsrc = UseCnc = false;
} // end of ODBCDEF constructor
/***********************************************************************/
......@@ -1009,7 +1009,7 @@ bool TDBODBC::SetRecpos(PGLOBAL g, int recpos)
} // end of SetRecpos
/***********************************************************************/
/* Data Base indexed read routine for MYSQL access method. */
/* Data Base indexed read routine for ODBC access method. */
/***********************************************************************/
bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
{
......@@ -1028,7 +1028,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr)
return false;
} else {
if (To_Def->GetHandler()->MakeKeyWhere(g, Query, op, c, kr))
if (hc->MakeKeyWhere(g, Query, op, c, kr))
return true;
if (To_CondFil) {
......
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