mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 06:08:38 -04:00
DBD::SQLite: applied a patch to make "do" faster [RT #35449]
This commit is contained in:
parent
f66f362a4c
commit
a0fe46546a
3 changed files with 43 additions and 0 deletions
15
SQLite.xs
15
SQLite.xs
|
@ -63,6 +63,21 @@ busy_timeout(dbh, timeout=0)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
_do(dbh, statement)
|
||||
SV * dbh
|
||||
char * statement
|
||||
CODE:
|
||||
{
|
||||
D_imp_dbh(dbh);
|
||||
IV retval;
|
||||
retval = sqlite_db_do(dbh, imp_dbh, statement);
|
||||
if (retval == 0)
|
||||
XST_mPV(0, "0E0"); /* (true but zero) */
|
||||
else
|
||||
XST_mUNDEF(0); /* <= -2 means error */
|
||||
}
|
||||
|
||||
MODULE = DBD::SQLite PACKAGE = DBD::SQLite::st
|
||||
|
||||
PROTOTYPES: DISABLE
|
||||
|
|
19
dbdimp.c
19
dbdimp.c
|
@ -230,6 +230,25 @@ sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
sqlite_db_do(SV *dbh, imp_dbh_t *imp_dbh, char *statement)
|
||||
{
|
||||
dTHR;
|
||||
int retval;
|
||||
char *errmsg;
|
||||
|
||||
sqlite_trace(2, "DO");
|
||||
if ((retval = sqlite3_exec(imp_dbh->db, statement,
|
||||
NULL, NULL, &errmsg))
|
||||
!= SQLITE_OK)
|
||||
{
|
||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sqlite_discon_all(SV *drh, imp_drh_t *imp_drh)
|
||||
{
|
||||
|
|
|
@ -62,6 +62,15 @@ sub connect {
|
|||
|
||||
package DBD::SQLite::db;
|
||||
|
||||
sub do {
|
||||
my ($dbh, $statement, $attr, @params) = @_;
|
||||
return DBD::SQLite::db::_do($dbh, $statement) unless defined $attr && @params;
|
||||
my $sth = $dbh->prepare($statement, $attr) or return undef;
|
||||
$sth->execute(@params) or return undef;
|
||||
my $rows = $sth->rows;
|
||||
($rows == 0) ? "0E0" : $rows;
|
||||
}
|
||||
|
||||
sub prepare {
|
||||
my ($dbh, $statement, @attribs) = @_;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue