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_5630_test.py

98 lines
2.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5896
ISSUE: 5896
TITLE: Can't create the shadow file
DESCRIPTION:
Shadow file is can not be created during restore when -use_all_space option is used
JIRA: CORE-5630
FBTEST: bugs.core_5630
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
from pathlib import Path
2022-01-25 22:55:48 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = python_act('db', substitutions=[('Commit current transaction \\(y/n\\)\\?', '')])
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout_a = """
2021-04-26 20:07:00 +02:00
RDB$FILE_SEQUENCE 0
RDB$FILE_START 0
RDB$FILE_LENGTH 0
RDB$FILE_FLAGS 1
RDB$SHADOW_NUMBER 1
S_HASH_BEFORE 1499836372373901520
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout_b = """
2021-04-26 20:07:00 +02:00
RDB$FILE_SEQUENCE 0
RDB$FILE_START 0
RDB$FILE_LENGTH 0
RDB$FILE_FLAGS 1
RDB$SHADOW_NUMBER 1
S_HASH_AFTER 1499836372373901520
"""
2022-01-25 22:55:48 +01:00
fdb_file = temp_file('core_5630.fdb')
fbk_file = temp_file('core_5630.fbk')
shd_file = temp_file('core_5630.shd')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.3')
2022-01-25 22:55:48 +01:00
def test_1(act: Action, fdb_file: Path, fbk_file: Path, shd_file: Path):
init_ddl = f"""
set bail on;
set list on;
2022-01-25 22:55:48 +01:00
create database 'localhost:{fdb_file}' user '{act.db.user}' password '{act.db.password}';
recreate table test(s varchar(30));
commit;
create or alter view v_shadow_info as
select
rdb$file_sequence -- 0
,rdb$file_start -- 0
,rdb$file_length -- 0
,rdb$file_flags -- 1
,rdb$shadow_number -- 1
from rdb$files
where lower(rdb$file_name) containing lower('core_5630.shd')
;
2021-04-26 20:07:00 +02:00
insert into test select 'line #' || lpad(row_number()over(), 3, '0' ) from rdb$types rows 200;
commit;
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
create shadow 1 '{shd_file}';
commit;
set list on;
select * from v_shadow_info;
select hash( list(s) ) as s_hash_before from test;
quit;
2022-01-25 22:55:48 +01:00
"""
act.expected_stdout = expected_stdout_a
act.isql(switches=['-q'], input=init_ddl)
assert act.clean_stdout == act.clean_expected_stdout
#
2022-01-25 22:55:48 +01:00
with act.connect_server() as srv:
srv.database.backup(database=fdb_file, backup=fbk_file)
srv.wait()
#
2022-01-25 22:55:48 +01:00
fdb_file.unlink()
shd_file.unlink()
#
2022-01-25 22:55:48 +01:00
act.reset()
act.gbak(switches=['-c', '-use_all_space', str(fbk_file), act.get_dsn(fdb_file)])
# Check that we have the same data in DB tables
sql_text = """
set list on;
select * from v_shadow_info;
select hash( list(s) ) as s_hash_after from test;
2022-01-25 22:55:48 +01:00
"""
act.reset()
act.expected_stdout = expected_stdout_b
act.isql(switches=['-q', act.get_dsn(fdb_file)], input=sql_text, connect_db=False)
assert act.clean_stdout == act.clean_expected_stdout