SQLite

Check-in [f89b54f414]
Login

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

Overview
Comment:Fix various error handling conditions on the cell overwrite optimization. Fix a test case so that it works with the new optimization.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | cell-overwrite-prototype
Files: files | file ages | folders
SHA3-256: f89b54f41405ed7e28132f66b8a0c690a087c2412c8f55790c2beabb0b521645
User & Date: drh 2018-05-03 16:56:06.556
Context
2018-05-04
19:18
Merge enhancements from trunk. (check-in: 9650f71b82 user: drh tags: cell-overwrite-prototype)
2018-05-03
16:56
Fix various error handling conditions on the cell overwrite optimization. Fix a test case so that it works with the new optimization. (check-in: f89b54f414 user: drh tags: cell-overwrite-prototype)
14:07
The BtCursor.info fields are only valid if info.nSize!=0. (check-in: 54c537eead user: drh tags: cell-overwrite-prototype)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
8172
8173
8174
8175
8176
8177
8178
8179


8180
8181
8182
8183
8184
8185
8186
      if( rc ) return rc;
      memset(pDest + i, 0, iAmt - i);
    }
  }else{
    if( nData<iAmt ){
      /* Mixed read data and zeros at the end.  Make a recursive call
      ** to write the zeros then fall through to write the real data */
      btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData, iAmt-nData);


      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }







|
>
>







8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
      if( rc ) return rc;
      memset(pDest + i, 0, iAmt - i);
    }
  }else{
    if( nData<iAmt ){
      /* Mixed read data and zeros at the end.  Make a recursive call
      ** to write the zeros then fall through to write the real data */
      int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
                                 iAmt-nData);
      if( rc ) return rc;
      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230


8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
  ovflPgno = get4byte(pCur->info.pPayload + iOffset);
  pBt = pPage->pBt;
  ovflPageSize = pBt->usableSize - 4;
  do{
    rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
    if( rc ) return rc;
    if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
      return SQLITE_CORRUPT_BKPT;
    }
    if( iOffset+ovflPageSize<nTotal ){
      ovflPgno = get4byte(pPage->aData);
    }else{
      ovflPageSize = nTotal - iOffset;
    }
    rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
                               iOffset, ovflPageSize);


    if( rc ) return rc;
    iOffset += ovflPageSize;
    sqlite3PagerUnref(pPage->pDbPage);
  }while( iOffset<nTotal );
  return SQLITE_OK;    
}


/*
** Insert a new record into the BTree.  The content of the new record







|
|
|
|
|
|
|
|
|
>
>


<







8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236

8237
8238
8239
8240
8241
8242
8243
  ovflPgno = get4byte(pCur->info.pPayload + iOffset);
  pBt = pPage->pBt;
  ovflPageSize = pBt->usableSize - 4;
  do{
    rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
    if( rc ) return rc;
    if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
      rc = SQLITE_CORRUPT_BKPT;
    }else{
      if( iOffset+ovflPageSize<nTotal ){
        ovflPgno = get4byte(pPage->aData);
      }else{
        ovflPageSize = nTotal - iOffset;
      }
      rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
                                 iOffset, ovflPageSize);
    }
    sqlite3PagerUnref(pPage->pDbPage);
    if( rc ) return rc;
    iOffset += ovflPageSize;

  }while( iOffset<nTotal );
  return SQLITE_OK;    
}


/*
** Insert a new record into the BTree.  The content of the new record
Changes to test/pager1.test.
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
do_test pager1-5.5.1 {
  sqlite3 db test.db
  execsql { 
    ATTACH 'test.db2' AS aux;
    PRAGMA journal_mode = PERSIST;
    CREATE TABLE t3(a, b);
    INSERT INTO t3 SELECT randomblob(1500), randomblob(1500) FROM t1;
    UPDATE t3 SET b = randomblob(1500);
  }
  expr [file size test.db-journal] > 15000
} {1}
do_test pager1-5.5.2 {
  execsql {
    PRAGMA synchronous = full;
    BEGIN;







|







1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
do_test pager1-5.5.1 {
  sqlite3 db test.db
  execsql { 
    ATTACH 'test.db2' AS aux;
    PRAGMA journal_mode = PERSIST;
    CREATE TABLE t3(a, b);
    INSERT INTO t3 SELECT randomblob(1500), randomblob(1500) FROM t1;
    UPDATE t3 SET b = randomblob(1501);
  }
  expr [file size test.db-journal] > 15000
} {1}
do_test pager1-5.5.2 {
  execsql {
    PRAGMA synchronous = full;
    BEGIN;