Repository navigation
Conversation
REFERENCES accounts with no column list was refused before anything ran, though an ordinary ADD FOREIGN KEY takes the referenced primary key.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🤖 Review 1/2 (correctness) of 971bab4: 0 blocking, 4 non-blocking. Inspected the whole change at What the change does: a
Invariants ( Consistency with #702 (sub-partitioned partitions): the two compose. #702's sub-partitioned step copies Non-blocking
Test case (not run here: it needs a live PostgreSQL): the admission refuses a referenced table with no primary key// With no referenced column list the foreign key references the primary key,
// so the catalog admission a dry run and a desired plan read refuses a
// referenced table without one, as the build does.
func TestAdmitPartitionedForeignKeyRefusesAReferencedTableWithoutAPrimaryKey(t *testing.T) {
withPartitionedFKServer(t, func(t *testing.T, newFixture func(t *testing.T) partitionedFKFixture) {
f := newFixture(t)
f.exec(t, `
CREATE TABLE %[1]s.accounts (id bigint NOT NULL UNIQUE);
CREATE TABLE %[1]s.events (
id bigint NOT NULL,
account_id bigint,
created_at timestamptz NOT NULL
) PARTITION BY RANGE (created_at);
CREATE TABLE %[1]s.events_2026_01 PARTITION OF %[1]s.events
FOR VALUES FROM ('2026-01-01') TO ('2026-02-01')`)
err := AdmitPartitionedForeignKey(t.Context(), f.pool, fmt.Sprintf(`
ALTER TABLE %[1]s.events
ADD CONSTRAINT events_account_fk
FOREIGN KEY (account_id) REFERENCES %[1]s.accounts`, f.schema))
require.ErrorIs(t, err, ErrPartitionedForeignKeyUnsupportedShape)
})
}A second case with
Verified
This review was generated by Claude Code (claude-sonnet-5-5). |
|
🤖 Review 2/2 (OSS adoption and integration) of 971bab4: 0 blocking, 2 non-blocking. Read the change from two seats: a user of Non-blocking
What reads well for adopters
This review was generated by Claude Code (claude-sonnet-5-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Stamping with comments: 0 blocking, 6 non-blocking (see the review comments above).
This stamp was left by Claude Code (claude-sonnet-5-5).
A foreign key added to a partitioned table that writes
REFERENCES accountswithout listing columns now runs online, using the referenced table's primary key, as PostgreSQL does.Why
pg-sprite adds a foreign key to a partitioned table one partition at a time, so writes keep flowing. In PostgreSQL,
REFERENCES accountswith no column list means "accounts' primary key", and it is a common way to write a foreign key. pg-sprite refused that form outright, so the user had to rewrite the statement with the columns spelled out before it would run.What
pkg/executor/partitioned_fk_reference.go:resolveFKTargetreads the referenced table's primary key columns, in key order, when the statement names none, and writes them into the spec. Every partition's statement and the parent's then name them.partitioned-foreign-key-unsupported-shapebefore any partition is touched.mainand already covered: anON DELETE SET NULL (cols)column list (runs on 15+, refused typed on 14), and foreign-table or sub-partitioned partitions (refused typed before any step). A build-level test for the foreign-table refusal was added.partitioned-foreign-key-design.md,execution-model.md,schemabot-integration.md,refusal-classes.md.(region, id)over columns created(id, region)both run online, and a rerun finds the work done.migrate.Runexecutes the statement.Before / after
cardsis partitioned;accountshasPRIMARY KEY (id).