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

142 lines
4.2 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-27 20:08:36 +01:00
"""
ID: issue-6483
ISSUE: https://github.com/FirebirdSQL/firebird/issues/6483
2022-01-27 20:08:36 +01:00
TITLE: Procedures and EXECUTE BLOCK without RETURNS should not be allowed to use SUSPEND
DESCRIPTION:
JIRA: CORE-6239
FBTEST: bugs.core_6239
NOTES:
Fix was done by commit https://github.com/FirebirdSQL/firebird/commit/b2b5f9a87cea26a9f12fa231804dba9d0426d3fa
(can be checked by 4.0.0.1763+, date of build since 05-feb-2020).
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
import pytest
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
test_script = """
2021-04-26 20:07:00 +02:00
-- these two collations and domain not needed for TEST per se.
-- We create them here only for reference in declaration of SP input params, see below:
create collation nums_coll for utf8 from unicode case insensitive 'NUMERIC-SORT=1';
create collation name_coll for utf8 from unicode no pad case insensitive accent insensitive;
create domain dm_test varchar(20) character set utf8 default 'foo' not null collate nums_coll;
commit;
2022-01-27 20:08:36 +01:00
-- All following statements should be declined with
2021-04-26 20:07:00 +02:00
-- Statement failed, SQLSTATE = 42000
-- Dynamic SQL Error
-- -SQL error code = -104
-- -SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
set term ^ ;
execute block as
begin
suspend;
end
^
execute block (a_x int not null = ?) as
begin
suspend;
end
^
create or alter procedure sp_missed_returns_in_its_header_1 as
begin
-- we use SUSPEND clause but there is no
-- output parameters in this SP header:
suspend;
end
^
create or alter procedure sp_missed_returns_in_its_header_2 (a_x varchar(10) not null) as
begin
suspend;
end
^
create or alter procedure sp_missed_returns_in_its_header_3 (p1 varchar(20) character set utf8 not null collate nums_coll default 'foo') SQL SECURITY DEFINER as
begin
suspend;
end
^
recreate package pg_test_1 as
begin
procedure pg_proc(
p1 varchar(20) character set utf8 not null collate nums_coll default 'foo'
,p2 dm_test default 'qwe'
,p3 dm_test default 'bar'
,p4 dm_test collate name_coll default 'rio'
);
end
^
create package body pg_test_1 as
begin
procedure pg_proc(
p1 varchar(20) character set utf8 not null collate nums_coll
,p2 dm_test
,p3 dm_test
,p4 dm_test collate name_coll
) as
begin
suspend;
end
end
^
set term ;^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE OR ALTER PROCEDURE SP_MISSED_RETURNS_IN_ITS_HEADER_1 failed
-Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE OR ALTER PROCEDURE SP_MISSED_RETURNS_IN_ITS_HEADER_2 failed
-Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE OR ALTER PROCEDURE SP_MISSED_RETURNS_IN_ITS_HEADER_3 failed
-Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-CREATE PACKAGE BODY PG_TEST_1 failed
-Dynamic SQL Error
-SQL error code = -104
-SUSPEND could not be used without RETURNS clause in PROCEDURE or EXECUTE BLOCK
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-27 20:08:36 +01:00
def test_1(act: Action):
act.expected_stderr = expected_stderr
act.execute()
assert act.clean_stderr == act.clean_expected_stderr