pt-index-usage ignores --database

Bug #1028614 reported by Bryan Aldridge on 2012-07-24
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to
Fix Released
Daniel Nichter
Fix Committed
Daniel Nichter
Fix Released
Daniel Nichter

Bug Description

Using output of "pt-query-digest --type tcpdump --no-report --print" as input to pt-index-usage with the --database option does not work. pt-index-usage connects to the "mysql" database, and attempts to change that with -D or --database option does not help.

Errors similar to ...

"DBD::mysql::db selectall_arrayref failed: Table 'mysql.<table name in other database>' doesn't exist [for Statement "EXPLAIN SELECT....."]

...are thrown for each query in the file produced by pt-query-digest after calling pt-index-usage.

Using percona-toolkit-2.1.2-1.noarch on Red Hat Enterprise Linux 5.8, MySQL 5.5.22 server and client.

Related branches

Changed in percona-toolkit:
status: New → Triaged
milestone: none → 2.1.3
importance: Undecided → Medium
tags: added: default-db
tags: added: standard-options
Changed in percona-toolkit:
status: Triaged → In Progress
assignee: nobody → Daniel Nichter (daniel-nichter)
summary: - pt-index-usage doesn't pay attention to --database option
+ pt-index-usage ignores --database
Daniel Nichter (daniel-nichter) wrote :

I can reproduce this:

$ ./pt-index-usage --database sakila ../t/pt-index-usage/samples/slow006.txt -h 127.1 -P 12345 -u msandbox -p msandbox
DBD::mysql::db selectall_arrayref failed: Table 'z.film_text' doesn't exist [for Statement "EXPLAIN select * from film_text"] at ./pt-index-usage line 4263, <> line 1.

The --database (-D) works, but the tool isn't restoring it after it gets SHOW CREATE TABLE defs for tables from other dbs. So in the above, the "z" database is the last db the tool accesses, leaving it as the current db.

Daniel Nichter (daniel-nichter) wrote :

This was supposedly fixed for and there's a test case, but apparently it's not a very good test case.

Percona now uses JIRA for bug reports so this bug report is migrated to:

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.