/ Check-in [1ddbb537]
Login

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

Overview
Comment:Avoid leaving view-definitions with an incomplete set of column names/types in the in-memory schema if an OOM strikes while allocating the same.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:1ddbb5372e7ea8407369b88698b3fb922b62dcac72be633a17bd0e41baa369f4
User & Date: dan 2018-07-09 18:55:44
Context
2018-07-09
20:41
Add an ALWAYS() around a branch in sqlite3BtreeSkipNext() that we believe must always be true. check-in: 12be361a user: drh tags: trunk
18:55
Avoid leaving view-definitions with an incomplete set of column names/types in the in-memory schema if an OOM strikes while allocating the same. check-in: 1ddbb537 user: dan tags: trunk
18:11
Add a couple of OOM tests. check-in: 50de2a0d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2315   2315       sqlite3DeleteTable(db, pSelTab);
  2316   2316       sqlite3SelectDelete(db, pSel);
  2317   2317       db->lookaside.bDisable--;
  2318   2318     } else {
  2319   2319       nErr++;
  2320   2320     }
  2321   2321     pTable->pSchema->schemaFlags |= DB_UnresetViews;
         2322  +  if( db->mallocFailed ){
         2323  +    sqlite3DeleteColumnNames(db, pTable);
         2324  +    pTable->aCol = 0;
         2325  +    pTable->nCol = 0;
         2326  +  }
  2322   2327   #endif /* SQLITE_OMIT_VIEW */
  2323   2328     return nErr;  
  2324   2329   }
  2325   2330   #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
  2326   2331   
  2327   2332   #ifndef SQLITE_OMIT_VIEW
  2328   2333   /*

Added test/schemafault.test.

            1  +# 2018-08-19
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# Test OOM injection in schema-related operations.
           12  +#
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +source $testdir/malloc_common.tcl
           17  +set testprefix schemafault
           18  +
           19  +do_execsql_test 1.0 {
           20  +  CREATE TABLE t2(aaa INTTT);
           21  +  CREATE VIEW v2(xxx , yyy) AS SELECT aaa, aaa+1 FROM t2;
           22  +}
           23  +
           24  +do_faultsim_test 1 -faults oom-* -prep {
           25  +} -body {
           26  +  execsql { SELECT * FROM v2 }
           27  +} -test {
           28  +  faultsim_test_result {0 {}}
           29  +}
           30  +
           31  +finish_test