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

75 lines
1.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-3274
ISSUE: 3274
TITLE: SQLSTATE should also be available as a PSQL context variable like GDSCODE/SQLCODE
DESCRIPTION:
JIRA: CORE-2890
FBTEST: bugs.core_2890
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory(from_backup='core2890.fbk')
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
commit;
set transaction no wait;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
update test set id = -id where id = 2;
set list on;
set term ^;
execute block returns(res_sqlcode int, res_gdscode int, res_sqlstate char(5)) as
begin
for
select res_sqlcode, res_gdscode, res_sqlstate
from sp_test('I')
into res_sqlcode, res_gdscode, res_sqlstate
do
suspend;
-------------------------------------
for
select res_sqlcode, res_gdscode, res_sqlstate
from sp_test('D')
into res_sqlcode, res_gdscode, res_sqlstate
do
suspend;
-------------------------------------
for
select res_sqlcode, res_gdscode, res_sqlstate
from sp_test('U')
into res_sqlcode, res_gdscode, res_sqlstate
do
suspend;
end
^
set term ;^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RES_SQLCODE -803
RES_GDSCODE 335544665
RES_SQLSTATE 23000
RES_SQLCODE -913
RES_GDSCODE 335544336
RES_SQLSTATE 40001
RES_SQLCODE -802
RES_GDSCODE 335544321
RES_SQLSTATE 22012
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-21 18:49:26 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00