1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 14:19:10 -04:00

allow to set busy_timeout to 0 via sqlite_busy_timeout() (#3)

This commit is contained in:
Kenichi Ishigaki 2014-03-26 23:14:40 +09:00
parent d23dac5eaa
commit 0c96602837
4 changed files with 11 additions and 8 deletions

View file

@ -206,9 +206,9 @@ set_authorizer(dbh, authorizer)
int
busy_timeout(dbh, timeout=0)
busy_timeout(dbh, timeout=NULL)
SV *dbh
int timeout
SV *timeout
ALIAS:
DBD::SQLite::db::sqlite_busy_timeout = 1
CODE:

View file

@ -1379,19 +1379,19 @@ sqlite_db_filename(pTHX_ SV *dbh)
}
int
sqlite_db_busy_timeout(pTHX_ SV *dbh, int timeout )
sqlite_db_busy_timeout(pTHX_ SV *dbh, SV *timeout )
{
D_imp_dbh(dbh);
croak_if_db_is_null();
if (timeout) {
imp_dbh->timeout = timeout;
if (timeout && SvIOK(timeout)) {
imp_dbh->timeout = SvIV(timeout);
if (!DBIc_ACTIVE(imp_dbh)) {
sqlite_error(dbh, -2, "attempt to set busy timeout on inactive database handle");
return -2;
}
sqlite3_busy_timeout(imp_dbh->db, timeout);
sqlite3_busy_timeout(imp_dbh->db, imp_dbh->timeout);
}
return imp_dbh->timeout;
}

View file

@ -96,7 +96,7 @@ int sqlite_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *ag
int sqlite_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func);
int sqlite_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler);
int sqlite_bind_col( SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *attribs );
int sqlite_db_busy_timeout (pTHX_ SV *dbh, int timeout );
int sqlite_db_busy_timeout (pTHX_ SV *dbh, SV *timeout );
int sqlite_db_backup_from_file(pTHX_ SV *dbh, char *filename);
int sqlite_db_backup_to_file(pTHX_ SV *dbh, char *filename);
void sqlite_db_collation_needed(pTHX_ SV *dbh, SV *callback );

View file

@ -12,7 +12,7 @@ use t::lib::Test qw/connect_ok @CALL_FUNCS/;
use Test::More;
use Test::NoWarnings;
plan tests => 18 * @CALL_FUNCS + 1;
plan tests => 20 * @CALL_FUNCS + 1;
my $show_diag = 0;
foreach my $call_func (@CALL_FUNCS) {
@ -26,6 +26,9 @@ foreach my $call_func (@CALL_FUNCS) {
ok( $dbh->$call_func('busy_timeout'), 'Found initial busy_timeout' );
ok( $dbh->$call_func(5000, 'busy_timeout') );
is( $dbh->$call_func('busy_timeout'), 5000, 'Set busy_timeout to new value' );
ok( defined $dbh->$call_func(0, 'busy_timeout') );
is( $dbh->$call_func('busy_timeout'), 0, 'Set busy_timeout to 0' );
}
# Attributes in the connect string