Repository navigation
migrate: run a CREATE TABLE ... PARTITION OF as the online create of a partition - #684
Conversation
First step of creating a partition online: the run creates the table standalone and attaches it with the online attach, which needs the CREATE's own bound as an ATTACH statement.
CREATE TABLE ... PARTITION OF takes ACCESS EXCLUSIVE on the parent; creating the table with LIKE and running the online attach reaches the same partition while the tree keeps serving reads and writes.
…a partition The imperative door refused every CREATE TABLE and pointed at the declarative door, which refuses PARTITION OF too, so adding a partition had no route through pg-sprite.
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 of 53609c5: 0 blocking, 6 non-blocking. (1/2: correctness, 4 of the 6. 2/2 covers adoption and integration ease, the other 2.) I read the PR at 53609c5 against the base it builds on (the Invariants
Findings (all non-blocking)F1. A refused
|
| Mutant | Caught by |
|---|---|
gateCreatePartition stops admitting a bare partition (return ..., false, ok && false) |
TestGate ("a bare create of a partition passes") |
gateCreatePartition returns the shape refusal with refused=false (a DEFAULT-bound create passes the gate) |
TestGate ("a create of a DEFAULT partition is a capability boundary") |
internal/cli/dryrun.go no longer diverts a CREATE TABLE to CreatePartitionDryRunVerdict (... && false) |
TestDryRunRefusesTheOnlineCreateOfAPartition |
rejectCreatePartitionAcks drops the AllowDestructive case |
not caught by any test in the PR; caught only by the probe test in F2 |
CI at the head: all 18 checks are green (lint, build, unit tests, PostgreSQL 14 to 18 matrix, Supabase compatibility, smoke test, DCO). I did not rerun anything.
This review was generated by Claude Code (claude-sonnet-5-5).
|
🤖 Review of 53609c5: 0 blocking, 6 non-blocking. (2/2: OSS adoption and integration ease for SchemaBot and other importers. 1/2 covers correctness: 4 of the 6.) An importer of A1. The dry run refuses a statement the run would execute, in the same class as a real refusal
This is a deliberate, documented limit, so I am not asking for the plan to be built here. Two cheap options: say in A2. The integration guide covers the online attach but not the online createAn embedder reads
A short subsection next to the attach outcomes, or one sentence in each of those two places, would let SchemaBot map the new route without reading the source. Nothing here blocks the merge. 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).
|
🤖 Reviewed the complete diff at [P1] Preserve the creation schema for an unqualified partition name. In The separate dry-run capability refusal, default-bound shape refusal, and reuse of the online attach verdict are consistent with the intended staged rollout. The exact-head GitHub checks were green when I reviewed. This was a static review without local test execution or independent enumeration of inline review threads. |
PostgreSQL creates an unqualified CREATE TABLE in the session's first search_path schema, which need not be the parent's schema the route used. --accept-blocking is now refused like every other acknowledgement, and a refused PARTITION OF no longer points at diff --desired.
|
🤖 Adversarial review response — created by Kiran's code review agent (Amp, claude-opus-5-5) — pull/684, follow-up commit The blocker is fixed: an unqualified partition name is now refused at the gate. Five of the seven findings are fixed in full, and the other two are fixed in part. The dry-run plan and the refusal-order tests are a follow-up.
No action: both reviews' invariant tables and "Verified" sections, whose mutants are caught as reported. Source: block/pg-sprite#684, review comments 7324745413, 7324748166 and 7325273698, and reviews 6139537008 and 6139885526 at head |
migrate --alternow runs a bare, schema-qualifiedCREATE TABLE schema.name PARTITION OF schema.parent FOR VALUES …as the online create of a partition, instead of refusing it.Why
Adding a partition (next month's, next year's) is the most routine change on a partitioned table, and the plain statement locks the whole partitioned table exclusively, so it waits behind every running query and stalls every query that arrives after it. Until now pg-sprite had no way to run it at all:
migrate --alterrefused everyCREATE TABLEand pointed at the desired-file front door, which refusesPARTITION OFtoo. This PR gives the statement a route that never locks the parent against reads or writes.What
CREATE TABLE schema.name PARTITION OF … FOR VALUES …through. ADEFAULTbound, an unqualified partition name, or any clause beside the bound (column list, constraints,IF NOT EXISTS,UNLOGGED,WITH,TABLESPACE,USING,PARTITION BY) is now refused as acapability-boundarythat names the cause, with no pointer at the declarative door, which refuses it too. An unqualified name is refused because PostgreSQL creates it in the first schema of the session'ssearch_path, which need not be the schema pg-sprite would use. Every otherCREATE TABLEkeeps its refusal.migrate.Runsends it toexecutor.CreatePartitionOnline(previous PR): create the table withLIKEthe parent, then the online attach with the statement's own bound.CREATEon the new table's schema.tableis the partitioned parent, as the online attach's is;statementis the submittedCREATE.DEFAULTpartition, and an unprovable bound are refused before anything is created; any later stop leaves what was made and a rerun resumes.--force,--accept-blocking,--restart,--block-writes,--allow-destructive) is a usage error (ErrCreatePartitionAcknowledgement): there is no blocking form to force or accept.--dry-runrefuses the statement as acapability-boundarywithout planning it. Planning it, with its own execution in the plan report, is the next PR.create-table-partition-ofcapability row moves to ✅gaformigrate(the desired-file door still refuses it), with a representative statement in the front-door claims test;limitations.mdgets a row for the shapes still refused, andschemabot-integration.mdsays what a host sees: the verdict's table, the connection it needs, the acknowledgement error, and the dry run's refusal. No README bullet covers this.Before / after
The same statement, submitted while a report query is reading the parent:
The same statement with an unqualified name (
CREATE TABLE events_2027 PARTITION OF app.events …) is refused at the gate before a connection is used: qualify it with the schema it belongs in.