diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-10-26 00:43:03 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-10-26 00:43:03 +0200 |
commit | ba3f4a2cc9ec5337f7677def0a1366cbb7332922 (patch) | |
tree | c125f165a39d3c283e6a0dba698b12cb4b64886f /storage/connect/odbconn.cpp | |
parent | c0907d57b1493e75ac16d8b24cb91a644f078750 (diff) | |
download | mariadb-git-ba3f4a2cc9ec5337f7677def0a1366cbb7332922.tar.gz |
- Add new features to ODBC table type
Srcdef definition
Execute command tables
uncomplete connect string
modified:
storage/connect/ha_connect.cc
storage/connect/odbccat.h
storage/connect/odbconn.cpp
storage/connect/odbconn.h
storage/connect/plgdbsem.h
storage/connect/plgdbutl.cpp
storage/connect/tabodbc.cpp
Diffstat (limited to 'storage/connect/odbconn.cpp')
-rw-r--r-- | storage/connect/odbconn.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index a9610c86f18..8dcf71c2953 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -13,6 +13,7 @@ #if defined(WIN32) //nclude <io.h> //nclude <fcntl.h> +#include <direct.h> // for getcwd #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro #endif @@ -172,10 +173,36 @@ int TranslateSQLType(int stp, int prec, int& len) } // end of TranslateSQLType /***********************************************************************/ -/* ODBConn static members initialization. */ +/* ODBCCheckConnection: Check completeness of connection string. */ /***********************************************************************/ -//HENV ODBConn::m_henv = SQL_NULL_HENV; -//int ODBConn::m_nAlloc = 0; // per-Appl reference to HENV above +char *ODBCCheckConnection(PGLOBAL g, char *dsn, int cop) + { + char *newdsn, dir[_MAX_PATH], buf[_MAX_PATH]; + int rc; + DWORD options = ODBConn::openReadOnly; + ODBConn *ocp = new(g) ODBConn(g, NULL); + + (void) getcwd(dir, sizeof(dir) - 1); + + switch (cop) { + case 1: options |= ODBConn::forceOdbcDialog; break; + case 2: options |= ODBConn::noOdbcDialog; break; + } // endswitch cop + + if (ocp->Open(dsn, options) < 1) + newdsn = NULL; + else + newdsn = ocp->GetConnect(); + + (void) getcwd(buf, sizeof(buf) - 1); + + // Some data sources change the current directory + if (strcmp(dir, buf)) + rc = chdir(dir); + + ocp->Close(); + return newdsn; // Return complete connection string + } // end of ODBCCheckConnection /***********************************************************************/ /* Allocate the structure used to refer to the result set. */ @@ -254,7 +281,7 @@ PQRYRES ODBCColumns(PGLOBAL g, char *dsn, char *table, if (!info) { ocp = new(g) ODBConn(g, NULL); - if (ocp->Open(dsn, 2) < 1) // 2 is openReadOnly + if (ocp->Open(dsn, 10) < 1) // openReadOnly + noODBCdialog return NULL; // We fix a MySQL limit because some data sources return 32767 @@ -1662,7 +1689,7 @@ PQRYRES ODBConn::GetMetaData(PGLOBAL g, char *dsn, char *src) RETCODE rc; HSTMT hstmt; - if (Open(dsn, 2) < 1) // 2 is openReadOnly + if (Open(dsn, 10) < 1) // openReadOnly + noOdbcDialog return NULL; try { |