Skip to content

Commit fd352ce

Browse files
committed
pattern-priv
1 parent b2b84f3 commit fd352ce

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,11 @@ public Optional<ConfigPhysicalPlan> visitPipeDeactivateTemplate(
332332
for (final PartialPath intersectedPath :
333333
getAllIntersectedPatterns(
334334
templateEntry.getKey(), userName, pipeDeactivateTemplatePlan)) {
335-
newTemplateSetInfo.put(intersectedPath, templateEntry.getValue());
335+
// root.db.device2.measurement -> root.db.device.** = root.db
336+
// Note that we cannot take this circumstance into account
337+
if (intersectedPath.getNodeLength() == templateEntry.getKey().getNodeLength()) {
338+
newTemplateSetInfo.put(intersectedPath, templateEntry.getValue());
339+
}
336340
}
337341
}
338342
return !newTemplateSetInfo.isEmpty()
@@ -356,7 +360,7 @@ public Optional<ConfigPhysicalPlan> visitTTL(final SetTTLPlan setTTLPlan, final
356360
new PartialPath(setTTLPlan.getPathPattern()), userName, setTTLPlan);
357361
// The intersectionList is either a singleton list or an empty list, because the pipe
358362
// pattern and TTL path are each either a prefix path or a full path
359-
return !paths.isEmpty()
363+
return !paths.isEmpty() && paths.get(0).getNodeLength() == setTTLPlan.getPathPattern().length
360364
? Optional.of(new SetTTLPlan(paths.get(0).getNodes(), setTTLPlan.getTTL()))
361365
: Optional.empty();
362366
} catch (final AuthException e) {

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/manager/pipe/source/PipeConfigTreePrivilegeParseVisitorTest.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ public void testPatternRelatedPrivilege() throws IOException {
158158
new PartialPath(new String[] {"root", "db", "device", "measurement"});
159159
final PartialPath unmatchedPath =
160160
new PartialPath(new String[] {"root", "db", "device2", "measurement"});
161+
final PartialPath intersectPath =
162+
new PartialPath(new String[] {"root", "*", "device", "measurement"});
161163

162164
final PathPatternTree originalTree = new PathPatternTree();
163165
originalTree.appendPathPattern(matchedPath);
@@ -198,10 +200,7 @@ public void testPatternRelatedPrivilege() throws IOException {
198200
new PipeDeactivateTemplatePlan(
199201
new HashMap<PartialPath, List<Template>>() {
200202
{
201-
put(
202-
new PartialPath(
203-
new String[] {"root", "*", "device", "measurement"}),
204-
Collections.singletonList(new Template()));
203+
put(intersectPath, Collections.singletonList(new Template()));
205204
put(unmatchedPath, Collections.singletonList(new Template()));
206205
}
207206
}),
@@ -210,11 +209,15 @@ public void testPatternRelatedPrivilege() throws IOException {
210209
.getTemplateSetInfo()
211210
.keySet());
212211

213-
Assert.assertTrue(
214-
skipVisitor
215-
.visitTTL(
216-
new SetTTLPlan(new String[] {"root", "db", "device", "measurement"}, 100), null)
217-
.isPresent());
212+
Assert.assertArrayEquals(
213+
new String[] {"root", "db", "device", "measurement"},
214+
((SetTTLPlan)
215+
skipVisitor
216+
.visitTTL(
217+
new SetTTLPlan(new String[] {"root", "*", "device", "measurement"}, 100),
218+
null)
219+
.get())
220+
.getPathPattern());
218221
Assert.assertFalse(
219222
skipVisitor
220223
.visitTTL(

0 commit comments

Comments
 (0)