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

REPLACE and charset of third parameter [CORE5919] #6177

Open
firebird-automations opened this issue Sep 21, 2018 · 2 comments
Open

REPLACE and charset of third parameter [CORE5919] #6177

firebird-automations opened this issue Sep 21, 2018 · 2 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @ibprovider

Connection charset: win1251

CREATE TABLE TEST_MODIFY_ROW (
TEST_ID T_TEST_ID NOT NULL /* T_TEST_ID = BIGINT */,
COL_VARCHAR_10 T_VARCHAR_10 /* T_VARCHAR_10 = VARCHAR(10), CHARSET: WIN1251 */,
);

For query1
SELECT "r"."TEST_ID", "r"."COL_VARCHAR_10" FROM "TEST_MODIFY_ROW" AS "r"
WHERE (POSITION(REPLACE("r"."COL_VARCHAR_10", 'ABC', :__vv_0), "r"."COL_VARCHAR_10") > 0) AND ("r"."TEST_ID" = :__8__locals1_testID_1)

Server returns that "__vv_0" parameter has NON OCTETS charset.

For query2:
SELECT "r"."TEST_ID", "r"."COL_VARCHAR_10" FROM "TEST_MODIFY_ROW" AS "r"
WHERE (POSITION(REPLACE("r"."COL_VARCHAR_10", 'ABC'||x'00'||'123', :__vv_0), "r"."COL_VARCHAR_10") > 0) AND ("r"."TEST_ID" = :__8__locals1_testID_1)

Server returns that "__vv_0" parameter has OCTETS charset.

Difference of these queries in second parameter of REPLACE: 'ABC' and 'ABC'||x'00'||'123'.

For me - in second query parameter "__vv_0" should has NON OCTETS charset.

Could anybody confirm this behaviour and explain the reason?

@firebird-automations
Copy link
Collaborator Author

Commented by: @mrotteveel

This is expected: you're using a hex-literal which makes it a character set octets string, which cause the rest of the strings to be converted to octets as well. If you don't want that, you need to explicitly cast (although with a nul-character, a different choice than octets is an odd choice anyway).

@firebird-automations
Copy link
Collaborator Author

Commented by: @ibprovider

Hello Mark,

I understood.

SELECT "r"."TEST_ID", "r"."COL_VARCHAR_10"
FROM "TEST_MODIFY_ROW" AS "r"
WHERE (POSITION(REPLACE("r"."COL_VARCHAR_10", _utf8 'ABC'||_utf8 x'00'||_utf8 '123', :__vv_0), "r"."COL_VARCHAR_10") > 0) AND ("r"."TEST_ID" = :__8__locals1_testID_1)

works as expecting.

Please close this issue.

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