1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jumpmind.symmetric.db;
22
23 import org.apache.ddlutils.Platform;
24 import org.apache.ddlutils.model.Table;
25 import org.jumpmind.symmetric.load.IColumnFilter;
26 import org.jumpmind.symmetric.model.DataEventType;
27 import org.jumpmind.symmetric.model.Node;
28 import org.jumpmind.symmetric.model.Trigger;
29 import org.jumpmind.symmetric.model.TriggerHistory;
30 import org.springframework.jdbc.core.JdbcTemplate;
31 import org.springframework.jdbc.core.PreparedStatementCallback;
32 import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
33
34 public interface IDbDialect {
35
36 public void initTrigger(DataEventType dml, Trigger trigger, TriggerHistory audit, String tablePrefix, Table table);
37
38 /***
39 * Get the name of this symmetric instance. This can be set in
40 * symmetric.properties using the symmetric.runtime.engine.name property.
41 */
42 public String getEngineName();
43
44 public void removeTrigger(String catalogName, String schemaName, String triggerName, String tableName, TriggerHistory oldHistory);
45
46 public boolean doesTriggerExist(String catalogName, String schema, String tableName, String triggerName);
47
48 /***
49 * This is called by the data loader each time the table context changes,
50 * giving the dialect an opportunity to do any pre loading work. Only one
51 * table is active at any one point.
52 */
53 public void prepareTableForDataLoad(Table table);
54
55 /***
56 * This is called by the data loader each time the table context changes
57 * away from a table or when the the data loader is closed, giving the
58 * dialect an opportunity to do any post loading work for the given table.
59 */
60 public void cleanupAfterDataLoad(Table table);
61
62 /***
63 * Check to see if the database is configured for symmetric already, or if
64 * it needs configured.
65 *
66 * @return true if configuration tables need to be created.
67 */
68 public boolean doesDatabaseNeedConfigured();
69
70 public void initConfigDb();
71
72 public Platform getPlatform();
73
74 public String getName();
75
76 public String getVersion();
77
78 public int getMajorVersion();
79
80 public int getMinorVersion();
81
82 public String getProductVersion();
83
84 public BinaryEncoding getBinaryEncoding();
85
86 public Table getMetaDataFor(String catalog, String schema, final String tableName, boolean useCache);
87
88 public Table getMetaDataFor(Trigger trigger, boolean useCache);
89
90 public String getTransactionTriggerExpression(Trigger trigger);
91
92 public String createInitalLoadSqlFor(Node node, Trigger trigger);
93
94 public String createPurgeSqlFor(Node node, Trigger trigger, TriggerHistory history);
95
96 public String createCsvDataSql(Trigger trig, String whereClause);
97
98 public String createCsvPrimaryKeySql(Trigger trig, String whereClause);
99
100 public boolean isCharSpacePadded();
101
102 public boolean isCharSpaceTrimmed();
103
104 public boolean isEmptyStringNulled();
105
106 /***
107 * Get the maximum size the name of a trigger can be for the database
108 * platform. If the generated symmetric trigger name is greater than the max
109 * trigger name, symmetric will truncate the name, then log a warning
110 * suggesting that you might want to provide your own name.
111 */
112 public int getMaxTriggerNameLength();
113
114 public boolean storesUpperCaseNamesInCatalog();
115
116 public boolean storesLowerCaseNamesInCatalog();
117
118 public boolean supportsTransactionId();
119
120 public boolean requiresSavepointForFallback();
121
122 public Object createSavepoint();
123
124 public Object createSavepointForFallback();
125
126 public void rollbackToSavepoint(Object savepoint);
127
128 public void releaseSavepoint(Object savepoint);
129
130 public IColumnFilter getDatabaseColumnFilter();
131
132 /***
133 * Implement this if the database has some type of cleanup functionality
134 * that needs to be run when dropping database objects. An example is
135 * Oracle's 'purge recyclebin'
136 */
137 public void purge();
138
139 public SQLErrorCodeSQLExceptionTranslator getSqlErrorTranslator();
140
141 public void disableSyncTriggers();
142
143 public void disableSyncTriggers(String nodeId);
144
145 public void enableSyncTriggers();
146
147 public String getSyncTriggersExpression();
148
149 public String getDefaultSchema();
150
151 public String getDefaultCatalog();
152
153 public int getStreamingResultsFetchSize();
154
155 public JdbcTemplate getJdbcTemplate();
156
157 public String getCreateSymmetricDDL();
158
159 public String getCreateTableXML(Trigger trig);
160
161 public String getCreateTableSQL(Trigger trig);
162
163 public boolean isBlobSyncSupported();
164
165 public boolean isBlobOverrideToBinary();
166
167 public boolean isDateOverrideToTimestamp();
168
169 public boolean isClobSyncSupported();
170
171 /***
172 * An indicator as to whether the ability to override the default
173 * transaction id provided by the dialect can be overridden in the trigger
174 * configuration.
175 */
176 public boolean isTransactionIdOverrideSupported();
177
178 public String getIdentifierQuoteString();
179
180 public void createTables(String xml);
181
182 public String getSelectLastInsertIdSql(String sequenceName);
183
184 public long insertWithGeneratedKey(final String sql, final SequenceIdentifier sequenceId);
185
186 public long insertWithGeneratedKey(final String sql, final SequenceIdentifier sequenceIde,
187 final PreparedStatementCallback psCallback);
188
189 /***
190 * Get the string prepended to the Symmetric configuration tables.
191 *
192 * @return
193 */
194 public String getTablePrefix();
195
196 /***
197 * Give access to the templating mechanism that is used for trigger
198 * creation.
199 */
200 public String replaceTemplateVariables(DataEventType dml, Trigger trigger, TriggerHistory history,
201 String targetString);
202
203 public String getTriggerName(DataEventType dml, String triggerPrefix, int maxTriggerNameLength, Trigger trigger, TriggerHistory hist);
204 }