Repository navigation
Conversation
A lone ATTACH PARTITION ... FOR VALUES from migrate --alter now runs as executor.AttachPartitionOnline instead of ending rewrite-required, and its dry run plans it with the new online-attach execution (plan format 39). A parent with a DEFAULT partition is refused for now; --force keeps running the blocking ATTACH as written.
Main took plan format_version 42 for catalog_only_steps, so the online-attach contract moves to 43, with the doc examples and pins.
Adds unit tests for the attach's routing, fingerprint and refusal classes, and documents what its dry run and DEFAULT-window refusal do.
…AULT partition The online attach refused any parent with a DEFAULT partition, since its exclusion proof refuses writes there inside the new bound until the attach commits. A typed acknowledgement naming the parent now accepts that window; without it the refusal stays, now by design and naming the flag.
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. |
Main carries #605 as a squash, so the online attach files take main's copy with this branch's DEFAULT-partition change on top.
|
🤖 Review 1/2 (correctness) of 1aa637a: 0 blocking, 3 non-blocking. Inspected the whole change at The question for a change that widens an acknowledgement is whether the new path opens only for the person who typed it, and whether what it accepts is exactly what the text says. Both hold up on a read:
Invariants ( Non-blocking
Test case: the acknowledgement names the parent exactly, and Force beside the window is a usage errorfunc TestAcceptDefaultWriteWindowAckNamesTheParentExactly(t *testing.T) {
st, err := statement.ParseOne(`ALTER TABLE app.orders ATTACH PARTITION app.orders_2027 FOR VALUES FROM ('2027-01-01') TO ('2028-01-01')`)
require.NoError(t, err)
require.NoError(t, checkAcceptDefaultWriteWindowAck(st, "app.orders"))
for _, given := range []string{"app.orders_2027", "orders", "APP.ORDERS", "app.orders ", `"app"."orders"`, "other.orders"} {
err := checkAcceptDefaultWriteWindowAck(st, given)
require.ErrorIs(t, err, ErrAcceptDefaultWriteWindowMismatch, given)
mismatch, ok := err.(*AcknowledgementMismatchError)
require.True(t, ok, given)
assert.Equal(t, "app.orders", mismatch.Table)
assert.Equal(t, given, mismatch.Given)
}
}
func TestOptionsRefuseForceBesideTheDefaultWindowAcknowledgement(t *testing.T) {
opts := DefaultOptions()
opts.Force = "app.orders"
opts.AcceptDefaultWriteWindow = "app.orders"
err := opts.validate()
require.Error(t, err)
assert.Contains(t, err.Error(), "Options.AcceptDefaultWriteWindow")
opts.Force = ""
require.NoError(t, opts.validate())
}Both pass on Verified
This review was generated by Claude Code (claude-sonnet-5-5). |
|
🤖 Review 2/2 (OSS adoption and integration) of 1aa637a: 0 blocking, 2 non-blocking. Read the change from two seats: an importer that embeds Non-blocking
Test case: the dry-run note for an online attach names the DEFAULT partition windowfunc TestDryRunTextOnlineAttachNamesTheDefaultPartitionWindow(t *testing.T) {
report := plan.NewReport(plan.SourceAlter)
report.Schema, report.Table, report.ServerVersion = "app", "orders", "16.10"
report.Disposition = router.DispositionExecute
sql := `ALTER TABLE "app"."orders" ATTACH PARTITION "app"."orders_2027" FOR VALUES FROM ('2027-01-01') TO ('2028-01-01')`
report.Statements = append(report.Statements, plan.Statement{
SQL: sql,
Route: planner.RouteNative,
Backend: router.BackendNative,
Disposition: router.DispositionExecute,
ExecSQL: []string{sql},
Execution: planner.ExecutionOnlineAttach,
})
var out strings.Builder
require.NoError(t, writeDryRunText(&out, palette{}, report))
flat := strings.Join(strings.Fields(out.String()), " ")
assert.Contains(t, flat, "will attach the table online")
assert.Contains(t, flat, "DEFAULT partition")
assert.Contains(t, flat, "--accept-default-write-window")
}The first assertion passes on
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.
🤖 First-pass review of 1aa637a: 0 blocking, 5 non-blocking (3 in the correctness review, 2 in the OSS adoption review, both posted as PR comments). The new path opens only with the typed acknowledgement, the accepted window is the documented one, and without the flag the plan still refuses.
This review was generated by Claude Code (claude-sonnet-5-5).
The dry run planned an online attach beside a DEFAULT partition as executing, so a CI gate on it passed an attach the run refuses. It now makes the attach's own catalog checks and takes --accept-default-write-window.
docs/capabilities.md is regenerated from the merged capabilities.yaml: the attach row keeps the DEFAULT write window, the detach row takes main's nested, referenced, and cross-schema text.
Adds
--accept-default-write-window SCHEMA.TABLE(Options.AcceptDefaultWriteWindow), somigrate --altercan run anATTACH PARTITION ... FOR VALUESonline on a table that has aDEFAULTpartition once the operator accepts its brief write window.Why
Many partitioned tables keep a
DEFAULTpartition to catch rows no other partition takes. To attach a new partition without scanning thatDEFAULTpartition under a lock that blocks it, pg-sprite first adds aCHECKto it saying none of its rows fall inside the new bound. From that moment until the attach commits, any write that would land in theDEFAULTpartition inside the new bound fails. That is a real, if short, cost to the application, so pg-sprite refused every attach beside aDEFAULTpartition. This PR lets the operator accept the window explicitly, by naming the table, the way the other acknowledgements work.What
Options.AcceptDefaultWriteWindowand--accept-default-write-window SCHEMA.TABLE. When the value names the resolved partitioned table, the online attach runs withAttachPartitionOptions.AcceptDefaultWriteWindowset, and a warn-level audit record names the table before it starts.ErrAcceptDefaultWriteWindowMismatch, anAcknowledgementMismatchError, before anything runs;RunDesiredrejects it withErrAcceptDefaultWriteWindowNotSupported, andWithoutAcknowledgementsclears it;Acknowledgements()listsaccept-default-write-window;--force(which runs the blockingATTACHand opens no window), with--dry-run(which does not read theDEFAULTpartition yet), and with--desired(a desired file cannot express an attach).Options.validaterefuses it besideForcetoo.capability-boundarytoby-design: the engine can run the attach, and only the operator's consent is missing. Its detail now names the flag and the23514writes the window refuses.cli.md,limitations.md,refusal-classes.md,schemabot-integration.md,invariants.md, and theattach-partitioncapability row.The dry run still plans an attach beside a
DEFAULTpartition as executing without reading the catalog. Making it report the refusal, and take this flag, is a follow-up.Before / after
The change is what happens when a
DEFAULTpartition sits beside the new bound. An attach on a table with noDEFAULTpartition is unchanged, and--forcestill runs the blockingATTACH.Example:
app.ordershasorders_2026andorders_default, and the operator attachesorders_2027for 2027.