mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-02 15:24:57 +01:00
Poco::Data ODBC impl doesn't bind to unsigned numeric types properly #1683
This commit is contained in:
parent
4cc043e4a8
commit
3fb4c34161
@ -51,6 +51,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();
|
||||
|
||||
|
@ -21,14 +21,14 @@ namespace Data {
|
||||
namespace ODBC {
|
||||
|
||||
|
||||
ODBCMetaColumn::ODBCMetaColumn(const StatementHandle& rStmt, std::size_t position) :
|
||||
ODBCMetaColumn::ODBCMetaColumn(const StatementHandle& rStmt, std::size_t position) :
|
||||
MetaColumn(position),
|
||||
_rStmt(rStmt)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ODBCMetaColumn::~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();
|
||||
@ -97,16 +114,20 @@ void ODBCMetaColumn::init()
|
||||
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:
|
||||
|
@ -232,7 +232,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;
|
||||
|
@ -181,7 +181,7 @@ void PooledThread::activate()
|
||||
void PooledThread::release()
|
||||
{
|
||||
const long JOIN_TIMEOUT = 10000;
|
||||
|
||||
|
||||
_mutex.lock();
|
||||
_pTarget = 0;
|
||||
_mutex.unlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user