Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 72a90ec

Browse files
committed
Add extra protection in case the statement_truncate_len variable is removed from the sys_config table
1 parent 6c1a225 commit 72a90ec

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

functions/format_statement.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,16 @@ CREATE DEFINER='root'@'localhost' FUNCTION format_statement (
6262
DETERMINISTIC
6363
NO SQL
6464
BEGIN
65+
/* Check if we have the configured length, if not, init it */
6566
IF @statement_truncate_len IS NULL THEN
6667
SELECT value INTO @statement_truncate_len FROM sys.sys_config WHERE variable = 'statement_truncate_len';
6768
END IF;
69+
70+
/* Protection against the variable being removed from sys_config */
71+
IF @statement_truncate_len IS NULL THEN
72+
SET @statement_truncate_len := 64;
73+
END IF;
74+
6875
IF CHAR_LENGTH(statement) > @statement_truncate_len THEN
6976
RETURN REPLACE(CONCAT(LEFT(statement, (@statement_truncate_len/2)-2), ' ... ', RIGHT(statement, (@statement_truncate_len/2)-2)), '\n', ' ');
7077
ELSE

0 commit comments

Comments
 (0)