@@ -3440,12 +3440,7 @@ pub enum Statement {
3440
3440
/// MS-SQL session
3441
3441
///
3442
3442
/// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
3443
- SetSessionParam {
3444
- names : Vec < String > ,
3445
- identity_insert_obj : Option < ObjectName > ,
3446
- offsets_keywords : Option < Vec < String > > ,
3447
- value : String ,
3448
- } ,
3443
+ SetSessionParam ( SetSessionParamKind ) ,
3449
3444
}
3450
3445
3451
3446
impl fmt:: Display for Statement {
@@ -5033,21 +5028,7 @@ impl fmt::Display for Statement {
5033
5028
}
5034
5029
Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
5035
5030
Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
5036
- Statement :: SetSessionParam {
5037
- names,
5038
- identity_insert_obj,
5039
- offsets_keywords,
5040
- value,
5041
- } => {
5042
- write ! ( f, "SET" ) ?;
5043
- write ! ( f, " {}" , display_comma_separated( names) ) ?;
5044
- if let Some ( obj) = identity_insert_obj {
5045
- write ! ( f, " {obj}" ) ?;
5046
- } else if let Some ( keywords) = offsets_keywords {
5047
- write ! ( f, " {}" , display_comma_separated( keywords) ) ?;
5048
- }
5049
- write ! ( f, " {value}" )
5050
- }
5031
+ Statement :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
5051
5032
}
5052
5033
}
5053
5034
}
@@ -7963,6 +7944,126 @@ impl fmt::Display for TableObject {
7963
7944
}
7964
7945
}
7965
7946
7947
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7948
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7949
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7950
+ pub enum SetSessionParamKind {
7951
+ Generic ( SetSessionParamGeneric ) ,
7952
+ IdentityInsert ( SetSessionParamIdentityInsert ) ,
7953
+ Offsets ( SetSessionParamOffsets ) ,
7954
+ Statistics ( SetSessionParamStatistics ) ,
7955
+ }
7956
+
7957
+ impl fmt:: Display for SetSessionParamKind {
7958
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7959
+ match self {
7960
+ SetSessionParamKind :: Generic ( x) => write ! ( f, "{x}" ) ,
7961
+ SetSessionParamKind :: IdentityInsert ( x) => write ! ( f, "{x}" ) ,
7962
+ SetSessionParamKind :: Offsets ( x) => write ! ( f, "{x}" ) ,
7963
+ SetSessionParamKind :: Statistics ( x) => write ! ( f, "{x}" ) ,
7964
+ }
7965
+ }
7966
+ }
7967
+
7968
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7969
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7970
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7971
+ pub struct SetSessionParamGeneric {
7972
+ pub names : Vec < String > ,
7973
+ pub value : String ,
7974
+ }
7975
+
7976
+ impl fmt:: Display for SetSessionParamGeneric {
7977
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7978
+ write ! ( f, "{} {}" , display_comma_separated( & self . names) , self . value)
7979
+ }
7980
+ }
7981
+
7982
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7983
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7984
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7985
+ pub struct SetSessionParamIdentityInsert {
7986
+ pub obj : ObjectName ,
7987
+ pub value : SessionParamValue ,
7988
+ }
7989
+
7990
+ impl fmt:: Display for SetSessionParamIdentityInsert {
7991
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7992
+ write ! ( f, "IDENTITY_INSERT {} {}" , self . obj, self . value)
7993
+ }
7994
+ }
7995
+
7996
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7997
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7998
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7999
+ pub struct SetSessionParamOffsets {
8000
+ pub keywords : Vec < String > ,
8001
+ pub value : SessionParamValue ,
8002
+ }
8003
+
8004
+ impl fmt:: Display for SetSessionParamOffsets {
8005
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8006
+ write ! (
8007
+ f,
8008
+ "OFFSETS {} {}" ,
8009
+ display_comma_separated( & self . keywords) ,
8010
+ self . value
8011
+ )
8012
+ }
8013
+ }
8014
+
8015
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
8016
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8017
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
8018
+ pub struct SetSessionParamStatistics {
8019
+ pub topic : SessionParamStatsTopic ,
8020
+ pub value : SessionParamValue ,
8021
+ }
8022
+
8023
+ impl fmt:: Display for SetSessionParamStatistics {
8024
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8025
+ write ! ( f, "STATISTICS {} {}" , self . topic, self . value)
8026
+ }
8027
+ }
8028
+
8029
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
8030
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8031
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
8032
+ pub enum SessionParamStatsTopic {
8033
+ IO ,
8034
+ Profile ,
8035
+ Time ,
8036
+ Xml ,
8037
+ }
8038
+
8039
+ impl fmt:: Display for SessionParamStatsTopic {
8040
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8041
+ match self {
8042
+ SessionParamStatsTopic :: IO => write ! ( f, "IO" ) ,
8043
+ SessionParamStatsTopic :: Profile => write ! ( f, "PROFILE" ) ,
8044
+ SessionParamStatsTopic :: Time => write ! ( f, "TIME" ) ,
8045
+ SessionParamStatsTopic :: Xml => write ! ( f, "XML" ) ,
8046
+ }
8047
+ }
8048
+ }
8049
+
8050
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
8051
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8052
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
8053
+ pub enum SessionParamValue {
8054
+ On ,
8055
+ Off ,
8056
+ }
8057
+
8058
+ impl fmt:: Display for SessionParamValue {
8059
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8060
+ match self {
8061
+ SessionParamValue :: On => write ! ( f, "ON" ) ,
8062
+ SessionParamValue :: Off => write ! ( f, "OFF" ) ,
8063
+ }
8064
+ }
8065
+ }
8066
+
7966
8067
#[ cfg( test) ]
7967
8068
mod tests {
7968
8069
use super :: * ;
0 commit comments