Bug #71634 P_S digest looks wrong for system variables, shown as @ @ variable...
Submitted: 8 Feb 2014 12:03 Modified: 16 May 2014 9:32
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6.16 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any
Tags: windmill

[8 Feb 2014 12:03] Simon Mudd
Description:
I notice this row on a server in P_S.events_statements_current:

               SQL_TEXT: SELECT COUNT(*) AS num_long_running, @@long_query_time AS long_running_time FROM information_schema.processlist WHERE time > @@long_query_time AND state IN ('Locked', 'Waiting for table', 'Waiting for tables', 'Waiting for table flush', 'Waiting for release of readlock', 'Waiting for event metadata lock', 'Waiting for schema metadata lock', 'Waiting for stored function metadata lock', 'Waiting for stored procedure metadata lock', 'Waiting for table level lock', 'Waiting for table metadata lock', 'Waiting for trigger metadata lock', 'User lock') limit 1
                 DIGEST: e1536e4d0ac1b09f9605de1b54386cb4
            DIGEST_TEXT: SELECT COUNT ( * ) AS num_long_running , @ @ long_query_time AS long_running_time FROM information_schema . processlist WHERE TIME > @ @ long_query_time AND state IN (...) LIMIT ? 

It looks to me as if the normalised digest should show @@long_query_time and not @ @ long_query_time which in my opinion looks and is wrong.

Perhaps it's not critical but it does look strange and as "normalised" SQL is not really correct.

I think this query may have been produced by MEM 3.0.6 but am not entirely sure, but the query itself is not the issue it's the digest.

How to repeat:
See above.

Suggested fix:
System variables like @@hostname, @@long_query_time should when the query is normalised look the same. So please consider fixing these.
[25 Feb 2014 9:23] Marc ALFF
Verified as described.

The DIGEST TEXT printed should print queries with a valid syntax.

Given that:
- "SELECT @@hostname" is valid
- "SELECT @ @ hostname" is invalid,

this is a bug.
[16 May 2014 2:40] Paul DuBois
Noted in 5.7.5 changelog.

In the DIGEST_TEXT column of Performance Schema statement events
tables, references to system variables of the form @@var_name were
stored as @ @ var_name.
[16 May 2014 9:32] Simon Mudd
No mention made of 5.6 in the fix, just 5.7.5. So will you be backporting the fix to 5.6 too?
[17 Feb 2015 0:56] Paul DuBois
Noted in 5.6.24 changelog.
[27 Apr 2015 14:29] Laurynas Biveinis
commit 305130361bf72726de220f3d2b2787395e10be61
Author: Marc Alff <marc.alff@oracle.com>
Date:   Tue Feb 10 11:31:32 2015 +0100

    WL#8354 BACKPORT DIGEST IMPROVEMENTS TO MYSQL 5.6