FbCommand mishandling BLOB field parameters on empty resultsets
---------------------------------------------------------------

                 Key: DNET-420
                 URL: http://tracker.firebirdsql.org/browse/DNET-420
             Project: .NET Data provider
          Issue Type: Bug
          Components: ADO.NET Provider
    Affects Versions: 2.6.5
         Environment: Windows XP
Firebird 2.5.1
            Reporter: Scott Morgan
            Assignee: Jiri Cincura


Assume a table of form:
CREATE TABLE PHRASES  ( TEXT BLOB SUB_TYPE 1 );

Then attempt the following, looking for a non-existent value:

FbCommand cmd = new FbCommand("SELECT TEXT FROM PHRASES WHERE LOWER(TEXT) LIKE 
@search_str", conn))
cmd.Parameters.Add("@search_str", FbDbType.Text).Value = "dont exist";    // 
<-- needs to be >7 chars long
FbDataReader reader = cmd.ExecuteReader();

An exception is thrown by ExecuteReader:

Unhandled Exception: FirebirdSql.Data.FirebirdClient.FbException: arithmetic 
exception, numeric overflow, or string truncation
string right truncation ---> FirebirdSql.Data.Common.IscException: arithmetic 
exception, numeric overflow, or string truncation 
string right truncation
   at FirebirdSql.Data.Client.Managed.Version10.XdrStream.Write(DbField param) 
in 
C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\XdrStream.cs:line
 695
   at FirebirdSql.Data.Client.Managed.Version10.XdrStream.Write(Descriptor 
descriptor) in 
C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\XdrStream.cs:line
 650
   at 
FirebirdSql.Data.Client.Managed.Version10.GdsStatement.SendExecuteToBuffer() in 
C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version10\GdsStatement.cs:line
 596
   at FirebirdSql.Data.Client.Managed.Version12.GdsStatement.Execute() in 
C:\projects\fb.net\source\FirebirdSql\Data\Client\Managed\Version12\GdsStatement.cs:line
 61
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior 
behavior, Boolean returnsSet) in 
C:\projects\fb.net\source\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 1250
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior 
behavior) in 
C:\projects\fb.net\source\FirebirdSql\Data\FirebirdClient\FbCommand.cs:line 551

The problem seems to be the lib mistaking the field for a VARCHAR type when the 
resultset is empty.

A workaround is to explicitly cast the parameter as a BLOB:

FbCommand cmd = new FbCommand("SELECT TEXT FROM PHRASES WHERE LOWER(TEXT) LIKE 
CAST(@search_str" AS BLOB SUB_TYPE 1), conn))

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to