@@ -63,6 +63,64 @@ public string GetXaSQL(string command, string xid)
63
63
}
64
64
}
65
65
66
+ public class SqlServerDBSpecial : IDbSpecial
67
+ {
68
+ private SqlServerDBSpecial ( )
69
+ { }
70
+
71
+ private static readonly Lazy < SqlServerDBSpecial > Instancelock =
72
+ new Lazy < SqlServerDBSpecial > ( ( ) => new SqlServerDBSpecial ( ) ) ;
73
+
74
+ public static SqlServerDBSpecial Instance => Instancelock . Value ;
75
+
76
+ /*
77
+
78
+ IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = 'dtm_barrier')
79
+ BEGIN
80
+ CREATE DATABASE dtm_barrier
81
+ USE dtm_barrier
82
+ END
83
+
84
+ GO
85
+
86
+ IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N’[dbo].[barrier]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)
87
+ BEGIN
88
+ DROP TABLE [dbo].[barrier]
89
+ END
90
+
91
+ GO
92
+
93
+ CREATE TABLE [dbo].[barrier]
94
+ (
95
+ [id] bigint NOT NULL IDENTITY(1,1) PRIMARY KEY,
96
+ [trans_type] varchar(45) NOT NULL DEFAULT(''),
97
+ [gid] varchar(128) NOT NULL DEFAULT(''),
98
+ [branch_id] varchar(128) NOT NULL DEFAULT(''),
99
+ [op] varchar(45) NOT NULL DEFAULT(''),
100
+ [barrier_id] varchar(45) NOT NULL DEFAULT(''),
101
+ [reason] varchar(45) NOT NULL DEFAULT(''),
102
+ [create_time] datetime NOT NULL DEFAULT(getdate()) ,
103
+ [update_time] datetime NOT NULL DEFAULT(getdate())
104
+ )
105
+
106
+ GO
107
+
108
+ CREATE UNIQUE INDEX[ix_uniq_barrier] ON[dbo].[barrier]
109
+ ([gid] ASC, [branch_id] ASC, [op] ASC, [barrier_id] ASC)
110
+ WITH(IGNORE_DUP_KEY = ON)
111
+
112
+ GO
113
+ */
114
+ public string GetInsertIgnoreTemplate ( string tableAndValues , string pgConstraint )
115
+ => string . Format ( "insert into {0}" , tableAndValues ) ;
116
+
117
+ public string GetPlaceHoldSQL ( string sql )
118
+ => sql ;
119
+
120
+ public string GetXaSQL ( string command , string xid )
121
+ => throw new DtmcliException ( "not support xa now!!!" ) ;
122
+ }
123
+
66
124
public class DbSpecialDelegate
67
125
{
68
126
private DbSpecialDelegate ( )
@@ -77,6 +135,7 @@ private DbSpecialDelegate()
77
135
{
78
136
{ Constant . Barrier . DBTYPE_MYSQL , MysqlDBSpecial . Instance } ,
79
137
{ Constant . Barrier . DBTYPE_POSTGRES , PostgresDBSpecial . Instance } ,
138
+ { Constant . Barrier . DBTYPE_SQLSERVER , SqlServerDBSpecial . Instance } ,
80
139
} ;
81
140
private string _currentDBType = Constant . Barrier . DBTYPE_MYSQL ;
82
141
0 commit comments