2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
"""
|
|
|
|
ID: issue-4506
|
|
|
|
ISSUE: 4506
|
|
|
|
TITLE: CREATE COLLATION does not verify base collation charset
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-4180
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table tci(id int);
|
|
|
|
commit;
|
2022-01-23 20:41:55 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set term ^;
|
|
|
|
execute block as
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
execute statement 'drop collation ci_coll';
|
|
|
|
when any do begin end
|
|
|
|
end
|
2022-01-23 20:41:55 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
begin
|
|
|
|
execute statement 'drop collation win1252_unicode';
|
|
|
|
when any do begin end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
^ set term ;^
|
|
|
|
commit;
|
2022-01-23 20:41:55 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
create collation win1252_unicode for win1252; -- this is special collation named (charset_unicode)
|
|
|
|
create collation ci_coll for win1252 from win1252_unicode case insensitive;
|
|
|
|
commit;
|
2022-01-23 20:41:55 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table tci(id int, name varchar(30) character set win1252 collate ci_coll);
|
|
|
|
commit;
|
|
|
|
insert into tci(id, name) values(9, 'one Row');
|
|
|
|
insert into tci(id, name) values(7, 'One row');
|
|
|
|
insert into tci(id, name) values(0, 'oNE row');
|
|
|
|
insert into tci(id, name) values(1, 'one ROw');
|
|
|
|
insert into tci(id, name) values(5, 'one roW');
|
|
|
|
insert into tci(id, name) values(4, 'oNe roW');
|
|
|
|
insert into tci(id, name) values(2, 'onE ROw');
|
|
|
|
insert into tci(id, name) values(3, 'ONE ROW');
|
|
|
|
insert into tci(id, name) values(8, 'oNE rOW');
|
|
|
|
insert into tci(id, name) values(1, 'one row');
|
|
|
|
commit;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
select n1, n2, min(n1) n3, max(n2) n4
|
|
|
|
from (
|
|
|
|
select n1, n2
|
|
|
|
from (
|
|
|
|
select min(name) n1, max(name) n2 from tci group by name
|
|
|
|
union all
|
|
|
|
select distinct name, name from tci
|
|
|
|
union all
|
|
|
|
select distinct max(name), max(name) from tci
|
|
|
|
)
|
|
|
|
order by rand()
|
|
|
|
)
|
|
|
|
group by n1, n2;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-23 20:41:55 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
N1 one row
|
|
|
|
N2 one row
|
|
|
|
N3 ONE ROW
|
|
|
|
N4 ONE ROW
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-23 20:41:55 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|