diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2012-10-25 11:16:24 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2012-10-26 19:12:22 +0200 |
commit | 77e60c005812968af9885c20fac0a098012fbeba (patch) | |
tree | f3a2148412edbf5118e46df3c7d178563bdc966d /connectivity | |
parent | improve comments (diff) | |
download | core-77e60c005812968af9885c20fac0a098012fbeba.tar.gz core-77e60c005812968af9885c20fac0a098012fbeba.zip |
fdo#52392 dbase: correctly NULL out non-filled in fields in inserted rows
Change-Id: Id2e8ad5b6bed1c184de6dccf7fa43254099fb958
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DTable.hxx | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index dee73fa71cb3..e88a7c132501 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -1505,7 +1505,7 @@ sal_Bool ODbaseTable::InsertRow(OValueRefVector& rRow, sal_Bool bFlush,const Ref sal_uInt32 nTempPos = m_nFilePos; m_nFilePos = (sal_uIntPtr)m_aHeader.db_anz + 1; - sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols ); + sal_Bool bInsertRow = UpdateBuffer( rRow, NULL, _xCols, true ); if ( bInsertRow ) { sal_uInt32 nFileSize = 0, nMemoFileSize = 0; @@ -1567,7 +1567,7 @@ sal_Bool ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,con m_pMemoStream->Seek(STREAM_SEEK_TO_END); nMemoFileSize = m_pMemoStream->Tell(); } - if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer()) + if (!UpdateBuffer(rRow, pOrgRow, _xCols, false) || !WriteBuffer()) { if (HasMemoFields() && m_pMemoStream) m_pMemoStream->SetStreamSize(nMemoFileSize); // restore old size @@ -1668,7 +1668,7 @@ static double toDouble(const rtl::OString& rString) } //------------------------------------------------------------------ -sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols) +sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow, const Reference<XIndexAccess>& _xCols, const bool bForceAllFields) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateBuffer" ); OSL_ENSURE(m_pBuffer,"Buffer is NULL!"); @@ -1814,10 +1814,10 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c ++nPos; // the row values start at 1 - // If the variable is bound at all? - if ( !rRow.get()[nPos]->isBound() ) + // don't overwrite non-bound columns + if ( ! (bForceAllFields || rRow.get()[nPos]->isBound()) ) { - // No - the next field. + // No - don't overwrite this field, it has not changed. nByteOffset += nLen; continue; } @@ -1828,14 +1828,14 @@ sal_Bool ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,c ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) ); OSL_ENSURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!"); // Update !! - if (pOrgRow.is() && !rRow.get()[nPos]->getValue().isNull() ) + if (pOrgRow.is() && rRow.get()[nPos]->isBound() && !rRow.get()[nPos]->getValue().isNull() ) pIndex->Update(m_nFilePos,*(pOrgRow->get())[nPos],*rRow.get()[nPos]); else pIndex->Insert(m_nFilePos,*rRow.get()[nPos]); } char* pData = (char *)(m_pBuffer + nByteOffset); - if (rRow.get()[nPos]->getValue().isNull()) + if (rRow.get()[nPos]->getValue().isNull() || !rRow.get()[nPos]->isBound()) { if ( bSetZero ) memset(pData,0,nLen); // Clear to NULL char ('\0') diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index 334a8141af07..691b65469ed2 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -107,7 +107,7 @@ namespace connectivity sal_Bool WriteMemo(const ORowSetValue& aVariable, sal_uIntPtr& rBlockNr); sal_Bool WriteBuffer(); - sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); + sal_Bool UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols, bool bForceAllFields); ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos); void AllocBuffer(); |