diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2022-04-01 19:40:21 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2022-04-01 20:39:47 +0200 |
commit | da81a880df76bebb6d9fbc770c313381a3c33268 (patch) | |
tree | 724bd66ac8cba66b8c96b170d1e7337f500b9ff3 /connectivity | |
parent | 8ed2457a089ae78b54f82c1fae07d54777dda3ca (diff) |
tdf#148310: Firebird: copy complete rows, CLOB field, last character lost
off by 1 pb.
Indeed we got:
610 sal_Int64 nCharWritten = 1; // XClob is indexed from 1
offapi/com/sun/star/sdbc/XClob.idl indeed indicates:
114 The substring begins at position <code>pos</code> and has up
115 to
116 <code>length</code>
117 consecutive characters.
118 </p>
119 @param pos
120 the starting position, 1-based
121 @param length
122 the length of the substring
123 @returns
124 the substring
125 @throws SQLException
126 if a database access error occurs.
127 */
128 string getSubString([in]hyper pos, [in]long length) raises (SQLException);
but if the string to copy has length 1, we never enter:
while ( nLen > nCharWritten )
=> we must change this into: while ( nLen >= nCharWritten )
also number of remaining characters to take into account at each loop must be adapted too:
sal_Int64 nCharRemain = nLen - nCharWritten; => would be 0
into:
sal_Int64 nCharRemain = nLen - nCharWritten + 1;
Change-Id: I7697c8312024818f73a19c39f694cf209f494d71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132443
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/firebird/PreparedStatement.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 39fef04a185c..10f034ce15ce 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -610,9 +610,9 @@ void SAL_CALL OPreparedStatement::setClob(sal_Int32 nParameterIndex, const Refer sal_Int64 nCharWritten = 1; // XClob is indexed from 1 ISC_STATUS aErr = 0; sal_Int64 nLen = xClob->length(); - while ( nLen > nCharWritten ) + while ( nLen >= nCharWritten ) { - sal_Int64 nCharRemain = nLen - nCharWritten; + sal_Int64 nCharRemain = nLen - nCharWritten + 1; constexpr sal_uInt16 MAX_SIZE = SAL_MAX_UINT16 / 4; sal_uInt16 nWriteSize = std::min<sal_Int64>(nCharRemain, MAX_SIZE); OString sData = OUStringToOString( |