You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2023/08/10 11:26:48 UTC

[shardingsphere] branch master updated: Support oracle national character parsing (#28023)

This is an automated email from the ASF dual-hosted git repository.

zhaojinchao 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 eeffeb6312f Support oracle national character parsing (#28023)
eeffeb6312f is described below

commit eeffeb6312f01dc23ea38617c43e6695b41f436c
Author: ZhangCheng <ch...@apache.org>
AuthorDate: Thu Aug 10 19:26:38 2023 +0800

    Support oracle national character parsing (#28023)
    
    * Add oracle column parsing assertions of multiset expression
    
    * Support oracle national character parsing
---
 .../src/main/antlr4/imports/oracle/Literals.g4     |  2 ++
 .../parser/src/main/resources/case/dml/insert.xml  | 26 ++++++++++++++++++++++
 .../main/resources/sql/supported/dml/insert.xml    |  1 +
 3 files changed, 29 insertions(+)

diff --git a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/Literals.g4 b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/Literals.g4
index ea52447e7c7..93ff07550d7 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/Literals.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/Literals.g4
@@ -30,6 +30,8 @@ IDENTIFIER_
 STRING_
     : SINGLE_QUOTED_TEXT
     | DOUBLE_QUOTED_TEXT
+    | N? SINGLE_QUOTED_TEXT
+    | N? DOUBLE_QUOTED_TEXT
     ;
 
 SINGLE_QUOTED_TEXT
diff --git a/test/it/parser/src/main/resources/case/dml/insert.xml b/test/it/parser/src/main/resources/case/dml/insert.xml
index a5cae8cc3f0..253484364cd 100644
--- a/test/it/parser/src/main/resources/case/dml/insert.xml
+++ b/test/it/parser/src/main/resources/case/dml/insert.xml
@@ -2384,4 +2384,30 @@
             </value>
         </values>
     </insert>
+
+    <insert sql-case-id="insert_with_national_character_set">
+        <table name="customers" start-index="12" stop-index="20" literal-start-index="12" literal-stop-index="20" />
+        <columns start-index="21" stop-index="21" literal-start-index="21" literal-stop-index="21" />
+        <values>
+            <value>
+                <assignment-value>
+                    <literal-expression value="1000" start-index="30" stop-index="33" literal-start-index="30" literal-stop-index="33" />
+                </assignment-value>
+                <assignment-value>
+                    <function function-name="TO_NCHAR" text="TO_NCHAR('John Smith')" start-index="36" stop-index="57" literal-start-index="36" literal-stop-index="57">
+                        <parameter>
+                            <literal-expression value="John Smith" start-index="45" stop-index="56" literal-start-index="45" literal-stop-index="56" />
+                        </parameter>
+                        <literalText>TO_NCHAR('John Smith')</literalText>
+                    </function>
+                </assignment-value>
+                <assignment-value>
+                    <literal-expression value="'500 Oracle Parkway" start-index="59" stop-index="79" literal-start-index="59" literal-stop-index="79" />
+                </assignment-value>
+                <assignment-value>
+                    <column name="sysdate" start-index="81" stop-index="87" literal-start-index="81" literal-stop-index="87" />
+                </assignment-value>
+            </value>
+        </values>
+    </insert>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
index c5cad9f5667..ee36c40dc8b 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/insert.xml
@@ -94,4 +94,5 @@
     <sql-case id="insert_datetime_literals" value="INSERT INTO date_tab VALUES ( TIMESTAMP'1999-12-01 10:00:00', TIMESTAMP'1999-12-01 10:00:00', TIMESTAMP'1999-12-01 10:00:00');" db-types="Oracle" />
     <sql-case id="insert_with_content_keyword" value="INSERT INTO SYS_MQ_MSG (ID, CONTENT) VALUES (1, 'test');" db-types="Oracle" />
     <sql-case id="insert_with_connect_by_and_prior" value="Insert Into t (c1,c2,c3,c4,c5) select c1,c2,regexp_substr(c3, '[^,]+', 1, l) c3,c4,c5 from t where id=1 connect by l &lt;= regexp_count(c3, ',') + 1 and ID = prior ID and prior dbms_random.value is not null;" db-types="Oracle" />
+    <sql-case id="insert_with_national_character_set" value="INSERT INTO customers VALUES (1000, TO_NCHAR('John Smith'),N'500 Oracle Parkway',sysdate);" db-types="Oracle" />
 </sql-cases>