~ubuntu-branches/ubuntu/maverick/sqlite3/maverick-updates

« back to all changes in this revision

Viewing changes to test/tkt2920.test

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2008-10-01 20:16:18 UTC
  • mfrom: (3.1.20 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081001201618-yfvqqj1qs29wdtcc
Tags: 3.5.9-5
Backport fix for distinct on indexes (closes: #500792).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# 2008 Feb 1
 
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
#
 
12
# This file is to test that ticket #2920 is fixed.
 
13
#
 
14
# $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $
 
15
#
 
16
 
 
17
set testdir [file dirname $argv0]
 
18
source $testdir/tester.tcl
 
19
 
 
20
# Create a database file that is full.
 
21
#
 
22
do_test tkt2920-1.1 {
 
23
  db eval {
 
24
    PRAGMA page_size=1024;
 
25
    PRAGMA max_page_count=40;
 
26
    PRAGMA auto_vacuum=0;
 
27
    CREATE TABLE filler (fill);
 
28
  }
 
29
  file size test.db
 
30
} {2048}
 
31
do_test tkt2920-1.2 {
 
32
  db eval BEGIN
 
33
  for {set i 0} {$i<34} {incr i} {
 
34
    db eval {INSERT INTO filler VALUES(randomblob(1024))}
 
35
  }
 
36
  db eval COMMIT
 
37
}  {}
 
38
 
 
39
# Try to add a single new page to the full database.  We get
 
40
# a disk full error.  But this does not corrupt the database.
 
41
#
 
42
do_test tkt2920-1.3 {
 
43
  db eval BEGIN
 
44
  catchsql {
 
45
     INSERT INTO filler VALUES(randomblob(1024))
 
46
  }
 
47
} {1 {database or disk is full}}
 
48
integrity_check tkt2920-1.4
 
49
 
 
50
# Increase the maximum size of the database file by 1 page,
 
51
# but then try to add a two-page record.  This also fails.
 
52
#
 
53
do_test tkt2920-1.5 {
 
54
  db eval {PRAGMA max_page_count=41}
 
55
  catchsql {
 
56
     INSERT INTO filler VALUES(randomblob(2048))
 
57
  }
 
58
} {1 {database or disk is full}}
 
59
integrity_check tkt2920-1.6
 
60
 
 
61
# Increase the maximum size of the database by one more page.
 
62
# This time the insert works.
 
63
#
 
64
do_test tkt2920-1.7 {
 
65
  db eval {PRAGMA max_page_count=42}
 
66
  catchsql {
 
67
     INSERT INTO filler VALUES(randomblob(2048))
 
68
  }
 
69
} {0 {}}
 
70
integrity_check tkt2920-1.8
 
71
 
 
72
# The previous errors cancelled the transaction.
 
73
#
 
74
do_test tkt2920-1.9 {
 
75
  catchsql {COMMIT}
 
76
} {1 {cannot commit - no transaction is active}}
 
77
 
 
78
finish_test