Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Bug Fixes

1. SQL Parser: Support Oracle SQL parser correctly extract REGEXP_SUBSTR parameters - [#37924](https://github.com/apache/shardingsphere/pull/37924)
2. SQL Parser: Fix escape '\' in SQL causing DialectSQLParsingException - [#37943](https://github.com/apache/shardingsphere/pull/37943)

## Release 5.5.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ STRING_
;

SINGLE_QUOTED_TEXT
: (SQ_ (('\\' +) | '\'\'' | ~('\'' | '\\'))* SQ_)
: (SQ_ ('\'\'' | ~'\'')* SQ_)
;

DOUBLE_QUOTED_TEXT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ IDENTIFIER_
;

STRING_
: E? SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_
: E SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_
| SQ_ ('\'\'' | ~'\'')* SQ_
;

NUMBER_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ IDENTIFIER_
;

STRING_
: (SQ_ ('\\'. | '\'\'' | ~('\'' | '\\'))* SQ_)
: (SQ_ ('\'\'' | ~'\'')* SQ_)
;

NUMBER_
Expand Down
87 changes: 87 additions & 0 deletions test/it/parser/src/main/resources/case/dml/select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3466,6 +3466,93 @@
</expr>
</where>
</select>

<select sql-case-id="select_like_escape_backslash_postgresql">
<from>
<simple-table name="t_user" start-index="14" stop-index="19" />
</from>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
<where start-index="21" stop-index="57">
<expr>
<binary-operation-expression start-index="27" stop-index="57">
<left>
<column name="name" start-index="27" stop-index="30" />
</left>
<operator>LIKE</operator>
<right>
<list-expression start-index="37" stop-index="57">
<items>
<literal-expression value="abc\_def" start-index="37" stop-index="46" />
</items>
<items>
<literal-expression value="\" start-index="55" stop-index="57" />
</items>
</list-expression>
</right>
</binary-operation-expression>
</expr>
</where>
</select>

<select sql-case-id="select_like_escape_backslash_oracle">
<from>
<simple-table name="t_user" start-index="14" stop-index="19" />
</from>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
<where start-index="21" stop-index="57">
<expr>
<binary-operation-expression start-index="27" stop-index="57">
<left>
<column name="name" start-index="27" stop-index="30" />
</left>
<operator>LIKE</operator>
<right>
<list-expression start-index="37" stop-index="57">
<items>
<literal-expression value="abc\_def" start-index="37" stop-index="46" />
</items>
<items>
<literal-expression value="\" start-index="55" stop-index="57" />
</items>
</list-expression>
</right>
</binary-operation-expression>
</expr>
</where>
</select>

<select sql-case-id="select_like_escape_backslash_sql92">
<from>
<simple-table name="t_user" start-index="14" stop-index="19" />
</from>
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
<where start-index="21" stop-index="57">
<expr>
<binary-operation-expression start-index="27" stop-index="57">
<left>
<column name="name" start-index="27" stop-index="30" />
</left>
<operator>LIKE</operator>
<right>
<list-expression start-index="37" stop-index="57">
<items>
<literal-expression value="abc\_def" start-index="37" stop-index="46" />
</items>
<items>
<literal-expression value="\" start-index="55" stop-index="57" />
</items>
</list-expression>
</right>
</binary-operation-expression>
</expr>
</where>
</select>

<select sql-case-id="select_with_block_comment" >
<from>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
<sql-case id="select_alias_as_single_quote_string" value="SELECT status as 'status' FROM t_order" db-types="MySQL" />
<sql-case id="select_alias_as_string_double_quote" value="SELECT status as &quot;status&quot; FROM t_order" db-types="MySQL" />
<sql-case id="select_with_multi_quoted_string" value="SELECT * FROM t_order WHERE name like &quot;%&quot;''&quot;%&quot;" db-types="MySQL" />
<sql-case id="select_like_escape_backslash_postgresql" value="SELECT * FROM t_user WHERE name LIKE 'abc\_def' ESCAPE '\'" db-types="PostgreSQL" />
<sql-case id="select_like_escape_backslash_oracle" value="SELECT * FROM t_user WHERE name LIKE 'abc\_def' ESCAPE '\'" db-types="Oracle" />
<sql-case id="select_like_escape_backslash_sql92" value="SELECT * FROM t_user WHERE name LIKE 'abc\_def' ESCAPE '\'" db-types="SQL92" />
</sql-cases>