connectivity/source/drivers/firebird/PreparedStatement.cxx |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3507f6e6513cb53e404f2e33d5500fdeb2b7788d
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Fri Apr 1 19:40:21 2022 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Fri Apr 1 23:19:48 2022 +0200

    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 <serval2...@yahoo.fr>
    (cherry picked from commit da81a880df76bebb6d9fbc770c313381a3c33268)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132378
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx 
b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index a3abf2d68cc8..392785b9c816 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -612,9 +612,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(

Reply via email to