New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTruncation with PreparedStatements and LIKE expression on BLOB-field [JDBC132] #173
Comments
Commented by: Jerker Klang (conio) Reprodusable test for the issue. |
Modified by: Jerker Klang (conio)Attachment: Main.java [ 11290 ] |
Modified by: Roman Rokytskyy (rrokytskyy)Fix Version: Jaybird 2.2 [ 10053 ] timeestimate: 0 [ 0 ] timeoriginalestimate: 0 [ 0 ] |
Commented by: @mrotteveel Original reproduction class did not survive server crash (or has not been restored yet); New reproduction case added. In my reproduction it fails at a boundary of 31 characters To reproduce: Maybe the sqllen field has a different meaning for blobs (this is used in org.firebirdsql.jdbc.field.FBWorkaroundStringField to throw the error) Also interesting: |
Modified by: @mrotteveelAttachment: JDBC132Reproduction.java [ 11584 ] |
Modified by: @mrotteveel |
Commented by: @mrotteveel It looks like this is caused by CORE3353 in Firebird 2.5.0 and earlier describes a blob as a VARCHAR(30) parameter for LIKE. If the parameter value exceeds 30 characters, then Jaybird throws a DataTruncation exception (in FBWorkaroundStringField) as part of a workaround for CORE251 / CORE3559. In Firebird 2.5.1 a blob is no longer described as VARCHAR(30) so this error no longer occurs (checked with 2.5.1.26339 snapshot build). A workaround is to explicitly cast the parameter(!) to BLOB SUB_TYPE 1, like so: |
Modified by: @mrotteveel |
Modified by: @mrotteveel |
Modified by: @mrotteveelassignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ] |
Commented by: @mrotteveel Closed as 'Won't fix', as this will be fixed in Firebird 2.5.1 and 2.1.5 and there is unfortunately no workaround possible on Jaybird. |
Modified by: @mrotteveelstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: Jerker Klang (conio)
Relate to CORE3353
Relate to CORE251
Relate to CORE3559
Attachments:
Main.java
JDBC132Reproduction.java
When using a query with a LIKE expression on a BLOB the matching string can't exceed a certain number of characters (28 in my testcase). According to the release notes for Firebird 2.1 "small" blobs with subtype 1 could not be treated as strings. It does however not mention if the LIKE expression should work but isql allows the query.
The table used was:
CREATE TABLE TMPTABLE (ID INTEGER NOT NULL,
MYBLOB BLOB SUB_TYPE TEXT SEGMENT SIZE 80);
The query was:
select id from tmptable where myblob like ?
When setting a string larger than 28 in this case preparedStatement.setString threw a DataTruncation:
DataTruncation: false/29/28
java.sql.DataTruncation: Data truncation
at org.firebirdsql.jdbc.field.FBWorkaroundStringField.setString(FBWorkaroundStringField.java:97)
The text was updated successfully, but these errors were encountered: