LP #924872: userstat.patch has several bugs (incorrectly ported from Google Tools for MySQL)
Description
Environment
Smart Checklist
Activity

Julia Vural March 4, 2025 at 9:04 PM
It appears that this issue is no longer being worked on, so we are closing it for housekeeping purposes. If you believe the issue still exists, please open a new ticket after confirming it's present in the latest release.

lpjirasync January 21, 2018 at 12:15 PM
**Comment from Launchpad by: Laurynas Biveinis on: 01-08-2013 14:15:53
Fernando -
If it's not repeatable it could have been fixed in the last year and a half, feel free to review the release notes or bugs tagged with "userstat".

lpjirasync January 21, 2018 at 12:15 PM
**Comment from Launchpad by: Fernando Ipar on: 30-07-2013 21:54:10
I am not seeing the "Counter from *_STATISTICS don't update while connection live" part on 5.5.32-31.0.
I read a table from multiple threads and table_statistics.Rows_read reliably increases while the connections are open.
Is there a repeatable test case for this somewhere?

lpjirasync January 21, 2018 at 12:14 PM
**Comment from Launchpad by: Raghavendra D Prabhu on: 19-09-2012 20:17:50
Tested on PS 5.5:
1)
SHOW CLIENT_STATISTICS like '%localhost%'\G
*************************** 1. row ***************************
Client: localhost
Total_connections: 2
Concurrent_connections: 0
Connected_time: 24
Busy_time: 0
Cpu_time: 0
Bytes_received: 243
Bytes_sent: 0
Binlog_bytes_written: 0
Rows_fetched: 4
Rows_updated: 0
Table_rows_read: 0
Select_commands: 4
Update_commands: 0
Other_commands: 1
Commit_transactions: 0
Rollback_transactions: 0
Denied_connections: 0
Lost_connections: 0
Access_denied: 0
Empty_queries: 0
Total_ssl_connections: 0
1 row in set (0.00 sec)
mysql> SHOW CLIENT_STATISTICS like '%localhost%'\G
*************************** 1. row ***************************
Client: localhost
Total_connections: 2
Concurrent_connections: 0
Connected_time: 122
Busy_time: 0
Cpu_time: 0
Bytes_received: 289
Bytes_sent: 0
Binlog_bytes_written: 0
Rows_fetched: 5
Rows_updated: 0
Table_rows_read: 0
Select_commands: 5
Update_commands: 0
Other_commands: 1
Commit_transactions: 0
Rollback_transactions: 0
Denied_connections: 0
Lost_connections: 0
Access_denied: 0
Empty_queries: 0
Total_ssl_connections: 0
1 row in set (0.00 sec)
mysql> SHOW CLIENT_STATISTICS like '%localhost%'\G
*************************** 1. row ***************************
Client: localhost
Total_connections: 2
Concurrent_connections: 0
Connected_time: 124
Busy_time: 0
Cpu_time: 0
Bytes_received: 335
Bytes_sent: 0
Binlog_bytes_written: 0
Rows_fetched: 6
Rows_updated: 0
Table_rows_read: 0
Select_commands: 6
Update_commands: 0
Other_commands: 1
Commit_transactions: 0
Rollback_transactions: 0
Denied_connections: 0
Lost_connections: 0
Access_denied: 0
Empty_queries: 0
Total_ssl_connections: 0
1 row in set (0.00 sec)
2)
select * from table_statistics\G
*************************** 1. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: user
ROWS_READ: 7
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
*************************** 2. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: proxies_priv
ROWS_READ: 2
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
*************************** 3. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: db
ROWS_READ: 2
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
3 rows in set (0.00 sec)
mysql> select * from mysql.user\G
..........
.........
mysql> select * from table_statistics\G
*************************** 1. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: user
ROWS_READ: 14
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
*************************** 2. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: proxies_priv
ROWS_READ: 2
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
*************************** 3. row ***************************
TABLE_SCHEMA: mysql
TABLE_NAME: db
ROWS_READ: 2
ROWS_CHANGED: 0
ROWS_CHANGED_X_INDEXES: 0
3 rows in set (0.00 sec)
3)
Regarding " * Incorrectly counted the kind of queries (Other/Select/etc)"
the statistics for queries are counted correctly.
However,
a) CONCURRENT_CONNECTIONS is always zero and is no where updated in the code . It needs to be fixed.
b) Empty queries doesn't count for queries like 'show global variables like "%... "'
Details
Assignee
UnassignedUnassignedReporter
lpjirasynclpjirasync(Deactivated)Labels
Priority
High
Details
Details
Assignee
Reporter

Labels
Priority
Smart Checklist
Open Smart Checklist
Smart Checklist
Open Smart Checklist
Smart Checklist

**Reported in Launchpad by Oleg Tsarev last update 17-03-2016 15:47:02
userstat.patch has several bugs:
WHERE and LIKE don't work with SHOW syntax (i.e. doesn't work (for example) SHOW CLIENT_STATISTICS LIKE 'client_name%')
Counter from *_STATISTICS don't update while connection live (updates from connection go to statistics just after connection close)
Incorrectly counted the kind of queries (Other/Select/etc)