Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 38.0Mb
PDF (A4) - 38.0Mb
PDF (RPM) - 37.4Mb
HTML Download (TGZ) - 10.3Mb
HTML Download (Zip) - 10.3Mb
HTML Download (RPM) - 8.9Mb
Man Pages (TGZ) - 216.7Kb
Man Pages (Zip) - 329.5Kb
Info (Gzip) - 3.5Mb
Info (Zip) - 3.5Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  The format_statement() Function

26.4.5.5 The format_statement() Function

Given a string (normally representing an SQL statement), reduces it to the length given by the statement_truncate_len configuration option, and returns the result. No truncation occurs if the string is shorter than statement_truncate_len. Otherwise, the middle part of the string is replaced by an ellipsis (...).

This function is useful for formatting possibly lengthy statements retrieved from Performance Schema tables to a known fixed maximum length.

Parameters
  • statement LONGTEXT: The statement to format.

Configuration Options

format_statement() operation can be modified using the following configuration options or their corresponding user-defined variables (see Section 26.4.2.1, “The sys_config Table”):

  • statement_truncate_len, @sys.statement_truncate_len

    The maximum length of statements returned by the format_statement() function. Longer statements are truncated to this length. The default is 64.

Return Value

A LONGTEXT value.

Example

By default, format_statement() truncates statements to be no more than 64 characters. Setting @sys.statement_truncate_len changes the truncation length for the current session:

mysql> SET @stmt = 'SELECT variable, value, set_time, set_by FROM sys_config';
mysql> SELECT format_statement(@stmt);
+----------------------------------------------------------+
| format_statement(@stmt)                                  |
+----------------------------------------------------------+
| SELECT variable, value, set_time, set_by FROM sys_config |
+----------------------------------------------------------+
mysql> SET @sys.statement_truncate_len = 32;
mysql> SELECT format_statement(@stmt);
+-----------------------------------+
| format_statement(@stmt)           |
+-----------------------------------+
| SELECT variabl ... ROM sys_config |
+-----------------------------------+

User Comments
Sign Up Login You must be logged in to post a comment.