2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
#
|
|
|
|
# id: bugs.core_5431
|
|
|
|
# title: Support for DROP IDENTITY clause
|
|
|
|
# decription:
|
|
|
|
# Checked on 4.0.0.477
|
|
|
|
# 18.08.2020: replaced expected_stdout, checked on 4.0.0.2164.
|
2021-12-30 19:43:52 +01:00
|
|
|
# 31.08.2021: added substitution for ignore difference in BLR offset values.
|
2021-04-26 20:07:00 +02:00
|
|
|
#
|
|
|
|
# tracker_id: CORE-5431
|
|
|
|
# min_versions: ['4.0']
|
|
|
|
# versions: 4.0
|
|
|
|
# qmid: None
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from firebird.qa import db_factory, isql_act, Action
|
|
|
|
|
|
|
|
# version: 4.0
|
|
|
|
# resources: None
|
|
|
|
|
2021-12-30 19:43:52 +01:00
|
|
|
substitutions_1 = [('RDB\\$[\\d]+', 'RDB'), ('.*at offset [\\d]+', 'at offset')]
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
init_script_1 = """"""
|
|
|
|
|
|
|
|
db_1 = db_factory(sql_dialect=3, init=init_script_1)
|
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
set list on;
|
|
|
|
--set echo on;
|
|
|
|
|
|
|
|
recreate table test1(
|
|
|
|
id smallint generated by default as identity ( start with 32767 increment -65535 )
|
|
|
|
);
|
|
|
|
|
|
|
|
commit;
|
|
|
|
|
|
|
|
-- Should be 1:
|
|
|
|
select count(*) as identity_sequences_count_1
|
|
|
|
from rdb$generators
|
|
|
|
where rdb$system_flag = 6;
|
|
|
|
|
|
|
|
insert into test1 default values returning id as test1_id;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
alter table test1 alter column id drop identity;
|
|
|
|
commit;
|
|
|
|
|
|
|
|
-- Should be 0:
|
|
|
|
select count(*) as identity_sequences_count_2
|
|
|
|
from rdb$generators
|
|
|
|
where rdb$system_flag = 6;
|
|
|
|
|
|
|
|
-- Should issue
|
|
|
|
-- Statement failed, SQLSTATE = 42000
|
|
|
|
-- invalid request BLR at offset 47
|
|
|
|
-- -generator RDB$nnn is not defined
|
|
|
|
insert into test1 default values returning id as test1_id;
|
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
|
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|
|
|
IDENTITY_SEQUENCES_COUNT_1 1
|
|
|
|
TEST1_ID 32767
|
|
|
|
IDENTITY_SEQUENCES_COUNT_2 0
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
expected_stderr_1 = """
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
invalid request BLR at offset 47
|
|
|
|
-generator RDB is not defined
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_1(act_1: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
act_1.expected_stdout = expected_stdout_1
|
|
|
|
act_1.expected_stderr = expected_stderr_1
|
|
|
|
act_1.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_1.clean_stderr == act_1.clean_expected_stderr
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
assert act_1.clean_stdout == act_1.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|