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
JNI Implementation for writing VARCHAR (SQL_VARYING) writes too much data [JDBC237] #286
Comments
Modified by: @mrotteveeldescription: The XSQLVAR handling for a VARCHAR (SQL_VARYING) writes to much data. It uses sqllen + 3 bytes (and 0x20 pads it) where actual data length + 2 is sufficient. Also for both SQL_TEXT and SQL_VARYING it is null-terminating the byte-array, which is not necessary. => The XSQLVAR handling for a VARCHAR (SQL_VARYING) writes to much data. It uses sqllen + 3 bytes (and 0x20 pads it) where actual data length + 2 is sufficient. Also for both SQL_TEXT and SQL_VARYING it is null-terminating the byte-array, which is not necessary. |
Commented by: @mrotteveel Check pure-java implementation as well. |
Modified by: @mrotteveelFix Version: Jaybird 2.3 [ 10440 ] |
Commented by: @mrotteveel The approach taken by FDB is interesting: it saves the sqllen and sqltype in a separate location at preparation time. At execute time it restores the original values, and converts sqltype SQL_VARYING to SQL_TEXT and sets the sqllen for SQL_VARYING and SQL_TEXT to the actual data length. |
Commented by: @mrotteveel Changed JnaStatement to set sqllen to the minimum of the field length or the actual data length in the case of SQL_TEXT and SQL_VARYING. Need to double check if this works correctly with multibyte character sets. |
Modified by: @mrotteveelassignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ] |
Commented by: @mrotteveel Added test that writes a UTF8 CHAR and VARCHAR field and reads back the inserted value. |
Modified by: @mrotteveelstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @mrotteveel
The XSQLVAR handling for a VARCHAR (SQL_VARYING) writes to much data. It uses sqllen + 3 bytes (and 0x20 pads it) where actual data length + 2 is sufficient.
Also for both SQL_TEXT and SQL_VARYING it is null-terminating the byte-array, which is not necessary.
See thread: http://sourceforge.net/mailarchive/forum.php?thread_name=4F37C03E.40105%40lawinegevaar.nl&forum_name=firebird-devel
Commits: 0a4ee8b FirebirdSQL/fbt-repository@47cf080
The text was updated successfully, but these errors were encountered: