Skip to content

Commit 7c8143e

Browse files
committed
1 parent 36f54b0 commit 7c8143e

File tree

7 files changed

+1222
-1046
lines changed

7 files changed

+1222
-1046
lines changed

deps/rabbit/src/rabbit_amqp_filter_sql.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ eval({ApplicationProperties, Ast}, Msg) ->
5858
eval0({Type, Value}, _Msg)
5959
when Type =:= integer orelse
6060
Type =:= float orelse
61+
Type =:= boolean orelse
6162
Type =:= string orelse
62-
Type =:= boolean ->
63+
Type =:= binary ->
6364
Value;
6465

6566
%% Identifier lookup

deps/rabbit/src/rabbit_amqp_sql_lexer.erl

Lines changed: 667 additions & 620 deletions
Large diffs are not rendered by default.

deps/rabbit/src/rabbit_amqp_sql_lexer.xrl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Definitions.
88
WHITESPACE = [\s\t\f\n\r]
99
DIGIT = [0-9]
10+
HEXDIGIT = [0-9A-F]
1011
INT = {DIGIT}+
1112
% Approximate numeric literal with a decimal
1213
FLOAT = ({DIGIT}+\.{DIGIT}*|\.{DIGIT}+)(E[\+\-]?{INT})?
@@ -17,6 +18,7 @@ EXPONENT = {DIGIT}+E[\+\-]?{DIGIT}+
1718
% to allow identifiers such as properties.group-id
1819
IDENTIFIER = [a-zA-Z_$][a-zA-Z0-9_$.\-]*
1920
STRING = '([^']|'')*'
21+
BINARY = 0x({HEXDIGIT}{HEXDIGIT})+
2022
2123
Rules.
2224
{WHITESPACE}+ : skip_token.
@@ -65,6 +67,7 @@ FALSE : {token, {boolean, TokenLine, false}}.
6567
{EXPONENT} : {token, {float, TokenLine, parse_scientific_notation(TokenChars)}}.
6668
{STRING} : {token, {string, TokenLine, process_string(TokenChars)}}.
6769
{IDENTIFIER} : {token, {identifier, TokenLine, unicode:characters_to_binary(TokenChars)}}.
70+
{BINARY} : {token, {binary, TokenLine, parse_binary(TokenChars)}}.
6871

6972
% Catch any other characters as errors
7073
. : {error, {illegal_character, TokenChars}}.
@@ -100,3 +103,12 @@ process_string(Chars) ->
100103

101104
process_escaped_quotes(Binary) ->
102105
binary:replace(Binary, <<"''">>, <<"'">>, [global]).
106+
107+
parse_binary([$0, $x | HexChars]) ->
108+
parse_hex_pairs(HexChars, <<>>).
109+
110+
parse_hex_pairs([], Acc) ->
111+
Acc;
112+
parse_hex_pairs([H1, H2 | Rest], Acc) ->
113+
Byte = list_to_integer([H1, H2], 16),
114+
parse_hex_pairs(Rest, <<Acc/binary, Byte>>).

0 commit comments

Comments
 (0)