Skip to content

feat(plan): disclose greenfield steps as plain executable statements - #69

Open
Kiran01bm wants to merge 2 commits into
mainfrom
kiran01bm/ct8-greenfield-exec-sql
Open

feat(plan): disclose greenfield steps as plain executable statements#69
Kiran01bm wants to merge 2 commits into
mainfrom
kiran01bm/ct8-greenfield-exec-sql

Conversation

@Kiran01bm

@Kiran01bm Kiran01bm commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Greenfield plan statements now disclose what the create path actually executes: exec_sql is the statement as written, each build's decision is reclassified metadata-only, and no CONCURRENTLY substitution is shown for a table that does not exist yet.

Why

A greenfield CREATE TABLE plan (the table does not exist yet) is executed statement-by-statement by the create path, which runs the desired file's builds verbatim and refuses a concurrent build on a table born this run. The plan report disclosed the opposite: the planner's live-table rewrite (CREATE INDEX CONCURRENTLY …) as the greenfield exec_sql, with a safer-idiom decision and a blocking-lock warning in the human report. An orchestrator that ran exec_sql itself ran a form the engine never would, and a reviewer was told a table nobody reads yet was about to be locked.

What

  • plan.DiscloseGreenfieldExecution sets exec_sql to the statement itself and execution: autocommit for every executable greenfield statement, withdraws safer_sql, and re-stamps a safer-idiom decision to metadata-only — the reason the planner already gives the CREATE TABLE itself. Refused, rewrite-required and unavailable statements are untouched.
  • diffplan calls it on the greenfield branch, so pg-sprite diff --json, --sql (-- native (metadata-only)), the human report (note[metadata-only]runs as written) and the library Report all agree.
  • Withdrawing per-decision advice is one helper shared with RefuseUnsupportedPartitionedParent.
  • Docs: plan-report.md (field rows, reason vocabulary, Fingerprint), postgres-online-ddl-reference.md (metadata-only / safer-idiom), safer-sequences.md, schemabot-integration.md.

Fingerprint change, no version bump. plan.Fingerprint hashes exec_sql, so every greenfield plan's fingerprint changes value (for the same desired file, sha256:63a6cd9e…sha256:df731940…). The serialization is unchanged and format_version stays 2; the fingerprint now commits to what runs. A consumer holding a pre-upgrade greenfield fingerprint gets one plan-fingerprint-mismatch and re-plans. Fingerprints for existing tables are unaffected. docs/plan-report.md carries the caveat.

Before / after

Before (greenfield CREATE INDEX statement)      After
+------------------------------------------+    +------------------------------------------+
| sql:        CREATE INDEX i ON t (c)      |    | sql:        CREATE INDEX i ON t (c)      |
| exec_sql:   CREATE INDEX CONCURRENTLY …  | -> | exec_sql:   CREATE INDEX i ON t (c)      |
| execution:  autocommit-each-step         |    | execution:  autocommit-each-step         |
| reason:     safer-idiom                  |    | reason:     metadata-only                |
| safer_sql:  CREATE INDEX CONCURRENTLY …  |    | safer_sql:  (absent)                     |
| text:       warning[safer-idiom] …       |    | text:       note[metadata-only] …        |
|             will run a safer online seq. |    |             runs as written              |
+------------------------------------------+    +------------------------------------------+
   (create path refuses CONCURRENTLY here)         (what the create path runs)

A greenfield create plan runs each statement verbatim, so the report now
carries exec_sql and autocommit execution per step instead of leaving the
reviewer to infer the create path's execution from the desired file.
… execution

A safer-idiom decision left on an execute statement with no safer_sql is a
state router.Route cannot produce; the CLI keyed a blocking-lock warning off
it right before "runs as written". An index on a table born in this run has
no readers to lock out, so it takes the same reason the planner already gives
the CREATE TABLE. Docs disclose the greenfield fingerprint value change.
@Kiran01bm
Kiran01bm marked this pull request as ready for review September 3, 2026 04:40
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant