On 18-2-2012 22:38, Dmitry Yemanov wrote:
> 15.02.2012 20:01, Mark Rotteveel wrote:
>
>> Does SQL_VARYING require the sqllen to be updated as well, or can that
>> be left as it was originally set by isc_dsql_describe_bind?
>
> I'd say it should correspond to the real data. You're not required to
> use isc_dsql_describe_bind(), after all.

The 'problem' is that using (and reusing) prepared statements is very 
common in Java, and the bind information provided by 
isc_dsql_describe_bind() is used inside Jaybird as well.

Changing the sqllen for SQL_VARYING to the actual length, will change 
the information available to the driver about the field (in the current 
implementation of Jaybird that is).
For example: if I have VARCHAR(10) field, then Jaybird 'knows' based on 
the sqllen that upto 10 characters will fit, if I would set a two 
character string and change the sqllen to 2, then on the next use 
Jaybird would (incorrectly) think that the field is upto 2 characters 
and will throw a string truncation error if a a 3+ character string 
would be set.

The reason that Jaybird will throw that string truncation error if the 
value is longer then the (described) sqllen is that it saves a roundtrip 
to the server to get that same error; Firebird will throw that error if 
the parameter exceeds the field length (see CORE-251 / CORE-3559).

I could change Jaybird to keep a copy of the original bind description 
and use that, but that would be more complex then only changing the 
SQL_VARYING sqldata to contain the payload length + actual data without 
padding (the current implementation pads upto sqllen).
So if I could keep the sqllen untouched that would save me some work :)

-- 
Mark Rotteveel

------------------------------------------------------------------------------
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-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to