6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_6089_test.py

60 lines
1.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-26 21:10:46 +01:00
"""
ID: issue-6339
ISSUE: 6339
TITLE: BLOBs are unnecessarily copied during UPDATE after a table format change
DESCRIPTION:
It's not easy to obtain BLOB_ID using only fdb. Rather in ISQL blob_id will be shown always (even if we do not want this :)).
This test runs ISQL with commands that were provided in the ticket and parses its result by extracting only column BLOB_ID.
Each BLOB_ID is added to set(), so eventually we can get total number of UNIQUE blob IDs that were generated during test.
This number must be equal to number of records in the table (three in this test).
JIRA: CORE-6089
FBTEST: bugs.core_6089
2022-01-26 21:10:46 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-10 19:50:31 +01:00
import re
2022-01-26 21:10:46 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-26 21:10:46 +01:00
test_script = """
2021-12-10 19:50:31 +01:00
set bail on;
set list on;
set blob off;
recreate table t (col1 int, col2 blob);
recreate view v as select col2 as col2_blob_id from t; -- NB: alias for column have to be matched to re.compile() argument
commit;
insert into t values (1, '1');
insert into t values (2, '2');
insert into t values (3, '3');
commit;
2021-04-26 20:07:00 +02:00
2021-12-10 19:50:31 +01:00
select v.* from v;
update t set col1 = -col1;
select v.* from v;
2021-04-26 20:07:00 +02:00
2021-12-10 19:50:31 +01:00
rollback;
alter table t add col3 date;
select v.* from v;
update t set col1 = -col1;
select v.* from v; -- bug was here
quit;
"""
@pytest.mark.version('>=3.0.5')
2022-01-26 21:10:46 +01:00
def test_1(act: Action):
2021-12-10 19:50:31 +01:00
pattern = re.compile('COL2_BLOB_ID\\s+\\S+', re.IGNORECASE)
blob_id_set = set()
2022-01-26 21:10:46 +01:00
act.isql(switches=['-q'], input=test_script)
for line in act.stdout.splitlines():
2021-12-10 19:50:31 +01:00
if pattern.search(line):
blob_id_set.add(line.split()[1])
# Check
assert len(blob_id_set) == 3