1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor.sysvar.provider;
19
20 import org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor.sysvar.Scope;
21 import org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor.sysvar.MySQLSystemVariable;
22 import org.apache.shardingsphere.proxy.backend.mysql.handler.admin.executor.sysvar.MySQLSystemVariableValueProvider;
23 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
24 import org.apache.shardingsphere.sql.parser.sql.common.enums.TransactionIsolationLevel;
25
26 import java.util.Optional;
27
28
29
30
31 public final class TransactionIsolationValueProvider implements MySQLSystemVariableValueProvider {
32
33 @Override
34 public String get(final Scope scope, final ConnectionSession connectionSession, final MySQLSystemVariable variable) {
35 return Scope.GLOBAL == scope ? variable.getDefaultValue()
36 : Optional.ofNullable(connectionSession.getIsolationLevel()).map(TransactionIsolationLevel::getIsolationLevel).orElseGet(TransactionIsolationLevel.REPEATABLE_READ::getIsolationLevel);
37 }
38 }