Skip to content

Commit 6cdf45d

Browse files
committed
Added/Updated tests\bugs\core_1058_addi_test.py: Example from FirebirdSQL/firebird#7924 (comment)
1 parent c46a29e commit 6cdf45d

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

tests/bugs/core_1058_addi_test.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#coding:utf-8
2+
3+
"""
4+
ID: issue-1479
5+
ISSUE: https://github.com/FirebirdSQL/firebird/issues/1479
6+
TITLE: ALTER DOMAIN and ALTER TABLE don't allow to change character set and/or collation
7+
DESCRIPTION:
8+
NOTES:
9+
[12.04.2024] pzotov
10+
Example from https://github.com/FirebirdSQL/firebird/issues/7924#issue-2046076122
11+
Check solved issue about case when we change table fields type using:
12+
alter table test
13+
alter column fld_domain_defined type varchar(10) character set win1250
14+
,alter column fld_explicit_type1 type varchar(10) character set win1252
15+
,alter column fld_explicit_type2 type varchar(10) character set win1257
16+
;
17+
Before fix column types were NOT changed in this case and remains previous data:
18+
FLD_DOMAIN_DEFINED VARCHAR(10) CHARACTER SET UTF8 COLLATE UNICODE_CI_AI Nullable // why not win1250 ?
19+
FLD_EXPLICIT_TYPE1 VARCHAR(10) CHARACTER SET WIN1257 COLLATE WIN1257_EE Nullable // why not win1252 ?
20+
FLD_EXPLICIT_TYPE2 VARCHAR(10) CHARACTER SET UTF8 COLLATE UNICODE_CI Nullable // why not win1257 ?
21+
Initially report was sent to Adriano, Dmitry et al, 05-oct-2023 08:18.
22+
Fix 22-JAN-2024 17:42 in: https://github.com/FirebirdSQL/firebird/commit/11dec10f9fc079ed74d623211e01f465e45d6a7c
23+
"""
24+
25+
import pytest
26+
from firebird.qa import *
27+
28+
db = db_factory(charset = 'win1251')
29+
30+
test_script = """
31+
set bail on;
32+
set list on;
33+
create view v_domain_info as
34+
select
35+
f.rdb$field_name as dm_name
36+
,f.rdb$field_length as dm_size
37+
,f.rdb$character_length as dm_char_len
38+
,f.rdb$character_set_id as dm_cset_id
39+
,f.rdb$collation_id as dm_coll_id
40+
,c.rdb$character_set_name as dm_cset_name
41+
--,c.rdb$default_collate_name as dm_default_coll_name
42+
--,k.rdb$base_collation_name
43+
,k.rdb$collation_name as dm_coll_name
44+
from rdb$fields f
45+
join rdb$character_sets c on f.rdb$character_set_id = c.rdb$character_set_id
46+
join rdb$collations k on c.rdb$character_set_id = k.rdb$character_set_id and f.rdb$collation_id = k.rdb$collation_id
47+
where f.rdb$field_name = upper('dm_test')
48+
;
49+
50+
create view v_fields_info as
51+
select
52+
rf.rdb$field_name as field_name
53+
-- ,rf.rdb$field_source
54+
-- ,rf.rdb$field_position
55+
,f.rdb$character_length as field_char_len
56+
,f.rdb$character_set_id as field_cset_id
57+
,f.rdb$collation_id as field_coll_id
58+
,c.rdb$character_set_name as cset_name
59+
--,c.rdb$default_collate_name
60+
--,k.rdb$base_collation_name
61+
,k.rdb$collation_name as field_collation
62+
--,k.rdb$collation_id
63+
from rdb$relation_fields rf
64+
join rdb$fields f on rf.rdb$field_source = f.rdb$field_name
65+
join rdb$character_sets c on f.rdb$character_set_id = c.rdb$character_set_id
66+
join rdb$collations k on c.rdb$character_set_id = k.rdb$character_set_id and f.rdb$collation_id = k.rdb$collation_id
67+
where rf.rdb$relation_name = upper('TEST')
68+
order by
69+
field_name
70+
,field_cset_id
71+
,field_coll_id
72+
;
73+
74+
---------------------------------------------------------------
75+
alter character set utf8 set default collation unicode_ci;
76+
alter character set win1252 set default collation pxw_span;
77+
alter character set win1257 set default collation win1257_ee;
78+
commit;
79+
80+
create domain dm_test varchar(10) character set win1252;
81+
create table test(
82+
fld_domain_defined dm_test
83+
,fld_explicit_type1 varchar(10) character set win1257
84+
,fld_explicit_type2 varchar(10) character set utf8
85+
);
86+
commit;
87+
88+
---------------------------------------------------------------
89+
90+
alter character set utf8 set default collation unicode_ci_ai;
91+
alter character set win1252 set default collation pxw_swedfin;
92+
alter character set win1257 set default collation win1257_lv;
93+
commit;
94+
95+
alter domain dm_test type varchar(10) character set utf8;
96+
commit;
97+
98+
alter table test
99+
alter column fld_domain_defined type varchar(10) character set win1250
100+
,alter column fld_explicit_type1 type varchar(10) character set win1252
101+
,alter column fld_explicit_type2 type varchar(10) character set win1257
102+
;
103+
commit;
104+
105+
select 'domain_info' as msg, v.* from v_domain_info v;
106+
select 'table info' as msg, v.* from v_fields_info v;
107+
"""
108+
109+
act = isql_act('db', test_script)
110+
111+
expected_stdout = """
112+
MSG domain_info
113+
DM_NAME DM_TEST
114+
DM_SIZE 40
115+
DM_CHAR_LEN 10
116+
DM_CSET_ID 4
117+
DM_COLL_ID 4
118+
DM_CSET_NAME UTF8
119+
DM_COLL_NAME UNICODE_CI_AI
120+
121+
MSG table info
122+
FIELD_NAME FLD_DOMAIN_DEFINED
123+
FIELD_CHAR_LEN 10
124+
FIELD_CSET_ID 51
125+
FIELD_COLL_ID 0
126+
CSET_NAME WIN1250
127+
FIELD_COLLATION WIN1250
128+
129+
MSG table info
130+
FIELD_NAME FLD_EXPLICIT_TYPE1
131+
FIELD_CHAR_LEN 10
132+
FIELD_CSET_ID 53
133+
FIELD_COLL_ID 5
134+
CSET_NAME WIN1252
135+
FIELD_COLLATION PXW_SWEDFIN
136+
137+
MSG table info
138+
FIELD_NAME FLD_EXPLICIT_TYPE2
139+
FIELD_CHAR_LEN 10
140+
FIELD_CSET_ID 60
141+
FIELD_COLL_ID 3
142+
CSET_NAME WIN1257
143+
FIELD_COLLATION WIN1257_LV
144+
"""
145+
146+
@pytest.mark.version('>=6')
147+
def test_1(act: Action):
148+
act.expected_stdout = expected_stdout
149+
act.execute(combine_output = True)
150+
assert act.clean_stdout == act.clean_expected_stdout

0 commit comments

Comments
 (0)