SQLite

Check-in [277dace43d]
Login

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

Overview
Comment:Fix compilation and testing when SQLITE_OMIT_TRIGGER is defined. Ticket #3786. (CVS 6464)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 277dace43d51fbc79c7a62fc841c150ecd8d0823
User & Date: danielk1977 2009-04-07 14:14:22.000
Context
2009-04-07
14:38
Fix an incorrect assert in btree.c. (CVS 6465) (check-in: 2c1f59834a user: danielk1977 tags: trunk)
14:14
Fix compilation and testing when SQLITE_OMIT_TRIGGER is defined. Ticket #3786. (CVS 6464) (check-in: 277dace43d user: danielk1977 tags: trunk)
13:48
Only enable WHERE-tracing when both TEST and DEBUG are enabled. (CVS 6463) (check-in: 55b9364925 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/sqliteInt.h.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2001 September 15
**
** 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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.851 2009/04/05 12:22:09 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
** 2001 September 15
**
** 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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.852 2009/04/07 14:14:22 danielk1977 Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_

/*
** Include the configuration header output by 'configure' if we're using the
** autoconf-based build
2533
2534
2535
2536
2537
2538
2539

2540
2541
2542
2543
2544
2545
2546
  void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
#else
# define sqlite3TriggersExist(B,C,D,E,F) 0
# define sqlite3DeleteTrigger(A,B)
# define sqlite3DropTriggerPtr(A,B)
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0

#endif

int sqlite3JoinType(Parse*, Token*, Token*, Token*);
void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
void sqlite3DeferForeignKey(Parse*, int);
#ifndef SQLITE_OMIT_AUTHORIZATION
  void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);







>







2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
  void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
#else
# define sqlite3TriggersExist(B,C,D,E,F) 0
# define sqlite3DeleteTrigger(A,B)
# define sqlite3DropTriggerPtr(A,B)
# define sqlite3UnlinkAndDeleteTrigger(A,B,C)
# define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I,J,K,L) 0
# define sqlite3TriggerList(X, Y) 0
#endif

int sqlite3JoinType(Parse*, Token*, Token*, Token*);
void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int);
void sqlite3DeferForeignKey(Parse*, int);
#ifndef SQLITE_OMIT_AUTHORIZATION
  void sqlite3AuthRead(Parse*,Expr*,Schema*,SrcList*);
Changes to test/alter2.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter2.test,v 1.13 2008/03/19 00:21:31 drh Exp $
#

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

# We have to have pragmas in order to do this test
ifcapable {!pragma} return







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#*************************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing that SQLite can handle a subtle 
# file format change that may be used in the future to implement
# "ALTER TABLE ... ADD COLUMN".
#
# $Id: alter2.test,v 1.14 2009/04/07 14:14:22 danielk1977 Exp $
#

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

# We have to have pragmas in order to do this test
ifcapable {!pragma} return
216
217
218
219
220
221
222


223
224
225
226
227
228
229
      CREATE TRIGGER abc3_t2 AFTER UPDATE OF c ON abc3 BEGIN
        INSERT INTO clog VALUES(old.c, new.c);
      END;
      UPDATE abc3 SET c = a*2;
      SELECT * FROM clog;
    }
  } {{} 2 {} 6 {} 10}


}

#---------------------------------------------------------------------
# Check that an error occurs if the database is upgraded to a file
# format that SQLite does not support (in this case 5). Note: The 
# file format is checked each time the schema is read, so changing the
# file format requires incrementing the schema cookie.







>
>







216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
      CREATE TRIGGER abc3_t2 AFTER UPDATE OF c ON abc3 BEGIN
        INSERT INTO clog VALUES(old.c, new.c);
      END;
      UPDATE abc3 SET c = a*2;
      SELECT * FROM clog;
    }
  } {{} 2 {} 6 {} 10}
} else {
  execsql { CREATE TABLE abc3(a, b); }
}

#---------------------------------------------------------------------
# Check that an error occurs if the database is upgraded to a file
# format that SQLite does not support (in this case 5). Note: The 
# file format is checked each time the schema is read, so changing the
# file format requires incrementing the schema cookie.
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
    set_file_format 2
    db close
    sqlite3 db test.db
    execsql {SELECT 1 FROM sqlite_master LIMIT 1;}
    get_file_format
  } {2}
  do_test alter2-5.2 {
    execsql {    
      VACUUM;
    }
  } {}
  do_test alter2-5.3 {
    get_file_format
  } $default_file_format
}
 
#---------------------------------------------------------------------







|
<
<







274
275
276
277
278
279
280
281


282
283
284
285
286
287
288
    set_file_format 2
    db close
    sqlite3 db test.db
    execsql {SELECT 1 FROM sqlite_master LIMIT 1;}
    get_file_format
  } {2}
  do_test alter2-5.2 {
    execsql { VACUUM }


  } {}
  do_test alter2-5.3 {
    get_file_format
  } $default_file_format
}
 
#---------------------------------------------------------------------
Changes to test/backup2.test.
9
10
11
12
13
14
15
16
17
18
19


20
21
22
23
24
25
26
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the "backup" and "restore" methods
# of the TCL interface - methods which are based on the
# sqlite3_backup_XXX API.
#
# $Id: backup2.test,v 1.3 2009/03/18 13:55:30 danielk1977 Exp $

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



# Fill a database with test data.
#
do_test backup2-1 {
  db eval {
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(randstr(8000,8000));







|



>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing the "backup" and "restore" methods
# of the TCL interface - methods which are based on the
# sqlite3_backup_XXX API.
#
# $Id: backup2.test,v 1.4 2009/04/07 14:14:23 danielk1977 Exp $

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

ifcapable !trigger||!view { finish_test ; return }

# Fill a database with test data.
#
do_test backup2-1 {
  db eval {
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(randstr(8000,8000));
Changes to test/hook.test.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# The focus of the tests in this file is the  following interface:
#
#      sqlite_commit_hook    (tests hook-1..hook-3 inclusive)
#      sqlite_update_hook    (tests hook-4-*)
#      sqlite_rollback_hook  (tests hook-5.*)
#
# $Id: hook.test,v 1.14 2009/01/03 14:04:39 drh Exp $

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

do_test hook-1.2 {
  db commit_hook
} {}







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# The focus of the tests in this file is the  following interface:
#
#      sqlite_commit_hook    (tests hook-1..hook-3 inclusive)
#      sqlite_update_hook    (tests hook-4-*)
#      sqlite_rollback_hook  (tests hook-5.*)
#
# $Id: hook.test,v 1.15 2009/04/07 14:14:23 danielk1977 Exp $

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

do_test hook-1.2 {
  db commit_hook
} {}
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
    UPDATE main t1 1 \
    UPDATE main t1 3 \
    DELETE main t1 1 \
    DELETE main t1 3 \
    DELETE main t1 4 \
]


# Update hook is not invoked for changes to sqlite_master
#
do_test hook-4.1.3 {
  set ::update_hook {}
  execsql {
    CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT RAISE(IGNORE); END;
  }
  set ::update_hook
} {}
do_test hook-4.1.4 {
  set ::update_hook {}
  execsql {
    DROP TRIGGER r1;
  }
  set ::update_hook
} {}


set ::update_hook {}
ifcapable trigger {
  do_test hook-4.2.1 {
    catchsql {
      DROP TABLE t2;
    }
    execsql {
      CREATE TABLE t2(c INTEGER PRIMARY KEY, d);
      CREATE TRIGGER t1_trigger AFTER INSERT ON t1 BEGIN







>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<
|
<







154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

179

180
181
182
183
184
185
186
    UPDATE main t1 1 \
    UPDATE main t1 3 \
    DELETE main t1 1 \
    DELETE main t1 3 \
    DELETE main t1 4 \
]

ifcapable trigger {
  # Update hook is not invoked for changes to sqlite_master
  #
  do_test hook-4.1.3 {
    set ::update_hook {}
    execsql {
      CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN SELECT RAISE(IGNORE); END;
    }
    set ::update_hook
  } {}
  do_test hook-4.1.4 {
    set ::update_hook {}
    execsql {
      DROP TRIGGER r1;
    }
    set ::update_hook
  } {}
  

  set ::update_hook {}

  do_test hook-4.2.1 {
    catchsql {
      DROP TABLE t2;
    }
    execsql {
      CREATE TABLE t2(c INTEGER PRIMARY KEY, d);
      CREATE TRIGGER t1_trigger AFTER INSERT ON t1 BEGIN
Changes to test/temptrigger.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15


16
17
18
19
20
21
22
# 2009 February 27
#
# 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.
#
#***********************************************************************
#
# $Id: temptrigger.test,v 1.1 2009/02/28 10:47:42 danielk1977 Exp $

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



# Test cases:
#
#   temptrigger-1.*: Shared cache problem.
#   temptrigger-2.*: A similar shared cache problem.
#   temptrigger-3.*: Attached database problem.
#











|



>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 2009 February 27
#
# 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.
#
#***********************************************************************
#
# $Id: temptrigger.test,v 1.2 2009/04/07 14:14:23 danielk1977 Exp $

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

ifcapable !trigger { finish_test ; return }

# Test cases:
#
#   temptrigger-1.*: Shared cache problem.
#   temptrigger-2.*: A similar shared cache problem.
#   temptrigger-3.*: Attached database problem.
#
Changes to test/tkt2767.test.
9
10
11
12
13
14
15
16
17
18
19
20


21
22
23
24
25
26
27
#
#***********************************************************************
#
# This file is to test that ticket #2767 has been fixed.
# Ticket #2767 is for a VDBE stack overflow on BEFORE
# triggers that run RAISE(IGNORE).
#
# $Id: tkt2767.test,v 1.2 2008/07/12 14:52:21 drh Exp $
#

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



do_test tkt2767-1.1 {
  execsql {
    -- Construct a table with many rows of data
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(1);
    INSERT INTO t1 VALUES(2);







|




>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#
#***********************************************************************
#
# This file is to test that ticket #2767 has been fixed.
# Ticket #2767 is for a VDBE stack overflow on BEFORE
# triggers that run RAISE(IGNORE).
#
# $Id: tkt2767.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $
#

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

ifcapable !trigger { finish_test ; return }

do_test tkt2767-1.1 {
  execsql {
    -- Construct a table with many rows of data
    CREATE TABLE t1(x);
    INSERT INTO t1 VALUES(1);
    INSERT INTO t1 VALUES(2);
Changes to test/tkt2832.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
25
# 2007 Dec 12
#
# 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 is to test that ticket #2832 has been fixed.
#
# $Id: tkt2832.test,v 1.4 2008/07/12 14:52:21 drh Exp $
#

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



do_test tkt2832-1.1 {
  execsql {
    CREATE TABLE t1(a PRIMARY KEY);
    INSERT INTO t1 VALUES(2);
    INSERT INTO t1 VALUES(1);
    INSERT INTO t1 VALUES(3);













|




>
>







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
# 2007 Dec 12
#
# 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 is to test that ticket #2832 has been fixed.
#
# $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $
#

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

ifcapable !trigger { finish_test ; return }

do_test tkt2832-1.1 {
  execsql {
    CREATE TABLE t1(a PRIMARY KEY);
    INSERT INTO t1 VALUES(2);
    INSERT INTO t1 VALUES(1);
    INSERT INTO t1 VALUES(3);
Changes to test/tkt3298.test.
8
9
10
11
12
13
14
15
16
17
18


19
20
21
22
23
24
25
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# 
# This file tests changes to the name resolution logic that occurred
# in august of 2008 and where associated with tickets #3298 and #3301
#
# $Id: tkt3298.test,v 1.2 2008/08/22 12:46:46 drh Exp $

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



do_test tkt3298-1.1 {
  execsql {
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
    INSERT INTO t1 VALUES(0, 1);
    INSERT INTO t1 VALUES(1, 1);
    INSERT INTO t1 VALUES(2, 1);







|



>
>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# 
# This file tests changes to the name resolution logic that occurred
# in august of 2008 and where associated with tickets #3298 and #3301
#
# $Id: tkt3298.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $

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

ifcapable !trigger { finish_test ; return }

do_test tkt3298-1.1 {
  execsql {
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
    INSERT INTO t1 VALUES(0, 1);
    INSERT INTO t1 VALUES(1, 1);
    INSERT INTO t1 VALUES(2, 1);
Changes to test/trace.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 implements regression tests for SQLite library.
#
# This file implements tests for the "sqlite3_trace()" API.
#
# $Id: trace.test,v 1.7 2008/01/12 21:35:57 drh Exp $

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

ifcapable !trace {
  finish_test
  return







|







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.
#
# This file implements tests for the "sqlite3_trace()" API.
#
# $Id: trace.test,v 1.8 2009/04/07 14:14:23 danielk1977 Exp $

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

ifcapable !trace {
  finish_test
  return
143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168

169
do_test trace-4.5 {
  set TRACE_OUT
} {SELECT * FROM t1}
catch {sqlite3_finalize $STMT}

# Trigger tracing.
#

do_test trace-5.1 {
  db eval {
    CREATE TRIGGER r1t1 AFTER UPDATE ON t1 BEGIN
      UPDATE t2 SET a=new.a WHERE rowid=new.rowid;
    END;
    CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
      SELECT 'hello';
    END;
  }
  set TRACE_OUT {}
  proc trace_proc cmd {
    lappend ::TRACE_OUT [string trim $cmd]
  }
  db eval {
    UPDATE t1 SET a=a+1;
  }
  set TRACE_OUT
} {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}


finish_test







>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
do_test trace-4.5 {
  set TRACE_OUT
} {SELECT * FROM t1}
catch {sqlite3_finalize $STMT}

# Trigger tracing.
#
ifcapable trigger {
  do_test trace-5.1 {
    db eval {
      CREATE TRIGGER r1t1 AFTER UPDATE ON t1 BEGIN
        UPDATE t2 SET a=new.a WHERE rowid=new.rowid;
      END;
      CREATE TRIGGER r1t2 AFTER UPDATE ON t2 BEGIN
        SELECT 'hello';
      END;
    }
    set TRACE_OUT {}
    proc trace_proc cmd {
      lappend ::TRACE_OUT [string trim $cmd]
    }
    db eval {
      UPDATE t1 SET a=a+1;
    }
    set TRACE_OUT
  } {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}
}

finish_test
Changes to test/vtabC.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is is verifying that the xUpdate, xSync, xCommit
# and xRollback methods are only invoked after an xBegin or xCreate.
# Ticket #3083.
#
# $Id: vtabC.test,v 1.1 2008/04/28 20:27:54 drh Exp $

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

ifcapable !vtab {
  finish_test
  return
}




# N will be the number of virtual tables we have defined.
#
unset -nocomplain N
for {set N 1} {$N<=20} {incr N} {
  db close







|








>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is is verifying that the xUpdate, xSync, xCommit
# and xRollback methods are only invoked after an xBegin or xCreate.
# Ticket #3083.
#
# $Id: vtabC.test,v 1.2 2009/04/07 14:14:23 danielk1977 Exp $

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

ifcapable !vtab {
  finish_test
  return
}

ifcapable !trigger { finish_test ; return }


# N will be the number of virtual tables we have defined.
#
unset -nocomplain N
for {set N 1} {$N<=20} {incr N} {
  db close