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 truncation reading 8859-1 Spanish column using isc_dsql_fetch with UTF-8 connection.. [CORE2361] #2784

Closed
firebird-issue-importer opened this issue Mar 9, 2009 · 10 comments

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Mar 9, 2009

Submitted by: Richard Wesley (hawkfish)

Jira_subtask_outward CORE2435
Is related to QA393

Database script:

create database "setup.B21839.fdb";

create table "'Master by Reseller$'" (
"Tier" VARCHAR(20) CHARACTER SET ISO8859_1 COLLATE ES_ES_CI_AI
);

commit;

insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('(blank)');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Approved');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Bronze');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('DMR');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Domestic Distributor');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('End-User');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Evaluation');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Gold');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('New');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('Silver');
insert into "'Master by Reseller$'" ( "Tier" ) VALUES ('VAM');

commit;

We then connect to it using the API:

dpb\.SetParam\( isc\_dpb\_user\_name, attr\[ DataConnection::attrUsername \] \);
dpb\.SetParam\( isc\_dpb\_password, pwd \);
dpb\.SetParam\( isc\_dpb\_lc\_ctype, \_T\("UTF8"\) \);
dpb\.SetParam\( isc\_dpb\_sql\_dialect, \(ISC\_SCHAR\) SQL\_DIALECT\_V6 \);

and attempt to run the following query:

SELECT DISTINCT ((CASE WHEN "'Master by Reseller$'"."Tier" IN ( '(blank)', 'Domestic Distributor', 'End-User', 'Evaluation', 'New') THEN '(blank)' ELSE "'Master by Reseller$'"."Tier" END)) AS "Tier (group)"
FROM "'Master by Reseller$'"
ORDER BY 1 ASC

The XSQLDA structure comes back from isc_dsql_describe with a single record having a length of 0x01c. We multiply this by 4 to make sure we allocate enough space. for the returning string. We then call isc_dsql_execute and isc_dsql_fetch. The isc_dsql_fetch call fails with:

Status: 335544321
arithmetic exception, numeric overflow, or string truncation

Adding the string 'Approved' to the IN list in the query seems to solve the problem. Most notably, it reduces the maximum length of the return string to be less than '(blank)'.

The problem does not reproduce with the UTF8 character set.

Commits: 5350f53 502f0f9

====== Test Details ======

See also other tickets related to collation ES_ES_CI_AI: CORE1384, CORE1774, CORE1172, CORE1178

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Mar 9, 2009

Commented by: Richard Wesley (hawkfish)

Sorry, it is the isc_dsql_execute call that fails (we have seen both with this expression).

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Mar 9, 2009

Commented by: Richard Wesley (hawkfish)

Also happens in 2.1.2.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Mar 9, 2009

Modified by: Richard Wesley (hawkfish)

Version: 2.1.2 [ 10270 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Mar 10, 2009

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 14, 2009

Commented by: @asfernandes

Simple test case:
select case when 1 = 0 then '(blank)' else "'Master by Reseller$'"."Tier" end from "'Master by Reseller$'";

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 18, 2009

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 2.5 RC1 [ 10300 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 24, 2011

Modified by: @pcisar

Link: This issue is related to QA393 [ QA393 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented May 31, 2011

Commented by: @pcisar

QA test added.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented May 31, 2011

Modified by: @pcisar

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented May 28, 2015

Modified by: @pavel-zotov

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

QA Status: Done successfully

Test Details: See also other tickets related to collation ES_ES_CI_AI: CORE1384, CORE1774, CORE1172, CORE1178

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

Successfully merging a pull request may close this issue.

None yet
2 participants