Commit 4ab970ab authored by Olivier Bertrand's avatar Olivier Bertrand

- Commit merged file (on Linux)

modified:
  storage/connect/ha_connect.cc
  storage/connect/myconn.cpp
  storage/connect/odbccat.h
  storage/connect/odbconn.cpp
  storage/connect/odbconn.h
  storage/connect/tabmul.cpp
  storage/connect/tabmysql.cpp
  storage/connect/tabodbc.cpp
  storage/connect/tabodbc.h
  
- Fix typo error in TDBDIR::CloseDB

modified:
  storage/connect/tabmul.cpp

- Fix format in TDBXDBC::MakeCMD (was not accepted on Linux)

modified:
  storage/connect/tabodbc.cpp
parents b8422f63 ca4c54aa
...@@ -1133,13 +1133,14 @@ bool ha_connect::OpenTable(PGLOBAL g, bool del) ...@@ -1133,13 +1133,14 @@ bool ha_connect::OpenTable(PGLOBAL g, bool del)
break; break;
} // endswitch xmode } // endswitch xmode
if (xmod != MODE_INSERT) { if (xmod != MODE_INSERT || tdbp->GetAmType() == TYPE_AM_ODBC
|| tdbp->GetAmType() == TYPE_AM_MYSQL) {
// Get the list of used fields (columns) // Get the list of used fields (columns)
char *p; char *p;
unsigned int k1, k2, n1, n2; unsigned int k1, k2, n1, n2;
Field* *field; Field* *field;
Field* fp; Field* fp;
MY_BITMAP *map= table->read_set; MY_BITMAP *map= (xmod == MODE_INSERT) ? table->write_set : table->read_set;
MY_BITMAP *ump= (xmod == MODE_UPDATE) ? table->write_set : NULL; MY_BITMAP *ump= (xmod == MODE_UPDATE) ? table->write_set : NULL;
k1= k2= 0; k1= k2= 0;
...@@ -1374,7 +1375,8 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf) ...@@ -1374,7 +1375,8 @@ int ha_connect::ScanRecord(PGLOBAL g, uchar *buf)
fp->option_struct->special) fp->option_struct->special)
continue; // Is a virtual column possible here ??? continue; // Is a virtual column possible here ???
if (xmod == MODE_INSERT || if ((xmod == MODE_INSERT && tdbp->GetAmType() != TYPE_AM_MYSQL
&& tdbp->GetAmType() != TYPE_AM_ODBC) ||
bitmap_is_set(table->write_set, fp->field_index)) { bitmap_is_set(table->write_set, fp->field_index)) {
for (colp= tp->GetSetCols(); colp; colp= colp->GetNext()) for (colp= tp->GetSetCols(); colp; colp= colp->GetNext())
if (!stricmp(colp->GetName(), fp->field_name)) if (!stricmp(colp->GetName(), fp->field_name))
...@@ -3464,7 +3466,7 @@ static bool add_field(String *sql, const char *field_name, int typ, int len, ...@@ -3464,7 +3466,7 @@ static bool add_field(String *sql, const char *field_name, int typ, int len,
{ {
bool error= false; bool error= false;
const char *type= PLGtoMYSQLtype(typ, dbf); const char *type= PLGtoMYSQLtype(typ, dbf);
type= PLGtoMYSQLtype(typ, true); // type= PLGtoMYSQLtype(typ, true); ?????
error|= sql->append('`'); error|= sql->append('`');
error|= sql->append(field_name); error|= sql->append(field_name);
...@@ -3948,7 +3950,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3948,7 +3950,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
else else
return HA_ERR_INTERNAL_ERROR; // Should never happen return HA_ERR_INTERNAL_ERROR; // Should never happen
if (src && ttp != TAB_PIVOT) { if (src && ttp != TAB_PIVOT && ttp != TAB_ODBC) {
qrp= SrcColumns(g, host, db, user, pwd, src, port); qrp= SrcColumns(g, host, db, user, pwd, src, port);
if (qrp && ttp == TAB_OCCUR) if (qrp && ttp == TAB_OCCUR)
...@@ -3966,7 +3968,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3966,7 +3968,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
switch (fnc) { switch (fnc) {
case FNC_NO: case FNC_NO:
case FNC_COL: case FNC_COL:
qrp= ODBCColumns(g, dsn, (char *) tab, NULL, fnc == FNC_COL); if (src) {
qrp= ODBCSrcCols(g, dsn, (char*)src);
src= NULL; // for next tests
} else
qrp= ODBCColumns(g, dsn, (char *) tab, NULL, fnc == FNC_COL);
break; break;
case FNC_TABLE: case FNC_TABLE:
qrp= ODBCTables(g, dsn, (char *) tab, true); qrp= ODBCTables(g, dsn, (char *) tab, true);
......
...@@ -89,7 +89,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -89,7 +89,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32}; static unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 256, 32, 32};
char *fld, *fmt, cmd[128]; char *fld, *fmt, cmd[128];
int i, n, nf, ncol = sizeof(buftyp) / sizeof(int); int i, n, nf, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0; int len, type, prec, rc, k = 0;
PQRYRES qrp; PQRYRES qrp;
PCOLRES crp; PCOLRES crp;
MYSQLC myc; MYSQLC myc;
...@@ -166,7 +166,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db, ...@@ -166,7 +166,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
// Get type, type name, and precision // Get type, type name, and precision
fld = myc.GetCharField(1); fld = myc.GetCharField(1);
prec = 0; prec = 0;
len = 256; // Default for text or blob len = 255; // Default for text or blob
if ((nf = sscanf(fld, "%[^(](%d,%d", cmd, &len, &prec)) < 1) { if ((nf = sscanf(fld, "%[^(](%d,%d", cmd, &len, &prec)) < 1) {
sprintf(g->Message, MSG(BAD_FIELD_TYPE), fld); sprintf(g->Message, MSG(BAD_FIELD_TYPE), fld);
......
...@@ -4,5 +4,6 @@ ...@@ -4,5 +4,6 @@
PQRYRES ODBCDataSources(PGLOBAL g, bool info); PQRYRES ODBCDataSources(PGLOBAL g, bool info);
PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table,
char *colpat, bool info); char *colpat, bool info);
PQRYRES ODBCSrcCols(PGLOBAL g, char *dsn, char *src);
PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info); PQRYRES ODBCTables(PGLOBAL g, char *dsn, char *tabpat, bool info);
PQRYRES ODBCDrivers(PGLOBAL g, bool info); PQRYRES ODBCDrivers(PGLOBAL g, bool info);
This diff is collapsed.
...@@ -91,8 +91,7 @@ class DBX : public BLOCK { ...@@ -91,8 +91,7 @@ class DBX : public BLOCK {
// Implementation (use ThrowDBX to create) // Implementation (use ThrowDBX to create)
RETCODE GetRC(void) {return m_RC;} RETCODE GetRC(void) {return m_RC;}
PSZ GetMsg(void) {return m_Msg;} PSZ GetMsg(void) {return m_Msg;}
const char *GetErrorMessage(int i) const char *GetErrorMessage(int i);
{return (i >=0 && i < MAX_NUM_OF_MSG) ? m_ErrMsg[i] : "No ODBC error";}
protected: protected:
void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT); void BuildErrorMessage(ODBConn* pdb, HSTMT hstmt = SQL_NULL_HSTMT);
...@@ -107,6 +106,7 @@ class DBX : public BLOCK { ...@@ -107,6 +106,7 @@ class DBX : public BLOCK {
/* ODBConn class. */ /* ODBConn class. */
/***********************************************************************/ /***********************************************************************/
class ODBConn : public BLOCK { class ODBConn : public BLOCK {
friend class TDBODBC;
friend class DBX; friend class DBX;
friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&); friend PQRYRES GetColumnInfo(PGLOBAL, char*&, char *, int, PVBLK&);
private: private:
...@@ -142,11 +142,12 @@ class ODBConn : public BLOCK { ...@@ -142,11 +142,12 @@ class ODBConn : public BLOCK {
int ExecDirectSQL(char *sql, ODBCCOL *tocols); int ExecDirectSQL(char *sql, ODBCCOL *tocols);
int Fetch(void); int Fetch(void);
int PrepareSQL(char *sql); int PrepareSQL(char *sql);
bool ExecuteSQL(void); int ExecuteSQL(bool x);
bool BindParam(ODBCCOL *colp); bool BindParam(ODBCCOL *colp);
int GetCatInfo(CATPARM *cap); int GetCatInfo(CATPARM *cap);
bool GetDataSources(PQRYRES qrp); bool GetDataSources(PQRYRES qrp);
bool GetDrivers(PQRYRES qrp); bool GetDrivers(PQRYRES qrp);
PQRYRES GetMetaData(PGLOBAL g, char *dsn, char *src);
public: public:
// Set special options // Set special options
...@@ -185,5 +186,6 @@ class ODBConn : public BLOCK { ...@@ -185,5 +186,6 @@ class ODBConn : public BLOCK {
int m_Catver; int m_Catver;
PSZ m_Connect; PSZ m_Connect;
bool m_Updatable; bool m_Updatable;
bool m_Transact;
char m_IDQuoteChar; char m_IDQuoteChar;
}; // end of ODBConn class definition }; // end of ODBConn class definition
...@@ -884,9 +884,11 @@ void TDBDIR::CloseDB(PGLOBAL g) ...@@ -884,9 +884,11 @@ void TDBDIR::CloseDB(PGLOBAL g)
_findclose(Hsearch); _findclose(Hsearch);
Hsearch = -1; Hsearch = -1;
#else // !WIN32 #else // !WIN32
// Close the DIR handle. // Close the DIR handle
closedir(Dir); if (Dir) {
Dir = NULL; closedir(Dir);
Dir = NULL;
} // endif dir
#endif // !WIN32 #endif // !WIN32
iFile = 0; iFile = 0;
} // end of CloseDB } // end of CloseDB
......
...@@ -507,6 +507,9 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g) ...@@ -507,6 +507,9 @@ bool TDBMYSQL::MakeSelect(PGLOBAL g)
if (To_Filter) if (To_Filter)
strcat(strcat(Query, " WHERE "), To_Filter); strcat(strcat(Query, " WHERE "), To_Filter);
if (trace)
htrc("Query=%s\n", Query);
// Now we know how much to suballocate // Now we know how much to suballocate
PlugSubAlloc(g, NULL, strlen(Query) + 1); PlugSubAlloc(g, NULL, strlen(Query) + 1);
return FALSE; return FALSE;
...@@ -1040,18 +1043,20 @@ int TDBMYSQL::DeleteDB(PGLOBAL g, int irc) ...@@ -1040,18 +1043,20 @@ int TDBMYSQL::DeleteDB(PGLOBAL g, int irc)
/***********************************************************************/ /***********************************************************************/
void TDBMYSQL::CloseDB(PGLOBAL g) void TDBMYSQL::CloseDB(PGLOBAL g)
{ {
if (Mode == MODE_INSERT) { if (Myc.Connected()) {
char cmd[64]; if (Mode == MODE_INSERT) {
int w; char cmd[64];
PDBUSER dup = PlgGetUser(g); int w;
PDBUSER dup = PlgGetUser(g);
dup->Step = "Enabling indexes";
sprintf(cmd, "ALTER TABLE `%s` ENABLE KEYS", Tabname); dup->Step = "Enabling indexes";
Myc.m_Rows = -1; // To execute the query sprintf(cmd, "ALTER TABLE `%s` ENABLE KEYS", Tabname);
m_Rc = Myc.ExecSQL(g, cmd, &w); Myc.m_Rows = -1; // To execute the query
} // endif m_Rc m_Rc = Myc.ExecSQL(g, cmd, &w);
} // endif m_Rc
Myc.Close();
Myc.Close();
} // endif Myc
if (trace) if (trace)
htrc("MySQL CloseDB: closing %s rc=%d\n", Name, m_Rc); htrc("MySQL CloseDB: closing %s rc=%d\n", Name, m_Rc);
......
This diff is collapsed.
/*************** Tabodbc H Declares Source Code File (.H) **************/ /*************** Tabodbc H Declares Source Code File (.H) **************/
/* Name: TABODBC.H Version 1.5 */ /* Name: TABODBC.H Version 1.6 */
/* */ /* */
/* (C) Copyright to the author Olivier BERTRAND 2000-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2000-2013 */
/* */ /* */
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
typedef class ODBCDEF *PODEF; typedef class ODBCDEF *PODEF;
typedef class TDBODBC *PTDBODBC; typedef class TDBODBC *PTDBODBC;
typedef class ODBCCOL *PODBCCOL; typedef class ODBCCOL *PODBCCOL;
typedef class TDBXDBC *PTDBXDBC;
typedef class XSRCCOL *PXSRCCOL;
typedef class TDBOIF *PTDBOIF; typedef class TDBOIF *PTDBOIF;
typedef class OIFCOL *POIFCOL; typedef class OIFCOL *POIFCOL;
typedef class TDBSRC *PTDBSRC; typedef class TDBSRC *PTDBSRC;
...@@ -19,6 +21,8 @@ typedef class TDBSRC *PTDBSRC; ...@@ -19,6 +21,8 @@ typedef class TDBSRC *PTDBSRC;
/* ODBC table. */ /* ODBC table. */
/***********************************************************************/ /***********************************************************************/
class DllExport ODBCDEF : public TABDEF { /* Logical table description */ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
friend class TDBODBC;
friend class TDBXDBC;
public: public:
// Constructor // Constructor
ODBCDEF(void); ODBCDEF(void);
...@@ -29,6 +33,7 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -29,6 +33,7 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
PSZ GetTabname(void) {return Tabname;} PSZ GetTabname(void) {return Tabname;}
PSZ GetTabowner(void) {return Tabowner;} PSZ GetTabowner(void) {return Tabowner;}
PSZ GetTabqual(void) {return Tabqual;} PSZ GetTabqual(void) {return Tabqual;}
PSZ GetSrcdef(void) {return Srcdef;}
PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;} PSZ GetQchar(void) {return (Qchar && *Qchar) ? Qchar : NULL;}
int GetCatver(void) {return Catver;} int GetCatver(void) {return Catver;}
int GetOptions(void) {return Options;} int GetOptions(void) {return Options;}
...@@ -43,9 +48,11 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */ ...@@ -43,9 +48,11 @@ class DllExport ODBCDEF : public TABDEF { /* Logical table description */
PSZ Tabname; /* External table name */ PSZ Tabname; /* External table name */
PSZ Tabowner; /* External table owner */ PSZ Tabowner; /* External table owner */
PSZ Tabqual; /* External table qualifier */ PSZ Tabqual; /* External table qualifier */
PSZ Srcdef; /* The source table SQL definition */
PSZ Qchar; /* Identifier quoting character */ PSZ Qchar; /* Identifier quoting character */
int Catver; /* ODBC version for catalog functions */ int Catver; /* ODBC version for catalog functions */
int Options; /* Open connection options */ int Options; /* Open connection options */
bool Xsrc; /* Execution type */
}; // end of ODBCDEF }; // end of ODBCDEF
#if !defined(NODBC) #if !defined(NODBC)
...@@ -92,10 +99,10 @@ class TDBODBC : public TDBASE { ...@@ -92,10 +99,10 @@ class TDBODBC : public TDBASE {
int Decode(char *utf, char *buf, size_t n); int Decode(char *utf, char *buf, size_t n);
char *MakeSQL(PGLOBAL g, bool cnt); char *MakeSQL(PGLOBAL g, bool cnt);
//bool MakeUpdate(PGLOBAL g, PSELECT selist); //bool MakeUpdate(PGLOBAL g, PSELECT selist);
//bool MakeInsert(PGLOBAL g); bool MakeInsert(PGLOBAL g);
//bool MakeDelete(PGLOBAL g); //bool MakeDelete(PGLOBAL g);
//bool MakeFilter(PGLOBAL g, bool c); //bool MakeFilter(PGLOBAL g, bool c);
//bool BindParameters(PGLOBAL g); bool BindParameters(PGLOBAL g);
// Members // Members
ODBConn *Ocp; // Points to an ODBC connection class ODBConn *Ocp; // Points to an ODBC connection class
...@@ -104,6 +111,7 @@ class TDBODBC : public TDBASE { ...@@ -104,6 +111,7 @@ class TDBODBC : public TDBASE {
char *TableName; // Points to ODBC table name char *TableName; // Points to ODBC table name
char *Owner; // Points to ODBC table Owner char *Owner; // Points to ODBC table Owner
char *Qualifier; // Points to ODBC table Qualifier char *Qualifier; // Points to ODBC table Qualifier
char *Srcdef; // The source table SQL definition
char *Query; // Points to SQL statement char *Query; // Points to SQL statement
char *Count; // Points to count(*) SQL statement char *Count; // Points to count(*) SQL statement
//char *Where; // Points to local where clause //char *Where; // Points to local where clause
...@@ -122,7 +130,7 @@ class TDBODBC : public TDBASE { ...@@ -122,7 +130,7 @@ class TDBODBC : public TDBASE {
}; // end of class TDBODBC }; // end of class TDBODBC
/***********************************************************************/ /***********************************************************************/
/* Class ODBCCOL: DOS access method column descriptor. */ /* Class ODBCCOL: ODBC access method column descriptor. */
/* This A.M. is used for ODBC tables. */ /* This A.M. is used for ODBC tables. */
/***********************************************************************/ /***********************************************************************/
class ODBCCOL : public COLBLK { class ODBCCOL : public COLBLK {
...@@ -153,16 +161,85 @@ class ODBCCOL : public COLBLK { ...@@ -153,16 +161,85 @@ class ODBCCOL : public COLBLK {
ODBCCOL(void); ODBCCOL(void);
// Members // Members
TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's TIMESTAMP_STRUCT *Sqlbuf; // To get SQL_TIMESTAMP's
void *Bufp; // To extended buffer void *Bufp; // To extended buffer
PVBLK Blkp; // To Value Block PVBLK Blkp; // To Value Block
//char F_Date[12]; // Internal Date format //char F_Date[12]; // Internal Date format
PVAL To_Val; // To value used for Insert PVAL To_Val; // To value used for Insert
SQLLEN *StrLen; // As returned by ODBC SQLLEN *StrLen; // As returned by ODBC
SQLLEN Slen; // Used with Fetch SQLLEN Slen; // Used with Fetch
int Rank; // Rank (position) number in the query int Rank; // Rank (position) number in the query
}; // end of class ODBCCOL }; // end of class ODBCCOL
/***********************************************************************/
/* This is the ODBC Access Method class declaration that send */
/* commands to be executed by other DB ODBC drivers. */
/***********************************************************************/
class TDBXDBC : public TDBODBC {
friend class XSRCCOL;
friend class ODBConn;
public:
// Constructor
TDBXDBC(PODEF tdp = NULL) : TDBODBC(tdp) {Cmdcol = NULL;}
TDBXDBC(PTDBXDBC tdbp) : TDBODBC(tdbp) {Cmdcol = tdbp->Cmdcol;}
// Implementation
//virtual AMT GetAmType(void) {return TYPE_AM_ODBC;}
virtual PTDB Duplicate(PGLOBAL g)
{return (PTDB)new(g) TDBXDBC(this);}
// Methods
virtual PTDB CopyOne(PTABS t);
//virtual int GetRecpos(void);
//virtual PSZ GetFile(PGLOBAL g);
//virtual void SetFile(PGLOBAL g, PSZ fn);
//virtual void ResetSize(void);
//virtual int GetAffectedRows(void) {return AftRows;}
//virtual PSZ GetServer(void) {return "ODBC";}
// Database routines
virtual PCOL MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n);
//virtual int GetProgMax(PGLOBAL g);
virtual int GetMaxSize(PGLOBAL g);
virtual bool OpenDB(PGLOBAL g);
virtual int ReadDB(PGLOBAL g);
virtual int WriteDB(PGLOBAL g);
//virtual int DeleteDB(PGLOBAL g, int irc);
//virtual void CloseDB(PGLOBAL g);
protected:
// Internal functions
char *MakeCMD(PGLOBAL g);
//bool BindParameters(PGLOBAL g);
// Members
char *Cmdcol; // The name of the Xsrc command column
}; // end of class TDBXDBC
/***********************************************************************/
/* Used by table in source execute mode. */
/***********************************************************************/
class XSRCCOL : public ODBCCOL {
friend class TDBXDBC;
public:
// Constructors
XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PSZ am = "ODBC");
XSRCCOL(XSRCCOL *colp, PTDB tdbp); // Constructor used in copy process
// Implementation
//virtual int GetAmType(void) {return TYPE_AM_ODBC;}
// Methods
virtual void ReadColumn(PGLOBAL g);
virtual void WriteColumn(PGLOBAL g);
// void Print(PGLOBAL g, FILE *, uint);
protected:
// Members
char *Buffer; // To get returned message
int Flag; // Column content desc
}; // end of class XSRCCOL
/***********************************************************************/ /***********************************************************************/
/* This is the class declaration for the Data Sources catalog table. */ /* This is the class declaration for the Data Sources catalog table. */
/***********************************************************************/ /***********************************************************************/
......
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