From ad0a3e851863aad5858c111b232ff0ab38ba050b Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Tue, 21 Jan 2025 15:03:08 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_8356_test.py: Checked on 6.0.0.590-7e96b33. --- tests/bugs/gh_8356_test.py | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 tests/bugs/gh_8356_test.py diff --git a/tests/bugs/gh_8356_test.py b/tests/bugs/gh_8356_test.py new file mode 100644 index 00000000..a8d5ce12 --- /dev/null +++ b/tests/bugs/gh_8356_test.py @@ -0,0 +1,88 @@ +#coding:utf-8 + +""" +ID: issue-8356 +ISSUE: https://github.com/FirebirdSQL/firebird/issues/8356 +TITLE: Make Trace use HEX representation for parameter values of types [VAR]CHAR CHARACTER SET OCTETS and [VAR]BINARY +DESCRIPTION: +NOTES: + [21.01.2025] pzotov + After fix parameters type '[va]rchar(N) character set octets' is shown in the trace as '[var]binary(N)'. + + Confirmed problem on 6.0.0.585: parameter values in the trace are shown in binary (non-readable) form. + Checked on 6.0.0.590-7e96b33 - all fine. +""" +import re + +import pytest +from firebird.qa import * + +init_sql = """ + set term ^; + create procedure sp_test ( + a_vchr varchar(16) character set octets + ,a_chr char(16) character set octets + ,a_vbin varbinary(16) + ,a_bin binary(16) + ) as + declare n smallint; + begin + n = 1; + end + ^ + set term ;^ + commit; +""" + +db = db_factory(init = init_sql) + +act = python_act('db') + +test_sql = """ + execute procedure sp_test( + gen_uuid() + ,gen_uuid() + ,gen_uuid() + ,gen_uuid() + ); +""" + +trace_events_lst = \ + [ 'time_threshold = 0' + ,'log_procedure_start = true' + ,'log_initfini = false' + ] + +@pytest.mark.trace +@pytest.mark.version('>=6.0') +def test_1(act: Action, capsys): + + with act.trace(db_events = trace_events_lst): + act.reset() + act.isql(switches = ['-q'], input = test_sql, combine_output = True) + + # Process trace + # BEFORE FIX: param0 = varchar(16), "" + # AFTER FIX: param0 = varbinary(16), "D0EC952EC11A4C209011CF95C1712D2F" + + param_name_pattern = re.compile( r'\s?param\d+\s?=\s?(var)?(binary|char)\(\d+\)', re.IGNORECASE ) + # param_hexvalue_ptn = re.compile('') + + for line in act.trace_log: + if param_name_pattern.search(line.lower()): + param_name = line.split("=")[0].strip() + param_val = line.split('"')[1] + try: + _ = int(param_val, 16) + print(f'Parameter: {param_name}, value is in HEX form.') + except ValueError as e: + print(f'Parameter: {param_name}, value: "{param_val}" - not in HEX form.') + + act.expected_stdout = """ + Parameter: param0, value is in HEX form. + Parameter: param1, value is in HEX form. + Parameter: param2, value is in HEX form. + Parameter: param3, value is in HEX form. + """ + act.stdout = capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout