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/+/127593
Reviewed-by: Lionel Mamane <lionel@mamane.lu>
Tested-by: Jenkins
This commit is contained in:
Julien Nabet
2021-12-27 18:22:20 +01:00
parent 03c7cd9bbe
commit 8cf970d4b3
@@ -262,6 +262,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",