Fix bug using null as measurement name#11742
Merged
MarcosZyk merged 17 commits intoapache:masterfrom Dec 24, 2023
Merged
Conversation
MarcosZyk
reviewed
Dec 19, 2023
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
Outdated
Show resolved
Hide resolved
Contributor
|
Please add some IT to validate this modification. |
SzyWilliam
pushed a commit
to SzyWilliam/iotdb
that referenced
this pull request
Nov 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This modification is based on the bug identified in timechoDB—TIMECHO-483
Issue Description
The IoTDB's cli session can run normally when receiving null as a template sequence name. The SQL test is as follows: create schema template nullt aligned (null TEXT, s_status BOOLEAN);
However, users found that when adding a measurement node with null as the measurement name to an existing template null_t using IoTDB's Java native interface, an NPE occurred during createSchemaTemplate by the session.
Cause Description:
This is because the cli session of IoTDB processes the input SQL in the ASTVisitor by using parseNodeNameWithoutWildCard to handle the measurement name part as a String. Correspondingly, the Java native interface creates a measurementNode with null as the name, and at this point, the name as a String is assigned as null. Subsequently, the null value will be continuously passed to the server, but the measurement name cannot be null, resulting in this error.
Issue Fix:
This problem fix is based on the principle that the measurement name cannot be null, and an error will be given for any occurrence of null received by the API.
Regarding the problem encountered in the Java native interface, considering that similar issues might exist in other language native interfaces, modifications were made to the server's code. In the StatementGenerator within CreateSchemaTemplateStatement, if the measurement name read is null, an error will be thrown.