2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
2022-01-22 21:59:15 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
ID: issue-3723
|
|
|
|
ISSUE: 3723
|
|
|
|
TITLE: Generators are set to 0 after restore
|
|
|
|
DESCRIPTION:
|
|
|
|
FB 4.x has incompatible behaviour with all previous versions since build 4.0.0.2131 (06-aug-2020):
|
|
|
|
statement 'alter sequence <seq_name> restart with 0' changes rdb$generators.rdb$initial_value to -1 thus
|
|
|
|
next call of gen_id(<seq_name>,1) will return 0 (ZERO!) rather than 1.
|
|
|
|
See also CORE-6084 and its fix: https://github.com/FirebirdSQL/firebird/commit/23dc0c6297825b2e9006f4d5a2c488702091033d
|
|
|
|
This is considered as *expected* and is noted in doc/README.incompatibilities.3to4.txt
|
|
|
|
JIRA: CORE-3357
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3357
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
import pytest
|
2021-11-17 19:43:06 +01:00
|
|
|
from io import BytesIO
|
2022-01-22 21:59:15 +01:00
|
|
|
from firebird.qa import *
|
2021-11-17 19:43:06 +01:00
|
|
|
from firebird.driver import SrvRestoreFlag
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
init_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate sequence g1 start with 9223372036854775807 increment by -2147483647;
|
|
|
|
recreate sequence g2 start with -9223372036854775808 increment by 2147483647;
|
|
|
|
commit;
|
2021-11-17 19:43:06 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory(init=init_script)
|
2021-11-17 19:43:06 +01:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = python_act('db')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
# version: 3.0
|
2022-02-02 15:46:19 +01:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stdout_3 = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Generator G1, current value: 9223372036854775807, initial value: 9223372036854775807, increment: -2147483647
|
|
|
|
Generator G2, current value: -9223372036854775808, initial value: -9223372036854775808, increment: 2147483647
|
2021-11-17 19:43:06 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
# version: 4.0
|
2022-02-02 15:46:19 +01:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stdout_4 = """
|
2021-04-26 20:07:00 +02:00
|
|
|
Generator G1, current value: -9223372034707292162, initial value: 9223372036854775807, increment: -2147483647
|
|
|
|
Generator G2, current value: 9223372034707292161, initial value: -9223372036854775808, increment: 2147483647
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
@pytest.mark.version('>=3.0')
|
|
|
|
def test_1(act: Action):
|
|
|
|
with act.connect_server() as srv:
|
2021-11-17 19:43:06 +01:00
|
|
|
backup = BytesIO()
|
2022-01-22 21:59:15 +01:00
|
|
|
srv.database.local_backup(database=act.db.db_path, backup_stream=backup)
|
2021-11-17 19:43:06 +01:00
|
|
|
backup.seek(0)
|
2022-01-22 21:59:15 +01:00
|
|
|
srv.database.local_restore(backup_stream=backup, database=act.db.db_path,
|
2021-11-17 19:43:06 +01:00
|
|
|
flags=SrvRestoreFlag.REPLACE)
|
2022-01-22 21:59:15 +01:00
|
|
|
act.expected_stdout = expected_stdout_4 if act.is_version('>=4') else expected_stdout_3
|
|
|
|
act.isql(switches=[], input="show sequ g1; show sequ g2;")
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|