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-automations opened this issue Dec 16, 2010 · 12 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

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-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Version: 3.0 Initial [ 10301 ]

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Commented by: John Kilin (johnkilin)

Why not?

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Fix is committed into 2.5 source tree.
Please, confirm

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Commented by: @hvlad

John confirmed fix privately

@firebird-automations
Copy link
Collaborator Author

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-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Link: This issue is duplicated by CORE3313 [ CORE3313 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

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