Skip to content

Instantly share code, notes, and snippets.

@Thomascountz
Created September 14, 2022 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thomascountz/fa749ed2abd80310f9c8eb74bd84891a to your computer and use it in GitHub Desktop.
Save Thomascountz/fa749ed2abd80310f9c8eb74bd84891a to your computer and use it in GitHub Desktop.
Why is SQL_TEXT NULL?

This is an example of selecting * that will need to execute for more than the set timeout of 1ms.

mysql> select * /*+ MAX_EXECUTION_TIME(1) */ from test_table;
ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded

mysql> select thread_id,event_name,sql_text,digest_text,current_schema,mysql_errno,returned_sqlstate,message_text,errors from performance_schema.events_statements_history where mysql_errno = 3024 limit 1\G
*************************** 1. row ***************************
        thread_id: 345
       event_name: statement/sql/select
         sql_text: NULL         
      digest_text: SELECT /*+ MAX_EXECUTION_TIME (?) */ * FROM `test_table`
   current_schema: test
      mysql_errno: 3024
returned_sqlstate: HY000
     message_text: Query execution was interrupted, maximum statement execution time exceeded
           errors: 1
1 row in set (0.01 sec)

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.30    |
+-----------+
1 row in set (0.00 sec)

The documentation states:

For a command not associated with an SQL statement, the value is NULL. source

But as far as I can tell, this command is associated with a SQL statement, hence the event being called statement/sql/select.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment