You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/08/29 00:45:14 UTC
[iotdb] branch master updated: [IOTDB-4236] BackSlash in where clause may cause parse error (#7139)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new be3a931847 [IOTDB-4236] BackSlash in where clause may cause parse error (#7139)
be3a931847 is described below
commit be3a931847e4107c740aef7314086792331114ad
Author: Liao Lanyu <10...@users.noreply.github.com>
AuthorDate: Mon Aug 29 08:45:06 2022 +0800
[IOTDB-4236] BackSlash in where clause may cause parse error (#7139)
---
.../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 6 ++---
.../db/it/IoTDBSyntaxConventionIdentifierIT.java | 29 ++++++++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index 4ab2bccd0a..70f0711a96 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -941,15 +941,15 @@ fragment CN_CHAR
;
fragment DQUOTA_STRING
- : '"' ( '\\'. | '""' | ~('"') )* '"'
+ : '"' ( '\\"' | '""' | ~('"') )* '"'
;
fragment SQUOTA_STRING
- : '\'' ( '\\'. | '\'\'' | ~('\'') )* '\''
+ : '\'' ( '\\\'' | '\'\'' | ~('\'') )* '\''
;
fragment BQUOTA_STRING
- : '`' ( '\\' ~('`') | '``' | ~('`') )* '`'
+ : '`' ( '``' | ~('`') )* '`'
;
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
index 7af57028af..74862440a4 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSyntaxConventionIdentifierIT.java
@@ -407,6 +407,7 @@ public class IoTDBSyntaxConventionIdentifierIT {
statement.execute("CREATE TIMESERIES root.sg1.d1.`1` INT32");
statement.execute("CREATE TIMESERIES root.sg1.d1.`a.b` INT32");
statement.execute("CREATE TIMESERIES root.sg1.d1.`a.``b` INT32");
+ statement.execute("CREATE TIMESERIES root.sg1.d1.text TEXT");
int pointCnt = 3;
for (int i = 0; i < pointCnt; i++) {
statement.execute(
@@ -484,6 +485,34 @@ public class IoTDBSyntaxConventionIdentifierIT {
}
Assert.assertEquals(1, cnt);
}
+
+ cnt = 0;
+ try (ResultSet resultSet =
+ statement.executeQuery("SELECT text FROM root.sg1.d1 where text = '\'")) {
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(0, cnt);
+ }
+
+ cnt = 0;
+ try (ResultSet resultSet =
+ statement.executeQuery(
+ "SELECT text FROM root.sg1.d1 where text = '\' or text = 'asdf'")) {
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(0, cnt);
+ }
+
+ cnt = 0;
+ try (ResultSet resultSet =
+ statement.executeQuery("SELECT text FROM root.sg1.d1 where text = '\\'")) {
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(0, cnt);
+ }
} catch (SQLException e) {
e.printStackTrace();
fail();