mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 22:28:47 -04:00
DBD-SQLite: fixed error handling of backup_(from|to)_file
This commit is contained in:
parent
47463880ee
commit
edfec1a6db
1 changed files with 44 additions and 20 deletions
32
dbdimp.c
32
dbdimp.c
|
@ -1346,7 +1346,12 @@ sqlite_db_backup_from_file(pTHX_ SV *dbh, char *filename)
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
|
|
||||||
rc = sqlite3_open(filename, &pFrom);
|
rc = sqlite3_open(filename, &pFrom);
|
||||||
if (rc==SQLITE_OK) {
|
if ( rc != SQLITE_OK )
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
pBackup = sqlite3_backup_init(imp_dbh->db, "main", pFrom, "main");
|
pBackup = sqlite3_backup_init(imp_dbh->db, "main", pFrom, "main");
|
||||||
if (pBackup) {
|
if (pBackup) {
|
||||||
|
@ -1355,8 +1360,15 @@ sqlite_db_backup_from_file(pTHX_ SV *dbh, char *filename)
|
||||||
}
|
}
|
||||||
rc = sqlite3_errcode(imp_dbh->db);
|
rc = sqlite3_errcode(imp_dbh->db);
|
||||||
(void)sqlite3_close(pFrom);
|
(void)sqlite3_close(pFrom);
|
||||||
|
|
||||||
|
if ( rc != SQLITE_OK )
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accesses the SQLite Online Backup API, and copies the currently loaded
|
/* Accesses the SQLite Online Backup API, and copies the currently loaded
|
||||||
|
@ -1374,7 +1386,12 @@ sqlite_db_backup_to_file(pTHX_ SV *dbh, char *filename)
|
||||||
D_imp_dbh(dbh);
|
D_imp_dbh(dbh);
|
||||||
|
|
||||||
rc = sqlite3_open(filename, &pTo);
|
rc = sqlite3_open(filename, &pTo);
|
||||||
if (rc==SQLITE_OK) {
|
if ( rc != SQLITE_OK )
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
pBackup = sqlite3_backup_init(pTo, "main", imp_dbh->db, "main");
|
pBackup = sqlite3_backup_init(pTo, "main", imp_dbh->db, "main");
|
||||||
if (pBackup) {
|
if (pBackup) {
|
||||||
|
@ -1383,8 +1400,15 @@ sqlite_db_backup_to_file(pTHX_ SV *dbh, char *filename)
|
||||||
}
|
}
|
||||||
rc = sqlite3_errcode(pTo);
|
rc = sqlite3_errcode(pTo);
|
||||||
(void)sqlite3_close(pTo);
|
(void)sqlite3_close(pTo);
|
||||||
|
|
||||||
|
if ( rc != SQLITE_OK )
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
|
|
Loading…
Add table
Reference in a new issue