mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-23 15:14:37 +01:00
Poco::Data ODBC impl doesn't bind to unsigned numeric types properly #1683
This commit is contained in:
parent
5b91bc65b6
commit
43195651af
@ -50,6 +50,9 @@ public:
|
||||
/// null-termination byte that ends the character string.
|
||||
/// This information is returned from the SQL_DESC_LENGTH record field of the IRD.
|
||||
|
||||
bool isUnsigned() const;
|
||||
/// Returns true if column is unsigned or a non-numeric data type.
|
||||
|
||||
private:
|
||||
ODBCMetaColumn();
|
||||
|
||||
|
@ -58,6 +58,23 @@ void ODBCMetaColumn::getDescription()
|
||||
}
|
||||
|
||||
|
||||
bool ODBCMetaColumn::isUnsigned() const
|
||||
{
|
||||
SQLLEN val = 0;
|
||||
if (Utility::isError(Poco::Data::ODBC::SQLColAttribute(_rStmt,
|
||||
(SQLUSMALLINT)position() + 1, // ODBC columns are 1-based
|
||||
SQL_DESC_UNSIGNED,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&val)))
|
||||
{
|
||||
throw StatementException(_rStmt);
|
||||
}
|
||||
return (val == SQL_TRUE);
|
||||
}
|
||||
|
||||
|
||||
void ODBCMetaColumn::init()
|
||||
{
|
||||
getDescription();
|
||||
@ -94,23 +111,27 @@ void ODBCMetaColumn::init()
|
||||
case SQL_WVARCHAR:
|
||||
case SQL_WLONGVARCHAR:
|
||||
setType(MetaColumn::FDT_WSTRING); break;
|
||||
|
||||
|
||||
case SQL_TINYINT:
|
||||
setType(MetaColumn::FDT_INT8); break;
|
||||
|
||||
setType(isUnsigned() ? MetaColumn::FDT_UINT8 : MetaColumn::FDT_INT8);
|
||||
break;
|
||||
|
||||
case SQL_SMALLINT:
|
||||
setType(MetaColumn::FDT_INT16); break;
|
||||
|
||||
setType(isUnsigned() ? MetaColumn::FDT_UINT16 : MetaColumn::FDT_INT16);
|
||||
break;
|
||||
|
||||
case SQL_INTEGER:
|
||||
setType(MetaColumn::FDT_INT32); break;
|
||||
|
||||
setType(isUnsigned() ? MetaColumn::FDT_UINT32 : MetaColumn::FDT_INT32);
|
||||
break;
|
||||
|
||||
case SQL_BIGINT:
|
||||
setType(MetaColumn::FDT_INT64); break;
|
||||
|
||||
setType(isUnsigned() ? MetaColumn::FDT_UINT64 : MetaColumn::FDT_INT64);
|
||||
break;
|
||||
|
||||
case SQL_DOUBLE:
|
||||
case SQL_FLOAT:
|
||||
setType(MetaColumn::FDT_DOUBLE); break;
|
||||
|
||||
|
||||
case SQL_NUMERIC:
|
||||
case SQL_DECIMAL:
|
||||
if (0 == _columnDesc.decimalDigits)
|
||||
|
@ -222,7 +222,11 @@ bool SessionImpl::canTransact()
|
||||
|
||||
void SessionImpl::setTransactionIsolation(Poco::UInt32 ti)
|
||||
{
|
||||
#if POCO_PTR_IS_64_BIT
|
||||
Poco::UInt64 isolation = 0;
|
||||
#else
|
||||
Poco::UInt32 isolation = 0;
|
||||
#endif
|
||||
|
||||
if (ti & Session::TRANSACTION_READ_UNCOMMITTED)
|
||||
isolation |= SQL_TXN_READ_UNCOMMITTED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user