@@ -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
}
@@ -7933,6 +7914,126 @@ impl fmt::Display for RenameTable {
7933
7914
}
7934
7915
}
7935
7916
7917
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7918
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7919
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7920
+ pub enum SetSessionParamKind {
7921
+ Generic ( SetSessionParamGeneric ) ,
7922
+ IdentityInsert ( SetSessionParamIdentityInsert ) ,
7923
+ Offsets ( SetSessionParamOffsets ) ,
7924
+ Statistics ( SetSessionParamStatistics ) ,
7925
+ }
7926
+
7927
+ impl fmt:: Display for SetSessionParamKind {
7928
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7929
+ match self {
7930
+ SetSessionParamKind :: Generic ( x) => write ! ( f, "{x}" ) ,
7931
+ SetSessionParamKind :: IdentityInsert ( x) => write ! ( f, "{x}" ) ,
7932
+ SetSessionParamKind :: Offsets ( x) => write ! ( f, "{x}" ) ,
7933
+ SetSessionParamKind :: Statistics ( x) => write ! ( f, "{x}" ) ,
7934
+ }
7935
+ }
7936
+ }
7937
+
7938
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7939
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7940
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7941
+ pub struct SetSessionParamGeneric {
7942
+ pub names : Vec < String > ,
7943
+ pub value : String ,
7944
+ }
7945
+
7946
+ impl fmt:: Display for SetSessionParamGeneric {
7947
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7948
+ write ! ( f, "{} {}" , display_comma_separated( & self . names) , self . value)
7949
+ }
7950
+ }
7951
+
7952
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7953
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7954
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7955
+ pub struct SetSessionParamIdentityInsert {
7956
+ pub obj : ObjectName ,
7957
+ pub value : SessionParamValue ,
7958
+ }
7959
+
7960
+ impl fmt:: Display for SetSessionParamIdentityInsert {
7961
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7962
+ write ! ( f, "IDENTITY_INSERT {} {}" , self . obj, self . value)
7963
+ }
7964
+ }
7965
+
7966
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7967
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7968
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7969
+ pub struct SetSessionParamOffsets {
7970
+ pub keywords : Vec < String > ,
7971
+ pub value : SessionParamValue ,
7972
+ }
7973
+
7974
+ impl fmt:: Display for SetSessionParamOffsets {
7975
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7976
+ write ! (
7977
+ f,
7978
+ "OFFSETS {} {}" ,
7979
+ display_comma_separated( & self . keywords) ,
7980
+ self . value
7981
+ )
7982
+ }
7983
+ }
7984
+
7985
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
7986
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
7987
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
7988
+ pub struct SetSessionParamStatistics {
7989
+ pub topic : SessionParamStatsTopic ,
7990
+ pub value : SessionParamValue ,
7991
+ }
7992
+
7993
+ impl fmt:: Display for SetSessionParamStatistics {
7994
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
7995
+ write ! ( f, "STATISTICS {} {}" , self . topic, self . value)
7996
+ }
7997
+ }
7998
+
7999
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
8000
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8001
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
8002
+ pub enum SessionParamStatsTopic {
8003
+ IO ,
8004
+ Profile ,
8005
+ Time ,
8006
+ Xml ,
8007
+ }
8008
+
8009
+ impl fmt:: Display for SessionParamStatsTopic {
8010
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8011
+ match self {
8012
+ SessionParamStatsTopic :: IO => write ! ( f, "IO" ) ,
8013
+ SessionParamStatsTopic :: Profile => write ! ( f, "PROFILE" ) ,
8014
+ SessionParamStatsTopic :: Time => write ! ( f, "TIME" ) ,
8015
+ SessionParamStatsTopic :: Xml => write ! ( f, "XML" ) ,
8016
+ }
8017
+ }
8018
+ }
8019
+
8020
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
8021
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
8022
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
8023
+ pub enum SessionParamValue {
8024
+ On ,
8025
+ Off ,
8026
+ }
8027
+
8028
+ impl fmt:: Display for SessionParamValue {
8029
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
8030
+ match self {
8031
+ SessionParamValue :: On => write ! ( f, "ON" ) ,
8032
+ SessionParamValue :: Off => write ! ( f, "OFF" ) ,
8033
+ }
8034
+ }
8035
+ }
8036
+
7936
8037
#[ cfg( test) ]
7937
8038
mod tests {
7938
8039
use super :: * ;
0 commit comments