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

DBD-SQLite: fixed return value of create_function

This commit is contained in:
Kenichi Ishigaki 2009-05-06 10:14:47 +00:00
parent a8346d9b42
commit e471875089
3 changed files with 16 additions and 12 deletions

View file

@ -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)

View file

@ -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 )

View file

@ -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 );