From d2c60eef348a9a21ce372a44c676405789b84325 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Wed, 30 Oct 2024 15:03:22 +0300 Subject: [PATCH] Added/Updated tests\bugs\core_5464_test.py: Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.13.33793; 3.0.2.32670-0fab1a8. --- tests/bugs/core_5464_test.py | 136 ++++++++++++++++++++++------------- 1 file changed, 88 insertions(+), 48 deletions(-) diff --git a/tests/bugs/core_5464_test.py b/tests/bugs/core_5464_test.py index fa3855c5..4f4593e5 100644 --- a/tests/bugs/core_5464_test.py +++ b/tests/bugs/core_5464_test.py @@ -5,66 +5,106 @@ ID: issue-5734 ISSUE: 5734 TITLE: AV in fbclient when reading blob stored in incompatible encoding DESCRIPTION: + Domain description contains non-ascii text in Latvian + and is created using charset = win1257. + Subsequent connect which tries to get this description uses cp1253 (Greek). + Commit that fixed ticket: 0fab1a85597baa5054a34cae437f5da6096580b0 (20.01.2017 00:43) JIRA: CORE-5464 FBTEST: bugs.core_5464 NOTES: - [06.10.2022] pzotov - Could not complete adjusting for LINUX in new-qa. - DEFERRED. + [30.10.2024] pzotov + Crash *not* occurs but one may note different behaviour of snapshots before and after fix. + + Snapshot before fix (e.g. 90a46fa3, 06-jan-2017) for query to rdb$fields (see view v_domain_descr) + behave differently depending on connection protocol: + * for TCP is does not return any record for query to view 'v_conn_cset'; + * for LOCAL protocol its returns weird 'RDB$SYSTEM_FLAG 18775' and error 'SQLSTATE = 42000 / invalid BLOB ID'. + + Also, error message for query to view 'v_domain_descr' (before fix) was: + Statement failed, SQLSTATE = HY000 + Cannot transliterate character between character sets + request synchronization error + + Discussed with Vlad, letters date: 29-oct-2024. + Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.13.33793; 3.0.2.32670-0fab1a8. """ -import platform +import locale +from pathlib import Path + import pytest from firebird.qa import * -init_script = """ - create domain d_int int; - comment on domain d_int is - '*Лев Николаевич Толстой * *Анна Каренина * /Мне отмщение, и аз воздам/ *ЧАСТЬ ПЕРВАЯ* *I * - Все счастливые семьи похожи друг на друга, каждая несчастливая - семья несчастлива по-своему. - Все смешалось в доме Облонских. Жена узнала, что муж был в связи - с бывшею в их доме француженкою-гувернанткой, и объявила мужу, что - не может жить с ним в одном доме. Положение это продолжалось уже - третий день и мучительно чувствовалось и самими супругами, и всеми - членами семьи, и домочадцами. Все члены семьи и домочадцы - чувствовали, что нет смысла в их сожительстве и что на каждом - п1 - '; - commit; -""" +db = db_factory(charset='win1257') +act = isql_act('db', substitutions = [('TCPv(4|6)', 'TCP')]) -db_1 = db_factory(charset='WIN1251', init=init_script) +tmp_sql = temp_file('tmp_core_5464.sql') -test_script = """ - set blob all; - set list on; +@pytest.mark.version('>=3.0.1') +def test_1(act: Action, tmp_sql: Path, capsys): - select c.rdb$character_set_name as connection_cset, r.rdb$character_set_name as db_default_cset - from mon$attachments a - join rdb$character_sets c on a.mon$character_set_id = c.rdb$character_set_id - cross join rdb$database r where a.mon$attachment_id=current_connection; + non_ascii_txt = """ + Oblonsku mājā viss bija sajaukts. + Sieva uzzināja, ka viņas vīram ir attiecības ar franču guvernanti, + kas atradās viņu mājā, un paziņoja vīram, ka nevar dzīvot ar viņu vienā mājā. + """ - select rdb$field_name, rdb$system_flag, rdb$description - from rdb$fields where rdb$description is not null; -""" + init_script = f""" + create domain dm_test int; + comment on domain dm_test is '{non_ascii_txt}'; + commit; + create view v_conn_cset as + select + rdb$get_context('SYSTEM', 'NETWORK_PROTOCOL') as conn_protocol + ,c.rdb$character_set_name as connection_cset + ,r.rdb$character_set_name as db_default_cset + from mon$attachments a + join rdb$character_sets c on a.mon$character_set_id = c.rdb$character_set_id + cross join rdb$database r where a.mon$attachment_id=current_connection; -act = isql_act('db_1', test_script) + create view v_domain_descr as + select f.rdb$field_name, f.rdb$system_flag, f.rdb$description + from rdb$database d + left join rdb$fields f on f.rdb$description is not null; + commit; + """ + tmp_sql.write_bytes(init_script.encode('cp1257')) + act.isql(switches=['-q'], input_file = tmp_sql, charset='win1257', combine_output = True, io_enc = locale.getpreferredencoding()) + assert act.return_code == 0 -expected_stdout = """ - CONNECTION_CSET WIN1250 - DB_DEFAULT_CSET WIN1251 -""" + test_sql = f""" + set blob all; + set list on; + set count on; + connect '{act.db.dsn}'; + select v1.* from v_conn_cset as v1; + select v2.* from v_domain_descr as v2; + commit; -expected_stderr = """ - Statement failed, SQLSTATE = 22018 - Cannot transliterate character between character sets -""" + connect '{act.db.db_path}'; + select v3.* from v_conn_cset as v3; + select v4.* from v_domain_descr as v4; + commit; + """ + act.isql(switches=['-q'], connect_db = False, input = test_sql, charset='win1253', combine_output = True, io_enc = locale.getpreferredencoding()) -@pytest.mark.skipif(platform.system() != 'Windows', reason='FIXME: see notes') -@pytest.mark.version('>=3.0.2') -def test_1(act: Action): - act.expected_stderr = expected_stderr - act.expected_stdout = expected_stdout - act.isql(switches=['-q'], input=test_script, charset='WIN1250') - assert (act.clean_stderr == act.clean_expected_stderr and - act.clean_stdout == act.clean_expected_stdout) + act.expected_stdout = """ + CONN_PROTOCOL TCP + CONNECTION_CSET WIN1253 + DB_DEFAULT_CSET WIN1257 + Records affected: 1 + + Statement failed, SQLSTATE = 22018 + Cannot transliterate character between character sets + Records affected: 0 + + + CONN_PROTOCOL + CONNECTION_CSET WIN1253 + DB_DEFAULT_CSET WIN1257 + Records affected: 1 + + Statement failed, SQLSTATE = 22018 + Cannot transliterate character between character sets + Records affected: 0 + """ + assert act.clean_stdout == act.clean_expected_stdout