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 54bc4574126 Fix firebird backslash string literal (#40175)
54bc4574126 is described below
commit 54bc4574126174625147d37be2093da367c9faa9
Author: Maxim Igoshin <[email protected]>
AuthorDate: Fri Oct 16 10:41:03 2026 +0300
Fix firebird backslash string literal (#40175)
* Treat backslash as an ordinary character in Firebird string literals
* Fix CODE_OF_CONDUCT violations in Firebird backslash string literal
parser cases
---
.../src/main/antlr4/imports/firebird/Literals.g4 | 2 +-
.../parser/src/main/resources/case/dml/select.xml | 51 ++++++++++++++++++++++
.../main/resources/sql/supported/dml/select.xml | 2 +
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git
a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/Literals.g4
b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/Literals.g4
index 3e52be725dd..a411410e349 100644
---
a/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/Literals.g4
+++
b/parser/sql/engine/dialect/firebird/src/main/antlr4/imports/firebird/Literals.g4
@@ -25,7 +25,7 @@ IDENTIFIER_
;
STRING_
- : (SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_)
+ : (SQ_ ('\'\'' | ~'\'')* SQ_)
;
NUMBER_
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 2e6a8e5b278..dfdd8a9253d 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -13482,6 +13482,57 @@
</from>
</select>
+ <select sql-case-id="select_where_like_escape_backslash_firebird">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <where start-index="22" stop-index="56">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="56">
+ <left>
+ <column name="status" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>LIKE</operator>
+ <right>
+ <list-expression start-index="40" stop-index="56">
+ <items>
+ <literal-expression value="a\_b"
start-index="40" stop-index="45" />
+ </items>
+ <items>
+ <literal-expression value="\" start-index="54"
stop-index="56" />
+ </items>
+ </list-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="select_where_backslash_literal_firebird">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <where start-index="22" stop-index="45">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="45">
+ <left>
+ <column name="status" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="C:\dir\" start-index="37"
stop-index="45" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
<select sql-case-id="select_where_and_like_firebird">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
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 503aff482fa..49fc00dbd87 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
@@ -455,6 +455,8 @@
<sql-case id="select_parenthesized_column_firebird" value="SELECT
(user_id) FROM t_order" db-types="Firebird"/>
<sql-case id="select_schema_table_firebird" value="SELECT * FROM
schema1.t_order" db-types="Firebird"/>
<sql-case id="select_where_and_like_firebird" value="SELECT * FROM t_order
WHERE user_id = 1 AND status LIKE 'A%'" db-types="Firebird"/>
+ <sql-case id="select_where_like_escape_backslash_firebird" value="SELECT *
FROM t_order WHERE status LIKE 'a\_b' ESCAPE '\'" db-types="Firebird"/>
+ <sql-case id="select_where_backslash_literal_firebird" value="SELECT *
FROM t_order WHERE status = 'C:\dir\'" db-types="Firebird"/>
<sql-case id="select_safe_eq_firebird" value="SELECT 1 <=> 1"
db-types="Firebird"/>
<sql-case id="select_in_list_firebird" value="SELECT * FROM t_order WHERE
id IN (1,2)" db-types="Firebird"/>
<sql-case id="select_not_in_list_firebird" value="SELECT * FROM t_order
WHERE id NOT IN (1,2)" db-types="Firebird"/>