SQLite

Check-in [d9d8a048d4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correctly detect an OOM occurring in the setDestPgsz() subroutine of backup.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d9d8a048d4b621435870b4f8dd13b2938ac2f8fd
User & Date: drh 2016-09-02 21:17:51.499
Context
2016-09-02
21:34
Add a test case for the OOM handled by the previous commit. (check-in: 9bdf7ca1b3 user: dan tags: trunk)
21:17
Correctly detect an OOM occurring in the setDestPgsz() subroutine of backup. (check-in: d9d8a048d4 user: drh tags: trunk)
17:18
Within a backup operation, ensure that a read-transaction is opened on the source database before its page size is read. This ensures the page-size used to write to the backup database is the same as its actual page-size, which is important for ZipVFS databases. (check-in: 7908fc6049 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/backup.c.
394
395
396
397
398
399
400
401


402
403
404
405
406
407
408

    /* If the destination database has not yet been locked (i.e. if this
    ** is the first call to backup_step() for the current backup operation),
    ** try to set its page size to the same as the source database. This
    ** is especially important on ZipVFS systems, as in that case it is
    ** not possible to create a database file that uses one page size by
    ** writing to it with another.  */
    if( p->bDestLocked==0 ) setDestPgsz(p);



    /* Lock the destination database, if it is not locked already. */
    if( SQLITE_OK==rc && p->bDestLocked==0
     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2)) 
    ){
      p->bDestLocked = 1;
      sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);







|
>
>







394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410

    /* If the destination database has not yet been locked (i.e. if this
    ** is the first call to backup_step() for the current backup operation),
    ** try to set its page size to the same as the source database. This
    ** is especially important on ZipVFS systems, as in that case it is
    ** not possible to create a database file that uses one page size by
    ** writing to it with another.  */
    if( p->bDestLocked==0 && rc==SQLITE_OK && setDestPgsz(p)==SQLITE_NOMEM ){
      rc = SQLITE_NOMEM;
    }

    /* Lock the destination database, if it is not locked already. */
    if( SQLITE_OK==rc && p->bDestLocked==0
     && SQLITE_OK==(rc = sqlite3BtreeBeginTrans(p->pDest, 2)) 
    ){
      p->bDestLocked = 1;
      sqlite3BtreeGetMeta(p->pDest, BTREE_SCHEMA_VERSION, &p->iDestSchema);