Kaydet (Commit) c25b884d authored tarafından Tamas Bunth's avatar Tamas Bunth Kaydeden (comit) Tamás Bunth

Firebird: allow setting BINARY fix and VARBINARY

Allow setting BINARY (fix) and VARBINARY types in method setBytes.

Change-Id: I6c8cfc5aff6e1240eadd6b061d629586a25b71c3
Reviewed-on: https://gerrit.libreoffice.org/50735Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Bunth <btomi96@gmail.com>
üst 70306e5a
...@@ -787,6 +787,11 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex, ...@@ -787,6 +787,11 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed); checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
checkParameterIndex(nParameterIndex); checkParameterIndex(nParameterIndex);
XSQLVAR* pVar = m_pInSqlda->sqlvar + (nParameterIndex - 1);
int dType = (pVar->sqltype & ~1); // drop flag bit for now
if( dType == SQL_BLOB )
{
#if SAL_TYPES_SIZEOFPOINTER == 8 #if SAL_TYPES_SIZEOFPOINTER == 8
isc_blob_handle aBlobHandle = 0; isc_blob_handle aBlobHandle = 0;
#else #else
...@@ -826,6 +831,34 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex, ...@@ -826,6 +831,34 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
} }
setValue< ISC_QUAD >(nParameterIndex, aBlobId, SQL_BLOB); setValue< ISC_QUAD >(nParameterIndex, aBlobId, SQL_BLOB);
}
else if( dType == SQL_VARYING )
{
const sal_Int32 nMaxSize = 0xFFFF;
Sequence<sal_Int8> xBytesCopy(xBytes);
// First 2 bytes indicate string size
if (xBytesCopy.getLength() > nMaxSize)
{
xBytesCopy.realloc( nMaxSize );
}
const short nSize = xBytesCopy.getLength();
memcpy(pVar->sqldata, &nSize, 2);
// Actual data
memcpy(pVar->sqldata + 2, xBytesCopy.getConstArray(), nSize);
}
else if( dType == SQL_TEXT )
{
memcpy(pVar->sqldata, xBytes.getConstArray(), xBytes.getLength() );
// Fill remainder with spaces
memset(pVar->sqldata + xBytes.getLength(), 0, pVar->sqllen - xBytes.getLength());
}
else
{
::dbtools::throwSQLException(
"Incorrect type for setBytes",
::dbtools::StandardSQLState::INVALID_SQL_DATA_TYPE,
*this);
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment