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

86 lines
2.3 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4704
ISSUE: 4704
TITLE: User savepoints are not released on commit
DESCRIPTION:
Added separate code for 4.0: one need to be sure that all changes have been flushed on disk before we launch gstat.
See letter from hvlad, 02.02.2019 22:30.
::: NOTE :::
!! It looks strange but if we put preparing statement in 'init_script' section than result of 'gstat -i' will be WRONG,
even if we do db_conn.close() before runProgram('gstat' ...) !!
JIRA: CORE-4382
FBTEST: bugs.core_4382
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
substitutions = [('^((?!nodes).)*$', ''), ('Root page: [0-9]+,', ''), ('Depth', 'depth')]
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-12-31 12:06:51 +01:00
create table g_test (f integer);
create index g_ind on g_test (f);
insert into g_test values (1);
commit;
update g_test set f=2;
savepoint a;
update g_test set f=3;
savepoint b;
update g_test set f=4;
savepoint c;
update g_test set f=5;
savepoint d;
update g_test set f=6;
savepoint e;
update g_test set f=7;
commit;
select * from g_test;
COMMIT;
-- Confirmed result of "gstat -i"
-- 1) for 3.0 Alpha1 & Alpha2:
-- Root page: 203, depth: 1, leaf buckets: 1, nodes: 6
-- ^- orphans, must be: 1
-- 2) for 2.5.3:
-- Depth: 1, leaf buckets: 1, nodes: 6
-- ^- upper case! ^- orphans, must be: 1
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
# version: 3.0
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db_1 = db_factory(init=init_script)
2021-12-31 12:06:51 +01:00
2022-01-23 20:41:55 +01:00
act_1 = python_act('db_1', substitutions=substitutions)
2021-12-31 12:06:51 +01:00
expected_stdout_1 = """
2022-01-14 14:53:16 +01:00
Root page: 203, depth: 1, leaf buckets: 1, nodes: 1
2021-12-31 12:06:51 +01:00
"""
2022-01-23 20:41:55 +01:00
@pytest.mark.version('>=3,<4.0')
2021-12-31 12:06:51 +01:00
def test_1(act_1: Action):
act_1.expected_stdout = expected_stdout_1
act_1.gstat(switches=['-i'])
assert act_1.clean_stdout == act_1.clean_expected_stdout
# version: 4.0
2022-01-23 20:41:55 +01:00
db_2 = db_factory()
act_2 = python_act('db_2', substitutions=substitutions)
2021-04-26 20:07:00 +02:00
2021-12-31 12:06:51 +01:00
expected_stdout_2 = """
2022-02-07 18:03:19 +01:00
Root page: 203, depth: 1, leaf buckets: 1, nodes: 2
2021-11-26 19:20:43 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2021-12-31 12:06:51 +01:00
def test_2(act_2: Action):
2022-01-23 20:41:55 +01:00
act_2.isql(switches=['-q'], input=init_script)
2021-12-31 12:06:51 +01:00
act_2.reset()
act_2.expected_stdout = expected_stdout_2
act_2.gstat(switches=['-i'])
assert act_2.clean_stdout == act_2.clean_expected_stdout
2021-04-26 20:07:00 +02:00