Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,13 @@ public void isDatabaseNameValid(final String databaseName, final boolean isTable
throws MetadataException {
databaseReadWriteLock.readLock().lock();
try {
(isTableModel ? tableModelMTree : treeModelMTree)
.checkDatabaseAlreadySet(getQualifiedDatabasePartialPath(databaseName));
final PartialPath databasePath = getQualifiedDatabasePartialPath(databaseName);
for (final String node : databasePath.getNodes()) {
if (node.isEmpty()) {
throw new IllegalPathException(databaseName);
}
}
(isTableModel ? tableModelMTree : treeModelMTree).checkDatabaseAlreadySet(databasePath);
} finally {
databaseReadWriteLock.readLock().unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.iotdb.confignode.persistence.schema;

import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.schema.table.TsTable;
import org.apache.iotdb.commons.schema.template.Template;
Expand All @@ -40,6 +41,7 @@
import org.apache.iotdb.confignode.consensus.response.template.TemplateSetInfoResp;
import org.apache.iotdb.confignode.rpc.thrift.TDatabaseSchema;
import org.apache.iotdb.db.schemaengine.template.TemplateInternalRPCUtil;
import org.apache.iotdb.rpc.TSStatusCode;

import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.external.commons.io.FileUtils;
Expand Down Expand Up @@ -162,6 +164,21 @@ public void testTableStatisticsRollbackAndDatabaseRecreation() {
Assert.assertEquals(0, statistics.getBaseTableNum(database));
}

@Test
public void testDatabasePathWithEmptyNodeIsInvalid() throws MetadataException {
clusterSchemaInfo.isDatabaseNameValid("root.database", false);
clusterSchemaInfo.isDatabaseNameValid("database", true);

for (final String database : Arrays.asList("", "root.", "root..database", "root.database.")) {
try {
clusterSchemaInfo.isDatabaseNameValid(database, database.isEmpty());
Assert.fail("Expected IllegalPathException for database: " + database);
} catch (final IllegalPathException e) {
Assert.assertEquals(TSStatusCode.ILLEGAL_PATH.getStatusCode(), e.getErrorCode());
}
}
}

@Test
public void testSetTemplate() throws IllegalPathException {
String templateName = "template_name";
Expand Down
Loading