SQLite

Check-in [e0d3aa75b4]
Login

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

Overview
Comment:Fix an assert() failure that can occur following a malloc() failure. Ticket #3455. (CVS 5834)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e0d3aa75b4fa0e706185a3058b5962916e30d066
User & Date: danielk1977 2008-10-22 10:45:38.000
Context
2008-10-22
16:04
Test cases for ticket #3442. (CVS 5835) (check-in: a8bb5acf70 user: shane tags: trunk)
10:45
Fix an assert() failure that can occur following a malloc() failure. Ticket #3455. (CVS 5834) (check-in: e0d3aa75b4 user: danielk1977 tags: trunk)
2008-10-21
04:30
Update the autoconf build system to include memjournal.c. (CVS 5833) (check-in: a3c810f0c8 user: danielk1977 tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/build.c.
18
19
20
21
22
23
24
25

26
27
28
29
30
31
32
18
19
20
21
22
23
24

25
26
27
28
29
30
31
32







-
+







**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.498 2008/10/06 16:18:40 danielk1977 Exp $
** $Id: build.c,v 1.499 2008/10/22 10:45:38 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
2397
2398
2399
2400
2401
2402
2403
2404

2405
2406
2407
2408
2409
2410
2411
2397
2398
2399
2400
2401
2402
2403

2404
2405
2406
2407
2408
2409
2410
2411







-
+







    ){
      /* Because the parser constructs pTblName from a single identifier,
      ** sqlite3FixSrcList can never fail. */
      assert(0);
    }
    pTab = sqlite3LocateTable(pParse, 0, pTblName->a[0].zName, 
        pTblName->a[0].zDatabase);
    if( !pTab ) goto exit_create_index;
    if( !pTab || db->mallocFailed ) goto exit_create_index;
    assert( db->aDb[iDb].pSchema==pTab->pSchema );
  }else{
    assert( pName==0 );
    pTab = pParse->pNewTable;
    if( !pTab ) goto exit_create_index;
    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
  }
Changes to test/attachmalloc.test.
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+







#    May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the ATTACH statement and
# specifically out-of-memory conditions within that command.
#
# $Id: attachmalloc.test,v 1.9 2008/08/04 20:13:27 drh Exp $
# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !memdebug||!attach {
  finish_test
41
42
43
44
45
46
47
48














49
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63








+
+
+
+
+
+
+
+
+
+
+
+
+
+

  ATTACH 'test2.db' AS two;
  CREATE TABLE two.t1(x);
  ATTACH 'test3.db' AS three;
  CREATE TABLE three.t1(x);
  ATTACH 'test4.db' AS four;
  CREATE TABLE four.t1(x);
}

do_malloc_test attachmalloc-2 -tclprep {
  file delete -force test2.db
  file delete -force test2.db-journal
  sqlite3 db2 test2.db
  db2 eval {
    CREATE TABLE t1(a, b, c);
    CREATE INDEX i1 ON t1(a, b);
  }
  db2 close
} -sqlbody {
  CREATE TABLE t1(d, e, f);
  ATTACH 'test2.db' AS db1;
}

finish_test