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

93 lines
2.8 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4702
ISSUE: 4702
TITLE: ISQL truncates blob when reading an empty segment
DESCRIPTION:
JIRA: CORE-4380
FBTEST: bugs.core_4380
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-11-26 19:20:43 +01:00
import re
2022-01-23 20:41:55 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
set term ^;
create procedure sp_test_master(a_id int) returns(o_txt varchar(20)) as
begin
end
^
set term ;^
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(init=init_script)
2021-11-26 19:20:43 +01:00
2022-01-23 20:41:55 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PARAMETERS:
NUMBER NAME TYPE
0 A_ID INPUT
0 O_TXT OUTPUT
VARIABLES:
NUMBER NAME
BLR TO SOURCE MAPPING:
BLR OFFSET LINE COLUMN
VALUES: <OFFSET> <LINE> <COLUMN>
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action, capsys):
# NB: i'm not sure that this test properly reflects the trouble described in the ticket.
# At least on 3.0 Alpha 1, Alpha 2 and Beta 2 (31807) output is identical.
2021-11-26 19:20:43 +01:00
sql_script = """
set blob all;
set list on;
select rdb$debug_info from rdb$procedures;
2022-01-23 20:41:55 +01:00
"""
act.isql(switches=[], input=sql_script)
2021-11-26 19:20:43 +01:00
# RDB$DEBUG_INFO 1a:1e1
# Parameters:
# Number Name Type
# --------------------------------------------------
# 0 A_ID INPUT
# 0 O_TXT OUTPUT
#
# Variables:
# Number Name
# -------------------------------------------
# 0 O_TXT
#
# BLR to Source mapping:
# BLR offset Line Column
# --------------------------------
# 42 2 79
# ^ ^ ^
# | | |
# +-----------+----------+---- all of them can vary!
# Print content of log with filtering lines:we are interesting only for rows
# which contain words: {'Parameters', 'Number', 'Variables', 'BLR'}.
# For last line (with three numbers for offset, line and col) we just check
# matching of row to appropriate pattern.
# NB: we remove all exsessive spaces from printed lines.
pattern = re.compile("[\\s]+[0-9]+[\\s]+[0-9]+[\\s]+[0-9]+")
2022-01-23 20:41:55 +01:00
for line in act.stdout.splitlines():
2021-11-26 19:20:43 +01:00
line = line.upper()
if ('PARAMETER' in line or
'NUMBER' in line or
'INPUT' in line or
'OUTPUT' in line or
'VARIABLE' in line or
'BLR' in line):
print(' '.join(line.split()).upper())
if pattern.match(line):
print('VALUES: <OFFSET> <LINE> <COLUMN>')
# Test
2022-01-23 20:41:55 +01:00
act.reset()
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout