From bbe3c2c5b1c6bbc4fe171fb658b149338ec87f83 Mon Sep 17 00:00:00 2001 From: Lawrin Novitsky Date: Tue, 8 Dec 2015 16:49:22 +0100 Subject: [PATCH] Some minor changes done while merged 2.0 to the main branch Types/typos correstions, casts etc But couple of tests in catalog have been fixed --- ma_connection.c | 18 +++--- ma_connection.h | 4 +- ma_desc.c | 4 +- ma_platform_posix.c | 17 ----- ma_statement.c | 14 ++--- ma_string.c | 18 ++++++ ma_string.h | 7 ++- test/basic.c | 23 +++---- test/catalog.c | 2 +- test/multistatement.c | 2 +- test/result2.c | 2 +- test/tap.h | 5 +- test/types.c | 2 +- test/unicode.c | 140 ++++++++++++++++++++++-------------------- 14 files changed, 131 insertions(+), 127 deletions(-) diff --git a/ma_connection.c b/ma_connection.c index 7380bbb4..c33716f6 100644 --- a/ma_connection.c +++ b/ma_connection.c @@ -167,10 +167,8 @@ SQLRETURN MADB_DbcSetAttr(MADB_Dbc *Dbc, SQLINTEGER Attribute, SQLPOINTER ValueP break; case SQL_ATTR_AUTOCOMMIT: { - SQLINTEGER ValidAttrs[]= {2, SQL_AUTOCOMMIT_ON, SQL_AUTOCOMMIT_OFF}; - /* (Here and in other places)We need to double-cast to avoid compiler warnings. - size_t is chosen as integer type that has the same size with pointer */ - MADB_CHECK_ATTRIBUTE(Dbc, (SQLINTEGER)(size_t)ValuePtr, ValidAttrs); + SQLULEN ValidAttrs[]= {2, SQL_AUTOCOMMIT_ON, SQL_AUTOCOMMIT_OFF}; + MADB_CHECK_ATTRIBUTE(Dbc, ValuePtr, ValidAttrs); /* if a connection is open, try to apply setting to the connection */ if (Dbc->mariadb) { @@ -184,7 +182,7 @@ SQLRETURN MADB_DbcSetAttr(MADB_Dbc *Dbc, SQLINTEGER Attribute, SQLPOINTER ValueP return SQL_ERROR; } } - Dbc->AutoCommit= (SQLUINTEGER)(size_t)ValuePtr; + Dbc->AutoCommit= (SQLUINTEGER)(SQLULEN)ValuePtr; } break; case SQL_ATTR_CONNECTION_DEAD: @@ -209,15 +207,15 @@ SQLRETURN MADB_DbcSetAttr(MADB_Dbc *Dbc, SQLINTEGER Attribute, SQLPOINTER ValueP } break; case SQL_ATTR_LOGIN_TIMEOUT: - Dbc->LoginTimeout= (SQLUINTEGER)(size_t)ValuePtr; + Dbc->LoginTimeout= (SQLUINTEGER)(SQLULEN)ValuePtr; break; case SQL_ATTR_METADATA_ID: - Dbc->MetadataId= (SQLUINTEGER)(size_t)ValuePtr; + Dbc->MetadataId= (SQLUINTEGER)(SQLULEN)ValuePtr; break; case SQL_ATTR_ODBC_CURSORS: { - SQLINTEGER ValidAttrs[]= {3, SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER}; - MADB_CHECK_ATTRIBUTE(Dbc, (SQLULEN)ValuePtr, ValidAttrs); + SQLULEN ValidAttrs[]= {3, SQL_CUR_USE_IF_NEEDED, SQL_CUR_USE_ODBC, SQL_CUR_USE_DRIVER}; + MADB_CHECK_ATTRIBUTE(Dbc, ValuePtr, ValidAttrs); if ((SQLULEN)ValuePtr != SQL_CUR_USE_ODBC) MADB_SetError(&Dbc->Error, MADB_ERR_01S02, NULL, 0); Dbc->OdbcCursors= SQL_CUR_USE_ODBC; @@ -235,7 +233,7 @@ SQLRETURN MADB_DbcSetAttr(MADB_Dbc *Dbc, SQLINTEGER Attribute, SQLPOINTER ValueP MADB_SetError(&Dbc->Error, MADB_ERR_HY001, NULL, 0); return Dbc->Error.ReturnValue; } - Dbc->PacketSize= (SQLUINTEGER)(size_t)ValuePtr; + Dbc->PacketSize= (SQLUINTEGER)(SQLULEN)ValuePtr; break; case SQL_ATTR_QUIET_MODE: Dbc->QuietMode= (HWND)ValuePtr; diff --git a/ma_connection.h b/ma_connection.h index 19815078..2e75aa78 100644 --- a/ma_connection.h +++ b/ma_connection.h @@ -1,5 +1,5 @@ /************************************************************************************ - Copyright (C) 2013 SkySQL AB + Copyright (C) 2013,2015 MariaDB Corporation AB This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -62,7 +62,7 @@ SQLRETURN MADB_Dbc_GetCurrentDB(MADB_Dbc *Connection, SQLPOINTER CurrentDB, SQLI /**************** Helper macros ****************/ /* check if the connection is established */ #define MADB_Dbc_ACTIVE(a) \ - ((a)->mariadb && mysql_get_socket((a)->mariadb) != -1) + ((a)->mariadb && mysql_get_socket((a)->mariadb) != MARIADB_INVALID_SOCKET) #define MADB_Dbc_DSN(a) \ (a) && (a)->Dsn diff --git a/ma_desc.c b/ma_desc.c index 0cce0702..a1ac5be6 100644 --- a/ma_desc.c +++ b/ma_desc.c @@ -1,6 +1,6 @@ /************************************************************************************ - Copyright (C) 2013,2015 MariaDB Corporation AB - + Copyright (C) 2013, 2015 MariaDB Corporation AB + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either diff --git a/ma_platform_posix.c b/ma_platform_posix.c index 6a944ee8..cc5f1c4f 100644 --- a/ma_platform_posix.c +++ b/ma_platform_posix.c @@ -118,23 +118,6 @@ int DSNPrompt_Free (MADB_Prompt *prompt) } -/* Length in SQLWCHAR units*/ -SQLINTEGER SqlwcsLen(SQLWCHAR *str) -{ - SQLINTEGER result= 0; - - if (str) - { - while (*str) - { - ++result; - /* str+= (utf16->mb_charlen(*str))/sizeof(SQLWCHAR)); */ - ++str; - } - } - return result; -} - /* CharLen < 0 - treat as NTS */ SQLINTEGER SqlwcsOctetLen(SQLWCHAR *str, SQLINTEGER *CharLen) diff --git a/ma_statement.c b/ma_statement.c index 496d9038..dccd88ee 100644 --- a/ma_statement.c +++ b/ma_statement.c @@ -494,7 +494,7 @@ SQLRETURN MADB_StmtPutData(MADB_Stmt *Stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or /* To make sure that we will not consume the doble amount of memory, we need to send data via mysql_send_long_data directly to the server instead of allocating a separate buffer. This means we need to process Update and Insert statements row by row. */ - if (mysql_stmt_send_long_data(MyStmt->stmt, Stmt->PutParam, (wDataPtr ? (char *)wDataPtr : DataPtr), (unsigned long)Length)) + if (mysql_stmt_send_long_data(MyStmt->stmt, Stmt->PutParam, (wDataPtr ? (char *)wDataPtr : DataPtr), (size_t)Length)) { MADB_SetNativeError(&Stmt->Error, SQL_HANDLE_STMT, MyStmt->stmt); } @@ -1882,12 +1882,12 @@ SQLRETURN MADB_StmtSetAttr(MADB_Stmt *Stmt, SQLINTEGER Attribute, SQLPOINTER Val Stmt->Options.SimulateCursor= (SQLULEN) ValuePtr; break; case SQL_ATTR_CURSOR_SCROLLABLE: - Stmt->Options.CursorType= ((SQLLEN)ValuePtr == SQL_NONSCROLLABLE) ? + Stmt->Options.CursorType= ((SQLULEN)ValuePtr == SQL_NONSCROLLABLE) ? SQL_CURSOR_FORWARD_ONLY : SQL_CURSOR_STATIC; break; case SQL_ATTR_CURSOR_SENSITIVITY: /* we only support default value = SQL_UNSPECIFIED */ - if ((SQLLEN)ValuePtr != SQL_UNSPECIFIED) + if ((SQLULEN)ValuePtr != SQL_UNSPECIFIED) { MADB_SetError(&Stmt->Error, MADB_ERR_01S02, "Option value changed to default cursor sensitivity", 0); ret= SQL_SUCCESS_WITH_INFO; @@ -1895,7 +1895,7 @@ SQLRETURN MADB_StmtSetAttr(MADB_Stmt *Stmt, SQLINTEGER Attribute, SQLPOINTER Val break; case SQL_ATTR_CURSOR_TYPE: /* We need to check global DSN/Connection settings */ - if (MA_ODBC_CURSOR_FORWARD_ONLY(Stmt->Connection) && (SQLLEN)ValuePtr != SQL_CURSOR_FORWARD_ONLY) + if (MA_ODBC_CURSOR_FORWARD_ONLY(Stmt->Connection) && (SQLULEN)ValuePtr != SQL_CURSOR_FORWARD_ONLY) { Stmt->Options.CursorType= SQL_CURSOR_FORWARD_ONLY; MADB_SetError(&Stmt->Error, MADB_ERR_01S02, "Option value changed to default (SQL_CURSOR_FORWARD_ONLY)", 0); @@ -1903,7 +1903,7 @@ SQLRETURN MADB_StmtSetAttr(MADB_Stmt *Stmt, SQLINTEGER Attribute, SQLPOINTER Val } else if (MA_ODBC_CURSOR_DYNAMIC(Stmt->Connection)) { - if ((SQLLEN)ValuePtr == SQL_CURSOR_KEYSET_DRIVEN) + if ((SQLULEN)ValuePtr == SQL_CURSOR_KEYSET_DRIVEN) { Stmt->Options.CursorType= SQL_CURSOR_STATIC; MADB_SetError(&Stmt->Error, MADB_ERR_01S02, "Option value changed to default (SQL_CURSOR_STATIC)", 0); @@ -1914,8 +1914,8 @@ SQLRETURN MADB_StmtSetAttr(MADB_Stmt *Stmt, SQLINTEGER Attribute, SQLPOINTER Val /* only FORWARD or Static is allowed */ else { - if ((SQLLEN)ValuePtr != SQL_CURSOR_FORWARD_ONLY && - (SQLLEN)ValuePtr != SQL_CURSOR_STATIC) + if ((SQLULEN)ValuePtr != SQL_CURSOR_FORWARD_ONLY && + (SQLULEN)ValuePtr != SQL_CURSOR_STATIC) { Stmt->Options.CursorType= SQL_CURSOR_STATIC; MADB_SetError(&Stmt->Error, MADB_ERR_01S02, "Option value changed to default (SQL_CURSOR_STATIC)", 0); diff --git a/ma_string.c b/ma_string.c index f252f274..f2fc0881 100644 --- a/ma_string.c +++ b/ma_string.c @@ -534,3 +534,21 @@ SQLINTEGER SqlwcsCharLen(SQLWCHAR *str, SQLLEN octets) return result; } + +/* Length in SQLWCHAR units*/ +SQLINTEGER SqlwcsLen(SQLWCHAR *str) +{ + SQLINTEGER result= 0; + + if (str) + { + while (*str) + { + ++result; + /* str+= (utf16->mb_charlen(*str))/sizeof(SQLWCHAR)); */ + ++str; + } + } + return result; +} + diff --git a/ma_string.h b/ma_string.h index 91aa5db8..eb3861d5 100644 --- a/ma_string.h +++ b/ma_string.h @@ -38,9 +38,10 @@ size_t MADB_SetString(Client_Charset* cc, void *Dest, unsigned int DestLength, my_bool MADB_ValidateStmt(char *StmtStr); my_bool MADB_IsStatementSupported(char *StmtStr, char *token1, char *token2); -SQLINTEGER MbstrOctetLen(char *str, SQLLEN *CharLen, CHARSET_INFO *cs); -SQLLEN MbstrCharLen(char *str, SQLINTEGER OctetLen, CHARSET_INFO *cs); -SQLINTEGER SqlwcsCharLen(SQLWCHAR *str, SQLLEN octets); +SQLINTEGER MbstrOctetLen(char *str, SQLLEN *CharLen, CHARSET_INFO *cs); +SQLLEN MbstrCharLen(char *str, SQLINTEGER OctetLen, CHARSET_INFO *cs); +SQLINTEGER SqlwcsCharLen(SQLWCHAR *str, SQLLEN octets); +SQLINTEGER SqlwcsLen(SQLWCHAR *str); #define ADJUST_LENGTH(ptr, len)\ if((ptr) && ((len) == SQL_NTS))\ diff --git a/test/basic.c b/test/basic.c index 1544da15..a2337464 100644 --- a/test/basic.c +++ b/test/basic.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - 2013 MontyProgram AB + 2013, 2015 MariaDB Corporation AB The MySQL Connector/ODBC is licensed under the terms of the GPLv2 , like most @@ -497,7 +497,7 @@ ODBC_TEST(charset_utf8) CHECK_STMT_RC(hstmt1, SQLFreeStmt(hstmt1, SQL_CLOSE)); - CHECK_STMT_RC(hstmt1, SQLColumns(hstmt1, (SQLCHAR *)"odbc_test", SQL_NTS, NULL, 0, + CHECK_STMT_RC(hstmt1, SQLColumns(hstmt1, (SQLCHAR *)my_schema, SQL_NTS, NULL, 0, (SQLCHAR *)"t_bug19345", SQL_NTS, (SQLCHAR *)"%", 1)); @@ -906,6 +906,7 @@ ODBC_TEST(t_bug32014) SQLHDBC hdbc1; SQLHSTMT hstmt1; SQLUINTEGER info; + SQLULEN attr; long i=0; SQLSMALLINT value_len; @@ -944,26 +945,26 @@ ODBC_TEST(t_bug32014) CHECK_STMT_RC(hstmt1, SQLSetStmtOption(hstmt1, SQL_CURSOR_TYPE , SQL_CURSOR_FORWARD_ONLY )); CHECK_STMT_RC(hstmt1, SQLGetStmtOption(hstmt1, SQL_CURSOR_TYPE, - (SQLPOINTER) &info)); - is_num(info, expectedCurType[i][SQL_CURSOR_FORWARD_ONLY]); + (SQLPOINTER) &attr)); + is_num(attr, expectedCurType[i][SQL_CURSOR_FORWARD_ONLY]); CHECK_STMT_RC(hstmt1, SQLSetStmtOption(hstmt1, SQL_CURSOR_TYPE, SQL_CURSOR_KEYSET_DRIVEN )); CHECK_STMT_RC(hstmt1, SQLGetStmtOption(hstmt1, SQL_CURSOR_TYPE, - (SQLPOINTER) &info)); - is_num(info, expectedCurType[i][SQL_CURSOR_KEYSET_DRIVEN]); + (SQLPOINTER) &attr)); + is_num(attr, expectedCurType[i][SQL_CURSOR_KEYSET_DRIVEN]); CHECK_STMT_RC(hstmt1, SQLSetStmtOption(hstmt1, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC )); CHECK_STMT_RC(hstmt1, SQLGetStmtOption(hstmt1, SQL_CURSOR_TYPE, - (SQLPOINTER) &info)); - is_num(info, expectedCurType[i][SQL_CURSOR_DYNAMIC]); + (SQLPOINTER) &attr)); + is_num(attr, expectedCurType[i][SQL_CURSOR_DYNAMIC]); CHECK_STMT_RC(hstmt1, SQLSetStmtOption(hstmt1, SQL_CURSOR_TYPE, SQL_CURSOR_STATIC )); CHECK_STMT_RC(hstmt1, SQLGetStmtOption(hstmt1, SQL_CURSOR_TYPE, - (SQLPOINTER) &info)); - is_num(info, expectedCurType[i][SQL_CURSOR_STATIC]); + (SQLPOINTER) &attr)); + is_num(attr, expectedCurType[i][SQL_CURSOR_STATIC]); ODBC_Disconnect(henv1, hdbc1, hstmt1); @@ -1300,7 +1301,7 @@ MA_ODBC_TESTS my_tests[]= {bug19823, "bug19823", NORMAL}, {t_basic, "t_basic", NORMAL}, {t_reconnect, "t_reconnect", NORMAL}, - {charset_utf8, "charset_utf8", KNOWN_FAILURE}, + {charset_utf8, "charset_utf8", NORMAL}, {charset_gbk, "charset_gbk", NORMAL}, {t_bug30774, "t_bug30774", NORMAL}, #ifdef WE_HAVE_SETUPLIB diff --git a/test/catalog.c b/test/catalog.c index a2ef162f..0b161d27 100644 --- a/test/catalog.c +++ b/test/catalog.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - 2013 MontyProgram AB + 2013, 2015 MariaDB Corporation AB The MySQL Connector/ODBC is licensed under the terms of the GPLv2 , like most diff --git a/test/multistatement.c b/test/multistatement.c index e6a926d1..c9897a9a 100644 --- a/test/multistatement.c +++ b/test/multistatement.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - 2013 MontyProgram AB + 2013, 2015 MariaDB Corporation AB The MySQL Connector/ODBC is licensed under the terms of the GPLv2 , like most diff --git a/test/result2.c b/test/result2.c index 8271b7ff..fb8d60c9 100644 --- a/test/result2.c +++ b/test/result2.c @@ -911,7 +911,7 @@ ODBC_TEST(t_bug11766437) CHECK_STMT_RC(Stmt, SQLFetch(Stmt)); ptr= rows; - for (i= 0; i < rowcnt; ++i) + for (i= 0; (SQLUINTEGER)i < rowcnt; ++i) { /* Verifying inserted id field */ is_num(*((SQLINTEGER *)ptr), i); diff --git a/test/tap.h b/test/tap.h index eb766613..4065412a 100644 --- a/test/tap.h +++ b/test/tap.h @@ -582,7 +582,7 @@ int ODBC_Connect(SQLHANDLE *Env, SQLHANDLE *Connection, SQLHANDLE *Stmt) rc= SQLAllocHandle(SQL_HANDLE_DBC, *Env, Connection); FAIL_IF(rc != SQL_SUCCESS, "Couldn't allocate connection handle"); - /*my_options |= 4;*/ + /* my_options |= 4; */ _snprintf(DSNString, 1024, "DSN=%s;UID=%s;PWD=%s;PORT=%u;DATABASE=%s;OPTION=%ul;SERVER=%s", my_dsn, my_uid, my_pwd, my_port, my_schema, my_options, my_servername); diag("DSN: DSN=%s;UID=%s;PWD=%s;PORT=%u;DATABASE=%s;OPTION=%ul;SERVER=%s", my_dsn, my_uid, @@ -868,9 +868,6 @@ SQLWCHAR *dup_char_as_sqlwchar(SQLCHAR *from) SQLWCHAR* latin_as_sqlwchar(char *str, SQLWCHAR *buffer) { SQLWCHAR *res= buffer; - int error, char_size; - size_t len_in= strlen(str); - size_t len_out= len_in*2 + 8; if (str == NULL) { diff --git a/test/types.c b/test/types.c index 1cf52e47..76102dd9 100644 --- a/test/types.c +++ b/test/types.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - 2013 MontyProgram AB + 2013, 2015 MariaDB Corporation AB The MySQL Connector/ODBC is licensed under the terms of the GPLv2 , like most diff --git a/test/unicode.c b/test/unicode.c index 6ced755d..f9eeee48 100644 --- a/test/unicode.c +++ b/test/unicode.c @@ -1,6 +1,6 @@ /* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. - 2013 MontyProgram AB + 2013, 2015 MariaDB Corporation AB The MySQL Connector/ODBC is licensed under the terms of the GPLv2 , like most @@ -89,9 +89,9 @@ ODBC_TEST(sqlconnect) CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, - CW(my_dsn), SQL_NTS, - CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + wdsn, SQL_NTS, + wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLDisconnect(hdbc1)); CHECK_DBC_RC(hdbc1, SQLFreeConnect(hdbc1)); @@ -108,9 +108,9 @@ ODBC_TEST(sqlprepare) CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, - CW(my_dsn), SQL_NTS, - CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + wdsn, SQL_NTS, + wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(Connection, SQLAllocStmt(hdbc1, &hstmt1)); @@ -228,9 +228,9 @@ ODBC_TEST(sqlchar) CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, - CW(my_dsn), SQL_NTS, - CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + wdsn, SQL_NTS, + wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(Connection, SQLAllocStmt(hdbc1, &hstmt1)); CHECK_STMT_RC(hstmt1, SQLPrepareW(hstmt1, W(L"SELECT ? FROM DUAL"), SQL_NTS)); @@ -362,8 +362,8 @@ ODBC_TEST(sqlsetcursorname) CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE)); CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -519,8 +519,8 @@ ODBC_TEST(sqlcolattribute) SQLSMALLINT len; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -564,8 +564,8 @@ ODBC_TEST(sqldescribecol) SQLSMALLINT len; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -607,20 +607,26 @@ ODBC_TEST(sqlgetconnectattr) SQLINTEGER len; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); + /* Since we use SQLConnectW here, there is the chance that my_schema/wschema is different from the one defined in the my_dsn/wdsn */ + CHECK_STMT_RC(hstmt1, SQLSetConnectAttrW(hdbc1, SQL_ATTR_CURRENT_CATALOG, wschema, SQL_NTS)); CHECK_STMT_RC(hstmt1, SQLGetConnectAttrW(hdbc1, SQL_ATTR_CURRENT_CATALOG, wbuff, sizeof(wbuff), &len)); - is_num(len, 9 * sizeof(SQLWCHAR)); - IS_WSTR(sqlwchar_to_wchar_t(wbuff), L"odbc_test", 5); + /* Since we use SQLConnectW here, there is the chance that my_schema/wschema is different from the one defined in the */ + is_num(len, SqlwcsLen(wschema) * sizeof(SQLWCHAR)); + IS_WSTR(wbuff, wschema, len/sizeof(SQLWCHAR) + 1); FAIL_IF(SQLGetConnectAttrW(hdbc1, SQL_ATTR_CURRENT_CATALOG, wbuff, 3 * sizeof(SQLWCHAR), &len) != SQL_SUCCESS_WITH_INFO, "expected SUCCESS_WITH_INFO"); - is_num(len, 9 * sizeof(SQLWCHAR)); - IS_WSTR(sqlwchar_to_wchar_t(wbuff), L"od", 3); + is_num(len, SqlwcsLen(wschema) * sizeof(SQLWCHAR)); + /* Comparing 2 chars */ + IS_WSTR(wbuff, wschema, 2); + /* And verifying that 3rd char is terminating NULL */ + is_num(wbuff[2], 0); CHECK_STMT_RC(hstmt1, SQLFreeStmt(hstmt1, SQL_DROP)); CHECK_DBC_RC(hdbc1, SQLDisconnect(hdbc1)); @@ -640,8 +646,8 @@ ODBC_TEST(sqlgetdiagrec) HSTMT hstmt1; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -689,8 +695,8 @@ ODBC_TEST(sqlgetdiagfield) HSTMT hstmt1; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -734,8 +740,8 @@ ODBC_TEST(sqlcolumns) SQLWCHAR wbuff[MAX_ROW_DATA_LEN+1]; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -744,7 +750,7 @@ ODBC_TEST(sqlcolumns) W(L"CREATE TABLE t_columns (a\x00e3g INT)"), SQL_NTS)); - CHECK_STMT_RC(hstmt1, SQLColumnsW(hstmt1, CW("odbc_test"), 9, NULL, 0, + CHECK_STMT_RC(hstmt1, SQLColumnsW(hstmt1, wschema, SQL_NTS, NULL, 0, CW("t_columns"), SQL_NTS, W(L"a\x00e3g"), SQL_NTS)); @@ -773,8 +779,8 @@ ODBC_TEST(sqltables) SQLWCHAR wbuff[MAX_ROW_DATA_LEN+1]; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -816,8 +822,8 @@ ODBC_TEST(sqlspecialcolumns) SQLWCHAR wbuff[MAX_ROW_DATA_LEN+1]; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -859,8 +865,8 @@ ODBC_TEST(sqlforeignkeys) CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -916,8 +922,8 @@ ODBC_TEST(sqlprimarykeys) SQLWCHAR wbuff[MAX_ROW_DATA_LEN+1]; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -958,8 +964,8 @@ ODBC_TEST(sqlstatistics) SQLWCHAR table[]= {'t', 'a', '\x00e3', 'g', '\0'}; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -1008,8 +1014,8 @@ ODBC_TEST(t_bug32161) SQLSMALLINT ctype; CHECK_ENV_RC(Env, SQLAllocConnect(Env, &hdbc1)); - CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, CW(my_dsn), SQL_NTS, CW(my_uid), SQL_NTS, - CW(my_pwd), SQL_NTS)); + CHECK_DBC_RC(hdbc1, SQLConnectW(hdbc1, wdsn, SQL_NTS, wuid, SQL_NTS, + wpwd, SQL_NTS)); CHECK_DBC_RC(hdbc1, SQLAllocStmt(hdbc1, &hstmt1)); @@ -1395,32 +1401,32 @@ ODBC_TEST(odbc19) MA_ODBC_TESTS my_tests[]= { - {test_CONO1, "test_CONO1", NORMAL}, - {test_count, "test_count", NORMAL}, - {sqlconnect, "sqlconnect", NORMAL}, - {sqlprepare, "sqlprepare", NORMAL}, - {sqlprepare_ansi, "sqlprepare_ansi", NORMAL}, - {sqlchar, "sqlchar", NORMAL}, - {sqldriverconnect, "sqldriverconnect", NORMAL}, - {sqlnativesql, "sqlnativesql", NORMAL}, - {sqlsetcursorname, "sqlsetcursorname", NORMAL}, - {sqlgetcursorname, "sqlgetcursorname", NORMAL}, - {sqlcolattribute, "sqlcolattribute", NORMAL}, - {sqldescribecol, "sqldescribecol", NORMAL}, - {sqlgetconnectattr, "sqlgetconnectattr", KNOWN_FAILURE}, - {sqlgetdiagrec, "sqlgetdiagrec", NORMAL}, - {sqlgetdiagfield, "sqlgetdiagfield", NORMAL}, - {sqlcolumns, "sqlcolumns", KNOWN_FAILURE}, - {sqltables, "sqltables", NORMAL}, - {sqlspecialcolumns, "sqlspecialcolumns", NORMAL}, - {sqlforeignkeys, "sqlforeignkeys", NORMAL}, - {sqlprimarykeys, "sqlprimarykeys", NORMAL}, - {sqlstatistics, "sqlstatistics", KNOWN_FAILURE}, - {t_bug32161, "t_bug32161", NORMAL}, - {t_bug34672, "t_bug34672", NORMAL}, - {t_bug28168, "t_bug28168", NORMAL}, - {t_bug14363601, "t_bug14363601", NORMAL}, - {odbc19, "test_issue_odbc19", NORMAL}, + {test_CONO1, "test_CONO1", NORMAL}, + {test_count, "test_count", NORMAL}, + {sqlconnect, "sqlconnect", NORMAL}, + {sqlprepare, "sqlprepare", NORMAL}, + {sqlprepare_ansi, "sqlprepare_ansi", NORMAL}, + {sqlchar, "sqlchar", NORMAL}, + {sqldriverconnect, "sqldriverconnect", NORMAL}, + {sqlnativesql, "sqlnativesql", NORMAL}, + {sqlsetcursorname, "sqlsetcursorname", NORMAL}, + {sqlgetcursorname, "sqlgetcursorname", NORMAL}, + {sqlcolattribute, "sqlcolattribute", NORMAL}, + {sqldescribecol, "sqldescribecol", NORMAL}, + {sqlgetconnectattr, "sqlgetconnectattr", NORMAL}, + {sqlgetdiagrec, "sqlgetdiagrec", NORMAL}, + {sqlgetdiagfield, "sqlgetdiagfield", NORMAL}, + {sqlcolumns, "sqlcolumns", NORMAL}, + {sqltables, "sqltables", NORMAL}, + {sqlspecialcolumns, "sqlspecialcolumns", NORMAL}, + {sqlforeignkeys, "sqlforeignkeys", NORMAL}, + {sqlprimarykeys, "sqlprimarykeys", NORMAL}, + {sqlstatistics, "sqlstatistics", NORMAL}, + {t_bug32161, "t_bug32161", NORMAL}, + {t_bug34672, "t_bug34672", NORMAL}, + {t_bug28168, "t_bug28168", NORMAL}, + {t_bug14363601, "t_bug14363601", NORMAL}, + {odbc19, "test_issue_odbc19", NORMAL}, {NULL, NULL} };