From f5d4ebb40c4b802550ed4b6f93e89b854886bff7 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Thu, 16 Feb 2023 12:33:19 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_7380_test.py: Confirmed bug on 5.0.0.821, 4.0.3.2873 --- tests/bugs/gh_7380_test.py | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/bugs/gh_7380_test.py diff --git a/tests/bugs/gh_7380_test.py b/tests/bugs/gh_7380_test.py new file mode 100644 index 00000000..135eb17f --- /dev/null +++ b/tests/bugs/gh_7380_test.py @@ -0,0 +1,55 @@ +#coding:utf-8 + +""" +ID: issue-7380 +ISSUE: 7380 +TITLE: Aliased blob variable with less restrictions makes text blob accept malformed string through BLOB_APPEND +NOTES: + [16.02.2023] pzotov + Confirmed bug on 5.0.0.821, 4.0.3.2873 + Checked on 5.0.0.938, 4.0.3.2876 -- all fine. + ::: NOTE ::: + If script is executed from command line using ISQL then problem looks as described in the ticket. + But if the same script is executed from firebird-qa then FB 5.0.0.821 crashes. +""" + +import pytest +from firebird.qa import * + +db = db_factory() + +test_script = """ + set list on; + + set term ^; + create table t (b_utf8 blob sub_type text character set utf8) + ^ + + -- Wrong: no "Malformed string" error + execute block + as + declare b blob sub_type text character set utf8; + declare bb blob sub_type binary; + begin + b = blob_append(b, 'a'); + bb = b; + -- No error + b = blob_append(bb, x'FF'); + -- Malformed blob is saved to table + insert into t (b_utf8) values (:b); + end + ^ +""" + +act = isql_act('db', test_script, substitutions=[('-At block line:.*', '')]) + +expected_stdout = """ + Statement failed, SQLSTATE = 22000 + Malformed string +""" + +@pytest.mark.version('>=4.0.3') +def test_1(act: Action): + act.expected_stdout = expected_stdout + act.execute(combine_output = True) + assert act.clean_stdout == act.clean_expected_stdout