You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/10/28 01:34:21 UTC
[shardingsphere] branch master updated: Fix oracle parsing does not support varchar2 specified type(#21805) (#21811)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 f8b8d6c6b81 Fix oracle parsing does not support varchar2 specified type(#21805) (#21811)
f8b8d6c6b81 is described below
commit f8b8d6c6b81577e52b244d8317f5aa6b5e2a7498
Author: ZhangCheng <fl...@outlook.com>
AuthorDate: Fri Oct 28 09:34:14 2022 +0800
Fix oracle parsing does not support varchar2 specified type(#21805) (#21811)
* Fix oracle parsing does not support varchar2 type specified length in create table
* Add test case
---
.../dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 | 2 +-
.../dialect/oracle/src/main/antlr4/imports/oracle/Keyword.g4 | 5 +++++
test/parser/src/main/resources/case/ddl/create-table.xml | 10 ++++++++++
.../src/main/resources/sql/supported/ddl/create-table.xml | 1 +
4 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 b/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index 71d4fed59b6..585b3a7726b 100644
--- a/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -418,7 +418,7 @@ alias
;
dataTypeLength
- : LP_ (INTEGER_ (COMMA_ INTEGER_)?)? RP_
+ : LP_ (INTEGER_ (COMMA_ INTEGER_)? (CHAR | BYTE)?)? RP_
;
primaryKey
diff --git a/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/Keyword.g4 b/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/Keyword.g4
index 91866dcb390..e44012d959f 100644
--- a/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/Keyword.g4
+++ b/sql-parser/dialect/oracle/src/main/antlr4/imports/oracle/Keyword.g4
@@ -359,6 +359,11 @@ DOUBLE
: D O U B L E
;
+BYTE
+ :
+ B Y T E
+ ;
+
CHAR
: C H A R
;
diff --git a/test/parser/src/main/resources/case/ddl/create-table.xml b/test/parser/src/main/resources/case/ddl/create-table.xml
index af214f32b52..bd84c5e9c01 100644
--- a/test/parser/src/main/resources/case/ddl/create-table.xml
+++ b/test/parser/src/main/resources/case/ddl/create-table.xml
@@ -1784,4 +1784,14 @@
<column name="status" />
</column-definition>
</create-table>
+
+ <create-table sql-case-id="create_table_with_varchar2_char_and_byte_type">
+ <table name="t_order" start-index="13" stop-index="19" />
+ <column-definition type="VARCHAR2" start-index="22" stop-index="62">
+ <column name="SYS_ID" />
+ </column-definition>
+ <column-definition type="VARCHAR2" start-index="65" stop-index="118">
+ <column name="ATTACHMENT_NAME" />
+ </column-definition>
+ </create-table>
</sql-parser-test-cases>
diff --git a/test/parser/src/main/resources/sql/supported/ddl/create-table.xml b/test/parser/src/main/resources/sql/supported/ddl/create-table.xml
index 592ffcc971c..fe2b083f9bd 100644
--- a/test/parser/src/main/resources/sql/supported/ddl/create-table.xml
+++ b/test/parser/src/main/resources/sql/supported/ddl/create-table.xml
@@ -127,4 +127,5 @@
<sql-case id="create_table_national" value="CREATE TABLE t_order (national int);" db-types="PostgreSQL,openGauss" />
<sql-case id="create_table_with_visible" value="CREATE TABLE t_order (order_id INT, user_id INT, status VARCHAR(10) VISIBLE) ENGINE=INNODB" db-types="MySQL" />
<sql-case id="create_table_with_invisible" value="CREATE TABLE t_order (order_id INT, user_id INT, status VARCHAR(10) INVISIBLE) ENGINE=INNODB" db-types="MySQL" />
+ <sql-case id="create_table_with_varchar2_char_and_byte_type" value="CREATE TABLE t_order (SYS_ID VARCHAR2(32 CHAR) VISIBLE NOT NULL, ATTACHMENT_NAME VARCHAR2(1024 BYTE) VISIBLE DEFAULT '')" db-types="Oracle" />
</sql-cases>