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

EXECUTE STATEMENT parses the SQL text using wrong charset [CORE3282] #3650

Closed
firebird-issue-importer opened this issue Dec 16, 2010 · 12 comments
Closed

Comments

@firebird-issue-importer

Submitted by: John Kilin (johnkilin)

Is duplicated by CORE3313

EXECUTE STATEMENT implementation simply calls the DSQL layer to do its job, but DSQL considers the input SQL text having the connection charset. In EXECUTE STATEMENT, however, the SQL text has the actual charset defined by the appropriate variable descriptor. If it differs from the connection charset and the SQL text contains non-ASCII characters, we get "malformed string" or "cannot transliterate" errors.

The issue can be seen if some procedure using EXECUTE STATEMENT is created in one charset, but called with another charset. Or if the dynamic SQL text is retrieved from a column which charset differs from the connection one.

I doubt it can be fixed for earlier versions (because of the layering issues), but it seems doable for v2.5 and v3.0.

Commits: 8e4755b 0e1ea07 c2963f8

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

Confirmed on 2.5.0: get "Malformed string" when connect with cset=utf8.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 16, 2010

Modified by: @dyemanov

Version: 3.0 Initial [ 10301 ]

assignee: Vlad Khorsun [ hvlad ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 16, 2010

Modified by: @dyemanov

reporter: Dmitry Yemanov [ dimitr ] => John Kilin [ johnkilin ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2010

Commented by: @dyemanov

Test case:

set names win1251;

create table TestTable (
ParamName varchar(100) character set win1251,
ParamValue varchar(1000) character set win1251
);
commit;

insert into TestTable(ParamName, ParamValue)
values ('TESTSQL', 'execute block as declare variable bufStr varchar(1024); begin bufStr= ''Тест''; end');
commit;

set term ^;

create or alter procedure TESTSP
AS
declare variable SQLText varchar(1024);
begin
select ParamValue
from TestTable
where ParamName='TESTSQL'
into SQLText;

execute statement SQLText;
end^

set term ;^
commit;

-- connect using WIN1251
execute procedure TESTSP
-- no errors

-- connect using UTF8
execute procedure TESTSP
-- Invalid token.
-- Dynamic SQL Error.
-- SQL error code = -104.
-- Malformed string.
-- At procedure 'TESTSP' line: 10, col: 3.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 20, 2010

Commented by: @hvlad

EXECUTE STATEMENTS have 5 string parameters which could be affected by this "charset issue" :
sql text
connection string
user name
role
password

Should we convert all of them into calling attachment charset ?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 21, 2010

Commented by: John Kilin (johnkilin)

Why not?

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Dec 23, 2010

Commented by: @hvlad

Fix is committed into 2.5 source tree.
Please, confirm

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 3, 2011

Commented by: @hvlad

It seems to me that only query text should be converted into attachment charset because engine assumed that query text is in attachment charset.

Other parameters (connection string, user name, role and password) should not be coverted into attachment charset because user should be able to set correct charset manually.

New fix is committed.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 21, 2011

Commented by: @hvlad

John confirmed fix privately

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Jan 21, 2011

Modified by: @hvlad

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

resolution: Fixed [ 1 ]

Fix Version: 2.5.1 [ 10333 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

@firebird-issue-importer
Copy link
Author

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

Modified by: @dyemanov

Link: This issue is duplicated by CORE3313 [ CORE3313 ]

@firebird-issue-importer
Copy link
Author

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

Modified by: @pcisar

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

@firebird-issue-importer
Copy link
Author

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

Modified by: @pavel-zotov

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

QA Status: Done successfully

Test Details: Confirmed on 2.5.0: get "Malformed string" when connect with cset=utf8.

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