Tools fail on tables named 0 (zero)

Bug #1206636 reported by Mark Devlin
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Confirmed
Medium
Unassigned

Bug Description

All of the percona-toolkit tools die, gracefully, if a database has a table named `0` (zero). This appears to be the case for all versions up to and including 2.2.4.

The problem is that the $tbl variable will evaluate to false anywhere it's checked.

While naming a table zero is not the smartest thing, it is a valid table name and the toolkit should be able to handle it.

PTDEBUG=1 pt-duplicate-key-checker
# /usr/bin/perl 5.014002
# Linux kvstoredb101 3.2.0-48-generic #74-Ubuntu SMP Thu Jun 6 19:43:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
# Arguments:
# OptionParser:1259 12696 Option rule: This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details.
# OptionParser:1268 12696 =item --all-structs
# OptionParser:1287 12696 Option has no attributes
# OptionParser:1295 12696 Short help: Compare indexes with different structs (BTREE, HASH, etc)
# OptionParser:1268 12696 =item --ask-pass
# OptionParser:1287 12696 Option has no attributes
# OptionParser:1295 12696 Short help: Prompt for a password when connecting to MySQL
# OptionParser:1268 12696 =item --charset
# OptionParser:1295 12696 Short help: Default character set
# OptionParser:1268 12696 =item --[no]clustered
# OptionParser:1295 12696 Short help: PK columns appended to secondary key is duplicate
# OptionParser:1268 12696 =item --config
# OptionParser:1295 12696 Short help: Read this comma-separated list of config files; if specified, this must be the first option on the command line
# OptionParser:1268 12696 =item --databases
# OptionParser:1295 12696 Short help: Check only this comma-separated list of databases
# OptionParser:1268 12696 =item --defaults-file
# OptionParser:1295 12696 Short help: Only read mysql options from the given file
# OptionParser:1268 12696 =item --engines
# OptionParser:1295 12696 Short help: Check only tables whose storage engine is in this comma-separated list
# OptionParser:1268 12696 =item --help
# OptionParser:1287 12696 Option has no attributes
# OptionParser:1295 12696 Short help: Show help and exit
# OptionParser:1268 12696 =item --host
# OptionParser:1295 12696 Short help: Connect to host
# OptionParser:1268 12696 =item --ignore-databases
# OptionParser:1295 12696 Short help: Ignore this comma-separated list of databases
# OptionParser:1268 12696 =item --ignore-engines
# OptionParser:1295 12696 Short help: Ignore this comma-separated list of storage engines
# OptionParser:1268 12696 =item --ignore-order
# OptionParser:1287 12696 Option has no attributes
# OptionParser:1295 12696 Short help: Ignore index order so KEY(a,b) duplicates KEY(b,a)
# OptionParser:1268 12696 =item --ignore-tables
# OptionParser:1295 12696 Short help: Ignore this comma-separated list of tables
# OptionParser:1268 12696 =item --key-types
# OptionParser:1295 12696 Short help: Check for duplicate f=foreign keys, k=keys or fk=both
# OptionParser:1268 12696 =item --password
# OptionParser:1295 12696 Short help: Password to use when connecting
# OptionParser:1268 12696 =item --pid
# OptionParser:1295 12696 Short help: Create the given PID file
# OptionParser:1268 12696 =item --port
# OptionParser:1295 12696 Short help: Port number to use for connection
# OptionParser:1268 12696 =item --set-vars
# OptionParser:1295 12696 Short help: Set the MySQL variables in this comma-separated list of variable=value pairs
# OptionParser:1268 12696 =item --socket
# OptionParser:1295 12696 Short help: Socket file to use for connection
# OptionParser:1268 12696 =item --[no]sql
# OptionParser:1295 12696 Short help: Print DROP KEY statement for each duplicate key
# OptionParser:1268 12696 =item --[no]summary
# OptionParser:1295 12696 Short help: Print summary of indexes at end of output
# OptionParser:1268 12696 =item --tables
# OptionParser:1295 12696 Short help: Check only this comma-separated list of tables
# OptionParser:1268 12696 =item --user
# OptionParser:1295 12696 Short help: User for login if not current user
# OptionParser:1268 12696 =item --verbose
# OptionParser:1295 12696 Short help: Output all keys and/or foreign keys found, not just redundant ones
# OptionParser:1268 12696 =item --version
# OptionParser:1287 12696 Option has no attributes
# OptionParser:1295 12696 Short help: Show version and exit
# OptionParser:1268 12696 =item --[no]version-check
# OptionParser:1295 12696 Short help: Check for the latest version of Percona Toolkit, MySQL, and other programs
# OptionParser:1334 12696 Parsing opt spec: group => default spec => all-structs desc => Compare indexes with different structs (BTREE, HASH, etc)
# OptionParser:1372 12696 all-structs type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => ask-pass desc => Prompt for a password when connecting to MySQL
# OptionParser:1372 12696 ask-pass type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => charset|A=s desc => Default character set
# OptionParser:1372 12696 charset type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => clustered! desc => PK columns appended to secondary key is duplicate (default yes)
# OptionParser:1372 12696 clustered type: undef
# OptionParser:1379 12696 clustered default: yes
# OptionParser:1334 12696 Parsing opt spec: group => default spec => config=A desc => Read this comma-separated list of config files; if specified, this must be the first option on the command line
# OptionParser:1372 12696 config type: A
# OptionParser:1334 12696 Parsing opt spec: group => default spec => databases|d=h desc => Check only this comma-separated list of databases
# OptionParser:1372 12696 databases type: h
# OptionParser:1334 12696 Parsing opt spec: group => default spec => defaults-file|F=s desc => Only read mysql options from the given file
# OptionParser:1372 12696 defaults-file type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => engines|e=h desc => Check only tables whose storage engine is in this comma-separated list
# OptionParser:1372 12696 engines type: h
# OptionParser:1334 12696 Parsing opt spec: group => default spec => help desc => Show help and exit
# OptionParser:1372 12696 help type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => host|h=s desc => Connect to host
# OptionParser:1372 12696 host type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => ignore-databases=H desc => Ignore this comma-separated list of databases
# OptionParser:1372 12696 ignore-databases type: H
# OptionParser:1334 12696 Parsing opt spec: group => default spec => ignore-engines=H desc => Ignore this comma-separated list of storage engines
# OptionParser:1372 12696 ignore-engines type: H
# OptionParser:1334 12696 Parsing opt spec: group => default spec => ignore-order desc => Ignore index order so KEY(a,b) duplicates KEY(b,a)
# OptionParser:1372 12696 ignore-order type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => ignore-tables=H desc => Ignore this comma-separated list of tables
# OptionParser:1372 12696 ignore-tables type: H
# OptionParser:1334 12696 Parsing opt spec: group => default spec => key-types=s desc => Check for duplicate f=foreign keys, k=keys or fk=both (default fk)
# OptionParser:1372 12696 key-types type: s
# OptionParser:1379 12696 key-types default: fk
# OptionParser:1334 12696 Parsing opt spec: group => default spec => password|p=s desc => Password to use when connecting
# OptionParser:1372 12696 password type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => pid=s desc => Create the given PID file
# OptionParser:1372 12696 pid type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => port|P=i desc => Port number to use for connection
# OptionParser:1372 12696 port type: i
# OptionParser:1334 12696 Parsing opt spec: group => default spec => set-vars=A desc => Set the MySQL variables in this comma-separated list of variable=value pairs
# OptionParser:1372 12696 set-vars type: A
# OptionParser:1334 12696 Parsing opt spec: group => default spec => socket|S=s desc => Socket file to use for connection
# OptionParser:1372 12696 socket type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => sql! desc => Print DROP KEY statement for each duplicate key (default yes)
# OptionParser:1372 12696 sql type: undef
# OptionParser:1379 12696 sql default: yes
# OptionParser:1334 12696 Parsing opt spec: group => default spec => summary! desc => Print summary of indexes at end of output (default yes)
# OptionParser:1372 12696 summary type: undef
# OptionParser:1379 12696 summary default: yes
# OptionParser:1334 12696 Parsing opt spec: group => default spec => tables|t=h desc => Check only this comma-separated list of tables
# OptionParser:1372 12696 tables type: h
# OptionParser:1334 12696 Parsing opt spec: group => default spec => user|u=s desc => User for login if not current user
# OptionParser:1372 12696 user type: s
# OptionParser:1334 12696 Parsing opt spec: group => default spec => verbose|v desc => Output all keys and/or foreign keys found, not just redundant ones
# OptionParser:1372 12696 verbose type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => version desc => Show version and exit
# OptionParser:1372 12696 version type: undef
# OptionParser:1334 12696 Parsing opt spec: group => default spec => version-check! desc => Check for the latest version of Percona Toolkit, MySQL, and other programs (default yes)
# OptionParser:1372 12696 version-check type: undef
# OptionParser:1379 12696 version-check default: yes
# OptionParser:1394 12696 Parsing rule: This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details.
# OptionParser:1450 12696 Participants for This tool accepts additional command-line arguments. Refer to the SYNOPSIS and usage information for details. :
# OptionParser:1426 12696 Strict mode disabled by rule
# OptionParser:1178 12696 Parsing DSN OPTIONS
# OptionParser:1268 12696 =item * A
# OptionParser:1295 12696 Short help: Default character set
# OptionParser:1268 12696 =item * D
# OptionParser:1295 12696 Short help: Default database
# OptionParser:1268 12696 =item * F
# OptionParser:1295 12696 Short help: Only read default options from the given file
# OptionParser:1268 12696 =item * h
# OptionParser:1295 12696 Short help: Connect to host
# OptionParser:1268 12696 =item * p
# OptionParser:1295 12696 Short help: Password to use when connecting
# OptionParser:1268 12696 =item * P
# OptionParser:1295 12696 Short help: Port number to use for connection
# OptionParser:1268 12696 =item * S
# OptionParser:1295 12696 Short help: Socket file to use for connection
# OptionParser:1268 12696 =item * u
# OptionParser:1295 12696 Short help: User for login if not current user
# DSNParser:697 12696 DSN option: copy=1, dsn=charset, desc=Default character set, key=A
# DSNParser:697 12696 DSN option: copy=1, dsn=database, desc=Default database, key=D
# DSNParser:697 12696 DSN option: copy=1, dsn=mysql_read_default_file, desc=Only read default options from the given file, key=F
# DSNParser:697 12696 DSN option: copy=1, dsn=host, desc=Connect to host, key=h
# DSNParser:697 12696 DSN option: copy=1, dsn=password, desc=Password to use when connecting, key=p
# DSNParser:697 12696 DSN option: copy=1, dsn=port, desc=Port number to use for connection, key=P
# DSNParser:697 12696 DSN option: copy=1, dsn=mysql_socket, desc=Socket file to use for connection, key=S
# DSNParser:697 12696 DSN option: copy=1, dsn=user, desc=User for login if not current user, key=u
# OptionParser:1222 12696 pt-duplicate-key-checker 2.2.4
# OptionParser:1534 12696 Cannot open /etc/percona-toolkit/percona-toolkit.conf: No such file or directory
#
# OptionParser:1534 12696 Cannot open /etc/percona-toolkit/pt-duplicate-key-checker.conf: No such file or directory
#
# OptionParser:1534 12696 Cannot open /root/.percona-toolkit.conf: No such file or directory
#
# OptionParser:1534 12696 Cannot open /root/.pt-duplicate-key-checker.conf: No such file or directory
#
# OptionParser:1722 12696 Nothing to validate for option key-types type s value fk
# OptionParser:1722 12696 Nothing to validate for option engines type h value undef
# OptionParser:1722 12696 Nothing to validate for option tables type h value undef
# OptionParser:1722 12696 Nothing to validate for option password type s value undef
# OptionParser:1722 12696 Nothing to validate for option pid type s value undef
# OptionParser:1722 12696 Nothing to validate for option user type s value undef
# OptionParser:1722 12696 Nothing to validate for option databases type h value undef
# OptionParser:1722 12696 Nothing to validate for option charset type s value undef
# OptionParser:1722 12696 Nothing to validate for option port type i value undef
# OptionParser:1722 12696 Nothing to validate for option socket type s value undef
# OptionParser:1722 12696 Nothing to validate for option defaults-file type s value undef
# OptionParser:1722 12696 Nothing to validate for option host type s value undef
# OptionParser:2116 12696 --set-vars: $VAR1 = {
# wait_timeout => {
# default => 1,
# val => '10000'
# }
# };
#
# DSNParser:713 12696 Setting set-vars property
# OptionParser:1796 12696 Getting description and usage from SYNOPSIS in /usr/bin/pt-duplicate-key-checker
# OptionParser:2049 12696 Parsing SYNOPSIS in /usr/bin/pt-duplicate-key-checker
# OptionParser:2062 12696 Raw SYNOPSIS text: Usage: pt-duplicate-key-checker [OPTIONS] [DSN]
#
# pt-duplicate-key-checker examines MySQL tables for duplicate or redundant
# indexes and foreign keys. Connection options are read from MySQL option files.
#
#
# OptionParser:1800 12696 Description: pt-duplicate-key-checker examines MySQL tables for duplicate or redundant indexes and foreign keys. Connection options are read from MySQL option files.
# Usage: pt-duplicate-key-checker [OPTIONS] [DSN]
# DSNParser:785 12696 DSN string made from options:
# DSNParser:722 12696 No DSN to parse
# DSNParser:838 12696 DBI:mysql:;;mysql_read_default_group=client
# DSNParser:887 12696 DBI:mysql:;;mysql_read_default_group=client undef undef mysql_enable_utf8=>0, ShowErrorStatement=>1, AutoCommit=>1, RaiseError=>1, PrintError=>0
# DSNParser:915 12696 DBI::db=HASH(0x2101010) SELECT @@SQL_MODE
# DSNParser:1046 12696 DBI::db=HASH(0x2101010) SET SESSION wait_timeout=10000
# DSNParser:946 12696 DBI::db=HASH(0x2101010) SET @@SQL_QUOTE_SHOW_CREATE = 1/*!40101, @@SQL_MODE='NO_AUTO_VALUE_ON_ZERO'*/
# DSNParser:955 12696 DBH info: DBI::db=HASH(0x2101010) $VAR1 = {
# '@@hostname' => 'kvstoredb101',
# 'CONNECTION_ID()' => '43718',
# 'DATABASE()' => undef,
# 'VERSION()' => '5.5.31-30.3-log'
# };
# Connection info: Localhost via UNIX socket Character set info: $VAR1 = [
# {
# Value => 'latin1',
# Variable_name => 'character_set_client'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_connection'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_database'
# },
# {
# Value => 'binary',
# Variable_name => 'character_set_filesystem'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_results'
# },
# {
# Value => 'latin1',
# Variable_name => 'character_set_server'
# },
# {
# Value => 'utf8',
# Variable_name => 'character_set_system'
# },
# {
# Value => '/usr/share/mysql/charsets/',
# Variable_name => 'character_sets_dir'
# }
# ];
# $DBD::mysql::VERSION: 4.020 $DBI::VERSION: 1.616
# VersionCheck:4251 12696 FindBin::Bin: /usr/bin
# VersionCheck:4410 12696 SELECT CONCAT(@@hostname, @@port)
# VersionCheck:4431 12696 MySQL instance: 2c42ba74b0839b4f8d614182a11f38c4 kvstoredb1013306 $VAR1 = undef;
#
# VersionCheck:4231 12696 Version check file percona-version-check in /tmp
# VersionCheck:4345 12696 Version check file /tmp/percona-version-check contents: 0,1375208084
# 2c42ba74b0839b4f8d614182a11f38c4,1375208084
# VersionCheck:4353 12696 Intsance 2c42ba74b0839b4f8d614182a11f38c4 last checked 1375208084 now 1375208094 diff 10 hours until next check 24.00
# VersionCheck:4353 12696 Intsance 0 last checked 1375208084 now 1375208094 diff 10 hours until next check 24.00
# VersionCheck:4274 12696 0 instances to check
# SchemaIterator:3175 12696 Schema object filters: $VAR1 = {};
#
# SchemaIterator:3286 12696 Getting next schema object from dbh DBI::db=HASH(0x2101010)
# SchemaIterator:3290 12696 SHOW DATABASES
# SchemaIterator:3368 12696 Database information_schema is a system database, ignoring
# SchemaIterator:3368 12696 Database performance_schema is a system database, ignoring
# SchemaIterator:3296 12696 Found 6 databases
# SchemaIterator:3303 12696 Next database: IDM
# SchemaIterator:3309 12696 SHOW /*!50002 FULL*/ TABLES FROM `IDM`
I need a tbl argument at /usr/bin/pt-duplicate-key-checker line 3401.

Tags: all-tools
tags: added: all-tools
Changed in percona-toolkit:
milestone: none → 2.2.5
importance: Undecided → Medium
status: New → Confirmed
summary: - percona tools fail on tables named 0 (zero)
+ Tools fail on tables named 0 (zero)
Changed in percona-toolkit:
milestone: 2.2.5 → none
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-619

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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