adding-foreign-key-constraint shouldn't warn if the constraint and tables are created in the same transaction

Open
#973 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
postgresql, rust, sql

Research direction

Start by reproducing the reported transaction with the example SQL, then locate the rule that emits the foreign-key warning and inspect the existing concurrent-index handling for analogous behavior. Done means the same-transaction table and constraint creation no longer warns, while foreign-key creation involving existing tables still does; add a regression test for both cases.

Written by the indexing model from the issue text.

Description

enhancement

require-concurrent-index-creation won't trigger if the index and table are created in the same transaction, since the table will be empty and unused at the time the lock is needed. I think foreign key constraint creation should have similar behavior.

This triggers the warning currently:

BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS dbo.table1 (id bigint);
CREATE TABLE IF NOT EXISTS dbo.table2 (table1_id bigint references dbo.table1(id));
END TRANSACTION;
Dominant language
Rust
Stars
1.2k
Forks
70
Avg merge
52m
Merged PRs (30d)
47

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sbdchd/squawk

All issues in sbdchd/squawk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.