DECLARE date tinytext;
DECLARE client tinytext;
DECLARE request tinytext;
DECLARE query text;
SELECT
SUBSTRING_INDEX(NEW.syslog_text, " queries:", 1) as `date`,
SUBSTRING_INDEX(
SUBSTRING_INDEX(NEW.syslog_text, "#", 1),
" ",
-1
) as `client`,
SUBSTRING_INDEX(
SUBSTRING_INDEX(
NEW.syslog_text,
"query: ",
-1
),
" IN PTR",
1
) as `request`
INTO date, client, request;
SET query = "INSERT INTO `logs` (`date`, `client`, `request`) VALUES(?, ?, ?)";
PREPARE stmt FROM query;
EXECUTE stmt USING date, client, request;
DEALLOCATE stmt;