33 /* Open the sqlite3_backup object used to accomplish the transfer */
34 pBackup = sqlite3_backup_init(pFile, "main", pDb, "main");
35 if( pBackup ){
36
37 /* Each iteration of this loop copies 5 database pages from database
38 ** pDb to the backup database. If the return value of backup_step()
39 ** indicates that there are still further pages to copy, sleep for
40 ** 250 ms before repeating. */
41 do {
42 rc = sqlite3_backup_step(pBackup, 5);
43 xProgress(
44 sqlite3_backup_remaining(pBackup),
45 sqlite3_backup_pagecount(pBackup)
46 );
47 if( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){
48 sqlite3_sleep(250);
49 }
50 } while( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED );
51
52 /* Release resources allocated by backup_init(). */
53 (void)sqlite3_backup_finish(pBackup);
54 }
55 rc = sqlite3_errcode(pFile);
56 }
57
58 /* Close the database connection opened on database file zFilename
59 ** and return the result of this function. */
60 (void)sqlite3_close(pFile);
61 return rc;
62 }
作者 Stephen_Liu
|