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

chengzhang 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 bc8f603fab1 Fix wrong column parse result when column contains oracle 
quote (#28146)
bc8f603fab1 is described below

commit bc8f603fab165949dfe04f0f5c3473a66cb2fc28
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Fri Aug 18 07:39:39 2023 +0800

    Fix wrong column parse result when column contains oracle quote (#28146)
---
 .../src/main/antlr4/imports/oracle/BaseRule.g4     | 12 ++---
 .../src/main/antlr4/imports/oracle/Literals.g4     |  2 -
 .../src/main/resources/case/dml/select-join.xml    | 52 ++++++++++++++++++++++
 .../resources/sql/supported/dml/select-join.xml    |  1 +
 4 files changed, 59 insertions(+), 8 deletions(-)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index 78cd97992aa..1a8384fd8bf 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -76,7 +76,7 @@ nullValueLiterals
     ;
 
 identifier
-    : IDENTIFIER_ | unreservedWord | STRING_
+    : IDENTIFIER_ | unreservedWord | DOUBLE_QUOTED_TEXT
     ;
 
 unreservedWord
@@ -588,7 +588,7 @@ roleName
     ;
 
 username
-    : identifier
+    : identifier | STRING_
     ;
 
 password
@@ -1005,7 +1005,7 @@ hashSubpartitionQuantity
     ;
 
 odciParameters
-    : identifier
+    : STRING_
     ;
 
 databaseName
@@ -1017,7 +1017,7 @@ locationName
     ;
 
 fileName
-    : STRING_
+    : identifier | STRING_
     ;
 
 asmFileName
@@ -1129,7 +1129,7 @@ logminerSessionName
     ;
 
 tablespaceGroupName
-    : identifier
+    : identifier | STRING_
     ;
 
 copyName
@@ -1788,7 +1788,7 @@ searchString
     ;
 
 attributeValue
-    : identifier
+    : STRING_
     ;
 
 joinGroupName
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 93ff07550d7..e564665412d 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
@@ -29,9 +29,7 @@ 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/select-join.xml 
b/test/it/parser/src/main/resources/case/dml/select-join.xml
index 11a61f36b0a..b8dd63f2a96 100644
--- a/test/it/parser/src/main/resources/case/dml/select-join.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-join.xml
@@ -591,4 +591,56 @@
             </expr>
         </where>
     </select>
+    
+    <select sql-case-id="select_join_with_quote" parameters="1">
+        <projections start-index="7" stop-index="18">
+            <shorthand-projection start-index="7" stop-index="11">
+                <owner name="u" start-index="7" stop-index="9" 
start-delimiter="&quot;" end-delimiter="&quot;" />
+            </shorthand-projection>
+            <shorthand-projection start-index="14" stop-index="18">
+                <owner name="o" start-index="14" stop-index="16" 
start-delimiter="&quot;" end-delimiter="&quot;" />
+            </shorthand-projection>
+        </projections>
+        <from>
+            <join-table join-type="INNER">
+                <left>
+                    <simple-table name="t_user" alias="u" start-index="25" 
stop-index="34" />
+                </left>
+                <right>
+                    <simple-table name="t_order" alias="o" start-index="47" 
stop-index="57" />
+                </right>
+                <on-condition>
+                    <binary-operation-expression start-index="62" 
stop-index="86">
+                        <left>
+                            <column name="user_id" start-index="62" 
stop-index="72">
+                                <owner name="u" start-index="62" 
stop-index="64" start-delimiter="&quot;" end-delimiter="&quot;" />
+                            </column>
+                        </left>
+                        <operator>=</operator>
+                        <right>
+                            <column name="user_id" start-index="76" 
stop-index="86">
+                                <owner name="o" start-index="76" 
stop-index="78" start-delimiter="&quot;" end-delimiter="&quot;" />
+                            </column>
+                        </right>
+                    </binary-operation-expression>
+                </on-condition>
+            </join-table>
+        </from>
+        <where start-index="88" stop-index="108">
+            <expr>
+                <binary-operation-expression start-index="94" stop-index="108">
+                    <left>
+                        <column name="user_id" start-index="94" 
stop-index="104">
+                            <owner name="u" start-index="94" stop-index="96" 
start-delimiter="&quot;" end-delimiter="&quot;" />
+                        </column>
+                    </left>
+                    <operator>=</operator>
+                    <right>
+                        <literal-expression value="1" start-index="108" 
stop-index="108" />
+                        <parameter-marker-expression parameter-index="0" 
start-index="108" stop-index="108" />
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
index 718c0a480ec..fd2dcd40b41 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-join.xml
@@ -31,4 +31,5 @@
     <sql-case id="select_natural_right_join" value="SELECT * FROM t_order o 
NATURAL RIGHT JOIN t_order_item i WHERE o.order_id = ?" 
db-types="MySQL,PostgreSQL,openGauss,Oracle" />
     <sql-case id="select_natural_full_join" value="SELECT * FROM t_order o 
NATURAL FULL JOIN t_order_item i WHERE o.order_id = ?" 
db-types="PostgreSQL,openGauss,Oracle" />
     <sql-case id="select_with_join_operator" value="SELECT * FROM t_order o , 
t_order_item i WHERE o.order_id(+) = i.order_id" db-types="Oracle" />
+    <sql-case id="select_join_with_quote" value="SELECT &quot;u&quot;.*, 
&quot;o&quot;.* FROM t_user &quot;u&quot; INNER JOIN t_order &quot;o&quot; ON 
&quot;u&quot;.user_id = &quot;o&quot;.user_id WHERE &quot;u&quot;.user_id = ?" 
db-types="Oracle" />
 </sql-cases>

Reply via email to