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 01bd119  Fix Oracle insert with colum name 'RANK'  (#11158)
01bd119 is described below

commit 01bd119cbc26d6e9525fabc187cc019998b6ae9e
Author: tuichenchuxin <[email protected]>
AuthorDate: Tue Jul 6 09:17:18 2021 +0800

    Fix Oracle insert with colum name 'RANK'  (#11158)
    
    * issue-11074
    Oracle Insert statement Parse SQL ERROR!Please Help! #11074
    
    * Fix Oracle insert with colum name 'RANK'
    
    * Fix Oracle insert with colum name 'RANK'
---
 .../src/main/antlr4/imports/oracle/BaseRule.g4             |  2 +-
 .../src/main/resources/case/dml/insert.xml                 | 14 ++++++++++++++
 .../src/main/resources/sql/supported/dml/insert.xml        |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index 0a0eba3..03b7176 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -96,7 +96,7 @@ unreservedWord
     | BECOME | CHANGE | NOTIFICATION | PRIVILEGE | PURGE | RESUMABLE
     | SYSGUID | SYSBACKUP | SYSDBA | SYSDG | SYSKM | SYSOPER | DBA_RECYCLEBIN 
|SCHEMA
     | DO | DEFINER | CURRENT_USER | CASCADED | CLOSE | OPEN | NEXT | NAME | 
NAMES
-    | COLLATION | REAL | TYPE | FIRST
+    | COLLATION | REAL | TYPE | FIRST | RANK
     ;
 
 schemaName
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
index 22ed987..8fd5d67 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/dml/insert.xml
@@ -1824,4 +1824,18 @@
             </projections>
         </select-subquery>
     </insert>
+
+    <insert sql-case-id="insert_with_rank_column">
+        <table name="sales" start-index="12" stop-index="16" />
+        <columns start-index="18" stop-index="23">
+            <column name="rank" start-index="19" stop-index="22" />
+        </columns>
+        <values>
+            <value>
+                <assignment-value>
+                    <literal-expression value="1" start-index="33" 
stop-index="33" />
+                </assignment-value>
+            </value>
+        </values>
+    </insert>
 </sql-parser-test-cases>
diff --git 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
index 0e9be8c..fd894ed 100644
--- 
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
+++ 
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/dml/insert.xml
@@ -82,4 +82,5 @@
     <sql-case id="insert_with_multitable_element" value="INSERT ALL INTO sales 
(prod_id, cust_id, time_id, amount) VALUES (product_id, customer_id, 
weekly_start_date, sales_sun) INTO sales (prod_id, cust_id, time_id, amount) 
VALUES (product_id, customer_id, sales_mon, weekly_start_date+1) SELECT 
product_id, customer_id, weekly_start_date, sales_sun, sales_mon FROM 
sales_input_table" db-types="Oracle" />
     <sql-case id="insert_all_with_multitable_with_conditional_when" 
value="INSERT ALL WHEN order_total &lt;= 100000 THEN INTO small_orders WHEN 
order_total > 1000000 AND order_total &lt;= 200000 THEN INTO medium_orders WHEN 
order_total > 200000 THEN INTO large_orders SELECT order_id, order_total, 
sales_rep_id, customer_id FROM orders" db-types="Oracle" />
     <sql-case 
id="insert_all_with_multitable_with_conditional_when_with_conditional_else" 
value="INSERT ALL WHEN order_total &lt;= 100000 THEN INTO small_orders WHEN 
order_total > 100000 AND order_total &lt;= 200000 THEN INTO medium_orders ELSE 
INTO large_orders SELECT order_id, order_total, sales_rep_id, customer_id FROM 
orders" db-types="Oracle" />
+    <sql-case id="insert_with_rank_column" value="insert into sales (rank) 
values (1)" db-types="Oracle" />
 </sql-cases>

Reply via email to