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

Clob will now use the connection encoding #121

Merged
merged 1 commit into from Apr 25, 2014

Conversation

andrewtaylor
Copy link

Suggested fix to make CLOB handling with the large object store a little better. Uses the encoding from the connection to determine how the character stream should be encoded before storing it in the large object store. Not a perfect solution, but the best we can do without storing the encoding with the large object. Should at least be better than mangling the data as US-ASCII.

@davecramer
Copy link
Member

If memory serves the connection encoding is always UTF8 with the JDBC driver.

This PR suggests that there is a bug but it might be simpler to just set the encoding to UTF-8 ?

@andrewtaylor
Copy link
Author

Hi,

The underlying issue is on line 3177 of AbstractJdbc2Statement.java. It is calling getAsciiStream(), which by the definition of the API method can only return US-ASCII. The change I propose is that it call getCharacterStream() (which gives us a Writer) and write the data to the large object store using the connection encoding.

The change to AbstractJdbc2Clob is to ensure that the reader also uses the connection encoding rather than the current behaviour, which is to use the platform encoding.

FYI database and platform are both UTF-8, I assume the connection will be the same (I have never had to set it explicitly). All other strings are handled correctly.

davecramer pushed a commit that referenced this pull request Apr 25, 2014
Clob will now use the connection encoding
@davecramer davecramer merged commit 73f54f6 into pgjdbc:master Apr 25, 2014
davecramer pushed a commit that referenced this pull request Sep 15, 2014
pull #121 from brekka/clob_encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants