File: //proc/3/cwd/installd/perl588installer/DBD-SQLite-1.14/SQLite.c
/*
* This file was generated automatically by xsubpp version 1.9508 from the
* contents of SQLite.xs. Do not edit this file, edit SQLite.xs instead.
*
* ANY CHANGES MADE HERE WILL BE LOST!
*
*/
#line 1 "SQLite.xs"
/* $Id: SQLite.xs,v 1.8 2005/06/20 13:53:00 matt Exp $ */
#include "SQLiteXS.h"
DBISTATE_DECLARE;
#line 17 "SQLite.c"
XS(XS_DBD__SQLite__db_list_tables); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_list_tables)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::list_tables(dbh)");
{
SV * dbh = ST(0);
AV * RETVAL;
#line 18 "SQLite.xs"
{
RETVAL = newAV();
}
#line 32 "SQLite.c"
ST(0) = newRV((SV*)RETVAL);
sv_2mortal(ST(0));
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_last_insert_rowid); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_last_insert_rowid)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::last_insert_rowid(dbh)");
{
SV * dbh = ST(0);
int RETVAL;
dXSTARG;
#line 28 "SQLite.xs"
{
D_imp_dbh(dbh);
RETVAL = sqlite3_last_insert_rowid(imp_dbh->db);
}
#line 55 "SQLite.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_create_function); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_create_function)
{
dXSARGS;
if (items != 4)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::create_function(dbh, name, argc, func)");
{
SV * dbh = ST(0);
char * name = (char *)SvPV_nolen(ST(1));
int argc = (int)SvIV(ST(2));
SV * func = ST(3);
#line 42 "SQLite.xs"
{
sqlite3_db_create_function( dbh, name, argc, func );
}
#line 77 "SQLite.c"
}
XSRETURN_EMPTY;
}
XS(XS_DBD__SQLite__db_create_aggregate); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_create_aggregate)
{
dXSARGS;
if (items != 4)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::create_aggregate(dbh, name, argc, aggr)");
{
SV * dbh = ST(0);
char * name = (char *)SvPV_nolen(ST(1));
int argc = (int)SvIV(ST(2));
SV * aggr = ST(3);
#line 53 "SQLite.xs"
{
sqlite3_db_create_aggregate( dbh, name, argc, aggr );
}
#line 98 "SQLite.c"
}
XSRETURN_EMPTY;
}
XS(XS_DBD__SQLite__db_busy_timeout); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_busy_timeout)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::busy_timeout(dbh, timeout=0)");
{
SV * dbh = ST(0);
int timeout;
int RETVAL;
dXSTARG;
if (items < 2)
timeout = 0;
else {
timeout = (int)SvIV(ST(1));
}
#line 62 "SQLite.xs"
RETVAL = dbd_set_sqlite3_busy_timeout( dbh, timeout );
#line 123 "SQLite.c"
XSprePUSH; PUSHi((IV)RETVAL);
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_reset); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_reset)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::reset(sth)");
{
SV * sth = ST(0);
#line 74 "SQLite.xs"
{
sqlite_st_reset(sth);
}
#line 142 "SQLite.c"
}
XSRETURN_EMPTY;
}
/* INCLUDE: Including 'SQLite.xsi' from 'SQLite.xs' */
#include "Driver_xst.h"
XS(XS_DBD__SQLite__dr_dbixs_revision); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__dr_dbixs_revision)
{
dXSARGS;
PERL_UNUSED_VAR(ax); /* -Wall */
SP -= items;
{
#line 36 "SQLite.xsi"
ST(0) = sv_2mortal(newSViv(DBIXS_REVISION));
#line 161 "SQLite.c"
PUTBACK;
return;
}
}
#ifdef dbd_discon_all
#define XSubPPtmpAAAA 1
XS(XS_DBD__SQLite__dr_discon_all_); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__dr_discon_all_)
{
dXSARGS;
dXSI32;
if (items != 1)
Perl_croak(aTHX_ "Usage: %s(drh)", GvNAME(CvGV(cv)));
{
SV * drh = ST(0);
#line 48 "SQLite.xsi"
D_imp_drh(drh);
if (0) ix = ix; /* avoid unused variable warning */
ST(0) = dbd_discon_all(drh, imp_drh) ? &sv_yes : &sv_no;
#line 184 "SQLite.c"
}
XSRETURN(1);
}
#endif /* dbd_discon_all */
#ifdef dbd_dr_data_sources
#define XSubPPtmpAAAB 1
XS(XS_DBD__SQLite__dr_data_sources); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__dr_data_sources)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: DBD::SQLite::dr::data_sources(drh, attr = Nullsv)");
SP -= items;
{
SV * drh = ST(0);
SV * attr;
if (items < 2)
attr = Nullsv;
else {
attr = ST(1);
}
#line 62 "SQLite.xsi"
{
D_imp_drh(drh);
AV *av = dbd_dr_data_sources(drh, imp_drh, attr);
if (av) {
int i;
int n = AvFILL(av)+1;
EXTEND(sp, n);
for (i = 0; i < n; ++i) {
PUSHs(AvARRAY(av)[i]);
}
}
}
#line 223 "SQLite.c"
PUTBACK;
return;
}
}
#endif
XS(XS_DBD__SQLite__db__login); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db__login)
{
dXSARGS;
if (items < 4 || items > 5)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::_login(dbh, dbname, username, password, attribs=Nullsv)");
{
SV * dbh = ST(0);
char * dbname = (char *)SvPV_nolen(ST(1));
SV * username = ST(2);
SV * password = ST(3);
SV * attribs;
if (items < 5)
attribs = Nullsv;
else {
attribs = ST(4);
}
#line 92 "SQLite.xsi"
{
STRLEN lna;
D_imp_dbh(dbh);
char *u = (SvOK(username)) ? SvPV(username,lna) : "";
char *p = (SvOK(password)) ? SvPV(password,lna) : "";
#ifdef dbd_db_login6
ST(0) = dbd_db_login6(dbh, imp_dbh, dbname, u, p, attribs) ? &sv_yes : &sv_no;
#else
ST(0) = dbd_db_login( dbh, imp_dbh, dbname, u, p) ? &sv_yes : &sv_no;
#endif
}
#line 261 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_selectall_arrayref); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_selectall_arrayref)
{
dXSARGS;
{
#line 108 "SQLite.xsi"
SV *sth;
SV **maxrows_svp;
SV **tmp_svp;
SV *attr = &PL_sv_undef;
imp_sth_t *imp_sth;
#line 278 "SQLite.c"
#line 114 "SQLite.xsi"
if (items > 2) {
attr = ST(2);
if (SvROK(attr) &&
(DBD_ATTRIB_TRUE(attr,"Slice",5,tmp_svp) || DBD_ATTRIB_TRUE(attr,"Columns",7,tmp_svp))
) {
/* fallback to perl implementation */
SV *tmp =dbixst_bounce_method("DBD::SQLite::db::SUPER::selectall_arrayref", items);
SPAGAIN;
ST(0) = tmp;
XSRETURN(1);
}
}
/* --- prepare --- */
if (SvROK(ST(1))) {
MAGIC *mg;
sth = ST(1);
/* switch to inner handle if not already */
if ( (mg = mg_find(SvRV(sth),'P')) )
sth = mg->mg_obj;
}
else {
sth = dbixst_bounce_method("prepare", 3);
SPAGAIN; SP -= items; /* because stack might have been realloc'd */
if (!SvROK(sth))
XSRETURN_UNDEF;
/* switch to inner handle */
sth = mg_find(SvRV(sth),'P')->mg_obj;
}
imp_sth = (imp_sth_t*)(DBIh_COM(sth));
/* --- bind_param --- */
if (items > 3) { /* need to bind params before execute */
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
XSRETURN_UNDEF;
}
}
/* --- execute --- */
DBIc_ROW_COUNT(imp_sth) = 0;
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
XSRETURN_UNDEF;
}
/* --- fetchall --- */
maxrows_svp = DBD_ATTRIB_GET_SVP(attr, "MaxRows", 7);
ST(0) = dbdxst_fetchall_arrayref(sth, &PL_sv_undef, (maxrows_svp) ? *maxrows_svp : &PL_sv_undef);
#line 323 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_selectrow_arrayref); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_selectrow_arrayref)
{
dXSARGS;
dXSI32;
PERL_UNUSED_VAR(ax); /* -Wall */
SP -= items;
{
#line 164 "SQLite.xsi"
int is_selectrow_array = (ix == 1);
imp_sth_t *imp_sth;
SV *sth;
AV *row_av;
#line 342 "SQLite.c"
#line 169 "SQLite.xsi"
if (SvROK(ST(1))) {
MAGIC *mg;
sth = ST(1);
/* switch to inner handle if not already */
if ( (mg = mg_find(SvRV(sth),'P')) )
sth = mg->mg_obj;
}
else {
/* --- prepare --- */
sth = dbixst_bounce_method("prepare", 3);
SPAGAIN; SP -= items; /* because stack might have been realloc'd */
if (!SvROK(sth)) {
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
/* switch to inner handle */
sth = mg_find(SvRV(sth),'P')->mg_obj;
}
imp_sth = (imp_sth_t*)(DBIh_COM(sth));
/* --- bind_param --- */
if (items > 3) { /* need to bind params before execute */
if (!dbdxst_bind_params(sth, imp_sth, items-2, ax+2) ) {
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
}
/* --- execute --- */
DBIc_ROW_COUNT(imp_sth) = 0;
if ( dbd_st_execute(sth, imp_sth) <= -2 ) { /* -2 == error */
if (is_selectrow_array) { XSRETURN_EMPTY; } else { XSRETURN_UNDEF; }
}
/* --- fetchrow_arrayref --- */
row_av = dbd_st_fetch(sth, imp_sth);
if (!row_av) {
if (GIMME == G_SCALAR)
PUSHs(&PL_sv_undef);
}
else if (is_selectrow_array) {
int i;
int num_fields = AvFILL(row_av)+1;
if (GIMME == G_SCALAR)
num_fields = 1; /* return just first field */
EXTEND(sp, num_fields);
for(i=0; i < num_fields; ++i) {
PUSHs(AvARRAY(row_av)[i]);
}
}
else {
PUSHs( sv_2mortal(newRV((SV *)row_av)) );
}
/* --- finish --- */
#ifdef dbd_st_finish3
dbd_st_finish3(sth, imp_sth, 0);
#else
dbd_st_finish(sth, imp_sth);
#endif
#line 398 "SQLite.c"
PUTBACK;
return;
}
}
#ifdef dbd_db_do4 /* deebeedee-deebee-doo, deebee-doobee-dah? */
#define XSubPPtmpAAAC 1
XS(XS_DBD__SQLite__db_do); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_do)
{
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::do(dbh, statement, params = Nullsv)");
{
SV * dbh = ST(0);
char * statement = (char *)SvPV_nolen(ST(1));
SV * params;
if (items < 3)
params = Nullsv;
else {
params = ST(2);
}
#line 233 "SQLite.xsi"
{
D_imp_dbh(dbh);
IV retval;
retval = dbd_db_do4(dbh, imp_dbh, statement, params);
/* remember that dbd_db_do4 must return <= -2 for error */
if (retval == 0) /* ok with no rows affected */
XST_mPV(0, "0E0"); /* (true but zero) */
else if (retval < -1) /* -1 == unknown number of rows */
XST_mUNDEF(0); /* <= -2 means error */
else
XST_mIV(0, retval); /* typically 1, rowcount or -1 */
}
#line 437 "SQLite.c"
}
XSRETURN(1);
}
#endif
#ifdef dbd_db_last_insert_id
#define XSubPPtmpAAAD 1
XS(XS_DBD__SQLite__db_last_insert_id); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_last_insert_id)
{
dXSARGS;
if (items < 5 || items > 6)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::last_insert_id(dbh, catalog, schema, table, field, attr=Nullsv)");
{
SV * dbh = ST(0);
SV * catalog = ST(1);
SV * schema = ST(2);
SV * table = ST(3);
SV * field = ST(4);
SV * attr;
if (items < 6)
attr = Nullsv;
else {
attr = ST(5);
}
#line 260 "SQLite.xsi"
{
D_imp_dbh(dbh);
ST(0) = dbd_db_last_insert_id(dbh, imp_dbh, catalog, schema, table, field, attr);
}
#line 471 "SQLite.c"
}
XSRETURN(1);
}
#endif
XS(XS_DBD__SQLite__db_commit); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_commit)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::commit(dbh)");
{
SV * dbh = ST(0);
#line 272 "SQLite.xsi"
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
warn("commit ineffective with AutoCommit enabled");
ST(0) = dbd_db_commit(dbh, imp_dbh) ? &sv_yes : &sv_no;
#line 491 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_rollback); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_rollback)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::rollback(dbh)");
{
SV * dbh = ST(0);
#line 282 "SQLite.xsi"
D_imp_dbh(dbh);
if (DBIc_has(imp_dbh,DBIcf_AutoCommit) && DBIc_WARN(imp_dbh))
warn("rollback ineffective with AutoCommit enabled");
ST(0) = dbd_db_rollback(dbh, imp_dbh) ? &sv_yes : &sv_no;
#line 510 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_disconnect); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_disconnect)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::disconnect(dbh)");
{
SV * dbh = ST(0);
#line 292 "SQLite.xsi"
D_imp_dbh(dbh);
if ( !DBIc_ACTIVE(imp_dbh) ) {
XSRETURN_YES;
}
/* Check for disconnect() being called whilst refs to cursors */
/* still exists. This possibly needs some more thought. */
if (DBIc_ACTIVE_KIDS(imp_dbh) && DBIc_WARN(imp_dbh) && !dirty) {
STRLEN lna;
char *plural = (DBIc_ACTIVE_KIDS(imp_dbh)==1) ? "" : "s";
warn("%s->disconnect invalidates %d active statement handle%s %s",
SvPV(dbh,lna), (int)DBIc_ACTIVE_KIDS(imp_dbh), plural,
"(either destroy statement handles or call finish on them before disconnecting)");
}
ST(0) = dbd_db_disconnect(dbh, imp_dbh) ? &sv_yes : &sv_no;
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
#line 540 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_STORE); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_STORE)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::STORE(dbh, keysv, valuesv)");
{
SV * dbh = ST(0);
SV * keysv = ST(1);
SV * valuesv = ST(2);
#line 315 "SQLite.xsi"
D_imp_dbh(dbh);
if (SvGMAGICAL(valuesv))
mg_get(valuesv);
ST(0) = &sv_yes;
if (!dbd_db_STORE_attrib(dbh, imp_dbh, keysv, valuesv))
if (!DBIc_DBISTATE(imp_dbh)->set_attr(dbh, keysv, valuesv))
ST(0) = &sv_no;
#line 564 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_FETCH); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_FETCH)
{
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::FETCH(dbh, keysv)");
{
SV * dbh = ST(0);
SV * keysv = ST(1);
#line 329 "SQLite.xsi"
D_imp_dbh(dbh);
SV *valuesv = dbd_db_FETCH_attrib(dbh, imp_dbh, keysv);
if (!valuesv)
valuesv = DBIc_DBISTATE(imp_dbh)->get_attr(dbh, keysv);
ST(0) = valuesv; /* dbd_db_FETCH_attrib did sv_2mortal */
#line 585 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__db_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_DESTROY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::DESTROY(dbh)");
SP -= items;
{
SV * dbh = ST(0);
#line 340 "SQLite.xsi"
/* keep in sync with default DESTROY in DBI.xs */
D_imp_dbh(dbh);
ST(0) = &sv_yes;
if (!DBIc_IMPSET(imp_dbh)) { /* was never fully set up */
STRLEN lna;
if (DBIc_WARN(imp_dbh) && !dirty && DBIc_DBISTATE(imp_dbh)->debug >= 2)
PerlIO_printf(DBIc_LOGPIO(imp_dbh),
" DESTROY for %s ignored - handle not initialised\n",
SvPV(dbh,lna));
}
else {
if (DBIc_IADESTROY(imp_dbh)) { /* want's ineffective destroy */
DBIc_ACTIVE_off(imp_dbh);
if (DBIc_DBISTATE(imp_dbh)->debug)
PerlIO_printf(DBIc_LOGPIO(imp_dbh), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(dbh));
}
if (DBIc_ACTIVE(imp_dbh)) {
if (!DBIc_has(imp_dbh,DBIcf_AutoCommit)) {
/* Application is using transactions and hasn't explicitly disconnected.
Some databases will automatically commit on graceful disconnect.
Since we're about to gracefully disconnect as part of the DESTROY
we want to be sure we're not about to implicitly commit changes
that are incomplete and should be rolled back. (The DESTROY may
be due to a RaiseError, for example.) So we rollback here.
This will be harmless if the application has issued a commit,
XXX Could add an attribute flag to indicate that the driver
doesn't have this problem. Patches welcome.
XXX or could just move the DBIc_is(imp_dbh, DBIcf_Executed) test
to cover the rollback as well. That just needs sanity checking
that DBIcf_Executed is set by any/all possible way to execute a
statement that might start a transaction.
*/
if (DBIc_WARN(imp_dbh)
&& DBIc_is(imp_dbh, DBIcf_Executed) /* has not just called commit/rollback */
&& (!dirty || DBIc_DBISTATE(imp_dbh)->debug >= 3)
)
warn("Issuing rollback() for database handle being DESTROY'd without explicit disconnect()");
dbd_db_rollback(dbh, imp_dbh); /* ROLLBACK! */
}
dbd_db_disconnect(dbh, imp_dbh);
DBIc_ACTIVE_off(imp_dbh); /* ensure it's off, regardless */
}
dbd_db_destroy(dbh, imp_dbh);
}
#line 645 "SQLite.c"
PUTBACK;
return;
}
}
#ifdef dbd_take_imp_data
#define XSubPPtmpAAAE 1
XS(XS_DBD__SQLite__db_take_imp_data); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_take_imp_data)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::take_imp_data(h)");
{
SV * h = ST(0);
#line 392 "SQLite.xsi"
D_imp_xxh(h);
/* dbd_take_imp_data() returns &sv_no (or other defined but false value)
* to indicate "preparations complete, now call SUPER::take_imp_data" for me.
* Anything else is returned to the caller via sv_2mortal(sv), typically that
* would be &sv_undef for error or an SV holding the imp_data.
*/
SV *sv = dbd_take_imp_data(h, imp_xxh, NULL);
if (SvOK(sv) && !SvTRUE(sv)) {
SV *tmp = dbixst_bounce_method("DBD::SQLite::db::SUPER::take_imp_data", items);
SPAGAIN;
ST(0) = tmp;
} else {
ST(0) = sv_2mortal(sv);
}
#line 678 "SQLite.c"
}
XSRETURN(1);
}
#endif
#ifdef dbd_db_data_sources
#define XSubPPtmpAAAF 1
XS(XS_DBD__SQLite__db_data_sources); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__db_data_sources)
{
dXSARGS;
if (items < 1 || items > 2)
Perl_croak(aTHX_ "Usage: DBD::SQLite::db::data_sources(dbh, attr = Nullsv)");
SP -= items;
{
SV * dbh = ST(0);
SV * attr;
if (items < 2)
attr = Nullsv;
else {
attr = ST(1);
}
#line 416 "SQLite.xsi"
{
D_imp_dbh(dbh);
AV *av = dbd_db_data_sources(dbh, imp_dbh, attr);
if (av) {
int i;
int n = AvFILL(av)+1;
EXTEND(sp, n);
for (i = 0; i < n; ++i) {
PUSHs(AvARRAY(av)[i]);
}
}
}
#line 717 "SQLite.c"
PUTBACK;
return;
}
}
#endif
XS(XS_DBD__SQLite__st__prepare); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st__prepare)
{
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::_prepare(sth, statement, attribs=Nullsv)");
{
SV * sth = ST(0);
SV * statement = ST(1);
SV * attribs;
if (items < 3)
attribs = Nullsv;
else {
attribs = ST(2);
}
#line 445 "SQLite.xsi"
{
D_imp_sth(sth);
DBD_ATTRIBS_CHECK("_prepare", sth, attribs);
#ifdef dbd_st_prepare_sv
ST(0) = dbd_st_prepare_sv(sth, imp_sth, statement, attribs) ? &sv_yes : &sv_no;
#else
ST(0) = dbd_st_prepare(sth, imp_sth, SvPV_nolen(statement), attribs) ? &sv_yes : &sv_no;
#endif
}
#line 751 "SQLite.c"
}
XSRETURN(1);
}
#ifdef dbd_st_rows
#define XSubPPtmpAAAG 1
XS(XS_DBD__SQLite__st_rows); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_rows)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::rows(sth)");
{
SV * sth = ST(0);
#line 462 "SQLite.xsi"
D_imp_sth(sth);
XST_mIV(0, dbd_st_rows(sth, imp_sth));
#line 771 "SQLite.c"
}
XSRETURN(1);
}
#endif /* dbd_st_rows */
#ifdef dbd_st_bind_col
#define XSubPPtmpAAAH 1
XS(XS_DBD__SQLite__st_bind_col); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_bind_col)
{
dXSARGS;
if (items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::bind_col(sth, col, ref, attribs=Nullsv)");
{
SV * sth = ST(0);
SV * col = ST(1);
SV * ref = ST(2);
SV * attribs;
if (items < 4)
attribs = Nullsv;
else {
attribs = ST(3);
}
#line 477 "SQLite.xsi"
{
IV sql_type = 0;
D_imp_sth(sth);
if (SvGMAGICAL(ref))
mg_get(ref);
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_col", sth, attribs);
/* XXX we should perhaps complain if TYPE is not SvNIOK */
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
}
}
switch(dbd_st_bind_col(sth, imp_sth, col, ref, sql_type, attribs)) {
case 2: ST(0) = &sv_yes; /* job done completely */
break;
case 1: /* fallback to DBI default */
ST(0) = (DBIc_DBISTATE(imp_sth)->bind_col(sth, col, ref, attribs))
? &sv_yes : &sv_no;
break;
default: ST(0) = &sv_no; /* dbd_st_bind_col has called set_err */
break;
}
}
#line 827 "SQLite.c"
}
XSRETURN(1);
}
#endif /* dbd_st_bind_col */
XS(XS_DBD__SQLite__st_bind_param); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_bind_param)
{
dXSARGS;
if (items < 3 || items > 4)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::bind_param(sth, param, value, attribs=Nullsv)");
{
SV * sth = ST(0);
SV * param = ST(1);
SV * value = ST(2);
SV * attribs;
if (items < 4)
attribs = Nullsv;
else {
attribs = ST(3);
}
#line 515 "SQLite.xsi"
{
IV sql_type = 0;
D_imp_sth(sth);
if (SvGMAGICAL(value))
mg_get(value);
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
/* XXX we should perhaps complain if TYPE is not SvNIOK */
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
}
}
ST(0) = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, FALSE, 0)
? &sv_yes : &sv_no;
}
#line 872 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_bind_param_inout); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_bind_param_inout)
{
dXSARGS;
if (items < 4 || items > 5)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::bind_param_inout(sth, param, value_ref, maxlen, attribs=Nullsv)");
{
SV * sth = ST(0);
SV * param = ST(1);
SV * value_ref = ST(2);
IV maxlen = (IV)SvIV(ST(3));
SV * attribs;
if (items < 5)
attribs = Nullsv;
else {
attribs = ST(4);
}
#line 545 "SQLite.xsi"
{
IV sql_type = 0;
D_imp_sth(sth);
SV *value;
if (!SvROK(value_ref) || SvTYPE(SvRV(value_ref)) > SVt_PVMG)
croak("bind_param_inout needs a reference to a scalar value");
value = SvRV(value_ref);
if (SvREADONLY(value))
croak("Modification of a read-only value attempted");
if (SvGMAGICAL(value))
mg_get(value);
if (attribs) {
if (SvNIOK(attribs)) {
sql_type = SvIV(attribs);
attribs = Nullsv;
}
else {
SV **svp;
DBD_ATTRIBS_CHECK("bind_param", sth, attribs);
DBD_ATTRIB_GET_IV(attribs, "TYPE",4, svp, sql_type);
}
}
ST(0) = dbd_bind_ph(sth, imp_sth, param, value, sql_type, attribs, TRUE, maxlen)
? &sv_yes : &sv_no;
}
#line 922 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_execute); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_execute)
{
dXSARGS;
if (items < 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::execute(sth, ...)");
{
SV * sth = ST(0);
#line 576 "SQLite.xsi"
D_imp_sth(sth);
int retval;
if (items > 1) { /* need to bind params */
if (!dbdxst_bind_params(sth, imp_sth, items, ax) ) {
XSRETURN_UNDEF;
}
}
/* XXX this code is duplicated in selectrow_arrayref above */
if (DBIc_ROW_COUNT(imp_sth) > 0) /* reset for re-execute */
DBIc_ROW_COUNT(imp_sth) = 0;
retval = dbd_st_execute(sth, imp_sth);
/* remember that dbd_st_execute must return <= -2 for error */
if (retval == 0) /* ok with no rows affected */
XST_mPV(0, "0E0"); /* (true but zero) */
else if (retval < -1) /* -1 == unknown number of rows */
XST_mUNDEF(0); /* <= -2 means error */
else
XST_mIV(0, retval); /* typically 1, rowcount or -1 */
#line 955 "SQLite.c"
}
XSRETURN(1);
}
#ifdef dbd_st_execute_for_fetch
#define XSubPPtmpAAAI 1
XS(XS_DBD__SQLite__st_execute_for_fetch); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_execute_for_fetch)
{
dXSARGS;
if (items < 2 || items > 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::execute_for_fetch(sth, fetch_tuple_sub, tuple_status = Nullsv)");
{
SV * sth = ST(0);
SV * fetch_tuple_sub = ST(1);
SV * tuple_status;
if (items < 3)
tuple_status = Nullsv;
else {
tuple_status = ST(2);
}
#line 604 "SQLite.xsi"
{
D_imp_sth(sth);
ST(0) = dbd_st_execute_for_fetch(sth, imp_sth, fetch_tuple_sub, tuple_status);
}
#line 985 "SQLite.c"
}
XSRETURN(1);
}
#endif
XS(XS_DBD__SQLite__st_fetchrow_arrayref); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_fetchrow_arrayref)
{
dXSARGS;
dXSI32;
if (items != 1)
Perl_croak(aTHX_ "Usage: %s(sth)", GvNAME(CvGV(cv)));
{
SV * sth = ST(0);
#line 619 "SQLite.xsi"
D_imp_sth(sth);
AV *av;
if (0) ix = ix; /* avoid unused variable warning */
av = dbd_st_fetch(sth, imp_sth);
ST(0) = (av) ? sv_2mortal(newRV((SV *)av)) : &PL_sv_undef;
#line 1007 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_fetchrow_array); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_fetchrow_array)
{
dXSARGS;
dXSI32;
if (items != 1)
Perl_croak(aTHX_ "Usage: %s(sth)", GvNAME(CvGV(cv)));
SP -= items;
{
SV * sth = ST(0);
#line 632 "SQLite.xsi"
D_imp_sth(sth);
AV *av;
av = dbd_st_fetch(sth, imp_sth);
if (av) {
int i;
int num_fields = AvFILL(av)+1;
EXTEND(sp, num_fields);
for(i=0; i < num_fields; ++i) {
PUSHs(AvARRAY(av)[i]);
}
if (0) ix = ix; /* avoid unused variable warning */
}
#line 1036 "SQLite.c"
PUTBACK;
return;
}
}
XS(XS_DBD__SQLite__st_fetchall_arrayref); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_fetchall_arrayref)
{
dXSARGS;
if (items < 1 || items > 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::fetchall_arrayref(sth, slice=&PL_sv_undef, batch_row_count=&PL_sv_undef)");
{
SV * sth = ST(0);
SV * slice;
SV * batch_row_count;
if (items < 2)
slice = &PL_sv_undef;
else {
slice = ST(1);
}
if (items < 3)
batch_row_count = &PL_sv_undef;
else {
batch_row_count = ST(2);
}
#line 652 "SQLite.xsi"
if (SvOK(slice)) { /* fallback to perl implementation */
SV *tmp = dbixst_bounce_method("DBD::SQLite::st::SUPER::fetchall_arrayref", 3);
SPAGAIN;
ST(0) = tmp;
}
else {
ST(0) = dbdxst_fetchall_arrayref(sth, slice, batch_row_count);
}
#line 1074 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_finish); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_finish)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::finish(sth)");
{
SV * sth = ST(0);
#line 666 "SQLite.xsi"
D_imp_sth(sth);
D_imp_dbh_from_sth;
if (!DBIc_ACTIVE(imp_sth)) {
/* No active statement to finish */
XSRETURN_YES;
}
if (!DBIc_ACTIVE(imp_dbh)) {
/* Either an explicit disconnect() or global destruction */
/* has disconnected us from the database. Finish is meaningless */
DBIc_ACTIVE_off(imp_sth);
XSRETURN_YES;
}
#ifdef dbd_st_finish3
ST(0) = dbd_st_finish3(sth, imp_sth, 0) ? &sv_yes : &sv_no;
#else
ST(0) = dbd_st_finish(sth, imp_sth) ? &sv_yes : &sv_no;
#endif
#line 1106 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_blob_read); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_blob_read)
{
dXSARGS;
if (items < 4 || items > 6)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::blob_read(sth, field, offset, len, destrv=Nullsv, destoffset=0)");
{
SV * sth = ST(0);
int field = (int)SvIV(ST(1));
long offset = (long)SvIV(ST(2));
long len = (long)SvIV(ST(3));
SV * destrv;
long destoffset;
if (items < 5)
destrv = Nullsv;
else {
destrv = ST(4);
}
if (items < 6)
destoffset = 0;
else {
destoffset = (long)SvIV(ST(5));
}
#line 694 "SQLite.xsi"
{
D_imp_sth(sth);
if (!destrv)
destrv = sv_2mortal(newRV(sv_2mortal(newSV(0))));
if (dbd_st_blob_read(sth, imp_sth, field, offset, len, destrv, destoffset))
ST(0) = SvRV(destrv);
else ST(0) = &PL_sv_undef;
}
#line 1146 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_STORE); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_STORE)
{
dXSARGS;
if (items != 3)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::STORE(sth, keysv, valuesv)");
{
SV * sth = ST(0);
SV * keysv = ST(1);
SV * valuesv = ST(2);
#line 710 "SQLite.xsi"
D_imp_sth(sth);
if (SvGMAGICAL(valuesv))
mg_get(valuesv);
ST(0) = &sv_yes;
if (!dbd_st_STORE_attrib(sth, imp_sth, keysv, valuesv))
if (!DBIc_DBISTATE(imp_sth)->set_attr(sth, keysv, valuesv))
ST(0) = &sv_no;
#line 1170 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_FETCH_attrib); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_FETCH_attrib)
{
dXSARGS;
dXSI32;
if (items != 2)
Perl_croak(aTHX_ "Usage: %s(sth, keysv)", GvNAME(CvGV(cv)));
{
SV * sth = ST(0);
SV * keysv = ST(1);
#line 727 "SQLite.xsi"
D_imp_sth(sth);
SV *valuesv;
if (0) ix = ix; /* avoid unused variable warning */
valuesv = dbd_st_FETCH_attrib(sth, imp_sth, keysv);
if (!valuesv)
valuesv = DBIc_DBISTATE(imp_sth)->get_attr(sth, keysv);
ST(0) = valuesv; /* dbd_st_FETCH_attrib did sv_2mortal */
#line 1194 "SQLite.c"
}
XSRETURN(1);
}
XS(XS_DBD__SQLite__st_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_DBD__SQLite__st_DESTROY)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: DBD::SQLite::st::DESTROY(sth)");
SP -= items;
{
SV * sth = ST(0);
#line 740 "SQLite.xsi"
/* keep in sync with default DESTROY in DBI.xs */
D_imp_sth(sth);
ST(0) = &sv_yes;
if (!DBIc_IMPSET(imp_sth)) { /* was never fully set up */
STRLEN lna;
if (DBIc_WARN(imp_sth) && !dirty && DBIc_DBISTATE(imp_sth)->debug >= 2)
PerlIO_printf(DBIc_LOGPIO(imp_sth),
" DESTROY for %s ignored - handle not initialised\n",
SvPV(sth,lna));
}
else {
if (DBIc_IADESTROY(imp_sth)) { /* want's ineffective destroy */
DBIc_ACTIVE_off(imp_sth);
if (DBIc_DBISTATE(imp_sth)->debug)
PerlIO_printf(DBIc_LOGPIO(imp_sth), " DESTROY %s skipped due to InactiveDestroy\n", SvPV_nolen(sth));
}
if (DBIc_ACTIVE(imp_sth)) {
D_imp_dbh_from_sth;
if (!dirty && DBIc_ACTIVE(imp_dbh)) {
#ifdef dbd_st_finish3
dbd_st_finish3(sth, imp_sth, 1);
#else
dbd_st_finish(sth, imp_sth);
#endif
}
else {
DBIc_ACTIVE_off(imp_sth);
}
}
dbd_st_destroy(sth, imp_sth);
}
#line 1241 "SQLite.c"
PUTBACK;
return;
}
}
/* INCLUDE: Returning to 'SQLite.xs' from 'SQLite.xsi' */
#ifdef __cplusplus
extern "C"
#endif
XS(boot_DBD__SQLite); /* prototype to pass -Wmissing-prototypes */
XS(boot_DBD__SQLite)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
{
CV * cv ;
newXS("DBD::SQLite::db::list_tables", XS_DBD__SQLite__db_list_tables, file);
newXS("DBD::SQLite::db::last_insert_rowid", XS_DBD__SQLite__db_last_insert_rowid, file);
newXS("DBD::SQLite::db::create_function", XS_DBD__SQLite__db_create_function, file);
newXS("DBD::SQLite::db::create_aggregate", XS_DBD__SQLite__db_create_aggregate, file);
newXS("DBD::SQLite::db::busy_timeout", XS_DBD__SQLite__db_busy_timeout, file);
newXS("DBD::SQLite::st::reset", XS_DBD__SQLite__st_reset, file);
newXS("DBD::SQLite::dr::dbixs_revision", XS_DBD__SQLite__dr_dbixs_revision, file);
#if XSubPPtmpAAAA
cv = newXS("DBD::SQLite::dr::disconnect_all", XS_DBD__SQLite__dr_discon_all_, file);
XSANY.any_i32 = 1 ;
cv = newXS("DBD::SQLite::dr::discon_all_", XS_DBD__SQLite__dr_discon_all_, file);
XSANY.any_i32 = 0 ;
#endif
#if XSubPPtmpAAAB
newXS("DBD::SQLite::dr::data_sources", XS_DBD__SQLite__dr_data_sources, file);
#endif
newXS("DBD::SQLite::db::_login", XS_DBD__SQLite__db__login, file);
newXS("DBD::SQLite::db::selectall_arrayref", XS_DBD__SQLite__db_selectall_arrayref, file);
cv = newXS("DBD::SQLite::db::selectrow_array", XS_DBD__SQLite__db_selectrow_arrayref, file);
XSANY.any_i32 = 1 ;
cv = newXS("DBD::SQLite::db::selectrow_arrayref", XS_DBD__SQLite__db_selectrow_arrayref, file);
XSANY.any_i32 = 0 ;
#if XSubPPtmpAAAC
newXS("DBD::SQLite::db::do", XS_DBD__SQLite__db_do, file);
#endif
#if XSubPPtmpAAAD
newXS("DBD::SQLite::db::last_insert_id", XS_DBD__SQLite__db_last_insert_id, file);
#endif
newXS("DBD::SQLite::db::commit", XS_DBD__SQLite__db_commit, file);
newXS("DBD::SQLite::db::rollback", XS_DBD__SQLite__db_rollback, file);
newXS("DBD::SQLite::db::disconnect", XS_DBD__SQLite__db_disconnect, file);
newXS("DBD::SQLite::db::STORE", XS_DBD__SQLite__db_STORE, file);
newXS("DBD::SQLite::db::FETCH", XS_DBD__SQLite__db_FETCH, file);
newXS("DBD::SQLite::db::DESTROY", XS_DBD__SQLite__db_DESTROY, file);
#if XSubPPtmpAAAE
newXS("DBD::SQLite::db::take_imp_data", XS_DBD__SQLite__db_take_imp_data, file);
#endif
#if XSubPPtmpAAAF
newXS("DBD::SQLite::db::data_sources", XS_DBD__SQLite__db_data_sources, file);
#endif
newXS("DBD::SQLite::st::_prepare", XS_DBD__SQLite__st__prepare, file);
#if XSubPPtmpAAAG
newXS("DBD::SQLite::st::rows", XS_DBD__SQLite__st_rows, file);
#endif
#if XSubPPtmpAAAH
newXS("DBD::SQLite::st::bind_col", XS_DBD__SQLite__st_bind_col, file);
#endif
newXS("DBD::SQLite::st::bind_param", XS_DBD__SQLite__st_bind_param, file);
newXS("DBD::SQLite::st::bind_param_inout", XS_DBD__SQLite__st_bind_param_inout, file);
newXS("DBD::SQLite::st::execute", XS_DBD__SQLite__st_execute, file);
#if XSubPPtmpAAAI
newXS("DBD::SQLite::st::execute_for_fetch", XS_DBD__SQLite__st_execute_for_fetch, file);
#endif
cv = newXS("DBD::SQLite::st::fetchrow_arrayref", XS_DBD__SQLite__st_fetchrow_arrayref, file);
XSANY.any_i32 = 0 ;
cv = newXS("DBD::SQLite::st::fetch", XS_DBD__SQLite__st_fetchrow_arrayref, file);
XSANY.any_i32 = 1 ;
cv = newXS("DBD::SQLite::st::fetchrow", XS_DBD__SQLite__st_fetchrow_array, file);
XSANY.any_i32 = 1 ;
cv = newXS("DBD::SQLite::st::fetchrow_array", XS_DBD__SQLite__st_fetchrow_array, file);
XSANY.any_i32 = 0 ;
newXS("DBD::SQLite::st::fetchall_arrayref", XS_DBD__SQLite__st_fetchall_arrayref, file);
newXS("DBD::SQLite::st::finish", XS_DBD__SQLite__st_finish, file);
newXS("DBD::SQLite::st::blob_read", XS_DBD__SQLite__st_blob_read, file);
newXS("DBD::SQLite::st::STORE", XS_DBD__SQLite__st_STORE, file);
cv = newXS("DBD::SQLite::st::FETCH", XS_DBD__SQLite__st_FETCH_attrib, file);
XSANY.any_i32 = 1 ;
cv = newXS("DBD::SQLite::st::FETCH_attrib", XS_DBD__SQLite__st_FETCH_attrib, file);
XSANY.any_i32 = 0 ;
newXS("DBD::SQLite::st::DESTROY", XS_DBD__SQLite__st_DESTROY, file);
}
/* Initialisation Section */
#line 12 "SQLite.xs"
sv_setpv(get_sv("DBD::SQLite::sqlite_version", TRUE), SQLITE_VERSION);
#line 18 "SQLite.xsi"
items = 0; /* avoid 'unused variable' warning */
DBISTATE_INIT;
/* XXX this interface will change: */
DBI_IMP_SIZE("DBD::SQLite::dr::imp_data_size", sizeof(imp_drh_t));
DBI_IMP_SIZE("DBD::SQLite::db::imp_data_size", sizeof(imp_dbh_t));
DBI_IMP_SIZE("DBD::SQLite::st::imp_data_size", sizeof(imp_sth_t));
dbd_init(DBIS);
#if XSubPPtmpAAAA
#endif
#if XSubPPtmpAAAB
#endif
#if XSubPPtmpAAAC
#endif
#if XSubPPtmpAAAD
#endif
#if XSubPPtmpAAAE
#endif
#if XSubPPtmpAAAF
#endif
#if XSubPPtmpAAAG
#endif
#if XSubPPtmpAAAH
#endif
#if XSubPPtmpAAAI
#endif
#line 1368 "SQLite.c"
/* End of Initialisation Section */
XSRETURN_YES;
}