@@ -1858,7 +1858,8 @@ static SQLRETURN copy_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
1858
1858
errno = 0 ;
1859
1859
if (! wstr2llong (& wval , & ll )) { /* string is 0-term -> wcstoll? */
1860
1860
ERRH (stmt , "can't convert `" LWPD "` to long long." , wstr );
1861
- RET_HDIAGS (stmt , errno ? SQL_STATE_22003 : SQL_STATE_22018 );
1861
+ RET_HDIAGS (stmt , errno == ERANGE ? SQL_STATE_22003 :
1862
+ SQL_STATE_22018 );
1862
1863
}
1863
1864
DBGH (stmt , "string `" LWPD "` converted to LL=%lld." , wstr , ll );
1864
1865
/* delegate to existing functionality */
@@ -1876,7 +1877,8 @@ static SQLRETURN copy_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
1876
1877
if (! wstr2ullong (& wval , & ull )) { /* string is 0-term: wcstoull? */
1877
1878
ERRH (stmt , "can't convert `" LWPD "` to unsigned long long." ,
1878
1879
wstr );
1879
- RET_HDIAGS (stmt , errno ? SQL_STATE_22003 : SQL_STATE_22018 );
1880
+ RET_HDIAGS (stmt , errno == ERANGE ? SQL_STATE_22003 :
1881
+ SQL_STATE_22018 );
1880
1882
}
1881
1883
DBGH (stmt , "string `" LWPD "` converted to ULL=%llu." , wstr , ull );
1882
1884
if (ull <= LLONG_MAX ) {
@@ -1894,7 +1896,7 @@ static SQLRETURN copy_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
1894
1896
* (SQLUBIGINT * )data_ptr = (SQLUBIGINT )ull ;
1895
1897
write_out_octets (octet_len_ptr , sizeof (SQLUBIGINT ), irec );
1896
1898
DBGH (stmt , "converted string `" LWPD "` to "
1897
- "unsigned long long %llu." , wstr , ull );
1899
+ "unsigned long long %llu." , wstr , ull );
1898
1900
} else {
1899
1901
REJECT_AS_OOR (stmt , ull , /*fixed?*/ TRUE, "non-ULL" );
1900
1902
}
@@ -1914,14 +1916,15 @@ static SQLRETURN copy_string(esodbc_rec_st *arec, esodbc_rec_st *irec,
1914
1916
/* if empty string, non-numeric or under/over-flow, bail out */
1915
1917
if ((! wval .cnt ) || (wval .str + wval .cnt != endp ) || errno ) {
1916
1918
ERRH (stmt , "can't convert `" LWPD "` to double." , wstr );
1917
- RET_HDIAGS (stmt , errno ? SQL_STATE_22003 : SQL_STATE_22018 );
1919
+ RET_HDIAGS (stmt , errno == ERANGE ? SQL_STATE_22003 :
1920
+ SQL_STATE_22018 );
1918
1921
}
1919
1922
/* delegate to existing functionality */
1920
1923
return copy_double (arec , irec , pos , dbl );
1921
1924
1922
1925
1923
1926
default :
1924
- BUGH (stmt , "unexpected unhanlded data type: %d." ,
1927
+ BUGH (stmt , "unexpected unhandled data type: %d." ,
1925
1928
get_c_target_type (arec , irec ));
1926
1929
return SQL_ERROR ;
1927
1930
}
0 commit comments