@@ -4403,6 +4403,13 @@ pub enum Statement {
44034403 /// ```
44044404 /// [Snowflake](https://docs.snowflake.com/en/sql-reference/sql/create-user)
44054405 CreateUser ( CreateUser ) ,
4406+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
4407+ ///
4408+ /// ```sql
4409+ /// VACUUM tbl
4410+ /// ```
4411+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
4412+ Vacuum ( VacuumStatement ) ,
44064413}
44074414
44084415/// ```sql
@@ -6336,6 +6343,7 @@ impl fmt::Display for Statement {
63366343 Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
63376344 Statement :: ExportData ( e) => write ! ( f, "{e}" ) ,
63386345 Statement :: CreateUser ( s) => write ! ( f, "{s}" ) ,
6346+ Statement :: Vacuum ( s) => write ! ( f, "{s}" ) ,
63396347 }
63406348 }
63416349}
@@ -10521,6 +10529,50 @@ impl fmt::Display for CreateTableLike {
1052110529 }
1052210530}
1052310531
10532+ /// Re-sorts rows and reclaims space in either a specified table or all tables in the current database
10533+ ///
10534+ /// '''sql
10535+ /// VACUUM [ FULL | SORT ONLY | DELETE ONLY | REINDEX | RECLUSTER ] [ \[ table_name \] [ TO threshold PERCENT ] \[ BOOST \] ]
10536+ /// '''
10537+ /// [Redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_VACUUM_command.html)
10538+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
10539+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
10540+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
10541+ pub struct VacuumStatement {
10542+ pub full : bool ,
10543+ pub sort_only : bool ,
10544+ pub delete_only : bool ,
10545+ pub reindex : bool ,
10546+ pub recluster : bool ,
10547+ pub table_name : Option < ObjectName > ,
10548+ pub threshold : Option < Value > ,
10549+ pub boost : bool ,
10550+ }
10551+
10552+ impl fmt:: Display for VacuumStatement {
10553+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
10554+ write ! (
10555+ f,
10556+ "VACUUM{}{}{}{}{}" ,
10557+ if self . full { " FULL" } else { "" } ,
10558+ if self . sort_only { " SORT ONLY" } else { "" } ,
10559+ if self . delete_only { " DELETE ONLY" } else { "" } ,
10560+ if self . reindex { " REINDEX" } else { "" } ,
10561+ if self . recluster { " RECLUSTER" } else { "" } ,
10562+ ) ?;
10563+ if let Some ( table_name) = & self . table_name {
10564+ write ! ( f, " {table_name}" ) ?;
10565+ }
10566+ if let Some ( threshold) = & self . threshold {
10567+ write ! ( f, " TO {threshold} PERCENT" ) ?;
10568+ }
10569+ if self . boost {
10570+ write ! ( f, " BOOST" ) ?;
10571+ }
10572+ Ok ( ( ) )
10573+ }
10574+ }
10575+
1052410576#[ cfg( test) ]
1052510577mod tests {
1052610578 use crate :: tokenizer:: Location ;
0 commit comments