diff --git a/src/IntegrationTests/ITODBCResults/test_odbc_results.cpp b/src/IntegrationTests/ITODBCResults/test_odbc_results.cpp index 83496fde8..aa7d7ca4f 100644 --- a/src/IntegrationTests/ITODBCResults/test_odbc_results.cpp +++ b/src/IntegrationTests/ITODBCResults/test_odbc_results.cpp @@ -2310,23 +2310,33 @@ TEST_F(TestSQLGetData, TIMESTAMP_TO_SQL_C_DATE) { EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); DATE_STRUCT ds1{2021, 1, 2}; CompareDateStruct(ds1, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 2, SQL_C_DATE, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); DATE_STRUCT ds{2021, 11, 20}; CompareDateStruct(ds, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 3, SQL_C_DATE, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); CompareDateStruct(ds, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 4, SQL_C_DATE, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); CompareDateStruct(ds, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 5, SQL_C_DATE, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); CompareDateStruct(ds, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 6, SQL_C_DATE, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(DATE_STRUCT), indicator); @@ -2356,10 +2366,14 @@ TEST_F(TestSQLGetData, TIMESTAMP_TO_SQL_C_TIME) { EXPECT_EQ((SQLLEN)sizeof(TIME_STRUCT), indicator); TIME_STRUCT ts2{6, 39, 45}; CompareTimeStruct(ts2, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 3, SQL_C_TIME, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(TIME_STRUCT), indicator); CompareTimeStruct(ts2, data); + EXPECT_TRUE(CheckSQLSTATE(SQL_HANDLE_STMT, m_hstmt, + SQLSTATE_FRACTIONAL_TRUNCATION)); ret = SQLGetData(m_hstmt, 4, SQL_C_TIME, &data, sizeof(data), &indicator); EXPECT_TRUE(SQL_SUCCEEDED(ret)); EXPECT_EQ((SQLLEN)sizeof(TIME_STRUCT), indicator); diff --git a/src/odfesqlodbc/convert.c b/src/odfesqlodbc/convert.c index 23b123f56..bc07b7a57 100644 --- a/src/odfesqlodbc/convert.c +++ b/src/odfesqlodbc/convert.c @@ -1306,16 +1306,7 @@ int copy_and_convert_field(StatementClass *stmt, OID field_type, int atttypmod, std_time.ss = 0; } if (strnicmp(value, "invalid", 7) != 0) { - BOOL bZone = field_type != TS_TYPE_TIMESTAMP_NO_TMZONE; - int zone; - - /* - * sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &std_time.y, - * &std_time.m, &std_time.d, &std_time.hh, &std_time.mm, - * &std_time.ss); - */ - bZone = FALSE; /* time zone stuff is unreliable */ - timestamp2stime(value, &std_time, &bZone, &zone); + char2stime(value, &std_time, &result, fCType); MYLOG(LOG_ALL, "2stime fr=%d\n", std_time.fr); } else { /*