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 e96b3b1ec3a Fix BYTEA type cast (#27593) (#27602)
e96b3b1ec3a is described below

commit e96b3b1ec3a8cd6eae77d7ac20609c3bef8f7b44
Author: jiangtao <[email protected]>
AuthorDate: Thu Aug 3 09:11:30 2023 +0800

    Fix BYTEA type cast (#27593) (#27602)
---
 .../src/main/antlr4/imports/opengauss/BaseRule.g4  |  1 +
 .../src/main/antlr4/imports/postgresql/BaseRule.g4 |  1 +
 .../main/resources/case/dml/select-expression.xml  | 26 ++++++++++++++++++++++
 .../sql/supported/dml/select-expression.xml        |  1 +
 4 files changed, 29 insertions(+)

diff --git 
a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4 
b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
index c0c87d9d603..af7d0efdae3 100644
--- a/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
+++ b/parser/sql/dialect/opengauss/src/main/antlr4/imports/opengauss/BaseRule.g4
@@ -143,6 +143,7 @@ unreservedWord
     | BEFORE
     | BEGIN
     | BY
+    | BYTEA
     | BOX
     | CACHE
     | CALL
diff --git 
a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4 
b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
index db7448b0db8..0011b4a935d 100644
--- 
a/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
+++ 
b/parser/sql/dialect/postgresql/src/main/antlr4/imports/postgresql/BaseRule.g4
@@ -144,6 +144,7 @@ unreservedWord
     | BEFORE
     | BEGIN
     | BY
+    | BYTEA
     | BOX
     | CACHE
     | CALL
diff --git a/test/it/parser/src/main/resources/case/dml/select-expression.xml 
b/test/it/parser/src/main/resources/case/dml/select-expression.xml
index fbf1d6cd94d..d7df28026b0 100644
--- a/test/it/parser/src/main/resources/case/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-expression.xml
@@ -223,6 +223,32 @@
         </order-by>
     </select>
 
+    <select sql-case-id="select_with_encode_function">
+        <from>
+            <simple-table name="test_bytea" start-index="54" stop-index="63" />
+        </from>
+        <projections start-index="7" stop-index="47">
+            <expression-projection 
text="ENCODE(test_datetype_col::bytea,'escape')" start-index="7" 
stop-index="47">
+                <expr>
+                    <function function-name="ENCODE" start-index="7" 
stop-index="47" text="ENCODE(test_datetype_col::bytea,'escape')">
+                        <parameter>
+                            <type-cast-expression>
+                                <expression>
+                                    <column name="test_datetype_col" 
start-index="14" stop-index="30" >
+                                    </column>
+                                </expression>
+                                <data-type>bytea</data-type>
+                            </type-cast-expression>
+                        </parameter>
+                        <parameter>
+                            <literal-expression value="escape" 
start-index="39" stop-index="46" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
     <select sql-case-id="select_with_date_function">
         <from>
             <simple-table name="t_order_item" alias="i" start-delimiter="`" 
end-delimiter="`" start-index="51" stop-index="69" />
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
index 7415e69befa..ba98745114e 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
@@ -25,6 +25,7 @@
     <sql-case id="select_case_when_with_div_condition" value="select case 1/0 
when &quot;a&quot; then &quot;true&quot; else &quot;false&quot; END" 
db-types="MySQL" />
     <sql-case id="select_with_expression" value="SELECT o.order_id + 1 * 2 as 
exp FROM t_order AS o ORDER BY o.order_id" db-types="MySQL, H2, SQL92, 
SQLServer" />
     <sql-case id="select_with_expression_for_postgresql" value="SELECT 
o.order_id + 1 * 2 as exp FROM t_order AS o ORDER BY o.order_id" 
db-types="PostgreSQL,openGauss" />
+    <sql-case id="select_with_encode_function" value="SELECT 
ENCODE(test_datetype_col::bytea,'escape') FROM test_bytea" 
db-types="PostgreSQL,openGauss" />
     <sql-case id="select_with_date_function" value="SELECT 
DATE(i.creation_date) AS creation_date FROM `t_order_item` AS i ORDER BY 
DATE(i.creation_date) DESC" db-types="MySQL" />
     <sql-case id="select_with_regexp" value="SELECT * FROM t_order_item t 
WHERE t.status REGEXP ? AND t.item_id IN (?, ?)" db-types="MySQL" />
     <sql-case id="select_with_rlike" value="SELECT * FROM t_order_item t WHERE 
t.status RLIKE ? AND t.item_id IN (?, ?)" db-types="MySQL" />

Reply via email to