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
25
26
27
28 public final class TransactionReadOnlyValueProvider implements MySQLSystemVariableValueProvider {
29
30 @Override
31 public String get(final Scope scope, final ConnectionSession connectionSession, final MySQLSystemVariable variable) {
32 if (Scope.GLOBAL == scope) {
33 return variable.getDefaultValue();
34 }
35 return connectionSession.isReadOnly() ? "1" : "0";
36 }
37 }