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

118 lines
2.9 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-4740
ISSUE: 4740
TITLE: Regression: Can not run ALTER TABLE DROP CONSTRAINT <FK_name> after recent changes in svn
DESCRIPTION: Added some extra DDL statements to be run within single Tx and then to be rollbacked.
JIRA: CORE-4418
FBTEST: bugs.core_4418
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 = [('COLL-VERSION=\\d{2,}.\\d{2,}', 'COLL-VERSION=111.222'),
('COLL-VERSION=\\d+\\.\\d+\\.\\d+\\.\\d+', 'COLL-VERSION=111.222')]
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table td(id int);
recreate table tm(id int);
commit;
set term ^;
execute block as
begin
begin
execute statement 'drop domain dm_ids';
when any do begin end
end
begin
execute statement 'drop domain dm_nums';
when any do begin end
end
begin
execute statement 'drop collation nums_coll';
when any do begin end
end
end
^set term ;^
commit;
create collation nums_coll for utf8 from unicode case insensitive 'NUMERIC-SORT=1';
commit;
create domain dm_nums as varchar(20) character set utf8 collate nums_coll;
commit;
create domain dm_ids as bigint;
commit;
recreate table tm(
id dm_ids,
nm dm_nums,
constraint tm_pk primary key(id)
);
recreate table td(
id dm_ids,
pid dm_ids,
nm dm_nums,
constraint td_pk primary key(id),
constraint td_fk foreign key(pid) references tm
);
set autoddl off;
commit;
alter table td drop constraint td_fk;
alter table td drop constraint td_pk;
alter table tm drop constraint tm_pk;
drop table td;
drop table tm;
drop domain dm_nums;
drop domain dm_ids;
drop collation nums_coll;
rollback;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(charset='UTF8', init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
show table tm;
show table td;
show domain dm_ids;
show domain dm_nums;
show collation nums_coll;
-- oel64: coll-version=49.192.5.41
-- winxp: coll-version=58.0.6.50
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script, substitutions=substitutions)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
ID (DM_IDS) BIGINT Not Null
NM (DM_NUMS) VARCHAR(20) CHARACTER SET UTF8 Nullable
COLLATE NUMS_COLL
CONSTRAINT TM_PK:
Primary key (ID)
ID (DM_IDS) BIGINT Not Null
PID (DM_IDS) BIGINT Nullable
NM (DM_NUMS) VARCHAR(20) CHARACTER SET UTF8 Nullable
COLLATE NUMS_COLL
CONSTRAINT TD_FK:
Foreign key (PID) References TM (ID)
CONSTRAINT TD_PK:
Primary key (ID)
DM_IDS BIGINT Nullable
DM_NUMS VARCHAR(20) CHARACTER SET UTF8 Nullable
COLLATE NUMS_COLL
2021-12-19 22:25:36 +01:00
NUMS_COLL, CHARACTER SET UTF8, FROM EXTERNAL ('UNICODE'), PAD SPACE, CASE INSENSITIVE, 'COLL-VERSION=153.88;NUMERIC-SORT=1'
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00