@@ -3438,12 +3438,7 @@ pub enum Statement {
34383438 /// MS-SQL session
34393439 ///
34403440 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
3441- SetSessionParam {
3442- names : Vec < String > ,
3443- identity_insert_obj : Option < ObjectName > ,
3444- offsets_keywords : Option < Vec < String > > ,
3445- value : String ,
3446- } ,
3441+ SetSessionParam ( SetSessionParamKind ) ,
34473442}
34483443
34493444impl fmt:: Display for Statement {
@@ -5021,21 +5016,7 @@ impl fmt::Display for Statement {
50215016 }
50225017 Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
50235018 Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
5024- Statement :: SetSessionParam {
5025- names,
5026- identity_insert_obj,
5027- offsets_keywords,
5028- value,
5029- } => {
5030- write ! ( f, "SET" ) ?;
5031- write ! ( f, " {}" , display_comma_separated( names) ) ?;
5032- if let Some ( obj) = identity_insert_obj {
5033- write ! ( f, " {obj}" ) ?;
5034- } else if let Some ( keywords) = offsets_keywords {
5035- write ! ( f, " {}" , display_comma_separated( keywords) ) ?;
5036- }
5037- write ! ( f, " {value}" )
5038- }
5019+ Statement :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
50395020 }
50405021 }
50415022}
@@ -7821,6 +7802,126 @@ impl fmt::Display for RenameTable {
78217802 }
78227803}
78237804
7805+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7806+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7807+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7808+ pub enum SetSessionParamKind {
7809+ Generic ( SetSessionParamGeneric ) ,
7810+ IdentityInsert ( SetSessionParamIdentityInsert ) ,
7811+ Offsets ( SetSessionParamOffsets ) ,
7812+ Statistics ( SetSessionParamStatistics ) ,
7813+ }
7814+
7815+ impl fmt:: Display for SetSessionParamKind {
7816+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7817+ match self {
7818+ SetSessionParamKind :: Generic ( x) => write ! ( f, "{x}" ) ,
7819+ SetSessionParamKind :: IdentityInsert ( x) => write ! ( f, "{x}" ) ,
7820+ SetSessionParamKind :: Offsets ( x) => write ! ( f, "{x}" ) ,
7821+ SetSessionParamKind :: Statistics ( x) => write ! ( f, "{x}" ) ,
7822+ }
7823+ }
7824+ }
7825+
7826+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7827+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7828+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7829+ pub struct SetSessionParamGeneric {
7830+ pub names : Vec < String > ,
7831+ pub value : String ,
7832+ }
7833+
7834+ impl fmt:: Display for SetSessionParamGeneric {
7835+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7836+ write ! ( f, "{} {}" , display_comma_separated( & self . names) , self . value)
7837+ }
7838+ }
7839+
7840+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7841+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7842+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7843+ pub struct SetSessionParamIdentityInsert {
7844+ pub obj : ObjectName ,
7845+ pub value : SessionParamValue ,
7846+ }
7847+
7848+ impl fmt:: Display for SetSessionParamIdentityInsert {
7849+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7850+ write ! ( f, "IDENTITY_INSERT {} {}" , self . obj, self . value)
7851+ }
7852+ }
7853+
7854+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7855+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7856+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7857+ pub struct SetSessionParamOffsets {
7858+ pub keywords : Vec < String > ,
7859+ pub value : SessionParamValue ,
7860+ }
7861+
7862+ impl fmt:: Display for SetSessionParamOffsets {
7863+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7864+ write ! (
7865+ f,
7866+ "OFFSETS {} {}" ,
7867+ display_comma_separated( & self . keywords) ,
7868+ self . value
7869+ )
7870+ }
7871+ }
7872+
7873+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7874+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7875+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7876+ pub struct SetSessionParamStatistics {
7877+ pub topic : SessionParamStatsTopic ,
7878+ pub value : SessionParamValue ,
7879+ }
7880+
7881+ impl fmt:: Display for SetSessionParamStatistics {
7882+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7883+ write ! ( f, "STATISTICS {} {}" , self . topic, self . value)
7884+ }
7885+ }
7886+
7887+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7888+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7889+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7890+ pub enum SessionParamStatsTopic {
7891+ IO ,
7892+ Profile ,
7893+ Time ,
7894+ Xml ,
7895+ }
7896+
7897+ impl fmt:: Display for SessionParamStatsTopic {
7898+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7899+ match self {
7900+ SessionParamStatsTopic :: IO => write ! ( f, "IO" ) ,
7901+ SessionParamStatsTopic :: Profile => write ! ( f, "PROFILE" ) ,
7902+ SessionParamStatsTopic :: Time => write ! ( f, "TIME" ) ,
7903+ SessionParamStatsTopic :: Xml => write ! ( f, "XML" ) ,
7904+ }
7905+ }
7906+ }
7907+
7908+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7909+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7910+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7911+ pub enum SessionParamValue {
7912+ On ,
7913+ Off ,
7914+ }
7915+
7916+ impl fmt:: Display for SessionParamValue {
7917+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7918+ match self {
7919+ SessionParamValue :: On => write ! ( f, "ON" ) ,
7920+ SessionParamValue :: Off => write ! ( f, "OFF" ) ,
7921+ }
7922+ }
7923+ }
7924+
78247925#[ cfg( test) ]
78257926mod tests {
78267927 use super :: * ;
0 commit comments