~percona-toolkit-dev/percona-toolkit/fix-zombie-bug-919819

« back to all changes in this revision

Viewing changes to lib/Schema.pm

  • Committer: Daniel Nichter
  • Date: 2012-01-19 19:46:56 UTC
  • Revision ID: daniel@percona.com-20120119194656-3l1nzgtq1p7xvigo
Replace MKDEBUG with PTDEBUG in modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
use strict;
55
55
use warnings FATAL => 'all';
56
56
use English qw(-no_match_vars);
57
 
use constant MKDEBUG => $ENV{MKDEBUG} || 0;
 
57
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
58
58
 
59
59
# Sub: new
60
60
#
145
145
   my ($col, $tbl, $db);
146
146
   if ( my $col_name = $args{col_name} ) {
147
147
      ($col, $tbl, $db) = reverse map { s/`//g; $_ } split /[.]/, $col_name;
148
 
      MKDEBUG && _d('Column', $col_name, 'has db', $db, 'tbl', $tbl,
 
148
      PTDEBUG && _d('Column', $col_name, 'has db', $db, 'tbl', $tbl,
149
149
         'col', $col);
150
150
   }
151
151
   else {
157
157
   $col = lc $col;
158
158
 
159
159
   if ( !$col ) {
160
 
      MKDEBUG && _d('No column specified or parsed');
 
160
      PTDEBUG && _d('No column specified or parsed');
161
161
      return;
162
162
   }
163
 
   MKDEBUG && _d('Finding column', $col, 'in', $db, $tbl);
 
163
   PTDEBUG && _d('Finding column', $col, 'in', $db, $tbl);
164
164
 
165
165
   if ( $db && !$schema->{$db} ) {
166
 
      MKDEBUG && _d('Database', $db, 'does not exist');
 
166
      PTDEBUG && _d('Database', $db, 'does not exist');
167
167
      return;
168
168
   }
169
169
 
170
170
   if ( $db && $tbl && !$schema->{$db}->{$tbl} ) {
171
 
      MKDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
 
171
      PTDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
172
172
      return;
173
173
   }
174
174
 
185
185
         if ( $ignore
186
186
              && grep { $_->{db} eq $search_db && $_->{tbl} eq $search_tbl }
187
187
                 @$ignore ) {
188
 
            MKDEBUG && _d('Ignoring', $search_db, $search_tbl, $col);
 
188
            PTDEBUG && _d('Ignoring', $search_db, $search_tbl, $col);
189
189
            next TABLE;
190
190
         }
191
191
 
192
192
         my $tbl = $schema->{$search_db}->{$search_tbl};
193
193
         if ( $tbl->{tbl_struct}->{is_col}->{$col} ) {
194
 
            MKDEBUG && _d('Column', $col, 'exists in', $tbl->{db}, $tbl->{tbl});
 
194
            PTDEBUG && _d('Column', $col, 'exists in', $tbl->{db}, $tbl->{tbl});
195
195
            push @tbls, $tbl;
196
196
         }
197
197
      }
208
208
   my ($tbl, $db);
209
209
   if ( my $tbl_name = $args{tbl_name} ) {
210
210
      ($tbl, $db) = reverse map { s/`//g; $_ } split /[.]/, $tbl_name;
211
 
      MKDEBUG && _d('Table', $tbl_name, 'has db', $db, 'tbl', $tbl);
 
211
      PTDEBUG && _d('Table', $tbl_name, 'has db', $db, 'tbl', $tbl);
212
212
   }
213
213
   else {
214
214
      ($tbl, $db) = @args{qw(tbl db)};
218
218
   $tbl = lc $tbl;
219
219
 
220
220
   if ( !$tbl ) {
221
 
      MKDEBUG && _d('No table specified or parsed');
 
221
      PTDEBUG && _d('No table specified or parsed');
222
222
      return;
223
223
   }
224
 
   MKDEBUG && _d('Finding table', $tbl, 'in', $db);
 
224
   PTDEBUG && _d('Finding table', $tbl, 'in', $db);
225
225
 
226
226
   if ( $db && !$schema->{$db} ) {
227
 
      MKDEBUG && _d('Database', $db, 'does not exist');
 
227
      PTDEBUG && _d('Database', $db, 'does not exist');
228
228
      return;
229
229
   }
230
230
 
231
231
   if ( $db && $tbl && !$schema->{$db}->{$tbl} ) {
232
 
      MKDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
 
232
      PTDEBUG && _d('Table', $tbl, 'does not exist in database', $db);
233
233
      return;
234
234
   }
235
235
 
238
238
   DATABASE:
239
239
   foreach my $search_db ( @search_dbs ) {
240
240
      if ( $ignore && grep { $_->{db} eq $search_db } @$ignore ) {
241
 
         MKDEBUG && _d('Ignoring', $search_db);
 
241
         PTDEBUG && _d('Ignoring', $search_db);
242
242
         next DATABASE;
243
243
      }
244
244
 
245
245
      if ( exists $schema->{$search_db}->{$tbl} ) {
246
 
         MKDEBUG && _d('Table', $tbl, 'exists in', $search_db);
 
246
         PTDEBUG && _d('Table', $tbl, 'exists in', $search_db);
247
247
         push @dbs, $search_db;
248
248
      }
249
249
   }