LP #1008796: Several tools don't have --database

Description

**Reported in Launchpad by Baron Schwartz last update 22-03-2013 22:56:58

I think this option ought to be pretty much universal unless we can think of a reason not to use it. It lets us set the initial database for a connection.

Environment

None

Smart Checklist

Activity

lpjirasync January 24, 2018 at 3:40 PM

**Comment from Launchpad by: Daniel Nichter on: 05-12-2012 17:32:13

And these have --database (-D):

pt-heartbeat
pt-index-usage
pt-kill
pt-query-advisor
pt-show-grants
pt-slave-delay
pt-slave-find
pt-slave-restart
pt-table-usage
pt-visual-explain

So yes, we're rather inconsistent. pt-archiver not having it became an issue recently because shell tools can/should be able to pass everything after – to a tool, but pt-archiver doesn't have --database. Other standard MySQL program options align like this (by design): --user, --host, etc.

I think we should add --database to all those tools, Brian. Since DSNParser picks up --database because its short form is -D, just adding the option should be enough (then it's magically used as the default db for each connection). But requires, though, that the DSN OPTIONS section lists a D item, because that's part of the magic too.

lpjirasync January 24, 2018 at 3:40 PM

**Comment from Launchpad by: Brian Fraser on: 05-12-2012 17:22:57

Turns out that all of these lack --database:

pt-archiver
pt-config-diff
pt-deadlock-logger
pt-duplicate-key-checker
pt-fk-error-logger
pt-log-player
pt-online-schema-change
pt-query-digest
pt-table-checksum
pt-table-sync
pt-upgrade
pt-variable-advisor

lpjirasync January 24, 2018 at 3:40 PM

**Comment from Launchpad by: Brian Fraser on: 08-11-2012 20:08:54

Looks like pt-slave-delay already has a --database option; ptc doesn't, but has --databases and it's shortcut -d. The attached branch adds a second alias, so that it now accepts --databases, -d, and --database. It's a minor cosmetic fix, but option standardization is a good thing overall.

Done
Created January 24, 2018 at 3:39 PM
Updated January 24, 2018 at 3:40 PM
Resolved January 24, 2018 at 3:40 PM