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 ea71b7d4d67 Enhanced hex function for mysql (#26921)
ea71b7d4d67 is described below

commit ea71b7d4d67446037fe1b7e0e6e8b0e947c63dd9
Author: niu niu <[email protected]>
AuthorDate: Thu Jul 13 11:37:33 2023 +0800

    Enhanced hex function for mysql (#26921)
---
 .../src/main/antlr4/imports/mysql/BaseRule.g4      |  2 +-
 .../parser/src/main/resources/case/dml/select.xml  | 30 ++++++++++++++++++++++
 .../main/resources/sql/supported/dml/select.xml    |  1 +
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index 9b4f96af45c..ff972a8a107 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -84,7 +84,7 @@ temporalLiterals
     ;
     
 hexadecimalLiterals
-    : UNDERSCORE_CHARSET? HEX_DIGIT_ collateClause?
+    : UNDERSCORE_CHARSET? UL_BINARY? HEX_DIGIT_ collateClause?
     ;
     
 bitValueLiterals
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml 
b/test/it/parser/src/main/resources/case/dml/select.xml
index 5fad5747135..3264f29901f 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -17,6 +17,36 @@
   -->
 
 <sql-parser-test-cases>
+    <select sql-case-id="select_with_hex_function">
+        <projections start-index="7" stop-index="50">
+            <expression-projection text="HEX(_binary 0x0003 &lt;&lt; (_binary 
0x38 | 0x38))" start-index="7" stop-index="50">
+                <expr>
+                    <function start-index="7" stop-index="50" 
text="HEX(_binary 0x0003 &lt;&lt; (_binary 0x38 | 0x38))" function-name="HEX">
+                        <parameter>
+                            <binary-operation-expression start-index="11" 
stop-index="49">
+                                <left>
+                                    <common-expression start-index="11" 
stop-index="24" text="_binary0x0003" />
+                                </left>
+                                <operator>&lt;&lt;</operator>
+                                <right>
+                                    <binary-operation-expression 
start-index="30" stop-index="48">
+                                        <left>
+                                            <common-expression 
start-index="30" stop-index="41" text="_binary0x38" />
+                                        </left>
+                                        <operator>|</operator>
+                                        <right>
+                                            <common-expression 
start-index="45" stop-index="48" text="0x38" />
+                                        </right>
+                                    </binary-operation-expression>
+                                </right>
+                            </binary-operation-expression>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
     <select sql-case-id="select_with_exist_in">
         <projections start-index="7" stop-index="93">
             <expression-projection text="+0 
IN(0b111111111111111111111111111111111111111111111111111,rpad(1.0,2048,1),32767.1)"
 start-index="7" stop-index="93">
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index ed2df4974c6..ab5e7ed3415 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -17,6 +17,7 @@
   -->
 
 <sql-cases>
+    <sql-case id="select_with_hex_function" value="SELECT HEX(_binary 0x0003 
&lt;&lt; (_binary 0x38 | 0x38))" db-types="MySQL" />
     <sql-case id="select_with_exist_in" value="SELECT (+0 
IN(0b111111111111111111111111111111111111111111111111111,rpad(1.0,2048,1),32767.1))"
 db-types="MySQL" />
     <sql-case id="select_constant_without_table" value="SELECT 1 as a" 
db-types="MySQL, PostgreSQL,openGauss, SQLServer" />
     <sql-case id="select_with_operator_ilike" value="SELECT id from t_order 
where name !~ '^pg_toast'" db-types="PostgreSQL,openGauss" />

Reply via email to