Merge lp:~mauricio-stekl/percona-toolkit/pt-docs-percona-theme into lp:percona-toolkit/2.0

Proposed by Daniel Nichter
Status: Superseded
Proposed branch: lp:~mauricio-stekl/percona-toolkit/pt-docs-percona-theme
Merge into: lp:percona-toolkit/2.0
Diff against target: 75776 lines (+33086/-6245) (has conflicts)
181 files modified
Changelog (+18/-2)
MANIFEST (+2/-2)
Makefile.PL (+1/-1)
bin/pt-archiver (+196/-196)
bin/pt-collect (+1/-1)
bin/pt-config-diff (+118/-118)
bin/pt-deadlock-logger (+96/-96)
bin/pt-diskstats (+1/-1)
bin/pt-duplicate-key-checker (+207/-207)
bin/pt-fifo-split (+54/-54)
bin/pt-find (+135/-135)
bin/pt-fk-error-logger (+90/-90)
bin/pt-heartbeat (+195/-195)
bin/pt-index-usage (+271/-271)
bin/pt-kill (+190/-190)
bin/pt-log-player (+157/-157)
bin/pt-mext (+1/-1)
bin/pt-mysql-summary (+1/-1)
bin/pt-online-schema-change (+216/-216)
bin/pt-pmp (+1/-1)
bin/pt-query-advisor (+316/-316)
bin/pt-query-digest (+695/-670)
bin/pt-show-grants (+85/-85)
bin/pt-sift (+1/-1)
bin/pt-slave-delay (+106/-106)
bin/pt-slave-find (+133/-133)
bin/pt-slave-restart (+139/-139)
bin/pt-stalk (+1/-1)
bin/pt-summary (+1/-1)
bin/pt-table-checksum (+350/-350)
bin/pt-table-sync (+455/-455)
bin/pt-tcp-model (+77/-77)
bin/pt-trend (+73/-67)
bin/pt-upgrade (+533/-533)
bin/pt-variable-advisor (+111/-111)
bin/pt-visual-explain (+75/-75)
config/deb/changelog (+15/-0)
config/sphinx-build/Makefile (+131/-0)
config/sphinx-build/conf.py (+6/-6)
config/sphinx-build/percona-theme/layout.html (+473/-0)
config/sphinx-build/percona-theme/searchbox.html (+22/-0)
config/sphinx-build/percona-theme/static/default.css_t (+469/-0)
config/sphinx-build/percona-theme/static/jquery.min.js (+154/-0)
config/sphinx-build/percona-theme/static/percona.com.css (+1/-0)
config/sphinx-build/percona-theme/static/percona.com.js (+242/-0)
config/sphinx-build/percona-theme/static/sidebar.js (+151/-0)
config/sphinx-build/percona-theme/theme.conf (+32/-0)
docs/index.rst (+59/-0)
docs/installation.rst (+25/-0)
docs/percona-toolkit.pod (+1/-1)
docs/release_notes.rst (+28/-0)
docs/user/pt-archiver.rst.OTHER (+1556/-0)
docs/user/pt-collect.rst.OTHER (+264/-0)
docs/user/pt-config-diff.rst.OTHER (+518/-0)
docs/user/pt-deadlock-logger.rst.OTHER (+760/-0)
docs/user/pt-diskstats.rst.OTHER (+390/-0)
docs/user/pt-duplicate-key-checker.rst.OTHER (+563/-0)
docs/user/pt-fifo-split.rst.OTHER (+305/-0)
docs/user/pt-find.rst.OTHER (+977/-0)
docs/user/pt-fk-error-logger.rst.OTHER (+493/-0)
docs/user/pt-heartbeat.rst.OTHER (+874/-0)
docs/user/pt-index-usage.rst.OTHER (+840/-0)
docs/user/pt-kill.rst.OTHER (+1053/-0)
docs/user/pt-log-player.rst.OTHER (+795/-0)
docs/user/pt-mext.rst.OTHER (+224/-0)
docs/user/pt-mysql-summary.rst.OTHER (+233/-0)
docs/user/pt-online-schema-change.rst.OTHER (+807/-0)
docs/user/pt-pmp.rst.OTHER (+244/-0)
docs/user/pt-query-advisor.rst.OTHER (+848/-0)
docs/user/pt-query-digest.rst.OTHER (+2561/-0)
docs/user/pt-show-grants.rst.OTHER (+534/-0)
docs/user/pt-sift.rst.OTHER (+273/-0)
docs/user/pt-slave-delay.rst.OTHER (+532/-0)
docs/user/pt-slave-find.rst.OTHER (+543/-0)
docs/user/pt-slave-restart.rst.OTHER (+755/-0)
docs/user/pt-stalk.rst.OTHER (+367/-0)
docs/user/pt-summary.rst.OTHER (+230/-0)
docs/user/pt-table-checksum.rst.OTHER (+2036/-0)
docs/user/pt-table-sync.rst.OTHER (+1627/-0)
docs/user/pt-tcp-model.rst.OTHER (+531/-0)
docs/user/pt-trend.rst.OTHER (+266/-0)
docs/user/pt-upgrade.rst.OTHER (+824/-0)
docs/user/pt-variable-advisor.rst.OTHER (+1100/-0)
docs/user/pt-visual-explain.rst.OTHER (+963/-0)
docs/user/release_notes.rst.OTHER (+69/-0)
docs/user/version.rst.OTHER (+7/-0)
lib/Advisor.pm (+6/-6)
lib/AdvisorRules.pm (+1/-1)
lib/BinaryLogParser.pm (+17/-17)
lib/ChangeHandler.pm (+18/-18)
lib/CompareQueryTimes.pm (+3/-3)
lib/CompareResults.pm (+37/-37)
lib/CompareWarnings.pm (+11/-11)
lib/CopyRowsInsertSelect.pm (+3/-3)
lib/DSNParser.pm (+21/-21)
lib/Daemon.pm (+12/-12)
lib/DuplicateKeyFinder.pm (+26/-26)
lib/EventAggregator.pm (+27/-27)
lib/EventTimeline.pm (+3/-3)
lib/ExecutionThrottler.pm (+5/-5)
lib/ExplainAnalyzer.pm (+8/-8)
lib/FileIterator.pm (+4/-4)
lib/GeneralLogParser.pm (+9/-9)
lib/HTTPProtocolParser.pm (+22/-22)
lib/IndexUsage.pm (+8/-8)
lib/KeySize.pm (+4/-4)
lib/LogSplitter.pm (+18/-18)
lib/MasterSlave.pm (+41/-41)
lib/MemcachedEvent.pm (+6/-6)
lib/MemcachedProtocolParser.pm (+38/-38)
lib/MockSth.pm (+1/-1)
lib/MockSync.pm (+1/-1)
lib/MockSyncStream.pm (+1/-1)
lib/MySQLConfig.pm (+14/-14)
lib/MySQLConfigComparer.pm (+4/-4)
lib/MySQLDump.pm (+19/-19)
lib/MySQLProtocolParser.pm (+83/-83)
lib/OSCCaptureSync.pm (+1/-1)
lib/OptionParser.pm (+39/-39)
lib/Outfile.pm (+1/-1)
lib/PerconaTest.pm (+1/-1)
lib/PgLogParser.pm (+46/-46)
lib/Pipeline.pm (+6/-6)
lib/PodParser.pm (+12/-12)
lib/Processlist.pm (+32/-32)
lib/Progress.pm (+1/-1)
lib/ProtocolParser.pm (+18/-18)
lib/QueryAdvisorRules.pm (+10/-10)
lib/QueryParser.pm (+26/-26)
lib/QueryReportFormatter.pm (+38/-13)
lib/QueryReview.pm (+4/-4)
lib/QueryRewriter.pm (+9/-9)
lib/Quoter.pm (+1/-1)
lib/ReportFormatter.pm (+17/-17)
lib/Retry.pm (+8/-8)
lib/RowDiff.pm (+21/-21)
lib/Runtime.pm (+8/-8)
lib/SQLParser.pm (+52/-52)
lib/Sandbox.pm (+5/-5)
lib/Schema.pm (+15/-15)
lib/SchemaIterator.pm (+37/-33)
lib/SimpleTCPDumpParser.pm (+2/-2)
lib/SlowLogParser.pm (+17/-17)
lib/SlowLogWriter.pm (+1/-1)
lib/SysLogParser.pm (+21/-21)
lib/TCPRequestAggregator.pm (+20/-20)
lib/TableChecksum.pm (+16/-16)
lib/TableChunker.pm (+60/-60)
lib/TableNibbler.pm (+14/-5)
lib/TableParser.pm (+28/-28)
lib/TableSyncChunk.pm (+15/-15)
lib/TableSyncGroupBy.pm (+2/-2)
lib/TableSyncNibble.pm (+29/-29)
lib/TableSyncStream.pm (+1/-1)
lib/TableSyncer.pm (+39/-39)
lib/TcpdumpParser.pm (+2/-2)
lib/TextResultSetParser.pm (+4/-4)
lib/TimeSeriesTrender.pm (+1/-1)
lib/Transformers.pm (+8/-8)
lib/UpgradeReportFormatter.pm (+1/-1)
lib/VariableAdvisorRules.pm (+2/-2)
lib/VersionParser.pm (+5/-5)
t/lib/DSNParser.t (+1/-1)
t/lib/Daemon.t (+1/-1)
t/lib/ExecutionThrottler.t (+1/-1)
t/lib/ExplainAnalyzer.t (+1/-1)
t/lib/FileIterator.t (+1/-1)
t/lib/IndexUsage.t (+1/-1)
t/lib/Progress.t (+1/-1)
t/lib/SchemaIterator.t (+1/-1)
t/lib/TableSyncer.t (+5/-5)
t/pt-deadlock-logger/clear_deadlocks.t (+2/-2)
t/pt-query-digest/issue_1186.t (+2/-2)
t/pt-query-digest/issue_232.t (+1/-1)
t/pt-query-digest/mirror.t (+2/-2)
t/pt-table-checksum/force_index.t (+2/-2)
t/pt-table-checksum/schema.t (+2/-2)
t/pt-table-checksum/since.t (+3/-3)
t/pt-table-sync/basics.t (+8/-8)
t/pt-table-sync/force_index.t (+2/-2)
util/write-user-docs (+9/-17)
Text conflict in Changelog
Text conflict in bin/pt-query-digest
Text conflict in bin/pt-trend
Contents conflict in docs/user/pt-archiver.rst
Contents conflict in docs/user/pt-collect.rst
Contents conflict in docs/user/pt-config-diff.rst
Contents conflict in docs/user/pt-deadlock-logger.rst
Contents conflict in docs/user/pt-diskstats.rst
Contents conflict in docs/user/pt-duplicate-key-checker.rst
Contents conflict in docs/user/pt-fifo-split.rst
Contents conflict in docs/user/pt-find.rst
Contents conflict in docs/user/pt-fk-error-logger.rst
Contents conflict in docs/user/pt-heartbeat.rst
Contents conflict in docs/user/pt-index-usage.rst
Contents conflict in docs/user/pt-kill.rst
Contents conflict in docs/user/pt-log-player.rst
Contents conflict in docs/user/pt-mext.rst
Contents conflict in docs/user/pt-mysql-summary.rst
Contents conflict in docs/user/pt-online-schema-change.rst
Contents conflict in docs/user/pt-pmp.rst
Contents conflict in docs/user/pt-query-advisor.rst
Contents conflict in docs/user/pt-query-digest.rst
Contents conflict in docs/user/pt-show-grants.rst
Contents conflict in docs/user/pt-sift.rst
Contents conflict in docs/user/pt-slave-delay.rst
Contents conflict in docs/user/pt-slave-find.rst
Contents conflict in docs/user/pt-slave-restart.rst
Contents conflict in docs/user/pt-stalk.rst
Contents conflict in docs/user/pt-summary.rst
Contents conflict in docs/user/pt-table-checksum.rst
Contents conflict in docs/user/pt-table-sync.rst
Contents conflict in docs/user/pt-tcp-model.rst
Contents conflict in docs/user/pt-trend.rst
Contents conflict in docs/user/pt-upgrade.rst
Contents conflict in docs/user/pt-variable-advisor.rst
Contents conflict in docs/user/pt-visual-explain.rst
Contents conflict in docs/user/release_notes.rst
Contents conflict in docs/user/version.rst
Text conflict in lib/QueryReportFormatter.pm
Text conflict in lib/SchemaIterator.pm
Text conflict in lib/TableNibbler.pm
To merge this branch: bzr merge lp:~mauricio-stekl/percona-toolkit/pt-docs-percona-theme
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+87090@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Unmerged revisions

126. By Mauricio Stekl

first import of Makefile

125. By Mauricio Stekl

import new favicon

124. By Mauricio Stekl

first import of static rst

123. By Mauricio Stekl

modifications to use static index and instalattion rst files

122. By Mauricio Stekl

added configuration to use percona theme

121. By Mauricio Stekl

Added files for Percona website theme

120. By Daniel Nichter

Add download link to release notes.

119. By Daniel Nichter

Write 1.0.2 release notes.

118. By Daniel Nichter

Updates for 1.0.2 release.

117. By Daniel Nichter

Update Changelog for 1.0.2.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Changelog'
2--- Changelog 2011-10-11 14:31:42 +0000
3+++ Changelog 2011-12-29 16:12:24 +0000
4@@ -1,7 +1,23 @@
5 Changelog for Percona Toolkit
6
7- * Fixed bug 821717: pt-tcp-model --type=requests crashes
8-
9+<<<<<<< TREE
10+ * Fixed bug 821717: pt-tcp-model --type=requests crashes
11+
12+=======
13+v1.0.2 released 2011-12-22
14+
15+ * Fixed bug 856065: pt-trend does not work
16+ * Fixed bug 887688: Prepared statements crash pt-query-digest
17+ * Fixed bug 903513: MKDEBUG should be PTDEBUG
18+ * Fixed bug 857091: pt-sift downloads http://percona.com/get/pt-pmp, which does not work
19+ * Fixed bug 857104: pt-sift tries to invoke mext, should be pt-mext
20+ * Fixed bug 884504: pt-stalk doesn't check pt-collect
21+ * Fixed bug 821717: pt-tcp-model --type=requests crashes
22+ * Fixed bug 844038: pt-online-schema-change documentation example w/drop-tmp-table does not work
23+ * Fixed bug 898663: Typo in pt-log-player documentation
24+ * Fixed bug 903753: Typo in pt-table-checksum documentation
25+
26+>>>>>>> MERGE-SOURCE
27 v1.0.1 released 2011-09-01
28
29 * Fixed bug 819421: MasterSlave::is_replication_thread() doesn't match all
30
31=== modified file 'MANIFEST'
32--- MANIFEST 2011-08-05 21:32:28 +0000
33+++ MANIFEST 2011-12-29 16:12:24 +0000
34@@ -1,8 +1,8 @@
35+COPYING
36 Changelog
37-COPYING
38 INSTALL
39+MANIFEST
40 Makefile.PL
41-MANIFEST
42 README
43 bin/pt-archiver
44 bin/pt-collect
45
46=== modified file 'Makefile.PL'
47--- Makefile.PL 2011-09-01 16:00:38 +0000
48+++ Makefile.PL 2011-12-29 16:12:24 +0000
49@@ -2,7 +2,7 @@
50
51 WriteMakefile(
52 NAME => 'percona-toolkit',
53- VERSION => '1.0.1',
54+ VERSION => '1.0.2',
55 EXE_FILES => [ <bin/*> ],
56 MAN1PODS => {
57 'docs/percona-toolkit.pod' => 'blib/man1/percona-toolkit.1',
58
59=== modified file 'bin/pt-archiver'
60--- bin/pt-archiver 2011-09-01 16:00:38 +0000
61+++ bin/pt-archiver 2011-12-29 16:12:24 +0000
62@@ -6,7 +6,7 @@
63
64 use strict;
65 use warnings FATAL => 'all';
66-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
67+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
68
69 # ###########################################################################
70 # OptionParser package
71@@ -22,7 +22,7 @@
72 use strict;
73 use warnings FATAL => 'all';
74 use English qw(-no_match_vars);
75-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
76+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
77
78 use List::Util qw(max);
79 use Getopt::Long;
80@@ -106,7 +106,7 @@
81 my $contents = do { local $/ = undef; <$fh> };
82 close $fh;
83 if ( $contents =~ m/^=head1 DSN OPTIONS/m ) {
84- MKDEBUG && _d('Parsing DSN OPTIONS');
85+ PTDEBUG && _d('Parsing DSN OPTIONS');
86 my $dsn_attribs = {
87 dsn => 1,
88 copy => 1,
89@@ -150,7 +150,7 @@
90
91 if ( $contents =~ m/^=head1 VERSION\n\n^(.+)$/m ) {
92 $self->{version} = $1;
93- MKDEBUG && _d($self->{version});
94+ PTDEBUG && _d($self->{version});
95 }
96
97 return;
98@@ -187,7 +187,7 @@
99 chomp $para;
100 $para =~ s/\s+/ /g;
101 $para =~ s/$POD_link_re/$1/go;
102- MKDEBUG && _d('Option rule:', $para);
103+ PTDEBUG && _d('Option rule:', $para);
104 push @rules, $para;
105 }
106
107@@ -196,7 +196,7 @@
108 do {
109 if ( my ($option) = $para =~ m/^=item $self->{item}/ ) {
110 chomp $para;
111- MKDEBUG && _d($para);
112+ PTDEBUG && _d($para);
113 my %attribs;
114
115 $para = <$fh>; # read next paragraph, possibly attributes
116@@ -215,7 +215,7 @@
117 $para = <$fh>; # read next paragraph, probably short help desc
118 }
119 else {
120- MKDEBUG && _d('Option has no attributes');
121+ PTDEBUG && _d('Option has no attributes');
122 }
123
124 $para =~ s/\s+\Z//g;
125@@ -223,7 +223,7 @@
126 $para =~ s/$POD_link_re/$1/go;
127
128 $para =~ s/\.(?:\n.*| [A-Z].*|\Z)//s;
129- MKDEBUG && _d('Short help:', $para);
130+ PTDEBUG && _d('Short help:', $para);
131
132 die "No description after option spec $option" if $para =~ m/^=item/;
133
134@@ -261,7 +261,7 @@
135
136 foreach my $opt ( @specs ) {
137 if ( ref $opt ) { # It's an option spec, not a rule.
138- MKDEBUG && _d('Parsing opt spec:',
139+ PTDEBUG && _d('Parsing opt spec:',
140 map { ($_, '=>', $opt->{$_}) } keys %$opt);
141
142 my ( $long, $short ) = $opt->{spec} =~ m/^([\w-]+)(?:\|([^!+=]*))?/;
143@@ -274,7 +274,7 @@
144 $self->{opts}->{$long} = $opt;
145
146 if ( length $long == 1 ) {
147- MKDEBUG && _d('Long opt', $long, 'looks like short opt');
148+ PTDEBUG && _d('Long opt', $long, 'looks like short opt');
149 $self->{short_opts}->{$long} = $long;
150 }
151
152@@ -300,14 +300,14 @@
153
154 my ( $type ) = $opt->{spec} =~ m/=(.)/;
155 $opt->{type} = $type;
156- MKDEBUG && _d($long, 'type:', $type);
157+ PTDEBUG && _d($long, 'type:', $type);
158
159
160 $opt->{spec} =~ s/=./=s/ if ( $type && $type =~ m/[HhAadzm]/ );
161
162 if ( (my ($def) = $opt->{desc} =~ m/default\b(?: ([^)]+))?/) ) {
163 $self->{defaults}->{$long} = defined $def ? $def : 1;
164- MKDEBUG && _d($long, 'default:', $def);
165+ PTDEBUG && _d($long, 'default:', $def);
166 }
167
168 if ( $long eq 'config' ) {
169@@ -316,13 +316,13 @@
170
171 if ( (my ($dis) = $opt->{desc} =~ m/(disables .*)/) ) {
172 $disables{$long} = $dis;
173- MKDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
174+ PTDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
175 }
176
177 $self->{opts}->{$long} = $opt;
178 }
179 else { # It's an option rule, not a spec.
180- MKDEBUG && _d('Parsing rule:', $opt);
181+ PTDEBUG && _d('Parsing rule:', $opt);
182 push @{$self->{rules}}, $opt;
183 my @participants = $self->_get_participants($opt);
184 my $rule_ok = 0;
185@@ -330,17 +330,17 @@
186 if ( $opt =~ m/mutually exclusive|one and only one/ ) {
187 $rule_ok = 1;
188 push @{$self->{mutex}}, \@participants;
189- MKDEBUG && _d(@participants, 'are mutually exclusive');
190+ PTDEBUG && _d(@participants, 'are mutually exclusive');
191 }
192 if ( $opt =~ m/at least one|one and only one/ ) {
193 $rule_ok = 1;
194 push @{$self->{atleast1}}, \@participants;
195- MKDEBUG && _d(@participants, 'require at least one');
196+ PTDEBUG && _d(@participants, 'require at least one');
197 }
198 if ( $opt =~ m/default to/ ) {
199 $rule_ok = 1;
200 $self->{defaults_to}->{$participants[0]} = $participants[1];
201- MKDEBUG && _d($participants[0], 'defaults to', $participants[1]);
202+ PTDEBUG && _d($participants[0], 'defaults to', $participants[1]);
203 }
204 if ( $opt =~ m/restricted to option groups/ ) {
205 $rule_ok = 1;
206@@ -354,7 +354,7 @@
207 if( $opt =~ m/accepts additional command-line arguments/ ) {
208 $rule_ok = 1;
209 $self->{strict} = 0;
210- MKDEBUG && _d("Strict mode disabled by rule");
211+ PTDEBUG && _d("Strict mode disabled by rule");
212 }
213
214 die "Unrecognized option rule: $opt" unless $rule_ok;
215@@ -364,7 +364,7 @@
216 foreach my $long ( keys %disables ) {
217 my @participants = $self->_get_participants($disables{$long});
218 $self->{disables}->{$long} = \@participants;
219- MKDEBUG && _d('Option', $long, 'disables', @participants);
220+ PTDEBUG && _d('Option', $long, 'disables', @participants);
221 }
222
223 return;
224@@ -378,7 +378,7 @@
225 unless exists $self->{opts}->{$long};
226 push @participants, $long;
227 }
228- MKDEBUG && _d('Participants for', $str, ':', @participants);
229+ PTDEBUG && _d('Participants for', $str, ':', @participants);
230 return @participants;
231 }
232
233@@ -401,7 +401,7 @@
234 die "Cannot set default for nonexistent option $long"
235 unless exists $self->{opts}->{$long};
236 $self->{defaults}->{$long} = $defaults{$long};
237- MKDEBUG && _d('Default val for', $long, ':', $defaults{$long});
238+ PTDEBUG && _d('Default val for', $long, ':', $defaults{$long});
239 }
240 return;
241 }
242@@ -430,7 +430,7 @@
243 $opt->{value} = $val;
244 }
245 $opt->{got} = 1;
246- MKDEBUG && _d('Got option', $long, '=', $val);
247+ PTDEBUG && _d('Got option', $long, '=', $val);
248 }
249
250 sub get_opts {
251@@ -461,7 +461,7 @@
252 if ( $self->got('config') ) {
253 die $EVAL_ERROR;
254 }
255- elsif ( MKDEBUG ) {
256+ elsif ( PTDEBUG ) {
257 _d($EVAL_ERROR);
258 }
259 }
260@@ -528,7 +528,7 @@
261 if ( exists $self->{disables}->{$long} ) {
262 my @disable_opts = @{$self->{disables}->{$long}};
263 map { $self->{opts}->{$_}->{value} = undef; } @disable_opts;
264- MKDEBUG && _d('Unset options', @disable_opts,
265+ PTDEBUG && _d('Unset options', @disable_opts,
266 'because', $long,'disables them');
267 }
268
269@@ -577,7 +577,7 @@
270 delete $long[$i];
271 }
272 else {
273- MKDEBUG && _d('Temporarily failed to parse', $long);
274+ PTDEBUG && _d('Temporarily failed to parse', $long);
275 }
276 }
277
278@@ -601,12 +601,12 @@
279 my $val = $opt->{value};
280
281 if ( $val && $opt->{type} eq 'm' ) { # type time
282- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
283+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
284 my ( $prefix, $num, $suffix ) = $val =~ m/([+-]?)(\d+)([a-z])?$/;
285 if ( !$suffix ) {
286 my ( $s ) = $opt->{desc} =~ m/\(suffix (.)\)/;
287 $suffix = $s || 's';
288- MKDEBUG && _d('No suffix given; using', $suffix, 'for',
289+ PTDEBUG && _d('No suffix given; using', $suffix, 'for',
290 $opt->{long}, '(value:', $val, ')');
291 }
292 if ( $suffix =~ m/[smhd]/ ) {
293@@ -615,23 +615,23 @@
294 : $suffix eq 'h' ? $num * 3600 # Hours
295 : $num * 86400; # Days
296 $opt->{value} = ($prefix || '') . $val;
297- MKDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
298+ PTDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
299 }
300 else {
301 $self->save_error("Invalid time suffix for --$opt->{long}");
302 }
303 }
304 elsif ( $val && $opt->{type} eq 'd' ) { # type DSN
305- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
306+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
307 my $prev = {};
308 my $from_key = $self->{defaults_to}->{ $opt->{long} };
309 if ( $from_key ) {
310- MKDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
311+ PTDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
312 if ( $self->{opts}->{$from_key}->{parsed} ) {
313 $prev = $self->{opts}->{$from_key}->{value};
314 }
315 else {
316- MKDEBUG && _d('Cannot parse', $opt->{long}, 'until',
317+ PTDEBUG && _d('Cannot parse', $opt->{long}, 'until',
318 $from_key, 'parsed');
319 return;
320 }
321@@ -640,7 +640,7 @@
322 $opt->{value} = $self->{DSNParser}->parse($val, $prev, $defaults);
323 }
324 elsif ( $val && $opt->{type} eq 'z' ) { # type size
325- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
326+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
327 $self->_parse_size($opt, $val);
328 }
329 elsif ( $opt->{type} eq 'H' || (defined $val && $opt->{type} eq 'h') ) {
330@@ -650,7 +650,7 @@
331 $opt->{value} = [ split(/(?<!\\),\s*/, ($val || '')) ];
332 }
333 else {
334- MKDEBUG && _d('Nothing to validate for option',
335+ PTDEBUG && _d('Nothing to validate for option',
336 $opt->{long}, 'type', $opt->{type}, 'value', $val);
337 }
338
339@@ -724,11 +724,11 @@
340 $file ||= $self->{file} || __FILE__;
341
342 if ( !$self->{description} || !$self->{usage} ) {
343- MKDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
344+ PTDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
345 my %synop = $self->_parse_synopsis($file);
346 $self->{description} ||= $synop{description};
347 $self->{usage} ||= $synop{usage};
348- MKDEBUG && _d("Description:", $self->{description},
349+ PTDEBUG && _d("Description:", $self->{description},
350 "\nUsage:", $self->{usage});
351 }
352
353@@ -943,7 +943,7 @@
354 my ( $self, $opt, $val ) = @_;
355
356 if ( lc($val || '') eq 'null' ) {
357- MKDEBUG && _d('NULL size for', $opt->{long});
358+ PTDEBUG && _d('NULL size for', $opt->{long});
359 $opt->{value} = 'null';
360 return;
361 }
362@@ -953,7 +953,7 @@
363 if ( defined $num ) {
364 if ( $factor ) {
365 $num *= $factor_for{$factor};
366- MKDEBUG && _d('Setting option', $opt->{y},
367+ PTDEBUG && _d('Setting option', $opt->{y},
368 'to num', $num, '* factor', $factor);
369 }
370 $opt->{value} = ($pre || '') . $num;
371@@ -977,7 +977,7 @@
372 sub _parse_synopsis {
373 my ( $self, $file ) = @_;
374 $file ||= $self->{file} || __FILE__;
375- MKDEBUG && _d("Parsing SYNOPSIS in", $file);
376+ PTDEBUG && _d("Parsing SYNOPSIS in", $file);
377
378 local $INPUT_RECORD_SEPARATOR = ''; # read paragraphs
379 open my $fh, "<", $file or die "Cannot open $file: $OS_ERROR";
380@@ -990,7 +990,7 @@
381 push @synop, $para;
382 }
383 close $fh;
384- MKDEBUG && _d("Raw SYNOPSIS text:", @synop);
385+ PTDEBUG && _d("Raw SYNOPSIS text:", @synop);
386 my ($usage, $desc) = @synop;
387 die "The SYNOPSIS section in $file is not formatted properly"
388 unless $usage && $desc;
389@@ -1017,7 +1017,7 @@
390 print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
391 }
392
393-if ( MKDEBUG ) {
394+if ( PTDEBUG ) {
395 print '# ', $^X, ' ', $], "\n";
396 if ( my $uname = `uname -a` ) {
397 $uname =~ s/\s+/ /g;
398@@ -1047,7 +1047,7 @@
399 use strict;
400 use warnings FATAL => 'all';
401 use English qw(-no_match_vars);
402-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
403+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
404
405 use Data::Dumper;
406 $Data::Dumper::Indent = 1;
407@@ -1092,7 +1092,7 @@
408
409 my @defs = $ddl =~ m/^(\s+`.*?),?$/gm;
410 my @cols = map { $_ =~ m/`([^`]+)`/ } @defs;
411- MKDEBUG && _d('Table cols:', join(', ', map { "`$_`" } @cols));
412+ PTDEBUG && _d('Table cols:', join(', ', map { "`$_`" } @cols));
413
414 my %def_for;
415 @def_for{@cols} = @defs;
416@@ -1153,7 +1153,7 @@
417 }
418 sort keys %{$tbl->{keys}};
419
420- MKDEBUG && _d('Indexes sorted best-first:', join(', ', @indexes));
421+ PTDEBUG && _d('Indexes sorted best-first:', join(', ', @indexes));
422 return @indexes;
423 }
424
425@@ -1171,7 +1171,7 @@
426 ($best) = $self->sort_indexes($tbl);
427 }
428 }
429- MKDEBUG && _d('Best index found is', $best);
430+ PTDEBUG && _d('Best index found is', $best);
431 return $best;
432 }
433
434@@ -1180,25 +1180,25 @@
435 return () unless $where;
436 my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
437 . ' WHERE ' . $where;
438- MKDEBUG && _d($sql);
439+ PTDEBUG && _d($sql);
440 my $expl = $dbh->selectrow_hashref($sql);
441 $expl = { map { lc($_) => $expl->{$_} } keys %$expl };
442 if ( $expl->{possible_keys} ) {
443- MKDEBUG && _d('possible_keys =', $expl->{possible_keys});
444+ PTDEBUG && _d('possible_keys =', $expl->{possible_keys});
445 my @candidates = split(',', $expl->{possible_keys});
446 my %possible = map { $_ => 1 } @candidates;
447 if ( $expl->{key} ) {
448- MKDEBUG && _d('MySQL chose', $expl->{key});
449+ PTDEBUG && _d('MySQL chose', $expl->{key});
450 unshift @candidates, grep { $possible{$_} } split(',', $expl->{key});
451- MKDEBUG && _d('Before deduping:', join(', ', @candidates));
452+ PTDEBUG && _d('Before deduping:', join(', ', @candidates));
453 my %seen;
454 @candidates = grep { !$seen{$_}++ } @candidates;
455 }
456- MKDEBUG && _d('Final list:', join(', ', @candidates));
457+ PTDEBUG && _d('Final list:', join(', ', @candidates));
458 return @candidates;
459 }
460 else {
461- MKDEBUG && _d('No keys in possible_keys');
462+ PTDEBUG && _d('No keys in possible_keys');
463 return ();
464 }
465 }
466@@ -1212,66 +1212,66 @@
467 my ($dbh, $db, $tbl) = @args{@required_args};
468 my $q = $self->{Quoter};
469 my $db_tbl = $q->quote($db, $tbl);
470- MKDEBUG && _d('Checking', $db_tbl);
471+ PTDEBUG && _d('Checking', $db_tbl);
472
473 my $sql = "SHOW TABLES FROM " . $q->quote($db)
474 . ' LIKE ' . $q->literal_like($tbl);
475- MKDEBUG && _d($sql);
476+ PTDEBUG && _d($sql);
477 my $row;
478 eval {
479 $row = $dbh->selectrow_arrayref($sql);
480 };
481 if ( $EVAL_ERROR ) {
482- MKDEBUG && _d($EVAL_ERROR);
483+ PTDEBUG && _d($EVAL_ERROR);
484 return 0;
485 }
486 if ( !$row->[0] || $row->[0] ne $tbl ) {
487- MKDEBUG && _d('Table does not exist');
488+ PTDEBUG && _d('Table does not exist');
489 return 0;
490 }
491
492- MKDEBUG && _d('Table exists; no privs to check');
493+ PTDEBUG && _d('Table exists; no privs to check');
494 return 1 unless $args{all_privs};
495
496 $sql = "SHOW FULL COLUMNS FROM $db_tbl";
497- MKDEBUG && _d($sql);
498+ PTDEBUG && _d($sql);
499 eval {
500 $row = $dbh->selectrow_hashref($sql);
501 };
502 if ( $EVAL_ERROR ) {
503- MKDEBUG && _d($EVAL_ERROR);
504+ PTDEBUG && _d($EVAL_ERROR);
505 return 0;
506 }
507 if ( !scalar keys %$row ) {
508- MKDEBUG && _d('Table has no columns:', Dumper($row));
509+ PTDEBUG && _d('Table has no columns:', Dumper($row));
510 return 0;
511 }
512 my $privs = $row->{privileges} || $row->{Privileges};
513
514 $sql = "DELETE FROM $db_tbl LIMIT 0";
515- MKDEBUG && _d($sql);
516+ PTDEBUG && _d($sql);
517 eval {
518 $dbh->do($sql);
519 };
520 my $can_delete = $EVAL_ERROR ? 0 : 1;
521
522- MKDEBUG && _d('User privs on', $db_tbl, ':', $privs,
523+ PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
524 ($can_delete ? 'delete' : ''));
525
526 if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
527 && $can_delete) ) {
528- MKDEBUG && _d('User does not have all privs');
529+ PTDEBUG && _d('User does not have all privs');
530 return 0;
531 }
532
533- MKDEBUG && _d('User has all privs');
534+ PTDEBUG && _d('User has all privs');
535 return 1;
536 }
537
538 sub get_engine {
539 my ( $self, $ddl, $opts ) = @_;
540 my ( $engine ) = $ddl =~ m/\).*?(?:ENGINE|TYPE)=(\w+)/;
541- MKDEBUG && _d('Storage engine:', $engine);
542+ PTDEBUG && _d('Storage engine:', $engine);
543 return $engine || undef;
544 }
545
546@@ -1287,7 +1287,7 @@
547 next KEY if $key =~ m/FOREIGN/;
548
549 my $key_ddl = $key;
550- MKDEBUG && _d('Parsed key:', $key_ddl);
551+ PTDEBUG && _d('Parsed key:', $key_ddl);
552
553 if ( $engine !~ m/MEMORY|HEAP/ ) {
554 $key =~ s/USING HASH/USING BTREE/;
555@@ -1313,7 +1313,7 @@
556 }
557 $name =~ s/`//g;
558
559- MKDEBUG && _d( $name, 'key cols:', join(', ', map { "`$_`" } @cols));
560+ PTDEBUG && _d( $name, 'key cols:', join(', ', map { "`$_`" } @cols));
561
562 $keys->{$name} = {
563 name => $name,
564@@ -1335,7 +1335,7 @@
565 elsif ( $this_key->{is_unique} && !$this_key->{is_nullable} ) {
566 $clustered_key = $this_key->{name};
567 }
568- MKDEBUG && $clustered_key && _d('This key is the clustered key');
569+ PTDEBUG && $clustered_key && _d('This key is the clustered key');
570 }
571 }
572
573@@ -1403,7 +1403,7 @@
574 }
575 grep { $_->{name} ne $clustered_key }
576 values %{$tbl_struct->{keys}};
577- MKDEBUG && _d('Secondary indexes:', Dumper(\@sec_indexes));
578+ PTDEBUG && _d('Secondary indexes:', Dumper(\@sec_indexes));
579
580 if ( @sec_indexes ) {
581 $sec_indexes_ddl = join(' ', @sec_indexes);
582@@ -1413,7 +1413,7 @@
583 $ddl =~ s/,(\n\) )/$1/s;
584 }
585 else {
586- MKDEBUG && _d('Not removing secondary indexes from',
587+ PTDEBUG && _d('Not removing secondary indexes from',
588 $tbl_struct->{engine}, 'table');
589 }
590
591@@ -1448,7 +1448,7 @@
592 use strict;
593 use warnings FATAL => 'all';
594 use English qw(-no_match_vars);
595-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
596+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
597
598 use Data::Dumper;
599 $Data::Dumper::Indent = 0;
600@@ -1471,7 +1471,7 @@
601 if ( !$opt->{key} || !$opt->{desc} ) {
602 die "Invalid DSN option: ", Dumper($opt);
603 }
604- MKDEBUG && _d('DSN option:',
605+ PTDEBUG && _d('DSN option:',
606 join(', ',
607 map { "$_=" . (defined $opt->{$_} ? ($opt->{$_} || '') : 'undef') }
608 keys %$opt
609@@ -1489,7 +1489,7 @@
610 sub prop {
611 my ( $self, $prop, $value ) = @_;
612 if ( @_ > 2 ) {
613- MKDEBUG && _d('Setting', $prop, 'property');
614+ PTDEBUG && _d('Setting', $prop, 'property');
615 $self->{$prop} = $value;
616 }
617 return $self->{$prop};
618@@ -1498,10 +1498,10 @@
619 sub parse {
620 my ( $self, $dsn, $prev, $defaults ) = @_;
621 if ( !$dsn ) {
622- MKDEBUG && _d('No DSN to parse');
623+ PTDEBUG && _d('No DSN to parse');
624 return;
625 }
626- MKDEBUG && _d('Parsing', $dsn);
627+ PTDEBUG && _d('Parsing', $dsn);
628 $prev ||= {};
629 $defaults ||= {};
630 my %given_props;
631@@ -1513,23 +1513,23 @@
632 $given_props{$prop_key} = $prop_val;
633 }
634 else {
635- MKDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
636+ PTDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
637 $given_props{h} = $dsn_part;
638 }
639 }
640
641 foreach my $key ( keys %$opts ) {
642- MKDEBUG && _d('Finding value for', $key);
643+ PTDEBUG && _d('Finding value for', $key);
644 $final_props{$key} = $given_props{$key};
645 if ( !defined $final_props{$key}
646 && defined $prev->{$key} && $opts->{$key}->{copy} )
647 {
648 $final_props{$key} = $prev->{$key};
649- MKDEBUG && _d('Copying value for', $key, 'from previous DSN');
650+ PTDEBUG && _d('Copying value for', $key, 'from previous DSN');
651 }
652 if ( !defined $final_props{$key} ) {
653 $final_props{$key} = $defaults->{$key};
654- MKDEBUG && _d('Copying value for', $key, 'from defaults');
655+ PTDEBUG && _d('Copying value for', $key, 'from defaults');
656 }
657 }
658
659@@ -1560,7 +1560,7 @@
660 grep { $o->has($_) && $o->get($_) }
661 keys %{$self->{opts}}
662 );
663- MKDEBUG && _d('DSN string made from options:', $dsn_string);
664+ PTDEBUG && _d('DSN string made from options:', $dsn_string);
665 return $self->parse($dsn_string);
666 }
667
668@@ -1610,7 +1610,7 @@
669 qw(F h P S A))
670 . ';mysql_read_default_group=client';
671 }
672- MKDEBUG && _d($dsn);
673+ PTDEBUG && _d($dsn);
674 return ($dsn, $info->{u}, $info->{p});
675 }
676
677@@ -1655,7 +1655,7 @@
678 my $dbh;
679 my $tries = 2;
680 while ( !$dbh && $tries-- ) {
681- MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
682+ PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
683 join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
684
685 eval {
686@@ -1665,21 +1665,21 @@
687 my $sql;
688
689 $sql = 'SELECT @@SQL_MODE';
690- MKDEBUG && _d($dbh, $sql);
691+ PTDEBUG && _d($dbh, $sql);
692 my ($sql_mode) = $dbh->selectrow_array($sql);
693
694 $sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
695 . '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
696 . ($sql_mode ? ",$sql_mode" : '')
697 . '\'*/';
698- MKDEBUG && _d($dbh, $sql);
699+ PTDEBUG && _d($dbh, $sql);
700 $dbh->do($sql);
701
702 if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
703 $sql = "/*!40101 SET NAMES $charset*/";
704- MKDEBUG && _d($dbh, ':', $sql);
705+ PTDEBUG && _d($dbh, ':', $sql);
706 $dbh->do($sql);
707- MKDEBUG && _d('Enabling charset for STDOUT');
708+ PTDEBUG && _d('Enabling charset for STDOUT');
709 if ( $charset eq 'utf8' ) {
710 binmode(STDOUT, ':utf8')
711 or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
712@@ -1691,15 +1691,15 @@
713
714 if ( $self->prop('set-vars') ) {
715 $sql = "SET " . $self->prop('set-vars');
716- MKDEBUG && _d($dbh, ':', $sql);
717+ PTDEBUG && _d($dbh, ':', $sql);
718 $dbh->do($sql);
719 }
720 }
721 };
722 if ( !$dbh && $EVAL_ERROR ) {
723- MKDEBUG && _d($EVAL_ERROR);
724+ PTDEBUG && _d($EVAL_ERROR);
725 if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
726- MKDEBUG && _d('Going to try again without utf8 support');
727+ PTDEBUG && _d('Going to try again without utf8 support');
728 delete $defaults->{mysql_enable_utf8};
729 }
730 elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
731@@ -1717,7 +1717,7 @@
732 }
733 }
734
735- MKDEBUG && _d('DBH info: ',
736+ PTDEBUG && _d('DBH info: ',
737 $dbh,
738 Dumper($dbh->selectrow_hashref(
739 'SELECT DATABASE(), CONNECTION_ID(), VERSION()/*!50038 , @@hostname*/')),
740@@ -1743,7 +1743,7 @@
741
742 sub disconnect {
743 my ( $self, $dbh ) = @_;
744- MKDEBUG && $self->print_active_handles($dbh);
745+ PTDEBUG && $self->print_active_handles($dbh);
746 $dbh->disconnect;
747 }
748
749@@ -1804,7 +1804,7 @@
750 use strict;
751 use warnings FATAL => 'all';
752 use English qw(-no_match_vars);
753-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
754+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
755
756 sub new {
757 my ( $class ) = @_;
758@@ -1814,7 +1814,7 @@
759 sub parse {
760 my ( $self, $str ) = @_;
761 my $result = sprintf('%03d%03d%03d', $str =~ m/(\d+)/g);
762- MKDEBUG && _d($str, 'parses to', $result);
763+ PTDEBUG && _d($str, 'parses to', $result);
764 return $result;
765 }
766
767@@ -1825,7 +1825,7 @@
768 $dbh->selectrow_array('SELECT VERSION()'));
769 }
770 my $result = $self->{$dbh} ge $self->parse($target) ? 1 : 0;
771- MKDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
772+ PTDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
773 return $result;
774 }
775
776@@ -1843,7 +1843,7 @@
777 }
778 @{ $dbh->selectall_arrayref("SHOW ENGINES", {Slice=>{}}) };
779 if ( $innodb ) {
780- MKDEBUG && _d("InnoDB support:", $innodb->{support});
781+ PTDEBUG && _d("InnoDB support:", $innodb->{support});
782 if ( $innodb->{support} =~ m/YES|DEFAULT/i ) {
783 my $vars = $dbh->selectrow_hashref(
784 "SHOW VARIABLES LIKE 'innodb_version'");
785@@ -1855,7 +1855,7 @@
786 }
787 }
788
789- MKDEBUG && _d("InnoDB version:", $innodb_version);
790+ PTDEBUG && _d("InnoDB version:", $innodb_version);
791 return $innodb_version;
792 }
793
794@@ -1887,7 +1887,7 @@
795 use strict;
796 use warnings FATAL => 'all';
797 use English qw(-no_match_vars);
798-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
799+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
800
801 sub new {
802 my ( $class, %args ) = @_;
803@@ -1964,7 +1964,7 @@
804 use strict;
805 use warnings FATAL => 'all';
806 use English qw(-no_match_vars);
807-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
808+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
809
810 sub new {
811 my ( $class, %args ) = @_;
812@@ -1993,11 +1993,11 @@
813 my @asc_slice;
814
815 @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
816- MKDEBUG && _d('Will ascend index', $index);
817- MKDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
818+ PTDEBUG && _d('Will ascend index', $index);
819+ PTDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
820 if ( $args{asc_first} ) {
821 @asc_cols = $asc_cols[0];
822- MKDEBUG && _d('Ascending only first column');
823+ PTDEBUG && _d('Ascending only first column');
824 }
825
826 my %col_posn = do { my $i = 0; map { $_ => $i++ } @cols };
827@@ -2008,7 +2008,7 @@
828 }
829 push @asc_slice, $col_posn{$col};
830 }
831- MKDEBUG && _d('Will ascend, in ordinal position:', join(', ', @asc_slice));
832+ PTDEBUG && _d('Will ascend, in ordinal position:', join(', ', @asc_slice));
833
834 my $asc_stmt = {
835 cols => \@cols,
836@@ -2129,7 +2129,7 @@
837 else {
838 @del_cols = @{$tbl->{cols}};
839 }
840- MKDEBUG && _d('Columns needed for DELETE:', join(', ', @del_cols));
841+ PTDEBUG && _d('Columns needed for DELETE:', join(', ', @del_cols));
842
843 my %col_posn = do { my $i = 0; map { $_ => $i++ } @cols };
844 foreach my $col ( @del_cols ) {
845@@ -2139,7 +2139,7 @@
846 }
847 push @del_slice, $col_posn{$col};
848 }
849- MKDEBUG && _d('Ordinals needed for DELETE:', join(', ', @del_slice));
850+ PTDEBUG && _d('Ordinals needed for DELETE:', join(', ', @del_slice));
851
852 my $del_stmt = {
853 cols => \@cols,
854@@ -2223,7 +2223,7 @@
855 use strict;
856 use warnings FATAL => 'all';
857 use English qw(-no_match_vars);
858-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
859+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
860
861 ( our $before = <<'EOF') =~ s/^ //gm;
862 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
863@@ -2317,11 +2317,11 @@
864 sub _use_db {
865 my ( $self, $dbh, $quoter, $new ) = @_;
866 if ( !$new ) {
867- MKDEBUG && _d('No new DB to use');
868+ PTDEBUG && _d('No new DB to use');
869 return;
870 }
871 my $sql = 'USE ' . $quoter->quote($new);
872- MKDEBUG && _d($dbh, $sql);
873+ PTDEBUG && _d($dbh, $sql);
874 $dbh->do($sql);
875 return;
876 }
877@@ -2333,12 +2333,12 @@
878 . q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
879 . '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
880 . '@@SQL_QUOTE_SHOW_CREATE := 1 */';
881- MKDEBUG && _d($sql);
882+ PTDEBUG && _d($sql);
883 eval { $dbh->do($sql); };
884- MKDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
885+ PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
886 $self->_use_db($dbh, $quoter, $db);
887 $sql = "SHOW CREATE TABLE " . $quoter->quote($db, $tbl);
888- MKDEBUG && _d($sql);
889+ PTDEBUG && _d($sql);
890 my $href;
891 eval { $href = $dbh->selectrow_hashref($sql); };
892 if ( $EVAL_ERROR ) {
893@@ -2348,15 +2348,15 @@
894
895 $sql = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
896 . '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
897- MKDEBUG && _d($sql);
898+ PTDEBUG && _d($sql);
899 $dbh->do($sql);
900 my ($key) = grep { m/create table/i } keys %$href;
901 if ( $key ) {
902- MKDEBUG && _d('This table is a base table');
903+ PTDEBUG && _d('This table is a base table');
904 $self->{tables}->{$db}->{$tbl} = [ 'table', $href->{$key} ];
905 }
906 else {
907- MKDEBUG && _d('This table is a view');
908+ PTDEBUG && _d('This table is a view');
909 ($key) = grep { m/create view/i } keys %$href;
910 $self->{tables}->{$db}->{$tbl} = [ 'view', $href->{$key} ];
911 }
912@@ -2366,11 +2366,11 @@
913
914 sub get_columns {
915 my ( $self, $dbh, $quoter, $db, $tbl ) = @_;
916- MKDEBUG && _d('Get columns for', $db, $tbl);
917+ PTDEBUG && _d('Get columns for', $db, $tbl);
918 if ( !$self->{cache} || !$self->{columns}->{$db}->{$tbl} ) {
919 $self->_use_db($dbh, $quoter, $db);
920 my $sql = "SHOW COLUMNS FROM " . $quoter->quote($db, $tbl);
921- MKDEBUG && _d($sql);
922+ PTDEBUG && _d($sql);
923 my $cols = $dbh->selectall_arrayref($sql, { Slice => {} });
924
925 $self->{columns}->{$db}->{$tbl} = [
926@@ -2391,7 +2391,7 @@
927 map { ' ' . $quoter->quote($_->{field}) . ' ' . $_->{type} }
928 @{$self->get_columns($dbh, $quoter, $db, $tbl)});
929 $result .= "\n)";
930- MKDEBUG && _d($result);
931+ PTDEBUG && _d($result);
932 return $result;
933 }
934
935@@ -2403,11 +2403,11 @@
936 . q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
937 . '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
938 . '@@SQL_QUOTE_SHOW_CREATE := 1 */';
939- MKDEBUG && _d($sql);
940+ PTDEBUG && _d($sql);
941 eval { $dbh->do($sql); };
942- MKDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
943+ PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
944 $sql = "SHOW TRIGGERS FROM " . $quoter->quote($db);
945- MKDEBUG && _d($sql);
946+ PTDEBUG && _d($sql);
947 my $sth = $dbh->prepare($sql);
948 $sth->execute();
949 if ( $sth->rows ) {
950@@ -2420,7 +2420,7 @@
951 }
952 $sql = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
953 . '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
954- MKDEBUG && _d($sql);
955+ PTDEBUG && _d($sql);
956 $dbh->do($sql);
957 }
958 if ( $tbl ) {
959@@ -2439,7 +2439,7 @@
960 push @params, $like;
961 }
962 my $sth = $dbh->prepare($sql);
963- MKDEBUG && _d($sql, @params);
964+ PTDEBUG && _d($sql, @params);
965 $sth->execute( @params );
966 my @dbs = map { $_->[0] } @{$sth->fetchall_arrayref()};
967 $self->{databases} = \@dbs unless $like;
968@@ -2457,7 +2457,7 @@
969 $sql .= ' LIKE ?';
970 push @params, $like;
971 }
972- MKDEBUG && _d($sql, @params);
973+ PTDEBUG && _d($sql, @params);
974 my $sth = $dbh->prepare($sql);
975 $sth->execute(@params);
976 my @tables = @{$sth->fetchall_arrayref({})};
977@@ -2483,7 +2483,7 @@
978 $sql .= ' LIKE ?';
979 push @params, $like;
980 }
981- MKDEBUG && _d($sql, @params);
982+ PTDEBUG && _d($sql, @params);
983 my $sth = $dbh->prepare($sql);
984 $sth->execute(@params);
985 my @tables = @{$sth->fetchall_arrayref()};
986@@ -2528,7 +2528,7 @@
987 use strict;
988 use warnings FATAL => 'all';
989 use English qw(-no_match_vars);
990-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
991+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
992
993 use POSIX qw(setsid);
994
995@@ -2546,17 +2546,17 @@
996
997 check_PID_file(undef, $self->{PID_file});
998
999- MKDEBUG && _d('Daemonized child will log to', $self->{log_file});
1000+ PTDEBUG && _d('Daemonized child will log to', $self->{log_file});
1001 return bless $self, $class;
1002 }
1003
1004 sub daemonize {
1005 my ( $self ) = @_;
1006
1007- MKDEBUG && _d('About to fork and daemonize');
1008+ PTDEBUG && _d('About to fork and daemonize');
1009 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
1010 if ( $pid ) {
1011- MKDEBUG && _d('I am the parent and now I die');
1012+ PTDEBUG && _d('I am the parent and now I die');
1013 exit;
1014 }
1015
1016@@ -2598,19 +2598,19 @@
1017 }
1018 }
1019
1020- MKDEBUG && _d('I am the child and now I live daemonized');
1021+ PTDEBUG && _d('I am the child and now I live daemonized');
1022 return;
1023 }
1024
1025 sub check_PID_file {
1026 my ( $self, $file ) = @_;
1027 my $PID_file = $self ? $self->{PID_file} : $file;
1028- MKDEBUG && _d('Checking PID file', $PID_file);
1029+ PTDEBUG && _d('Checking PID file', $PID_file);
1030 if ( $PID_file && -f $PID_file ) {
1031 my $pid;
1032 eval { chomp($pid = `cat $PID_file`); };
1033 die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
1034- MKDEBUG && _d('PID file exists; it contains PID', $pid);
1035+ PTDEBUG && _d('PID file exists; it contains PID', $pid);
1036 if ( $pid ) {
1037 my $pid_is_alive = kill 0, $pid;
1038 if ( $pid_is_alive ) {
1039@@ -2628,7 +2628,7 @@
1040 }
1041 }
1042 else {
1043- MKDEBUG && _d('No PID file');
1044+ PTDEBUG && _d('No PID file');
1045 }
1046 return;
1047 }
1048@@ -2648,7 +2648,7 @@
1049
1050 my $PID_file = $self->{PID_file};
1051 if ( !$PID_file ) {
1052- MKDEBUG && _d('No PID file to create');
1053+ PTDEBUG && _d('No PID file to create');
1054 return;
1055 }
1056
1057@@ -2661,7 +2661,7 @@
1058 close $PID_FH
1059 or die "Cannot close PID file $PID_file: $OS_ERROR";
1060
1061- MKDEBUG && _d('Created PID file:', $self->{PID_file});
1062+ PTDEBUG && _d('Created PID file:', $self->{PID_file});
1063 return;
1064 }
1065
1066@@ -2670,10 +2670,10 @@
1067 if ( $self->{PID_file} && -f $self->{PID_file} ) {
1068 unlink $self->{PID_file}
1069 or warn "Cannot remove PID file $self->{PID_file}: $OS_ERROR";
1070- MKDEBUG && _d('Removed PID file');
1071+ PTDEBUG && _d('Removed PID file');
1072 }
1073 else {
1074- MKDEBUG && _d('No PID to remove');
1075+ PTDEBUG && _d('No PID to remove');
1076 }
1077 return;
1078 }
1079@@ -2714,7 +2714,7 @@
1080 use strict;
1081 use warnings FATAL => 'all';
1082 use English qw(-no_match_vars);
1083-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
1084+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
1085
1086 sub new {
1087 my ( $class, %args ) = @_;
1088@@ -2735,7 +2735,7 @@
1089 eval {
1090 $dbh = $args->{dbh} || $dp->get_dbh(
1091 $dp->get_cxn_params($dsn), { AutoCommit => 1 });
1092- MKDEBUG && _d('Connected to', $dp->as_string($dsn));
1093+ PTDEBUG && _d('Connected to', $dp->as_string($dsn));
1094 };
1095 if ( $EVAL_ERROR ) {
1096 print STDERR "Cannot connect to ", $dp->as_string($dsn), "\n"
1097@@ -2744,15 +2744,15 @@
1098 }
1099
1100 my $sql = 'SELECT @@SERVER_ID';
1101- MKDEBUG && _d($sql);
1102+ PTDEBUG && _d($sql);
1103 my ($id) = $dbh->selectrow_array($sql);
1104- MKDEBUG && _d('Working on server ID', $id);
1105+ PTDEBUG && _d('Working on server ID', $id);
1106 my $master_thinks_i_am = $dsn->{server_id};
1107 if ( !defined $id
1108 || ( defined $master_thinks_i_am && $master_thinks_i_am != $id )
1109 || $args->{server_ids_seen}->{$id}++
1110 ) {
1111- MKDEBUG && _d('Server ID seen, or not what master said');
1112+ PTDEBUG && _d('Server ID seen, or not what master said');
1113 if ( $args->{skip_callback} ) {
1114 $args->{skip_callback}->($dsn, $dbh, $level, $args->{parent});
1115 }
1116@@ -2768,7 +2768,7 @@
1117 $self->find_slave_hosts($dp, $dbh, $dsn, $args->{method});
1118
1119 foreach my $slave ( @slaves ) {
1120- MKDEBUG && _d('Recursing from',
1121+ PTDEBUG && _d('Recursing from',
1122 $dp->as_string($dsn), 'to', $dp->as_string($slave));
1123 $self->recurse_to_slaves(
1124 { %$args, dsn => $slave, dbh => undef, parent => $dsn }, $level + 1 );
1125@@ -2786,23 +2786,23 @@
1126 }
1127 else {
1128 if ( ($dsn->{P} || 3306) != 3306 ) {
1129- MKDEBUG && _d('Port number is non-standard; using only hosts method');
1130+ PTDEBUG && _d('Port number is non-standard; using only hosts method');
1131 @methods = qw(hosts);
1132 }
1133 }
1134- MKDEBUG && _d('Looking for slaves on', $dsn_parser->as_string($dsn),
1135+ PTDEBUG && _d('Looking for slaves on', $dsn_parser->as_string($dsn),
1136 'using methods', @methods);
1137
1138 my @slaves;
1139 METHOD:
1140 foreach my $method ( @methods ) {
1141 my $find_slaves = "_find_slaves_by_$method";
1142- MKDEBUG && _d('Finding slaves with', $find_slaves);
1143+ PTDEBUG && _d('Finding slaves with', $find_slaves);
1144 @slaves = $self->$find_slaves($dsn_parser, $dbh, $dsn);
1145 last METHOD if @slaves;
1146 }
1147
1148- MKDEBUG && _d('Found', scalar(@slaves), 'slaves');
1149+ PTDEBUG && _d('Found', scalar(@slaves), 'slaves');
1150 return @slaves;
1151 }
1152
1153@@ -2831,11 +2831,11 @@
1154
1155 my @slaves;
1156 my $sql = 'SHOW SLAVE HOSTS';
1157- MKDEBUG && _d($dbh, $sql);
1158+ PTDEBUG && _d($dbh, $sql);
1159 @slaves = @{$dbh->selectall_arrayref($sql, { Slice => {} })};
1160
1161 if ( @slaves ) {
1162- MKDEBUG && _d('Found some SHOW SLAVE HOSTS info');
1163+ PTDEBUG && _d('Found some SHOW SLAVE HOSTS info');
1164 @slaves = map {
1165 my %hash;
1166 @hash{ map { lc $_ } keys %$_ } = values %$_;
1167@@ -2864,7 +2864,7 @@
1168 $user =~ s/([^@]+)@(.+)/'$1'\@'$2'/;
1169 }
1170 my $sql = $show . $user;
1171- MKDEBUG && _d($dbh, $sql);
1172+ PTDEBUG && _d($dbh, $sql);
1173
1174 my $proc;
1175 eval {
1176@@ -2875,11 +2875,11 @@
1177 if ( $EVAL_ERROR ) {
1178
1179 if ( $EVAL_ERROR =~ m/no such grant defined for user/ ) {
1180- MKDEBUG && _d('Retrying SHOW GRANTS without host; error:',
1181+ PTDEBUG && _d('Retrying SHOW GRANTS without host; error:',
1182 $EVAL_ERROR);
1183 ($user) = split('@', $user);
1184 $sql = $show . $user;
1185- MKDEBUG && _d($sql);
1186+ PTDEBUG && _d($sql);
1187 eval {
1188 $proc = grep {
1189 m/ALL PRIVILEGES.*?\*\.\*|PROCESS/
1190@@ -2894,7 +2894,7 @@
1191 }
1192
1193 $sql = 'SHOW PROCESSLIST';
1194- MKDEBUG && _d($dbh, $sql);
1195+ PTDEBUG && _d($dbh, $sql);
1196 grep { $_->{command} =~ m/Binlog Dump/i }
1197 map { # Lowercase the column names
1198 my %hash;
1199@@ -2954,7 +2954,7 @@
1200 if ( !$self->{not_a_slave}->{$dbh} ) {
1201 my $sth = $self->{sths}->{$dbh}->{SLAVE_STATUS}
1202 ||= $dbh->prepare('SHOW SLAVE STATUS');
1203- MKDEBUG && _d($dbh, 'SHOW SLAVE STATUS');
1204+ PTDEBUG && _d($dbh, 'SHOW SLAVE STATUS');
1205 $sth->execute();
1206 my ($ss) = @{$sth->fetchall_arrayref({})};
1207
1208@@ -2963,7 +2963,7 @@
1209 return $ss;
1210 }
1211
1212- MKDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS');
1213+ PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS');
1214 $self->{not_a_slave}->{$dbh}++;
1215 }
1216 }
1217@@ -2972,21 +2972,21 @@
1218 my ( $self, $dbh ) = @_;
1219
1220 if ( $self->{not_a_master}->{$dbh} ) {
1221- MKDEBUG && _d('Server on dbh', $dbh, 'is not a master');
1222+ PTDEBUG && _d('Server on dbh', $dbh, 'is not a master');
1223 return;
1224 }
1225
1226 my $sth = $self->{sths}->{$dbh}->{MASTER_STATUS}
1227 ||= $dbh->prepare('SHOW MASTER STATUS');
1228- MKDEBUG && _d($dbh, 'SHOW MASTER STATUS');
1229+ PTDEBUG && _d($dbh, 'SHOW MASTER STATUS');
1230 $sth->execute();
1231 my ($ms) = @{$sth->fetchall_arrayref({})};
1232- MKDEBUG && _d(
1233+ PTDEBUG && _d(
1234 $ms ? map { "$_=" . (defined $ms->{$_} ? $ms->{$_} : '') } keys %$ms
1235 : '');
1236
1237 if ( !$ms || scalar keys %$ms < 2 ) {
1238- MKDEBUG && _d('Server on dbh', $dbh, 'does not seem to be a master');
1239+ PTDEBUG && _d('Server on dbh', $dbh, 'does not seem to be a master');
1240 $self->{not_a_master}->{$dbh}++;
1241 }
1242
1243@@ -3007,17 +3007,17 @@
1244 if ( $master_status ) {
1245 my $sql = "SELECT MASTER_POS_WAIT('$master_status->{file}', "
1246 . "$master_status->{position}, $timeout)";
1247- MKDEBUG && _d($slave_dbh, $sql);
1248+ PTDEBUG && _d($slave_dbh, $sql);
1249 my $start = time;
1250 ($result) = $slave_dbh->selectrow_array($sql);
1251
1252 $waited = time - $start;
1253
1254- MKDEBUG && _d('Result of waiting:', $result);
1255- MKDEBUG && _d("Waited", $waited, "seconds");
1256+ PTDEBUG && _d('Result of waiting:', $result);
1257+ PTDEBUG && _d("Waited", $waited, "seconds");
1258 }
1259 else {
1260- MKDEBUG && _d('Not waiting: this server is not a master');
1261+ PTDEBUG && _d('Not waiting: this server is not a master');
1262 }
1263
1264 return {
1265@@ -3030,7 +3030,7 @@
1266 my ( $self, $dbh ) = @_;
1267 my $sth = $self->{sths}->{$dbh}->{STOP_SLAVE}
1268 ||= $dbh->prepare('STOP SLAVE');
1269- MKDEBUG && _d($dbh, $sth->{Statement});
1270+ PTDEBUG && _d($dbh, $sth->{Statement});
1271 $sth->execute();
1272 }
1273
1274@@ -3039,13 +3039,13 @@
1275 if ( $pos ) {
1276 my $sql = "START SLAVE UNTIL MASTER_LOG_FILE='$pos->{file}', "
1277 . "MASTER_LOG_POS=$pos->{position}";
1278- MKDEBUG && _d($dbh, $sql);
1279+ PTDEBUG && _d($dbh, $sql);
1280 $dbh->do($sql);
1281 }
1282 else {
1283 my $sth = $self->{sths}->{$dbh}->{START_SLAVE}
1284 ||= $dbh->prepare('START SLAVE');
1285- MKDEBUG && _d($dbh, $sth->{Statement});
1286+ PTDEBUG && _d($dbh, $sth->{Statement});
1287 $sth->execute();
1288 }
1289 }
1290@@ -3058,12 +3058,12 @@
1291 my $slave_pos = $self->repl_posn($slave_status);
1292 my $master_status = $self->get_master_status($master);
1293 my $master_pos = $self->repl_posn($master_status);
1294- MKDEBUG && _d('Master position:', $self->pos_to_string($master_pos),
1295+ PTDEBUG && _d('Master position:', $self->pos_to_string($master_pos),
1296 'Slave position:', $self->pos_to_string($slave_pos));
1297
1298 my $result;
1299 if ( $self->pos_cmp($slave_pos, $master_pos) < 0 ) {
1300- MKDEBUG && _d('Waiting for slave to catch up to master');
1301+ PTDEBUG && _d('Waiting for slave to catch up to master');
1302 $self->start_slave($slave, $master_pos);
1303
1304 $result = $self->wait_for_master(
1305@@ -3075,7 +3075,7 @@
1306 if ( !defined $result->{result} ) {
1307 $slave_status = $self->get_slave_status($slave);
1308 if ( !$self->slave_is_running($slave_status) ) {
1309- MKDEBUG && _d('Master position:',
1310+ PTDEBUG && _d('Master position:',
1311 $self->pos_to_string($master_pos),
1312 'Slave position:', $self->pos_to_string($slave_pos));
1313 $slave_pos = $self->repl_posn($slave_status);
1314@@ -3083,7 +3083,7 @@
1315 die "MASTER_POS_WAIT() returned NULL but slave has not "
1316 . "caught up to master";
1317 }
1318- MKDEBUG && _d('Slave is caught up to master and stopped');
1319+ PTDEBUG && _d('Slave is caught up to master and stopped');
1320 }
1321 else {
1322 die "Slave has not caught up to master and it is still running";
1323@@ -3091,7 +3091,7 @@
1324 }
1325 }
1326 else {
1327- MKDEBUG && _d("Slave is already caught up to master");
1328+ PTDEBUG && _d("Slave is already caught up to master");
1329 }
1330
1331 return $result;
1332@@ -3134,7 +3134,7 @@
1333 sub has_slave_updates {
1334 my ( $self, $dbh ) = @_;
1335 my $sql = q{SHOW VARIABLES LIKE 'log_slave_updates'};
1336- MKDEBUG && _d($dbh, $sql);
1337+ PTDEBUG && _d($dbh, $sql);
1338 my ($name, $value) = $dbh->selectrow_array($sql);
1339 return $value && $value =~ m/^(1|ON)$/;
1340 }
1341@@ -3196,12 +3196,12 @@
1342 }
1343 if ( !$match ) {
1344 if ( ($query->{User} || $query->{user} || '') eq "system user" ) {
1345- MKDEBUG && _d("Slave replication thread");
1346+ PTDEBUG && _d("Slave replication thread");
1347 if ( $type ne 'all' ) {
1348 my $state = $query->{State} || $query->{state} || '';
1349
1350 if ( $state =~ m/^init|end$/ ) {
1351- MKDEBUG && _d("Special state:", $state);
1352+ PTDEBUG && _d("Special state:", $state);
1353 $match = 1;
1354 }
1355 else {
1356@@ -3222,7 +3222,7 @@
1357 }
1358 }
1359 else {
1360- MKDEBUG && _d('Not system user');
1361+ PTDEBUG && _d('Not system user');
1362 }
1363
1364 if ( !defined $args{check_known_ids} || $args{check_known_ids} ) {
1365@@ -3232,14 +3232,14 @@
1366 }
1367 else {
1368 if ( $self->{replication_thread}->{$id} ) {
1369- MKDEBUG && _d("Thread ID is a known replication thread ID");
1370+ PTDEBUG && _d("Thread ID is a known replication thread ID");
1371 $match = 1;
1372 }
1373 }
1374 }
1375 }
1376
1377- MKDEBUG && _d('Matches', $type, 'replication thread:',
1378+ PTDEBUG && _d('Matches', $type, 'replication thread:',
1379 ($match ? 'yes' : 'no'), '; match:', $match);
1380
1381 return $match;
1382@@ -3280,7 +3280,7 @@
1383 );
1384
1385 my $sql = "SHOW VARIABLES LIKE 'slave_skip_errors'";
1386- MKDEBUG && _d($dbh, $sql);
1387+ PTDEBUG && _d($dbh, $sql);
1388 my $row = $dbh->selectrow_arrayref($sql);
1389 $filters{slave_skip_errors} = $row->[1] if $row->[1] && $row->[1] ne 'OFF';
1390 }
1391@@ -3334,7 +3334,7 @@
1392 $Data::Dumper::Indent = 1;
1393 $Data::Dumper::Quotekeys = 0;
1394
1395-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
1396+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
1397
1398 # Global variables; as few as possible.
1399 my $oktorun = 1;
1400@@ -3505,7 +3505,7 @@
1401 }
1402 my $dbh = $dp->get_dbh(
1403 $dp->get_cxn_params($table), { AutoCommit => $ac });
1404- MKDEBUG && _d('Inspecting table on', $dp->as_string($table));
1405+ PTDEBUG && _d('Inspecting table on', $dp->as_string($table));
1406
1407 # Set options that can enable removing data on the master and archiving it
1408 # on the slaves.
1409@@ -3551,7 +3551,7 @@
1410
1411 if ( $o->get('check-charset') ) {
1412 my $sql = 'SELECT CONCAT(/*!40100 @@session.character_set_connection, */ "")';
1413- MKDEBUG && _d($sql);
1414+ PTDEBUG && _d($sql);
1415 my ($dbh_charset) = $table->{dbh}->selectrow_array($sql);
1416 if ( ($dbh_charset || "") ne ($table->{info}->{charset} || "") ) {
1417 $src->{dbh}->disconnect() if $src && $src->{dbh};
1418@@ -3637,7 +3637,7 @@
1419 my @sel_cols = $o->get('columns') ? @{$o->get('columns')} # Explicit
1420 : $o->get('primary-key-only') ? @{$src->{info}->{keys}->{PRIMARY}->{cols}}
1421 : @{$src->{info}->{cols}}; # All
1422- MKDEBUG && _d("sel cols: ", @sel_cols);
1423+ PTDEBUG && _d("sel cols: ", @sel_cols);
1424
1425 $del_stmt = $nibbler->generate_del_stmt(
1426 tbl_struct => $src->{info},
1427@@ -3711,7 +3711,7 @@
1428 }
1429 }
1430
1431- MKDEBUG && _d("Index for DELETE:", $del_stmt->{index});
1432+ PTDEBUG && _d("Index for DELETE:", $del_stmt->{index});
1433 if ( !$bulk_del ) {
1434 # The LIMIT might be 1 here, because even though a SELECT can return
1435 # many rows, an INSERT only does one at a time. It would not be safe to
1436@@ -3726,10 +3726,10 @@
1437 . " FROM $src->{db_tbl} WHERE $del_stmt->{where}";
1438
1439 if ( $src->{info}->{keys}->{$del_stmt->{index}}->{is_unique} ) {
1440- MKDEBUG && _d("DELETE index is unique; LIMIT 1 is not needed");
1441+ PTDEBUG && _d("DELETE index is unique; LIMIT 1 is not needed");
1442 }
1443 else {
1444- MKDEBUG && _d("Adding LIMIT 1 to DELETE because DELETE index "
1445+ PTDEBUG && _d("Adding LIMIT 1 to DELETE because DELETE index "
1446 . "is not unique");
1447 $del_sql .= " LIMIT 1";
1448 }
1449@@ -3761,7 +3761,7 @@
1450 ins_tbl => $dst->{info},
1451 sel_cols => \@sel_cols,
1452 );
1453- MKDEBUG && _d("inst stmt: ", Dumper($ins_stmt));
1454+ PTDEBUG && _d("inst stmt: ", Dumper($ins_stmt));
1455 @ins_slice = @{$ins_stmt->{slice}};
1456 if ( $o->get('bulk-insert') ) {
1457 $ins_sql = 'LOAD DATA'
1458@@ -3788,7 +3788,7 @@
1459 $ins_sql = '';
1460 }
1461
1462- if ( MKDEBUG ) {
1463+ if ( PTDEBUG ) {
1464 _d("get first sql:", $first_sql);
1465 _d("get next sql:", $next_sql);
1466 _d("del row sql:", $del_sql);
1467@@ -3857,7 +3857,7 @@
1468 $statistics{SELECT} += $get_sth->rows;
1469 });
1470 my $row = $get_sth->fetchrow_arrayref();
1471- MKDEBUG && _d("First row: ", Dumper($row), 'rows:', $get_sth->rows);
1472+ PTDEBUG && _d("First row: ", Dumper($row), 'rows:', $get_sth->rows);
1473 if ( !$row ) {
1474 $get_sth->finish;
1475 $src->{dbh}->disconnect();
1476@@ -3945,7 +3945,7 @@
1477 $ins_sth ||= $ins_row; # Default to the sth decided before.
1478 my $success = do_with_retries($o, 'inserting', sub {
1479 $ins_sth->execute(@{$row}[@ins_slice]);
1480- MKDEBUG && _d('Inserted', $del_row->rows, 'rows');
1481+ PTDEBUG && _d('Inserted', $del_row->rows, 'rows');
1482 $statistics{INSERT} += $ins_sth->rows;
1483 });
1484 if ( $success == $OUT_OF_RETRIES ) {
1485@@ -3968,7 +3968,7 @@
1486 if ( !$o->get('no-delete') ) {
1487 my $success = do_with_retries($o, 'deleting', sub {
1488 $del_row->execute(@{$row}[@del_slice]);
1489- MKDEBUG && _d('Deleted', $del_row->rows, 'rows');
1490+ PTDEBUG && _d('Deleted', $del_row->rows, 'rows');
1491 $statistics{DELETE} += $del_row->rows;
1492 });
1493 if ( $success == $OUT_OF_RETRIES ) {
1494@@ -4020,7 +4020,7 @@
1495 $row = $get_sth->fetchrow_arrayref();
1496 }
1497 if ( !$row ) {
1498- MKDEBUG && _d('No more rows in this chunk; doing bulk operations');
1499+ PTDEBUG && _d('No more rows in this chunk; doing bulk operations');
1500
1501 # ###################################################################
1502 # This code is for the bulk archiving functionality.
1503@@ -4049,7 +4049,7 @@
1504 $ins_sth ||= $ins_row; # Default to the sth decided before.
1505 my $success = do_with_retries($o, 'bulk_inserting', sub {
1506 $ins_sth->execute($bulkins_file->filename());
1507- MKDEBUG && _d('Bulk inserted', $del_row->rows, 'rows');
1508+ PTDEBUG && _d('Bulk inserted', $del_row->rows, 'rows');
1509 $statistics{INSERT} += $ins_sth->rows;
1510 });
1511 if ( $success != $ALL_IS_WELL ) {
1512@@ -4073,7 +4073,7 @@
1513 @{$first_row}[@bulkdel_slice],
1514 @{$lastrow}[@bulkdel_slice],
1515 );
1516- MKDEBUG && _d('Bulk deleted', $del_row->rows, 'rows');
1517+ PTDEBUG && _d('Bulk deleted', $del_row->rows, 'rows');
1518 $statistics{DELETE} += $del_row->rows;
1519 });
1520 if ( $success != $ALL_IS_WELL ) {
1521@@ -4089,12 +4089,12 @@
1522 commit($o, 1) if $commit_each;
1523 $get_sth = $get_next;
1524
1525- MKDEBUG && _d('Fetching rows in next chunk');
1526+ PTDEBUG && _d('Fetching rows in next chunk');
1527 trace('select', sub {
1528 my $select_start = time;
1529 $get_sth->execute(@{$lastrow}[@asc_slice]);
1530 $last_select_time = time - $select_start;
1531- MKDEBUG && _d('Fetched', $get_sth->rows, 'rows');
1532+ PTDEBUG && _d('Fetched', $get_sth->rows, 'rows');
1533 $statistics{SELECT} += $get_sth->rows;
1534 });
1535
1536@@ -4109,14 +4109,14 @@
1537 }
1538 } # no next row (do bulk operations)
1539 else {
1540- MKDEBUG && _d('Got another row in this chunk');
1541+ PTDEBUG && _d('Got another row in this chunk');
1542 }
1543
1544 # Check slave lag and wait if slave is too far behind.
1545 if ( $lag_dbh ) {
1546 my $lag = $ms->get_slave_lag($lag_dbh);
1547 while ( !defined $lag || $lag > $o->get('max-lag') ) {
1548- MKDEBUG && _d('Sleeping: slave lag is', $lag);
1549+ PTDEBUG && _d('Sleeping: slave lag is', $lag);
1550 sleep($o->get('check-interval'));
1551 $lag = $ms->get_slave_lag($lag_dbh);
1552 }
1553@@ -4126,13 +4126,13 @@
1554 if( my $sleep_time = $o->get('sleep') ) {
1555 $sleep_time = $last_select_time * $o->get('sleep-coef')
1556 if $o->get('sleep-coef');
1557- MKDEBUG && _d('Sleeping', $sleep_time);
1558+ PTDEBUG && _d('Sleeping', $sleep_time);
1559 trace('sleep', sub {
1560 sleep($sleep_time);
1561 });
1562 }
1563 } # ROW
1564- MKDEBUG && _d('Done fetching rows');
1565+ PTDEBUG && _d('Done fetching rows');
1566
1567 # Transactions might still be open, etc
1568 commit($o, $txnsize || $commit_each);
1569@@ -5637,6 +5637,6 @@
1570
1571 =head1 VERSION
1572
1573-pt-archiver 1.0.1
1574+pt-archiver 1.0.2
1575
1576 =cut
1577
1578=== modified file 'bin/pt-collect'
1579--- bin/pt-collect 2011-09-01 16:00:38 +0000
1580+++ bin/pt-collect 2011-12-29 16:12:24 +0000
1581@@ -443,7 +443,7 @@
1582
1583 =head1 VERSION
1584
1585-pt-collect 1.0.1
1586+pt-collect 1.0.2
1587
1588 =cut
1589
1590
1591=== modified file 'bin/pt-config-diff'
1592--- bin/pt-config-diff 2011-09-01 16:00:38 +0000
1593+++ bin/pt-config-diff 2011-12-29 16:12:24 +0000
1594@@ -6,7 +6,7 @@
1595
1596 use strict;
1597 use warnings FATAL => 'all';
1598-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
1599+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
1600
1601 # ###########################################################################
1602 # OptionParser package
1603@@ -22,7 +22,7 @@
1604 use strict;
1605 use warnings FATAL => 'all';
1606 use English qw(-no_match_vars);
1607-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
1608+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
1609
1610 use List::Util qw(max);
1611 use Getopt::Long;
1612@@ -106,7 +106,7 @@
1613 my $contents = do { local $/ = undef; <$fh> };
1614 close $fh;
1615 if ( $contents =~ m/^=head1 DSN OPTIONS/m ) {
1616- MKDEBUG && _d('Parsing DSN OPTIONS');
1617+ PTDEBUG && _d('Parsing DSN OPTIONS');
1618 my $dsn_attribs = {
1619 dsn => 1,
1620 copy => 1,
1621@@ -150,7 +150,7 @@
1622
1623 if ( $contents =~ m/^=head1 VERSION\n\n^(.+)$/m ) {
1624 $self->{version} = $1;
1625- MKDEBUG && _d($self->{version});
1626+ PTDEBUG && _d($self->{version});
1627 }
1628
1629 return;
1630@@ -187,7 +187,7 @@
1631 chomp $para;
1632 $para =~ s/\s+/ /g;
1633 $para =~ s/$POD_link_re/$1/go;
1634- MKDEBUG && _d('Option rule:', $para);
1635+ PTDEBUG && _d('Option rule:', $para);
1636 push @rules, $para;
1637 }
1638
1639@@ -196,7 +196,7 @@
1640 do {
1641 if ( my ($option) = $para =~ m/^=item $self->{item}/ ) {
1642 chomp $para;
1643- MKDEBUG && _d($para);
1644+ PTDEBUG && _d($para);
1645 my %attribs;
1646
1647 $para = <$fh>; # read next paragraph, possibly attributes
1648@@ -215,7 +215,7 @@
1649 $para = <$fh>; # read next paragraph, probably short help desc
1650 }
1651 else {
1652- MKDEBUG && _d('Option has no attributes');
1653+ PTDEBUG && _d('Option has no attributes');
1654 }
1655
1656 $para =~ s/\s+\Z//g;
1657@@ -223,7 +223,7 @@
1658 $para =~ s/$POD_link_re/$1/go;
1659
1660 $para =~ s/\.(?:\n.*| [A-Z].*|\Z)//s;
1661- MKDEBUG && _d('Short help:', $para);
1662+ PTDEBUG && _d('Short help:', $para);
1663
1664 die "No description after option spec $option" if $para =~ m/^=item/;
1665
1666@@ -261,7 +261,7 @@
1667
1668 foreach my $opt ( @specs ) {
1669 if ( ref $opt ) { # It's an option spec, not a rule.
1670- MKDEBUG && _d('Parsing opt spec:',
1671+ PTDEBUG && _d('Parsing opt spec:',
1672 map { ($_, '=>', $opt->{$_}) } keys %$opt);
1673
1674 my ( $long, $short ) = $opt->{spec} =~ m/^([\w-]+)(?:\|([^!+=]*))?/;
1675@@ -274,7 +274,7 @@
1676 $self->{opts}->{$long} = $opt;
1677
1678 if ( length $long == 1 ) {
1679- MKDEBUG && _d('Long opt', $long, 'looks like short opt');
1680+ PTDEBUG && _d('Long opt', $long, 'looks like short opt');
1681 $self->{short_opts}->{$long} = $long;
1682 }
1683
1684@@ -300,14 +300,14 @@
1685
1686 my ( $type ) = $opt->{spec} =~ m/=(.)/;
1687 $opt->{type} = $type;
1688- MKDEBUG && _d($long, 'type:', $type);
1689+ PTDEBUG && _d($long, 'type:', $type);
1690
1691
1692 $opt->{spec} =~ s/=./=s/ if ( $type && $type =~ m/[HhAadzm]/ );
1693
1694 if ( (my ($def) = $opt->{desc} =~ m/default\b(?: ([^)]+))?/) ) {
1695 $self->{defaults}->{$long} = defined $def ? $def : 1;
1696- MKDEBUG && _d($long, 'default:', $def);
1697+ PTDEBUG && _d($long, 'default:', $def);
1698 }
1699
1700 if ( $long eq 'config' ) {
1701@@ -316,13 +316,13 @@
1702
1703 if ( (my ($dis) = $opt->{desc} =~ m/(disables .*)/) ) {
1704 $disables{$long} = $dis;
1705- MKDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
1706+ PTDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
1707 }
1708
1709 $self->{opts}->{$long} = $opt;
1710 }
1711 else { # It's an option rule, not a spec.
1712- MKDEBUG && _d('Parsing rule:', $opt);
1713+ PTDEBUG && _d('Parsing rule:', $opt);
1714 push @{$self->{rules}}, $opt;
1715 my @participants = $self->_get_participants($opt);
1716 my $rule_ok = 0;
1717@@ -330,17 +330,17 @@
1718 if ( $opt =~ m/mutually exclusive|one and only one/ ) {
1719 $rule_ok = 1;
1720 push @{$self->{mutex}}, \@participants;
1721- MKDEBUG && _d(@participants, 'are mutually exclusive');
1722+ PTDEBUG && _d(@participants, 'are mutually exclusive');
1723 }
1724 if ( $opt =~ m/at least one|one and only one/ ) {
1725 $rule_ok = 1;
1726 push @{$self->{atleast1}}, \@participants;
1727- MKDEBUG && _d(@participants, 'require at least one');
1728+ PTDEBUG && _d(@participants, 'require at least one');
1729 }
1730 if ( $opt =~ m/default to/ ) {
1731 $rule_ok = 1;
1732 $self->{defaults_to}->{$participants[0]} = $participants[1];
1733- MKDEBUG && _d($participants[0], 'defaults to', $participants[1]);
1734+ PTDEBUG && _d($participants[0], 'defaults to', $participants[1]);
1735 }
1736 if ( $opt =~ m/restricted to option groups/ ) {
1737 $rule_ok = 1;
1738@@ -354,7 +354,7 @@
1739 if( $opt =~ m/accepts additional command-line arguments/ ) {
1740 $rule_ok = 1;
1741 $self->{strict} = 0;
1742- MKDEBUG && _d("Strict mode disabled by rule");
1743+ PTDEBUG && _d("Strict mode disabled by rule");
1744 }
1745
1746 die "Unrecognized option rule: $opt" unless $rule_ok;
1747@@ -364,7 +364,7 @@
1748 foreach my $long ( keys %disables ) {
1749 my @participants = $self->_get_participants($disables{$long});
1750 $self->{disables}->{$long} = \@participants;
1751- MKDEBUG && _d('Option', $long, 'disables', @participants);
1752+ PTDEBUG && _d('Option', $long, 'disables', @participants);
1753 }
1754
1755 return;
1756@@ -378,7 +378,7 @@
1757 unless exists $self->{opts}->{$long};
1758 push @participants, $long;
1759 }
1760- MKDEBUG && _d('Participants for', $str, ':', @participants);
1761+ PTDEBUG && _d('Participants for', $str, ':', @participants);
1762 return @participants;
1763 }
1764
1765@@ -401,7 +401,7 @@
1766 die "Cannot set default for nonexistent option $long"
1767 unless exists $self->{opts}->{$long};
1768 $self->{defaults}->{$long} = $defaults{$long};
1769- MKDEBUG && _d('Default val for', $long, ':', $defaults{$long});
1770+ PTDEBUG && _d('Default val for', $long, ':', $defaults{$long});
1771 }
1772 return;
1773 }
1774@@ -430,7 +430,7 @@
1775 $opt->{value} = $val;
1776 }
1777 $opt->{got} = 1;
1778- MKDEBUG && _d('Got option', $long, '=', $val);
1779+ PTDEBUG && _d('Got option', $long, '=', $val);
1780 }
1781
1782 sub get_opts {
1783@@ -461,7 +461,7 @@
1784 if ( $self->got('config') ) {
1785 die $EVAL_ERROR;
1786 }
1787- elsif ( MKDEBUG ) {
1788+ elsif ( PTDEBUG ) {
1789 _d($EVAL_ERROR);
1790 }
1791 }
1792@@ -528,7 +528,7 @@
1793 if ( exists $self->{disables}->{$long} ) {
1794 my @disable_opts = @{$self->{disables}->{$long}};
1795 map { $self->{opts}->{$_}->{value} = undef; } @disable_opts;
1796- MKDEBUG && _d('Unset options', @disable_opts,
1797+ PTDEBUG && _d('Unset options', @disable_opts,
1798 'because', $long,'disables them');
1799 }
1800
1801@@ -577,7 +577,7 @@
1802 delete $long[$i];
1803 }
1804 else {
1805- MKDEBUG && _d('Temporarily failed to parse', $long);
1806+ PTDEBUG && _d('Temporarily failed to parse', $long);
1807 }
1808 }
1809
1810@@ -601,12 +601,12 @@
1811 my $val = $opt->{value};
1812
1813 if ( $val && $opt->{type} eq 'm' ) { # type time
1814- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
1815+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
1816 my ( $prefix, $num, $suffix ) = $val =~ m/([+-]?)(\d+)([a-z])?$/;
1817 if ( !$suffix ) {
1818 my ( $s ) = $opt->{desc} =~ m/\(suffix (.)\)/;
1819 $suffix = $s || 's';
1820- MKDEBUG && _d('No suffix given; using', $suffix, 'for',
1821+ PTDEBUG && _d('No suffix given; using', $suffix, 'for',
1822 $opt->{long}, '(value:', $val, ')');
1823 }
1824 if ( $suffix =~ m/[smhd]/ ) {
1825@@ -615,23 +615,23 @@
1826 : $suffix eq 'h' ? $num * 3600 # Hours
1827 : $num * 86400; # Days
1828 $opt->{value} = ($prefix || '') . $val;
1829- MKDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
1830+ PTDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
1831 }
1832 else {
1833 $self->save_error("Invalid time suffix for --$opt->{long}");
1834 }
1835 }
1836 elsif ( $val && $opt->{type} eq 'd' ) { # type DSN
1837- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
1838+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
1839 my $prev = {};
1840 my $from_key = $self->{defaults_to}->{ $opt->{long} };
1841 if ( $from_key ) {
1842- MKDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
1843+ PTDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
1844 if ( $self->{opts}->{$from_key}->{parsed} ) {
1845 $prev = $self->{opts}->{$from_key}->{value};
1846 }
1847 else {
1848- MKDEBUG && _d('Cannot parse', $opt->{long}, 'until',
1849+ PTDEBUG && _d('Cannot parse', $opt->{long}, 'until',
1850 $from_key, 'parsed');
1851 return;
1852 }
1853@@ -640,7 +640,7 @@
1854 $opt->{value} = $self->{DSNParser}->parse($val, $prev, $defaults);
1855 }
1856 elsif ( $val && $opt->{type} eq 'z' ) { # type size
1857- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
1858+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
1859 $self->_parse_size($opt, $val);
1860 }
1861 elsif ( $opt->{type} eq 'H' || (defined $val && $opt->{type} eq 'h') ) {
1862@@ -650,7 +650,7 @@
1863 $opt->{value} = [ split(/(?<!\\),\s*/, ($val || '')) ];
1864 }
1865 else {
1866- MKDEBUG && _d('Nothing to validate for option',
1867+ PTDEBUG && _d('Nothing to validate for option',
1868 $opt->{long}, 'type', $opt->{type}, 'value', $val);
1869 }
1870
1871@@ -724,11 +724,11 @@
1872 $file ||= $self->{file} || __FILE__;
1873
1874 if ( !$self->{description} || !$self->{usage} ) {
1875- MKDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
1876+ PTDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
1877 my %synop = $self->_parse_synopsis($file);
1878 $self->{description} ||= $synop{description};
1879 $self->{usage} ||= $synop{usage};
1880- MKDEBUG && _d("Description:", $self->{description},
1881+ PTDEBUG && _d("Description:", $self->{description},
1882 "\nUsage:", $self->{usage});
1883 }
1884
1885@@ -943,7 +943,7 @@
1886 my ( $self, $opt, $val ) = @_;
1887
1888 if ( lc($val || '') eq 'null' ) {
1889- MKDEBUG && _d('NULL size for', $opt->{long});
1890+ PTDEBUG && _d('NULL size for', $opt->{long});
1891 $opt->{value} = 'null';
1892 return;
1893 }
1894@@ -953,7 +953,7 @@
1895 if ( defined $num ) {
1896 if ( $factor ) {
1897 $num *= $factor_for{$factor};
1898- MKDEBUG && _d('Setting option', $opt->{y},
1899+ PTDEBUG && _d('Setting option', $opt->{y},
1900 'to num', $num, '* factor', $factor);
1901 }
1902 $opt->{value} = ($pre || '') . $num;
1903@@ -977,7 +977,7 @@
1904 sub _parse_synopsis {
1905 my ( $self, $file ) = @_;
1906 $file ||= $self->{file} || __FILE__;
1907- MKDEBUG && _d("Parsing SYNOPSIS in", $file);
1908+ PTDEBUG && _d("Parsing SYNOPSIS in", $file);
1909
1910 local $INPUT_RECORD_SEPARATOR = ''; # read paragraphs
1911 open my $fh, "<", $file or die "Cannot open $file: $OS_ERROR";
1912@@ -990,7 +990,7 @@
1913 push @synop, $para;
1914 }
1915 close $fh;
1916- MKDEBUG && _d("Raw SYNOPSIS text:", @synop);
1917+ PTDEBUG && _d("Raw SYNOPSIS text:", @synop);
1918 my ($usage, $desc) = @synop;
1919 die "The SYNOPSIS section in $file is not formatted properly"
1920 unless $usage && $desc;
1921@@ -1017,7 +1017,7 @@
1922 print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
1923 }
1924
1925-if ( MKDEBUG ) {
1926+if ( PTDEBUG ) {
1927 print '# ', $^X, ' ', $], "\n";
1928 if ( my $uname = `uname -a` ) {
1929 $uname =~ s/\s+/ /g;
1930@@ -1047,7 +1047,7 @@
1931 use strict;
1932 use warnings FATAL => 'all';
1933 use English qw(-no_match_vars);
1934-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
1935+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
1936
1937 use Data::Dumper;
1938 $Data::Dumper::Indent = 0;
1939@@ -1070,7 +1070,7 @@
1940 if ( !$opt->{key} || !$opt->{desc} ) {
1941 die "Invalid DSN option: ", Dumper($opt);
1942 }
1943- MKDEBUG && _d('DSN option:',
1944+ PTDEBUG && _d('DSN option:',
1945 join(', ',
1946 map { "$_=" . (defined $opt->{$_} ? ($opt->{$_} || '') : 'undef') }
1947 keys %$opt
1948@@ -1088,7 +1088,7 @@
1949 sub prop {
1950 my ( $self, $prop, $value ) = @_;
1951 if ( @_ > 2 ) {
1952- MKDEBUG && _d('Setting', $prop, 'property');
1953+ PTDEBUG && _d('Setting', $prop, 'property');
1954 $self->{$prop} = $value;
1955 }
1956 return $self->{$prop};
1957@@ -1097,10 +1097,10 @@
1958 sub parse {
1959 my ( $self, $dsn, $prev, $defaults ) = @_;
1960 if ( !$dsn ) {
1961- MKDEBUG && _d('No DSN to parse');
1962+ PTDEBUG && _d('No DSN to parse');
1963 return;
1964 }
1965- MKDEBUG && _d('Parsing', $dsn);
1966+ PTDEBUG && _d('Parsing', $dsn);
1967 $prev ||= {};
1968 $defaults ||= {};
1969 my %given_props;
1970@@ -1112,23 +1112,23 @@
1971 $given_props{$prop_key} = $prop_val;
1972 }
1973 else {
1974- MKDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
1975+ PTDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
1976 $given_props{h} = $dsn_part;
1977 }
1978 }
1979
1980 foreach my $key ( keys %$opts ) {
1981- MKDEBUG && _d('Finding value for', $key);
1982+ PTDEBUG && _d('Finding value for', $key);
1983 $final_props{$key} = $given_props{$key};
1984 if ( !defined $final_props{$key}
1985 && defined $prev->{$key} && $opts->{$key}->{copy} )
1986 {
1987 $final_props{$key} = $prev->{$key};
1988- MKDEBUG && _d('Copying value for', $key, 'from previous DSN');
1989+ PTDEBUG && _d('Copying value for', $key, 'from previous DSN');
1990 }
1991 if ( !defined $final_props{$key} ) {
1992 $final_props{$key} = $defaults->{$key};
1993- MKDEBUG && _d('Copying value for', $key, 'from defaults');
1994+ PTDEBUG && _d('Copying value for', $key, 'from defaults');
1995 }
1996 }
1997
1998@@ -1159,7 +1159,7 @@
1999 grep { $o->has($_) && $o->get($_) }
2000 keys %{$self->{opts}}
2001 );
2002- MKDEBUG && _d('DSN string made from options:', $dsn_string);
2003+ PTDEBUG && _d('DSN string made from options:', $dsn_string);
2004 return $self->parse($dsn_string);
2005 }
2006
2007@@ -1209,7 +1209,7 @@
2008 qw(F h P S A))
2009 . ';mysql_read_default_group=client';
2010 }
2011- MKDEBUG && _d($dsn);
2012+ PTDEBUG && _d($dsn);
2013 return ($dsn, $info->{u}, $info->{p});
2014 }
2015
2016@@ -1254,7 +1254,7 @@
2017 my $dbh;
2018 my $tries = 2;
2019 while ( !$dbh && $tries-- ) {
2020- MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
2021+ PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
2022 join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
2023
2024 eval {
2025@@ -1264,21 +1264,21 @@
2026 my $sql;
2027
2028 $sql = 'SELECT @@SQL_MODE';
2029- MKDEBUG && _d($dbh, $sql);
2030+ PTDEBUG && _d($dbh, $sql);
2031 my ($sql_mode) = $dbh->selectrow_array($sql);
2032
2033 $sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
2034 . '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
2035 . ($sql_mode ? ",$sql_mode" : '')
2036 . '\'*/';
2037- MKDEBUG && _d($dbh, $sql);
2038+ PTDEBUG && _d($dbh, $sql);
2039 $dbh->do($sql);
2040
2041 if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
2042 $sql = "/*!40101 SET NAMES $charset*/";
2043- MKDEBUG && _d($dbh, ':', $sql);
2044+ PTDEBUG && _d($dbh, ':', $sql);
2045 $dbh->do($sql);
2046- MKDEBUG && _d('Enabling charset for STDOUT');
2047+ PTDEBUG && _d('Enabling charset for STDOUT');
2048 if ( $charset eq 'utf8' ) {
2049 binmode(STDOUT, ':utf8')
2050 or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
2051@@ -1290,15 +1290,15 @@
2052
2053 if ( $self->prop('set-vars') ) {
2054 $sql = "SET " . $self->prop('set-vars');
2055- MKDEBUG && _d($dbh, ':', $sql);
2056+ PTDEBUG && _d($dbh, ':', $sql);
2057 $dbh->do($sql);
2058 }
2059 }
2060 };
2061 if ( !$dbh && $EVAL_ERROR ) {
2062- MKDEBUG && _d($EVAL_ERROR);
2063+ PTDEBUG && _d($EVAL_ERROR);
2064 if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
2065- MKDEBUG && _d('Going to try again without utf8 support');
2066+ PTDEBUG && _d('Going to try again without utf8 support');
2067 delete $defaults->{mysql_enable_utf8};
2068 }
2069 elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
2070@@ -1316,7 +1316,7 @@
2071 }
2072 }
2073
2074- MKDEBUG && _d('DBH info: ',
2075+ PTDEBUG && _d('DBH info: ',
2076 $dbh,
2077 Dumper($dbh->selectrow_hashref(
2078 'SELECT DATABASE(), CONNECTION_ID(), VERSION()/*!50038 , @@hostname*/')),
2079@@ -1342,7 +1342,7 @@
2080
2081 sub disconnect {
2082 my ( $self, $dbh ) = @_;
2083- MKDEBUG && $self->print_active_handles($dbh);
2084+ PTDEBUG && $self->print_active_handles($dbh);
2085 $dbh->disconnect;
2086 }
2087
2088@@ -1403,7 +1403,7 @@
2089 use strict;
2090 use warnings FATAL => 'all';
2091 use English qw(-no_match_vars);
2092-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2093+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2094
2095 use POSIX qw(setsid);
2096
2097@@ -1421,17 +1421,17 @@
2098
2099 check_PID_file(undef, $self->{PID_file});
2100
2101- MKDEBUG && _d('Daemonized child will log to', $self->{log_file});
2102+ PTDEBUG && _d('Daemonized child will log to', $self->{log_file});
2103 return bless $self, $class;
2104 }
2105
2106 sub daemonize {
2107 my ( $self ) = @_;
2108
2109- MKDEBUG && _d('About to fork and daemonize');
2110+ PTDEBUG && _d('About to fork and daemonize');
2111 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
2112 if ( $pid ) {
2113- MKDEBUG && _d('I am the parent and now I die');
2114+ PTDEBUG && _d('I am the parent and now I die');
2115 exit;
2116 }
2117
2118@@ -1473,19 +1473,19 @@
2119 }
2120 }
2121
2122- MKDEBUG && _d('I am the child and now I live daemonized');
2123+ PTDEBUG && _d('I am the child and now I live daemonized');
2124 return;
2125 }
2126
2127 sub check_PID_file {
2128 my ( $self, $file ) = @_;
2129 my $PID_file = $self ? $self->{PID_file} : $file;
2130- MKDEBUG && _d('Checking PID file', $PID_file);
2131+ PTDEBUG && _d('Checking PID file', $PID_file);
2132 if ( $PID_file && -f $PID_file ) {
2133 my $pid;
2134 eval { chomp($pid = `cat $PID_file`); };
2135 die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
2136- MKDEBUG && _d('PID file exists; it contains PID', $pid);
2137+ PTDEBUG && _d('PID file exists; it contains PID', $pid);
2138 if ( $pid ) {
2139 my $pid_is_alive = kill 0, $pid;
2140 if ( $pid_is_alive ) {
2141@@ -1503,7 +1503,7 @@
2142 }
2143 }
2144 else {
2145- MKDEBUG && _d('No PID file');
2146+ PTDEBUG && _d('No PID file');
2147 }
2148 return;
2149 }
2150@@ -1523,7 +1523,7 @@
2151
2152 my $PID_file = $self->{PID_file};
2153 if ( !$PID_file ) {
2154- MKDEBUG && _d('No PID file to create');
2155+ PTDEBUG && _d('No PID file to create');
2156 return;
2157 }
2158
2159@@ -1536,7 +1536,7 @@
2160 close $PID_FH
2161 or die "Cannot close PID file $PID_file: $OS_ERROR";
2162
2163- MKDEBUG && _d('Created PID file:', $self->{PID_file});
2164+ PTDEBUG && _d('Created PID file:', $self->{PID_file});
2165 return;
2166 }
2167
2168@@ -1545,10 +1545,10 @@
2169 if ( $self->{PID_file} && -f $self->{PID_file} ) {
2170 unlink $self->{PID_file}
2171 or warn "Cannot remove PID file $self->{PID_file}: $OS_ERROR";
2172- MKDEBUG && _d('Removed PID file');
2173+ PTDEBUG && _d('Removed PID file');
2174 }
2175 else {
2176- MKDEBUG && _d('No PID to remove');
2177+ PTDEBUG && _d('No PID to remove');
2178 }
2179 return;
2180 }
2181@@ -1589,7 +1589,7 @@
2182 use strict;
2183 use warnings FATAL => 'all';
2184 use English qw(-no_match_vars);
2185-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2186+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2187
2188 sub new {
2189 my ( $class, %args ) = @_;
2190@@ -1642,19 +1642,19 @@
2191 my $result_set;
2192
2193 if ( $text =~ m/^\+---/m ) { # standard "tabular" output
2194- MKDEBUG && _d('Result set text is standard tabular');
2195+ PTDEBUG && _d('Result set text is standard tabular');
2196 my $line_pattern = qr/^(\| .*)[\r\n]+/m;
2197 $result_set
2198 = $self->parse_horizontal_row($text, $line_pattern, \&_parse_tabular);
2199 }
2200 elsif ( $text =~ m/^\w+\t\w+/m ) { # tab-separated
2201- MKDEBUG && _d('Result set text is tab-separated');
2202+ PTDEBUG && _d('Result set text is tab-separated');
2203 my $line_pattern = qr/^(.*?\t.*)[\r\n]+/m;
2204 $result_set
2205 = $self->parse_horizontal_row($text, $line_pattern, \&_parse_tab_sep);
2206 }
2207 elsif ( $text =~ m/\*\*\* \d+\. row/ ) { # "vertical" output
2208- MKDEBUG && _d('Result set text is vertical (\G)');
2209+ PTDEBUG && _d('Result set text is vertical (\G)');
2210 foreach my $row ( split_vertical_rows($text) ) {
2211 push @$result_set, $self->parse_vertical_row($row);
2212 }
2213@@ -1733,7 +1733,7 @@
2214 use strict;
2215 use warnings FATAL => 'all';
2216 use English qw(-no_match_vars);
2217-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2218+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2219
2220 my %can_be_duplicate = (
2221 replicate_wild_do_table => 1,
2222@@ -1791,7 +1791,7 @@
2223 elsif ( my $dbh = $args{dbh} ) {
2224 $config_data{format} = $args{format} || 'show_variables';
2225 my $sql = "SHOW /*!40103 GLOBAL*/ VARIABLES";
2226- MKDEBUG && _d($dbh, $sql);
2227+ PTDEBUG && _d($dbh, $sql);
2228 my $rows = $dbh->selectall_arrayref($sql);
2229 $config_data{vars} = { map { @$_ } @$rows };
2230 $config_data{mysql_version} = _get_version($dbh);
2231@@ -1810,7 +1810,7 @@
2232 die "I need a $arg arugment" unless $args{$arg};
2233 }
2234 my ($output) = @args{@required_args};
2235- MKDEBUG && _d("Parsing config output");
2236+ PTDEBUG && _d("Parsing config output");
2237
2238 my $format = $args{format} || detect_config_output_format(%args);
2239 if ( !$format ) {
2240@@ -1868,22 +1868,22 @@
2241 || $output =~ m/Variable_name:\s+\w+/
2242 || $output =~ m/Variable_name\s+Value$/m )
2243 {
2244- MKDEBUG && _d('show variables format');
2245+ PTDEBUG && _d('show variables format');
2246 $format = 'show_variables';
2247 }
2248 elsif ( $output =~ m/Starts the MySQL database server/
2249 || $output =~ m/Default options are read from /
2250 || $output =~ m/^help\s+TRUE /m )
2251 {
2252- MKDEBUG && _d('mysqld format');
2253+ PTDEBUG && _d('mysqld format');
2254 $format = 'mysqld';
2255 }
2256 elsif ( $output =~ m/^--\w+/m ) {
2257- MKDEBUG && _d('my_print_defaults format');
2258+ PTDEBUG && _d('my_print_defaults format');
2259 $format = 'my_print_defaults';
2260 }
2261 elsif ( $output =~ m/^\s*\[[a-zA-Z]+\]\s*$/m ) {
2262- MKDEBUG && _d('option file format');
2263+ PTDEBUG && _d('option file format');
2264 $format = 'option_file',
2265 }
2266
2267@@ -1918,14 +1918,14 @@
2268 my ($opt_files) = $output =~ m/\G^(.+)\n/m;
2269 my %seen;
2270 my @opt_files = grep { !$seen{$_} } split(' ', $opt_files);
2271- MKDEBUG && _d('Option files:', @opt_files);
2272+ PTDEBUG && _d('Option files:', @opt_files);
2273 }
2274 else {
2275- MKDEBUG && _d("mysqld help output doesn't list option files");
2276+ PTDEBUG && _d("mysqld help output doesn't list option files");
2277 }
2278
2279 if ( $output !~ m/^-+ -+$/mg ) {
2280- MKDEBUG && _d("mysqld help output doesn't list vars and vals");
2281+ PTDEBUG && _d("mysqld help output doesn't list vars and vals");
2282 return;
2283 }
2284
2285@@ -1996,13 +1996,13 @@
2286 $var =~ s/-/_/g;
2287
2288 if ( exists $config{$var} && !$can_be_duplicate{$var} ) {
2289- MKDEBUG && _d("Duplicate var:", $var);
2290+ PTDEBUG && _d("Duplicate var:", $var);
2291 $duplicate_var = 1; # flag on, save all the var's values
2292 }
2293 }
2294 else {
2295 my $val = $item;
2296- MKDEBUG && _d("Var:", $var, "val:", $val);
2297+ PTDEBUG && _d("Var:", $var, "val:", $val);
2298
2299 if ( !defined $val ) {
2300 $val = '';
2301@@ -2063,7 +2063,7 @@
2302 sub _slurp_file {
2303 my ( $file ) = @_;
2304 die "I need a file argument" unless $file;
2305- MKDEBUG && _d("Reading", $file);
2306+ PTDEBUG && _d("Reading", $file);
2307 open my $fh, '<', $file or die "Cannot open $file: $OS_ERROR";
2308 my $contents = do { local $/ = undef; <$fh> };
2309 close $fh;
2310@@ -2075,7 +2075,7 @@
2311 return unless $dbh;
2312 my $version = $dbh->selectrow_arrayref('SELECT VERSION()')->[0];
2313 $version =~ s/(\d\.\d{1,2}.\d{1,2})/$1/;
2314- MKDEBUG && _d('MySQL version', $version);
2315+ PTDEBUG && _d('MySQL version', $version);
2316 return $version;
2317 }
2318
2319@@ -2149,7 +2149,7 @@
2320 use strict;
2321 use warnings FATAL => 'all';
2322 use English qw(-no_match_vars);
2323-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2324+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2325
2326 my %alt_val_for = (
2327 ON => 1,
2328@@ -2233,7 +2233,7 @@
2329 my ($configs) = @args{@required_args};
2330
2331 if ( @$configs < 2 ) {
2332- MKDEBUG && _d("Less than two MySQLConfig objects; nothing to compare");
2333+ PTDEBUG && _d("Less than two MySQLConfig objects; nothing to compare");
2334 return;
2335 }
2336
2337@@ -2281,7 +2281,7 @@
2338 }
2339 }
2340
2341- MKDEBUG && _d("Different", $var, "values:", $val0, $valN);
2342+ PTDEBUG && _d("Different", $var, "values:", $val0, $valN);
2343 $diffs->{$var} = [ map { $_->value_of($var) } @$configs ];
2344 last CONFIG;
2345 } # CONFIG
2346@@ -2308,7 +2308,7 @@
2347 my ($configs) = @args{@required_args};
2348
2349 if ( @$configs < 2 ) {
2350- MKDEBUG && _d("Less than two MySQLConfig objects; nothing to compare");
2351+ PTDEBUG && _d("Less than two MySQLConfig objects; nothing to compare");
2352 return;
2353 }
2354
2355@@ -2387,7 +2387,7 @@
2356 use strict;
2357 use warnings FATAL => 'all';
2358 use English qw(-no_match_vars);
2359-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2360+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2361
2362 use List::Util qw(min max);
2363 use POSIX qw(ceil);
2364@@ -2420,7 +2420,7 @@
2365 . "is not installed" unless $have_term;
2366 ($self->{line_width}) = GetTerminalSize();
2367 }
2368- MKDEBUG && _d('Line width:', $self->{line_width});
2369+ PTDEBUG && _d('Line width:', $self->{line_width});
2370
2371 return bless $self, $class;
2372 }
2373@@ -2445,7 +2445,7 @@
2374
2375 if ( $col->{width} ) {
2376 $col->{width_pct} = ceil(($col->{width} * 100) / $self->{line_width});
2377- MKDEBUG && _d('col:', $col_name, 'width:', $col->{width}, 'chars =',
2378+ PTDEBUG && _d('col:', $col_name, 'width:', $col->{width}, 'chars =',
2379 $col->{width_pct}, '%');
2380 }
2381
2382@@ -2453,7 +2453,7 @@
2383 $used_width += $col->{width_pct};
2384 }
2385 else {
2386- MKDEBUG && _d('Auto width col:', $col_name);
2387+ PTDEBUG && _d('Auto width col:', $col_name);
2388 $col->{auto_width} = 1;
2389 push @auto_width_cols, $i;
2390 }
2391@@ -2482,15 +2482,15 @@
2392
2393 if ( @auto_width_cols ) {
2394 my $wid_per_col = int((100 - $used_width) / scalar @auto_width_cols);
2395- MKDEBUG && _d('Line width left:', (100-$used_width), '%;',
2396+ PTDEBUG && _d('Line width left:', (100-$used_width), '%;',
2397 'each auto width col:', $wid_per_col, '%');
2398 map { $self->{cols}->[$_]->{width_pct} = $wid_per_col } @auto_width_cols;
2399 }
2400
2401 $min_hdr_wid += ($self->{n_cols} - 1) * length $self->{column_spacing};
2402- MKDEBUG && _d('min header width:', $min_hdr_wid);
2403+ PTDEBUG && _d('min header width:', $min_hdr_wid);
2404 if ( $min_hdr_wid > $self->{line_width} ) {
2405- MKDEBUG && _d('Will truncate headers because min header width',
2406+ PTDEBUG && _d('Will truncate headers because min header width',
2407 $min_hdr_wid, '> line width', $self->{line_width});
2408 $self->{truncate_headers} = 1;
2409 }
2410@@ -2531,7 +2531,7 @@
2411 my @col_fmts = $self->_make_column_formats();
2412 my $fmt = ($self->{line_prefix} || '')
2413 . join($self->{column_spacing}, @col_fmts);
2414- MKDEBUG && _d('Format:', $fmt);
2415+ PTDEBUG && _d('Format:', $fmt);
2416
2417 (my $hdr_fmt = $fmt) =~ s/%([^-])/%-$1/g;
2418
2419@@ -2583,7 +2583,7 @@
2420 $val = $mark . substr($val, -1 * $width + length $mark);
2421 }
2422 else {
2423- MKDEBUG && _d("I don't know how to", $side, "truncate values");
2424+ PTDEBUG && _d("I don't know how to", $side, "truncate values");
2425 }
2426 return $val;
2427 }
2428@@ -2595,27 +2595,27 @@
2429 foreach my $col ( @{$self->{cols}} ) {
2430 my $print_width = int($self->{line_width} * ($col->{width_pct} / 100));
2431
2432- MKDEBUG && _d('col:', $col->{name}, 'width pct:', $col->{width_pct},
2433+ PTDEBUG && _d('col:', $col->{name}, 'width pct:', $col->{width_pct},
2434 'char width:', $print_width,
2435 'min val:', $col->{min_val}, 'max val:', $col->{max_val});
2436
2437 if ( $col->{auto_width} ) {
2438 if ( $col->{min_val} && $print_width < $col->{min_val} ) {
2439- MKDEBUG && _d('Increased to min val width:', $col->{min_val});
2440+ PTDEBUG && _d('Increased to min val width:', $col->{min_val});
2441 $print_width = $col->{min_val};
2442 }
2443 elsif ( $col->{max_val} && $print_width > $col->{max_val} ) {
2444- MKDEBUG && _d('Reduced to max val width:', $col->{max_val});
2445+ PTDEBUG && _d('Reduced to max val width:', $col->{max_val});
2446 $extra_space += $print_width - $col->{max_val};
2447 $print_width = $col->{max_val};
2448 }
2449 }
2450
2451 $col->{print_width} = $print_width;
2452- MKDEBUG && _d('print width:', $col->{print_width});
2453+ PTDEBUG && _d('print width:', $col->{print_width});
2454 }
2455
2456- MKDEBUG && _d('Extra space:', $extra_space);
2457+ PTDEBUG && _d('Extra space:', $extra_space);
2458 while ( $extra_space-- ) {
2459 foreach my $col ( @{$self->{cols}} ) {
2460 if ( $col->{auto_width}
2461@@ -2638,7 +2638,7 @@
2462 my $print_width = $col->{print_width};
2463 next if length $col_name <= $print_width;
2464 $col->{name} = $self->truncate_value($col, $col_name, $print_width, $side);
2465- MKDEBUG && _d('Truncated hdr', $col_name, 'to', $col->{name},
2466+ PTDEBUG && _d('Truncated hdr', $col_name, 'to', $col->{name},
2467 'max width:', $print_width);
2468 }
2469 return;
2470@@ -2663,7 +2663,7 @@
2471 my $print_width = $col->{print_width};
2472 $val = $callback ? $callback->($col, $val, $print_width)
2473 : $self->truncate_value($col, $val, $print_width);
2474- MKDEBUG && _d('Truncated val', $vals->[$i], 'to', $val,
2475+ PTDEBUG && _d('Truncated val', $vals->[$i], 'to', $val,
2476 '; max width:', $print_width);
2477 $vals->[$i] = $val;
2478 }
2479@@ -2741,7 +2741,7 @@
2480 $Data::Dumper::Sortkeys = 1;
2481 $Data::Dumper::Quotekeys = 0;
2482
2483-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2484+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2485
2486 sub main {
2487 @ARGV = @_; # set global ARGV for this package
2488@@ -2787,7 +2787,7 @@
2489 my @config_names; # Human-readable names for those ^ objs
2490 foreach my $config_src ( @ARGV ) {
2491 if ( -f $config_src ) {
2492- MKDEBUG && _d('Config source', $config_src, 'is a file');
2493+ PTDEBUG && _d('Config source', $config_src, 'is a file');
2494 push @configs, new MySQLConfig(
2495 file => $config_src,
2496 %common_modules,
2497@@ -2795,7 +2795,7 @@
2498 push @config_names, $config_src; # filename
2499 }
2500 else {
2501- MKDEBUG && _d('Config source', $config_src, 'is a DSN');
2502+ PTDEBUG && _d('Config source', $config_src, 'is a DSN');
2503 my $dsn = $dp->parse($config_src, $last_dsn, $dsn_defaults);
2504 my $dbh = $dp->get_dbh($dp->get_cxn_params($dsn), {AutoCommit => 1});
2505 $dp->fill_in_dsn($dbh, $dsn);
2506@@ -2818,7 +2818,7 @@
2507 if ( $o->get('daemonize') ) {
2508 $daemon = new Daemon(o=>$o);
2509 $daemon->daemonize();
2510- MKDEBUG && _d('I am a daemon now');
2511+ PTDEBUG && _d('I am a daemon now');
2512 }
2513 elsif ( $o->get('pid') ) {
2514 # We're not daemoninzing, it just handles PID stuff.
2515@@ -2850,10 +2850,10 @@
2516 # };
2517 }
2518
2519- MKDEBUG && _d("Comparing", scalar @configs, "configs");
2520+ PTDEBUG && _d("Comparing", scalar @configs, "configs");
2521 my $diffs = $config_cmp->diff(configs=>\@configs);
2522 my $n_diffs = scalar keys %$diffs;
2523- MKDEBUG && _d($n_diffs, "differences found:", Dumper($diffs));
2524+ PTDEBUG && _d($n_diffs, "differences found:", Dumper($diffs));
2525 if ( $n_diffs ) {
2526 if ( $o->get('report') ) {
2527 foreach my $var ( sort keys %$diffs ) {
2528@@ -3257,6 +3257,6 @@
2529
2530 =head1 VERSION
2531
2532-pt-config-diff 1.0.1
2533+pt-config-diff 1.0.2
2534
2535 =cut
2536
2537=== modified file 'bin/pt-deadlock-logger'
2538--- bin/pt-deadlock-logger 2011-09-01 16:00:38 +0000
2539+++ bin/pt-deadlock-logger 2011-12-29 16:12:24 +0000
2540@@ -6,7 +6,7 @@
2541
2542 use strict;
2543 use warnings FATAL => 'all';
2544-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2545+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2546
2547 # ###########################################################################
2548 # OptionParser package
2549@@ -22,7 +22,7 @@
2550 use strict;
2551 use warnings FATAL => 'all';
2552 use English qw(-no_match_vars);
2553-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2554+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2555
2556 use List::Util qw(max);
2557 use Getopt::Long;
2558@@ -106,7 +106,7 @@
2559 my $contents = do { local $/ = undef; <$fh> };
2560 close $fh;
2561 if ( $contents =~ m/^=head1 DSN OPTIONS/m ) {
2562- MKDEBUG && _d('Parsing DSN OPTIONS');
2563+ PTDEBUG && _d('Parsing DSN OPTIONS');
2564 my $dsn_attribs = {
2565 dsn => 1,
2566 copy => 1,
2567@@ -150,7 +150,7 @@
2568
2569 if ( $contents =~ m/^=head1 VERSION\n\n^(.+)$/m ) {
2570 $self->{version} = $1;
2571- MKDEBUG && _d($self->{version});
2572+ PTDEBUG && _d($self->{version});
2573 }
2574
2575 return;
2576@@ -187,7 +187,7 @@
2577 chomp $para;
2578 $para =~ s/\s+/ /g;
2579 $para =~ s/$POD_link_re/$1/go;
2580- MKDEBUG && _d('Option rule:', $para);
2581+ PTDEBUG && _d('Option rule:', $para);
2582 push @rules, $para;
2583 }
2584
2585@@ -196,7 +196,7 @@
2586 do {
2587 if ( my ($option) = $para =~ m/^=item $self->{item}/ ) {
2588 chomp $para;
2589- MKDEBUG && _d($para);
2590+ PTDEBUG && _d($para);
2591 my %attribs;
2592
2593 $para = <$fh>; # read next paragraph, possibly attributes
2594@@ -215,7 +215,7 @@
2595 $para = <$fh>; # read next paragraph, probably short help desc
2596 }
2597 else {
2598- MKDEBUG && _d('Option has no attributes');
2599+ PTDEBUG && _d('Option has no attributes');
2600 }
2601
2602 $para =~ s/\s+\Z//g;
2603@@ -223,7 +223,7 @@
2604 $para =~ s/$POD_link_re/$1/go;
2605
2606 $para =~ s/\.(?:\n.*| [A-Z].*|\Z)//s;
2607- MKDEBUG && _d('Short help:', $para);
2608+ PTDEBUG && _d('Short help:', $para);
2609
2610 die "No description after option spec $option" if $para =~ m/^=item/;
2611
2612@@ -261,7 +261,7 @@
2613
2614 foreach my $opt ( @specs ) {
2615 if ( ref $opt ) { # It's an option spec, not a rule.
2616- MKDEBUG && _d('Parsing opt spec:',
2617+ PTDEBUG && _d('Parsing opt spec:',
2618 map { ($_, '=>', $opt->{$_}) } keys %$opt);
2619
2620 my ( $long, $short ) = $opt->{spec} =~ m/^([\w-]+)(?:\|([^!+=]*))?/;
2621@@ -274,7 +274,7 @@
2622 $self->{opts}->{$long} = $opt;
2623
2624 if ( length $long == 1 ) {
2625- MKDEBUG && _d('Long opt', $long, 'looks like short opt');
2626+ PTDEBUG && _d('Long opt', $long, 'looks like short opt');
2627 $self->{short_opts}->{$long} = $long;
2628 }
2629
2630@@ -300,14 +300,14 @@
2631
2632 my ( $type ) = $opt->{spec} =~ m/=(.)/;
2633 $opt->{type} = $type;
2634- MKDEBUG && _d($long, 'type:', $type);
2635+ PTDEBUG && _d($long, 'type:', $type);
2636
2637
2638 $opt->{spec} =~ s/=./=s/ if ( $type && $type =~ m/[HhAadzm]/ );
2639
2640 if ( (my ($def) = $opt->{desc} =~ m/default\b(?: ([^)]+))?/) ) {
2641 $self->{defaults}->{$long} = defined $def ? $def : 1;
2642- MKDEBUG && _d($long, 'default:', $def);
2643+ PTDEBUG && _d($long, 'default:', $def);
2644 }
2645
2646 if ( $long eq 'config' ) {
2647@@ -316,13 +316,13 @@
2648
2649 if ( (my ($dis) = $opt->{desc} =~ m/(disables .*)/) ) {
2650 $disables{$long} = $dis;
2651- MKDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
2652+ PTDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
2653 }
2654
2655 $self->{opts}->{$long} = $opt;
2656 }
2657 else { # It's an option rule, not a spec.
2658- MKDEBUG && _d('Parsing rule:', $opt);
2659+ PTDEBUG && _d('Parsing rule:', $opt);
2660 push @{$self->{rules}}, $opt;
2661 my @participants = $self->_get_participants($opt);
2662 my $rule_ok = 0;
2663@@ -330,17 +330,17 @@
2664 if ( $opt =~ m/mutually exclusive|one and only one/ ) {
2665 $rule_ok = 1;
2666 push @{$self->{mutex}}, \@participants;
2667- MKDEBUG && _d(@participants, 'are mutually exclusive');
2668+ PTDEBUG && _d(@participants, 'are mutually exclusive');
2669 }
2670 if ( $opt =~ m/at least one|one and only one/ ) {
2671 $rule_ok = 1;
2672 push @{$self->{atleast1}}, \@participants;
2673- MKDEBUG && _d(@participants, 'require at least one');
2674+ PTDEBUG && _d(@participants, 'require at least one');
2675 }
2676 if ( $opt =~ m/default to/ ) {
2677 $rule_ok = 1;
2678 $self->{defaults_to}->{$participants[0]} = $participants[1];
2679- MKDEBUG && _d($participants[0], 'defaults to', $participants[1]);
2680+ PTDEBUG && _d($participants[0], 'defaults to', $participants[1]);
2681 }
2682 if ( $opt =~ m/restricted to option groups/ ) {
2683 $rule_ok = 1;
2684@@ -354,7 +354,7 @@
2685 if( $opt =~ m/accepts additional command-line arguments/ ) {
2686 $rule_ok = 1;
2687 $self->{strict} = 0;
2688- MKDEBUG && _d("Strict mode disabled by rule");
2689+ PTDEBUG && _d("Strict mode disabled by rule");
2690 }
2691
2692 die "Unrecognized option rule: $opt" unless $rule_ok;
2693@@ -364,7 +364,7 @@
2694 foreach my $long ( keys %disables ) {
2695 my @participants = $self->_get_participants($disables{$long});
2696 $self->{disables}->{$long} = \@participants;
2697- MKDEBUG && _d('Option', $long, 'disables', @participants);
2698+ PTDEBUG && _d('Option', $long, 'disables', @participants);
2699 }
2700
2701 return;
2702@@ -378,7 +378,7 @@
2703 unless exists $self->{opts}->{$long};
2704 push @participants, $long;
2705 }
2706- MKDEBUG && _d('Participants for', $str, ':', @participants);
2707+ PTDEBUG && _d('Participants for', $str, ':', @participants);
2708 return @participants;
2709 }
2710
2711@@ -401,7 +401,7 @@
2712 die "Cannot set default for nonexistent option $long"
2713 unless exists $self->{opts}->{$long};
2714 $self->{defaults}->{$long} = $defaults{$long};
2715- MKDEBUG && _d('Default val for', $long, ':', $defaults{$long});
2716+ PTDEBUG && _d('Default val for', $long, ':', $defaults{$long});
2717 }
2718 return;
2719 }
2720@@ -430,7 +430,7 @@
2721 $opt->{value} = $val;
2722 }
2723 $opt->{got} = 1;
2724- MKDEBUG && _d('Got option', $long, '=', $val);
2725+ PTDEBUG && _d('Got option', $long, '=', $val);
2726 }
2727
2728 sub get_opts {
2729@@ -461,7 +461,7 @@
2730 if ( $self->got('config') ) {
2731 die $EVAL_ERROR;
2732 }
2733- elsif ( MKDEBUG ) {
2734+ elsif ( PTDEBUG ) {
2735 _d($EVAL_ERROR);
2736 }
2737 }
2738@@ -528,7 +528,7 @@
2739 if ( exists $self->{disables}->{$long} ) {
2740 my @disable_opts = @{$self->{disables}->{$long}};
2741 map { $self->{opts}->{$_}->{value} = undef; } @disable_opts;
2742- MKDEBUG && _d('Unset options', @disable_opts,
2743+ PTDEBUG && _d('Unset options', @disable_opts,
2744 'because', $long,'disables them');
2745 }
2746
2747@@ -577,7 +577,7 @@
2748 delete $long[$i];
2749 }
2750 else {
2751- MKDEBUG && _d('Temporarily failed to parse', $long);
2752+ PTDEBUG && _d('Temporarily failed to parse', $long);
2753 }
2754 }
2755
2756@@ -601,12 +601,12 @@
2757 my $val = $opt->{value};
2758
2759 if ( $val && $opt->{type} eq 'm' ) { # type time
2760- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
2761+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
2762 my ( $prefix, $num, $suffix ) = $val =~ m/([+-]?)(\d+)([a-z])?$/;
2763 if ( !$suffix ) {
2764 my ( $s ) = $opt->{desc} =~ m/\(suffix (.)\)/;
2765 $suffix = $s || 's';
2766- MKDEBUG && _d('No suffix given; using', $suffix, 'for',
2767+ PTDEBUG && _d('No suffix given; using', $suffix, 'for',
2768 $opt->{long}, '(value:', $val, ')');
2769 }
2770 if ( $suffix =~ m/[smhd]/ ) {
2771@@ -615,23 +615,23 @@
2772 : $suffix eq 'h' ? $num * 3600 # Hours
2773 : $num * 86400; # Days
2774 $opt->{value} = ($prefix || '') . $val;
2775- MKDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
2776+ PTDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
2777 }
2778 else {
2779 $self->save_error("Invalid time suffix for --$opt->{long}");
2780 }
2781 }
2782 elsif ( $val && $opt->{type} eq 'd' ) { # type DSN
2783- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
2784+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
2785 my $prev = {};
2786 my $from_key = $self->{defaults_to}->{ $opt->{long} };
2787 if ( $from_key ) {
2788- MKDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
2789+ PTDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
2790 if ( $self->{opts}->{$from_key}->{parsed} ) {
2791 $prev = $self->{opts}->{$from_key}->{value};
2792 }
2793 else {
2794- MKDEBUG && _d('Cannot parse', $opt->{long}, 'until',
2795+ PTDEBUG && _d('Cannot parse', $opt->{long}, 'until',
2796 $from_key, 'parsed');
2797 return;
2798 }
2799@@ -640,7 +640,7 @@
2800 $opt->{value} = $self->{DSNParser}->parse($val, $prev, $defaults);
2801 }
2802 elsif ( $val && $opt->{type} eq 'z' ) { # type size
2803- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
2804+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
2805 $self->_parse_size($opt, $val);
2806 }
2807 elsif ( $opt->{type} eq 'H' || (defined $val && $opt->{type} eq 'h') ) {
2808@@ -650,7 +650,7 @@
2809 $opt->{value} = [ split(/(?<!\\),\s*/, ($val || '')) ];
2810 }
2811 else {
2812- MKDEBUG && _d('Nothing to validate for option',
2813+ PTDEBUG && _d('Nothing to validate for option',
2814 $opt->{long}, 'type', $opt->{type}, 'value', $val);
2815 }
2816
2817@@ -724,11 +724,11 @@
2818 $file ||= $self->{file} || __FILE__;
2819
2820 if ( !$self->{description} || !$self->{usage} ) {
2821- MKDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
2822+ PTDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
2823 my %synop = $self->_parse_synopsis($file);
2824 $self->{description} ||= $synop{description};
2825 $self->{usage} ||= $synop{usage};
2826- MKDEBUG && _d("Description:", $self->{description},
2827+ PTDEBUG && _d("Description:", $self->{description},
2828 "\nUsage:", $self->{usage});
2829 }
2830
2831@@ -943,7 +943,7 @@
2832 my ( $self, $opt, $val ) = @_;
2833
2834 if ( lc($val || '') eq 'null' ) {
2835- MKDEBUG && _d('NULL size for', $opt->{long});
2836+ PTDEBUG && _d('NULL size for', $opt->{long});
2837 $opt->{value} = 'null';
2838 return;
2839 }
2840@@ -953,7 +953,7 @@
2841 if ( defined $num ) {
2842 if ( $factor ) {
2843 $num *= $factor_for{$factor};
2844- MKDEBUG && _d('Setting option', $opt->{y},
2845+ PTDEBUG && _d('Setting option', $opt->{y},
2846 'to num', $num, '* factor', $factor);
2847 }
2848 $opt->{value} = ($pre || '') . $num;
2849@@ -977,7 +977,7 @@
2850 sub _parse_synopsis {
2851 my ( $self, $file ) = @_;
2852 $file ||= $self->{file} || __FILE__;
2853- MKDEBUG && _d("Parsing SYNOPSIS in", $file);
2854+ PTDEBUG && _d("Parsing SYNOPSIS in", $file);
2855
2856 local $INPUT_RECORD_SEPARATOR = ''; # read paragraphs
2857 open my $fh, "<", $file or die "Cannot open $file: $OS_ERROR";
2858@@ -990,7 +990,7 @@
2859 push @synop, $para;
2860 }
2861 close $fh;
2862- MKDEBUG && _d("Raw SYNOPSIS text:", @synop);
2863+ PTDEBUG && _d("Raw SYNOPSIS text:", @synop);
2864 my ($usage, $desc) = @synop;
2865 die "The SYNOPSIS section in $file is not formatted properly"
2866 unless $usage && $desc;
2867@@ -1017,7 +1017,7 @@
2868 print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
2869 }
2870
2871-if ( MKDEBUG ) {
2872+if ( PTDEBUG ) {
2873 print '# ', $^X, ' ', $], "\n";
2874 if ( my $uname = `uname -a` ) {
2875 $uname =~ s/\s+/ /g;
2876@@ -1047,7 +1047,7 @@
2877 use strict;
2878 use warnings FATAL => 'all';
2879 use English qw(-no_match_vars);
2880-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2881+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2882
2883 sub new {
2884 my ( $class ) = @_;
2885@@ -1057,7 +1057,7 @@
2886 sub parse {
2887 my ( $self, $str ) = @_;
2888 my $result = sprintf('%03d%03d%03d', $str =~ m/(\d+)/g);
2889- MKDEBUG && _d($str, 'parses to', $result);
2890+ PTDEBUG && _d($str, 'parses to', $result);
2891 return $result;
2892 }
2893
2894@@ -1068,7 +1068,7 @@
2895 $dbh->selectrow_array('SELECT VERSION()'));
2896 }
2897 my $result = $self->{$dbh} ge $self->parse($target) ? 1 : 0;
2898- MKDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
2899+ PTDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
2900 return $result;
2901 }
2902
2903@@ -1086,7 +1086,7 @@
2904 }
2905 @{ $dbh->selectall_arrayref("SHOW ENGINES", {Slice=>{}}) };
2906 if ( $innodb ) {
2907- MKDEBUG && _d("InnoDB support:", $innodb->{support});
2908+ PTDEBUG && _d("InnoDB support:", $innodb->{support});
2909 if ( $innodb->{support} =~ m/YES|DEFAULT/i ) {
2910 my $vars = $dbh->selectrow_hashref(
2911 "SHOW VARIABLES LIKE 'innodb_version'");
2912@@ -1098,7 +1098,7 @@
2913 }
2914 }
2915
2916- MKDEBUG && _d("InnoDB version:", $innodb_version);
2917+ PTDEBUG && _d("InnoDB version:", $innodb_version);
2918 return $innodb_version;
2919 }
2920
2921@@ -1130,7 +1130,7 @@
2922 use strict;
2923 use warnings FATAL => 'all';
2924 use English qw(-no_match_vars);
2925-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2926+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2927
2928 sub new {
2929 my ( $class, %args ) = @_;
2930@@ -1207,7 +1207,7 @@
2931 use strict;
2932 use warnings FATAL => 'all';
2933 use English qw(-no_match_vars);
2934-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
2935+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
2936
2937 use Data::Dumper;
2938 $Data::Dumper::Indent = 0;
2939@@ -1230,7 +1230,7 @@
2940 if ( !$opt->{key} || !$opt->{desc} ) {
2941 die "Invalid DSN option: ", Dumper($opt);
2942 }
2943- MKDEBUG && _d('DSN option:',
2944+ PTDEBUG && _d('DSN option:',
2945 join(', ',
2946 map { "$_=" . (defined $opt->{$_} ? ($opt->{$_} || '') : 'undef') }
2947 keys %$opt
2948@@ -1248,7 +1248,7 @@
2949 sub prop {
2950 my ( $self, $prop, $value ) = @_;
2951 if ( @_ > 2 ) {
2952- MKDEBUG && _d('Setting', $prop, 'property');
2953+ PTDEBUG && _d('Setting', $prop, 'property');
2954 $self->{$prop} = $value;
2955 }
2956 return $self->{$prop};
2957@@ -1257,10 +1257,10 @@
2958 sub parse {
2959 my ( $self, $dsn, $prev, $defaults ) = @_;
2960 if ( !$dsn ) {
2961- MKDEBUG && _d('No DSN to parse');
2962+ PTDEBUG && _d('No DSN to parse');
2963 return;
2964 }
2965- MKDEBUG && _d('Parsing', $dsn);
2966+ PTDEBUG && _d('Parsing', $dsn);
2967 $prev ||= {};
2968 $defaults ||= {};
2969 my %given_props;
2970@@ -1272,23 +1272,23 @@
2971 $given_props{$prop_key} = $prop_val;
2972 }
2973 else {
2974- MKDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
2975+ PTDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
2976 $given_props{h} = $dsn_part;
2977 }
2978 }
2979
2980 foreach my $key ( keys %$opts ) {
2981- MKDEBUG && _d('Finding value for', $key);
2982+ PTDEBUG && _d('Finding value for', $key);
2983 $final_props{$key} = $given_props{$key};
2984 if ( !defined $final_props{$key}
2985 && defined $prev->{$key} && $opts->{$key}->{copy} )
2986 {
2987 $final_props{$key} = $prev->{$key};
2988- MKDEBUG && _d('Copying value for', $key, 'from previous DSN');
2989+ PTDEBUG && _d('Copying value for', $key, 'from previous DSN');
2990 }
2991 if ( !defined $final_props{$key} ) {
2992 $final_props{$key} = $defaults->{$key};
2993- MKDEBUG && _d('Copying value for', $key, 'from defaults');
2994+ PTDEBUG && _d('Copying value for', $key, 'from defaults');
2995 }
2996 }
2997
2998@@ -1319,7 +1319,7 @@
2999 grep { $o->has($_) && $o->get($_) }
3000 keys %{$self->{opts}}
3001 );
3002- MKDEBUG && _d('DSN string made from options:', $dsn_string);
3003+ PTDEBUG && _d('DSN string made from options:', $dsn_string);
3004 return $self->parse($dsn_string);
3005 }
3006
3007@@ -1369,7 +1369,7 @@
3008 qw(F h P S A))
3009 . ';mysql_read_default_group=client';
3010 }
3011- MKDEBUG && _d($dsn);
3012+ PTDEBUG && _d($dsn);
3013 return ($dsn, $info->{u}, $info->{p});
3014 }
3015
3016@@ -1414,7 +1414,7 @@
3017 my $dbh;
3018 my $tries = 2;
3019 while ( !$dbh && $tries-- ) {
3020- MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
3021+ PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
3022 join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
3023
3024 eval {
3025@@ -1424,21 +1424,21 @@
3026 my $sql;
3027
3028 $sql = 'SELECT @@SQL_MODE';
3029- MKDEBUG && _d($dbh, $sql);
3030+ PTDEBUG && _d($dbh, $sql);
3031 my ($sql_mode) = $dbh->selectrow_array($sql);
3032
3033 $sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
3034 . '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
3035 . ($sql_mode ? ",$sql_mode" : '')
3036 . '\'*/';
3037- MKDEBUG && _d($dbh, $sql);
3038+ PTDEBUG && _d($dbh, $sql);
3039 $dbh->do($sql);
3040
3041 if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
3042 $sql = "/*!40101 SET NAMES $charset*/";
3043- MKDEBUG && _d($dbh, ':', $sql);
3044+ PTDEBUG && _d($dbh, ':', $sql);
3045 $dbh->do($sql);
3046- MKDEBUG && _d('Enabling charset for STDOUT');
3047+ PTDEBUG && _d('Enabling charset for STDOUT');
3048 if ( $charset eq 'utf8' ) {
3049 binmode(STDOUT, ':utf8')
3050 or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
3051@@ -1450,15 +1450,15 @@
3052
3053 if ( $self->prop('set-vars') ) {
3054 $sql = "SET " . $self->prop('set-vars');
3055- MKDEBUG && _d($dbh, ':', $sql);
3056+ PTDEBUG && _d($dbh, ':', $sql);
3057 $dbh->do($sql);
3058 }
3059 }
3060 };
3061 if ( !$dbh && $EVAL_ERROR ) {
3062- MKDEBUG && _d($EVAL_ERROR);
3063+ PTDEBUG && _d($EVAL_ERROR);
3064 if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
3065- MKDEBUG && _d('Going to try again without utf8 support');
3066+ PTDEBUG && _d('Going to try again without utf8 support');
3067 delete $defaults->{mysql_enable_utf8};
3068 }
3069 elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
3070@@ -1476,7 +1476,7 @@
3071 }
3072 }
3073
3074- MKDEBUG && _d('DBH info: ',
3075+ PTDEBUG && _d('DBH info: ',
3076 $dbh,
3077 Dumper($dbh->selectrow_hashref(
3078 'SELECT DATABASE(), CONNECTION_ID(), VERSION()/*!50038 , @@hostname*/')),
3079@@ -1502,7 +1502,7 @@
3080
3081 sub disconnect {
3082 my ( $self, $dbh ) = @_;
3083- MKDEBUG && $self->print_active_handles($dbh);
3084+ PTDEBUG && $self->print_active_handles($dbh);
3085 $dbh->disconnect;
3086 }
3087
3088@@ -1563,7 +1563,7 @@
3089 use strict;
3090 use warnings FATAL => 'all';
3091 use English qw(-no_match_vars);
3092-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3093+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3094
3095 use POSIX qw(setsid);
3096
3097@@ -1581,17 +1581,17 @@
3098
3099 check_PID_file(undef, $self->{PID_file});
3100
3101- MKDEBUG && _d('Daemonized child will log to', $self->{log_file});
3102+ PTDEBUG && _d('Daemonized child will log to', $self->{log_file});
3103 return bless $self, $class;
3104 }
3105
3106 sub daemonize {
3107 my ( $self ) = @_;
3108
3109- MKDEBUG && _d('About to fork and daemonize');
3110+ PTDEBUG && _d('About to fork and daemonize');
3111 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
3112 if ( $pid ) {
3113- MKDEBUG && _d('I am the parent and now I die');
3114+ PTDEBUG && _d('I am the parent and now I die');
3115 exit;
3116 }
3117
3118@@ -1633,19 +1633,19 @@
3119 }
3120 }
3121
3122- MKDEBUG && _d('I am the child and now I live daemonized');
3123+ PTDEBUG && _d('I am the child and now I live daemonized');
3124 return;
3125 }
3126
3127 sub check_PID_file {
3128 my ( $self, $file ) = @_;
3129 my $PID_file = $self ? $self->{PID_file} : $file;
3130- MKDEBUG && _d('Checking PID file', $PID_file);
3131+ PTDEBUG && _d('Checking PID file', $PID_file);
3132 if ( $PID_file && -f $PID_file ) {
3133 my $pid;
3134 eval { chomp($pid = `cat $PID_file`); };
3135 die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
3136- MKDEBUG && _d('PID file exists; it contains PID', $pid);
3137+ PTDEBUG && _d('PID file exists; it contains PID', $pid);
3138 if ( $pid ) {
3139 my $pid_is_alive = kill 0, $pid;
3140 if ( $pid_is_alive ) {
3141@@ -1663,7 +1663,7 @@
3142 }
3143 }
3144 else {
3145- MKDEBUG && _d('No PID file');
3146+ PTDEBUG && _d('No PID file');
3147 }
3148 return;
3149 }
3150@@ -1683,7 +1683,7 @@
3151
3152 my $PID_file = $self->{PID_file};
3153 if ( !$PID_file ) {
3154- MKDEBUG && _d('No PID file to create');
3155+ PTDEBUG && _d('No PID file to create');
3156 return;
3157 }
3158
3159@@ -1696,7 +1696,7 @@
3160 close $PID_FH
3161 or die "Cannot close PID file $PID_file: $OS_ERROR";
3162
3163- MKDEBUG && _d('Created PID file:', $self->{PID_file});
3164+ PTDEBUG && _d('Created PID file:', $self->{PID_file});
3165 return;
3166 }
3167
3168@@ -1705,10 +1705,10 @@
3169 if ( $self->{PID_file} && -f $self->{PID_file} ) {
3170 unlink $self->{PID_file}
3171 or warn "Cannot remove PID file $self->{PID_file}: $OS_ERROR";
3172- MKDEBUG && _d('Removed PID file');
3173+ PTDEBUG && _d('Removed PID file');
3174 }
3175 else {
3176- MKDEBUG && _d('No PID to remove');
3177+ PTDEBUG && _d('No PID to remove');
3178 }
3179 return;
3180 }
3181@@ -1750,7 +1750,7 @@
3182 use Socket qw(inet_aton);
3183 use sigtrap qw(handler finish untrapped normal-signals);
3184
3185-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3186+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3187
3188 my $o;
3189 my $oktorun;
3190@@ -1863,7 +1863,7 @@
3191 # try to extract it from the $dbh
3192 if ( !$source_dsn->{h} ) {
3193 ($source_dsn->{h}) = $dbh->{mysql_hostinfo} =~ m/(\w+) via/;
3194- MKDEBUG && _d('Got source host from dbh:', $source_dsn->{h});
3195+ PTDEBUG && _d('Got source host from dbh:', $source_dsn->{h});
3196 }
3197
3198 my @cols = qw( server ts thread txn_id txn_time user hostname ip db tbl idx
3199@@ -1882,14 +1882,14 @@
3200 my $cols = join(',', map { $q->quote($_) } @cols);
3201 my $parms = join(',', map { '?' } @cols);
3202 my $sql = "INSERT IGNORE INTO $db_tbl($cols) VALUES($parms)";
3203- MKDEBUG && _d($sql);
3204+ PTDEBUG && _d($sql);
3205 $ins_sth = $dest_dbh->prepare($sql);
3206
3207 if ( $o->get('create-dest-table') ) {
3208 my $db_tbl = $q->quote($dest_dsn->{D}, $dest_dsn->{t});
3209 $sql = $o->read_para_after(__FILE__, qr/MAGIC_dest_table/);
3210 $sql =~ s/deadlocks/IF NOT EXISTS $db_tbl/;
3211- MKDEBUG && _d($sql);
3212+ PTDEBUG && _d($sql);
3213 $dest_dbh->do($sql);
3214 }
3215 }
3216@@ -1899,7 +1899,7 @@
3217 if ( $o->get('daemonize') ) {
3218 $daemon = new Daemon(o=>$o);
3219 $daemon->daemonize();
3220- MKDEBUG && _d('I am a daemon now');
3221+ PTDEBUG && _d('I am a daemon now');
3222 }
3223 elsif ( $o->get('pid') ) {
3224 # We're not daemoninzing, it just handles PID stuff.
3225@@ -1930,7 +1930,7 @@
3226 }
3227
3228 if ( $fingerprint ne $last_fingerprint ) {
3229- MKDEBUG && _d('New deadlock');
3230+ PTDEBUG && _d('New deadlock');
3231 if ( $o->got('print') || !$o->got('dest') ) {
3232 my $sep = $o->get('tab') ? "\t" : ' ';
3233 print join($sep, @cols), "\n";
3234@@ -1945,14 +1945,14 @@
3235 }
3236 }
3237 else {
3238- MKDEBUG && _d('Same deadlock, not printing');
3239+ PTDEBUG && _d('Same deadlock, not printing');
3240 }
3241 # Save deadlock's fingerprint for next interval.
3242 $last_fingerprint = $fingerprint;
3243
3244 # If specified, clear the deadlock...
3245 if ( my $db_tbl = $o->get('clear-deadlocks') ) {
3246- MKDEBUG && _d('Creating --clear-deadlocks table', $db_tbl);
3247+ PTDEBUG && _d('Creating --clear-deadlocks table', $db_tbl);
3248 $dbh->{AutoCommit} = 0;
3249 my $sql = $o->read_para_after(__FILE__, qr/MAGIC_clear_deadlocks/);
3250
3251@@ -1960,10 +1960,10 @@
3252 $sql =~ s/ENGINE=/TYPE=/;
3253 }
3254 $sql =~ s/test.deadlock_maker/$db_tbl/;
3255- MKDEBUG && _d($sql);
3256+ PTDEBUG && _d($sql);
3257 $dbh->do($sql);
3258 $sql = "INSERT INTO $db_tbl(a) VALUES(1)";
3259- MKDEBUG && _d($sql);
3260+ PTDEBUG && _d($sql);
3261 $dbh->do($sql); # I'm holding locks on the table now.
3262
3263 # Fork off a child to try to take a lock on the table.
3264@@ -1971,11 +1971,11 @@
3265 if ( defined($pid) && $pid == 0 ) { # I am a child
3266 my $dbh_child = get_cxn($source_dsn, 0);
3267 $sql = "SELECT * FROM $db_tbl FOR UPDATE";
3268- MKDEBUG && _d($sql);
3269+ PTDEBUG && _d($sql);
3270 eval { $dbh_child->do($sql); }; # Should block against parent.
3271- MKDEBUG && _d($EVAL_ERROR); # Parent inserted value 0.
3272+ PTDEBUG && _d($EVAL_ERROR); # Parent inserted value 0.
3273 $sql = "DROP TABLE $db_tbl";
3274- MKDEBUG && _d($sql);
3275+ PTDEBUG && _d($sql);
3276 $dbh_child->do($sql);
3277 exit;
3278 }
3279@@ -1984,9 +1984,9 @@
3280 }
3281 sleep 1;
3282 $sql = "INSERT INTO $db_tbl(a) VALUES(0)";# Will make child deadlock
3283- MKDEBUG && _d($sql);
3284+ PTDEBUG && _d($sql);
3285 eval { $dbh->do($sql); };
3286- MKDEBUG && _d($EVAL_ERROR);
3287+ PTDEBUG && _d($EVAL_ERROR);
3288 waitpid($pid, 0);
3289 }
3290
3291@@ -2146,7 +2146,7 @@
3292 $fingerprint = $fingerprint
3293 . join('', map { $txn->{$_} } qw(server ts thread) );
3294 }
3295- MKDEBUG && _d('Deadlock fingerprint:', $fingerprint);
3296+ PTDEBUG && _d('Deadlock fingerprint:', $fingerprint);
3297 return $fingerprint;
3298 }
3299
3300@@ -2736,6 +2736,6 @@
3301
3302 =head1 VERSION
3303
3304-pt-deadlock-logger 1.0.1
3305+pt-deadlock-logger 1.0.2
3306
3307 =cut
3308
3309=== modified file 'bin/pt-diskstats'
3310--- bin/pt-diskstats 2011-09-01 16:00:38 +0000
3311+++ bin/pt-diskstats 2011-12-29 16:12:24 +0000
3312@@ -888,7 +888,7 @@
3313
3314 =head1 VERSION
3315
3316-pt-diskstats 1.0.1
3317+pt-diskstats 1.0.2
3318
3319 =cut
3320
3321
3322=== modified file 'bin/pt-duplicate-key-checker'
3323--- bin/pt-duplicate-key-checker 2011-09-01 16:00:38 +0000
3324+++ bin/pt-duplicate-key-checker 2011-12-29 16:12:24 +0000
3325@@ -6,7 +6,7 @@
3326
3327 use strict;
3328 use warnings FATAL => 'all';
3329-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3330+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3331
3332 # ###########################################################################
3333 # VersionParser package
3334@@ -22,7 +22,7 @@
3335 use strict;
3336 use warnings FATAL => 'all';
3337 use English qw(-no_match_vars);
3338-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3339+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3340
3341 sub new {
3342 my ( $class ) = @_;
3343@@ -32,7 +32,7 @@
3344 sub parse {
3345 my ( $self, $str ) = @_;
3346 my $result = sprintf('%03d%03d%03d', $str =~ m/(\d+)/g);
3347- MKDEBUG && _d($str, 'parses to', $result);
3348+ PTDEBUG && _d($str, 'parses to', $result);
3349 return $result;
3350 }
3351
3352@@ -43,7 +43,7 @@
3353 $dbh->selectrow_array('SELECT VERSION()'));
3354 }
3355 my $result = $self->{$dbh} ge $self->parse($target) ? 1 : 0;
3356- MKDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
3357+ PTDEBUG && _d($self->{$dbh}, 'ge', $target, ':', $result);
3358 return $result;
3359 }
3360
3361@@ -61,7 +61,7 @@
3362 }
3363 @{ $dbh->selectall_arrayref("SHOW ENGINES", {Slice=>{}}) };
3364 if ( $innodb ) {
3365- MKDEBUG && _d("InnoDB support:", $innodb->{support});
3366+ PTDEBUG && _d("InnoDB support:", $innodb->{support});
3367 if ( $innodb->{support} =~ m/YES|DEFAULT/i ) {
3368 my $vars = $dbh->selectrow_hashref(
3369 "SHOW VARIABLES LIKE 'innodb_version'");
3370@@ -73,7 +73,7 @@
3371 }
3372 }
3373
3374- MKDEBUG && _d("InnoDB version:", $innodb_version);
3375+ PTDEBUG && _d("InnoDB version:", $innodb_version);
3376 return $innodb_version;
3377 }
3378
3379@@ -105,7 +105,7 @@
3380 use strict;
3381 use warnings FATAL => 'all';
3382 use English qw(-no_match_vars);
3383-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3384+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3385
3386 sub new {
3387 my ( $class, %args ) = @_;
3388@@ -182,7 +182,7 @@
3389 use strict;
3390 use warnings FATAL => 'all';
3391 use English qw(-no_match_vars);
3392-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3393+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3394
3395 use Data::Dumper;
3396 $Data::Dumper::Indent = 1;
3397@@ -227,7 +227,7 @@
3398
3399 my @defs = $ddl =~ m/^(\s+`.*?),?$/gm;
3400 my @cols = map { $_ =~ m/`([^`]+)`/ } @defs;
3401- MKDEBUG && _d('Table cols:', join(', ', map { "`$_`" } @cols));
3402+ PTDEBUG && _d('Table cols:', join(', ', map { "`$_`" } @cols));
3403
3404 my %def_for;
3405 @def_for{@cols} = @defs;
3406@@ -288,7 +288,7 @@
3407 }
3408 sort keys %{$tbl->{keys}};
3409
3410- MKDEBUG && _d('Indexes sorted best-first:', join(', ', @indexes));
3411+ PTDEBUG && _d('Indexes sorted best-first:', join(', ', @indexes));
3412 return @indexes;
3413 }
3414
3415@@ -306,7 +306,7 @@
3416 ($best) = $self->sort_indexes($tbl);
3417 }
3418 }
3419- MKDEBUG && _d('Best index found is', $best);
3420+ PTDEBUG && _d('Best index found is', $best);
3421 return $best;
3422 }
3423
3424@@ -315,25 +315,25 @@
3425 return () unless $where;
3426 my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
3427 . ' WHERE ' . $where;
3428- MKDEBUG && _d($sql);
3429+ PTDEBUG && _d($sql);
3430 my $expl = $dbh->selectrow_hashref($sql);
3431 $expl = { map { lc($_) => $expl->{$_} } keys %$expl };
3432 if ( $expl->{possible_keys} ) {
3433- MKDEBUG && _d('possible_keys =', $expl->{possible_keys});
3434+ PTDEBUG && _d('possible_keys =', $expl->{possible_keys});
3435 my @candidates = split(',', $expl->{possible_keys});
3436 my %possible = map { $_ => 1 } @candidates;
3437 if ( $expl->{key} ) {
3438- MKDEBUG && _d('MySQL chose', $expl->{key});
3439+ PTDEBUG && _d('MySQL chose', $expl->{key});
3440 unshift @candidates, grep { $possible{$_} } split(',', $expl->{key});
3441- MKDEBUG && _d('Before deduping:', join(', ', @candidates));
3442+ PTDEBUG && _d('Before deduping:', join(', ', @candidates));
3443 my %seen;
3444 @candidates = grep { !$seen{$_}++ } @candidates;
3445 }
3446- MKDEBUG && _d('Final list:', join(', ', @candidates));
3447+ PTDEBUG && _d('Final list:', join(', ', @candidates));
3448 return @candidates;
3449 }
3450 else {
3451- MKDEBUG && _d('No keys in possible_keys');
3452+ PTDEBUG && _d('No keys in possible_keys');
3453 return ();
3454 }
3455 }
3456@@ -347,66 +347,66 @@
3457 my ($dbh, $db, $tbl) = @args{@required_args};
3458 my $q = $self->{Quoter};
3459 my $db_tbl = $q->quote($db, $tbl);
3460- MKDEBUG && _d('Checking', $db_tbl);
3461+ PTDEBUG && _d('Checking', $db_tbl);
3462
3463 my $sql = "SHOW TABLES FROM " . $q->quote($db)
3464 . ' LIKE ' . $q->literal_like($tbl);
3465- MKDEBUG && _d($sql);
3466+ PTDEBUG && _d($sql);
3467 my $row;
3468 eval {
3469 $row = $dbh->selectrow_arrayref($sql);
3470 };
3471 if ( $EVAL_ERROR ) {
3472- MKDEBUG && _d($EVAL_ERROR);
3473+ PTDEBUG && _d($EVAL_ERROR);
3474 return 0;
3475 }
3476 if ( !$row->[0] || $row->[0] ne $tbl ) {
3477- MKDEBUG && _d('Table does not exist');
3478+ PTDEBUG && _d('Table does not exist');
3479 return 0;
3480 }
3481
3482- MKDEBUG && _d('Table exists; no privs to check');
3483+ PTDEBUG && _d('Table exists; no privs to check');
3484 return 1 unless $args{all_privs};
3485
3486 $sql = "SHOW FULL COLUMNS FROM $db_tbl";
3487- MKDEBUG && _d($sql);
3488+ PTDEBUG && _d($sql);
3489 eval {
3490 $row = $dbh->selectrow_hashref($sql);
3491 };
3492 if ( $EVAL_ERROR ) {
3493- MKDEBUG && _d($EVAL_ERROR);
3494+ PTDEBUG && _d($EVAL_ERROR);
3495 return 0;
3496 }
3497 if ( !scalar keys %$row ) {
3498- MKDEBUG && _d('Table has no columns:', Dumper($row));
3499+ PTDEBUG && _d('Table has no columns:', Dumper($row));
3500 return 0;
3501 }
3502 my $privs = $row->{privileges} || $row->{Privileges};
3503
3504 $sql = "DELETE FROM $db_tbl LIMIT 0";
3505- MKDEBUG && _d($sql);
3506+ PTDEBUG && _d($sql);
3507 eval {
3508 $dbh->do($sql);
3509 };
3510 my $can_delete = $EVAL_ERROR ? 0 : 1;
3511
3512- MKDEBUG && _d('User privs on', $db_tbl, ':', $privs,
3513+ PTDEBUG && _d('User privs on', $db_tbl, ':', $privs,
3514 ($can_delete ? 'delete' : ''));
3515
3516 if ( !($privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/
3517 && $can_delete) ) {
3518- MKDEBUG && _d('User does not have all privs');
3519+ PTDEBUG && _d('User does not have all privs');
3520 return 0;
3521 }
3522
3523- MKDEBUG && _d('User has all privs');
3524+ PTDEBUG && _d('User has all privs');
3525 return 1;
3526 }
3527
3528 sub get_engine {
3529 my ( $self, $ddl, $opts ) = @_;
3530 my ( $engine ) = $ddl =~ m/\).*?(?:ENGINE|TYPE)=(\w+)/;
3531- MKDEBUG && _d('Storage engine:', $engine);
3532+ PTDEBUG && _d('Storage engine:', $engine);
3533 return $engine || undef;
3534 }
3535
3536@@ -422,7 +422,7 @@
3537 next KEY if $key =~ m/FOREIGN/;
3538
3539 my $key_ddl = $key;
3540- MKDEBUG && _d('Parsed key:', $key_ddl);
3541+ PTDEBUG && _d('Parsed key:', $key_ddl);
3542
3543 if ( $engine !~ m/MEMORY|HEAP/ ) {
3544 $key =~ s/USING HASH/USING BTREE/;
3545@@ -448,7 +448,7 @@
3546 }
3547 $name =~ s/`//g;
3548
3549- MKDEBUG && _d( $name, 'key cols:', join(', ', map { "`$_`" } @cols));
3550+ PTDEBUG && _d( $name, 'key cols:', join(', ', map { "`$_`" } @cols));
3551
3552 $keys->{$name} = {
3553 name => $name,
3554@@ -470,7 +470,7 @@
3555 elsif ( $this_key->{is_unique} && !$this_key->{is_nullable} ) {
3556 $clustered_key = $this_key->{name};
3557 }
3558- MKDEBUG && $clustered_key && _d('This key is the clustered key');
3559+ PTDEBUG && $clustered_key && _d('This key is the clustered key');
3560 }
3561 }
3562
3563@@ -538,7 +538,7 @@
3564 }
3565 grep { $_->{name} ne $clustered_key }
3566 values %{$tbl_struct->{keys}};
3567- MKDEBUG && _d('Secondary indexes:', Dumper(\@sec_indexes));
3568+ PTDEBUG && _d('Secondary indexes:', Dumper(\@sec_indexes));
3569
3570 if ( @sec_indexes ) {
3571 $sec_indexes_ddl = join(' ', @sec_indexes);
3572@@ -548,7 +548,7 @@
3573 $ddl =~ s/,(\n\) )/$1/s;
3574 }
3575 else {
3576- MKDEBUG && _d('Not removing secondary indexes from',
3577+ PTDEBUG && _d('Not removing secondary indexes from',
3578 $tbl_struct->{engine}, 'table');
3579 }
3580
3581@@ -583,7 +583,7 @@
3582 use strict;
3583 use warnings FATAL => 'all';
3584 use English qw(-no_match_vars);
3585-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3586+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3587
3588 ( our $before = <<'EOF') =~ s/^ //gm;
3589 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
3590@@ -677,11 +677,11 @@
3591 sub _use_db {
3592 my ( $self, $dbh, $quoter, $new ) = @_;
3593 if ( !$new ) {
3594- MKDEBUG && _d('No new DB to use');
3595+ PTDEBUG && _d('No new DB to use');
3596 return;
3597 }
3598 my $sql = 'USE ' . $quoter->quote($new);
3599- MKDEBUG && _d($dbh, $sql);
3600+ PTDEBUG && _d($dbh, $sql);
3601 $dbh->do($sql);
3602 return;
3603 }
3604@@ -693,12 +693,12 @@
3605 . q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
3606 . '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
3607 . '@@SQL_QUOTE_SHOW_CREATE := 1 */';
3608- MKDEBUG && _d($sql);
3609+ PTDEBUG && _d($sql);
3610 eval { $dbh->do($sql); };
3611- MKDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
3612+ PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
3613 $self->_use_db($dbh, $quoter, $db);
3614 $sql = "SHOW CREATE TABLE " . $quoter->quote($db, $tbl);
3615- MKDEBUG && _d($sql);
3616+ PTDEBUG && _d($sql);
3617 my $href;
3618 eval { $href = $dbh->selectrow_hashref($sql); };
3619 if ( $EVAL_ERROR ) {
3620@@ -708,15 +708,15 @@
3621
3622 $sql = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
3623 . '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
3624- MKDEBUG && _d($sql);
3625+ PTDEBUG && _d($sql);
3626 $dbh->do($sql);
3627 my ($key) = grep { m/create table/i } keys %$href;
3628 if ( $key ) {
3629- MKDEBUG && _d('This table is a base table');
3630+ PTDEBUG && _d('This table is a base table');
3631 $self->{tables}->{$db}->{$tbl} = [ 'table', $href->{$key} ];
3632 }
3633 else {
3634- MKDEBUG && _d('This table is a view');
3635+ PTDEBUG && _d('This table is a view');
3636 ($key) = grep { m/create view/i } keys %$href;
3637 $self->{tables}->{$db}->{$tbl} = [ 'view', $href->{$key} ];
3638 }
3639@@ -726,11 +726,11 @@
3640
3641 sub get_columns {
3642 my ( $self, $dbh, $quoter, $db, $tbl ) = @_;
3643- MKDEBUG && _d('Get columns for', $db, $tbl);
3644+ PTDEBUG && _d('Get columns for', $db, $tbl);
3645 if ( !$self->{cache} || !$self->{columns}->{$db}->{$tbl} ) {
3646 $self->_use_db($dbh, $quoter, $db);
3647 my $sql = "SHOW COLUMNS FROM " . $quoter->quote($db, $tbl);
3648- MKDEBUG && _d($sql);
3649+ PTDEBUG && _d($sql);
3650 my $cols = $dbh->selectall_arrayref($sql, { Slice => {} });
3651
3652 $self->{columns}->{$db}->{$tbl} = [
3653@@ -751,7 +751,7 @@
3654 map { ' ' . $quoter->quote($_->{field}) . ' ' . $_->{type} }
3655 @{$self->get_columns($dbh, $quoter, $db, $tbl)});
3656 $result .= "\n)";
3657- MKDEBUG && _d($result);
3658+ PTDEBUG && _d($result);
3659 return $result;
3660 }
3661
3662@@ -763,11 +763,11 @@
3663 . q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
3664 . '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
3665 . '@@SQL_QUOTE_SHOW_CREATE := 1 */';
3666- MKDEBUG && _d($sql);
3667+ PTDEBUG && _d($sql);
3668 eval { $dbh->do($sql); };
3669- MKDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
3670+ PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
3671 $sql = "SHOW TRIGGERS FROM " . $quoter->quote($db);
3672- MKDEBUG && _d($sql);
3673+ PTDEBUG && _d($sql);
3674 my $sth = $dbh->prepare($sql);
3675 $sth->execute();
3676 if ( $sth->rows ) {
3677@@ -780,7 +780,7 @@
3678 }
3679 $sql = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
3680 . '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
3681- MKDEBUG && _d($sql);
3682+ PTDEBUG && _d($sql);
3683 $dbh->do($sql);
3684 }
3685 if ( $tbl ) {
3686@@ -799,7 +799,7 @@
3687 push @params, $like;
3688 }
3689 my $sth = $dbh->prepare($sql);
3690- MKDEBUG && _d($sql, @params);
3691+ PTDEBUG && _d($sql, @params);
3692 $sth->execute( @params );
3693 my @dbs = map { $_->[0] } @{$sth->fetchall_arrayref()};
3694 $self->{databases} = \@dbs unless $like;
3695@@ -817,7 +817,7 @@
3696 $sql .= ' LIKE ?';
3697 push @params, $like;
3698 }
3699- MKDEBUG && _d($sql, @params);
3700+ PTDEBUG && _d($sql, @params);
3701 my $sth = $dbh->prepare($sql);
3702 $sth->execute(@params);
3703 my @tables = @{$sth->fetchall_arrayref({})};
3704@@ -843,7 +843,7 @@
3705 $sql .= ' LIKE ?';
3706 push @params, $like;
3707 }
3708- MKDEBUG && _d($sql, @params);
3709+ PTDEBUG && _d($sql, @params);
3710 my $sth = $dbh->prepare($sql);
3711 $sth->execute(@params);
3712 my @tables = @{$sth->fetchall_arrayref()};
3713@@ -888,7 +888,7 @@
3714 use strict;
3715 use warnings FATAL => 'all';
3716 use English qw(-no_match_vars);
3717-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3718+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3719
3720 use Data::Dumper;
3721 $Data::Dumper::Indent = 0;
3722@@ -911,7 +911,7 @@
3723 if ( !$opt->{key} || !$opt->{desc} ) {
3724 die "Invalid DSN option: ", Dumper($opt);
3725 }
3726- MKDEBUG && _d('DSN option:',
3727+ PTDEBUG && _d('DSN option:',
3728 join(', ',
3729 map { "$_=" . (defined $opt->{$_} ? ($opt->{$_} || '') : 'undef') }
3730 keys %$opt
3731@@ -929,7 +929,7 @@
3732 sub prop {
3733 my ( $self, $prop, $value ) = @_;
3734 if ( @_ > 2 ) {
3735- MKDEBUG && _d('Setting', $prop, 'property');
3736+ PTDEBUG && _d('Setting', $prop, 'property');
3737 $self->{$prop} = $value;
3738 }
3739 return $self->{$prop};
3740@@ -938,10 +938,10 @@
3741 sub parse {
3742 my ( $self, $dsn, $prev, $defaults ) = @_;
3743 if ( !$dsn ) {
3744- MKDEBUG && _d('No DSN to parse');
3745+ PTDEBUG && _d('No DSN to parse');
3746 return;
3747 }
3748- MKDEBUG && _d('Parsing', $dsn);
3749+ PTDEBUG && _d('Parsing', $dsn);
3750 $prev ||= {};
3751 $defaults ||= {};
3752 my %given_props;
3753@@ -953,23 +953,23 @@
3754 $given_props{$prop_key} = $prop_val;
3755 }
3756 else {
3757- MKDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
3758+ PTDEBUG && _d('Interpreting', $dsn_part, 'as h=', $dsn_part);
3759 $given_props{h} = $dsn_part;
3760 }
3761 }
3762
3763 foreach my $key ( keys %$opts ) {
3764- MKDEBUG && _d('Finding value for', $key);
3765+ PTDEBUG && _d('Finding value for', $key);
3766 $final_props{$key} = $given_props{$key};
3767 if ( !defined $final_props{$key}
3768 && defined $prev->{$key} && $opts->{$key}->{copy} )
3769 {
3770 $final_props{$key} = $prev->{$key};
3771- MKDEBUG && _d('Copying value for', $key, 'from previous DSN');
3772+ PTDEBUG && _d('Copying value for', $key, 'from previous DSN');
3773 }
3774 if ( !defined $final_props{$key} ) {
3775 $final_props{$key} = $defaults->{$key};
3776- MKDEBUG && _d('Copying value for', $key, 'from defaults');
3777+ PTDEBUG && _d('Copying value for', $key, 'from defaults');
3778 }
3779 }
3780
3781@@ -1000,7 +1000,7 @@
3782 grep { $o->has($_) && $o->get($_) }
3783 keys %{$self->{opts}}
3784 );
3785- MKDEBUG && _d('DSN string made from options:', $dsn_string);
3786+ PTDEBUG && _d('DSN string made from options:', $dsn_string);
3787 return $self->parse($dsn_string);
3788 }
3789
3790@@ -1050,7 +1050,7 @@
3791 qw(F h P S A))
3792 . ';mysql_read_default_group=client';
3793 }
3794- MKDEBUG && _d($dsn);
3795+ PTDEBUG && _d($dsn);
3796 return ($dsn, $info->{u}, $info->{p});
3797 }
3798
3799@@ -1095,7 +1095,7 @@
3800 my $dbh;
3801 my $tries = 2;
3802 while ( !$dbh && $tries-- ) {
3803- MKDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
3804+ PTDEBUG && _d($cxn_string, ' ', $user, ' ', $pass,
3805 join(', ', map { "$_=>$defaults->{$_}" } keys %$defaults ));
3806
3807 eval {
3808@@ -1105,21 +1105,21 @@
3809 my $sql;
3810
3811 $sql = 'SELECT @@SQL_MODE';
3812- MKDEBUG && _d($dbh, $sql);
3813+ PTDEBUG && _d($dbh, $sql);
3814 my ($sql_mode) = $dbh->selectrow_array($sql);
3815
3816 $sql = 'SET @@SQL_QUOTE_SHOW_CREATE = 1'
3817 . '/*!40101, @@SQL_MODE=\'NO_AUTO_VALUE_ON_ZERO'
3818 . ($sql_mode ? ",$sql_mode" : '')
3819 . '\'*/';
3820- MKDEBUG && _d($dbh, $sql);
3821+ PTDEBUG && _d($dbh, $sql);
3822 $dbh->do($sql);
3823
3824 if ( my ($charset) = $cxn_string =~ m/charset=(\w+)/ ) {
3825 $sql = "/*!40101 SET NAMES $charset*/";
3826- MKDEBUG && _d($dbh, ':', $sql);
3827+ PTDEBUG && _d($dbh, ':', $sql);
3828 $dbh->do($sql);
3829- MKDEBUG && _d('Enabling charset for STDOUT');
3830+ PTDEBUG && _d('Enabling charset for STDOUT');
3831 if ( $charset eq 'utf8' ) {
3832 binmode(STDOUT, ':utf8')
3833 or die "Can't binmode(STDOUT, ':utf8'): $OS_ERROR";
3834@@ -1131,15 +1131,15 @@
3835
3836 if ( $self->prop('set-vars') ) {
3837 $sql = "SET " . $self->prop('set-vars');
3838- MKDEBUG && _d($dbh, ':', $sql);
3839+ PTDEBUG && _d($dbh, ':', $sql);
3840 $dbh->do($sql);
3841 }
3842 }
3843 };
3844 if ( !$dbh && $EVAL_ERROR ) {
3845- MKDEBUG && _d($EVAL_ERROR);
3846+ PTDEBUG && _d($EVAL_ERROR);
3847 if ( $EVAL_ERROR =~ m/not a compiled character set|character set utf8/ ) {
3848- MKDEBUG && _d('Going to try again without utf8 support');
3849+ PTDEBUG && _d('Going to try again without utf8 support');
3850 delete $defaults->{mysql_enable_utf8};
3851 }
3852 elsif ( $EVAL_ERROR =~ m/locate DBD\/mysql/i ) {
3853@@ -1157,7 +1157,7 @@
3854 }
3855 }
3856
3857- MKDEBUG && _d('DBH info: ',
3858+ PTDEBUG && _d('DBH info: ',
3859 $dbh,
3860 Dumper($dbh->selectrow_hashref(
3861 'SELECT DATABASE(), CONNECTION_ID(), VERSION()/*!50038 , @@hostname*/')),
3862@@ -1183,7 +1183,7 @@
3863
3864 sub disconnect {
3865 my ( $self, $dbh ) = @_;
3866- MKDEBUG && $self->print_active_handles($dbh);
3867+ PTDEBUG && $self->print_active_handles($dbh);
3868 $dbh->disconnect;
3869 }
3870
3871@@ -1244,7 +1244,7 @@
3872 use strict;
3873 use warnings FATAL => 'all';
3874 use English qw(-no_match_vars);
3875-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
3876+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
3877
3878 use List::Util qw(max);
3879 use Getopt::Long;
3880@@ -1328,7 +1328,7 @@
3881 my $contents = do { local $/ = undef; <$fh> };
3882 close $fh;
3883 if ( $contents =~ m/^=head1 DSN OPTIONS/m ) {
3884- MKDEBUG && _d('Parsing DSN OPTIONS');
3885+ PTDEBUG && _d('Parsing DSN OPTIONS');
3886 my $dsn_attribs = {
3887 dsn => 1,
3888 copy => 1,
3889@@ -1372,7 +1372,7 @@
3890
3891 if ( $contents =~ m/^=head1 VERSION\n\n^(.+)$/m ) {
3892 $self->{version} = $1;
3893- MKDEBUG && _d($self->{version});
3894+ PTDEBUG && _d($self->{version});
3895 }
3896
3897 return;
3898@@ -1409,7 +1409,7 @@
3899 chomp $para;
3900 $para =~ s/\s+/ /g;
3901 $para =~ s/$POD_link_re/$1/go;
3902- MKDEBUG && _d('Option rule:', $para);
3903+ PTDEBUG && _d('Option rule:', $para);
3904 push @rules, $para;
3905 }
3906
3907@@ -1418,7 +1418,7 @@
3908 do {
3909 if ( my ($option) = $para =~ m/^=item $self->{item}/ ) {
3910 chomp $para;
3911- MKDEBUG && _d($para);
3912+ PTDEBUG && _d($para);
3913 my %attribs;
3914
3915 $para = <$fh>; # read next paragraph, possibly attributes
3916@@ -1437,7 +1437,7 @@
3917 $para = <$fh>; # read next paragraph, probably short help desc
3918 }
3919 else {
3920- MKDEBUG && _d('Option has no attributes');
3921+ PTDEBUG && _d('Option has no attributes');
3922 }
3923
3924 $para =~ s/\s+\Z//g;
3925@@ -1445,7 +1445,7 @@
3926 $para =~ s/$POD_link_re/$1/go;
3927
3928 $para =~ s/\.(?:\n.*| [A-Z].*|\Z)//s;
3929- MKDEBUG && _d('Short help:', $para);
3930+ PTDEBUG && _d('Short help:', $para);
3931
3932 die "No description after option spec $option" if $para =~ m/^=item/;
3933
3934@@ -1483,7 +1483,7 @@
3935
3936 foreach my $opt ( @specs ) {
3937 if ( ref $opt ) { # It's an option spec, not a rule.
3938- MKDEBUG && _d('Parsing opt spec:',
3939+ PTDEBUG && _d('Parsing opt spec:',
3940 map { ($_, '=>', $opt->{$_}) } keys %$opt);
3941
3942 my ( $long, $short ) = $opt->{spec} =~ m/^([\w-]+)(?:\|([^!+=]*))?/;
3943@@ -1496,7 +1496,7 @@
3944 $self->{opts}->{$long} = $opt;
3945
3946 if ( length $long == 1 ) {
3947- MKDEBUG && _d('Long opt', $long, 'looks like short opt');
3948+ PTDEBUG && _d('Long opt', $long, 'looks like short opt');
3949 $self->{short_opts}->{$long} = $long;
3950 }
3951
3952@@ -1522,14 +1522,14 @@
3953
3954 my ( $type ) = $opt->{spec} =~ m/=(.)/;
3955 $opt->{type} = $type;
3956- MKDEBUG && _d($long, 'type:', $type);
3957+ PTDEBUG && _d($long, 'type:', $type);
3958
3959
3960 $opt->{spec} =~ s/=./=s/ if ( $type && $type =~ m/[HhAadzm]/ );
3961
3962 if ( (my ($def) = $opt->{desc} =~ m/default\b(?: ([^)]+))?/) ) {
3963 $self->{defaults}->{$long} = defined $def ? $def : 1;
3964- MKDEBUG && _d($long, 'default:', $def);
3965+ PTDEBUG && _d($long, 'default:', $def);
3966 }
3967
3968 if ( $long eq 'config' ) {
3969@@ -1538,13 +1538,13 @@
3970
3971 if ( (my ($dis) = $opt->{desc} =~ m/(disables .*)/) ) {
3972 $disables{$long} = $dis;
3973- MKDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
3974+ PTDEBUG && _d('Deferring check of disables rule for', $opt, $dis);
3975 }
3976
3977 $self->{opts}->{$long} = $opt;
3978 }
3979 else { # It's an option rule, not a spec.
3980- MKDEBUG && _d('Parsing rule:', $opt);
3981+ PTDEBUG && _d('Parsing rule:', $opt);
3982 push @{$self->{rules}}, $opt;
3983 my @participants = $self->_get_participants($opt);
3984 my $rule_ok = 0;
3985@@ -1552,17 +1552,17 @@
3986 if ( $opt =~ m/mutually exclusive|one and only one/ ) {
3987 $rule_ok = 1;
3988 push @{$self->{mutex}}, \@participants;
3989- MKDEBUG && _d(@participants, 'are mutually exclusive');
3990+ PTDEBUG && _d(@participants, 'are mutually exclusive');
3991 }
3992 if ( $opt =~ m/at least one|one and only one/ ) {
3993 $rule_ok = 1;
3994 push @{$self->{atleast1}}, \@participants;
3995- MKDEBUG && _d(@participants, 'require at least one');
3996+ PTDEBUG && _d(@participants, 'require at least one');
3997 }
3998 if ( $opt =~ m/default to/ ) {
3999 $rule_ok = 1;
4000 $self->{defaults_to}->{$participants[0]} = $participants[1];
4001- MKDEBUG && _d($participants[0], 'defaults to', $participants[1]);
4002+ PTDEBUG && _d($participants[0], 'defaults to', $participants[1]);
4003 }
4004 if ( $opt =~ m/restricted to option groups/ ) {
4005 $rule_ok = 1;
4006@@ -1576,7 +1576,7 @@
4007 if( $opt =~ m/accepts additional command-line arguments/ ) {
4008 $rule_ok = 1;
4009 $self->{strict} = 0;
4010- MKDEBUG && _d("Strict mode disabled by rule");
4011+ PTDEBUG && _d("Strict mode disabled by rule");
4012 }
4013
4014 die "Unrecognized option rule: $opt" unless $rule_ok;
4015@@ -1586,7 +1586,7 @@
4016 foreach my $long ( keys %disables ) {
4017 my @participants = $self->_get_participants($disables{$long});
4018 $self->{disables}->{$long} = \@participants;
4019- MKDEBUG && _d('Option', $long, 'disables', @participants);
4020+ PTDEBUG && _d('Option', $long, 'disables', @participants);
4021 }
4022
4023 return;
4024@@ -1600,7 +1600,7 @@
4025 unless exists $self->{opts}->{$long};
4026 push @participants, $long;
4027 }
4028- MKDEBUG && _d('Participants for', $str, ':', @participants);
4029+ PTDEBUG && _d('Participants for', $str, ':', @participants);
4030 return @participants;
4031 }
4032
4033@@ -1623,7 +1623,7 @@
4034 die "Cannot set default for nonexistent option $long"
4035 unless exists $self->{opts}->{$long};
4036 $self->{defaults}->{$long} = $defaults{$long};
4037- MKDEBUG && _d('Default val for', $long, ':', $defaults{$long});
4038+ PTDEBUG && _d('Default val for', $long, ':', $defaults{$long});
4039 }
4040 return;
4041 }
4042@@ -1652,7 +1652,7 @@
4043 $opt->{value} = $val;
4044 }
4045 $opt->{got} = 1;
4046- MKDEBUG && _d('Got option', $long, '=', $val);
4047+ PTDEBUG && _d('Got option', $long, '=', $val);
4048 }
4049
4050 sub get_opts {
4051@@ -1683,7 +1683,7 @@
4052 if ( $self->got('config') ) {
4053 die $EVAL_ERROR;
4054 }
4055- elsif ( MKDEBUG ) {
4056+ elsif ( PTDEBUG ) {
4057 _d($EVAL_ERROR);
4058 }
4059 }
4060@@ -1750,7 +1750,7 @@
4061 if ( exists $self->{disables}->{$long} ) {
4062 my @disable_opts = @{$self->{disables}->{$long}};
4063 map { $self->{opts}->{$_}->{value} = undef; } @disable_opts;
4064- MKDEBUG && _d('Unset options', @disable_opts,
4065+ PTDEBUG && _d('Unset options', @disable_opts,
4066 'because', $long,'disables them');
4067 }
4068
4069@@ -1799,7 +1799,7 @@
4070 delete $long[$i];
4071 }
4072 else {
4073- MKDEBUG && _d('Temporarily failed to parse', $long);
4074+ PTDEBUG && _d('Temporarily failed to parse', $long);
4075 }
4076 }
4077
4078@@ -1823,12 +1823,12 @@
4079 my $val = $opt->{value};
4080
4081 if ( $val && $opt->{type} eq 'm' ) { # type time
4082- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
4083+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a time value');
4084 my ( $prefix, $num, $suffix ) = $val =~ m/([+-]?)(\d+)([a-z])?$/;
4085 if ( !$suffix ) {
4086 my ( $s ) = $opt->{desc} =~ m/\(suffix (.)\)/;
4087 $suffix = $s || 's';
4088- MKDEBUG && _d('No suffix given; using', $suffix, 'for',
4089+ PTDEBUG && _d('No suffix given; using', $suffix, 'for',
4090 $opt->{long}, '(value:', $val, ')');
4091 }
4092 if ( $suffix =~ m/[smhd]/ ) {
4093@@ -1837,23 +1837,23 @@
4094 : $suffix eq 'h' ? $num * 3600 # Hours
4095 : $num * 86400; # Days
4096 $opt->{value} = ($prefix || '') . $val;
4097- MKDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
4098+ PTDEBUG && _d('Setting option', $opt->{long}, 'to', $val);
4099 }
4100 else {
4101 $self->save_error("Invalid time suffix for --$opt->{long}");
4102 }
4103 }
4104 elsif ( $val && $opt->{type} eq 'd' ) { # type DSN
4105- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
4106+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a DSN');
4107 my $prev = {};
4108 my $from_key = $self->{defaults_to}->{ $opt->{long} };
4109 if ( $from_key ) {
4110- MKDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
4111+ PTDEBUG && _d($opt->{long}, 'DSN copies from', $from_key, 'DSN');
4112 if ( $self->{opts}->{$from_key}->{parsed} ) {
4113 $prev = $self->{opts}->{$from_key}->{value};
4114 }
4115 else {
4116- MKDEBUG && _d('Cannot parse', $opt->{long}, 'until',
4117+ PTDEBUG && _d('Cannot parse', $opt->{long}, 'until',
4118 $from_key, 'parsed');
4119 return;
4120 }
4121@@ -1862,7 +1862,7 @@
4122 $opt->{value} = $self->{DSNParser}->parse($val, $prev, $defaults);
4123 }
4124 elsif ( $val && $opt->{type} eq 'z' ) { # type size
4125- MKDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
4126+ PTDEBUG && _d('Parsing option', $opt->{long}, 'as a size value');
4127 $self->_parse_size($opt, $val);
4128 }
4129 elsif ( $opt->{type} eq 'H' || (defined $val && $opt->{type} eq 'h') ) {
4130@@ -1872,7 +1872,7 @@
4131 $opt->{value} = [ split(/(?<!\\),\s*/, ($val || '')) ];
4132 }
4133 else {
4134- MKDEBUG && _d('Nothing to validate for option',
4135+ PTDEBUG && _d('Nothing to validate for option',
4136 $opt->{long}, 'type', $opt->{type}, 'value', $val);
4137 }
4138
4139@@ -1946,11 +1946,11 @@
4140 $file ||= $self->{file} || __FILE__;
4141
4142 if ( !$self->{description} || !$self->{usage} ) {
4143- MKDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
4144+ PTDEBUG && _d("Getting description and usage from SYNOPSIS in", $file);
4145 my %synop = $self->_parse_synopsis($file);
4146 $self->{description} ||= $synop{description};
4147 $self->{usage} ||= $synop{usage};
4148- MKDEBUG && _d("Description:", $self->{description},
4149+ PTDEBUG && _d("Description:", $self->{description},
4150 "\nUsage:", $self->{usage});
4151 }
4152
4153@@ -2165,7 +2165,7 @@
4154 my ( $self, $opt, $val ) = @_;
4155
4156 if ( lc($val || '') eq 'null' ) {
4157- MKDEBUG && _d('NULL size for', $opt->{long});
4158+ PTDEBUG && _d('NULL size for', $opt->{long});
4159 $opt->{value} = 'null';
4160 return;
4161 }
4162@@ -2175,7 +2175,7 @@
4163 if ( defined $num ) {
4164 if ( $factor ) {
4165 $num *= $factor_for{$factor};
4166- MKDEBUG && _d('Setting option', $opt->{y},
4167+ PTDEBUG && _d('Setting option', $opt->{y},
4168 'to num', $num, '* factor', $factor);
4169 }
4170 $opt->{value} = ($pre || '') . $num;
4171@@ -2199,7 +2199,7 @@
4172 sub _parse_synopsis {
4173 my ( $self, $file ) = @_;
4174 $file ||= $self->{file} || __FILE__;
4175- MKDEBUG && _d("Parsing SYNOPSIS in", $file);
4176+ PTDEBUG && _d("Parsing SYNOPSIS in", $file);
4177
4178 local $INPUT_RECORD_SEPARATOR = ''; # read paragraphs
4179 open my $fh, "<", $file or die "Cannot open $file: $OS_ERROR";
4180@@ -2212,7 +2212,7 @@
4181 push @synop, $para;
4182 }
4183 close $fh;
4184- MKDEBUG && _d("Raw SYNOPSIS text:", @synop);
4185+ PTDEBUG && _d("Raw SYNOPSIS text:", @synop);
4186 my ($usage, $desc) = @synop;
4187 die "The SYNOPSIS section in $file is not formatted properly"
4188 unless $usage && $desc;
4189@@ -2239,7 +2239,7 @@
4190 print STDERR "# $package:$line $PID ", join(' ', @_), "\n";
4191 }
4192
4193-if ( MKDEBUG ) {
4194+if ( PTDEBUG ) {
4195 print '# ', $^X, ' ', $], "\n";
4196 if ( my $uname = `uname -a` ) {
4197 $uname =~ s/\s+/ /g;
4198@@ -2269,7 +2269,7 @@
4199 use strict;
4200 use warnings FATAL => 'all';
4201 use English qw(-no_match_vars);
4202-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4203+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4204
4205 sub new {
4206 my ( $class, %args ) = @_;
4207@@ -2296,7 +2296,7 @@
4208 }
4209
4210 my $key_exists = $self->_key_exists(%args);
4211- MKDEBUG && _d('Key', $name, 'exists in', $args{tbl_name}, ':',
4212+ PTDEBUG && _d('Key', $name, 'exists in', $args{tbl_name}, ':',
4213 $key_exists ? 'yes': 'no');
4214
4215 my $sql = 'EXPLAIN SELECT ' . join(', ', @cols)
4216@@ -2312,7 +2312,7 @@
4217 }
4218 $sql .= join(' OR ', @where_cols);
4219 $self->{query} = $sql;
4220- MKDEBUG && _d('sql:', $sql);
4221+ PTDEBUG && _d('sql:', $sql);
4222
4223 my $explain;
4224 my $sth = $dbh->prepare($sql);
4225@@ -2328,7 +2328,7 @@
4226 my $key_len = $explain->{key_len};
4227 my $rows = $explain->{rows};
4228 my $chosen_key = $explain->{key}; # May differ from $name
4229- MKDEBUG && _d('MySQL chose key:', $chosen_key, 'len:', $key_len,
4230+ PTDEBUG && _d('MySQL chose key:', $chosen_key, 'len:', $key_len,
4231 'rows:', $rows);
4232
4233 my $key_size = 0;
4234@@ -2404,7 +2404,7 @@
4235 use strict;
4236 use warnings FATAL => 'all';
4237 use English qw(-no_match_vars);
4238-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4239+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4240
4241 sub new {
4242 my ( $class, %args ) = @_;
4243@@ -2431,14 +2431,14 @@
4244 if ( $key->{name} eq 'PRIMARY'
4245 || ($args{clustered_key} && $key->{name} eq $args{clustered_key}) ) {
4246 $primary_key = $key;
4247- MKDEBUG && _d('primary key:', $key->{name});
4248+ PTDEBUG && _d('primary key:', $key->{name});
4249 next KEY;
4250 }
4251
4252 my $is_fulltext = $key->{type} eq 'FULLTEXT' ? 1 : 0;
4253 if ( $args{ignore_order} || $is_fulltext ) {
4254 my $ordered_cols = join(',', sort(split(/,/, $key->{colnames})));
4255- MKDEBUG && _d('Reordered', $key->{name}, 'cols from',
4256+ PTDEBUG && _d('Reordered', $key->{name}, 'cols from',
4257 $key->{colnames}, 'to', $ordered_cols);
4258 $key->{colnames} = $ordered_cols;
4259 }
4260@@ -2453,42 +2453,42 @@
4261 push @normal_keys, $self->unconstrain_keys($primary_key, \@unique_keys);
4262
4263 if ( $primary_key ) {
4264- MKDEBUG && _d('Comparing PRIMARY KEY to UNIQUE keys');
4265+ PTDEBUG && _d('Comparing PRIMARY KEY to UNIQUE keys');
4266 push @dupes,
4267 $self->remove_prefix_duplicates([$primary_key], \@unique_keys, %args);
4268
4269- MKDEBUG && _d('Comparing PRIMARY KEY to normal keys');
4270+ PTDEBUG && _d('Comparing PRIMARY KEY to normal keys');
4271 push @dupes,
4272 $self->remove_prefix_duplicates([$primary_key], \@normal_keys, %args);
4273 }
4274
4275- MKDEBUG && _d('Comparing UNIQUE keys to normal keys');
4276+ PTDEBUG && _d('Comparing UNIQUE keys to normal keys');
4277 push @dupes,
4278 $self->remove_prefix_duplicates(\@unique_keys, \@normal_keys, %args);
4279
4280- MKDEBUG && _d('Comparing normal keys');
4281+ PTDEBUG && _d('Comparing normal keys');
4282 push @dupes,
4283 $self->remove_prefix_duplicates(\@normal_keys, \@normal_keys, %args);
4284
4285- MKDEBUG && _d('Comparing FULLTEXT keys');
4286+ PTDEBUG && _d('Comparing FULLTEXT keys');
4287 push @dupes,
4288 $self->remove_prefix_duplicates(\@fulltext_keys, \@fulltext_keys, %args, exact_duplicates => 1);
4289
4290
4291 my $clustered_key = $args{clustered_key} ? $keys{$args{clustered_key}}
4292 : undef;
4293- MKDEBUG && _d('clustered key:', $clustered_key->{name},
4294+ PTDEBUG && _d('clustered key:', $clustered_key->{name},
4295 $clustered_key->{colnames});
4296 if ( $clustered_key
4297 && $args{clustered}
4298 && $args{tbl_info}->{engine}
4299 && $args{tbl_info}->{engine} =~ m/InnoDB/i )
4300 {
4301- MKDEBUG && _d('Removing UNIQUE dupes of clustered key');
4302+ PTDEBUG && _d('Removing UNIQUE dupes of clustered key');
4303 push @dupes,
4304 $self->remove_clustered_duplicates($clustered_key, \@unique_keys, %args);
4305
4306- MKDEBUG && _d('Removing ordinary dupes of clustered key');
4307+ PTDEBUG && _d('Removing ordinary dupes of clustered key');
4308 push @dupes,
4309 $self->remove_clustered_duplicates($clustered_key, \@normal_keys, %args);
4310 }
4311@@ -2588,25 +2588,25 @@
4312 my $right_cols = $right_keys->[$right_index]->{colnames};
4313 my $right_len_cols = $right_keys->[$right_index]->{len_cols};
4314
4315- MKDEBUG && _d('Comparing left', $left_name, '(',$left_cols,')',
4316+ PTDEBUG && _d('Comparing left', $left_name, '(',$left_cols,')',
4317 'to right', $right_name, '(',$right_cols,')');
4318
4319 if ( substr($left_cols, 0, $right_len_cols)
4320 eq substr($right_cols, 0, $right_len_cols) ) {
4321
4322 if ( $args{exact_duplicates} && ($right_len_cols<$left_len_cols) ) {
4323- MKDEBUG && _d($right_name, 'not exact duplicate of', $left_name);
4324+ PTDEBUG && _d($right_name, 'not exact duplicate of', $left_name);
4325 next RIGHT_KEY;
4326 }
4327
4328 if ( exists $right_keys->[$right_index]->{unique_col} ) {
4329- MKDEBUG && _d('Cannot remove', $right_name,
4330+ PTDEBUG && _d('Cannot remove', $right_name,
4331 'because is constrains col',
4332 $right_keys->[$right_index]->{cols}->[0]);
4333 next RIGHT_KEY;
4334 }
4335
4336- MKDEBUG && _d('Remove', $right_name);
4337+ PTDEBUG && _d('Remove', $right_name);
4338 my $reason;
4339 if ( $right_keys->[$right_index]->{unconstrained} ) {
4340 $reason .= "Uniqueness of $right_name ignored because "
4341@@ -2634,12 +2634,12 @@
4342 $args{callback}->($dupe, %args) if $args{callback};
4343 }
4344 else {
4345- MKDEBUG && _d($right_name, 'not left-prefix of', $left_name);
4346+ PTDEBUG && _d($right_name, 'not left-prefix of', $left_name);
4347 next LEFT_KEY;
4348 }
4349 } # RIGHT_KEY
4350 } # LEFT_KEY
4351- MKDEBUG && _d('No more keys');
4352+ PTDEBUG && _d('No more keys');
4353
4354 @$left_keys = grep { defined $_; } @$left_keys;
4355 @$right_keys = grep { defined $_; } @$right_keys;
4356@@ -2658,7 +2658,7 @@
4357 for my $i ( 0 .. @$keys - 1 ) {
4358 my $key = $keys->[$i]->{colnames};
4359 if ( $key =~ m/$ck_cols$/ ) {
4360- MKDEBUG && _d("clustered key dupe:", $keys->[$i]->{name},
4361+ PTDEBUG && _d("clustered key dupe:", $keys->[$i]->{name},
4362 $keys->[$i]->{colnames});
4363 my $dupe = {
4364 key => $keys->[$i]->{name},
4365@@ -2681,7 +2681,7 @@
4366 $args{callback}->($dupe, %args) if $args{callback};
4367 }
4368 }
4369- MKDEBUG && _d('No more keys');
4370+ PTDEBUG && _d('No more keys');
4371
4372 @$keys = grep { defined $_; } @$keys;
4373
4374@@ -2704,14 +2704,14 @@
4375 my %unconstrain;
4376 my @unconstrained_keys;
4377
4378- MKDEBUG && _d('Unconstraining redundantly unique keys');
4379+ PTDEBUG && _d('Unconstraining redundantly unique keys');
4380
4381 UNIQUE_KEY:
4382 foreach my $unique_key ( $primary_key, @$unique_keys ) {
4383 next unless $unique_key; # primary key may be undefined
4384 my $cols = $unique_key->{cols};
4385 if ( @$cols == 1 ) {
4386- MKDEBUG && _d($unique_key->{name},'defines unique column:',$cols->[0]);
4387+ PTDEBUG && _d($unique_key->{name},'defines unique column:',$cols->[0]);
4388 if ( !exists $unique_cols{$cols->[0]} ) {
4389 $unique_cols{$cols->[0]} = $unique_key;
4390 $unique_key->{unique_col} = 1;
4391@@ -2719,7 +2719,7 @@
4392 }
4393 else {
4394 local $LIST_SEPARATOR = '-';
4395- MKDEBUG && _d($unique_key->{name}, 'defines unique set:', @$cols);
4396+ PTDEBUG && _d($unique_key->{name}, 'defines unique set:', @$cols);
4397 push @unique_sets, { cols => $cols, key => $unique_key };
4398 }
4399 }
4400@@ -2730,14 +2730,14 @@
4401 COL:
4402 foreach my $col ( @{$unique_set->{cols}} ) {
4403 if ( exists $unique_cols{$col} ) {
4404- MKDEBUG && _d('Unique set', $unique_set->{key}->{name},
4405+ PTDEBUG && _d('Unique set', $unique_set->{key}->{name},
4406 'has unique col', $col);
4407 last COL if ++$n_unique_cols > 1;
4408 $unique_set->{constraining_key} = $unique_cols{$col};
4409 }
4410 }
4411 if ( $n_unique_cols && $unique_set->{key}->{name} ne 'PRIMARY' ) {
4412- MKDEBUG && _d('Will unconstrain unique set',
4413+ PTDEBUG && _d('Will unconstrain unique set',
4414 $unique_set->{key}->{name},
4415 'because it is redundantly constrained by key',
4416 $unique_set->{constraining_key}->{name},
4417@@ -2749,7 +2749,7 @@
4418
4419 for my $i ( 0..(scalar @$unique_keys-1) ) {
4420 if ( exists $unconstrain{$unique_keys->[$i]->{name}} ) {
4421- MKDEBUG && _d('Unconstraining', $unique_keys->[$i]->{name});
4422+ PTDEBUG && _d('Unconstraining', $unique_keys->[$i]->{name});
4423 $unique_keys->[$i]->{unconstrained} = 1;
4424 $unique_keys->[$i]->{constraining_key}
4425 = $unconstrain{$unique_keys->[$i]->{name}};
4426@@ -2758,7 +2758,7 @@
4427 }
4428 }
4429
4430- MKDEBUG && _d('No more keys');
4431+ PTDEBUG && _d('No more keys');
4432 return @unconstrained_keys;
4433 }
4434
4435@@ -2790,7 +2790,7 @@
4436 use strict;
4437 use warnings FATAL => 'all';
4438 use English qw(-no_match_vars);
4439-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4440+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4441
4442 use POSIX qw(setsid);
4443
4444@@ -2808,17 +2808,17 @@
4445
4446 check_PID_file(undef, $self->{PID_file});
4447
4448- MKDEBUG && _d('Daemonized child will log to', $self->{log_file});
4449+ PTDEBUG && _d('Daemonized child will log to', $self->{log_file});
4450 return bless $self, $class;
4451 }
4452
4453 sub daemonize {
4454 my ( $self ) = @_;
4455
4456- MKDEBUG && _d('About to fork and daemonize');
4457+ PTDEBUG && _d('About to fork and daemonize');
4458 defined (my $pid = fork()) or die "Cannot fork: $OS_ERROR";
4459 if ( $pid ) {
4460- MKDEBUG && _d('I am the parent and now I die');
4461+ PTDEBUG && _d('I am the parent and now I die');
4462 exit;
4463 }
4464
4465@@ -2860,19 +2860,19 @@
4466 }
4467 }
4468
4469- MKDEBUG && _d('I am the child and now I live daemonized');
4470+ PTDEBUG && _d('I am the child and now I live daemonized');
4471 return;
4472 }
4473
4474 sub check_PID_file {
4475 my ( $self, $file ) = @_;
4476 my $PID_file = $self ? $self->{PID_file} : $file;
4477- MKDEBUG && _d('Checking PID file', $PID_file);
4478+ PTDEBUG && _d('Checking PID file', $PID_file);
4479 if ( $PID_file && -f $PID_file ) {
4480 my $pid;
4481 eval { chomp($pid = `cat $PID_file`); };
4482 die "Cannot cat $PID_file: $OS_ERROR" if $EVAL_ERROR;
4483- MKDEBUG && _d('PID file exists; it contains PID', $pid);
4484+ PTDEBUG && _d('PID file exists; it contains PID', $pid);
4485 if ( $pid ) {
4486 my $pid_is_alive = kill 0, $pid;
4487 if ( $pid_is_alive ) {
4488@@ -2890,7 +2890,7 @@
4489 }
4490 }
4491 else {
4492- MKDEBUG && _d('No PID file');
4493+ PTDEBUG && _d('No PID file');
4494 }
4495 return;
4496 }
4497@@ -2910,7 +2910,7 @@
4498
4499 my $PID_file = $self->{PID_file};
4500 if ( !$PID_file ) {
4501- MKDEBUG && _d('No PID file to create');
4502+ PTDEBUG && _d('No PID file to create');
4503 return;
4504 }
4505
4506@@ -2923,7 +2923,7 @@
4507 close $PID_FH
4508 or die "Cannot close PID file $PID_file: $OS_ERROR";
4509
4510- MKDEBUG && _d('Created PID file:', $self->{PID_file});
4511+ PTDEBUG && _d('Created PID file:', $self->{PID_file});
4512 return;
4513 }
4514
4515@@ -2932,10 +2932,10 @@
4516 if ( $self->{PID_file} && -f $self->{PID_file} ) {
4517 unlink $self->{PID_file}
4518 or warn "Cannot remove PID file $self->{PID_file}: $OS_ERROR";
4519- MKDEBUG && _d('Removed PID file');
4520+ PTDEBUG && _d('Removed PID file');
4521 }
4522 else {
4523- MKDEBUG && _d('No PID to remove');
4524+ PTDEBUG && _d('No PID to remove');
4525 }
4526 return;
4527 }
4528@@ -2976,7 +2976,7 @@
4529 use strict;
4530 use warnings FATAL => 'all';
4531 use English qw(-no_match_vars);
4532-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4533+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4534
4535 sub new {
4536 my ( $class, %args ) = @_;
4537@@ -3038,7 +3038,7 @@
4538 my ($col, $tbl, $db);
4539 if ( my $col_name = $args{col_name} ) {
4540 ($col, $tbl, $db) = reverse map { s/`//g; $_ } split /[.]/, $col_name;
4541- MKDEBUG && _d('Column', $col_name, 'has db', $db, 'tbl', $tbl,
4542+ PTDEBUG && _d('Column', $col_name, 'has db', $db, 'tbl', $tbl,
4543 'col', $col);
4544 }
4545 else {
4546@@ -3050,18 +3050,18 @@
4547 $col = lc $col;
4548
4549 if ( !$col ) {
4550- MKDEBUG && _d('No column specified or parsed');
4551+ PTDEBUG && _d('No column specified or parsed');
4552 return;
4553 }
4554- MKDEBUG && _d('Finding column', $col, 'in', $db, $tbl);
4555+ PTDEBUG && _d('Finding column', $col, 'in', $db, $tbl);
4556
4557 if ( $db && !$schema->{$db} ) {
4558- MKDEBUG && _d('Database', $db, 'does not exist');
4559+ PTDEBUG && _d('Database', $db, 'does not exist');
4560 return;
4561 }
4562
4563 if ( $db && $tbl && !$schema->{$db}->{$tbl} ) {
4564- MKDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
4565+ PTDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
4566 return;
4567 }
4568
4569@@ -3078,13 +3078,13 @@
4570 if ( $ignore
4571 && grep { $_->{db} eq $search_db && $_->{tbl} eq $search_tbl }
4572 @$ignore ) {
4573- MKDEBUG && _d('Ignoring', $search_db, $search_tbl, $col);
4574+ PTDEBUG && _d('Ignoring', $search_db, $search_tbl, $col);
4575 next TABLE;
4576 }
4577
4578 my $tbl = $schema->{$search_db}->{$search_tbl};
4579 if ( $tbl->{tbl_struct}->{is_col}->{$col} ) {
4580- MKDEBUG && _d('Column', $col, 'exists in', $tbl->{db}, $tbl->{tbl});
4581+ PTDEBUG && _d('Column', $col, 'exists in', $tbl->{db}, $tbl->{tbl});
4582 push @tbls, $tbl;
4583 }
4584 }
4585@@ -3101,7 +3101,7 @@
4586 my ($tbl, $db);
4587 if ( my $tbl_name = $args{tbl_name} ) {
4588 ($tbl, $db) = reverse map { s/`//g; $_ } split /[.]/, $tbl_name;
4589- MKDEBUG && _d('Table', $tbl_name, 'has db', $db, 'tbl', $tbl);
4590+ PTDEBUG && _d('Table', $tbl_name, 'has db', $db, 'tbl', $tbl);
4591 }
4592 else {
4593 ($tbl, $db) = @args{qw(tbl db)};
4594@@ -3111,18 +3111,18 @@
4595 $tbl = lc $tbl;
4596
4597 if ( !$tbl ) {
4598- MKDEBUG && _d('No table specified or parsed');
4599+ PTDEBUG && _d('No table specified or parsed');
4600 return;
4601 }
4602- MKDEBUG && _d('Finding table', $tbl, 'in', $db);
4603+ PTDEBUG && _d('Finding table', $tbl, 'in', $db);
4604
4605 if ( $db && !$schema->{$db} ) {
4606- MKDEBUG && _d('Database', $db, 'does not exist');
4607+ PTDEBUG && _d('Database', $db, 'does not exist');
4608 return;
4609 }
4610
4611 if ( $db && $tbl && !$schema->{$db}->{$tbl} ) {
4612- MKDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
4613+ PTDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
4614 return;
4615 }
4616
4617@@ -3131,12 +3131,12 @@
4618 DATABASE:
4619 foreach my $search_db ( @search_dbs ) {
4620 if ( $ignore && grep { $_->{db} eq $search_db } @$ignore ) {
4621- MKDEBUG && _d('Ignoring', $search_db);
4622+ PTDEBUG && _d('Ignoring', $search_db);
4623 next DATABASE;
4624 }
4625
4626 if ( exists $schema->{$search_db}->{$tbl} ) {
4627- MKDEBUG && _d('Table', $tbl, 'exists in', $search_db);
4628+ PTDEBUG && _d('Table', $tbl, 'exists in', $search_db);
4629 push @dbs, $search_db;
4630 }
4631 }
4632@@ -3172,7 +3172,7 @@
4633 use strict;
4634 use warnings FATAL => 'all';
4635 use English qw(-no_match_vars);
4636-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4637+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4638
4639 use Data::Dumper;
4640 $Data::Dumper::Indent = 1;
4641@@ -3234,11 +3234,11 @@
4642 if ( $is_table ) {
4643 my ($db, $tbl) = $q->split_unquote($obj);
4644 $db ||= '*';
4645- MKDEBUG && _d('Filter', $filter, 'value:', $db, $tbl);
4646+ PTDEBUG && _d('Filter', $filter, 'value:', $db, $tbl);
4647 $filters{$filter}->{$tbl} = $db;
4648 }
4649 else { # database
4650- MKDEBUG && _d('Filter', $filter, 'value:', $obj);
4651+ PTDEBUG && _d('Filter', $filter, 'value:', $obj);
4652 $filters{$filter}->{$obj} = 1;
4653 }
4654 }
4655@@ -3254,11 +3254,11 @@
4656 my $pat = $o->get($filter);
4657 next REGEX_FILTER unless $pat;
4658 $filters{$filter} = qr/$pat/;
4659- MKDEBUG && _d('Filter', $filter, 'value:', $filters{$filter});
4660+ PTDEBUG && _d('Filter', $filter, 'value:', $filters{$filter});
4661 }
4662 }
4663
4664- MKDEBUG && _d('Schema object filters:', Dumper(\%filters));
4665+ PTDEBUG && _d('Schema object filters:', Dumper(\%filters));
4666 return \%filters;
4667 }
4668
4669@@ -3286,7 +3286,7 @@
4670 }
4671 }
4672
4673- MKDEBUG && _d('Next schema object:', $schema_obj->{db}, $schema_obj->{tbl});
4674+ PTDEBUG && _d('Next schema object:', $schema_obj->{db}, $schema_obj->{tbl});
4675 return $schema_obj;
4676 }
4677
4678@@ -3296,14 +3296,14 @@
4679 if ( !$self->{fh} ) {
4680 my ($fh, $file) = $self->{file_itr}->();
4681 if ( !$fh ) {
4682- MKDEBUG && _d('No more files to iterate');
4683+ PTDEBUG && _d('No more files to iterate');
4684 return;
4685 }
4686 $self->{fh} = $fh;
4687 $self->{file} = $file;
4688 }
4689 my $fh = $self->{fh};
4690- MKDEBUG && _d('Getting next schema object from', $self->{file});
4691+ PTDEBUG && _d('Getting next schema object from', $self->{file});
4692
4693 local $INPUT_RECORD_SEPARATOR = '';
4694 CHUNK:
4695@@ -3318,7 +3318,7 @@
4696 }
4697 elsif ($self->{db} && $chunk =~ m/CREATE TABLE/) {
4698 if ($chunk =~ m/DROP VIEW IF EXISTS/) {
4699- MKDEBUG && _d('Table is a VIEW, skipping');
4700+ PTDEBUG && _d('Table is a VIEW, skipping');
4701 next CHUNK;
4702 }
4703
4704@@ -3346,7 +3346,7 @@
4705 }
4706 } # CHUNK
4707
4708- MKDEBUG && _d('No more schema objects in', $self->{file});
4709+ PTDEBUG && _d('No more schema objects in', $self->{file});
4710 close $self->{fh};
4711 $self->{fh} = undef;
4712
4713@@ -3357,26 +3357,26 @@
4714 my ( $self ) = @_;
4715 my $q = $self->{Quoter};
4716 my $dbh = $self->{dbh};
4717- MKDEBUG && _d('Getting next schema object from dbh', $dbh);
4718+ PTDEBUG && _d('Getting next schema object from dbh', $dbh);
4719
4720 if ( !defined $self->{dbs} ) {
4721 my $sql = 'SHOW DATABASES';
4722- MKDEBUG && _d($sql);
4723+ PTDEBUG && _d($sql);
4724 my @dbs = grep { $self->database_is_allowed($_) }
4725 @{$dbh->selectcol_arrayref($sql)};
4726- MKDEBUG && _d('Found', scalar @dbs, 'databases');
4727+ PTDEBUG && _d('Found', scalar @dbs, 'databases');
4728 $self->{dbs} = \@dbs;
4729 }
4730
4731 if ( !$self->{db} ) {
4732 $self->{db} = shift @{$self->{dbs}};
4733- MKDEBUG && _d('Next database:', $self->{db});
4734+ PTDEBUG && _d('Next database:', $self->{db});
4735 return unless $self->{db};
4736 }
4737
4738 if ( !defined $self->{tbls} ) {
4739 my $sql = 'SHOW /*!50002 FULL*/ TABLES FROM ' . $q->quote($self->{db});
4740- MKDEBUG && _d($sql);
4741+ PTDEBUG && _d($sql);
4742 my @tbls = map {
4743 $_->[0]; # (tbl, type)
4744 }
4745@@ -3386,7 +3386,7 @@
4746 && (!$type || ($type ne 'VIEW'));
4747 }
4748 @{$dbh->selectall_arrayref($sql)};
4749- MKDEBUG && _d('Found', scalar @tbls, 'tables in database', $self->{db});
4750+ PTDEBUG && _d('Found', scalar @tbls, 'tables in database', $self->{db});
4751 $self->{tbls} = \@tbls;
4752 }
4753
4754@@ -3396,9 +3396,9 @@
4755 || $self->{filters}->{'ignore-engines'} ) {
4756 my $sql = "SHOW TABLE STATUS FROM " . $q->quote($self->{db})
4757 . " LIKE \'$tbl\'";
4758- MKDEBUG && _d($sql);
4759+ PTDEBUG && _d($sql);
4760 $engine = $dbh->selectrow_hashref($sql)->{engine};
4761- MKDEBUG && _d($tbl, 'uses', $engine, 'engine');
4762+ PTDEBUG && _d($tbl, 'uses', $engine, 'engine');
4763 }
4764
4765
4766@@ -3416,7 +3416,7 @@
4767 }
4768 }
4769
4770- MKDEBUG && _d('No more tables in database', $self->{db});
4771+ PTDEBUG && _d('No more tables in database', $self->{db});
4772 $self->{db} = undef;
4773 $self->{tbls} = undef;
4774
4775@@ -3432,30 +3432,30 @@
4776 my $filter = $self->{filters};
4777
4778 if ( $db =~ m/information_schema|performance_schema|lost\+found/ ) {
4779- MKDEBUG && _d('Database', $db, 'is a system database, ignoring');
4780+ PTDEBUG && _d('Database', $db, 'is a system database, ignoring');
4781 return 0;
4782 }
4783
4784 if ( $self->{filters}->{'ignore-databases'}->{$db} ) {
4785- MKDEBUG && _d('Database', $db, 'is in --ignore-databases list');
4786+ PTDEBUG && _d('Database', $db, 'is in --ignore-databases list');
4787 return 0;
4788 }
4789
4790 if ( $filter->{'ignore-databases-regex'}
4791 && $db =~ $filter->{'ignore-databases-regex'} ) {
4792- MKDEBUG && _d('Database', $db, 'matches --ignore-databases-regex');
4793+ PTDEBUG && _d('Database', $db, 'matches --ignore-databases-regex');
4794 return 0;
4795 }
4796
4797 if ( $filter->{'databases'}
4798 && !$filter->{'databases'}->{$db} ) {
4799- MKDEBUG && _d('Database', $db, 'is not in --databases list, ignoring');
4800+ PTDEBUG && _d('Database', $db, 'is not in --databases list, ignoring');
4801 return 0;
4802 }
4803
4804 if ( $filter->{'databases-regex'}
4805 && $db !~ $filter->{'databases-regex'} ) {
4806- MKDEBUG && _d('Database', $db, 'does not match --databases-regex, ignoring');
4807+ PTDEBUG && _d('Database', $db, 'does not match --databases-regex, ignoring');
4808 return 0;
4809 }
4810
4811@@ -3475,25 +3475,25 @@
4812 if ( $filter->{'ignore-tables'}->{$tbl}
4813 && ($filter->{'ignore-tables'}->{$tbl} eq '*'
4814 || $filter->{'ignore-tables'}->{$tbl} eq $db) ) {
4815- MKDEBUG && _d('Table', $tbl, 'is in --ignore-tables list');
4816+ PTDEBUG && _d('Table', $tbl, 'is in --ignore-tables list');
4817 return 0;
4818 }
4819
4820 if ( $filter->{'ignore-tables-regex'}
4821 && $tbl =~ $filter->{'ignore-tables-regex'} ) {
4822- MKDEBUG && _d('Table', $tbl, 'matches --ignore-tables-regex');
4823+ PTDEBUG && _d('Table', $tbl, 'matches --ignore-tables-regex');
4824 return 0;
4825 }
4826
4827 if ( $filter->{'tables'}
4828 && !$filter->{'tables'}->{$tbl} ) {
4829- MKDEBUG && _d('Table', $tbl, 'is not in --tables list, ignoring');
4830+ PTDEBUG && _d('Table', $tbl, 'is not in --tables list, ignoring');
4831 return 0;
4832 }
4833
4834 if ( $filter->{'tables-regex'}
4835 && $tbl !~ $filter->{'tables-regex'} ) {
4836- MKDEBUG && _d('Table', $tbl, 'does not match --tables-regex, ignoring');
4837+ PTDEBUG && _d('Table', $tbl, 'does not match --tables-regex, ignoring');
4838 return 0;
4839 }
4840
4841@@ -3501,7 +3501,7 @@
4842 && $filter->{'tables'}->{$tbl}
4843 && $filter->{'tables'}->{$tbl} ne '*'
4844 && $filter->{'tables'}->{$tbl} ne $db ) {
4845- MKDEBUG && _d('Table', $tbl, 'is only allowed in database',
4846+ PTDEBUG && _d('Table', $tbl, 'is only allowed in database',
4847 $filter->{'tables'}->{$tbl});
4848 return 0;
4849 }
4850@@ -3518,13 +3518,13 @@
4851 my $filter = $self->{filters};
4852
4853 if ( $filter->{'ignore-engines'}->{$engine} ) {
4854- MKDEBUG && _d('Engine', $engine, 'is in --ignore-databases list');
4855+ PTDEBUG && _d('Engine', $engine, 'is in --ignore-databases list');
4856 return 0;
4857 }
4858
4859 if ( $filter->{'engines'}
4860 && !$filter->{'engines'}->{$engine} ) {
4861- MKDEBUG && _d('Engine', $engine, 'is not in --engines list, ignoring');
4862+ PTDEBUG && _d('Engine', $engine, 'is not in --engines list, ignoring');
4863 return 0;
4864 }
4865
4866@@ -3558,7 +3558,7 @@
4867 use strict;
4868 use warnings FATAL => 'all';
4869 use English qw(-no_match_vars);
4870-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4871+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4872
4873 use List::Util qw(max);
4874
4875@@ -3662,7 +3662,7 @@
4876 print_all_keys($fks, $tbl, \%seen_tbl) if $fks;
4877 }
4878 else {
4879- MKDEBUG && _d('Getting duplicate keys on', $tbl->{db}, $tbl->{tbl});
4880+ PTDEBUG && _d('Getting duplicate keys on', $tbl->{db}, $tbl->{tbl});
4881 eval {
4882 if ( $keys ) {
4883 $dk->get_duplicate_keys(
4884@@ -3746,7 +3746,7 @@
4885 foreach my $arg ( qw(tbl_info dbh is_fk o ks q tp seen_tbl) ) {
4886 die "I need a $arg argument" unless exists $args{$arg};
4887 }
4888- MKDEBUG && _d('Printing duplicate key', $dupe->{key});
4889+ PTDEBUG && _d('Printing duplicate key', $dupe->{key});
4890 my $db = $args{tbl_info}->{db};
4891 my $tbl = $args{tbl_info}->{tbl};
4892 my $dbh = $args{dbh};
4893@@ -3776,7 +3776,7 @@
4894 my %seen; # print each column only once
4895 foreach my $col ( @{$dupe->{cols}}, @{$dupe->{duplicate_of_cols}} ) {
4896 next if $seen{$col}++;
4897- MKDEBUG && _d('col', $col);
4898+ PTDEBUG && _d('col', $col);
4899 print "#\t" . lc($struct->{defs}->{lc $col}) . "\n";
4900 }
4901
4902@@ -4270,6 +4270,6 @@
4903
4904 =head1 VERSION
4905
4906-pt-duplicate-key-checker 1.0.1
4907+pt-duplicate-key-checker 1.0.2
4908
4909 =cut
4910
4911=== modified file 'bin/pt-fifo-split'
4912--- bin/pt-fifo-split 2011-09-01 16:00:38 +0000
4913+++ bin/pt-fifo-split 2011-12-29 16:12:24 +0000
4914@@ -6,7 +6,7 @@
4915
4916 use strict;
4917 use warnings FATAL => 'all';
4918-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4919+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4920
4921 # ###########################################################################
4922 # OptionParser package
4923@@ -22,7 +22,7 @@
4924 use strict;
4925 use warnings FATAL => 'all';
4926 use English qw(-no_match_vars);
4927-use constant MKDEBUG => $ENV{MKDEBUG} || 0;
4928+use constant PTDEBUG => $ENV{PTDEBUG} || 0;
4929
4930 use List::Util qw(max);
4931 use Getopt::Long;
4932@@ -106,7 +106,7 @@
4933 my $contents = do { local $/ = undef; <$fh> };
4934 close $fh;
4935 if ( $contents =~ m/^=head1 DSN OPTIONS/m ) {
4936- MKDEBUG && _d('Parsing DSN OPTIONS');
4937+ PTDEBUG && _d('Parsing DSN OPTIONS');
4938 my $dsn_attribs = {
4939 dsn => 1,
4940 copy => 1,
4941@@ -150,7 +150,7 @@
4942
4943 if ( $contents =~ m/^=head1 VERSION\n\n^(.+)$/m ) {
4944 $self->{version} = $1;
4945- MKDEBUG && _d($self->{version});
4946+ PTDEBUG && _d($self->{version});
4947 }
4948
4949 return;
4950@@ -187,7 +187,7 @@
4951 chomp $para;
4952 $para =~ s/\s+/ /g;
4953 $para =~ s/$POD_link_re/$1/go;
4954- MKDEBUG && _d('Option rule:', $para);
4955+ PTDEBUG && _d('Option rule:', $para);
4956 push @rules, $para;
4957 }
4958
4959@@ -196,7 +196,7 @@
4960 do {
4961 if ( my ($option) = $para =~ m/^=item $self->{item}/ ) {
4962 chomp $para;
4963- MKDEBUG && _d($para);
4964+ PTDEBUG && _d($para);
4965 my %attribs;
4966
4967 $para = <$fh>; # read next paragraph, possibly attributes
4968@@ -215,7 +215,7 @@
4969 $para = <$fh>; # read next paragraph, probably short help desc
4970 }
4971 else {
4972- MKDEBUG && _d('Option has no attributes');
4973+ PTDEBUG && _d('Option has no attributes');
4974 }
4975
4976 $para =~ s/\s+\Z//g;
4977@@ -223,7 +223,7 @@
4978 $para =~ s/$POD_link_re/$1/go;
4979
4980 $para =~ s/\.(?:\n.*| [A-Z].*|\Z)//s;
4981- MKDEBUG && _d('Short help:', $para);
4982+ PTDEBUG && _d('Short help:', $para);
4983
4984 die "No description after option spec $option" if $para =~ m/^=item/;
4985
4986@@ -261,7 +261,7 @@
4987
4988 foreach my $opt ( @specs ) {
4989 if ( ref $opt ) { # It's an option spec, not a rule.
4990- MKDEBUG && _d('Parsing opt spec:',
4991+ PTDEBUG && _d('Parsing opt spec:',
4992 map { ($_, '=>', $opt->{$_}) } keys %$opt);
4993
4994 my ( $long, $short ) = $opt->{spec} =~ m/^([\w-]+)(?:\|([^!+=]*))?/;
4995@@ -274,7 +274,7 @@
4996 $self->{opts}->{$long} = $opt;
4997
4998 if ( length $long == 1 ) {
4999- MKDEBUG && _d('Long opt', $long, 'looks like short opt');
5000+ PTDEBUG && _d('Long opt', $long, 'looks like short opt');
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches