-
Notifications
You must be signed in to change notification settings - Fork 397
Expand file tree
/
Copy pathSQLProviderAdapter.java
More file actions
44 lines (38 loc) · 1.53 KB
/
SQLProviderAdapter.java
File metadata and controls
44 lines (38 loc) · 1.53 KB
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
package sqlancer;
import java.util.List;
import sqlancer.common.log.LoggableFactory;
import sqlancer.common.log.SQLLoggableFactory;
import sqlancer.common.query.SQLQueryAdapter;
import sqlancer.common.schema.AbstractSchema;
import sqlancer.common.schema.AbstractTable;
public abstract class SQLProviderAdapter<G extends SQLGlobalState<O, ? extends AbstractSchema<G, ?>>, O extends DBMSSpecificOptions<? extends OracleFactory<G>>>
extends ProviderAdapter<G, O, SQLConnection> {
protected SQLProviderAdapter(Class<G> globalClass, Class<O> optionClass) {
super(globalClass, optionClass);
}
@Override
public LoggableFactory getLoggableFactory() {
return new SQLLoggableFactory();
}
@Override
protected void checkViewsAreValid(G globalState) {
List<? extends AbstractTable<?, ?, ?>> views = globalState.getSchema().getViews();
for (AbstractTable<?, ?, ?> view : views) {
SQLQueryAdapter q = new SQLQueryAdapter("SELECT 1 FROM " + view.getName() + " LIMIT 1");
try {
if (!q.execute(globalState)) {
dropView(globalState, view.getName());
}
} catch (Throwable t) {
dropView(globalState, view.getName());
}
}
}
private void dropView(G globalState, String viewName) {
try {
globalState.executeStatement(new SQLQueryAdapter("DROP VIEW " + viewName, true));
} catch (Throwable t2) {
throw new IgnoreMeException();
}
}
}