/ Check-in [dbe41774]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make REINDEX robust in the face of malloc() errors. (CVS 3990)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dbe417745d3d4ed875715ad7083d7345d1b6a56f
User & Date: drh 2007-05-12 15:00:15
Context
2007-05-14
11:34
Remove terms with operator TK_AS from the expression tree. Ticket #2356. (CVS 3991) check-in: 5627ff74 user: drh tags: trunk
2007-05-12
15:00
Make REINDEX robust in the face of malloc() errors. (CVS 3990) check-in: dbe41774 user: drh tags: trunk
12:08
Make the ANALYZE command robust in the face of malloc() failures. (CVS 3989) check-in: c08658e1 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.429 2007/05/08 20:59:49 drh Exp $
           25  +** $Id: build.c,v 1.430 2007/05/12 15:00:15 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   #include <ctype.h>
    29     29   
    30     30   /*
    31     31   ** This routine is called when a new SQL statement is beginning to
    32     32   ** be parsed.  Initialize the pParse structure as needed.
................................................................................
  3302   3302         }
  3303   3303         return;
  3304   3304       }
  3305   3305     }
  3306   3306     iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);
  3307   3307     if( iDb<0 ) return;
  3308   3308     z = sqlite3NameFromToken(pObjName);
         3309  +  if( z==0 ) return;
  3309   3310     zDb = db->aDb[iDb].zName;
  3310   3311     pTab = sqlite3FindTable(db, z, zDb);
  3311   3312     if( pTab ){
  3312   3313       reindexTable(pParse, pTab, 0);
  3313   3314       sqliteFree(z);
  3314   3315       return;
  3315   3316     }

Changes to test/mallocA.test.

     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file contains additional out-of-memory checks (see malloc.tcl).
    12     12   #
    13         -# $Id: mallocA.test,v 1.1 2007/05/12 12:08:51 drh Exp $
           13  +# $Id: mallocA.test,v 1.2 2007/05/12 15:00:15 drh Exp $
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   
    18     18   # Only run these tests if memory debugging is turned on.
    19     19   #
    20     20   if {[info command sqlite_malloc_stat]==""} {
................................................................................
   114    114     unset ::mallocopts
   115    115   }
   116    116   
   117    117   # Construct a test database
   118    118   #
   119    119   file delete -force test.db.bu
   120    120   db eval {
   121         -  CREATE TABLE t1(a,b,c);
          121  +  CREATE TABLE t1(a COLLATE NOCASE,b,c);
   122    122     INSERT INTO t1 VALUES(1,2,3);
   123    123     INSERT INTO t1 VALUES(1,2,4);
   124    124     INSERT INTO t1 VALUES(2,3,4);
   125    125     CREATE INDEX t1i1 ON t1(a);
   126    126     CREATE INDEX t1i2 ON t1(b,c);
   127    127     CREATE TABLE t2(x,y,z);
   128    128   }
................................................................................
   129    129   db close
   130    130   file copy test.db test.db.bu
   131    131   sqlite3 db test.db
   132    132   
   133    133   
   134    134   do_malloc_test 1 -sqlbody {
   135    135     ANALYZE
          136  +}
          137  +do_malloc_test 2 -sqlbody {
          138  +  REINDEX;
          139  +}
          140  +do_malloc_test 3 -sqlbody {
          141  +  REINDEX t1;
          142  +}
          143  +do_malloc_test 4 -sqlbody {
          144  +  REINDEX main.t1;
          145  +}
          146  +do_malloc_test 5 -sqlbody {
          147  +  REINDEX nocase;
   136    148   }
   137    149   
   138    150   # Ensure that no file descriptors were leaked.
   139    151   do_test malloc-99.X {
   140    152     catch {db close}
   141    153     set sqlite_open_file_count
   142    154   } {0}
   143    155   
   144    156   file delete -force test.db.bu
   145    157   sqlite_malloc_fail 0
   146    158   finish_test