diff --git a/SQLite.xs b/SQLite.xs index ec145a9..decffa7 100644 --- a/SQLite.xs +++ b/SQLite.xs @@ -114,11 +114,9 @@ progress_handler(dbh, n_opcodes, handler) RETVAL static int -trace(dbh, callback) +sqlite_trace(dbh, callback) SV *dbh SV *callback - ALIAS: - DBD::SQLite::db::sqlite_trace = 1 CODE: { RETVAL = sqlite_db_trace(aTHX_ dbh, callback ); diff --git a/lib/DBD/SQLite.pm b/lib/DBD/SQLite.pm index 781f2be..1aaef52 100644 --- a/lib/DBD/SQLite.pm +++ b/lib/DBD/SQLite.pm @@ -1161,6 +1161,11 @@ methods. If you need to use an older L, you can call these like this: $dbh->func( ..., "(method name without sqlite_ prefix)" ); +Exception: C should always be called as is, even with C +method (to avoid conflict with DBI's trace() method). + + $dbh->func( ..., "sqlite_trace"); + =head2 $dbh->sqlite_last_insert_rowid() This method returns the last inserted rowid. If you specify an INTEGER PRIMARY diff --git a/t/49_trace_and_profile.t b/t/49_trace_and_profile.t index f77275d..7c971a3 100644 --- a/t/49_trace_and_profile.t +++ b/t/49_trace_and_profile.t @@ -6,34 +6,41 @@ BEGIN { $^W = 1; } -use t::lib::Test qw/connect_ok/; -use Test::More tests => 13; +use t::lib::Test qw/connect_ok @CALL_FUNCS/; +use Test::More; use Test::NoWarnings; -my $dbh = connect_ok(); +plan tests => 12 * @CALL_FUNCS + 1; -{ # trace +my $flag = 0; +for my $call_func (@CALL_FUNCS) { + my $dbh = connect_ok(); + + # sqlite_trace should always be called as sqlite_trace, + # i.e. $dbh->func(..., "sqlite_trace") and $dbh->sqlite_trace(...) + my $func_name = $flag++ ? "trace" : "sqlite_trace"; + + # trace my @trace; - $dbh->sqlite_trace(sub { push @trace, [@_] }); + $dbh->$call_func(sub { push @trace, [@_] }, $func_name); $dbh->do('create table foo (id integer)'); is $trace[0][0] => "create table foo (id integer)"; $dbh->do('insert into foo values (?)', undef, 1); is $trace[1][0] => "insert into foo values ('1')"; - $dbh->sqlite_trace(undef); + $dbh->$call_func(undef, $func_name); $dbh->do('insert into foo values (?)', undef, 2); is @trace => 2; - $dbh->sqlite_trace(sub { push @trace, [@_] }); + $dbh->$call_func(sub { push @trace, [@_] }, $func_name); $dbh->do('insert into foo values (?)', undef, 3); is $trace[2][0] => "insert into foo values ('3')"; -} -{ # profile + # profile my @profile; - $dbh->sqlite_profile(sub { push @profile, [@_] }); + $dbh->$call_func(sub { push @profile, [@_] }, "profile"); $dbh->do('create table bar (id integer)'); is $profile[0][0] => "create table bar (id integer)"; like $profile[0][1] => qr/^[0-9]+$/; @@ -42,12 +49,12 @@ my $dbh = connect_ok(); is $profile[1][0] => "insert into bar values (?)"; like $profile[1][1] => qr/^[0-9]+$/; - $dbh->sqlite_profile(undef); + $dbh->$call_func(undef, "profile"); $dbh->do('insert into bar values (?)', undef, 2); is @profile => 2; - $dbh->sqlite_profile(sub { push @profile, [@_] }); + $dbh->$call_func(sub { push @profile, [@_] }, "profile"); $dbh->do('insert into bar values (?)', undef, 3); is $profile[2][0] => "insert into bar values (?)"; like $profile[2][1] => qr/^[0-9]+$/;