You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/09/14 03:05:59 UTC
[shardingsphere] branch master updated: support PostgreSQL set
statement parse number value
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 3ce5206 support PostgreSQL set statement parse number value
new 9daf6ad Merge pull request #7426 from strongduanmu/issue-7421-dev
3ce5206 is described below
commit 3ce52063ded63c28524db61e0d38f602725a30ff
Author: strongduanmu <st...@gmail.com>
AuthorDate: Sun Sep 13 13:37:45 2020 +0800
support PostgreSQL set statement parse number value
---
.../src/main/antlr4/imports/postgresql/DALStatement.g4 | 2 +-
.../sql/parser/postgresql/visitor/impl/PostgreSQLDALVisitor.java | 3 +++
.../src/main/resources/case/dal/set.xml | 5 +++++
.../src/main/resources/sql/supported/dal/set.xml | 1 +
4 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
index 03804af..63fe619 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
@@ -47,7 +47,7 @@ timeZoneClause_
;
configurationParameterClause
- : identifier (TO | EQ_) (identifier | STRING_ | DEFAULT)
+ : identifier (TO | EQ_) (identifier | NUMBER_ | STRING_ | DEFAULT)
;
resetParameter
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/impl/PostgreSQLDALVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/impl/PostgreSQLDALVisitor.java
index 6dfc983..652bf28 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/impl/PostgreSQLDALVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/impl/PostgreSQLDALVisitor.java
@@ -73,6 +73,9 @@ public final class PostgreSQLDALVisitor extends PostgreSQLVisitor implements DAL
if (null != ctx.identifier(1)) {
result.setAssignValue(ctx.identifier(1).getText());
}
+ if (null != ctx.NUMBER_()) {
+ result.setAssignValue(ctx.NUMBER_().getText());
+ }
if (null != ctx.DEFAULT()) {
result.setAssignValue(ctx.DEFAULT().getText());
}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
index 9eacd29..df557cd 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/dal/set.xml
@@ -22,6 +22,11 @@
<variable name="configuration_parameter" />
</variable-assign>
</set-variable>
+ <set-variable sql-case-id="set_parameter_equal_number" >
+ <variable-assign value="3" >
+ <variable name="extra_float_digits" />
+ </variable-assign>
+ </set-variable>
<set-variable sql-case-id="set_parameter_equal_session_mysql" >
<variable-assign value="'value'" >
<variable name="configuration_parameter" scope="SESSION"/>
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
index 7a8c245..ea1eb26 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/dal/set.xml
@@ -18,6 +18,7 @@
<sql-cases>
<sql-case id="set_parameter_equal" value="SET configuration_parameter = 'value'" db-types="PostgreSQL, MySQL" />
+ <sql-case id="set_parameter_equal_number" value="SET extra_float_digits = 3" db-types="PostgreSQL, MySQL" />
<sql-case id="set_parameter_equal_session_mysql" value="SET SESSION configuration_parameter = 'value'" db-types="MySQL" />
<sql-case id="set_parameter_to" value="SET configuration_parameter TO 'value'" db-types="PostgreSQL" />
<sql-case id="set_parameter_for_session_scope" value="SET SESSION configuration_parameter TO 'value'" db-types="PostgreSQL" />