Skip to content

Commit

Permalink
Enhanced hex function for mysql (apache#26921)
Browse files Browse the repository at this point in the history
  • Loading branch information
zihaoAK47 authored Jul 13, 2023
1 parent 7838f2b commit ea71b7d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ temporalLiterals
;

hexadecimalLiterals
: UNDERSCORE_CHARSET? HEX_DIGIT_ collateClause?
: UNDERSCORE_CHARSET? UL_BINARY? HEX_DIGIT_ collateClause?
;

bitValueLiterals
Expand Down
30 changes: 30 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 @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit ea71b7d

Please sign in to comment.