From e471875089cb82612f6889b09e5ea28d33588ad0 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Wed, 6 May 2009 10:14:47 +0000 Subject: [PATCH] DBD-SQLite: fixed return value of create_function --- SQLite.xs | 6 ++++-- dbdimp.c | 18 ++++++++++-------- dbdimp.h | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/SQLite.xs b/SQLite.xs index c75b3a5..4fd756a 100644 --- a/SQLite.xs +++ b/SQLite.xs @@ -71,7 +71,7 @@ create_aggregate(dbh, name, argc, aggr) sqlite3_db_create_aggregate(aTHX_ dbh, name, argc, aggr ); } -void +static int create_collation(dbh, name, func) SV *dbh char *name @@ -80,8 +80,10 @@ create_collation(dbh, name, func) DBD::SQLite::db::sqlite_create_collation = 1 CODE: { - sqlite3_db_create_collation(aTHX_ dbh, name, func ); + RETVAL = sqlite3_db_create_collation(aTHX_ dbh, name, func ); } + OUTPUT: + RETVAL static int progress_handler(dbh, n_opcodes, handler) diff --git a/dbdimp.c b/dbdimp.c index 005ad03..aa693a1 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -935,7 +935,7 @@ sqlite_db_func_dispatcher_no_unicode(sqlite3_context *context, int argc, sqlite3 sqlite_db_func_dispatcher(0, context, argc, value); } -void +int sqlite3_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func ) { D_imp_dbh(dbh); @@ -955,7 +955,9 @@ sqlite3_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func ) { 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); + return FALSE; } + return TRUE; } void @@ -1247,7 +1249,7 @@ sqlite_db_collation_dispatcher_utf8( return cmp; } -void +int sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func ) { D_imp_dbh(dbh); @@ -1260,12 +1262,12 @@ sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func ) /* Check that this is a proper collation function */ rv = sqlite_db_collation_dispatcher(func_sv, 2, aa, 2, aa); if (rv != 0) { - warn("improper collation function: %s(aa, aa) returns %d!", name, rv); + sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "improper collation function: %s(aa, aa) returns %d!", name, rv); } rv = sqlite_db_collation_dispatcher(func_sv, 2, aa, 2, zz); rv2 = sqlite_db_collation_dispatcher(func_sv, 2, zz, 2, aa); if (rv2 != (rv * -1)) { - warn("improper collation function: '%s' is not symmetric", name); + sqlite_trace(dbh, (imp_xxh_t*)imp_dbh, 2, "improper collation function: '%s' is not symmetric", name); } /* Copy the func reference so that it can be deallocated at disconnect */ @@ -1273,10 +1275,10 @@ sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func ) /* Register the func within sqlite3 */ rv = sqlite3_create_collation( - imp_dbh->db, name, SQLITE_UTF8, - func_sv, - imp_dbh->unicode ? sqlite_db_collation_dispatcher_utf8 - : sqlite_db_collation_dispatcher + imp_dbh->db, name, SQLITE_UTF8, + func_sv, + imp_dbh->unicode ? sqlite_db_collation_dispatcher_utf8 + : sqlite_db_collation_dispatcher ); if ( rv != SQLITE_OK ) diff --git a/dbdimp.h b/dbdimp.h index 7db74ab..f1d4a2f 100644 --- a/dbdimp.h +++ b/dbdimp.h @@ -78,10 +78,10 @@ struct aggrInfo { int inited; }; -void sqlite3_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func); +int sqlite3_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func); void sqlite3_db_enable_load_extension(pTHX_ SV *dbh, int onoff); void sqlite3_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr ); -void sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func); +int sqlite3_db_create_collation(pTHX_ SV *dbh, const char *name, SV *func); int sqlite3_db_progress_handler(pTHX_ SV *dbh, int n_opcodes, SV *handler); void sqlite_st_reset(pTHX_ SV *sth ); int sqlite_bind_col( SV *sth, imp_sth_t *imp_sth, SV *col, SV *ref, IV sql_type, SV *attribs );