Skip to content

[CBRD-26256] Add SQL test cases for FK replication restriction in ha_repl#2492

Open
zionyun wants to merge 6 commits intoCUBRID:feature/add-replication-optionfrom
zionyun:cbrd-26256_sql
Open

[CBRD-26256] Add SQL test cases for FK replication restriction in ha_repl#2492
zionyun wants to merge 6 commits intoCUBRID:feature/add-replication-optionfrom
zionyun:cbrd-26256_sql

Conversation

@zionyun
Copy link
Copy Markdown
Contributor

@zionyun zionyun commented Feb 20, 2026

refer to http://jira.cubrid.org/browse/CBRD-26256

각 diff 파일은 ha_repl 테스트에서 master/slave 간 데이터 값 차이로 인해 생성된 파일입니다.
REPLICATION OFF로 설정된 테이블은 master에는 데이터가 있지만, slave에는 데이터가 없습니다. 이로 인해 차이가 발생하므로, diff 파일이 생성되는 것은 정상적인 동작입니다.
특히 Referenced table (REPLICATION OFF) <- FK table (REPLICATION OFF) 구조에서는 HA 모드에서 create table이 실패해야 하지만, 본 SQL 테스트는 ha_mode=no 상태(싱글 모드)에서 실행되므로 모든 테이블이 정상적으로 생성 및 수행됩니다.
(HA_repl 테스트에서는 해당 FK table이 생성되지 않으나, diff file에 error message가 발생하지는 않습니다. 이 부분은 ha shell 로 검증 추가하겠습니다 : https://github.com/CUBRID/cubrid-testcases-private/pull/1578)

HA_repl 테스트에서는 기존 sql문에 있는 select 문들에 대해서는 수행되지 않으며, 각 DML문 직후에 select로 master,slave 의 데이터를 각각 비교하는 형태로 테스트가 진행됩니다.
예시)

--test:

evaluate '1. CREATE TABLE with FK - REPLICATION OFF PRIMARY KEY, CHILD REPLICATION OFF';
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:
drop table if exists create_b1_tbl;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:
drop table if exists create_a1_tbl;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:

CREATE TABLE create_a1_tbl ( \
id INT NOT NULL DEFAULT 0 PRIMARY KEY, \
phone VARCHAR(10) \
)REPLICATION OFF;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:

CREATE TABLE create_b1_tbl ( \
id INT NOT NULL PRIMARY KEY, \
name VARCHAR (10) NOT NULL, \
CONSTRAINT fk_id FOREIGN KEY (id) REFERENCES create_a1_tbl (id) \
ON DELETE CASCADE ON UPDATE RESTRICT \
)REPLICATION OFF;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:

insert into create_a1_tbl values (1, '0101111222');
--check:
$HC_CHECK_FOR_DML

--test:
insert into create_a1_tbl values (2, '0103333444');
--check:
$HC_CHECK_FOR_DML

--test:
insert into create_b1_tbl values (1, 'alice');
--check:
$HC_CHECK_FOR_DML

--test:
insert into create_b1_tbl values (2, 'bob');
--check:
$HC_CHECK_FOR_DML

--test:


drop table if exists create_b1_tbl;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:
drop table if exists create_a1_tbl;
--check:
@HC_CHECK_FOR_EACH_STATEMENT
--test:

@bagus-kim
Copy link
Copy Markdown
Contributor

빠져있는 것 같은 시나리오 입니다. 맞다면 추가요청 드립니다.

--evaluate '5. ALTER REPLICATION then ADD FK - REPLICATION OFF → ON';
drop table if exists alter_b6_tbl;
drop table if exists alter_a6_tbl;

create table alter_a6_tbl (
id int not null primary key
) replication off;

create table alter_b6_tbl (
id int not null primary key
) replication off;

alter table alter_b6_tbl replication on;

-- Expected: ERROR in HA mode
alter table alter_b6_tbl add constraint foreign key(id) references alter_a6_tbl(id);

drop table if exists alter_b6_tbl;
drop table if exists alter_a6_tbl;

--evaluate '6. DROP FK then re-add - REPLICATION OFF parent, ON child';

drop table if exists alter_b7_tbl;
drop table if exists alter_a7_tbl;

create table alter_a7_tbl (
id int not null primary key
) replication off;

create table alter_b7_tbl (
id int not null primary key,
constraint fk_id foreign key(id) references alter_a7_tbl(id)
);

-- drop
alter table alter_b7_tbl drop constraint fk_id;

-- Expected: ERROR in HA mode
alter table alter_b7_tbl add constraint foreign key(id) references alter_a7_tbl(id);

drop table if exists alter_b7_tbl;
drop table if exists alter_a7_tbl;

Comment thread sql/_36_guava/cbrd_26096_ha_repl_constraint/cbrd_26258/cases/alter.sql Outdated
Comment thread sql/_36_guava/cbrd_26096_ha_repl_constraint/cbrd_26258/cases/option.sql Outdated
@zionyun
Copy link
Copy Markdown
Contributor Author

zionyun commented Feb 27, 2026

@bagus-kim 추가 요청주신 시나리오는 CBRD-26274, CBRD-26273 에 포함되어있는 시나리오여서 해당 이슈에서 작성하도록 하겠습니다.
http://jira.cubrid.org/browse/CBRD-26276 의 6. ALTER TABLE 동작 검증 파일 기준으로 작성할 예정입니다!

@zionyun zionyun requested a review from bagus-kim March 5, 2026 07:14
@zionyun zionyun requested a review from kwonhoil March 16, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants