before windows port
This commit is contained in:
parent
77ea55f05e
commit
51c4b89aac
|
@ -15,7 +15,7 @@ IF (TD_LINUX_64)
|
||||||
ADD_LIBRARY(todbc SHARED ${SRC} ${todbc_flex_scanner_src})
|
ADD_LIBRARY(todbc SHARED ${SRC} ${todbc_flex_scanner_src})
|
||||||
SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
SET_TARGET_PROPERTIES(todbc PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||||
SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1)
|
SET_TARGET_PROPERTIES(todbc PROPERTIES VERSION ${TD_VER_NUMBER} SOVERSION 1)
|
||||||
TARGET_LINK_LIBRARIES(todbc taos)
|
TARGET_LINK_LIBRARIES(todbc taos odbcinst)
|
||||||
target_include_directories(todbc PUBLIC .)
|
target_include_directories(todbc PUBLIC .)
|
||||||
|
|
||||||
install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install.sh ${CMAKE_BINARY_DIR})")
|
install(CODE "execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/install.sh ${CMAKE_BINARY_DIR})")
|
||||||
|
|
|
@ -27,8 +27,19 @@
|
||||||
#include "todbc_util.h"
|
#include "todbc_util.h"
|
||||||
#include "todbc_conv.h"
|
#include "todbc_conv.h"
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
|
|
||||||
|
#include <odbcinst.h>
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UTF8_ENC "UTF-8"
|
#define UTF8_ENC "UTF-8"
|
||||||
#define UTF16_ENC "UCS-2LE"
|
#define UTF16_ENC "UCS-2LE"
|
||||||
#define UNICODE_ENC "UCS-4LE"
|
#define UNICODE_ENC "UCS-4LE"
|
||||||
|
@ -549,9 +560,20 @@ static SQLRETURN doSQLConnect(SQLHDBC ConnectionHandle,
|
||||||
const char *auth = NULL;
|
const char *auth = NULL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
D("server: %s", serverName);
|
||||||
|
D("user: %s", userName);
|
||||||
|
D("auth: %s", auth);
|
||||||
tsdb_conv(client_to_server, &buffer, (const char*)ServerName, (size_t)NameLength1, &serverName, NULL);
|
tsdb_conv(client_to_server, &buffer, (const char*)ServerName, (size_t)NameLength1, &serverName, NULL);
|
||||||
tsdb_conv(client_to_server, &buffer, (const char*)UserName, (size_t)NameLength2, &userName, NULL);
|
tsdb_conv(client_to_server, &buffer, (const char*)UserName, (size_t)NameLength2, &userName, NULL);
|
||||||
tsdb_conv(client_to_server, &buffer, (const char*)Authentication, (size_t)NameLength3, &auth, NULL);
|
tsdb_conv(client_to_server, &buffer, (const char*)Authentication, (size_t)NameLength3, &auth, NULL);
|
||||||
|
D("server: %s", serverName);
|
||||||
|
D("user: %s", userName);
|
||||||
|
D("auth: %s", auth);
|
||||||
|
char haha[4096]; haha[0] = '\0';
|
||||||
|
int n = SQLGetPrivateProfileString(serverName, "Server", "null", haha, sizeof(haha)-1, NULL);
|
||||||
|
D("n: %d", n);
|
||||||
|
D("haha: [%s]", haha);
|
||||||
|
|
||||||
if ((!serverName) || (!userName) || (!auth)) {
|
if ((!serverName) || (!userName) || (!auth)) {
|
||||||
SET_ERROR(conn, "HY001", TSDB_CODE_ODBC_OOM, "");
|
SET_ERROR(conn, "HY001", TSDB_CODE_ODBC_OOM, "");
|
||||||
break;
|
break;
|
||||||
|
@ -2847,6 +2869,21 @@ SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT StatementHandle,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL INSTAPI ConfigDSN(HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL INSTAPI ConfigTranslator(HWND hwndParent, DWORD *pvOption)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL INSTAPI ConfigDriver(HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszArgs,
|
||||||
|
LPSTR lpszMsg, WORD cbMsgMax, WORD *pcbMsgOut)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,4 +25,7 @@ SQLSetConnectAttr
|
||||||
SQLDescribeCol
|
SQLDescribeCol
|
||||||
SQLNumParams
|
SQLNumParams
|
||||||
SQLSetStmtAttr
|
SQLSetStmtAttr
|
||||||
|
ConfigDSN
|
||||||
|
ConfigTranslator
|
||||||
|
ConfigDriver
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,9 @@ static int open_connect(const char *dsn, const char *uid, const char *pwd, SQLHE
|
||||||
CHK_RESULT(r, SQL_HANDLE_ENV, env, "");
|
CHK_RESULT(r, SQL_HANDLE_ENV, env, "");
|
||||||
if (r!=SQL_SUCCESS) break;
|
if (r!=SQL_SUCCESS) break;
|
||||||
do {
|
do {
|
||||||
r = SQLConnect(conn, (SQLCHAR*)dsn, (SQLSMALLINT)strlen(dsn),
|
r = SQLConnect(conn, (SQLCHAR*)dsn, (SQLSMALLINT)(dsn ? strlen(dsn) : 0),
|
||||||
(SQLCHAR*)uid, (SQLSMALLINT)strlen(uid),
|
(SQLCHAR*)uid, (SQLSMALLINT)(uid ? strlen(uid) : 0),
|
||||||
(SQLCHAR*)pwd, (SQLSMALLINT)strlen(pwd));
|
(SQLCHAR*)pwd, (SQLSMALLINT)(pwd ? strlen(pwd) : 0));
|
||||||
CHK_RESULT(r, SQL_HANDLE_DBC, conn, "");
|
CHK_RESULT(r, SQL_HANDLE_DBC, conn, "");
|
||||||
if (r==SQL_SUCCESS) {
|
if (r==SQL_SUCCESS) {
|
||||||
*pEnv = env;
|
*pEnv = env;
|
||||||
|
@ -119,7 +119,7 @@ static int open_driver_connect(const char *connstr, SQLHENV *pEnv, SQLHDBC *pCon
|
||||||
SQLHDBC ConnectionHandle = conn;
|
SQLHDBC ConnectionHandle = conn;
|
||||||
SQLHWND WindowHandle = NULL;
|
SQLHWND WindowHandle = NULL;
|
||||||
SQLCHAR * InConnectionString = (SQLCHAR*)connstr;
|
SQLCHAR * InConnectionString = (SQLCHAR*)connstr;
|
||||||
SQLSMALLINT StringLength1 = (SQLSMALLINT)strlen(connstr);
|
SQLSMALLINT StringLength1 = (SQLSMALLINT)(connstr ? strlen(connstr) : 0);
|
||||||
SQLCHAR * OutConnectionString = buf;
|
SQLCHAR * OutConnectionString = buf;
|
||||||
SQLSMALLINT BufferLength = sizeof(buf);
|
SQLSMALLINT BufferLength = sizeof(buf);
|
||||||
SQLSMALLINT * StringLength2Ptr = &blen;
|
SQLSMALLINT * StringLength2Ptr = &blen;
|
||||||
|
@ -525,19 +525,103 @@ int test_sqls(const char *dsn, const char *uid, const char *pwd, const char *con
|
||||||
} else {
|
} else {
|
||||||
CHK_TEST(open_driver_connect(connstr, &env, &conn));
|
CHK_TEST(open_driver_connect(connstr, &env, &conn));
|
||||||
}
|
}
|
||||||
|
if (sqls) {
|
||||||
r = test_sqls_in_conn(env, conn, sqls);
|
r = test_sqls_in_conn(env, conn, sqls);
|
||||||
|
}
|
||||||
SQLDisconnect(conn);
|
SQLDisconnect(conn);
|
||||||
SQLFreeConnect(conn);
|
SQLFreeConnect(conn);
|
||||||
SQLFreeEnv(env);
|
SQLFreeEnv(env);
|
||||||
return r ? 1 : 0;
|
return r ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
void usage(const char *arg0) {
|
||||||
if (argc==1) {
|
fprintf(stdout, "%s usage:\n", arg0);
|
||||||
CHK_TEST(test_env());
|
fprintf(stdout, "%s [--dsn <dsn>] [--uid <uid>] [--pwd <pwd>] [--dcs <dcs>] [--sts <sts>]\n", arg0);
|
||||||
return 0;
|
fprintf(stdout, " --dsn <dsn>: DSN\n");
|
||||||
|
fprintf(stdout, " --uid <uid>: UID\n");
|
||||||
|
fprintf(stdout, " --pwd <pwd>: PWD\n");
|
||||||
|
fprintf(stdout, " --dcs <dcs>: driver connection string\n");
|
||||||
|
fprintf(stdout, " --sts <sts>: file where statements store\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
// if (argc==1) {
|
||||||
|
// CHK_TEST(test_env());
|
||||||
|
// CHK_TEST(test1("TAOS_DSN", "root", "taoxsdata"));
|
||||||
|
// D("Done!");
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
const char *dsn = NULL;
|
||||||
|
const char *uid = NULL;
|
||||||
|
const char *pwd = NULL;
|
||||||
|
const char *dcs = NULL; // driver connection string
|
||||||
|
const char *sts = NULL; // statements file
|
||||||
|
for (size_t i=1; i<argc; ++i) {
|
||||||
|
const char *arg = argv[i];
|
||||||
|
if (strcmp(arg, "-h")==0) {
|
||||||
|
usage(argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (strcmp(arg, "--dsn")==0) {
|
||||||
|
++i;
|
||||||
|
if (i>=argc) {
|
||||||
|
D("<dsn> expected but got nothing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (dcs) {
|
||||||
|
D("--dcs has already been specified");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
dsn = argv[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(arg, "--uid")==0) {
|
||||||
|
++i;
|
||||||
|
if (i>=argc) {
|
||||||
|
D("<uid> expected but got nothing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
uid = argv[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(arg, "--pwd")==0) {
|
||||||
|
++i;
|
||||||
|
if (i>=argc) {
|
||||||
|
D("<pwd> expected but got nothing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
pwd = argv[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(arg, "--dcs")==0) {
|
||||||
|
++i;
|
||||||
|
if (i>=argc) {
|
||||||
|
D("<dcs> expected but got nothing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (dsn || uid || pwd) {
|
||||||
|
D("either of --dsn/--uid/--pwd has already been specified");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
dcs = argv[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strcmp(arg, "--sts")==0) {
|
||||||
|
++i;
|
||||||
|
if (i>=argc) {
|
||||||
|
D("<sts> expected but got nothing");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sts = argv[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CHK_TEST(test_sqls(dsn, uid, pwd, dcs, sts));
|
||||||
|
D("Done!");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (0) {
|
||||||
const char *dsn = (argc>1) ? argv[1] : NULL;
|
const char *dsn = (argc>1) ? argv[1] : NULL;
|
||||||
const char *uid = (argc>2) ? argv[2] : NULL;
|
const char *uid = (argc>2) ? argv[2] : NULL;
|
||||||
const char *pwd = (argc>3) ? argv[3] : NULL;
|
const char *pwd = (argc>3) ? argv[3] : NULL;
|
||||||
|
@ -585,4 +669,5 @@ int main(int argc, char *argv[]) {
|
||||||
D("Done!");
|
D("Done!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue