You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: community/flamingock-auditstore-sql/src/main/java/io/flamingock/community/sql/internal/SqlAuditorDialectHelper.java
+53-2Lines changed: 53 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,6 @@ public String getCreateTableSqlString(String tableName) {
36
36
caseMARIADB:
37
37
caseH2:
38
38
caseHSQLDB:
39
-
caseFIREBIRD:
40
39
returnString.format(
41
40
"CREATE TABLE IF NOT EXISTS %s (" +
42
41
"id %s PRIMARY KEY, " +
@@ -60,6 +59,30 @@ public String getCreateTableSqlString(String tableName) {
Copy file name to clipboardExpand all lines: community/flamingock-auditstore-sql/src/main/java/io/flamingock/community/sql/internal/SqlLockDialectHelper.java
+83-9Lines changed: 83 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -44,12 +44,20 @@ public String getCreateTableSqlString(String tableName) {
44
44
"owner VARCHAR(255)," +
45
45
"expires_at TIMESTAMP" +
46
46
")", tableName);
47
+
caseFIREBIRD:
48
+
returnString.format(
49
+
"CREATE TABLE %s (" +
50
+
"lock_key VARCHAR(255) PRIMARY KEY, " +
51
+
"status VARCHAR(32), " +
52
+
"owner VARCHAR(255), " +
53
+
"expires_at TIMESTAMP" +
54
+
")",
55
+
tableName);
47
56
caseMYSQL:
48
57
caseMARIADB:
49
58
caseSQLITE:
50
59
caseH2:
51
60
caseHSQLDB:
52
-
caseFIREBIRD:
53
61
returnString.format(
54
62
"CREATE TABLE IF NOT EXISTS %s (" +
55
63
"`key` VARCHAR(255) PRIMARY KEY," +
@@ -58,7 +66,6 @@ public String getCreateTableSqlString(String tableName) {
58
66
"expires_at TIMESTAMP" +
59
67
")", tableName);
60
68
caseSQLSERVER:
61
-
caseSYBASE:
62
69
returnString.format(
63
70
"IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='%s' AND xtype='U') " +
64
71
"CREATE TABLE %s (" +
@@ -67,6 +74,19 @@ public String getCreateTableSqlString(String tableName) {
67
74
"owner VARCHAR(255)," +
68
75
"expires_at DATETIME" +
69
76
")", tableName, tableName);
77
+
caseSYBASE:
78
+
returnString.format(
79
+
"IF NOT EXISTS (SELECT 1 FROM sysobjects WHERE name='%s' AND type='U') " +
80
+
"BEGIN " +
81
+
" EXEC('CREATE TABLE %s (" +
82
+
" lock_key VARCHAR(255) NOT NULL PRIMARY KEY, " +
83
+
" status VARCHAR(32), " +
84
+
" owner VARCHAR(255), " +
85
+
" expires_at DATETIME" +
86
+
" )') " +
87
+
"END",
88
+
tableName, tableName
89
+
);
70
90
caseORACLE:
71
91
returnString.format(
72
92
"BEGIN EXECUTE IMMEDIATE 'CREATE TABLE %s (" +
@@ -106,12 +126,19 @@ public String getSelectLockSqlString(String tableName) {
106
126
// Select lock_key as the first column (getLockEntry expects rs.getString(1) to be the key)
107
127
returnString.format("SELECT lock_key, status, owner, expires_at FROM %s WHERE lock_key = ?", tableName);
108
128
caseSQLSERVER:
109
-
caseSYBASE:
110
129
returnString.format("SELECT [key], status, owner, expires_at FROM %s WITH (UPDLOCK, ROWLOCK) WHERE [key] = ?", tableName);
111
-
caseORACLE:
130
+
caseSYBASE:
131
+
returnString.format(
132
+
"SELECT lock_key, status, owner, expires_at " +
133
+
"FROM %s HOLDLOCK " +
134
+
"WHERE lock_key = ?",
135
+
tableName
136
+
); caseORACLE:
112
137
returnString.format("SELECT \"key\", status, owner, expires_at FROM %s WHERE \"key\" = ? FOR UPDATE", tableName);
113
138
caseINFORMIX:
114
139
returnString.format("SELECT lock_key, status, owner, expires_at FROM %s WHERE lock_key = ?", tableName);
140
+
caseFIREBIRD:
141
+
returnString.format("SELECT lock_key, status, owner, expires_at FROM %s WHERE lock_key = ?", tableName);
115
142
default:
116
143
returnString.format("SELECT `key`, status, owner, expires_at FROM %s WHERE `key` = ?", tableName);
117
144
}
@@ -135,7 +162,6 @@ public String getInsertOrUpdateLockSqlString(String tableName) {
135
162
"INSERT OR REPLACE INTO %s (`key`, status, owner, expires_at) VALUES (?, ?, ?, ?)",
136
163
tableName);
137
164
caseSQLSERVER:
138
-
caseSYBASE:
139
165
returnString.format(
140
166
"BEGIN TRANSACTION; " +
141
167
"UPDATE %s SET status = ?, owner = ?, expires_at = ? WHERE [key] = ?; " +
@@ -145,6 +171,17 @@ public String getInsertOrUpdateLockSqlString(String tableName) {
145
171
"END; " +
146
172
"COMMIT TRANSACTION;",
147
173
tableName, tableName);
174
+
caseSYBASE:
175
+
returnString.format(
176
+
"BEGIN TRAN " +
177
+
"UPDATE %s SET status = ?, owner = ?, expires_at = ? WHERE lock_key = ?; " +
0 commit comments