Skip to main content

AlterTableTarget

Enum AlterTableTarget 

Source
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.

Fields

§parent: String
§detach: bool
§

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.

Fields

§name: String
§if_exists: bool
§

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.

Fields

§name: String
§if_exists: bool
§

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).

Fields

§column: ColumnDef
§if_not_exists: bool
§

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

§column: String
§using: Option<Expr>
§collation: 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.

Fields

§column: String
§if_exists: bool
§cascade: bool
§

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.

Fields

§role: String
§

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.

Fields

§

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.

Fields

§name: String
§

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.

Fields

§

RenameConstraint

v7.39 (read01 round 48) — ALTER TABLE t RENAME CONSTRAINT old TO new. Reachable now that the schema stores user-supplied constraint names.

Fields

§

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

§column: String
§seq_name: Option<String>

The implicit sequence pg_dump names for an identity column (ADD GENERATED … ( SEQUENCE NAME s … )) or the nextval target for a serial default. The engine creates it if absent so the dump’s later setval(s, …) lands.

§

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.

Fields

§

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.

Fields

§enabled: bool
§

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.

Fields

§enabled: Option<bool>
§force: Option<bool>
§

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.

Fields

§child: String
§

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).

Fields

§child: String
§concurrently: bool
§finalize: bool
§

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.

Fields

§column: String
§default_expr: Expr
§

AlterColumnDropDefault

v7.37.18 (18.1) — ALTER TABLE … ALTER COLUMN col DROP DEFAULT.

Fields

§column: String
§

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).

Fields

§column: String
§

AlterColumnDropNotNull

v7.37.18 (18.2) — ALTER TABLE … ALTER COLUMN col DROP NOT NULL.

Fields

§column: String
§

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.

Fields

§column: String
§with: Option<i64>
§

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).

Fields

§column: String
§if_exists: bool
§

AlterColumnDropIdentity

v7.38 (read01, T28) — ALTER COLUMN col DROP IDENTITY [IF EXISTS]: de-generate an identity column into a plain column.

Fields

§column: String
§if_exists: bool
§

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.

Fields

§column: String
§expr: Expr
§

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).

Fields

§type_name: String
§

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).

Fields

§index: String

Trait Implementations§

Source§

impl Clone for AlterTableTarget

Source§

fn clone(&self) -> AlterTableTarget

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AlterTableTarget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AlterTableTarget

Source§

fn eq(&self, other: &AlterTableTarget) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AlterTableTarget

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.