Skip to content

Commit 5854bab

Browse files
CaideyipiJackieTien97
authored andcommitted
Solved the compilation problem
1 parent 09d526c commit 5854bab

File tree

7 files changed

+51
-38
lines changed

7 files changed

+51
-38
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAlterEncodingCompressorIT.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ public void alterEncodingAndCompressorTest() throws Exception {
156156
e.getMessage());
157157
}
158158

159-
try {
160-
statement.execute(
161-
"alter timeSeries root.vehicle.wind.a, root.__audit.** set STORAGE_PROPERTIES encoding=PLAIN, compressor=LZMA2");
162-
fail();
163-
} catch (final SQLException e) {
164-
Assert.assertEquals(
165-
"803: 'AUDIT' permission is needed to alter the encoding and compressor of database root.__audit",
166-
e.getMessage());
167-
}
168-
169159
try {
170160
statement.execute(
171161
"alter timeSeries if permitted root.vehicle.**, root.__audit.** set STORAGE_PROPERTIES encoding=GORILLA, compressor=GZIP");

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/treemodel/manual/IoTDBPipeInclusionIT.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ public void testPureSchemaInclusion() throws Exception {
7777
if (!TestUtils.tryExecuteNonQueriesWithRetry(
7878
senderEnv,
7979
Arrays.asList(
80-
// TODO: add database creation after the database auto creating on receiver can be
81-
// banned
80+
"create database root.ln",
8281
"create timeSeries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN",
8382
"ALTER timeSeries root.ln.wf01.wt01.status ADD TAGS tag3=v3",
8483
"ALTER timeSeries root.ln.wf01.wt01.status ADD ATTRIBUTES attr4=v4"),
8584
null)) {
86-
return;
85+
return;
8786
}
8887

8988
TestUtils.assertDataEventuallyOnEnv(
@@ -95,10 +94,10 @@ public void testPureSchemaInclusion() throws Exception {
9594

9695
if (!TestUtils.tryExecuteNonQueriesWithRetry(
9796
senderEnv,
98-
Arrays.asList(
99-
"ALTER timeSeries root.** set STORAGE_PROPERTIES compressor=ZSTD",
100-
"insert into root.ln.wf01.wt01(time, status) values(now(), false)",
101-
"flush"),
97+
Arrays.asList(
98+
"ALTER timeSeries root.** set STORAGE_PROPERTIES compressor=ZSTD",
99+
"insert into root.ln.wf01.wt01(time, status) values(now(), false)",
100+
"flush"),
102101
null)) {
103102
return;
104103
}
@@ -150,8 +149,7 @@ public void testPureSchemaInclusionWithMultiplePattern() throws Exception {
150149
if (!TestUtils.tryExecuteNonQueriesWithRetry(
151150
senderEnv,
152151
Arrays.asList(
153-
// TODO: add database creation after the database auto creating on receiver can be
154-
// banned
152+
"create timeseries root.ln",
155153
"create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN",
156154
"ALTER timeseries root.ln.wf01.wt01.status ADD TAGS tag3=v3",
157155
"ALTER timeseries root.ln.wf01.wt01.status ADD ATTRIBUTES attr4=v4"),

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/receiver/protocol/IoTDBConfigNodeReceiver.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.apache.iotdb.commons.pipe.sink.payload.thrift.request.PipeTransferFileSealReqV1;
3838
import org.apache.iotdb.commons.pipe.sink.payload.thrift.request.PipeTransferFileSealReqV2;
3939
import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
40-
import org.apache.iotdb.commons.schema.table.Audit;
4140
import org.apache.iotdb.commons.schema.table.TreeViewSchema;
4241
import org.apache.iotdb.commons.schema.table.TsTable;
4342
import org.apache.iotdb.commons.schema.table.column.TsTableColumnSchema;
@@ -345,23 +344,13 @@ private TSStatus checkPermission(final ConfigPhysicalPlan plan) throws IOExcepti
345344
.getStatus();
346345
case PipeAlterEncodingCompressor:
347346
// Judge here in the future
348-
if (configManager
349-
.checkUserPrivileges(username, new PrivilegeUnion(PrivilegeType.AUDIT))
350-
.getStatus()
351-
.getCode()
352-
!= TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
353-
((PipeAlterEncodingCompressorPlan) plan).setMayAlterAudit(false);
354-
}
355347
if (skipIfNoPrivileges.get()) {
356348
final PathPatternTree pathPatternTree =
357349
PathPatternTree.deserialize(
358350
ByteBuffer.wrap(
359351
configManager
360352
.fetchAuthizedPatternTree(username, PrivilegeType.WRITE_SCHEMA.ordinal())
361353
.getPathPatternTree()));
362-
if (((PipeAlterEncodingCompressorPlan) plan).isMayAlterAudit()) {
363-
pathPatternTree.appendPathPattern(Audit.TREE_MODEL_AUDIT_DATABASE_PATH_PATTERN, true);
364-
}
365354
((PipeAlterEncodingCompressorPlan) plan)
366355
.setPatternTreeBytes(
367356
PathPatternTreeUtils.intersectWithFullPathPrefixTree(

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/pipe/source/PipeConfigPhysicalPlanTreePatternParseVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public Optional<ConfigPhysicalPlan> visitPipeDeleteLogicalView(
254254
@Override
255255
public Optional<ConfigPhysicalPlan> visitPipeAlterEncodingCompressor(
256256
final PipeAlterEncodingCompressorPlan pipeAlterEncodingCompressorPlan,
257-
final UnionIoTDBTreePattern pattern) {
257+
final IoTDBTreePattern pattern) {
258258
try {
259259
final PathPatternTree intersectedTree =
260260
pattern.getIntersection(

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/AlterEncodingCompressorProcedure.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ public class AlterEncodingCompressorProcedure
6969
private boolean ifExists;
7070
private byte encoding;
7171
private byte compressor;
72-
private boolean mayAlterAudit;
72+
73+
// Reserved for potential upgrading
74+
private boolean mayAlterAudit = false;
7375

7476
private transient ByteBuffer patternTreeBytes;
7577
private transient String requestMessage;
@@ -149,7 +151,7 @@ protected Flow executeFromState(
149151

150152
private boolean alterEncodingCompressorInSchemaRegion(final ConfigNodeProcedureEnv env) {
151153
final Map<TConsensusGroupId, TRegionReplicaSet> relatedSchemaRegionGroup =
152-
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, mayAlterAudit);
154+
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree);
153155

154156
if (relatedSchemaRegionGroup.isEmpty()) {
155157
if (!ifExists) {
@@ -167,7 +169,7 @@ private boolean alterEncodingCompressorInSchemaRegion(final ConfigNodeProcedureE
167169
final DataNodeTSStatusTaskExecutor<TAlterEncodingCompressorReq> alterEncodingCompressorTask =
168170
new DataNodeTSStatusTaskExecutor<TAlterEncodingCompressorReq>(
169171
env,
170-
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree, mayAlterAudit),
172+
env.getConfigManager().getRelatedSchemaRegionGroup(patternTree),
171173
false,
172174
CnToDnAsyncRequestType.ALTER_ENCODING_COMPRESSOR,
173175
((dataNodeLocation, consensusGroupIdList) ->
@@ -237,9 +239,9 @@ private void collectPayload4Pipe(final ConfigNodeProcedureEnv env) {
237239
isGeneratedByPipe
238240
? new PipeEnrichedPlan(
239241
new PipeAlterEncodingCompressorPlan(
240-
patternTreeBytes, encoding, compressor, mayAlterAudit))
242+
patternTreeBytes, encoding, compressor, false))
241243
: new PipeAlterEncodingCompressorPlan(
242-
patternTreeBytes, encoding, compressor, mayAlterAudit));
244+
patternTreeBytes, encoding, compressor, false));
243245
} catch (final ConsensusException e) {
244246
LOGGER.warn(ClusterManager.CONSENSUS_WRITE_ERROR, e);
245247
result = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
@@ -285,7 +287,7 @@ public void serialize(final DataOutputStream stream) throws IOException {
285287
ReadWriteIOUtils.write(ifExists, stream);
286288
ReadWriteIOUtils.write(encoding, stream);
287289
ReadWriteIOUtils.write(compressor, stream);
288-
ReadWriteIOUtils.write(mayAlterAudit, stream);
290+
ReadWriteIOUtils.write(false, stream);
289291
}
290292

291293
@Override

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/AnalyzeVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3172,7 +3172,7 @@ public Analysis visitShowTimeSeries(
31723172
}
31733173

31743174
@Override
3175-
public Analysis visitShowStorageGroup(
3175+
public Analysis visitShowDatabase(
31763176
ShowDatabaseStatement showDatabaseStatement, MPPQueryContext context) {
31773177
Analysis analysis = new Analysis();
31783178
analysis.setRealStatement(showDatabaseStatement);

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/AlterEncodingCompressorStatement.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,38 @@
1919

2020
package org.apache.iotdb.db.queryengine.plan.statement.metadata;
2121

22+
import org.apache.iotdb.common.rpc.thrift.TSStatus;
23+
import org.apache.iotdb.commons.auth.AuthException;
24+
import org.apache.iotdb.commons.auth.entity.PrivilegeType;
2225
import org.apache.iotdb.commons.path.PartialPath;
2326
import org.apache.iotdb.commons.path.PathPatternTree;
27+
import org.apache.iotdb.commons.path.PathPatternTreeUtils;
28+
import org.apache.iotdb.commons.utils.StatusUtils;
29+
import org.apache.iotdb.db.auth.AuthorityChecker;
2430
import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
2531
import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement;
2632
import org.apache.iotdb.db.queryengine.plan.statement.Statement;
2733
import org.apache.iotdb.db.queryengine.plan.statement.StatementType;
2834
import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor;
35+
import org.apache.iotdb.rpc.TSStatusCode;
2936

3037
import org.apache.tsfile.file.metadata.enums.CompressionType;
3138
import org.apache.tsfile.file.metadata.enums.TSEncoding;
3239

3340
import java.util.List;
3441
import java.util.Objects;
3542

43+
import static org.apache.iotdb.db.auth.AuthorityChecker.getAuthorizedPathTree;
44+
3645
public class AlterEncodingCompressorStatement extends Statement implements IConfigStatement {
3746

3847
private PathPatternTree patternTree;
3948
private final TSEncoding encoding;
4049
private final CompressionType compressor;
4150
private final boolean ifExists;
4251
private final boolean ifPermitted;
52+
53+
// Reserved for upgrading
4354
private boolean withAudit = false;
4455

4556
public AlterEncodingCompressorStatement(
@@ -109,6 +120,29 @@ public boolean equals(final Object obj) {
109120
&& Objects.equals(this.ifPermitted, that.ifPermitted);
110121
}
111122

123+
@Override
124+
public TSStatus checkPermissionBeforeProcess(String userName) {
125+
if (AuthorityChecker.SUPER_USER.equals(userName)) {
126+
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
127+
}
128+
if (ifPermitted) {
129+
try {
130+
final PathPatternTree authTree =
131+
getAuthorizedPathTree(userName, PrivilegeType.WRITE_SCHEMA);
132+
setPatternTree(
133+
PathPatternTreeUtils.intersectWithFullPathPrefixTree(getPatternTree(), authTree));
134+
return StatusUtils.OK;
135+
} catch (final AuthException e) {
136+
return new TSStatus(e.getCode().getStatusCode());
137+
}
138+
}
139+
return AuthorityChecker.getTSStatus(
140+
AuthorityChecker.checkFullPathOrPatternListPermission(
141+
userName, getPaths(), PrivilegeType.WRITE_SCHEMA),
142+
getPaths(),
143+
PrivilegeType.WRITE_SCHEMA);
144+
}
145+
112146
@Override
113147
public int hashCode() {
114148
return Objects.hash(patternTree, encoding, compressor, ifExists, ifPermitted);

0 commit comments

Comments
 (0)