Bug #75765 Performance Schema statement digest generation is broken with null values

Submitted: 4 Feb 2015 15:17 Modified: 10 Mar 2015 13:30
Reporter: Joe Grasse (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.6.23 OS:Any
Assigned to: Marc ALFF CPU Architecture:Any
Tags: digest, performance_schema

[4 Feb 2015 15:17] Joe Grasse
Description:
Statements with null values generate more statement digest than they should.

How to repeat:
use test
CREATE TABLE digest_test (id int not null, txt varchar(20), txt2 varchar (20), txt3 varchar(20), primary key (id));
UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';
INSERT INTO digest_test VALUES (1, 'foo', 'bar', 'hello');
UPDATE digest_test SET txt = 'foo', txt2 = 'bar', txt3 = null where id = 1;
UPDATE digest_test SET txt = 'foo', txt2 = null, txt3 = 'hello' where id = 1;
UPDATE digest_test SET txt = null, txt2 = 'bar', txt3 = 'hello' where id = 1;
SELECT SQL_TEXT,DIGEST,DIGEST_TEXT FROM performance_schema.events_statements_history;

Suggested fix:
The update statements listed should only generate one digest.
[4 Feb 2015 23:07] MySQL Verification Team
Thank you for the bug report. Just 5.6 affected.

C:\dbs>net start mysqld56
The MySQLD56 service is starting.
The MySQLD56 service was started successfully.

C:\dbs>56

C:\dbs>c:\dbs\5.6\bin\mysql -uroot --port=3560 --debug-info --prompt="mysql 5.6 > "
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.24 Source distribution

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.6 > SELECT * FROM performance_schema.setup_consumers WHERE name = 'statements_digest';
+-------------------+---------+
| NAME              | ENABLED |
+-------------------+---------+
| statements_digest | YES     |
+-------------------+---------+
1 row in set (0.00 sec)

mysql 5.6 > use test
Database changed
mysql 5.6 > CREATE TABLE digest_test (id int not null, txt varchar(20), txt2 varchar (20), txt3 varchar(20), primary key (id));
Query OK, 0 rows affected (0.27 sec)

mysql 5.6 > UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 4  Changed: 2  Warnings: 0

mysql 5.6 > INSERT INTO digest_test VALUES (1, 'foo', 'bar', 'hello');
Query OK, 1 row affected (0.03 sec)

mysql 5.6 > UPDATE digest_test SET txt = 'foo', txt2 = 'bar', txt3 = null where id = 1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.6 > UPDATE digest_test SET txt = 'foo', txt2 = null, txt3 = 'hello' where id = 1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.6 > UPDATE digest_test SET txt = null, txt2 = 'bar', txt3 = 'hello' where id = 1;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.6 > SELECT SQL_TEXT,DIGEST,DIGEST_TEXT FROM performance_schema.events_statements_history;
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
| SQL_TEXT                                                                                     | DIGEST                           | DIGEST_TEXT                                                                    |
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
| UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%' | b8e52ce9f72eff66025a0ae4876e9696 | UPDATE performance_schema . setup_consumers SET ENABLED = ? WHERE NAME LIKE ?  |
| INSERT INTO digest_test VALUES (1, 'foo', 'bar', 'hello')                                    | 413d9173e5bace3d24d8242405d0814d | INSERT INTO digest_test VALUES (...)                                           |
| UPDATE digest_test SET txt = 'foo', txt2 = 'bar', txt3 = null where id = 1                   | f1c10dc26335f5ab4e8d963f84c6e720 | UPDATE digest_test SET txt = ? , txt2 = ? , txt3 = NULL WHERE id = ?           |
| UPDATE digest_test SET txt = 'foo', txt2 = null, txt3 = 'hello' where id = 1                 | afcb29de1fc419d2ddb1b4298b5ca791 | UPDATE digest_test SET txt = ? , txt2 = NULL , txt3 = ? WHERE id = ?           |
| UPDATE digest_test SET txt = null, txt2 = 'bar', txt3 = 'hello' where id = 1                 | e5eb6458dc1733dd92d6a3ffd03b3621 | UPDATE digest_test SET txt = NULL , txt2 = ? , txt3 = ? WHERE id = ?           |
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
5 rows in set (0.00 sec)

mysql 5.6 > exit
Bye

C:\dbs>net start mysqld57
The MySQLD57 service is starting...
The MySQLD57 service was started successfully.

C:\dbs>57

C:\dbs>c:\dbs\5.7\bin\mysql -uroot --port=3570 --prompt="mysql 5.7 > "
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.7.6-m16-debug Source distribution

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > use test
Database changed
mysql 5.7 > CREATE TABLE digest_test (id int not null, txt varchar(20), txt2 varchar (20), txt3 varchar(20), primary key (id));
Query OK, 0 rows affected (0.33 sec)

mysql 5.7 > UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 4  Changed: 2  Warnings: 0

mysql 5.7 > INSERT INTO digest_test VALUES (1, 'foo', 'bar', 'hello');
Query OK, 1 row affected (0.03 sec)

mysql 5.7 > UPDATE digest_test SET txt = 'foo', txt2 = 'bar', txt3 = null where id = 1;
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.7 > UPDATE digest_test SET txt = 'foo', txt2 = null, txt3 = 'hello' where id = 1;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.7 > UPDATE digest_test SET txt = null, txt2 = 'bar', txt3 = 'hello' where id = 1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql 5.7 > SELECT SQL_TEXT,DIGEST,DIGEST_TEXT FROM performance_schema.events_statements_history;
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
| SQL_TEXT                                                                                     | DIGEST                           | DIGEST_TEXT                                                                    |
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
| UPDATE performance_schema.setup_consumers SET ENABLED = 'YES' WHERE NAME LIKE '%statements%' | 6f2ef0e3df7d9764b0485717dcd05012 | UPDATE performance_schema . setup_consumers SET ENABLED = ? WHERE NAME LIKE ?  |
| INSERT INTO digest_test VALUES (1, 'foo', 'bar', 'hello')                                    | 8e5fb1dd792ddd81cb028e4d686e311f | INSERT INTO digest_test VALUES (...)                                           |
| UPDATE digest_test SET txt = 'foo', txt2 = 'bar', txt3 = null where id = 1                   | bfa7d81b371d288b15cdfbdcd60e4182 | UPDATE digest_test SET txt = ? , txt2 = ? , txt3 = ? WHERE id = ?              |
| UPDATE digest_test SET txt = 'foo', txt2 = null, txt3 = 'hello' where id = 1                 | bfa7d81b371d288b15cdfbdcd60e4182 | UPDATE digest_test SET txt = ? , txt2 = ? , txt3 = ? WHERE id = ?              |
| UPDATE digest_test SET txt = null, txt2 = 'bar', txt3 = 'hello' where id = 1                 | bfa7d81b371d288b15cdfbdcd60e4182 | UPDATE digest_test SET txt = ? , txt2 = ? , txt3 = ? WHERE id = ?              |
+----------------------------------------------------------------------------------------------+----------------------------------+--------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
[10 Mar 2015 12:51] Marc ALFF
The bug is fixed in 5.7.6 (as reported)

The bug is now also fixed in 5.6.24 (documentation in progress)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.053 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.