6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_2211_test.py

69 lines
1.6 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-2639
ISSUE: 2639
TITLE: Offset value for SUBSTRING from BLOB more than 32767 makes exception
DESCRIPTION:
JIRA: CORE-2211
FBTEST: bugs.core_2211
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-10-21 19:29:23 +02:00
-- [pcisar] 20.10.2021
-- This script reports error:
-- Statement failed, SQLSTATE = 54000
-- arithmetic exception, numeric overflow, or string truncation
-- -Implementation limit exceeded
-- -At block line: 7, col: 9
-- Statement failed, SQLSTATE = 22011
-- Invalid offset parameter -1 to SUBSTRING. Only positive integers are allowed.
2021-04-26 20:07:00 +02:00
recreate table test(b blob);
commit;
insert into test values('');
commit;
2021-10-21 19:29:23 +02:00
2021-04-26 20:07:00 +02:00
set list on;
set blob all;
2021-10-21 19:29:23 +02:00
2021-04-26 20:07:00 +02:00
set term ^;
execute block as
declare bsize int = 1000000;
declare vclen int = 32760;
begin
while (bsize > 0) do
begin
update test set b = b || rpad('', :vclen, uuid_to_char(gen_uuid()));
bsize = bsize - vclen;
end
--update test set b = b || b;
update test set b = b || rpad('', :vclen, '#');
end
^
set term ;^
select char_length(b) from test;
select substring(b from char_length(b)-1 for 1) from test;
rollback;
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script, substitutions=[('SUBSTRING.*', '')])
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
CHAR_LENGTH 1048320
SUBSTRING 0:43
#
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00