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

String right truncation error when preparing a query with a LIKE predicate without wildcards with UTF8 encoding and connection charset WIN1251. #8359

Open
sim1984 opened this issue Dec 23, 2024 · 1 comment

Comments

@sim1984
Copy link

sim1984 commented Dec 23, 2024

WI-V5.0.2.1582 Firebird 5.0 4a67617

Create database

chcp 1251
SET NAMES WIN1251;

CREATE DATABASE 'inet4://localhost:3055/test'
USER "SYSDBA" PASSWORD 'masterkey'
PAGE_SIZE 8192
DEFAULT CHARACTER SET UTF8;

RECREATE TABLE T (
  ID BIGINT NOT NULL,
  NAME_UTF8 VARCHAR(50),
  NAME_WIN1251 VARCHAR(50) CHARACTER SET WIN1251,
  PRIMARY KEY (ID)
);


INSERT INTO T(ID, NAME_UTF8, NAME_WIN1251) VALUES (1, 'abc', 'abc');
INSERT INTO T(ID, NAME_UTF8, NAME_WIN1251) VALUES (2, 'Ават', 'Ават');

COMMIT;

Query:

SET NAMES WIN1251;
CONNECT 'inet4://localhost:3055/test'
USER "SYSDBA" PASSWORD 'masterkey';

SELECT COUNT(*)
FROM T
WHERE NAME_WIN1251 LIKE 'Ават';

                COUNT
=====================
                    1

SELECT COUNT(*)
FROM T
WHERE NAME_UTF8 LIKE 'Ават';

Statement failed, SQLSTATE = 22001
arithmetic exception, numeric overflow, or string truncation
-string right truncation
-expected length 0, actual 1

-- Why??? But

SELECT COUNT(*)
FROM T
WHERE NAME_UTF8 LIKE 'Ава_';

                COUNT
=====================
                    1

@sim1984
Copy link
Author

sim1984 commented Dec 23, 2024

This is also reproduced in Firebird 4.0.2.

If the connection encoding is changed to UTF8 and the console encoding to 65001, then the error will not be raised for NAME_UTF8 LIKE 'Ават'.

@sim1984 sim1984 changed the title String right truncation error when preparing a query with a LIKE predicate without wildcards with UTF8 encoding. String right truncation error when preparing a query with a LIKE predicate without wildcards with UTF8 encoding and connection charset WIN1251. Dec 23, 2024
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

No branches or pull requests

1 participant