| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | use lib 'lib'; | ||
| 4 | use t::Util; | ||
| 5 | use File::Spec; | ||
| 6 | use Test::mysqld; | ||
| 7 | |||
| 8 | use DBIx::QueryLog (); | ||
| 9 | |||
| 10 | local $SIG{INT} = sub { exit 1 }; | ||
| 11 | |||
| 12 | my $mysqld = t::Util->setup_mysqld; | ||
| 13 | my $dbh = DBI->connect( | ||
| 14 | $mysqld->dsn(dbname => 'mysql'), '', '', | ||
| 15 | { | ||
| 16 | AutoCommit => 1, | ||
| 17 | RaiseError => 1, | ||
| 18 | }, | ||
| 19 | ) or die $DBI::errstr; | ||
| 20 | |||
| 21 | local *STDERR; | ||
| 22 | open STDERR, '>', File::Spec->devnull or die $!; | ||
| 23 | |||
| 24 | DBIx::QueryLog->skip_bind(1); | ||
| 25 | |||
| 26 | my $enabled; | ||
| 27 | my $disabled; | ||
| 28 | cmpthese 5000, { | ||
| 29 | original => sub { | ||
| 30 | DBIx::QueryLog->unimport unless $disabled++; | ||
| 31 | $dbh->do('SELECT * FROM user WHERE User = ?', undef, 'root'); | ||
| 32 | }, | ||
| 33 | logging => sub { | ||
| 34 | DBIx::QueryLog->import unless $enabled++; | ||
| 35 | $dbh->do('SELECT * FROM user WHERE User = ?', undef, 'root'); | ||
| 36 | }, | ||
| 37 | }; |