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

89 lines
2.3 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-27 20:08:36 +01:00
"""
ID: issue-6477
ISSUE: 6477
TITLE: Wrong dependencies of stored function on view after backup and restore
DESCRIPTION:
We make backup of this test DB and restore it to other name using PIPE mechanism
in order to skip creation of unneeded .fbk file
See: https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
JIRA: CORE-6233
FBTEST: bugs.core_6233
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-14 20:56:34 +01:00
from io import BytesIO
from pathlib import Path
2022-01-27 20:08:36 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
init_script = """
2021-12-14 20:56:34 +01:00
set bail on;
create or alter procedure p1 as begin end;
create or alter function f1 returns integer as begin end;
commit;
set term ^;
create or alter view v1 as
select 1 as n from rdb$database
^
create or alter function f1 returns integer as
declare ret integer;
begin
select n from v1 into ret;
return ret;
end
^
create or alter procedure p1 returns (ret integer) as
begin
select n from v1 into ret;
end
^
set term ;^
commit;
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
db = db_factory(init=init_script)
2021-12-14 20:56:34 +01:00
2022-01-27 20:08:36 +01:00
act = python_act('db')
2021-12-14 20:56:34 +01:00
2022-01-27 20:08:36 +01:00
test_script = """
2021-12-14 20:56:34 +01:00
set list on;
set count on;
select
RDB$DEPENDENT_NAME as dep_name
,RDB$DEPENDED_ON_NAME as dep_on_name
from rdb$dependencies
order by 1,2;
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
DEP_NAME F1
DEP_ON_NAME V1
DEP_NAME F1
DEP_ON_NAME V1
DEP_NAME P1
DEP_ON_NAME V1
DEP_NAME P1
DEP_ON_NAME V1
DEP_NAME V1
DEP_ON_NAME RDB$DATABASE
Records affected: 5
2021-12-14 20:56:34 +01:00
"""
fdb_restored = temp_file('core_6233_restored.fdb')
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.6')
2022-01-27 20:08:36 +01:00
def test_1(act: Action, fdb_restored: Path):
with act.connect_server() as srv:
2021-12-14 20:56:34 +01:00
backup = BytesIO()
2022-01-27 20:08:36 +01:00
srv.database.local_backup(database=act.db.db_path, backup_stream=backup)
2021-12-14 20:56:34 +01:00
backup.seek(0)
srv.database.local_restore(database=fdb_restored, backup_stream=backup)
#
2022-01-27 20:08:36 +01:00
act.expected_stdout = expected_stdout
act.isql(switches=[act.get_dsn(fdb_restored)], input=test_script, connect_db=False)
assert act.clean_stdout == act.clean_expected_stdout