Skip to content

Commit

Permalink
Fix of the testxase for iOdbc
Browse files Browse the repository at this point in the history
Looks like it doesn't let SQLGetDiagRec thru, if error message buffer is
not given.
  • Loading branch information
lawrinn committed Mar 31, 2023
1 parent 373ade1 commit 2459006
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/basic.c
Expand Up @@ -1789,7 +1789,7 @@ ODBC_TEST(t_odbc377)
{
SQLHDBC Hdbc;
SQLHSTMT Hstmt;
SQLCHAR Sqlstate[6];
SQLCHAR Sqlstate[6], ErrMsg[SQL_MAX_MESSAGE_LENGTH];

CHECK_ENV_RC(Env, SQLAllocConnect(Env, &Hdbc));

Expand All @@ -1812,20 +1812,24 @@ ODBC_TEST(t_odbc377)

CHECK_STMT_RC(Hstmt, SQLSetStmtAttr(Hstmt, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)1, 0));
EXPECT_STMT(Hstmt, SQLExecDirect(Hstmt, "SELECT SLEEP(2)", SQL_NTS), SQL_ERROR);
CHECK_STMT_RC(Hstmt, SQLGetDiagRec(SQL_HANDLE_STMT, Hstmt, 1, Sqlstate, NULL, NULL, 0, NULL));
Sqlstate[0]= '\0';
CHECK_STMT_RC(Hstmt, SQLGetDiagRec(SQL_HANDLE_STMT, Hstmt, 1, Sqlstate, NULL, ErrMsg, sizeof(ErrMsg), NULL));
if (strncmp(Sqlstate, "70100", 6) != 0 && strncmp(Sqlstate, "HY018", 6) != 0)
{
FAIL_IF(1, "Unexpected SQL State");
diag("Unexpected SQL State %s(%s)", Sqlstate, ErrMsg);
return FAIL;
}
CHECK_STMT_RC(Stmt, SQLFreeStmt(Stmt, SQL_CLOSE));

/* Verifying the same(i.e. query timeout works) for the case of prepare + execute */
CHECK_STMT_RC(Hstmt, SQLPrepare(Hstmt, "SELECT SLEEP(2)", SQL_NTS));
EXPECT_STMT(Hstmt, SQLExecute(Hstmt), SQL_ERROR);
CHECK_STMT_RC(Hstmt, SQLGetDiagRec(SQL_HANDLE_STMT, Hstmt, 1, Sqlstate, NULL, NULL, 0, NULL));
Sqlstate[0]= '\0';
CHECK_STMT_RC(Hstmt, SQLGetDiagRec(SQL_HANDLE_STMT, Hstmt, 1, Sqlstate, NULL, ErrMsg, sizeof(ErrMsg), NULL));
if (strncmp(Sqlstate, "70100", 6) != 0 && strncmp(Sqlstate, "HY018", 6) != 0)
{
FAIL_IF(1, "Unexpected SQL State");
diag("Unexpected SQL State %s(%s)", Sqlstate, ErrMsg);
return FAIL;
}

CHECK_STMT_RC(Hstmt, SQLFreeStmt(Hstmt, SQL_DROP));
Expand Down

0 comments on commit 2459006

Please sign in to comment.