/
ISymmetricDialect.java
280 lines (188 loc) · 9.8 KB
/
ISymmetricDialect.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.db;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Database;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.platform.PermissionType;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.util.BinaryEncoding;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.Node;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.symmetric.model.TriggerRouter;
import org.jumpmind.symmetric.service.IExtensionService;
import org.jumpmind.symmetric.service.IParameterService;
import org.jumpmind.symmetric.service.impl.TransformService.TransformTableNodeGroupLink;
/*
* A dialect is the interface that insulates SymmetricDS from database implementation specifics.
*/
public interface ISymmetricDialect {
public void createTrigger(StringBuilder sqlBuffer, DataEventType dml,
Trigger trigger, TriggerHistory hist, Channel channel,
String tablePrefix, Table table, ISqlTransaction transaction);
public void createTrigger(StringBuilder sqlBuffer, DataEventType dml,
Trigger trigger, TriggerHistory hist, Channel channel,
String tablePrefix, Table table);
public void createDdlTrigger(String tablePrefix, StringBuilder sqlBuffer, String triggerName);
/*
* Get the name of this symmetric instance. This can be set in symmetric.properties using the engine.name property.
*/
public String getEngineName();
public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String schemaName, String triggerName,
String tableName, ISqlTransaction transaction);
public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String schemaName, String triggerName,
String tableName);
public void removeDdlTrigger(StringBuilder sqlBuffer, String catalogName, String schemaName, String triggerName);
public boolean doesTriggerExist(String catalogName, String schema, String tableName, String triggerName);
public boolean doesDdlTriggerExist(String catalogName, String schema, String triggerName);
public void verifyDatabaseIsCompatible();
public void initTablesAndDatabaseObjects();
public void dropTablesAndDatabaseObjects();
public boolean createOrAlterTablesIfNecessary(String... tables);
public void dropRequiredDatabaseObjects();
public void createRequiredDatabaseObjects();
public IDatabasePlatform getPlatform();
public IDatabasePlatform getTargetPlatform();
public IDatabasePlatform getTargetPlatform(String tableName);
public String getName();
public String getVersion();
public int getMajorVersion();
public int getMinorVersion();
public String getProductVersion();
public BinaryEncoding getBinaryEncoding();
public String getTransactionTriggerExpression(String defaultCatalog, String defaultSchema, Trigger trigger);
public String createInitialLoadSqlFor(Node node, TriggerRouter trigger, Table table, TriggerHistory triggerHistory, Channel channel,
String overrideSelectSql);
public boolean[] getColumnPositionUsingTemplate(Table originalTable, TriggerHistory triggerHistory);
public String createPurgeSqlFor(Node node, TriggerRouter triggerRouter, TriggerHistory triggerHistory);
public String createPurgeSqlFor(Node node, TriggerRouter triggerRouter, TriggerHistory triggerHistory, List<TransformTableNodeGroupLink> transforms);
public String createPurgeSqlFor(Node node, TriggerRouter triggerRouter, TriggerHistory triggerHistory, List<TransformTableNodeGroupLink> transforms,
String deleteSql);
public List<String> createPurgeSqlForMultipleTables(Node node, TriggerRouter triggerRouter, TriggerHistory triggerHistory,
List<TransformTableNodeGroupLink> transforms, String deleteSql);
public String createCsvDataSql(Trigger trigger, TriggerHistory triggerHistory, Channel channel, String whereClause);
public String createCsvPrimaryKeySql(Trigger trigger, TriggerHistory triggerHistory, Channel channel, String whereClause);
/*
* Get the maximum size the name of a trigger can be for the database platform. If the generated symmetric trigger name is greater than the max trigger
* name, symmetric will truncate the name, then log a warning suggesting that you might want to provide your own name.
*/
public int getMaxTriggerNameLength();
public boolean supportsTransactionId();
/*
* Use this call to check to see if the implemented database dialect supports a way to check on pending database transactions.
*/
public boolean supportsTransactionViews();
/*
* Indicates if this dialect supports subselects in delete statements.
*/
public boolean supportsSubselectsInDelete();
/*
* Indicates if this dialect supports subselects in update statements.
*/
public boolean supportsSubselectsInUpdate();
/*
* Implement this if the database has some type of cleanup functionality that needs to be run when dropping database objects. An example is Oracle's 'purge
* recyclebin'
*/
public void cleanDatabase();
@Deprecated
public void disableSyncTriggers(ISqlTransaction transaction);
public void disableSyncTriggers(ISqlTransaction transaction, String nodeId);
public void enableSyncTriggers(ISqlTransaction transaction);
public String getSyncTriggersExpression();
public String getSyncTriggersOnIncomingExpression();
public String getSourceNodeExpression();
public String getCreateSymmetricDDL();
public boolean isBlobSyncSupported();
public boolean isClobSyncSupported();
/*
* An indicator as to whether the ability to override the default transaction id provided by the dialect can be overridden in the trigger configuration.
*/
public boolean isTransactionIdOverrideSupported();
public long insertWithGeneratedKey(final String sql, final SequenceIdentifier sequenceId);
public long insertWithGeneratedKey(final String sql, final SequenceIdentifier identifier, Object... args);
@Deprecated
public Column[] orderColumns(String[] columnNames, Table table);
public boolean supportsOpenCursorsAcrossCommit();
/*
* Retrieves a list of keywords for the database.
*/
public Set<String> getSqlKeywords();
public String getInitialLoadTableAlias();
public String preProcessTriggerSqlClause(String sqlClause);
public void truncateTable(String tableName);
public String getDatabaseTimeSQL();
public long getDatabaseTime();
public boolean areDatabaseTransactionsPendingSince(long time);
public Date getEarliestTransactionStartTime();
/*
* Returns true if the trigger select lob data back from the original table.
*/
public boolean needsToSelectLobData();
/*
* This is a SQL clause that compares the old data to the new data in a trigger.
*/
public String getDataHasChangedCondition(Trigger trigger);
/*
* Indicates whether captured data can contain gaps.
*/
public boolean canGapsOccurInCapturedDataIds();
public String massageDataExtractionSql(String sql, boolean isContainsBigLob);
public String massageForLob(String sql, boolean isContainsBigLob);
public boolean isInitialLoadTwoPassLob(Table table);
public String getInitialLoadTwoPassLobSql(String sql, Table table, boolean isFirstPass);
/*
* Indicates that the dialect relies on SQL that is to be inserted into the database for use by embedded Java triggers. H2 is an example dialect that needs
* this feature.
*
* @return
*/
public boolean escapesTemplatesForDatabaseInserts();
public String getMasterCollation();
public boolean supportsBatchUpdates();
public void cleanupTriggers();
public String getDriverName();
public String getDriverVersion();
public String getSequenceName(SequenceIdentifier identifier);
public String getSequenceKeyName(SequenceIdentifier identifier);
public long getCurrentSequenceValue(SequenceIdentifier identifier);
public String getTablePrefix();
public Database readSymmetricSchemaFromXml();
public String getSymmetricDdlChanges();
public String getTemplateNumberPrecisionSpec();
public Map<String, String> getSqlReplacementTokens();
public int getSqlTypeForIds();
public AbstractTriggerTemplate getTriggerTemplate();
public IParameterService getParameterService();
public void setExtensionService(IExtensionService extensionService);
public PermissionType[] getSymTablePermissions();
public ISymmetricDialect getTargetDialect();
public ISymmetricDialect getTargetDialect(String tableName);
public void setTargetDialect(ISymmetricDialect targetDialect);
}