Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SHOW VARIABLES LIKE 'lower_case_%' #12027

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.sql.SQLException;
import java.util.Collection;
import java.util.Optional;

/**
* Database backend handler with unicast schema.
Expand All @@ -49,20 +50,30 @@ public final class UnicastDatabaseBackendHandler implements DatabaseBackendHandl

@Override
public ResponseHeader execute() throws SQLException {
String schemaName = null == backendConnection.getSchemaName() ? getFirstSchemaName() : backendConnection.getSchemaName();
String originSchema = backendConnection.getSchemaName();
String schemaName = null == originSchema ? getFirstSchemaName() : originSchema;
if (!ProxyContext.getInstance().getMetaData(schemaName).isComplete()) {
throw new RuleNotExistedException();
}
databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, backendConnection);
return databaseCommunicationEngine.execute();
try {
backendConnection.setCurrentSchema(schemaName);
databaseCommunicationEngine = databaseCommunicationEngineFactory.newTextProtocolInstance(sqlStatementContext, sql, backendConnection);
return databaseCommunicationEngine.execute();
} finally {
backendConnection.setCurrentSchema(originSchema);
}
}

private String getFirstSchemaName() {
Collection<String> schemaNames = ProxyContext.getInstance().getAllSchemaNames();
if (schemaNames.isEmpty()) {
throw new NoDatabaseSelectedException();
}
return schemaNames.iterator().next();
Optional<String> result = schemaNames.stream().filter(each -> ProxyContext.getInstance().getMetaData(each).isComplete()).findFirst();
if (!result.isPresent()) {
throw new RuleNotExistedException();
}
return result.get();
}

@Override
Expand Down