pub struct AlterTableExecutor;Expand description
Executor for ALTER TABLE statements
Implementations§
Source§impl AlterTableExecutor
impl AlterTableExecutor
Sourcepub fn execute(
stmt: &AlterTableStmt,
database: &mut Database,
) -> Result<String, ExecutorError>
pub fn execute( stmt: &AlterTableStmt, database: &mut Database, ) -> Result<String, ExecutorError>
Execute an ALTER TABLE statement.
Convenience wrapper over execute_with_source
for callers that do not have the original statement text (e.g. an AST
built programmatically). Without the source text, ADD COLUMN falls back
to reconstructing sqlite_master.sql from the schema rather than editing
the verbatim text in place. See issue #5625.
Sourcepub fn execute_with_source(
stmt: &AlterTableStmt,
database: &mut Database,
alter_sql: Option<&str>,
) -> Result<String, ExecutorError>
pub fn execute_with_source( stmt: &AlterTableStmt, database: &mut Database, alter_sql: Option<&str>, ) -> Result<String, ExecutorError>
Execute an ALTER TABLE statement, optionally given the verbatim original
statement text (alter_sql).
After a successful structural ALTER, two pieces of bookkeeping run (issue #5625):
-
Catalog schema sync. Column operations (ADD/DROP/RENAME/MODIFY) only mutate the storage
Tablecopy of the schema. The catalog copy — read bysqlite_master,PRAGMA table_info, and DML column resolution — is then re-synced from the storage copy so both stay consistent. (RENAME TABLE syncs via drop+create and is exempt.) -
sql_sourceupkeep. SQLite edits the verbatimCREATE TABLEtext insqlite_master.sqlin place on ALTER rather than reconstructing it. For ADD COLUMN, RENAME COLUMN, DROP COLUMN, and RENAME TO the stored verbatim text is edited to match SQLite (whenalter_sqlis available / the structure permits; RENAME TO is handled intable_options::execute_rename_table). For the remaining variants, and whenever an in-place edit cannot apply cleanly, the stale text is invalidated so it is reconstructed from the (now-synced) schema. Either way the stored text remains re-parseable on reload (issue #5619).
Auto Trait Implementations§
impl Freeze for AlterTableExecutor
impl RefUnwindSafe for AlterTableExecutor
impl Send for AlterTableExecutor
impl Sync for AlterTableExecutor
impl Unpin for AlterTableExecutor
impl UnsafeUnpin for AlterTableExecutor
impl UnwindSafe for AlterTableExecutor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more