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
|
||||
*.h text
|
||||
*.test text
|
||||
*.java text
|
||||
|
||||
# These files should be checked out as is
|
||||
*.result -text -whitespace
|
||||
@@ -23,9 +24,11 @@ pcre/testdata/greppatN4 -text
|
||||
*.frm binary
|
||||
*.MYD binary
|
||||
*.MYI binary
|
||||
*.class binary
|
||||
|
||||
*.c diff=cpp
|
||||
*.h diff=cpp
|
||||
*.cc diff=cpp
|
||||
*.ic 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
|
||||
*.dep
|
||||
*.idb
|
||||
*.res
|
||||
*.tlog
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
Binary file not shown.
@@ -307,7 +307,7 @@ public class JdbcInterface {
|
||||
} // end of GetMaxValue
|
||||
|
||||
public int GetColumns(String[] parms) {
|
||||
int ncol = 0;
|
||||
int ncol = -1;
|
||||
|
||||
try {
|
||||
if (rs != null) rs.close();
|
||||
|
@@ -129,7 +129,8 @@
|
||||
#include "odbccat.h"
|
||||
#endif // ODBC_SUPPORT
|
||||
#if defined(JDBC_SUPPORT)
|
||||
#include "jdbccat.h"
|
||||
#include "tabjdbc.h"
|
||||
#include "jdbconn.h"
|
||||
#endif // JDBC_SUPPORT
|
||||
#include "xtable.h"
|
||||
#include "tabmysql.h"
|
||||
@@ -5163,7 +5164,6 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
#endif // ODBC_SUPPORT
|
||||
#if defined(JDBC_SUPPORT)
|
||||
PJPARM sjp= NULL;
|
||||
char *jpath= NULL;
|
||||
char *driver= NULL;
|
||||
char *url= 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);
|
||||
#endif
|
||||
#if defined(JDBC_SUPPORT)
|
||||
jpath= GetListOption(g, "Jpath", 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);
|
||||
#endif // JDBC_SUPPORT
|
||||
mxe= atoi(GetListOption(g,"maxerr", topt->oplist, "0"));
|
||||
@@ -5333,18 +5332,31 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
case TAB_JDBC:
|
||||
if (fnc & FNC_DRIVER) {
|
||||
ok= true;
|
||||
} else if (!url) {
|
||||
strcpy(g->Message, "Missing URL");
|
||||
} else if (!(url= strz(g, create_info->connect_string))) {
|
||||
strcpy(g->Message, "Missing URL");
|
||||
} 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->Driver= driver;
|
||||
sjp->Url= url;
|
||||
sjp->User= (char*)user;
|
||||
sjp->Pwd= (char*)pwd;
|
||||
sjp->Fsize= 0;
|
||||
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
|
||||
|
||||
supfnc |= (FNC_DRIVER | FNC_TABLE);
|
||||
@@ -5496,7 +5508,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp= ODBCTables(g, dsn, shm, tab, mxr, true, sop);
|
||||
qrp= ODBCTables(g, dsn, shm, tab, NULL, mxr, true, sop);
|
||||
break;
|
||||
case FNC_DSN:
|
||||
qrp= ODBCDataSources(g, mxr, true);
|
||||
@@ -5517,15 +5529,14 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
case FNC_NO:
|
||||
case FNC_COL:
|
||||
if (src) {
|
||||
qrp= JDBCSrcCols(g, jpath, (char*)src, sjp);
|
||||
qrp= JDBCSrcCols(g, (char*)src, sjp);
|
||||
src= NULL; // for next tests
|
||||
} else
|
||||
qrp= JDBCColumns(g, jpath, shm, tab, NULL,
|
||||
mxr, fnc == FNC_COL, sjp);
|
||||
qrp= JDBCColumns(g, shm, tab, NULL, mxr, fnc == FNC_COL, sjp);
|
||||
|
||||
break;
|
||||
case FNC_TABLE:
|
||||
qrp= JDBCTables(g, dsn, shm, tab, tabtyp, mxr, true, sjp);
|
||||
qrp= JDBCTables(g, shm, tab, tabtyp, mxr, true, sjp);
|
||||
break;
|
||||
#if 0
|
||||
case FNC_DSN:
|
||||
@@ -5533,7 +5544,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
break;
|
||||
#endif // 0
|
||||
case FNC_DRIVER:
|
||||
qrp= JDBCDrivers(g, jpath, mxr, true);
|
||||
qrp= JDBCDrivers(g, mxr, true);
|
||||
break;
|
||||
default:
|
||||
sprintf(g->Message, "invalid catfunc %s", fncn);
|
||||
@@ -5784,12 +5795,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
|
||||
|
||||
switch (typ) {
|
||||
case TYPE_DOUBLE:
|
||||
case TYPE_DECIM:
|
||||
// Some data sources do not count dec in length (prec)
|
||||
prec += (dec + 2); // To be safe
|
||||
break;
|
||||
case TYPE_DECIM:
|
||||
prec= len;
|
||||
break;
|
||||
default:
|
||||
dec= 0;
|
||||
} // endswitch typ
|
||||
|
@@ -21,9 +21,9 @@ typedef struct jdbc_parms {
|
||||
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,
|
||||
PQRYRES JDBCColumns(PGLOBAL g, 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,
|
||||
PQRYRES JDBCSrcCols(PGLOBAL g, char *src, PJPARM sop);
|
||||
PQRYRES JDBCTables(PGLOBAL g, char *db, char *tabpat,
|
||||
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;
|
||||
#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
|
||||
@@ -55,11 +46,17 @@ enum JCATINFO {
|
||||
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
|
||||
char *DB; // Database (Schema)
|
||||
char *Tab; // Table name or pattern
|
||||
char *Pat; // Table type or column pattern
|
||||
} 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
|
||||
class TDBJDBC;
|
||||
class JDBCCOL;
|
||||
@@ -79,7 +76,7 @@ private:
|
||||
public:
|
||||
JDBConn(PGLOBAL g, TDBJDBC *tdbp);
|
||||
|
||||
int Open(PSZ jpath, PJPARM sop);
|
||||
int Open(PJPARM sop);
|
||||
int Rewind(char *sql);
|
||||
void Close(void);
|
||||
PQRYRES AllocateResult(PGLOBAL g);
|
||||
@@ -114,8 +111,18 @@ public:
|
||||
PQRYRES GetMetaData(PGLOBAL g, char *src);
|
||||
|
||||
public:
|
||||
// Set special options
|
||||
//void OnSetOptions(HSTMT hstmt);
|
||||
// Set static variables
|
||||
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
|
||||
public:
|
||||
@@ -123,24 +130,30 @@ public:
|
||||
|
||||
// JDBC operations
|
||||
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(PSZ msg);
|
||||
//void AllocConnect(DWORD dwOptions);
|
||||
//void Connect(void);
|
||||
//bool DriverConnect(DWORD Options);
|
||||
//void VerifyConnect(void);
|
||||
//void GetConnectInfo(void);
|
||||
//void Free(void);
|
||||
|
||||
protected:
|
||||
// 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;
|
||||
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
|
||||
jclass jdi; // Pointer to the java wrapper class
|
||||
jobject job; // The java wrapper class object
|
||||
jmethodID xqid; // The ExecuteQuery method ID
|
||||
jmethodID xuid; // The ExecuteUpdate method ID
|
||||
jmethodID xid; // The Execute method ID
|
||||
@@ -151,9 +164,17 @@ protected:
|
||||
jmethodID prepid; // The CreatePrepStmt method ID
|
||||
jmethodID xpid; // The ExecutePrep 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_QueryTimeout;
|
||||
//DWORD m_UpdateOptions;
|
||||
char *Msg;
|
||||
char m_IDQuoteChar[2];
|
||||
PSZ m_Driver;
|
||||
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);
|
||||
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src, POPARM sop);
|
||||
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);
|
||||
|
@@ -606,7 +606,7 @@ PQRYRES ODBCDataSources(PGLOBAL g, int maxres, bool info)
|
||||
/* an ODBC database that will be retrieved by GetData commands. */
|
||||
/**************************************************************************/
|
||||
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,
|
||||
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)))
|
||||
return NULL;
|
||||
|
||||
//cap->Pat = (PUCHAR)tabtyp;
|
||||
cap->Pat = (PUCHAR)tabtyp;
|
||||
|
||||
if (trace)
|
||||
htrc("Getting table results ncol=%d\n", cap->Qrp->Nbcol);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/************* TabJDBC C++ Program Source Code File (.CPP) *************/
|
||||
/* PROGRAM NAME: TABJDBC */
|
||||
/* ------------- */
|
||||
/* Version 1.0 */
|
||||
/* Version 1.1 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
@@ -34,8 +34,10 @@
|
||||
/***********************************************************************/
|
||||
/* Include relevant MariaDB header file. */
|
||||
/***********************************************************************/
|
||||
#define MYSQL_SERVER 1
|
||||
#include "my_global.h"
|
||||
#include "sql_class.h"
|
||||
#include "sql_servers.h"
|
||||
#if defined(__WIN__)
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
@@ -67,7 +69,6 @@
|
||||
#include "plgdbsem.h"
|
||||
#include "mycat.h"
|
||||
#include "xtable.h"
|
||||
#include "jdbccat.h"
|
||||
#include "tabjdbc.h"
|
||||
#include "tabmul.h"
|
||||
#include "reldef.h"
|
||||
@@ -95,48 +96,160 @@ bool ExactInfo(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;
|
||||
Options = Quoted = Maxerr = Maxres = Memory = 0;
|
||||
Scrollable = Xsrc = false;
|
||||
} // 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. */
|
||||
/***********************************************************************/
|
||||
bool JDBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||
{
|
||||
Jpath = GetStringCatInfo(g, "Jpath", "");
|
||||
int rc = RC_OK;
|
||||
|
||||
Driver = GetStringCatInfo(g, "Driver", NULL);
|
||||
Desc = Url = GetStringCatInfo(g, "Url", NULL);
|
||||
Desc = Url = GetStringCatInfo(g, "Connect", NULL);
|
||||
|
||||
if (!Url && !Catfunc) {
|
||||
sprintf(g->Message, "Missing URL for JDBC table %s", Name);
|
||||
return true;
|
||||
// Look in the option list (deprecated)
|
||||
Url = GetStringCatInfo(g, "Url", NULL);
|
||||
|
||||
if (!Url) {
|
||||
sprintf(g->Message, "Missing URL for JDBC table %s", Name);
|
||||
return true;
|
||||
} // endif Url
|
||||
|
||||
} // endif Connect
|
||||
|
||||
Tabname = GetStringCatInfo(g, "Name",
|
||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
||||
Tabschema = GetStringCatInfo(g, "Dbname", NULL);
|
||||
Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
||||
Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
||||
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
||||
Tabtype = GetStringCatInfo(g, "Tabtype", NULL);
|
||||
Username = GetStringCatInfo(g, "User", NULL);
|
||||
Password = GetStringCatInfo(g, "Password", NULL);
|
||||
if (Url)
|
||||
rc = ParseURL(g, Url);
|
||||
|
||||
if (rc == RC_FX) // Error
|
||||
return true;
|
||||
else if (rc == RC_OK) { // Url was not a server name
|
||||
Tabname = GetStringCatInfo(g, "Name",
|
||||
(Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name);
|
||||
Tabname = GetStringCatInfo(g, "Tabname", Tabname);
|
||||
Username = GetStringCatInfo(g, "User", NULL);
|
||||
Password = GetStringCatInfo(g, "Password", NULL);
|
||||
} // endif rc
|
||||
|
||||
if ((Srcdef = GetStringCatInfo(g, "Srcdef", NULL)))
|
||||
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", "?");
|
||||
Sep = GetStringCatInfo(g, "Separator", NULL);
|
||||
Xsrc = GetBoolCatInfo("Execsrc", FALSE);
|
||||
Maxerr = GetIntCatInfo("Maxerr", 0);
|
||||
Maxres = GetIntCatInfo("Maxres", 0);
|
||||
Quoted = GetIntCatInfo("Quoted", 0);
|
||||
//Options = JDBConn::noJDBCDialog;
|
||||
//Options = JDBConn::noJDBCDialog | JDBConn::useCursorLib;
|
||||
//Cto= GetIntCatInfo("ConnectTimeout", DEFAULT_LOGIN_TIMEOUT);
|
||||
//Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT);
|
||||
Scrollable = GetBoolCatInfo("Scrollable", false);
|
||||
@@ -198,7 +311,7 @@ int JDBCPARM::CheckSize(int rows)
|
||||
if (Url && rows == 1) {
|
||||
// Are we connected to a MySQL JDBC connector?
|
||||
bool b = (!strncmp(Url, "jdbc:mysql:", 11) ||
|
||||
!strncmp(Url, "jdbc:mariadb:", 13));
|
||||
!strncmp(Url, "jdbc:mariadb:", 13));
|
||||
return b ? INT_MIN32 : rows;
|
||||
} else
|
||||
return rows;
|
||||
@@ -216,7 +329,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
||||
Cnp = NULL;
|
||||
|
||||
if (tdp) {
|
||||
Jpath = tdp->Jpath;
|
||||
Ops.Driver = tdp->Driver;
|
||||
Ops.Url = tdp->Url;
|
||||
TableName = tdp->Tabname;
|
||||
@@ -235,7 +347,6 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
||||
Memory = tdp->Memory;
|
||||
Ops.Scrollable = tdp->Scrollable;
|
||||
} else {
|
||||
Jpath = NULL;
|
||||
TableName = NULL;
|
||||
Schema = NULL;
|
||||
Ops.Driver = NULL;
|
||||
@@ -271,6 +382,7 @@ TDBJDBC::TDBJDBC(PJDBCDEF tdp) : TDBASE(tdp)
|
||||
Ncol = 0;
|
||||
Nparm = 0;
|
||||
Placed = false;
|
||||
Prepared = false;
|
||||
Werr = false;
|
||||
Rerr = false;
|
||||
Ops.Fsize = Ops.CheckSize(Rows);
|
||||
@@ -280,7 +392,6 @@ TDBJDBC::TDBJDBC(PTDBJDBC tdbp) : TDBASE(tdbp)
|
||||
{
|
||||
Jcp = tdbp->Jcp; // is that right ?
|
||||
Cnp = tdbp->Cnp;
|
||||
Jpath = tdbp->Jpath;
|
||||
TableName = tdbp->TableName;
|
||||
Schema = tdbp->Schema;
|
||||
Ops = tdbp->Ops;
|
||||
@@ -678,7 +789,7 @@ int TDBJDBC::Cardinality(PGLOBAL g)
|
||||
char qry[96], tbn[64];
|
||||
JDBConn *jcp = new(g)JDBConn(g, this);
|
||||
|
||||
if (jcp->Open(Jpath, &Ops) == RC_FX)
|
||||
if (jcp->Open(&Ops) == RC_FX)
|
||||
return -1;
|
||||
|
||||
// Table name can be encoded in UTF-8
|
||||
@@ -789,7 +900,7 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
|
||||
else if (Jcp->IsOpen())
|
||||
Jcp->Close();
|
||||
|
||||
if (Jcp->Open(Jpath, &Ops) == RC_FX)
|
||||
if (Jcp->Open(&Ops) == RC_FX)
|
||||
return true;
|
||||
else if (Quoted)
|
||||
Quote = Jcp->GetQuoteChar();
|
||||
@@ -1539,7 +1650,7 @@ bool TDBXJDC::OpenDB(PGLOBAL g)
|
||||
} else if (Jcp->IsOpen())
|
||||
Jcp->Close();
|
||||
|
||||
if (Jcp->Open(Jpath, &Ops) == RC_FX)
|
||||
if (Jcp->Open(&Ops) == RC_FX)
|
||||
return true;
|
||||
|
||||
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)
|
||||
{
|
||||
return JDBCDrivers(g, Jpath, Maxres, false);
|
||||
return JDBCDrivers(g, Maxres, false);
|
||||
} // end of GetResult
|
||||
|
||||
/* ---------------------------TDBJTB class --------------------------- */
|
||||
@@ -1661,7 +1772,6 @@ PQRYRES TDBJDRV::GetResult(PGLOBAL g)
|
||||
/***********************************************************************/
|
||||
TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
||||
{
|
||||
Jpath = tdp->Jpath;
|
||||
Schema = tdp->Tabschema;
|
||||
Tab = tdp->Tabname;
|
||||
Tabtype = tdp->Tabtype;
|
||||
@@ -1669,6 +1779,8 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
||||
Ops.Url = tdp->Url;
|
||||
Ops.User = tdp->Username;
|
||||
Ops.Pwd = tdp->Password;
|
||||
Ops.Fsize = 0;
|
||||
Ops.Scrollable = false;
|
||||
} // end of TDBJTB constructor
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -1676,17 +1788,25 @@ TDBJTB::TDBJTB(PJDBCDEF tdp) : TDBJDRV(tdp)
|
||||
/***********************************************************************/
|
||||
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
|
||||
|
||||
/* --------------------------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. */
|
||||
/***********************************************************************/
|
||||
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
|
||||
|
||||
#if 0
|
||||
|
@@ -7,6 +7,7 @@
|
||||
/***********************************************************************/
|
||||
#include "colblk.h"
|
||||
#include "resource.h"
|
||||
#include "jdbccat.h"
|
||||
|
||||
typedef class JDBCDEF *PJDBCDEF;
|
||||
typedef class TDBJDBC *PTDBJDBC;
|
||||
@@ -25,13 +26,13 @@ class DllExport JDBCDEF : public TABDEF { /* Logical table description */
|
||||
friend class TDBXJDC;
|
||||
friend class TDBJDRV;
|
||||
friend class TDBJTB;
|
||||
friend class TDBJDBCL;
|
||||
public:
|
||||
// Constructor
|
||||
JDBCDEF(void);
|
||||
|
||||
// Implementation
|
||||
virtual const char *GetType(void) { return "JDBC"; }
|
||||
PSZ GetJpath(void) { return Jpath; }
|
||||
PSZ GetTabname(void) { return Tabname; }
|
||||
PSZ GetTabschema(void) { return Tabschema; }
|
||||
PSZ GetTabcat(void) { return Tabcat; }
|
||||
@@ -45,10 +46,11 @@ public:
|
||||
virtual int Indexable(void) { return 2; }
|
||||
virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
|
||||
virtual PTDB GetTable(PGLOBAL g, MODE m);
|
||||
int ParseURL(PGLOBAL g, char *url, bool b = true);
|
||||
bool SetParms(PJPARM sjp);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
PSZ Jpath; /* Java class path */
|
||||
PSZ Driver; /* JDBC driver */
|
||||
PSZ Url; /* JDBC driver URL */
|
||||
PSZ Tabname; /* External table name */
|
||||
@@ -57,6 +59,7 @@ protected:
|
||||
PSZ Password; /* Password connect info */
|
||||
PSZ Tabcat; /* External table catalog */
|
||||
PSZ Tabtype; /* External table type */
|
||||
PSZ Colpat; /* Catalog column pattern */
|
||||
PSZ Srcdef; /* The source table SQL definition */
|
||||
PSZ Qchar; /* Identifier quoting character */
|
||||
PSZ Qrystr; /* The original query */
|
||||
@@ -73,7 +76,7 @@ protected:
|
||||
}; // end of JDBCDEF
|
||||
|
||||
#if !defined(NJDBC)
|
||||
#include "JDBConn.h"
|
||||
#include "jdbconn.h"
|
||||
|
||||
/***********************************************************************/
|
||||
/* This is the JDBC Access Method class declaration for files from */
|
||||
@@ -130,7 +133,6 @@ protected:
|
||||
JDBCCOL *Cnp; // Points to count(*) column
|
||||
JDBCPARM Ops; // Additional parameters
|
||||
PSTRG Query; // Constructed SQL query
|
||||
char *Jpath; // Java class path
|
||||
char *TableName; // Points to JDBC table name
|
||||
char *Schema; // Points to JDBC table Schema
|
||||
char *User; // User connect info
|
||||
@@ -282,7 +284,7 @@ protected:
|
||||
class TDBJDRV : public TDBCAT {
|
||||
public:
|
||||
// Constructor
|
||||
TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres; Jpath = tdp->Jpath;}
|
||||
TDBJDRV(PJDBCDEF tdp) : TDBCAT(tdp) {Maxres = tdp->Maxres;}
|
||||
|
||||
protected:
|
||||
// Specific routines
|
||||
@@ -290,7 +292,6 @@ protected:
|
||||
|
||||
// Members
|
||||
int Maxres; // Returned lines limit
|
||||
char *Jpath; // Java class path
|
||||
}; // end of class TDBJDRV
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -306,7 +307,6 @@ protected:
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// Members
|
||||
char *Jpath; // Points to Java classpath
|
||||
char *Schema; // Points to schema name or NULL
|
||||
char *Tab; // Points to JDBC table name or pattern
|
||||
char *Tabtype; // Points to JDBC table type
|
||||
@@ -319,14 +319,15 @@ protected:
|
||||
class TDBJDBCL : public TDBJTB {
|
||||
public:
|
||||
// Constructor
|
||||
TDBJDBCL(PJDBCDEF tdp) : TDBJTB(tdp) {}
|
||||
TDBJDBCL(PJDBCDEF tdp);
|
||||
|
||||
protected:
|
||||
// Specific routines
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// No additional Members
|
||||
}; // end of class TDBJCL
|
||||
// Members
|
||||
char *Colpat; // Points to catalog column pattern
|
||||
}; // end of class TDBJDBCL
|
||||
|
||||
#if 0
|
||||
/***********************************************************************/
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/************* Tabodbc C++ Program Source Code File (.CPP) *************/
|
||||
/* PROGRAM NAME: TABODBC */
|
||||
/* ------------- */
|
||||
/* Version 3.0 */
|
||||
/* Version 3.1 */
|
||||
/* */
|
||||
/* COPYRIGHT: */
|
||||
/* ---------- */
|
||||
@@ -96,7 +96,7 @@ bool ExactInfo(void);
|
||||
ODBCDEF::ODBCDEF(void)
|
||||
{
|
||||
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;
|
||||
Scrollable = Xsrc = UseCnc = false;
|
||||
} // end of ODBCDEF constructor
|
||||
@@ -120,7 +120,7 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||
Tabschema = GetStringCatInfo(g, "Schema", Tabschema);
|
||||
Tabcat = GetStringCatInfo(g, "Qualifier", NULL);
|
||||
Tabcat = GetStringCatInfo(g, "Catalog", Tabcat);
|
||||
Username = GetStringCatInfo(g, "User", NULL);
|
||||
Username = GetStringCatInfo(g, "User", NULL);
|
||||
Password = GetStringCatInfo(g, "Password", 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)
|
||||
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
|
||||
if (!(Memory = GetIntCatInfo("Memory", 0)))
|
||||
@@ -1768,6 +1774,7 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
|
||||
Dsn = tdp->GetConnect();
|
||||
Schema = tdp->GetTabschema();
|
||||
Tab = tdp->GetTabname();
|
||||
Tabtyp = tdp->Tabtyp;
|
||||
Ops.User = tdp->Username;
|
||||
Ops.Pwd = tdp->Password;
|
||||
Ops.Cto = tdp->Cto;
|
||||
@@ -1780,17 +1787,25 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp)
|
||||
/***********************************************************************/
|
||||
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
|
||||
|
||||
/* ---------------------------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. */
|
||||
/***********************************************************************/
|
||||
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 Tabodbc --------------------------- */
|
||||
|
@@ -25,7 +25,8 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
|
||||
friend class TDBXDBC;
|
||||
friend class TDBDRV;
|
||||
friend class TDBOTB;
|
||||
public:
|
||||
friend class TDBOCL;
|
||||
public:
|
||||
// Constructor
|
||||
ODBCDEF(void);
|
||||
|
||||
@@ -54,7 +55,9 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
|
||||
PSZ Username; /* User connect name */
|
||||
PSZ Password; /* Password connect info */
|
||||
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 Qrystr; /* The original query */
|
||||
PSZ Sep; /* Decimal separator */
|
||||
@@ -326,7 +329,8 @@ class TDBOTB : public TDBDRV {
|
||||
char *Dsn; // Points to connection string
|
||||
char *Schema; // Points to schema name or NULL
|
||||
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
|
||||
|
||||
/***********************************************************************/
|
||||
@@ -335,13 +339,14 @@ class TDBOTB : public TDBDRV {
|
||||
class TDBOCL : public TDBOTB {
|
||||
public:
|
||||
// Constructor
|
||||
TDBOCL(PODEF tdp) : TDBOTB(tdp) {}
|
||||
TDBOCL(PODEF tdp);
|
||||
|
||||
protected:
|
||||
// Specific routines
|
||||
virtual PQRYRES GetResult(PGLOBAL g);
|
||||
|
||||
// No additional Members
|
||||
// Members
|
||||
char *Colpat; // Points to column pattern
|
||||
}; // end of class TDBOCL
|
||||
|
||||
#endif // !NODBC
|
||||
|
Reference in New Issue
Block a user