diff --git a/odbc-test-gauss/expected/odbc_SQLGetConnectAttr.log b/odbc-test-gauss/expected/odbc_SQLGetConnectAttr.log index fc9de39d8f5c974b372af31ac1939d6668e7dabd..975c898a5337c228b3d83f36dfd24789c136850d 100644 --- a/odbc-test-gauss/expected/odbc_SQLGetConnectAttr.log +++ b/odbc-test-gauss/expected/odbc_SQLGetConnectAttr.log @@ -1,3 +1,5 @@ Connected Successfuly! OFF +The first argument is null, and the result is:-2 +The third argument is null, and the result is:-1 exit code : 0 diff --git a/odbc-test-gauss/odbc_SQLGetConnectAttr.c b/odbc-test-gauss/odbc_SQLGetConnectAttr.c index 1a1e3e99e9ea389bf9a3e4a1d91b789e35456676..a56e8877abe8191c15e5a700097bda78a2d2fb0b 100644 --- a/odbc-test-gauss/odbc_SQLGetConnectAttr.c +++ b/odbc-test-gauss/odbc_SQLGetConnectAttr.c @@ -1,5 +1,5 @@ /* -test: ²âÊÔ½Ó¿ÚSQLAllocEnv£¬¸Ã½Ó¿Úis a deprecated function and is replaced by SQLAllocHandle() +test: ���Խӿ�SQLAllocEnv���ýӿ�is a deprecated function and is replaced by SQLAllocHandle() */ #include #include @@ -81,6 +81,14 @@ int main(int argc,char *argv[]) printf( "ON\n" ) ; else printf( "OFF\n" ) ; + + SQLINTEGER lengthPtr; + // Abnormal test + rc = SQLGetConnectAttr(NULL, SQL_AUTOCOMMIT, &autocommit, SQL_NTS, &lengthPtr); + printf("The first argument is null, and the result is:%d\n", rc); + rc = SQLGetConnectAttr(V_OD_hdbc, SQL_AUTOCOMMIT, NULL, SQL_NTS, &lengthPtr); + printf("The third argument is null, and the result is:%d\n", rc); + SQLDisconnect(V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_DBC,V_OD_hdbc); SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env); diff --git a/odbcapi30.c b/odbcapi30.c index 04b4f5f544de7cb860a3fd8e8a0d6575c5cc02b6..07118578257870320016db2bb86fd8385192ca78 100644 --- a/odbcapi30.c +++ b/odbcapi30.c @@ -387,6 +387,12 @@ SQLGetConnectAttr(HDBC ConnectionHandle, { RETCODE ret; + if (!Value) { + CC_clear_error((ConnectionClass *) ConnectionHandle); + CC_set_error((ConnectionClass *) ConnectionHandle, CONN_EXEC_ERROR, "parameter Value is required", __FUNCTION__); + return SQL_ERROR; + } + MYLOG(0, "Entering %d\n", Attribute); CC_examine_global_transaction((ConnectionClass*) ConnectionHandle); ENTER_CONN_CS((ConnectionClass *) ConnectionHandle);