#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. # 31.08.2021: added substitution for ignore difference in BLR offset values. # # 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 substitutions_1 = [('RDB\\$[\\d]+', 'RDB'), ('.*at offset [\\d]+', 'at offset')] 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; """ 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 """ expected_stderr_1 = """ Statement failed, SQLSTATE = 42000 invalid request BLR at offset 47 -generator RDB is not defined """ @pytest.mark.version('>=4.0') def test_1(act_1: Action): act_1.expected_stdout = expected_stdout_1 act_1.expected_stderr = expected_stderr_1 act_1.execute() assert act_1.clean_stderr == act_1.clean_expected_stderr assert act_1.clean_stdout == act_1.clean_expected_stdout