[CBRD-26490] Add function to set referential_index for self-referencing FK#6825
Open
kangmin5505 wants to merge 2 commits intoCUBRID:developfrom
Open
[CBRD-26490] Add function to set referential_index for self-referencing FK#6825kangmin5505 wants to merge 2 commits intoCUBRID:developfrom
kangmin5505 wants to merge 2 commits intoCUBRID:developfrom
Conversation
Contributor
Author
|
/run all |
1 similar comment
Contributor
Author
|
/run all |
There was a problem hiding this comment.
Pull request overview
This pull request implements support for setting the referential_index column in _db_index for self-referencing foreign keys. Previously, this was excluded from the implementation because the logic ran before the class and its primary key were created. The solution is to move the logic from smt_check_foreign_key() (which runs before class creation) to allocate_foreign_key() (which runs after class and PK information is available).
Changes:
- Moved logic for setting
index_catalog_of_ref_classfromsmt_check_foreign_key()toallocate_foreign_key() - Renamed
find_index_catalog_class()tofind_index_catalog()and relocated it fromschema_template.ctoschema_manager.c - Removed unused variable
ref_cls_namefromsmt_check_foreign_key()
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/object/schema_template.c | Removed logic for setting index_catalog_of_ref_class, removed find_index_catalog_class() function, and cleaned up unused variable ref_cls_name |
| src/object/schema_manager.c | Added find_index_catalog() function and new logic in allocate_foreign_key() to set index_catalog_of_ref_class for both self-referencing and regular foreign keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
beyondykk9
approved these changes
Feb 6, 2026
Contributor
Author
|
실패한 sql 1 건은 PR 요청 완료하였습니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
http://jira.cubrid.org/browse/CBRD-26490
Purpose
_db_index의 referencial_index 컬럼 추가 시 self referencing은 제외하고 구현이 되었기 때문에 이를 구현합니다.
기존에 추가하지 못 했던 이유는 지금 구조에서는 referencial_index 컬럼에 참조하는 _db_index를 넣으려면 해당하는 _db_index가 존재해야 하는데, self referencing의 경우는 아직 자기 자신이 생성되지 않은 상태였기 때문입니다.
Implementation
기존에 CREATE TABLE 구문과 함께 생성된 self-referencing FK의 경우 index_catalog_of_ref_class(foreign key가 참조하는 PK의 _db_index 레코드)를 생성할 수 없었던 이유는 해당 로직을 smt_check_foreign_key()에서 처리하고 있었기 때문입니다. smt_check_foreign_key()는 do_create_local() 함수 내에서 호출되는데, do_create_local()은 아직 클래스를 생성하기 전입니다.
따라서 이 로직을 클래스와 PK 관련한 정보가 모두 생성된 이후인 allocate_foreign_key()로 이전하였습니다. 참고로 allocate_foreign_key()는 FK를 생성하고 참조하고 있는 클래스에 해당 정보를 추가하는 함수입니다.
Remarks
find_index_catalog_class()->find_index_catalog()smt_check_foreign_key ()에서 사용하지 않는 변수 제거