1
0
Fork 0
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:
Kenichi Ishigaki 2009-10-18 15:07:17 +00:00
parent 234d619b21
commit a8ab9bd263

View file

@ -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 *datatype, *collseq;
int notnull, primary, autoinc;
int retval = sqlite3_table_column_metadata(imp_dbh->db, database, tablename, fieldname, &datatype, &collseq, &notnull, &primary, &autoinc);
if (retval != SQLITE_OK) {
int rc = sqlite3_table_column_metadata(imp_dbh->db, database, tablename, fieldname, &datatype, &collseq, &notnull, &primary, &autoinc);
if (rc != SQLITE_OK) {
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 */
}
else {
@ -957,22 +957,21 @@ int
sqlite_db_create_function(pTHX_ SV *dbh, const char *name, int argc, SV *func)
{
D_imp_dbh(dbh);
int retval;
int rc;
/* Copy the function reference */
SV *func_sv = newSVsv(func);
av_push( imp_dbh->functions, func_sv );
/* 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,
imp_dbh->unicode ? sqlite_db_func_dispatcher_unicode
: sqlite_db_func_dispatcher_no_unicode,
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));
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
return FALSE;
}
return TRUE;
@ -982,13 +981,12 @@ int
sqlite_db_enable_load_extension(pTHX_ SV *dbh, int onoff)
{
D_imp_dbh(dbh);
int retval;
int rc;
retval = sqlite3_enable_load_extension( imp_dbh->db, onoff );
if ( retval != SQLITE_OK )
{
rc = sqlite3_enable_load_extension( imp_dbh->db, onoff );
if ( rc != SQLITE_OK ) {
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 TRUE;
@ -1186,31 +1184,29 @@ int
sqlite_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_pkg)
{
D_imp_dbh(dbh);
int retval;
int rc;
/* Copy the aggregate reference */
SV *aggr_pkg_copy = newSVsv(aggr_pkg);
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,
NULL,
sqlite_db_aggr_step_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));
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, retval, errmsg);
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
return FALSE;
}
return TRUE;
}
int
sqlite_db_collation_dispatcher(
void *func, int len1, const void *string1,
sqlite_db_collation_dispatcher(void *func, int len1, const void *string1,
int len2, const void *string2)
{
dTHX;
@ -1240,8 +1236,7 @@ sqlite_db_collation_dispatcher(
}
int
sqlite_db_collation_dispatcher_utf8(
void *func, int len1, const void *string1,
sqlite_db_collation_dispatcher_utf8(void *func, int len1, const void *string1,
int len2, const void *string2)
{
dTHX;
@ -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));
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (pFrom)
sqlite3_close(pFrom);
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));
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (pTo)
sqlite3_close(pTo);
return FALSE;
}