SQLite

Check-in [997d8afff9]
Login

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

Overview
Comment:Improved coverage for insert.c. (CVS 2213)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 997d8afff9b316aef4c5e2127c2207758ff4a703
User & Date: drh 2005-01-15 00:36:37.000
Context
2005-01-15
00:40
Improved test coverage for update.c. (CVS 2214) (check-in: 3ef95d5fe9 user: drh tags: trunk)
00:36
Improved coverage for insert.c. (CVS 2213) (check-in: 997d8afff9 user: drh tags: trunk)
2005-01-14
22:55
Add comments to the new balance_quick() routine. (CVS 2212) (check-in: 183c42eac8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/insert3.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17




18
19
20
21
22
23
24
# 2005 January 13
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.1 2005/01/14 01:22:01 drh Exp $

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





# Create a table and a corresponding insert trigger.  Do a self-insert
# into the table.
#
do_test insert3-1.0 {
  execsql {
    CREATE TABLE t1(a,b);













|



>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 2005 January 13
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing corner cases of the INSERT statement.
#
# $Id: insert3.test,v 1.2 2005/01/15 00:36:37 drh Exp $

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

# All the tests in this file require trigger support
#
ifcapable {trigger} {

# Create a table and a corresponding insert trigger.  Do a self-insert
# into the table.
#
do_test insert3-1.0 {
  execsql {
    CREATE TABLE t1(a,b);
89
90
91
92
93
94
95
96































97
    DELETE FROM t2dup;
    INSERT INTO t2(a) SELECT 1 FROM t1 LIMIT 1;
    INSERT INTO t2(b) SELECT 987 FROM t1 LIMIT 1;
    INSERT INTO t2(c) SELECT 876 FROM t1 LIMIT 1;
    SELECT * FROM t2dup;
  }
} {1 b c -1 987 c -1 b 876}
































finish_test








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

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    DELETE FROM t2dup;
    INSERT INTO t2(a) SELECT 1 FROM t1 LIMIT 1;
    INSERT INTO t2(b) SELECT 987 FROM t1 LIMIT 1;
    INSERT INTO t2(c) SELECT 876 FROM t1 LIMIT 1;
    SELECT * FROM t2dup;
  }
} {1 b c -1 987 c -1 b 876}

# Test for proper detection of malformed WHEN clauses on INSERT triggers.
#
do_test insert3-3.1 {
  execsql {
    CREATE TABLE t3(a,b,c);
    CREATE TRIGGER t3r1 BEFORE INSERT on t3 WHEN nosuchcol BEGIN
      SELECT 'illegal WHEN clause';
    END;
  }
} {}
do_test insert3-3.2 {
  catchsql {
    INSERT INTO t3 VALUES(1,2,3)
  }
} {1 {no such column: nosuchcol}}
do_test insert3-3.3 {
  execsql {
    CREATE TABLE t4(a,b,c);
    CREATE TRIGGER t4r1 AFTER INSERT on t4 WHEN nosuchcol BEGIN
      SELECT 'illegal WHEN clause';
    END;
  }
} {}
do_test insert3-3.4 {
  catchsql {
    INSERT INTO t4 VALUES(1,2,3)
  }
} {1 {no such column: nosuchcol}}

} ;# ifcapable {trigger}

finish_test