/ Check-in [c063bb04]
Login

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

Overview
Comment:Fix a Pager ref-count leak in the sqlite_dbpage virtual table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c063bb04da77d6847e4e254b6bb939c860e781382e34ddff8e0454d9db7552e2
User & Date: drh 2017-10-27 18:24:11
Context
2017-10-28
12:20
Add test cases from OSSFuzz to prevent a regression in co-routine processing. check-in: 689743d8 user: drh tags: trunk
2017-10-27
23:28
I was a little concerned about this check-in. Though I could not generate a failure myself, I thought it was risky. I checked it in for further testing. Then, overnight, OSSFuzz found a failure case for me. So the change is now moved out into a deadend branch. Was: Use OP_SCopy rather than OP_Copy to transfer results from a co-routine to its consumer. This undoes an earlier fix for ticket [98825a79ce] by check-in [ec6a06246e] because that problem no longer occurs due to WHERE clause push-down. Closed-Leaf check-in: 0926df09 user: drh tags: mistake
18:24
Fix a Pager ref-count leak in the sqlite_dbpage virtual table. check-in: c063bb04 user: drh tags: trunk
17:09
Handle the Ctrl-C event for the shell on Win32. check-in: c8aaf371 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/dbpage.c.

   216    216   static int dbpageFilter(
   217    217     sqlite3_vtab_cursor *pCursor, 
   218    218     int idxNum, const char *idxStr,
   219    219     int argc, sqlite3_value **argv
   220    220   ){
   221    221     DbpageCursor *pCsr = (DbpageCursor *)pCursor;
   222    222     DbpageTable *pTab = (DbpageTable *)pCursor->pVtab;
   223         -  int rc = SQLITE_OK;
          223  +  int rc;
   224    224     sqlite3 *db = pTab->db;
   225    225     Btree *pBt;
   226    226   
   227    227     /* Default setting is no rows of result */
   228    228     pCsr->pgno = 1; 
   229    229     pCsr->mxPgno = 0;
   230    230   
................................................................................
   250    250         pCsr->mxPgno = 0;
   251    251       }else{
   252    252         pCsr->mxPgno = pCsr->pgno;
   253    253       }
   254    254     }else{
   255    255       assert( pCsr->pgno==1 );
   256    256     }
          257  +  if( pCsr->pPage1 ) sqlite3PagerUnrefPageOne(pCsr->pPage1);
   257    258     rc = sqlite3PagerGet(pCsr->pPager, 1, &pCsr->pPage1, 0);
   258    259     return rc;
   259    260   }
   260    261   
   261    262   static int dbpageColumn(
   262    263     sqlite3_vtab_cursor *pCursor, 
   263    264     sqlite3_context *ctx, 

Changes to test/dbpage.test.

    52     52   do_execsql_test 160 {
    53     53     ATTACH ':memory:' AS aux1;
    54     54     PRAGMA aux1.page_size=4096;
    55     55     CREATE TABLE aux1.t2(a,b,c);
    56     56     INSERT INTO t2 VALUES(11,12,13);
    57     57     SELECT pgno, quote(substr(data,1,5)) FROM sqlite_dbpage('aux1');
    58     58   } {1 X'53514C6974' 2 X'0D00000001'}
           59  +do_execsql_test 170 {
           60  +  CREATE TABLE aux1.x3(x,y,z);
           61  +  INSERT INTO x3(x,y,z) VALUES(1,'main',1),(2,'aux1',1);
           62  +  SELECT pgno, schema, substr(data,1,6)
           63  +    FROM sqlite_dbpage, x3
           64  +   WHERE sqlite_dbpage.schema=x3.y AND sqlite_dbpage.pgno=x3.z
           65  +   ORDER BY x3.x;
           66  +} {1 main SQLite 1 aux1 SQLite}
    59     67   
    60     68   do_execsql_test 200 {
    61     69     CREATE TEMP TABLE saved_content(x);
    62     70     INSERT INTO saved_content(x) SELECT data FROM sqlite_dbpage WHERE pgno=4;
    63     71     UPDATE sqlite_dbpage SET data=zeroblob(4096) WHERE pgno=4;
    64     72   } {}
    65     73   do_catchsql_test 210 {