Skip to content

Commit dcdabfe

Browse files
committed
fix: remove supportsExplain
The `supportsExplain()` method did not actually do anything useful and returned the wrong result. The reason that it was not useful is that: 1. Parsers that do support the EXPLAIN keyword handle these as client-side statements. This means that they never go into the isQuery() method. 2. Parsers that do not support the EXPLAIN keyword cannot do anything with it anyways.
1 parent b5b1509 commit dcdabfe

File tree

3 files changed

+0
-26
lines changed

3 files changed

+0
-26
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractStatementParser.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -617,21 +617,13 @@ public boolean isUpdateStatement(String sql) {
617617
return statementStartsWith(sql, dmlStatements);
618618
}
619619

620-
protected abstract boolean supportsExplain();
621-
622620
private boolean statementStartsWith(String sql, Iterable<String> checkStatements) {
623621
Preconditions.checkNotNull(sql);
624622
Iterator<String> tokens = Splitter.onPattern("\\s+").split(sql).iterator();
625623
if (!tokens.hasNext()) {
626624
return false;
627625
}
628626
String token = tokens.next();
629-
if (supportsExplain() && token.equalsIgnoreCase("EXPLAIN")) {
630-
if (!tokens.hasNext()) {
631-
return false;
632-
}
633-
token = tokens.next();
634-
}
635627
for (String check : checkStatements) {
636628
if (token.equalsIgnoreCase(check)) {
637629
return true;

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/PostgreSQLStatementParser.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ Dialect getDialect() {
4646
return Dialect.POSTGRESQL;
4747
}
4848

49-
/**
50-
* Indicates whether the parser supports the {@code EXPLAIN} clause. The PostgreSQL parser does
51-
* not support it.
52-
*/
53-
@Override
54-
protected boolean supportsExplain() {
55-
return false;
56-
}
57-
5849
@Override
5950
boolean supportsNestedComments() {
6051
return true;

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/SpannerStatementParser.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ Dialect getDialect() {
4646
return Dialect.GOOGLE_STANDARD_SQL;
4747
}
4848

49-
/**
50-
* Indicates whether the parser supports the {@code EXPLAIN} clause. The Spanner parser does
51-
* support it.
52-
*/
53-
@Override
54-
protected boolean supportsExplain() {
55-
return true;
56-
}
57-
5849
@Override
5950
boolean supportsNestedComments() {
6051
return false;

0 commit comments

Comments
 (0)