This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ad62c75 fix parse error when 'N' in expression (#7623)
ad62c75 is described below
commit ad62c755ec99dbcf8dc99f232297c1fb319c4382
Author: JingShang Lu <[email protected]>
AuthorDate: Mon Sep 28 11:00:15 2020 +0800
fix parse error when 'N' in expression (#7623)
---
.../src/main/antlr4/imports/mysql/DDLStatement.g4 | 6 +++---
.../src/main/antlr4/imports/mysql/Literals.g4 | 4 ----
.../src/main/resources/case/dml/select.xml | 7 +++++++
.../src/main/resources/sql/supported/dml/select.xml | 1 +
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
index a62871a..34b0a00 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/DDLStatement.g4
@@ -112,7 +112,7 @@ alterDatabase
createDatabaseSpecification_
: DEFAULT? (CHARACTER SET | CHARSET) EQ_? characterSetName_
| DEFAULT? COLLATE EQ_? collationName_
- | DEFAULT? ENCRYPTION EQ_? Y_N_
+ | DEFAULT? ENCRYPTION EQ_? y_or_n=STRING_
;
alterDatabaseSpecification_
@@ -234,7 +234,7 @@ createTablespaceInnodb
: CREATE (UNDO)? TABLESPACE identifier
ADD DATAFILE STRING_
(FILE_BLOCK_SIZE EQ_ fileSizeLiteral_)?
- (ENCRYPTION EQ_ Y_N_ )?
+ (ENCRYPTION EQ_ y_or_n=STRING_)?
(ENGINE EQ_? STRING_)?
;
@@ -262,7 +262,7 @@ alterTablespaceNdb
alterTablespaceInnodb
: ALTER UNDO? TABLESPACE identifier
- (SET (ACTIVE | INACTIVE))? (ENCRYPTION EQ_? Y_N_)
+ (SET (ACTIVE | INACTIVE))? (ENCRYPTION EQ_? y_or_n=STRING_)
(RENAME TO identifier)?
(ENGINE EQ_? identifier)?
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
index 28121fe..60f3ebe 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/antlr4/imports/mysql/Literals.g4
@@ -36,10 +36,6 @@ IDENTIFIER_
| BQ_ ~'`'+ BQ_
;
-Y_N_
- : SQ_ ('Y' | 'N') SQ_
- ;
-
STRING_
: (DQ_ ( '\\'. | '""' | ~('"'| '\\') )* DQ_)
| (SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
index 86a4e82..e01ac58 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dml/select.xml
@@ -428,6 +428,13 @@
</order-by>
</select>
+ <select sql-case-id="select_with_N_string_in_expression">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7"/>
+ </projections>
+ <where></where>
+ </select>
+
<select sql-case-id="select_count_like_concat" parameters="'init', 1, 2,
9, 10">
<table-reference>
<table-factor>
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
index 000b5c2..0028f64 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dml/select.xml
@@ -31,6 +31,7 @@
<sql-case id="select_comparison_symbol_with_single_table" value="SELECT *
FROM t_order WHERE user_id >= ? AND user_id <= ? AND order_id >= ? AND
order_id <= ? ORDER BY user_id, order_id" />
<sql-case id="select_equal_with_same_sharding_column" value="SELECT * FROM
t_order WHERE order_id = ? AND order_id = ?" />
<sql-case id="select_in_with_same_sharding_column" value="SELECT * FROM
t_order WHERE order_id IN (?, ?) AND order_id IN (?, ?) ORDER BY order_id" />
+ <sql-case id="select_with_N_string_in_expression" value="SELECT * FROM
t_order WHERE is_deleted = 'N'" />
<sql-case id="select_count_like_concat" value="SELECT count(0) as
orders_count FROM t_order o WHERE o.status LIKE CONCAT('%%', ?, '%%') AND
o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ?" />
<sql-case id="select_like_with_single_quotes" value="select id from admin
where fullname like 'a%'" db-types="MySQL"/>
<sql-case id="select_count_tilde_concat" value="SELECT count(0) as
orders_count FROM t_order o WHERE o.status ~~ CONCAT('%%', ?, '%%') AND
o.user_id IN (?, ?) AND o.order_id BETWEEN ? AND ?" db-types="PostgreSQL" />