pub enum AlterTableTarget {
Show 30 variants
Inherit {
parent: String,
detach: bool,
},
SetHotTierBytes(u64),
AddForeignKey(ForeignKeyConstraint),
DropForeignKey {
name: String,
if_exists: bool,
},
DropIndex {
name: String,
if_exists: bool,
},
AddColumn {
column: ColumnDef,
if_not_exists: bool,
},
AlterColumnType {
column: String,
new_type: ColumnTypeName,
using: Option<Expr>,
collation: Option<(Collation, String)>,
},
DropColumn {
column: String,
if_exists: bool,
cascade: bool,
},
AddTableConstraint(TableConstraint),
OwnerTo {
role: String,
},
ClusterOn {
index: Option<String>,
},
ValidateConstraint {
name: String,
},
RenameColumn {
old: String,
new: String,
},
RenameConstraint {
old: String,
new: String,
},
SetColumnAutoIncrement {
column: String,
seq_name: Option<String>,
},
RenameTable {
new: String,
},
SetTriggerEnabled {
which: TriggerSelector,
enabled: bool,
},
SetRowSecurity {
enabled: Option<bool>,
force: Option<bool>,
},
AttachPartition {
child: String,
bounds: PartitionOfBoundsAst,
},
DetachPartition {
child: String,
concurrently: bool,
finalize: bool,
},
AlterColumnSetDefault {
column: String,
default_expr: Expr,
},
AlterColumnDropDefault {
column: String,
},
AlterColumnSetNotNull {
column: String,
},
AlterColumnDropNotNull {
column: String,
},
AlterColumnRestart {
column: String,
with: Option<i64>,
},
AlterColumnDropExpression {
column: String,
if_exists: bool,
},
AlterColumnDropIdentity {
column: String,
if_exists: bool,
},
AlterColumnSetExpression {
column: String,
expr: Expr,
},
OfType {
type_name: String,
},
ReplicaIdentityUsingIndex {
index: String,
},
}Variants§
Inherit
v7.39 (round 647) — ALTER TABLE c INHERIT p / NO INHERIT p.
Both were accepted-and-ignored since v7.37.18, on the reasoning
that SPG has no PG-style inheritance. Round 645 gave it one, and
the reasoning went stale: NO INHERIT reported success while the
child stayed attached, which is the worst kind of answer — the
statement says it worked and the catalog disagrees.
SetHotTierBytes(u64)
Per-table hot-tier byte budget override. The freezer
reads this before falling back to SPG_HOT_TIER_BYTES.
AddForeignKey(ForeignKeyConstraint)
v7.6.8 — ALTER TABLE t ADD CONSTRAINT name FOREIGN KEY (cols) REFERENCES parent[(pcols)] [ON DELETE/UPDATE …].
Engine validates existing rows against the new constraint
before installing it.
DropForeignKey
v7.6.8 — ALTER TABLE t DROP CONSTRAINT [IF EXISTS] name.
if_exists (v7.13.2 mailrs round-6 S7) makes the drop a
no-op when no FK with that name exists; otherwise raises.
DropIndex
v7.39 (round 431) — MySQL’s ALTER TABLE t DROP {INDEX|KEY} name,
the counterpart of ADD INDEX. Lowers to the same catalog action
as the standalone DROP INDEX statement.
AddColumn
v7.13.0 — ALTER TABLE t ADD [COLUMN] [IF NOT EXISTS] <col> <type> [DEFAULT <expr>] [NOT NULL]. mailrs round-5 G1
(20 migrate-*.sql hits). Engine appends the column to the
schema and back-fills every existing row with the DEFAULT
(or NULL when no DEFAULT and the column is nullable).
AlterColumnType
v7.13.0 — ALTER TABLE t ALTER COLUMN <col> TYPE <ty> [USING <expr>] (mailrs round-5 G8). Engine rewrites every
existing row’s column value by evaluating the optional
USING expression (default col::<ty>) and re-coercing
against the new column type.
Fields
new_type: ColumnTypeNamecollation: Option<(Collation, String)>v7.39 (round 713) — COLLATE <name> between the type and
USING. PG re-collates the column, and an ABSENT clause RESETS
the collation to the type default (measured round 713) — so
None is not “leave it alone”. The type parser consumed the
clause all along and this surface dropped it on the floor:
the statement succeeded and the ordering did not change, the
silent-divergence shape. Folded variant + the name as written.
DropColumn
v7.13.3 — ALTER TABLE t DROP [COLUMN] [IF EXISTS] <col> [CASCADE | RESTRICT] (mailrs round-7 S8). The column +
every row’s value at that position is removed; any index
on the column is dropped. if_exists makes the drop a
no-op when the column is missing. cascade removes
dependents (FKs referencing the column, partial indexes
whose predicate names the column); without it, the engine
rejects when dependents exist.
AddTableConstraint(TableConstraint)
v7.14.0 — ALTER TABLE t ADD CONSTRAINT name PRIMARY KEY (cols) / ADD CONSTRAINT name UNIQUE (cols) / ADD CONSTRAINT name CHECK (expr) — table-level constraints
installed post-CREATE-TABLE. pg_dump emits PKs as a
separate ALTER TABLE statement, so this surface lets the
dump load straight through.
OwnerTo
v7.39 (round 652) — OWNER TO <role>. SPG is single-owner, so
there is nothing to record; what PG does that SPG did not is
REFUSE a role that does not exist. The name has to reach the
engine for that, because only the engine knows the roles.
ClusterOn
v7.39 (round 652) — CLUSTER ON <index> and SET WITHOUT CLUSTER (the latter as None). SPG has no clustered storage, so
the hint is still a no-op; naming an index that does not exist is
not.
ValidateConstraint
v7.39 (round 652) — VALIDATE CONSTRAINT <name>: scan the rows
already in the table against a constraint added NOT VALID and,
if they all pass, mark it validated. It used to be swallowed as a
no-op on the theory that SPG validated at ADD time; SPG did not.
RenameColumn
v7.15.0 — ALTER TABLE t RENAME [COLUMN] old TO new.
Renames the column in the schema and propagates the rename
to every stored source string that references it as a
(potentially-qualified) column identifier: CHECK predicates,
partial-index predicates, runtime DEFAULT expressions, and
triggers’ UPDATE OF column lists. Function bodies and
trigger bodies are NOT auto-rewritten — they’re loose
source text and may contain references SPG can’t statically
resolve to this column (NEW./OLD. + dynamic SQL). Renames
the column even if dependents exist; users renaming a
column referenced by a function body update the function
body separately.
RenameConstraint
v7.39 (read01 round 48) — ALTER TABLE t RENAME CONSTRAINT old TO new.
Reachable now that the schema stores user-supplied constraint names.
SetColumnAutoIncrement
v7.22 (round-13 T2) — mark a column auto-incrementing.
pg_dump splits SERIAL/IDENTITY columns into a plain integer
column plus either ALTER COLUMN c SET DEFAULT nextval(…)
(serial) or ALTER COLUMN c ADD GENERATED … AS IDENTITY (…)
(identity); both lower to this. SPG’s auto-increment is
max+1-scan based, so the dump’s setval(…) calls stay
no-ops without losing the sequence position.
Fields
RenameTable
v7.16.2 — ALTER TABLE old RENAME TO new. Renames the
table itself (mailrs round-10 A.5 carve-out — mailrs’s
migrate-042 uses it). The engine moves the table entry
in the catalog under the new name; child catalog state
(FKs pointing at this table, triggers watching this
table) tracks the rename through the storage layer.
SetTriggerEnabled
v7.16.1 — ALTER TABLE t { ENABLE | DISABLE } TRIGGER { ALL | <name> }. Toggles whether row-level triggers
fire on subsequent INSERT/UPDATE/DELETE on the table.
pg_dump --disable-triggers emits a DISABLE wrapper +
ENABLE epilogue around every table’s data block so the
rows already-computed in prod don’t get re-rewritten
(and so trigger-driven side effects like
audit/queueing don’t re-fire during a bulk reload).
which == TriggerSelector::All toggles every trigger
on the table; Named(name) toggles one trigger. The
engine persists the disabled state on TriggerDef.enabled
(catalog FILE_VERSION 25+) and the row-write paths skip
the trigger when !enabled.
SetRowSecurity
v7.39 (RLS) — ALTER TABLE t { ENABLE | DISABLE | FORCE | NO FORCE } ROW LEVEL SECURITY. enabled = Some for ENABLE/DISABLE (sets
relrowsecurity); force = Some for FORCE/NO FORCE (sets
relforcerowsecurity). Exactly one is Some per statement.
AttachPartition
v7.37.16 (16.3) — ALTER TABLE parent ATTACH PARTITION child <bounds>. Promotes an existing table child to a partition
of parent using PG-style FOR VALUES … / DEFAULT bounds.
Engine validates that child’s columns are layout-compatible
with parent and that every row in child satisfies the
bound before installing the role.
DetachPartition
v7.37.16 (16.4 + 16.5) — ALTER TABLE parent DETACH PARTITION child [CONCURRENTLY] [FINALIZE]. Demotes a partition back
to a standalone table (clears partition_role) and removes
it from the parent’s child set. v7.37.16.5: CONCURRENTLY
is parser-accepted; engine performs the same atomic detach
(single-engine, no replication lag — the PG semantics that
require the two-phase split don’t apply).
AlterColumnSetDefault
v7.37.18 (18.1) — ALTER TABLE … ALTER COLUMN col SET DEFAULT <expr>. Engine re-parses + freezes the literal at this point,
matching CREATE TABLE-side default semantics. Volatile shapes
(now() / nextval) take the runtime-default path.
AlterColumnDropDefault
v7.37.18 (18.1) — ALTER TABLE … ALTER COLUMN col DROP DEFAULT.
AlterColumnSetNotNull
v7.37.18 (18.2) — ALTER TABLE … ALTER COLUMN col SET NOT NULL.
Engine validates that no existing row has NULL in that column
before flipping the flag (PG semantics — partial NOT NULL
would surface inconsistently).
AlterColumnDropNotNull
v7.37.18 (18.2) — ALTER TABLE … ALTER COLUMN col DROP NOT NULL.
AlterColumnRestart
v7.39 (round 220) — ALTER TABLE … ALTER COLUMN col RESTART [WITH n] on an identity column (None = bare RESTART, from the
column’s start value = 1). Engine records a next-value floor over
SPG’s max+1 identity allocation.
AlterColumnDropExpression
v7.38 (read01 U10) — ALTER TABLE … ALTER COLUMN col DROP EXPRESSION turns a stored generated column into a plain column
(its generation expression is removed; existing values are kept).
AlterColumnDropIdentity
v7.38 (read01, T28) — ALTER COLUMN col DROP IDENTITY [IF EXISTS]:
de-generate an identity column into a plain column.
AlterColumnSetExpression
v7.38 (read01 U12) — ALTER TABLE … ALTER COLUMN col SET EXPRESSION AS (expr) (PG 17) changes a stored generated column’s
expression and recomputes every existing row.
OfType
v7.39 (round 710) — OF <type> / the type half of the typed-table
binding. The BINDING stays a no-op (recorded); the TYPE must exist
(PG: type "x" does not exist).
ReplicaIdentityUsingIndex
v7.39 (round 710) — REPLICA IDENTITY USING INDEX <i>. The
identity setting no-ops (SPG has no logical replication consumer);
the INDEX must exist on this table (PG: index "i" for table "t" does not exist).
Trait Implementations§
Source§impl Clone for AlterTableTarget
impl Clone for AlterTableTarget
Source§fn clone(&self) -> AlterTableTarget
fn clone(&self) -> AlterTableTarget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more