On 29-8-2012 19:45, Mark Rotteveel wrote: > On 25-8-2012 11:49, Mark Rotteveel wrote: >> I have a question about handling NULL in XSQLVAR: >> >> Is it required to have sqldata set to null, or is setting sqlind to -1 >> sufficient? The reason I am asking is >> http://tracker.firebirdsql.org/browse/JDBC-271. >> >> When doing "SELECT cast(? as varchar(1)) FROM rdb$database" with the >> parameter set to NULL with sqldata being non-null and sqlind = -1, the >> query will return an empty string. >> >> If on the other hand you do >> INSERT INTO single_varchar (varcharcolumn) VALUES (?) >> with the same parameter data, followed by: >> SELECT varcharcolumn FROM single_varchar >> >> you will get NULL back. >> >> Is Jaybird doing it wrong and/or is this a bug with parameter handling >> in Firebird when the parameter is part of the select fields? > > Can this be caused by http://tracker.firebirdsql.org/browse/CORE-3475?
After some trial and error the problem is indeed related to CORE-3475. I have also found a solution for Jaybird with the native protocol: when the value being set is NULL and the sqltype does not have the nullable bit set, set it. The 'problem' is that fbclient will send a xsqlvar for a parameter that is set to NULL (eg sqlind = -1, etc), but does not have the nullable bit set as if it is a non-null value (empty string for varchar, 0 for int, etc). The pure Java protocol implementation will simply send the parameter as NULL (and Firebird server is OK with that). I have created CORE-3913 as I think it would be a good idea to have the value of sqlind be leading instead of the nullable bit when sending parameters from client to server. Mark -- Mark Rotteveel ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel