mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Merge branch 'connect/10.1' into 10.1
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -9,6 +9,7 @@
|
|||||||
*.cpp text
|
*.cpp text
|
||||||
*.h text
|
*.h text
|
||||||
*.test text
|
*.test text
|
||||||
|
*.java text
|
||||||
|
|
||||||
# These files should be checked out as is
|
# These files should be checked out as is
|
||||||
*.result -text -whitespace
|
*.result -text -whitespace
|
||||||
@@ -23,9 +24,11 @@ pcre/testdata/greppatN4 -text
|
|||||||
*.frm binary
|
*.frm binary
|
||||||
*.MYD binary
|
*.MYD binary
|
||||||
*.MYI binary
|
*.MYI binary
|
||||||
|
*.class binary
|
||||||
|
|
||||||
*.c diff=cpp
|
*.c diff=cpp
|
||||||
*.h diff=cpp
|
*.h diff=cpp
|
||||||
*.cc diff=cpp
|
*.cc diff=cpp
|
||||||
*.ic diff=cpp
|
*.ic diff=cpp
|
||||||
*.cpp diff=cpp
|
*.cpp diff=cpp
|
||||||
|
*.java diff=cpp
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -244,6 +244,8 @@ storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result
|
|||||||
*.exp
|
*.exp
|
||||||
*.dep
|
*.dep
|
||||||
*.idb
|
*.idb
|
||||||
|
*.res
|
||||||
|
*.tlog
|
||||||
|
|
||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
|
Binary file not shown.
@@ -307,7 +307,7 @@ 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();
|
||||||
|
@@ -129,7 +129,8 @@
|
|||||||
#include "odbccat.h"
|
#include "odbccat.h"
|
||||||
#endif // ODBC_SUPPORT
|
#endif // ODBC_SUPPORT
|
||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
#include "jdbccat.h"
|
#include "tabjdbc.h"
|
||||||
|
#include "jdbconn.h"
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
#include "xtable.h"
|
#include "xtable.h"
|
||||||
#include "tabmysql.h"
|
#include "tabmysql.h"
|
||||||
@@ -5163,7 +5164,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
#endif // ODBC_SUPPORT
|
#endif // ODBC_SUPPORT
|
||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
PJPARM sjp= NULL;
|
PJPARM sjp= NULL;
|
||||||
char *jpath= NULL;
|
|
||||||
char *driver= NULL;
|
char *driver= NULL;
|
||||||
char *url= NULL;
|
char *url= NULL;
|
||||||
char *tabtyp = NULL;
|
char *tabtyp = NULL;
|
||||||
@@ -5230,9 +5230,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
cnc= (!*ucnc || *ucnc == 'y' || *ucnc == 'Y' || atoi(ucnc) != 0);
|
cnc= (!*ucnc || *ucnc == 'y' || *ucnc == 'Y' || atoi(ucnc) != 0);
|
||||||
#endif
|
#endif
|
||||||
#if defined(JDBC_SUPPORT)
|
#if defined(JDBC_SUPPORT)
|
||||||
jpath= GetListOption(g, "Jpath", topt->oplist, NULL);
|
|
||||||
driver= GetListOption(g, "Driver", topt->oplist, NULL);
|
driver= GetListOption(g, "Driver", topt->oplist, NULL);
|
||||||
url= GetListOption(g, "URL", topt->oplist, NULL);
|
// url= GetListOption(g, "URL", topt->oplist, NULL);
|
||||||
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
|
tabtyp = GetListOption(g, "Tabtype", topt->oplist, NULL);
|
||||||
#endif // JDBC_SUPPORT
|
#endif // JDBC_SUPPORT
|
||||||
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
||||||
@@ -5333,18 +5332,31 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
case TAB_JDBC:
|
case TAB_JDBC:
|
||||||
if (fnc & FNC_DRIVER) {
|
if (fnc & FNC_DRIVER) {
|
||||||
ok= true;
|
ok= true;
|
||||||
} else if (!url) {
|
} else if (!(url= strz(g, create_info->connect_string))) {
|
||||||
strcpy(g->Message, "Missing URL");
|
strcpy(g->Message, "Missing URL");
|
||||||
} else {
|
} else {
|
||||||
// Store ODBC additional parameters
|
// Store JDBC additional parameters
|
||||||
|
int rc;
|
||||||
|
PJDBCDEF jdef= new(g) JDBCDEF();
|
||||||
|
|
||||||
|
jdef->SetName(create_info->alias);
|
||||||
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
|
sjp= (PJPARM)PlugSubAlloc(g, NULL, sizeof(JDBCPARM));
|
||||||
sjp->Driver= driver;
|
sjp->Driver= driver;
|
||||||
sjp->Url= url;
|
|
||||||
sjp->User= (char*)user;
|
|
||||||
sjp->Pwd= (char*)pwd;
|
|
||||||
sjp->Fsize= 0;
|
sjp->Fsize= 0;
|
||||||
sjp->Scrollable= false;
|
sjp->Scrollable= false;
|
||||||
ok= true;
|
|
||||||
|
if ((rc = jdef->ParseURL(g, url, false)) == RC_OK) {
|
||||||
|
sjp->Url= url;
|
||||||
|
sjp->User= (char*)user;
|
||||||
|
sjp->Pwd= (char*)pwd;
|
||||||
|
ok= true;
|
||||||
|
} else if (rc == RC_NF) {
|
||||||
|
if (jdef->GetTabname())
|
||||||
|
tab= jdef->GetTabname();
|
||||||
|
|
||||||
|
ok= jdef->SetParms(sjp);
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
} // endif's
|
} // endif's
|
||||||
|
|
||||||
supfnc |= (FNC_DRIVER | FNC_TABLE);
|
supfnc |= (FNC_DRIVER | FNC_TABLE);
|
||||||
@@ -5496,7 +5508,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);
|
||||||
@@ -5517,15 +5529,14 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
case FNC_NO:
|
case FNC_NO:
|
||||||
case FNC_COL:
|
case FNC_COL:
|
||||||
if (src) {
|
if (src) {
|
||||||
qrp= JDBCSrcCols(g, jpath, (char*)src, sjp);
|
qrp= JDBCSrcCols(g, (char*)src, sjp);
|
||||||
src= NULL; // for next tests
|
src= NULL; // for next tests
|
||||||
} else
|
} else
|
||||||
qrp= JDBCColumns(g, jpath, shm, tab, NULL,
|
qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
||||||
mxr, fnc == FNC_COL, sjp);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FNC_TABLE:
|
case FNC_TABLE:
|
||||||
qrp= JDBCTables(g, dsn, shm, tab, tabtyp, mxr, true, sjp);
|
qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case FNC_DSN:
|
case FNC_DSN:
|
||||||
@@ -5533,7 +5544,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
break;
|
break;
|
||||||
#endif // 0
|
#endif // 0
|
||||||
case FNC_DRIVER:
|
case FNC_DRIVER:
|
||||||
qrp= JDBCDrivers(g, jpath, mxr, true);
|
qrp= JDBCDrivers(g, mxr, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||||
@@ -5784,12 +5795,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
|||||||
|
|
||||||
switch (typ) {
|
switch (typ) {
|
||||||
case TYPE_DOUBLE:
|
case TYPE_DOUBLE:
|
||||||
|
case TYPE_DECIM:
|
||||||
// Some data sources do not count dec in length (prec)
|
// Some data sources do not count dec in length (prec)
|
||||||
prec += (dec + 2); // To be safe
|
prec += (dec + 2); // To be safe
|
||||||
break;
|
break;
|
||||||
case TYPE_DECIM:
|
|
||||||
prec= len;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
dec= 0;
|
dec= 0;
|
||||||
} // endswitch typ
|
} // endswitch typ
|
||||||
|
@@ -21,9 +21,9 @@ typedef struct jdbc_parms {
|
|||||||
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
char *JDBCCheckConnection(PGLOBAL g, char *dsn, int cop);
|
||||||
#endif // PROMPT_OK
|
#endif // PROMPT_OK
|
||||||
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
|
//PQRYRES JDBCDataSources(PGLOBAL g, int maxres, bool info);
|
||||||
PQRYRES JDBCColumns(PGLOBAL g, char *jpath, char *db, char *table,
|
PQRYRES JDBCColumns(PGLOBAL g, char *db, char *table,
|
||||||
char *colpat, int maxres, bool info, PJPARM sop);
|
char *colpat, int maxres, bool info, PJPARM sop);
|
||||||
PQRYRES JDBCSrcCols(PGLOBAL g, char *jpath, char *src, PJPARM sop);
|
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
|
||||||
PQRYRES JDBCTables(PGLOBAL g, char *jpath, char *db, char *tabpat,
|
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
|
||||||
char *tabtyp, int maxres, bool info, PJPARM sop);
|
char *tabtyp, int maxres, bool info, PJPARM sop);
|
||||||
PQRYRES JDBCDrivers(PGLOBAL g, char *jpath, int maxres, bool info);
|
PQRYRES JDBCDrivers(PGLOBAL g, int maxres, bool info);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,15 +32,6 @@
|
|||||||
typedef unsigned char *PUCHAR;
|
typedef unsigned char *PUCHAR;
|
||||||
#endif // !__WIN__
|
#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 {
|
enum JCATINFO {
|
||||||
CAT_TAB = 1, // JDBC Tables
|
CAT_TAB = 1, // JDBC Tables
|
||||||
CAT_COL = 2, // JDBC Columns
|
CAT_COL = 2, // JDBC Columns
|
||||||
@@ -55,11 +46,17 @@ 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 *GETJVM) (JavaVM **, jsize, jsize *);
|
||||||
|
#if defined(_DEBUG)
|
||||||
|
typedef jint(JNICALL *GETDEF) (void *);
|
||||||
|
#endif // _DEBUG
|
||||||
|
|
||||||
// JDBC connection to a data source
|
// JDBC connection to a data source
|
||||||
class TDBJDBC;
|
class TDBJDBC;
|
||||||
class JDBCCOL;
|
class JDBCCOL;
|
||||||
@@ -79,7 +76,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
|
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
|
||||||
|
|
||||||
int Open(PSZ jpath, PJPARM sop);
|
int Open(PJPARM sop);
|
||||||
int Rewind(char *sql);
|
int Rewind(char *sql);
|
||||||
void Close(void);
|
void Close(void);
|
||||||
PQRYRES AllocateResult(PGLOBAL g);
|
PQRYRES AllocateResult(PGLOBAL g);
|
||||||
@@ -114,8 +111,18 @@ public:
|
|||||||
PQRYRES GetMetaData(PGLOBAL g, char *src);
|
PQRYRES GetMetaData(PGLOBAL g, char *src);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Set special options
|
// Set static variables
|
||||||
//void OnSetOptions(HSTMT hstmt);
|
static void SetJVM(void) {
|
||||||
|
LibJvm = NULL;
|
||||||
|
CreateJavaVM = NULL;
|
||||||
|
GetCreatedJavaVMs = NULL;
|
||||||
|
#if defined(_DEBUG)
|
||||||
|
GetDefaultJavaVMInitArgs = NULL;
|
||||||
|
#endif // _DEBUG
|
||||||
|
} // end of SetJVM
|
||||||
|
|
||||||
|
static void ResetJVM(void);
|
||||||
|
static bool GetJVM(PGLOBAL g);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
public:
|
public:
|
||||||
@@ -123,24 +130,30 @@ public:
|
|||||||
|
|
||||||
// JDBC operations
|
// JDBC operations
|
||||||
protected:
|
protected:
|
||||||
//bool Check(RETCODE rc);
|
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
|
||||||
|
bool Check(jint rc = 0);
|
||||||
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
|
//void ThrowDJX(int rc, PSZ msg/*, HSTMT hstmt = SQL_NULL_HSTMT*/);
|
||||||
//void ThrowDJX(PSZ msg);
|
//void ThrowDJX(PSZ msg);
|
||||||
//void AllocConnect(DWORD dwOptions);
|
|
||||||
//void Connect(void);
|
|
||||||
//bool DriverConnect(DWORD Options);
|
|
||||||
//void VerifyConnect(void);
|
|
||||||
//void GetConnectInfo(void);
|
|
||||||
//void Free(void);
|
//void Free(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
|
#if defined(__WIN__)
|
||||||
|
static HANDLE LibJvm; // Handle to the jvm DLL
|
||||||
|
#else // !__WIN__
|
||||||
|
static void *LibJvm; // Handle for the jvm shared library
|
||||||
|
#endif // !__WIN__
|
||||||
|
static CRTJVM CreateJavaVM;
|
||||||
|
static GETJVM GetCreatedJavaVMs;
|
||||||
|
#if defined(_DEBUG)
|
||||||
|
static GETDEF GetDefaultJavaVMInitArgs;
|
||||||
|
#endif // _DEBUG
|
||||||
PGLOBAL m_G;
|
PGLOBAL m_G;
|
||||||
TDBJDBC *m_Tdb;
|
TDBJDBC *m_Tdb;
|
||||||
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
|
JavaVM *jvm; // Pointer to the JVM (Java Virtual Machine)
|
||||||
JNIEnv *env; // Pointer to native interface
|
JNIEnv *env; // Pointer to native interface
|
||||||
jclass jdi; // Pointer to the JdbcInterface class
|
jclass jdi; // Pointer to the java wrapper class
|
||||||
jobject job; // The JdbcInterface class object
|
jobject job; // The java wrapper class object
|
||||||
jmethodID xqid; // The ExecuteQuery method ID
|
jmethodID xqid; // The ExecuteQuery method ID
|
||||||
jmethodID xuid; // The ExecuteUpdate method ID
|
jmethodID xuid; // The ExecuteUpdate method ID
|
||||||
jmethodID xid; // The Execute method ID
|
jmethodID xid; // The Execute method ID
|
||||||
@@ -151,9 +164,17 @@ protected:
|
|||||||
jmethodID prepid; // The CreatePrepStmt method ID
|
jmethodID prepid; // The CreatePrepStmt method ID
|
||||||
jmethodID xpid; // The ExecutePrep method ID
|
jmethodID xpid; // The ExecutePrep method ID
|
||||||
jmethodID pcid; // The ClosePrepStmt method ID
|
jmethodID pcid; // The ClosePrepStmt method ID
|
||||||
|
jmethodID errid; // The GetErrmsg method ID
|
||||||
|
jmethodID chrfldid; // The StringField method ID
|
||||||
|
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 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 m_IDQuoteChar[2];
|
char m_IDQuoteChar[2];
|
||||||
PSZ m_Driver;
|
PSZ m_Driver;
|
||||||
PSZ m_Url;
|
PSZ m_Url;
|
||||||
|
@@ -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);
|
||||||
|
@@ -606,7 +606,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 +668,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);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************* TabJDBC C++ Program Source Code File (.CPP) *************/
|
/************* TabJDBC C++ Program Source Code File (.CPP) *************/
|
||||||
/* PROGRAM NAME: TABJDBC */
|
/* PROGRAM NAME: TABJDBC */
|
||||||
/* ------------- */
|
/* ------------- */
|
||||||
/* Version 1.0 */
|
/* Version 1.1 */
|
||||||
/* */
|
/* */
|
||||||
/* COPYRIGHT: */
|
/* COPYRIGHT: */
|
||||||
/* ---------- */
|
/* ---------- */
|
||||||
@@ -34,8 +34,10 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Include relevant MariaDB header file. */
|
/* Include relevant MariaDB header file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
#define MYSQL_SERVER 1
|
||||||
#include "my_global.h"
|
#include "my_global.h"
|
||||||
#include "sql_class.h"
|
#include "sql_class.h"
|
||||||
|
#include "sql_servers.h"
|
||||||
#if defined(__WIN__)
|
#if defined(__WIN__)
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -67,7 +69,6 @@
|
|||||||
#include "plgdbsem.h"
|
#include "plgdbsem.h"
|
||||||
#include "mycat.h"
|
#include "mycat.h"
|
||||||
#include "xtable.h"
|
#include "xtable.h"
|
||||||
#include "jdbccat.h"
|
|
||||||
#include "tabjdbc.h"
|
#include "tabjdbc.h"
|
||||||
#include "tabmul.h"
|
#include "tabmul.h"
|
||||||
#include "reldef.h"
|
#include "reldef.h"
|
||||||
@@ -95,48 +96,160 @@ bool ExactInfo(void);
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
JDBCDEF::JDBCDEF(void)
|
JDBCDEF::JDBCDEF(void)
|
||||||
{
|
{
|
||||||
Jpath = Driver = Url = Tabname = Tabschema = Username = NULL;
|
Driver = Url = 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;
|
||||||
} // end of JDBCDEF constructor
|
} // end of JDBCDEF constructor
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Called on table construction. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool JDBCDEF::SetParms(PJPARM sjp)
|
||||||
|
{
|
||||||
|
sjp->Url= Url;
|
||||||
|
sjp->User= Username;
|
||||||
|
sjp->Pwd= Password;
|
||||||
|
return true;
|
||||||
|
} // end of SetParms
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Parse connection string */
|
||||||
|
/* */
|
||||||
|
/* SYNOPSIS */
|
||||||
|
/* ParseURL() */
|
||||||
|
/* Url The connection string to parse */
|
||||||
|
/* */
|
||||||
|
/* DESCRIPTION */
|
||||||
|
/* This is used to set the Url in case a wrapper server as been */
|
||||||
|
/* specified. This is rather experimental yet. */
|
||||||
|
/* */
|
||||||
|
/* RETURN VALUE */
|
||||||
|
/* RC_OK Url was a true URL */
|
||||||
|
/* RC_NF Url was a server name/table */
|
||||||
|
/* RC_FX Error */
|
||||||
|
/* */
|
||||||
|
/***********************************************************************/
|
||||||
|
int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b)
|
||||||
|
{
|
||||||
|
if (strncmp(url, "jdbc:", 5)) {
|
||||||
|
// No "jdbc:" in connection string. Must be a straight
|
||||||
|
// "server" or "server/table"
|
||||||
|
// ok, so we do a little parsing, but not completely!
|
||||||
|
if ((Tabname= strchr(url, '/'))) {
|
||||||
|
// If there is a single '/' in the connection string,
|
||||||
|
// this means the user is specifying a table name
|
||||||
|
*Tabname++= '\0';
|
||||||
|
|
||||||
|
// there better not be any more '/'s !
|
||||||
|
if (strchr(Tabname, '/'))
|
||||||
|
return RC_FX;
|
||||||
|
|
||||||
|
} else if (b) {
|
||||||
|
// Otherwise, straight server name,
|
||||||
|
Tabname = GetStringCatInfo(g, "Name", NULL);
|
||||||
|
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
||||||
|
} // endelse
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
htrc("server: %s Tabname: %s", url, Tabname);
|
||||||
|
|
||||||
|
// Now make the required URL
|
||||||
|
FOREIGN_SERVER *server, server_buffer;
|
||||||
|
|
||||||
|
// get_server_by_name() clones the server if exists
|
||||||
|
if (!(server= get_server_by_name(current_thd->mem_root, url, &server_buffer))) {
|
||||||
|
sprintf(g->Message, "Server %s does not exist!", url);
|
||||||
|
return RC_FX;
|
||||||
|
} // endif server
|
||||||
|
|
||||||
|
if (strncmp(server->host, "jdbc:", 5)) {
|
||||||
|
// Now make the required URL
|
||||||
|
Url = (PSZ)PlugSubAlloc(g, NULL, 0);
|
||||||
|
strcat(strcpy(Url, "jdbc:"), server->scheme);
|
||||||
|
strcat(strcat(Url, "://"), server->host);
|
||||||
|
|
||||||
|
if (server->port) {
|
||||||
|
char buf[16];
|
||||||
|
|
||||||
|
sprintf(buf, "%ld", server->port);
|
||||||
|
strcat(strcat(Url, ":"), buf);
|
||||||
|
} // endif port
|
||||||
|
|
||||||
|
if (server->db)
|
||||||
|
strcat(strcat(Url, "/"), server->db);
|
||||||
|
|
||||||
|
PlugSubAlloc(g, NULL, strlen(Url) + 1);
|
||||||
|
} else // host is a URL
|
||||||
|
Url = PlugDup(g, server->host);
|
||||||
|
|
||||||
|
if (server->username)
|
||||||
|
Username = PlugDup(g, server->username);
|
||||||
|
|
||||||
|
if (server->password)
|
||||||
|
Password = PlugDup(g, server->password);
|
||||||
|
|
||||||
|
return RC_NF;
|
||||||
|
} // endif
|
||||||
|
|
||||||
|
// Url was a JDBC URL, nothing to do
|
||||||
|
return RC_OK;
|
||||||
|
} // end of ParseURL
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* DefineAM: define specific AM block values from JDBC file. */
|
/* DefineAM: define specific AM block values from JDBC file. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||||
{
|
{
|
||||||
Jpath = GetStringCatInfo(g, "Jpath", "");
|
int rc = RC_OK;
|
||||||
|
|
||||||
Driver = GetStringCatInfo(g, "Driver", NULL);
|
Driver = GetStringCatInfo(g, "Driver", NULL);
|
||||||
Desc = Url = GetStringCatInfo(g, "Url", NULL);
|
Desc = Url = GetStringCatInfo(g, "Connect", NULL);
|
||||||
|
|
||||||
if (!Url && !Catfunc) {
|
if (!Url && !Catfunc) {
|
||||||
sprintf(g->Message, "Missing URL for JDBC table %s", Name);
|
// Look in the option list (deprecated)
|
||||||
return true;
|
Url = GetStringCatInfo(g, "Url", NULL);
|
||||||
|
|
||||||
|
if (!Url) {
|
||||||
|
sprintf(g->Message, "Missing URL for JDBC table %s", Name);
|
||||||
|
return true;
|
||||||
|
} // endif Url
|
||||||
|
|
||||||
} // endif Connect
|
} // endif Connect
|
||||||
|
|
||||||
Tabname = GetStringCatInfo(g, "Name",
|
if (Url)
|
||||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
rc = ParseURL(g, Url);
|
||||||
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
|
||||||
Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
if (rc == RC_FX) // Error
|
||||||
Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
return true;
|
||||||
Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
else if (rc == RC_OK) { // Url was not a server name
|
||||||
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
Tabname = GetStringCatInfo(g, "Name",
|
||||||
Tabtype = GetStringCatInfo(g, "Tabtype", NULL);
|
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||||
Username = GetStringCatInfo(g, "User", NULL);
|
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
||||||
Password = GetStringCatInfo(g, "Password", NULL);
|
Username = GetStringCatInfo(g, "User", NULL);
|
||||||
|
Password = GetStringCatInfo(g, "Password", NULL);
|
||||||
|
} // endif rc
|
||||||
|
|
||||||
if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
||||||
Read_Only = true;
|
Read_Only = true;
|
||||||
|
|
||||||
|
Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
||||||
|
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
||||||
|
Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
||||||
|
Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
||||||
|
|
||||||
|
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);
|
||||||
Maxerr = GetIntCatInfo("Maxerr", 0);
|
Maxerr = GetIntCatInfo("Maxerr", 0);
|
||||||
Maxres = GetIntCatInfo("Maxres", 0);
|
Maxres = GetIntCatInfo("Maxres", 0);
|
||||||
Quoted = GetIntCatInfo("Quoted", 0);
|
Quoted = GetIntCatInfo("Quoted", 0);
|
||||||
//Options = JDBConn::noJDBCDialog;
|
|
||||||
//Options = JDBConn::noJDBCDialog | JDBConn::useCursorLib;
|
|
||||||
//Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
//Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
||||||
//Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
//Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
||||||
Scrollable = GetBoolCatInfo("Scrollable", false);
|
Scrollable = GetBoolCatInfo("Scrollable", false);
|
||||||
@@ -198,7 +311,7 @@ int JDBCPARM::CheckSize(int rows)
|
|||||||
if (Url && rows == 1) {
|
if (Url && rows == 1) {
|
||||||
// Are we connected to a MySQL JDBC connector?
|
// Are we connected to a MySQL JDBC connector?
|
||||||
bool b = (!strncmp(Url, "jdbc:mysql:", 11) ||
|
bool b = (!strncmp(Url, "jdbc:mysql:", 11) ||
|
||||||
!strncmp(Url, "jdbc:mariadb:", 13));
|
!strncmp(Url, "jdbc:mariadb:", 13));
|
||||||
return b ? INT_MIN32 : rows;
|
return b ? INT_MIN32 : rows;
|
||||||
} else
|
} else
|
||||||
return rows;
|
return rows;
|
||||||
@@ -216,7 +329,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
|||||||
Cnp = NULL;
|
Cnp = NULL;
|
||||||
|
|
||||||
if (tdp) {
|
if (tdp) {
|
||||||
Jpath = tdp->Jpath;
|
|
||||||
Ops.Driver = tdp->Driver;
|
Ops.Driver = tdp->Driver;
|
||||||
Ops.Url = tdp->Url;
|
Ops.Url = tdp->Url;
|
||||||
TableName = tdp->Tabname;
|
TableName = tdp->Tabname;
|
||||||
@@ -235,7 +347,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
|||||||
Memory = tdp->Memory;
|
Memory = tdp->Memory;
|
||||||
Ops.Scrollable = tdp->Scrollable;
|
Ops.Scrollable = tdp->Scrollable;
|
||||||
} else {
|
} else {
|
||||||
Jpath = NULL;
|
|
||||||
TableName = NULL;
|
TableName = NULL;
|
||||||
Schema = NULL;
|
Schema = NULL;
|
||||||
Ops.Driver = NULL;
|
Ops.Driver = NULL;
|
||||||
@@ -271,6 +382,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
|||||||
Ncol = 0;
|
Ncol = 0;
|
||||||
Nparm = 0;
|
Nparm = 0;
|
||||||
Placed = false;
|
Placed = false;
|
||||||
|
Prepared = false;
|
||||||
Werr = false;
|
Werr = false;
|
||||||
Rerr = false;
|
Rerr = false;
|
||||||
Ops.Fsize = Ops.CheckSize(Rows);
|
Ops.Fsize = Ops.CheckSize(Rows);
|
||||||
@@ -280,7 +392,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp)
|
|||||||
{
|
{
|
||||||
Jcp = tdbp->Jcp; // is that right ?
|
Jcp = tdbp->Jcp; // is that right ?
|
||||||
Cnp = tdbp->Cnp;
|
Cnp = tdbp->Cnp;
|
||||||
Jpath = tdbp->Jpath;
|
|
||||||
TableName = tdbp->TableName;
|
TableName = tdbp->TableName;
|
||||||
Schema = tdbp->Schema;
|
Schema = tdbp->Schema;
|
||||||
Ops = tdbp->Ops;
|
Ops = tdbp->Ops;
|
||||||
@@ -678,7 +789,7 @@ int TDBJDBC::Cardinality(PGLOBAL g)
|
|||||||
char qry[96], tbn[64];
|
char qry[96], tbn[64];
|
||||||
JDBConn *jcp = new(g)JDBConn(g, this);
|
JDBConn *jcp = new(g)JDBConn(g, this);
|
||||||
|
|
||||||
if (jcp->Open(Jpath, &Ops) == RC_FX)
|
if (jcp->Open(&Ops) == RC_FX)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Table name can be encoded in UTF-8
|
// Table name can be encoded in UTF-8
|
||||||
@@ -789,7 +900,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
|
|||||||
else if (Jcp->IsOpen())
|
else if (Jcp->IsOpen())
|
||||||
Jcp->Close();
|
Jcp->Close();
|
||||||
|
|
||||||
if (Jcp->Open(Jpath, &Ops) == RC_FX)
|
if (Jcp->Open(&Ops) == RC_FX)
|
||||||
return true;
|
return true;
|
||||||
else if (Quoted)
|
else if (Quoted)
|
||||||
Quote = Jcp->GetQuoteChar();
|
Quote = Jcp->GetQuoteChar();
|
||||||
@@ -1539,7 +1650,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
|
|||||||
} else if (Jcp->IsOpen())
|
} else if (Jcp->IsOpen())
|
||||||
Jcp->Close();
|
Jcp->Close();
|
||||||
|
|
||||||
if (Jcp->Open(Jpath, &Ops) == RC_FX)
|
if (Jcp->Open(&Ops) == RC_FX)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Use = USE_OPEN; // Do it now in case we are recursively called
|
Use = USE_OPEN; // Do it now in case we are recursively called
|
||||||
@@ -1651,7 +1762,7 @@ void JSRCCOL::WriteColumn(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES TDBJDRV::GetResult(PGLOBAL g)
|
PQRYRES TDBJDRV::GetResult(PGLOBAL g)
|
||||||
{
|
{
|
||||||
return JDBCDrivers(g, Jpath, Maxres, false);
|
return JDBCDrivers(g, Maxres, false);
|
||||||
} // end of GetResult
|
} // end of GetResult
|
||||||
|
|
||||||
/* ---------------------------TDBJTB class --------------------------- */
|
/* ---------------------------TDBJTB class --------------------------- */
|
||||||
@@ -1661,7 +1772,6 @@ PQRYRES TDBJDRV::GetResult(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
||||||
{
|
{
|
||||||
Jpath = tdp->Jpath;
|
|
||||||
Schema = tdp->Tabschema;
|
Schema = tdp->Tabschema;
|
||||||
Tab = tdp->Tabname;
|
Tab = tdp->Tabname;
|
||||||
Tabtype = tdp->Tabtype;
|
Tabtype = tdp->Tabtype;
|
||||||
@@ -1669,6 +1779,8 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
|||||||
Ops.Url = tdp->Url;
|
Ops.Url = tdp->Url;
|
||||||
Ops.User = tdp->Username;
|
Ops.User = tdp->Username;
|
||||||
Ops.Pwd = tdp->Password;
|
Ops.Pwd = tdp->Password;
|
||||||
|
Ops.Fsize = 0;
|
||||||
|
Ops.Scrollable = false;
|
||||||
} // end of TDBJTB constructor
|
} // end of TDBJTB constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -1676,17 +1788,25 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES TDBJTB::GetResult(PGLOBAL g)
|
PQRYRES TDBJTB::GetResult(PGLOBAL g)
|
||||||
{
|
{
|
||||||
return JDBCTables(g, Jpath, Schema, Tab, Tabtype, Maxres, false, &Ops);
|
return JDBCTables(g, Schema, Tab, Tabtype, Maxres, false, &Ops);
|
||||||
} // end of GetResult
|
} // end of GetResult
|
||||||
|
|
||||||
/* --------------------------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, Jpath, 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
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
#include "colblk.h"
|
#include "colblk.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
#include "jdbccat.h"
|
||||||
|
|
||||||
typedef class JDBCDEF *PJDBCDEF;
|
typedef class JDBCDEF *PJDBCDEF;
|
||||||
typedef class TDBJDBC *PTDBJDBC;
|
typedef class TDBJDBC *PTDBJDBC;
|
||||||
@@ -25,13 +26,13 @@ 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);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
virtual const char *GetType(void) { return "JDBC"; }
|
virtual const char *GetType(void) { return "JDBC"; }
|
||||||
PSZ GetJpath(void) { return Jpath; }
|
|
||||||
PSZ GetTabname(void) { return Tabname; }
|
PSZ GetTabname(void) { return Tabname; }
|
||||||
PSZ GetTabschema(void) { return Tabschema; }
|
PSZ GetTabschema(void) { return Tabschema; }
|
||||||
PSZ GetTabcat(void) { return Tabcat; }
|
PSZ GetTabcat(void) { return Tabcat; }
|
||||||
@@ -45,10 +46,11 @@ public:
|
|||||||
virtual int Indexable(void) { return 2; }
|
virtual int Indexable(void) { return 2; }
|
||||||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
||||||
virtual PTDB GetTable(PGLOBAL g, MODE m);
|
virtual PTDB GetTable(PGLOBAL g, MODE m);
|
||||||
|
int ParseURL(PGLOBAL g, char *url, bool b = true);
|
||||||
|
bool SetParms(PJPARM sjp);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
PSZ Jpath; /* Java class path */
|
|
||||||
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 */
|
||||||
@@ -57,6 +59,7 @@ protected:
|
|||||||
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 */
|
||||||
@@ -73,7 +76,7 @@ protected:
|
|||||||
}; // end of JDBCDEF
|
}; // end of JDBCDEF
|
||||||
|
|
||||||
#if !defined(NJDBC)
|
#if !defined(NJDBC)
|
||||||
#include "JDBConn.h"
|
#include "jdbconn.h"
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* This is the JDBC Access Method class declaration for files from */
|
/* This is the JDBC Access Method class declaration for files from */
|
||||||
@@ -130,7 +133,6 @@ 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 *Jpath; // Java class path
|
|
||||||
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
|
||||||
@@ -282,7 +284,7 @@ protected:
|
|||||||
class TDBJDRV : public TDBCAT {
|
class TDBJDRV : public TDBCAT {
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres; Jpath = tdp->Jpath;}
|
TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Specific routines
|
// Specific routines
|
||||||
@@ -290,7 +292,6 @@ protected:
|
|||||||
|
|
||||||
// Members
|
// Members
|
||||||
int Maxres; // Returned lines limit
|
int Maxres; // Returned lines limit
|
||||||
char *Jpath; // Java class path
|
|
||||||
}; // end of class TDBJDRV
|
}; // end of class TDBJDRV
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -306,7 +307,6 @@ protected:
|
|||||||
virtual PQRYRES GetResult(PGLOBAL g);
|
virtual PQRYRES GetResult(PGLOBAL g);
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
char *Jpath; // Points to Java classpath
|
|
||||||
char *Schema; // Points to schema name or NULL
|
char *Schema; // Points to schema name or NULL
|
||||||
char *Tab; // Points to JDBC table name or pattern
|
char *Tab; // Points to JDBC table name or pattern
|
||||||
char *Tabtype; // Points to JDBC table type
|
char *Tabtype; // Points to JDBC table type
|
||||||
@@ -319,14 +319,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
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************* 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);
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)))
|
||||||
@@ -1768,6 +1774,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 +1787,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 */
|
|||||||
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 */
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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
|
||||||
|
Reference in New Issue
Block a user