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

terrymanu 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 9914f666cfc Fix Firebird keyword column aliases (#40283)
9914f666cfc is described below

commit 9914f666cfc516f6e70a3cbb733562f3caab415a
Author: Zhang Muyuan <[email protected]>
AuthorDate: Wed Oct 21 18:49:59 2026 +0800

    Fix Firebird keyword column aliases (#40283)
---
 RELEASE-NOTES.md                                   |  1 +
 .../src/main/antlr4/imports/firebird/BaseRule.g4   |  3 ++
 .../parser/src/main/resources/case/dml/select.xml  | 48 ++++++++++++++++++++++
 .../main/resources/sql/supported/dml/select.xml    |  6 +++
 4 files changed, 58 insertions(+)

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index 4a70e841528..e9b01330ee0 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -33,6 +33,7 @@
 1. SQL Parser: Preserve SQLServer `CREATE TABLE` column nullability metadata - 
[#39414](https://github.com/apache/shardingsphere/pull/39414)
 1. SQL Parser: Preserve MySQL `ALTER TABLE MODIFY COLUMN` nullability metadata 
- [#39421](https://github.com/apache/shardingsphere/pull/39421)
 1. SQL Parser: Preserve Firebird `CREATE TABLE` column nullability metadata - 
[#39423](https://github.com/apache/shardingsphere/pull/39423)
+1. SQL Parser: Fix Firebird parsing of KEY, TEXT and COMMENT column aliases - 
[#40262](https://github.com/apache/shardingsphere/issues/40262)
 1. SQL Parser: Preserve openGauss `CREATE TABLE` column nullability metadata - 
[#39425](https://github.com/apache/shardingsphere/pull/39425)
 1. SQL Parser: Preserve Hive `CREATE TABLE` column nullability metadata - 
[#39428](https://github.com/apache/shardingsphere/pull/39428)
 1. SQL Parser: Preserve SQLServer `ALTER TABLE ALTER COLUMN` nullability 
metadata - [#39430](https://github.com/apache/shardingsphere/pull/39430)
diff --git 
a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
 
b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
index 5871ae36469..37448d809e5 100644
--- 
a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
+++ 
b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/BaseRule.g4
@@ -71,9 +71,11 @@ unreservedWord
     | C92 | CATALOG_NAME | CHARACTER_SET_CATALOG | CHARACTER_SET_NAME | 
CHARACTER_SET_SCHEMA
     | CLASS_ORIGIN | COBOL | COLLATION_CATALOG | COLLATION_NAME | 
COLLATION_SCHEMA
     | COLUMN_NAME | COMMAND_FUNCTION | COMMITTED | CONDITION_NUMBER | 
CONNECTION_NAME
+    | COMMENT
     | CONSTRAINT_CATALOG | CONSTRAINT_NAME | CONSTRAINT_SCHEMA | CURSOR_NAME
     | DATA | DATETIME_INTERVAL_CODE | DATETIME_INTERVAL_PRECISION | 
DYNAMIC_FUNCTION
     | FORTRAN
+    | KEY
     | LENGTH
     | MESSAGE_LENGTH | MESSAGE_OCTET_LENGTH | MESSAGE_TEXT | MORE92 | MUMPS
     | NAME | NULLABLE | NULLS | NUMBER
@@ -82,6 +84,7 @@ unreservedWord
     | REPEATABLE | RETURNED_LENGTH | RETURNED_OCTET_LENGTH | RETURNED_SQLSTATE 
| ROW_COUNT
     | SCALE | SCHEMA_NAME | SERIALIZABLE | SERVER_NAME | SUBCLASS_ORIGIN
     | TABLE_NAME | TYPE
+    | TEXT
     | UNCOMMITTED | UNNAMED | VALUE | FIRSTNAME | MIDDLENAME | LASTNAME
     ;
 
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 ead992450b0..4fe75a13909 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -15833,4 +15833,52 @@
             <shorthand-projection start-index="7" stop-index="7" />
         </projections>
     </select>
+    <select sql-case-id="select_key_alias_with_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="28" stop-index="34" />
+        </from>
+        <projections start-index="7" stop-index="21">
+            <column-projection name="order_id" alias="KEY" start-index="7" 
stop-index="21" />
+        </projections>
+    </select>
+    <select sql-case-id="select_text_alias_with_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="29" stop-index="35" />
+        </from>
+        <projections start-index="7" stop-index="22">
+            <column-projection name="order_id" alias="TEXT" start-index="7" 
stop-index="22" />
+        </projections>
+    </select>
+    <select sql-case-id="select_comment_alias_with_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="32" stop-index="38" />
+        </from>
+        <projections start-index="7" stop-index="25">
+            <column-projection name="order_id" alias="COMMENT" start-index="7" 
stop-index="25" />
+        </projections>
+    </select>
+    <select sql-case-id="select_key_alias_without_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="25" stop-index="31" />
+        </from>
+        <projections start-index="7" stop-index="18">
+            <column-projection name="order_id" alias="KEY" start-index="7" 
stop-index="18" />
+        </projections>
+    </select>
+    <select sql-case-id="select_text_alias_without_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="26" stop-index="32" />
+        </from>
+        <projections start-index="7" stop-index="19">
+            <column-projection name="order_id" alias="TEXT" start-index="7" 
stop-index="19" />
+        </projections>
+    </select>
+    <select sql-case-id="select_comment_alias_without_as_firebird">
+        <from>
+            <simple-table name="t_order" start-index="29" stop-index="35" />
+        </from>
+        <projections start-index="7" stop-index="22">
+            <column-projection name="order_id" alias="COMMENT" start-index="7" 
stop-index="22" />
+        </projections>
+    </select>
 </sql-parser-test-cases>
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 cbb392535e0..c7f2e3c74a3 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
@@ -606,4 +606,10 @@
     <sql-case id="select_where_is_distinct_from_and_equal_firebird" 
value="SELECT order_id FROM t_order WHERE status IS DISTINCT FROM ? AND 
order_id = ?" db-types="Firebird" />
     <sql-case id="select_with_schema_database_link_and_alias_oracle" 
value="SELECT * FROM userinfo.subs_rateplan@PJZW x" db-types="Oracle" />
     <sql-case id="select_with_dotted_database_link_oracle" value="SELECT * 
FROM [email protected] x" db-types="Oracle" />
+    <sql-case id="select_key_alias_with_as_firebird" value="SELECT order_id AS 
KEY FROM t_order" db-types="Firebird" />
+    <sql-case id="select_text_alias_with_as_firebird" value="SELECT order_id 
AS TEXT FROM t_order" db-types="Firebird" />
+    <sql-case id="select_comment_alias_with_as_firebird" value="SELECT 
order_id AS COMMENT FROM t_order" db-types="Firebird" />
+    <sql-case id="select_key_alias_without_as_firebird" value="SELECT order_id 
KEY FROM t_order" db-types="Firebird" />
+    <sql-case id="select_text_alias_without_as_firebird" value="SELECT 
order_id TEXT FROM t_order" db-types="Firebird" />
+    <sql-case id="select_comment_alias_without_as_firebird" value="SELECT 
order_id COMMENT FROM t_order" db-types="Firebird" />
 </sql-cases>

Reply via email to