From cc4c20d08fca59819e121c0678d1e595a97c92c9 Mon Sep 17 00:00:00 2001 From: Tamas Bunth Date: Tue, 30 Jul 2019 15:05:35 +0200 Subject: [PATCH] mysqlc: Support reading blob as string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1ef0c3817bc255e7f0c38aca73c475b19d5d7d9b Reviewed-on: https://gerrit.libreoffice.org/76600 Tested-by: Jenkins Reviewed-by: Tamás Bunth --- .../source/drivers/mysqlc/mysqlc_prepared_resultset.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index 7d2c5276d142..df5702605945 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -309,7 +309,10 @@ template <> DateTime OPreparedResultSet::retrieveValue(sal_Int32 column) template <> OUString OPreparedResultSet::retrieveValue(sal_Int32 column) { - if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(OUString))) + // redirect call to the appropiate method if needed + // BLOB can be simply read out as string + if (getTypeFromMysqlType(m_aFields[column - 1].type) != std::type_index(typeid(OUString)) + && m_aFields[column - 1].type != MYSQL_TYPE_BLOB) return getRowSetValue(column); const char* sStr = static_cast(m_aData[column - 1].buffer); @@ -344,6 +347,9 @@ ORowSetValue OPreparedResultSet::getRowSetValue(sal_Int32 nColumnIndex) case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: return getString(nColumnIndex); + case MYSQL_TYPE_BLOB: + throw SQLException("Column with type BLOB cannot be converted", *this, OUString(), 1, + Any()); default: SAL_WARN("connectivity.mysqlc", "OPreparedResultSet::getRowSetValue: unknown type: " << m_aFields[nColumnIndex - 1].type);