protected void doOperation(PostgresQueryContext context, PostgresServerSession server) throws IOException {
switch (operation) {
case USE:
{
SetSchemaNode node = (SetSchemaNode)statement;
String schemaName = (node.statementType() == StatementType.SET_SCHEMA_USER ?
server.getProperty("user") : node.getSchemaName());
if (server.getAIS().getSchema(schemaName) != null) {
server.setDefaultSchemaName(schemaName);
}
else {
throw new NoSuchSchemaException(schemaName);
}
}
break;
case BEGIN_TRANSACTION:
server.beginTransaction();
break;
case COMMIT_TRANSACTION:
server.commitTransaction();
break;
case ROLLBACK_TRANSACTION:
server.rollbackTransaction();
break;
case TRANSACTION_ISOLATION:
{
SetTransactionIsolationNode node = (SetTransactionIsolationNode)statement;
IsolationLevel level = node.getIsolationLevel();
switch (level) {
case UNSPECIFIED_ISOLATION_LEVEL:
case SERIALIZABLE_ISOLATION_LEVEL:
break;
default:
if (server.getAttribute(ISOLATION_LEVEL_WARNED) == null) {
context.warnClient(new IsolationLevelIgnoredException(level.getSyntax(), IsolationLevel.SERIALIZABLE_ISOLATION_LEVEL.getSyntax()));
server.setAttribute(ISOLATION_LEVEL_WARNED, Boolean.TRUE);
}
break;
}
}
break;
case TRANSACTION_ACCESS:
{
SetTransactionAccessNode node = (SetTransactionAccessNode)statement;
boolean current = node.isCurrent();
boolean readOnly = (node.getAccessMode() ==
AccessMode.READ_ONLY_ACCESS_MODE);
if (current)
server.setTransactionReadOnly(readOnly);
else
server.setTransactionDefaultReadOnly(readOnly);
}
break;
case SET_CONFIGURATION:
{
SetConfigurationNode node = (SetConfigurationNode)statement;
setVariable (server, node.getVariable(), node.getValue());
}
break;
case SHOW_CONFIGURATION:
{
ShowConfigurationNode node = (ShowConfigurationNode)statement;
showVariable (context, server, node.getVariable());
}
break;
case SET_CONSTRAINTS:
{
SetConstraintsNode node = (SetConstraintsNode)statement;
deferConstraints(server,
node.isAll(), node.getConstraints(), node.isDeferred());
}
break;
default:
throw new UnsupportedSQLException("session control", statement);
}