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

Data becomes truncated when database uses win1251 charset and client uses UTF8 #132

Closed
The-o opened this issue Jul 1, 2015 · 4 comments
Closed
Labels

Comments

@The-o
Copy link

The-o commented Jul 1, 2015

I work with a database that runs with NLS_LANG set to AMERICAN_AMERICA.CL8MSWIN1251 and have no write access to it. On my side NLS_LANG is set to AMERICAN_AMERICA.UTF8. When I execute a select statement, the result contains truncated data for cyrillic VARCHAR2 fields. It looks like the buffer for the incoming data uses its length in bytes in cp1251, not in utf8.

You can perform the following request to test this behaviour:

SELECT 'ААБББВВВ' AS "col1", RAWTOHEX('ААБББВВВ') AS "col2" FROM DUAL

I get this as a result:

[ { col1: 'ААББ', col2: 'C0C0C1C1C1C2C2C2' } ]

tcpdump shows that the server's response is correct cp1251 data with no truncation.

@cjbj
Copy link
Member

cjbj commented Jul 2, 2015

A full, short testcase which includes data would be helpful.

Reviewing NLS handling is on our roadmap. Other similar issues have been reported here, like #62

@cjbj cjbj added the bug label Jul 2, 2015
@paulish
Copy link

paulish commented Jul 22, 2015

I have fixed similar problem in another nodejs oracle driver: joeferner/node-oracle#238

@cjbj
Copy link
Member

cjbj commented Jul 23, 2015

@paulish thanks. The problem is indeed likely due to buffer sizing but we need to analyze where so we fix all potential issues and don't unnecessarily inflate memory use. The general rule of thumb is to multiply by the client/server character expansion ratio, which could be less than the '4' you have chosen.

@cjbj
Copy link
Member

cjbj commented Aug 17, 2015

@The-o try node-oracledb 1.0. We did increase the internal buffer sizes, as predicted. The space optimization I mentioned is on our ToDo list.

Also see https://github.com/oracle/node-oracledb/blob/master/doc/api.md#nls

@cjbj cjbj closed this as completed Aug 17, 2015
@oracle oracle locked and limited conversation to collaborators Nov 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants