6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

Added/Updated tests\bugs\core_6280_test.py: re-implemented using ISQL-launch. Removed old commented code. Confirmed crash on 3.0.6.33283. No problem on 3.0.6.33285. Checked on 6.0.0.195, 5.0.0.1305, 4.0.5.3049.

This commit is contained in:
pavel-zotov 2023-12-29 08:59:37 +03:00
parent b05ba82808
commit 699b326682

View File

@ -2,27 +2,32 @@
""" """
ID: issue-6522 ID: issue-6522
ISSUE: 6522 ISSUE: https://github.com/FirebirdSQL/firebird/issues/6522
TITLE: MERGE statement loses parameters in WHEN (NOT) MATCHED clause that will never TITLE: MERGE statement loses parameters in WHEN (NOT) MATCHED clause that will never be matched, crashes server in some situations
be matched, crashes server in some situations
DESCRIPTION: DESCRIPTION:
Confirmed crash on WI-V3.0.5.33220, WI-T4.0.0.1871 - but only when run MERGE statements with parameters from Python. NO crash when run it from ISQL.
No crash on 4.0.0.1881, but message "No SQLDA for input values provided" will raise for any number of input parameters: 2 or 3.
NOTES: NOTES:
[14.12.2021] pcisar [14.12.2021] pcisar
It's impossible to reimplement it in the same way with new driver. It's impossible to reimplement it in the same way with new driver.
PROBLEM: PROBLEM:
Original test used two parameter values where 3 parameters are expected, but Original test used two parameter values where 3 parameters are expected, but
new driver does not even allow that as it checks number of values with number of new driver does not even allow that as it checks number of values with number of
parameters - returned by iMessageMetadata.get_count(). parameters - returned by iMessageMetadata.get_count().
ALSO, as new driver uses OO API, it does not use SQLDA structures at all. ALSO, as new driver uses OO API, it does not use SQLDA structures at all.
[29.12.2023] pzotov
Problem can be reproduced if we run MERGE using ISQL utility with 'set sqlda_display on'.
Example was provided by Mark:
https://github.com/FirebirdSQL/firebird/issues/6522#issuecomment-826246877
Confirmed crash on 3.0.6.33283 (date of build: 15.04.2020).
Checked on 3.0.6.33285 (16.04.2020) -- all fine.
Checked on 6.0.0.195, 5.0.0.1305, 4.0.5.3049.
JIRA: CORE-6280 JIRA: CORE-6280
FBTEST: bugs.core_6280 FBTEST: bugs.core_6280
""" """
import pytest import pytest
from firebird.qa import * from firebird.qa import *
from firebird.driver import DatabaseError
init_script = """ init_script = """
recreate table t(i int not null primary key, j int); recreate table t(i int not null primary key, j int);
@ -30,65 +35,30 @@ init_script = """
db = db_factory(init=init_script) db = db_factory(init=init_script)
act = python_act('db') test_script = """
set sqlda_display on;
merge into t using (select 1 x from rdb$database) on 1 = 1
when matched then update set j = ?
when matched and i = ? then delete
when not matched then insert (i, j) values (1, ?);
expected_stdout = """
Error while executing SQL statement:
- SQLCODE: -902
- Dynamic SQL Error
- SQLDA error
- No SQLDA for input values provided
""" """
@pytest.mark.skip("FIXME: see notes") act = isql_act('db', test_script, substitutions=[('^((?!sqltype:|SQLSTATE|[Ee]rror|SQLDA).)*$', ''), ('[ \t]+', ' ')])
expected_stdout = """
01: sqltype: 496 LONG Nullable scale: 0 subtype: 0 len: 4
02: sqltype: 496 LONG Nullable scale: 0 subtype: 0 len: 4
03: sqltype: 496 LONG Nullable scale: 0 subtype: 0 len: 4
Statement failed, SQLSTATE = 07002
Dynamic SQL Error
-SQLDA error
-No SQLDA for input values provided
"""
@pytest.mark.version('>=3.0.6') @pytest.mark.version('>=3.0.6')
def test_1(act: Action): def test_1(act: Action):
with act.db.connect() as con: act.expected_stdout = expected_stdout
c = con.cursor() act.execute(combine_output = True)
cmd = """ assert act.clean_stdout == act.clean_expected_stdout
merge into t
using (select 1 x from rdb$database) on 1 = 1
when matched then
update set j = ?
when matched and i = ? then
delete
when not matched then
insert (i, j) values (1, ?)
"""
# PROBLEM:
# Original test used two parameter values where 3 parameters are expected, but
# new driver does not even allow that as it checks number of values with number of
# parameters - returned by iMessageMetadata.get_count().
# ALSO, as new driver uses OO API, it does not use SQLDA structures at all.
#with pytest.raises(DatabaseError):
#c.execute(cmd, [1, 2])
# Next passes ok on v4.0.0.2496, but does it really tests the original issue?
c.execute(cmd, [1, 2, 3])
# test_script_1
#---
#
# cur=db_conn.cursor()
# stm='''
# merge into t
# using (select 1 x from rdb$database) on 1 = 1
# when matched then
# update set j = ?
# when matched and i = ? then
# delete
# when not matched then
# insert (i, j) values (1, ?)
# '''
#
# try:
# cur.execute( stm ) (1,2,)
# # cur.execute( stm ) (1,2,3,) -- also leads to "No SQLDA for input values provided"
# except Exception as e:
# print(e[0])
# finally:
# cur.close()
# db_conn.close()
#
#
#---