mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
DBD::SQLite: done cleanup for now
This commit is contained in:
parent
234d619b21
commit
a8ab9bd263
1 changed files with 111 additions and 112 deletions
223
dbdimp.c
223
dbdimp.c
|
@ -729,7 +729,7 @@ sqlite_db_FETCH_attrib(SV *dbh, imp_dbh_t *imp_dbh, SV *keysv)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_st_STORE_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv)
|
sqlite_st_STORE_attrib(SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
/* char *key = SvPV_nolen(keysv); */
|
/* char *key = SvPV_nolen(keysv); */
|
||||||
|
@ -737,7 +737,7 @@ sqlite_st_STORE_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv, SV *valuesv)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
type_to_odbc_type (int type)
|
type_to_odbc_type(int type)
|
||||||
{
|
{
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SQLITE_INTEGER: return SQL_INTEGER;
|
case SQLITE_INTEGER: return SQL_INTEGER;
|
||||||
|
@ -750,7 +750,7 @@ type_to_odbc_type (int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
SV *
|
SV *
|
||||||
sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
sqlite_st_FETCH_attrib(SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
D_imp_dbh_from_sth;
|
D_imp_dbh_from_sth;
|
||||||
|
@ -798,9 +798,9 @@ sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
type = type_to_odbc_type(type);
|
type = type_to_odbc_type(type);
|
||||||
/* av_store(av, n, newSViv(type)); */
|
/* av_store(av, n, newSViv(type)); */
|
||||||
if (fieldtype)
|
if (fieldtype)
|
||||||
av_store(av, n, newSVpv(fieldtype, 0));
|
av_store(av, n, newSVpv(fieldtype, 0));
|
||||||
else
|
else
|
||||||
av_store(av, n, newSVpv("VARCHAR", 0));
|
av_store(av, n, newSVpv("VARCHAR", 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strEQ(key, "NULLABLE")) {
|
else if (strEQ(key, "NULLABLE")) {
|
||||||
|
@ -814,10 +814,10 @@ sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
const char *fieldname = sqlite3_column_name(imp_sth->stmt, n);
|
const char *fieldname = sqlite3_column_name(imp_sth->stmt, n);
|
||||||
const char *datatype, *collseq;
|
const char *datatype, *collseq;
|
||||||
int notnull, primary, autoinc;
|
int notnull, primary, autoinc;
|
||||||
int retval = sqlite3_table_column_metadata(imp_dbh->db, database, tablename, fieldname, &datatype, &collseq, ¬null, &primary, &autoinc);
|
int rc = sqlite3_table_column_metadata(imp_dbh->db, database, tablename, fieldname, &datatype, &collseq, ¬null, &primary, &autoinc);
|
||||||
if (retval != SQLITE_OK) {
|
if (rc != SQLITE_OK) {
|
||||||
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
char *errmsg = (char*)sqlite3_errmsg(imp_dbh->db);
|
||||||
sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, errmsg);
|
sqlite_error(sth, (imp_xxh_t*)imp_sth, rc, errmsg);
|
||||||
av_store(av, n, newSViv(2)); /* SQL_NULLABLE_UNKNOWN */
|
av_store(av, n, newSViv(2)); /* SQL_NULLABLE_UNKNOWN */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -838,7 +838,7 @@ sqlite_st_FETCH_attrib (SV *sth, imp_sth_t *imp_sth, SV *keysv)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_set_result(pTHX_ sqlite3_context *context, SV *result, int is_error )
|
sqlite_db_set_result(pTHX_ sqlite3_context *context, SV *result, int is_error)
|
||||||
{
|
{
|
||||||
STRLEN len;
|
STRLEN len;
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -954,48 +954,46 @@ sqlite_db_func_dispatcher_no_unicode(sqlite3_context *context, int argc, sqlite3
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func )
|
sqlite_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int rc;
|
||||||
|
|
||||||
/* Copy the function reference */
|
/* Copy the function reference */
|
||||||
SV *func_sv = newSVsv(func);
|
SV *func_sv = newSVsv(func);
|
||||||
av_push( imp_dbh->functions, func_sv );
|
av_push( imp_dbh->functions, func_sv );
|
||||||
|
|
||||||
/* warn("create_function %s with %d args\n", name, argc); */
|
/* warn("create_function %s with %d args\n", name, argc); */
|
||||||
retval = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
rc = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
||||||
func_sv,
|
func_sv,
|
||||||
imp_dbh->unicode ? sqlite_db_func_dispatcher_unicode
|
imp_dbh->unicode ? sqlite_db_func_dispatcher_unicode
|
||||||
: sqlite_db_func_dispatcher_no_unicode,
|
: sqlite_db_func_dispatcher_no_unicode,
|
||||||
NULL, NULL );
|
NULL, NULL );
|
||||||
if ( retval != SQLITE_OK )
|
if ( rc != SQLITE_OK ) {
|
||||||
{
|
|
||||||
char* const errmsg = form("sqlite_create_function failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
char* const errmsg = form("sqlite_create_function failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_enable_load_extension(pTHX_ SV *dbh, int onoff )
|
sqlite_db_enable_load_extension(pTHX_ SV *dbh, int onoff)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int rc;
|
||||||
|
|
||||||
retval = sqlite3_enable_load_extension( imp_dbh->db, onoff );
|
rc = sqlite3_enable_load_extension( imp_dbh->db, onoff );
|
||||||
if ( retval != SQLITE_OK )
|
if ( rc != SQLITE_OK ) {
|
||||||
{
|
|
||||||
char* const errmsg = form("sqlite_enable_load_extension failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
char* const errmsg = form("sqlite_enable_load_extension failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_aggr_new_dispatcher(pTHX_ sqlite3_context *context, aggrInfo *aggr_info )
|
sqlite_db_aggr_new_dispatcher(pTHX_ sqlite3_context *context, aggrInfo *aggr_info)
|
||||||
{
|
{
|
||||||
dSP;
|
dSP;
|
||||||
SV *pkg = NULL;
|
SV *pkg = NULL;
|
||||||
|
@ -1021,14 +1019,14 @@ sqlite_db_aggr_new_dispatcher(pTHX_ sqlite3_context *context, aggrInfo *aggr_inf
|
||||||
aggr_info->inited = 1;
|
aggr_info->inited = 1;
|
||||||
|
|
||||||
if ( SvTRUE( ERRSV ) ) {
|
if ( SvTRUE( ERRSV ) ) {
|
||||||
aggr_info->err = newSVpvf ("error during aggregator's new(): %s",
|
aggr_info->err = newSVpvf("error during aggregator's new(): %s",
|
||||||
SvPV_nolen (ERRSV));
|
SvPV_nolen (ERRSV));
|
||||||
POPs;
|
POPs;
|
||||||
} else if ( count != 1 ) {
|
} else if ( count != 1 ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
aggr_info->err = newSVpvf( "new() should return one value, got %d",
|
aggr_info->err = newSVpvf("new() should return one value, got %d",
|
||||||
count );
|
count );
|
||||||
/* Clear the stack */
|
/* Clear the stack */
|
||||||
for ( i=0; i < count; i++ ) {
|
for ( i=0; i < count; i++ ) {
|
||||||
POPs;
|
POPs;
|
||||||
|
@ -1051,15 +1049,15 @@ sqlite_db_aggr_new_dispatcher(pTHX_ sqlite3_context *context, aggrInfo *aggr_inf
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
sqlite_db_aggr_step_dispatcher(sqlite3_context *context,
|
||||||
int argc, sqlite3_value **value)
|
int argc, sqlite3_value **value)
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
int i;
|
int i;
|
||||||
aggrInfo *aggr;
|
aggrInfo *aggr;
|
||||||
|
|
||||||
aggr = sqlite3_aggregate_context (context, sizeof (aggrInfo));
|
aggr = sqlite3_aggregate_context(context, sizeof (aggrInfo));
|
||||||
if ( !aggr )
|
if ( !aggr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1068,7 +1066,7 @@ sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
||||||
|
|
||||||
/* initialize on first step */
|
/* initialize on first step */
|
||||||
if ( !aggr->inited ) {
|
if ( !aggr->inited ) {
|
||||||
sqlite_db_aggr_new_dispatcher(aTHX_ context, aggr );
|
sqlite_db_aggr_new_dispatcher(aTHX_ context, aggr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aggr->err || !aggr->aggr_inst )
|
if ( aggr->err || !aggr->aggr_inst )
|
||||||
|
@ -1106,7 +1104,7 @@ sqlite_db_aggr_step_dispatcher (sqlite3_context *context,
|
||||||
|
|
||||||
/* Check for an error */
|
/* Check for an error */
|
||||||
if (SvTRUE(ERRSV) ) {
|
if (SvTRUE(ERRSV) ) {
|
||||||
aggr->err = newSVpvf( "error during aggregator's step(): %s",
|
aggr->err = newSVpvf("error during aggregator's step(): %s",
|
||||||
SvPV_nolen(ERRSV));
|
SvPV_nolen(ERRSV));
|
||||||
POPs;
|
POPs;
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1122,7 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
aggrInfo *aggr, myAggr;
|
aggrInfo *aggr, myAggr;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
aggr = sqlite3_aggregate_context (context, sizeof (aggrInfo));
|
aggr = sqlite3_aggregate_context(context, sizeof (aggrInfo));
|
||||||
|
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
|
@ -1147,19 +1145,19 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
|
|
||||||
if ( SvTRUE(ERRSV) ) {
|
if ( SvTRUE(ERRSV) ) {
|
||||||
aggr->err = newSVpvf ("error during aggregator's finalize(): %s",
|
aggr->err = newSVpvf("error during aggregator's finalize(): %s",
|
||||||
SvPV_nolen(ERRSV) ) ;
|
SvPV_nolen(ERRSV) ) ;
|
||||||
POPs;
|
POPs;
|
||||||
} else if ( count != 1 ) {
|
} else if ( count != 1 ) {
|
||||||
int i;
|
int i;
|
||||||
aggr->err = newSVpvf( "finalize() should return 1 value, got %d",
|
aggr->err = newSVpvf("finalize() should return 1 value, got %d",
|
||||||
count );
|
count );
|
||||||
/* Clear the stack */
|
/* Clear the stack */
|
||||||
for ( i=0; i<count; i++ ) {
|
for ( i=0; i<count; i++ ) {
|
||||||
POPs;
|
POPs;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sqlite_db_set_result(aTHX_ context, POPs, 0 );
|
sqlite_db_set_result(aTHX_ context, POPs, 0);
|
||||||
}
|
}
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
}
|
}
|
||||||
|
@ -1168,7 +1166,7 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
warn( "DBD::SQLite: error in aggregator cannot be reported to SQLite: %s",
|
warn( "DBD::SQLite: error in aggregator cannot be reported to SQLite: %s",
|
||||||
SvPV_nolen( aggr->err ) );
|
SvPV_nolen( aggr->err ) );
|
||||||
|
|
||||||
/* sqlite_db_set_result(aTHX_ context, aggr->err, 1 ); */
|
/* sqlite_db_set_result(aTHX_ context, aggr->err, 1); */
|
||||||
SvREFCNT_dec( aggr->err );
|
SvREFCNT_dec( aggr->err );
|
||||||
aggr->err = NULL;
|
aggr->err = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1183,35 +1181,33 @@ sqlite_db_aggr_finalize_dispatcher( sqlite3_context *context )
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_pkg )
|
sqlite_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_pkg)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int rc;
|
||||||
|
|
||||||
/* Copy the aggregate reference */
|
/* Copy the aggregate reference */
|
||||||
SV *aggr_pkg_copy = newSVsv(aggr_pkg);
|
SV *aggr_pkg_copy = newSVsv(aggr_pkg);
|
||||||
av_push( imp_dbh->aggregates, aggr_pkg_copy );
|
av_push( imp_dbh->aggregates, aggr_pkg_copy );
|
||||||
|
|
||||||
retval = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
rc = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,
|
||||||
aggr_pkg_copy,
|
aggr_pkg_copy,
|
||||||
NULL,
|
NULL,
|
||||||
sqlite_db_aggr_step_dispatcher,
|
sqlite_db_aggr_step_dispatcher,
|
||||||
sqlite_db_aggr_finalize_dispatcher
|
sqlite_db_aggr_finalize_dispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( retval != SQLITE_OK )
|
if ( rc != SQLITE_OK ) {
|
||||||
{
|
|
||||||
char* const errmsg = form("sqlite_create_aggregate failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
char* const errmsg = form("sqlite_create_aggregate failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_collation_dispatcher(
|
sqlite_db_collation_dispatcher(void *func, int len1, const void *string1,
|
||||||
void *func, int len1, const void *string1,
|
int len2, const void *string2)
|
||||||
int len2, const void *string2)
|
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
@ -1221,8 +1217,8 @@ sqlite_db_collation_dispatcher(
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs( sv_2mortal ( newSVpvn( string1, len1) ) );
|
XPUSHs( sv_2mortal( newSVpvn( string1, len1) ) );
|
||||||
XPUSHs( sv_2mortal ( newSVpvn( string2, len2) ) );
|
XPUSHs( sv_2mortal( newSVpvn( string2, len2) ) );
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
n_retval = call_sv(func, G_SCALAR);
|
n_retval = call_sv(func, G_SCALAR);
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
|
@ -1240,9 +1236,8 @@ sqlite_db_collation_dispatcher(
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_collation_dispatcher_utf8(
|
sqlite_db_collation_dispatcher_utf8(void *func, int len1, const void *string1,
|
||||||
void *func, int len1, const void *string1,
|
int len2, const void *string2)
|
||||||
int len2, const void *string2)
|
|
||||||
{
|
{
|
||||||
dTHX;
|
dTHX;
|
||||||
dSP;
|
dSP;
|
||||||
|
@ -1253,12 +1248,12 @@ sqlite_db_collation_dispatcher_utf8(
|
||||||
ENTER;
|
ENTER;
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
sv1 = newSVpvn( string1, len1);
|
sv1 = newSVpvn(string1, len1);
|
||||||
SvUTF8_on(sv1);
|
SvUTF8_on(sv1);
|
||||||
sv2 = newSVpvn( string2, len2);
|
sv2 = newSVpvn(string2, len2);
|
||||||
SvUTF8_on(sv2);
|
SvUTF8_on(sv2);
|
||||||
XPUSHs( sv_2mortal ( sv1 ) );
|
XPUSHs( sv_2mortal( sv1 ) );
|
||||||
XPUSHs( sv_2mortal ( sv2 ) );
|
XPUSHs( sv_2mortal( sv2 ) );
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
n_retval = call_sv(func, G_SCALAR);
|
n_retval = call_sv(func, G_SCALAR);
|
||||||
SPAGAIN;
|
SPAGAIN;
|
||||||
|
@ -1276,7 +1271,7 @@ sqlite_db_collation_dispatcher_utf8(
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func )
|
sqlite_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int rv, rv2;
|
int rv, rv2;
|
||||||
|
@ -1317,7 +1312,7 @@ sqlite_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func )
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite_db_collation_needed_dispatcher (
|
sqlite_db_collation_needed_dispatcher(
|
||||||
void *dbh,
|
void *dbh,
|
||||||
sqlite3* db, /* unused */
|
sqlite3* db, /* unused */
|
||||||
int eTextRep, /* unused */
|
int eTextRep, /* unused */
|
||||||
|
@ -1333,7 +1328,7 @@ sqlite_db_collation_needed_dispatcher (
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
XPUSHs( dbh );
|
XPUSHs( dbh );
|
||||||
XPUSHs( sv_2mortal ( newSVpv( collation_name, 0) ) );
|
XPUSHs( sv_2mortal( newSVpv( collation_name, 0) ) );
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
|
||||||
call_sv( imp_dbh->collation_needed_callback, G_VOID );
|
call_sv( imp_dbh->collation_needed_callback, G_VOID );
|
||||||
|
@ -1345,7 +1340,7 @@ sqlite_db_collation_needed_dispatcher (
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sqlite_db_collation_needed(pTHX_ SV *dbh, SV *callback )
|
sqlite_db_collation_needed(pTHX_ SV *dbh, SV *callback)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
|
|
||||||
|
@ -1385,74 +1380,74 @@ sqlite_db_generic_callback_dispatcher( void *callback )
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler )
|
sqlite_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
|
|
||||||
if (!SvOK(handler)) {
|
if (!SvOK(handler)) {
|
||||||
/* remove previous handler */
|
/* remove previous handler */
|
||||||
sqlite3_progress_handler( imp_dbh->db, 0, NULL, NULL);
|
sqlite3_progress_handler( imp_dbh->db, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SV *handler_sv = newSVsv(handler);
|
SV *handler_sv = newSVsv(handler);
|
||||||
|
|
||||||
/* Copy the handler ref so that it can be deallocated at disconnect */
|
/* Copy the handler ref so that it can be deallocated at disconnect */
|
||||||
av_push( imp_dbh->functions, handler_sv );
|
av_push( imp_dbh->functions, handler_sv );
|
||||||
|
|
||||||
/* Register the func within sqlite3 */
|
/* Register the func within sqlite3 */
|
||||||
sqlite3_progress_handler( imp_dbh->db, n_opcodes,
|
sqlite3_progress_handler( imp_dbh->db, n_opcodes,
|
||||||
sqlite_db_generic_callback_dispatcher,
|
sqlite_db_generic_callback_dispatcher,
|
||||||
handler_sv );
|
handler_sv );
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
sqlite_db_commit_hook( pTHX_ SV *dbh, SV *hook )
|
sqlite_db_commit_hook(pTHX_ SV *dbh, SV *hook)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
void *retval;
|
void *retval;
|
||||||
|
|
||||||
if (!SvOK(hook)) {
|
if (!SvOK(hook)) {
|
||||||
/* remove previous hook */
|
/* remove previous hook */
|
||||||
retval = sqlite3_commit_hook( imp_dbh->db, NULL, NULL );
|
retval = sqlite3_commit_hook( imp_dbh->db, NULL, NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SV *hook_sv = newSVsv( hook );
|
SV *hook_sv = newSVsv( hook );
|
||||||
|
|
||||||
/* Copy the handler ref so that it can be deallocated at disconnect */
|
/* Copy the handler ref so that it can be deallocated at disconnect */
|
||||||
av_push( imp_dbh->functions, hook_sv );
|
av_push( imp_dbh->functions, hook_sv );
|
||||||
|
|
||||||
/* Register the hook within sqlite3 */
|
/* Register the hook within sqlite3 */
|
||||||
retval = sqlite3_commit_hook( imp_dbh->db,
|
retval = sqlite3_commit_hook( imp_dbh->db,
|
||||||
sqlite_db_generic_callback_dispatcher,
|
sqlite_db_generic_callback_dispatcher,
|
||||||
hook_sv );
|
hook_sv );
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval ? newSVsv(retval) : &PL_sv_undef;
|
return retval ? newSVsv(retval) : &PL_sv_undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
sqlite_db_rollback_hook( pTHX_ SV *dbh, SV *hook )
|
sqlite_db_rollback_hook(pTHX_ SV *dbh, SV *hook)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
void *retval;
|
void *retval;
|
||||||
|
|
||||||
if (!SvOK(hook)) {
|
if (!SvOK(hook)) {
|
||||||
/* remove previous hook */
|
/* remove previous hook */
|
||||||
retval = sqlite3_rollback_hook( imp_dbh->db, NULL, NULL );
|
retval = sqlite3_rollback_hook( imp_dbh->db, NULL, NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SV *hook_sv = newSVsv( hook );
|
SV *hook_sv = newSVsv( hook );
|
||||||
|
|
||||||
/* Copy the handler ref so that it can be deallocated at disconnect */
|
/* Copy the handler ref so that it can be deallocated at disconnect */
|
||||||
av_push( imp_dbh->functions, hook_sv );
|
av_push( imp_dbh->functions, hook_sv );
|
||||||
|
|
||||||
/* Register the hook within sqlite3 */
|
/* Register the hook within sqlite3 */
|
||||||
retval = sqlite3_rollback_hook( imp_dbh->db,
|
retval = sqlite3_rollback_hook( imp_dbh->db,
|
||||||
(void(*)(void *))
|
(void(*)(void *))
|
||||||
sqlite_db_generic_callback_dispatcher,
|
sqlite_db_generic_callback_dispatcher,
|
||||||
hook_sv );
|
hook_sv );
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval ? newSVsv(retval) : &PL_sv_undef;
|
return retval ? newSVsv(retval) : &PL_sv_undef;
|
||||||
|
@ -1470,10 +1465,10 @@ sqlite_db_update_dispatcher( void *callback, int op,
|
||||||
SAVETMPS;
|
SAVETMPS;
|
||||||
PUSHMARK(SP);
|
PUSHMARK(SP);
|
||||||
|
|
||||||
XPUSHs( sv_2mortal ( newSViv ( op ) ) );
|
XPUSHs( sv_2mortal( newSViv( op ) ) );
|
||||||
XPUSHs( sv_2mortal ( newSVpv ( database, 0 ) ) );
|
XPUSHs( sv_2mortal( newSVpv( database, 0 ) ) );
|
||||||
XPUSHs( sv_2mortal ( newSVpv ( table, 0 ) ) );
|
XPUSHs( sv_2mortal( newSVpv( table, 0 ) ) );
|
||||||
XPUSHs( sv_2mortal ( newSViv ( rowid ) ) );
|
XPUSHs( sv_2mortal( newSViv( rowid ) ) );
|
||||||
PUTBACK;
|
PUTBACK;
|
||||||
|
|
||||||
call_sv( callback, G_VOID );
|
call_sv( callback, G_VOID );
|
||||||
|
@ -1485,25 +1480,25 @@ sqlite_db_update_dispatcher( void *callback, int op,
|
||||||
}
|
}
|
||||||
|
|
||||||
SV*
|
SV*
|
||||||
sqlite_db_update_hook( pTHX_ SV *dbh, SV *hook )
|
sqlite_db_update_hook(pTHX_ SV *dbh, SV *hook)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
void *retval;
|
void *retval;
|
||||||
|
|
||||||
if (!SvOK(hook)) {
|
if (!SvOK(hook)) {
|
||||||
/* remove previous hook */
|
/* remove previous hook */
|
||||||
retval = sqlite3_update_hook( imp_dbh->db, NULL, NULL );
|
retval = sqlite3_update_hook( imp_dbh->db, NULL, NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SV *hook_sv = newSVsv( hook );
|
SV *hook_sv = newSVsv( hook );
|
||||||
|
|
||||||
/* Copy the handler ref so that it can be deallocated at disconnect */
|
/* Copy the handler ref so that it can be deallocated at disconnect */
|
||||||
av_push( imp_dbh->functions, hook_sv );
|
av_push( imp_dbh->functions, hook_sv );
|
||||||
|
|
||||||
/* Register the hook within sqlite3 */
|
/* Register the hook within sqlite3 */
|
||||||
retval = sqlite3_update_hook( imp_dbh->db,
|
retval = sqlite3_update_hook( imp_dbh->db,
|
||||||
sqlite_db_update_dispatcher,
|
sqlite_db_update_dispatcher,
|
||||||
hook_sv );
|
hook_sv );
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval ? newSVsv(retval) : &PL_sv_undef;
|
return retval ? newSVsv(retval) : &PL_sv_undef;
|
||||||
|
@ -1554,25 +1549,25 @@ sqlite_db_authorizer_dispatcher (
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sqlite_db_set_authorizer( pTHX_ SV *dbh, SV *authorizer )
|
sqlite_db_set_authorizer(pTHX_ SV *dbh, SV *authorizer)
|
||||||
{
|
{
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!SvOK(authorizer)) {
|
if (!SvOK(authorizer)) {
|
||||||
/* remove previous hook */
|
/* remove previous hook */
|
||||||
retval = sqlite3_set_authorizer( imp_dbh->db, NULL, NULL );
|
retval = sqlite3_set_authorizer( imp_dbh->db, NULL, NULL );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SV *authorizer_sv = newSVsv( authorizer );
|
SV *authorizer_sv = newSVsv( authorizer );
|
||||||
|
|
||||||
/* Copy the coderef so that it can be deallocated at disconnect */
|
/* Copy the coderef so that it can be deallocated at disconnect */
|
||||||
av_push( imp_dbh->functions, authorizer_sv );
|
av_push( imp_dbh->functions, authorizer_sv );
|
||||||
|
|
||||||
/* Register the hook within sqlite3 */
|
/* Register the hook within sqlite3 */
|
||||||
retval = sqlite3_set_authorizer( imp_dbh->db,
|
retval = sqlite3_set_authorizer( imp_dbh->db,
|
||||||
sqlite_db_authorizer_dispatcher,
|
sqlite_db_authorizer_dispatcher,
|
||||||
authorizer_sv );
|
authorizer_sv );
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1597,6 +1592,8 @@ sqlite_db_backup_from_file(pTHX_ SV *dbh, char *filename)
|
||||||
{
|
{
|
||||||
char* const errmsg = form("sqlite_backup_from_file failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
char* const errmsg = form("sqlite_backup_from_file failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
||||||
|
if (pFrom)
|
||||||
|
sqlite3_close(pFrom);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1637,6 +1634,8 @@ sqlite_db_backup_to_file(pTHX_ SV *dbh, char *filename)
|
||||||
{
|
{
|
||||||
char* const errmsg = form("sqlite_backup_to_file failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
char* const errmsg = form("sqlite_backup_to_file failed with error %s", sqlite3_errmsg(imp_dbh->db));
|
||||||
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
|
||||||
|
if (pTo)
|
||||||
|
sqlite3_close(pTo);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue