22
22
import lombok .NoArgsConstructor ;
23
23
import org .apache .shardingsphere .distsql .statement .DistSQLStatement ;
24
24
import org .apache .shardingsphere .distsql .statement .ral .RALStatement ;
25
+ import org .apache .shardingsphere .distsql .statement .rdl .resource .unit .type .AlterStorageUnitStatement ;
25
26
import org .apache .shardingsphere .distsql .statement .rdl .resource .unit .type .RegisterStorageUnitStatement ;
26
27
import org .apache .shardingsphere .distsql .statement .rdl .resource .unit .type .UnregisterStorageUnitStatement ;
27
28
import org .apache .shardingsphere .distsql .statement .rdl .rule .database .type .AlterRuleStatement ;
28
29
import org .apache .shardingsphere .distsql .statement .rdl .rule .database .type .CreateRuleStatement ;
29
30
import org .apache .shardingsphere .distsql .statement .rdl .rule .database .type .DropRuleStatement ;
31
+ import org .apache .shardingsphere .distsql .statement .rdl .rule .global .GlobalRuleDefinitionStatement ;
30
32
import org .apache .shardingsphere .distsql .statement .rql .resource .ShowStorageUnitsStatement ;
31
33
import org .apache .shardingsphere .distsql .statement .rql .rule .database .ShowDatabaseRulesStatement ;
34
+ import org .apache .shardingsphere .distsql .statement .rql .rule .global .ShowGlobalRulesStatement ;
32
35
import org .apache .shardingsphere .distsql .statement .rul .sql .FormatStatement ;
33
36
import org .apache .shardingsphere .distsql .statement .rul .sql .ParseStatement ;
34
37
import org .apache .shardingsphere .distsql .statement .rul .sql .PreviewStatement ;
35
38
import org .apache .shardingsphere .sql .parser .statement .core .statement .SQLStatement ;
36
39
import org .apache .shardingsphere .sql .parser .statement .core .statement .dcl .DCLStatement ;
37
40
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .AlterDatabaseStatement ;
41
+ import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .AlterIndexStatement ;
38
42
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .AlterTableStatement ;
39
43
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .CreateDatabaseStatement ;
40
44
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .CreateFunctionStatement ;
45
+ import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .CreateIndexStatement ;
41
46
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .CreateTableStatement ;
42
47
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .DDLStatement ;
43
48
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .DropDatabaseStatement ;
49
+ import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .DropIndexStatement ;
44
50
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .DropTableStatement ;
45
51
import org .apache .shardingsphere .sql .parser .statement .core .statement .ddl .TruncateStatement ;
46
52
import org .apache .shardingsphere .sql .parser .statement .core .statement .dml .DMLStatement ;
@@ -102,7 +108,7 @@ private static ACLOperation extractDDL(final DDLStatement sqlStatement) {
102
108
if (sqlStatement instanceof AlterDatabaseStatement ) {
103
109
return ACLOperation .ALTER_ANY_DATABASE ;
104
110
}
105
- if (sqlStatement instanceof AlterTableStatement ) {
111
+ if (sqlStatement instanceof AlterTableStatement || isIndexDDLStatement ( sqlStatement ) ) {
106
112
return ACLOperation .ALTER ;
107
113
}
108
114
if (sqlStatement instanceof CreateFunctionStatement ) {
@@ -114,6 +120,10 @@ private static ACLOperation extractDDL(final DDLStatement sqlStatement) {
114
120
return ACLOperation .UNKNOWN ;
115
121
}
116
122
123
+ private static boolean isIndexDDLStatement (final SQLStatement sqlStatement ) {
124
+ return sqlStatement instanceof CreateIndexStatement || sqlStatement instanceof AlterIndexStatement || sqlStatement instanceof DropIndexStatement ;
125
+ }
126
+
117
127
private static ACLOperation extractDistSQL (final DistSQLStatement sqlStatement ) {
118
128
if (sqlStatement instanceof CreateRuleStatement ) {
119
129
return ACLOperation .CREATE_RULE ;
@@ -127,7 +137,7 @@ private static ACLOperation extractDistSQL(final DistSQLStatement sqlStatement)
127
137
if (sqlStatement instanceof ShowDatabaseRulesStatement || sqlStatement instanceof ShowStorageUnitsStatement ) {
128
138
return ACLOperation .SHOW_RULES ;
129
139
}
130
- if (sqlStatement instanceof RegisterStorageUnitStatement ) {
140
+ if (sqlStatement instanceof RegisterStorageUnitStatement || sqlStatement instanceof AlterStorageUnitStatement ) {
131
141
return ACLOperation .REGISTER ;
132
142
}
133
143
if (sqlStatement instanceof UnregisterStorageUnitStatement ) {
@@ -145,7 +155,7 @@ private static ACLOperation extractDistSQL(final DistSQLStatement sqlStatement)
145
155
if (sqlStatement instanceof ParseStatement ) {
146
156
return ACLOperation .PARSE ;
147
157
}
148
- if (sqlStatement instanceof RALStatement ) {
158
+ if (sqlStatement instanceof RALStatement || sqlStatement instanceof ShowGlobalRulesStatement || sqlStatement instanceof GlobalRuleDefinitionStatement ) {
149
159
return ACLOperation .RAL_OPERATE ;
150
160
}
151
161
return ACLOperation .UNKNOWN ;
0 commit comments