summaryrefslogtreecommitdiff
path: root/connectivity/source
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-08-14 17:36:50 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-08-14 17:40:00 +0200
commit9a9ee66f0d9dd126ed31db096b77f9c67355411b (patch)
treef66038801902f26deefe695bd956515d261551f6 /connectivity/source
parent6dc6300fe50ea9555a9a54755c07a7b55519f71a (diff)
fixup handling of unsigned values
that overflow their signed counterpart type Change-Id: I7d446a5fdddb9d5ef313c1bd022fd959b11dec28
Diffstat (limited to 'connectivity/source')
-rw-r--r--connectivity/source/commontools/FValue.cxx22
-rw-r--r--connectivity/source/commontools/dbtools.cxx17
2 files changed, 32 insertions, 7 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index bf782898f6a1..5a18711c35af 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -204,8 +204,15 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
(*this) = getString();
break;
case DataType::BIGINT:
- (*this) = getLong();
+ {
+ sal_Int64 nVal(getLong());
+ sal_uInt64 nuVal(getULong());
+ if (nVal == 0 && nuVal != 0)
+ (*this) = nuVal;
+ else
+ (*this) = nVal;
break;
+ }
case DataType::FLOAT:
(*this) = getFloat();
@@ -221,8 +228,15 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType)
(*this) = getInt16();
break;
case DataType::INTEGER:
- (*this) = getInt32();
+ {
+ sal_Int32 nVal(getInt32());
+ sal_uInt32 nuVal(getUInt32());
+ if (nVal == 0 && nuVal != 0)
+ (*this) = nuVal;
+ else
+ (*this) = nVal;
break;
+ }
case DataType::BIT:
case DataType::BOOLEAN:
(*this) = getBool();
@@ -1498,7 +1512,7 @@ sal_uInt32 ORowSetValue::getUInt32() const
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- nRet = OUString(m_aValue.m_pString).toInt32();
+ nRet = OUString(m_aValue.m_pString).toUInt32();
break;
case DataType::FLOAT:
nRet = sal_uInt32(m_aValue.m_nFloat);
@@ -1645,7 +1659,7 @@ sal_uInt64 ORowSetValue::getULong() const
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- nRet = static_cast<sal_uInt64>(OUString(m_aValue.m_pString).toInt64());
+ nRet = static_cast<sal_uInt64>(OUString(m_aValue.m_pString).toUInt64());
break;
case DataType::FLOAT:
nRet = sal_uInt64(m_aValue.m_nFloat);
diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 8d24548df962..39b7e917c09c 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -1595,6 +1595,14 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
switch (_rValue.getValueTypeClass())
{
case TypeClass_UNSIGNED_HYPER:
+ {
+ sal_uInt64 nValue = 0;
+ OSL_VERIFY( _rValue >>= nValue );
+ _rxParameters->setString(_nColumnIndex, OUString::number(nValue));
+ }
+ break;
+
+ case TypeClass_UNSIGNED_LONG:
case TypeClass_HYPER:
{
sal_Int64 nValue = 0;
@@ -1627,7 +1635,6 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setByte(_nColumnIndex, *(sal_Int8 *)_rValue.getValue());
break;
- case TypeClass_UNSIGNED_SHORT:
case TypeClass_SHORT:
_rxParameters->setShort(_nColumnIndex, *(sal_Int16*)_rValue.getValue());
break;
@@ -1636,10 +1643,14 @@ sal_Bool implSetObject( const Reference< XParameters >& _rxParameters,
_rxParameters->setString(_nColumnIndex, OUString((sal_Unicode *)_rValue.getValue(),1));
break;
- case TypeClass_UNSIGNED_LONG:
+ case TypeClass_UNSIGNED_SHORT:
case TypeClass_LONG:
- _rxParameters->setInt(_nColumnIndex, *(sal_Int32*)_rValue.getValue());
+ {
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( _rValue >>= nValue );
+ _rxParameters->setInt(_nColumnIndex, nValue);
break;
+ }
case TypeClass_FLOAT:
_rxParameters->setFloat(_nColumnIndex, *(float*)_rValue.getValue());