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

82 lines
2.5 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-2311
ISSUE: 2311
TITLE: Signature mismatch when creating package body on identical packaged procedure header
DESCRIPTION:
Bug existed because backup/restore process changed value of RDB$PROCEDURE_PARAMETERS.RDB$NULL_FLAG
for procedure parameter from NULL to 0 (zero).
Test creates trivial package and stores its package body in variable that will be used after b/r.
Then we do backup / restore and attempt to apply this stored package body again, see 'sql_pk_body'.
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
Confirmed bug on: 4.0.0.1766, 3.0.6.33247. Attempt to apply 'recreate package ...' with the same SQL code fails with:
Statement failed, SQLSTATE = 42000 / ... / -Procedure ... has a signature mismatch on package body ...
Bug was partially fixed in snapshots 4.0.0.1782 and 3.0.6.33252: problem remained if procedure parameter was of built-in
datatype rather than domain (i.e. this parameter type was TIMESTAMP or INT etc, instead of apropriate domain).
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
Completely fixed in snapshots 4.0.0.1783 and 3.0.6.33254 (checked 23.02.2020).
Added special check for parameter that is declared of built-in datatype rather than domain.
JIRA: CORE-6250
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
import pytest
from io import BytesIO
from pathlib import Path
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2021-12-14 20:56:34 +01:00
sql_pk_body = """
set term ^;
recreate package body pg_test1 as
begin
procedure sp_test1 ( a_since dm_dts ) as begin end
end
^
recreate package body pg_test2 as
begin
procedure sp_test2 ( a_since timestamp ) as begin end
end
^
set term ;^
"""
2021-04-26 20:07:00 +02:00
2021-12-14 20:56:34 +01:00
sql_init = f"""
create domain dm_dts timestamp;
commit;
set term ^;
create or alter package pg_test1 as
begin
procedure sp_test1 ( a_since dm_dts ) ;
end
^
create or alter package pg_test2 as
begin
procedure sp_test2 ( a_since timestamp ) ;
end
^
set term ;^
2021-04-26 20:07:00 +02:00
2021-12-14 20:56:34 +01:00
{sql_pk_body}
commit;
"""
fdb_restored = temp_file('tmp_6250_restored.fdb')
@pytest.mark.version('>=3.0.6')
2022-01-27 20:08:36 +01:00
def test_1(act: Action, fdb_restored: Path):
act.isql(switches=[], input=sql_init)
2021-12-14 20:56:34 +01:00
backup = BytesIO()
2022-01-27 20:08:36 +01:00
with act.connect_server() as srv:
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.reset()
act.isql(switches=['-q', act.get_dsn(fdb_restored)], input=sql_pk_body, connect_db=False)
assert act.clean_stdout == act.clean_expected_stdout