From 30fb61f80bba3b119d2fbfb450e3cf1ae7e65d59 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Mon, 27 Dec 2021 16:58:05 +0100 Subject: tdf#130595: Parameter query with :parameter IS NULL doesn't work Problematic SQL here: SELECT * FROM "Table1" WHERE "Name" = :name OR :name IS NULL Firebird considers there are 2 parameters. When providing an empty string, no pb, OPreparedStatement::setNull is called which is ok for both parameters When providing a non empty string, we go to OPreparedStatement::setString. For first param no pb but for second param, sql type is SQL_NULL so it must be taken into account See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull for full details Change-Id: I80dff259d85957e8547c098e4c48b642cce26804 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127572 Reviewed-by: Lionel Mamane Tested-by: Jenkins --- connectivity/source/drivers/firebird/PreparedStatement.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx index 3b5511518957..db49ad2e4d8d 100644 --- a/connectivity/source/drivers/firebird/PreparedStatement.cxx +++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx @@ -264,6 +264,12 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 nParameterIndex, setBoolean(nParameterIndex, boolValue); break; } + case SQL_NULL: + { + // See https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull + pVar->sqldata = nullptr; + break; + } default: ::dbtools::throwSQLException( "Incorrect type for setString", -- cgit