[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - connectivity/source
Julien Nabet (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 19 08:50:55 UTC 2020
connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 22 ++++++++---
connectivity/source/drivers/firebird/ResultSet.cxx | 28 ++++++++++++--
2 files changed, 41 insertions(+), 9 deletions(-)
New commits:
commit 537e0fabf1cec7ea74a9d2fb93b795b902588e24
Author: Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sun Nov 15 15:45:26 2020 +0100
Commit: Lionel Mamane <lionel at mamane.lu>
CommitDate: Thu Nov 19 09:50:19 2020 +0100
tdf#121886: Firebird Datatype Image(BLOB) is not working properly
with Form or Report image controls.
+ merge with:
5c6340d06b4e58529f6122ecf3b26c6d4456226b
xBlob->length() returns sal_Int64 not sal_Int32
so deal with it in:
- OResultSet::getBytes
- ODatabaseMetaData::getColumns
and warn if blob is more than SAL_MAX_INT32
also rename xDescriptionBlob into xBlob
Implements getBytes at least when LONGVARBINARY corresponds to a BLOB
Change-Id: I7e4e99b537333558d5c3dcd172dc54e73472553b
Change-Id: I86c20310235fb4902633fab058066a1f2d62a600
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
(cherry picked from commit 61560ae7d6f00ba6b410f7779e9a46cf692a5400)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105864
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Lionel Mamane <lionel at mamane.lu>
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 7e6f957d2b1f..fdcfd1d64f89 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1247,13 +1247,23 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
// 12. Comments -- may be omitted
{
OUString aDescription;
- uno::Reference< XBlob > xDescriptionBlob = xRow->getBlob(3);
- if (xDescriptionBlob.is())
+ uno::Reference< XBlob > xBlob = xRow->getBlob(3);
+ if (xBlob.is())
{
- sal_Int32 aBlobLength = static_cast<sal_Int32>(xDescriptionBlob->length());
- aDescription = OUString(reinterpret_cast<char*>(xDescriptionBlob->getBytes(1, aBlobLength).getArray()),
- aBlobLength,
- RTL_TEXTENCODING_UTF8);
+ const sal_Int64 aBlobLength = xBlob->length();
+ if (aBlobLength > SAL_MAX_INT32)
+ {
+ SAL_WARN("connectivity.firebird", "getBytes can't return " << aBlobLength << " bytes but only max " << SAL_MAX_INT32);
+ aDescription = OUString(reinterpret_cast<char*>(xBlob->getBytes(1, SAL_MAX_INT32).getArray()),
+ SAL_MAX_INT32,
+ RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ aDescription = OUString(reinterpret_cast<char*>(xBlob->getBytes(1, static_cast<sal_Int32>(aBlobLength)).getArray()),
+ aBlobLength,
+ RTL_TEXTENCODING_UTF8);
+ }
}
aCurrentRow[12] = new ORowSetValueDecorator(aDescription);
}
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index 9409701d431f..7ae77c607e0d 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -665,10 +665,32 @@ sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 nColumnIndex)
return safelyRetrieveValue< ORowSetValue >(nColumnIndex);
}
-Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32)
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 nColumnIndex)
{
- return Sequence< sal_Int8 >(); // TODO: implement
- //return safelyRetrieveValue(columnIndex);
+ // &~1 to remove the "can contain NULL" indicator
+ int aSqlType = m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1;
+ if ( aSqlType == SQL_BLOB )
+ {
+ Reference< XBlob> xBlob = getBlob(nColumnIndex);
+ if (xBlob.is())
+ {
+ const sal_Int64 aBlobLength = xBlob->length();
+ if (aBlobLength > SAL_MAX_INT32)
+ {
+ SAL_WARN("connectivity.firebird", "getBytes can't return " << aBlobLength << " bytes but only max " << SAL_MAX_INT32);
+ return xBlob->getBytes(1, SAL_MAX_INT32);
+ }
+ return xBlob->getBytes(1, static_cast<sal_Int32>(aBlobLength));
+ }
+ else
+ return Sequence< sal_Int8 >();
+ }
+ // TODO implement SQL_VARYING and SQL_TEXT
+ // as it's the counterpart as OPreparedStatement::setBytes
+ else
+ {
+ return Sequence< sal_Int8 >(); // TODO: implement
+ }
}
sal_Int16 SAL_CALL OResultSet::getShort(sal_Int32 columnIndex)
More information about the Libreoffice-commits
mailing list