2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
"""
|
|
|
|
ID: issue-5073
|
|
|
|
ISSUE: 5073
|
|
|
|
TITLE: Table aliasing is unnecessary required when doing UPDATE ... RETURNING RDB$ pseudo-columns
|
|
|
|
DESCRIPTION:
|
|
|
|
NOTES:
|
|
|
|
After fix #6815 execution plan contains 'Local_Table' (FB 5.0+) for DML with RETURNING clauses:
|
|
|
|
"When such a statement is executed, Firebird should execute the statement to completion
|
|
|
|
and collect all requested data in a type of temporary table, once execution is complete,
|
|
|
|
fetches are done against this temporary table"
|
|
|
|
JIRA: CORE-4774
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_4774
|
2022-01-24 20:27:02 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table t(id int, x int);
|
|
|
|
commit;
|
|
|
|
insert into t values(1, 100);
|
|
|
|
commit;
|
|
|
|
set planonly;
|
|
|
|
insert into t(id, x) values(2, 200) returning rdb$db_key;
|
|
|
|
delete from t where id=1 returning rdb$db_key;
|
|
|
|
update t set x=-x where id=2 returning rdb$db_key;
|
2022-01-24 20:27:02 +01:00
|
|
|
update t set x=-x where id=2 returning rdb$record_version;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
act = isql_act('db', test_script)
|
|
|
|
|
|
|
|
# version: 3.0
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|
|
|
PLAN (T NATURAL)
|
|
|
|
PLAN (T NATURAL)
|
|
|
|
PLAN (T NATURAL)
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
@pytest.mark.version('>=3.0,<5.0')
|
2022-01-24 20:27:02 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout_1
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
# version: 5.0
|
|
|
|
|
|
|
|
expected_stdout_2 = """
|
|
|
|
PLAN (T NATURAL)
|
|
|
|
PLAN (Local_Table NATURAL)
|
|
|
|
|
|
|
|
PLAN (T NATURAL)
|
|
|
|
PLAN (Local_Table NATURAL)
|
|
|
|
|
|
|
|
PLAN (T NATURAL)
|
|
|
|
PLAN (Local_Table NATURAL)
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=5.0')
|
2022-01-24 20:27:02 +01:00
|
|
|
def test_2(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout_2
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-12-30 19:43:52 +01:00
|
|
|
|