2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
|
|
|
ID: issue-57063
|
|
|
|
ISSUE: 57063
|
|
|
|
TITLE: Support for DROP IDENTITY clause
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-5431
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
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
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
act = isql_act('db', test_script, substitutions=[('RDB\\$[\\d]+', 'RDB'),
|
|
|
|
('.*at offset [\\d]+', 'at offset')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
IDENTITY_SEQUENCES_COUNT_1 1
|
|
|
|
TEST1_ID 32767
|
|
|
|
IDENTITY_SEQUENCES_COUNT_2 0
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2022-01-25 22:55:48 +01:00
|
|
|
|
|
|
|
expected_stderr = """
|
2021-04-26 20:07:00 +02:00
|
|
|
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')
|
2022-01-25 22:55:48 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.expected_stderr = expected_stderr
|
|
|
|
act.execute()
|
|
|
|
assert (act.clean_stderr == act.clean_expected_stderr and
|
|
|
|
act.clean_stdout == act.clean_expected_stdout)
|
2021-04-26 20:07:00 +02:00
|
|
|
|