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

Size of char (maybe varchar) is wrong in multiple client library [CORE5587] #5854

Closed
firebird-automations opened this issue Jul 19, 2017 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Reydy Valentin (lifeoryou)

After lot of test, when a query return a char column type in returned columns. I think the size of string is multiplicate by the length bit of charset for one char.
For exemple when i select a char(3) in utf8 charset, i recive a string of size 12.
I test it in php and Java and i have the same bug.

If you want more specifics, i can you get more.

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

As designed. XSQLDA.sqllen is max size of data in bytes.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

If you can, set the field (in code, not in database) to be described as VARCHAR (SQL_VARYING).

If you can't, tell your driver developer to do it internally (it can still report for you that field is of type CHAR).

@firebird-automations
Copy link
Collaborator Author

Commented by: Reydy Valentin (lifeoryou)

What did you mean ?
I don't know XSQLDA.sqllen, it's a configuration variable ?

@firebird-automations
Copy link
Collaborator Author

Modified by: Reydy Valentin (lifeoryou)

summary: Size of char (maby varchar) is wrong in multiple client library => Size of char (maybe varchar) is wrong in multiple client library

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

This is not a bug. A char(3) character set UTF8 takes 3 * 4 = 12 bytes storage (as a UTF-8 character takes 1 - 4 bytes). This is communicated from server to client in a datastructure called (X)SQLDA. The sqllen contains the (max) length in bytes of a field.

When using Java/Jaybird 2.2 and earlier it **will** report the correct length **if** you have specified a connection character set. But if you haven't, you will be using character set NONE and it will report the length in bytes instead. In Jaybird 3 it will report the correct size even with none.

I can't speak for the PHP specifics, but it is possible it works the same and you just need to specify a connection character set.

@firebird-automations
Copy link
Collaborator Author

Commented by: Reydy Valentin (lifeoryou)

Humm ok. Thank

Effectivly in Java/Jaybird 3, it's corrected and i recive good string.
But not in Php, even with the charset specified.
I think is a bug of Php PDO Driver.

I post a issue in their tracker.

Thanks all guys

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

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

No branches or pull requests

1 participant