SQL Custom - MySQL
Hello, I am attempting to create a query to retrieve the last piece of information from a REGEX: input_circuitid { if ("%{reply:Packet-Type}" == 'Access-Accept') { "%{sql:INSERT INTO ... CASE \ WHEN '%{string:ADSL-Agent-Circuit-Id}' \ REGEXP '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})/[0-9]+/[0-9]+/[A-Za-z0-9]+$' \ THEN SUBSTRING_INDEX('%{string:ADSL-Agent-Circuit-Id}', '/', -1) \ ELSE NULL \ END \ ) \ ON DUPLICATE KEY UPDATE \ ... sn = CASE \ WHEN '%{string:ADSL-Agent-Circuit-Id}' \ REGEXP '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2})/[0-9]+/[0-9]+/[A-Za-z0-9]+$' \ THEN SUBSTRING_INDEX('%{string:ADSL-Agent-Circuit-Id}', '/', -1) \ ELSE sn \ END \ }" } } However, FreeRadius interprets the curly braces "}" as the end of the statement. REGEXP '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2} Is there any way for FreeRadius to understand that this does not close the instruction? Sincerely, Rodrigo Prazim
On Sep 12, 2025, at 9:24 AM, Rodrigo Prazim <rodrigoprazim@hotmail.com> wrote:
However, FreeRadius interprets the curly braces "}" as the end of the statement.
REGEXP '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[0-9]{1,2}
Is there any way for FreeRadius to understand that this does not close the instruction?
This is hard to fix in v3. The issue is that it would have to parse all of the contents of the SQL query, and there's no real way to do that correctly. The correct fix is to use v4, which solves all of the issues by making the expansions into real functions, with function-style arguments. Alan DeKok.
participants (2)
-
Alan DeKok -
Rodrigo Prazim