Skip to content
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

Invalid DPB encoding for 2.5 servers [JDBC251] #670

Closed
firebird-automations opened this issue May 2, 2012 · 15 comments
Closed

Invalid DPB encoding for 2.5 servers [JDBC251] #670

firebird-automations opened this issue May 2, 2012 · 15 comments

Comments

@firebird-automations
Copy link

Submitted by: Roman KIslukhin (roman.kisluhin)

Jira_subtask_outward JDBC253
Is duplicated by JDBC149

Attachments:
dpb_encoding.patch
DpbTest.java
ReproduceJDBC251.java

Since firebird 2.5 server receives dpb parameters in differents way for windows and linux os: on windows it converts string parameters from system encoding to utf8 (if isc_dpb_utf8_filename parameter is not set).

It's wrong If encodings on client and server are distinct (e.g. client on linux but server on windows etc.).

With Firebird 2.5 new MON$ field encodings, incorrect encoding for e.g. process name leads to conversion errors when trying to access mon$attachments table.

In Jaybird all string parameters in database parameter buffer are passed to fb in java encoding (e.g. UTF8 or Cp1251 - depend on file.encoding system parameter).
See code in ParameterBufferBase.StringArgument#⁠writeTo():

final byte[] valueBytes = this.value.getBytes();

We suggest fix it to pass all dpb parameters in UTF8 and use isc_dpb_utf8_filename parameter.

This may affect backwards compatibility with 2.1 servers, if non-ASCII file names are used.

Commits: 8f6cd13

@firebird-automations
Copy link
Author

Commented by: Roman KIslukhin (roman.kisluhin)

Patch fixing this issue

@firebird-automations
Copy link
Author

Modified by: Roman KIslukhin (roman.kisluhin)

Attachment: dpb_encoding.patch [ 12142 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Could you include a testcase that demonstrates this?

As this patch indeed has the potential to break things for earlier Firebird versions, I am hesitant to add it to Jaybird 2.2 at this point. BTW: This is not really a bug in Jaybird, but an improvement to the protocol; this problem has essentially always existed in the Firebird wire protocol.

@firebird-automations
Copy link
Author

Commented by: Roman KIslukhin (roman.kisluhin)

Server:
Firebird 2.5
Windows XP (Win1251)

Client:
Linux
OR
Windows with -Dfile.encoding=UTF8 java option
e.g.
java -Dfile.encoding=UTF8 -cp .;jaybird-full-2.2.1.jar DpbTest

Result:
Exception in thread "main" org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544321. arithmetic exception, numeric overflow, or string truncation
Cannot transliterate character between character sets
at org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:206)
at org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:119)
at org.firebirdsql.jdbc.AbstractResultSet.next(AbstractResultSet.java:265)
at DpbTest.main(DpbTest.java:77)

@firebird-automations
Copy link
Author

Modified by: Roman KIslukhin (roman.kisluhin)

Attachment: DpbTest.java [ 12144 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Simplified reproduction class. NOTE: Is saved as UTF-8

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Attachment: ReproduceJDBC251.java [ 12150 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

I am not going to take on this patch for Jaybird 2.2.

However, I will include isc_dpb_utf8_filename in ISCConstants. This way you can include utf8_filename=1 in the JDBC url (or add property utf8_filename with value 1) to get the desired behaviour with manually setting file.encoding=UTF-8 on the commandline.

For the database filename you can add the property filename_charset=<java charset> to the JDBCurl as well. I will see if it is wise and easy to use this same property for other (string) DPB elements.

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Need to take this into consideration when extending wire protocol support in Jaybird 2.3

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.3 [ 10440 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

Implemented in the new wire protocol for Jaybird 3.0. I am not sure yet about the impact on the native client wrapper.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue is duplicated by JDBC149 [ JDBC149 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment