Skip to content

[IOTDB-3168][To rel/0.13] Fix the path with * could be executed successfully when inserting#6051

Merged
HTHou merged 4 commits intoapache:rel/0.13from
23931017wu:IOTDB-3168
May 31, 2022
Merged

[IOTDB-3168][To rel/0.13] Fix the path with * could be executed successfully when inserting#6051
HTHou merged 4 commits intoapache:rel/0.13from
23931017wu:IOTDB-3168

Conversation

@23931017wu
Copy link
Copy Markdown
Contributor

By adding a function of "checkNameFormatIfHasstar" to "MetaFormatUnit.java". Introduce the "checkNameFormatIfHasstar" in "checkTimeseries".

Create a new function in bb

/** check whether the node name uses "*" correctly /
private static void checkNameFormatIfHasstar(String name) throws MetadataException {
if (!((name.startsWith("'") && name.endsWith("'"))
|| (name.startsWith(""") && name.endsWith(""")))
&& name.contains("
")

) {
  throw new MetadataException(String.format("%s is an illegal name.", name));
}

}

Content2 ...

/** check whether the given path is well formatted */
public static void checkTimeseries(PartialPath timeseries) throws IllegalPathException {
try {
checkCharacters(timeseries.getFullPath());
} catch (MetadataException e) {
throw new IllegalPathException(timeseries.getFullPath(), e.getMessage());
}
for (String name : timeseries.getNodes()) {
try {
checkReservedNames(name);
checkNameFormatIfHasstar(name);
checkNameFormat(name);
} catch (MetadataException e) {
throw new IllegalPathException(timeseries.getFullPath(), e.getMessage());
}
}
}

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

for (String name : timeseries.getNodes()) {
try {
checkReservedNames(name);
checkNameFormatIfHasstar(name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
checkNameFormatIfHasstar(name);
checkNameFormatIfHasStar(name);

// set recover config, avoid creating deleted time series when recovering wal
boolean prevIsAutoCreateSchemaEnabled = config.isAutoCreateSchemaEnabled();
config.setAutoCreateSchemaEnabled(false);
config.setAutoCreateSchemaEnabled(true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change the mode? We need to disable auto create when recover.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it.The state was changed to find the error.


/** check whether the node name uses "*" correctly */
private static void checkNameFormatIfHasstar(String name) throws MetadataException {
if (!((name.startsWith("'") && name.endsWith("'"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use backquote, not the quotation

@mychaow mychaow changed the title [IOTDB-3168] Fix the path with * could be executed successfully when inserting [IOTDB-3168][To rel/0.13] Fix the path with * could be executed successfully when inserting May 30, 2022
@mychaow mychaow requested a review from HTHou May 30, 2022 07:54
Copy link
Copy Markdown
Contributor

@HTHou HTHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Consider adding some IT cases?

@23931017wu
Copy link
Copy Markdown
Contributor Author

Modified running result:
image

IoTDB> create timeseries root.test..a.b
create timeseries root.test.
.a.b
Msg: 401: Error occurred while parsing SQL to physical plan: line 1:28 mismatched input '' expecting {STRING_LITERAL, INTEGER_LITERAL, ID, QUTOED_ID_IN_NODE_NAME}
IoTDB> insert into root.test.
.a(timestamp, b) values(1509465600000, true)
insert into root.test..a(timestamp, b) values(1509465600000, true)
Msg: 313: failed to insert measurements [b] caused by root.test.
.a.b is not a legal path, because * is an illegal name.
IoTDB> show timeseries root.test.**
show timeseries root.test.**
+----------+-----+-------------+--------+--------+-----------+----+----------+
|timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
+----------+-----+-------------+--------+--------+-----------+----+----------+
+----------+-----+-------------+--------+--------+-----------+----+----------+
Empty set.
It costs 0.025s
IoTDB>

@mychaow mychaow requested a review from HTHou May 31, 2022 05:07
@mychaow
Copy link
Copy Markdown
Member

mychaow commented May 31, 2022

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants