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

Fix bug #54379 PDO_OCI: UTF-8 output gets truncated #59

Closed
wants to merge 2 commits into from
Closed

Fix bug #54379 PDO_OCI: UTF-8 output gets truncated #59

wants to merge 2 commits into from

Conversation

kissifrot
Copy link

I can test a Windows build ogf PHP with that fix if needed.

It will probably need fixes/tweaks, especially with the given DSN at line 12
@kissifrot
Copy link
Author

Added test.

@cjbj
Copy link
Contributor

cjbj commented May 9, 2012

I scanned the change quickly. The code looks delicate. It defines the new size in terms of a utext (a short) which is intended for utf-16. If this sizing code is the root cause of the crash, I would have expected the patch to use oratext or text with some character set multiplication factor.

The test uses the wrong number of args to putenv() so it will fail. It hardcodes the connection string and char set. It should also have a skipif if the DB char set is not UTF8.

@kissifrot
Copy link
Author

Which patch?

@lstrojny
Copy link
Contributor

Can you squash the commit?

@gureedo
Copy link

gureedo commented Dec 11, 2013

It is not quite right solution.
Oracle docs defines three versions of utf8 encoding.

There is also another one caveat: NCHAR, NVARCHAR2, NCLOB types. Before transferring data to client Oracle converts data from such columns to NLS_NCHAR character set (if it is defined). Look here for details: http://docs.oracle.com/cd/A84870_01/doc/server.816/a76966/ch2.htm#94684
So, if NLS_NCHAR defined with different character set than connection charset or NLS_LANG, we can get invalid max character width for such columns.

I see here two ways.

  1. Always multiply data_size by 4, and not support old UTF8 (Unicode 3.0) character set.
  2. Detect character set and multiply by obtained max width.

But i don't know what to do with NLS_NCHAR.

@gitgitcode
Copy link

use oci function cast() like this :
select cast( tbl.description AS
varchar2(300) )as desc FROM database.table tbl;
it work 🎱

@cofirazak
Copy link

Can anyone clarify the status of this bug?
I've recompiled yestarday php with this fix to col->maxlen in oci_statement.c given by kissifrot, and it solved this bug.
So now i wonder why this bug is so old and still not merged in the master branch?
Can anyone clarify this please?

@php-pulls
Copy link

Comment on behalf of krakjoe at php.net:

Since this PR has merge conflicts, seems to have been abandoned by author, and seems like a questionable solution, I'm closing this PR.

If the author is watching and feels I am wrong, please open a clean PR, and start a discussion on internals.

@php-pulls php-pulls closed this Jan 1, 2017
@kissifrot
Copy link
Author

Well the original PR was more a quick hack than a real fix.
There is another PR and a different fix, #542 , about this

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.

7 participants