SQLite

Check-in [e8e879aca6]
Login

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

Overview
Comment:Fix an obscure cache corruption that could occur after an SQLITE_FULL error. (CVS 3964)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e8e879aca67dee959bab42627028964c474da72f
User & Date: danielk1977 2007-05-09 15:56:40.000
Context
2007-05-09
20:31
Fix a problem with strange expressions being fed to an ATTACH or DETACH statement. (CVS 3965) (check-in: 0c91dc9ee0 user: drh tags: trunk)
15:56
Fix an obscure cache corruption that could occur after an SQLITE_FULL error. (CVS 3964) (check-in: e8e879aca6 user: danielk1977 tags: trunk)
11:37
Add further test cases for compile time limits. (CVS 3963) (check-in: 9bf2c594a4 user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.338 2007/05/08 21:45:28 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include "os.h"
#include "pager.h"
#include <assert.h>
#include <string.h>







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.339 2007/05/09 15:56:40 danielk1977 Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
#include "os.h"
#include "pager.h"
#include <assert.h>
#include <string.h>
3073
3074
3075
3076
3077
3078
3079

3080
3081
3082
3083
3084
3085
3086
    }

    /* Populate the page with data, either by reading from the database
    ** file, or by setting the entire page to zero.
    */
    if( nMax<(int)pgno || MEMDB || (noContent && !pPager->alwaysRollback) ){
      if( pgno>pPager->mxPgno ){

        return SQLITE_FULL;
      }
      memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
      pPg->needRead = noContent && !pPager->alwaysRollback;
      IOTRACE(("ZERO %p %d\n", pPager, pgno));
    }else{
      rc = readDbPage(pPager, pPg, pgno);







>







3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
    }

    /* Populate the page with data, either by reading from the database
    ** file, or by setting the entire page to zero.
    */
    if( nMax<(int)pgno || MEMDB || (noContent && !pPager->alwaysRollback) ){
      if( pgno>pPager->mxPgno ){
        sqlite3PagerUnref(pPg);
        return SQLITE_FULL;
      }
      memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
      pPg->needRead = noContent && !pPager->alwaysRollback;
      IOTRACE(("ZERO %p %d\n", pPager, pgno));
    }else{
      rc = readDbPage(pPager, pPg, pgno);
Changes to test/sqllimits1.test.
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 contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.5 2007/05/09 11:37:23 danielk1977 Exp $

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

# Test organization:
#
#     sqllimits-1.*:  SQLITE_MAX_LENGTH







|







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 contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.6 2007/05/09 15:56:40 danielk1977 Exp $

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

# Test organization:
#
#     sqllimits-1.*:  SQLITE_MAX_LENGTH
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

do_test sqllimits1-3.6 {
  catchsql {
    SELECT COUNT(*) FROM trig;
  }
} {0 7}


#--------------------------------------------------------------------
# Test cases sqllimits1-4.* test the SQLITE_MAX_COLUMN limit.
#
do_test sqllimits-1.4.1 {
  # Columns in a table.
  set cols [list]
  for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} {







<







153
154
155
156
157
158
159

160
161
162
163
164
165
166

do_test sqllimits1-3.6 {
  catchsql {
    SELECT COUNT(*) FROM trig;
  }
} {0 7}


#--------------------------------------------------------------------
# Test cases sqllimits1-4.* test the SQLITE_MAX_COLUMN limit.
#
do_test sqllimits-1.4.1 {
  # Columns in a table.
  set cols [list]
  for {set i 0} {$i <= $SQLITE_MAX_COLUMN} {incr i} {
239
240
241
242
243
244
245














246
247
248
249
250
251
252

#--------------------------------------------------------------------
# These tests - sqllimits-5.* - test that the SQLITE_MAX_EXPR_LENGTH
# limit is enforced. The limit refers to the number of terms in 
# the expression.
#
# TODO















#--------------------------------------------------------------------
# Test cases sqllimits-6.* test that the SQLITE_MAX_VDBE_OP
# limit works as expected. The limit refers to the number of opcodes
# in a single VDBE program.
#
# TODO







>
>
>
>
>
>
>
>
>
>
>
>
>
>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265

#--------------------------------------------------------------------
# These tests - sqllimits-5.* - test that the SQLITE_MAX_EXPR_LENGTH
# limit is enforced. The limit refers to the number of terms in 
# the expression.
#
# TODO
do_test sqllimits-1.5.1 {
  execsql {
    PRAGMA max_page_count = 1000000;  -- 1 GB
    CREATE TABLE v0(a);
  }
  db transaction {
    for {set i 1} {$i < 2000} {incr i} {
      set expr "([string repeat {a AND } 50]a AND a) AS a"
      execsql [subst {
        CREATE VIEW v${i} AS SELECT $expr FROM v0
      }]
    }
  }
} {}

#--------------------------------------------------------------------
# Test cases sqllimits-6.* test that the SQLITE_MAX_VDBE_OP
# limit works as expected. The limit refers to the number of opcodes
# in a single VDBE program.
#
# TODO