/ Check-in [6ccb589b]
Login

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

Overview
Comment:Have tests pass when SQLITE_OMIT_SCHEMA_PRAGMAS is defined. (CVS 2144)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6ccb589bd94fc7d33e07caa39e011c3628563e9b
User & Date: danielk1977 2004-11-23 10:13:03
Context
2004-11-23
10:52
Ensure the test suite runs with SQLITE_OMIT_PAGER_PRAGMAS defined. (CVS 2145) check-in: 2d1f0b92 user: danielk1977 tags: trunk
10:13
Have tests pass when SQLITE_OMIT_SCHEMA_PRAGMAS is defined. (CVS 2144) check-in: 6ccb589b user: danielk1977 tags: trunk
09:06
Fix a bug involving balance_shallow() and the sqlite_master table. (CVS 2143) check-in: 557be3ff user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/attach.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
98
99
100
101
102
103
104

105
106
107

108
109
110
111
112
113
114
...
146
147
148
149
150
151
152



153
154

155
156
157
158
159
160
161
...
198
199
200
201
202
203
204

205
206
207

208
209
210
211
212
213
214
...
245
246
247
248
249
250
251

252
253
254

255
256
257
258
259
260
261
...
264
265
266
267
268
269
270

271
272
273

274
275
276
277
278
279
280
#    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 and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.31 2004/11/22 13:35:42 danielk1977 Exp $
#

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

for {set i 2} {$i<=15} {incr i} {
  file delete -force test$i.db
................................................................................
proc db_list {db} {
  set list {}
  foreach {idx name file} [execsql {PRAGMA database_list} $db] {
    lappend list $idx $name
  }
  return $list
}

do_test attach-1.11b {
  db_list db
} {0 main 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}

do_test attach-1.12 {
  catchsql {
    ATTACH 'test.db' as db2;
  }
} {1 {database db2 is already in use}}
do_test attach-1.13 {
  catchsql {
................................................................................
    ATTACH 'test.db' as db12;
  }
} {1 {too many attached databases - max 10}}
do_test attach-1.20.1 {
  execsql {
    DETACH db5;
  }



  db_list db
} {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11}

integrity_check attach-1.20.2
execsql {select * from sqlite_temp_master}
do_test attach-1.21 {
  catchsql {
    ATTACH 'test.db' as db12;
  }
} {0 {}}
................................................................................
    DETACH db7;
    DETACH db6;
    DETACH db4;
    DETACH db3;
    DETACH db2;
  }
} {0 {}}

do_test attach-1.29 {
  db_list db
} {0 main 1 temp}


ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
      INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
................................................................................
  }
} {}
do_test attach-2.7 {
  execsql {
    SELECT type, name, tbl_name FROM db2.sqlite_master;
  }
} {table t2 t2 table tx tx trigger r1 t2}

do_test attach-2.8 {
  db_list db
} {0 main 1 temp 2 db2}

do_test attach-2.9 {
  execsql {
    CREATE INDEX i2 ON t2(x);
    SELECT * FROM t2 WHERE x>5;
  } db2
} {21 x 22 y}
do_test attach-2.10 {
................................................................................
  } db2
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
#do_test attach-2.11 {
#  catchsql { 
#    SELECT * FROM t2 WHERE x>5;
#  }
#} {1 {database schema has changed}}

do_test attach-2.12 {
  db_list db
} {0 main 1 temp 2 db2}

do_test attach-2.13 {
  catchsql {
    SELECT * FROM t2 WHERE x>5;
  }
} {0 {21 x 22 y}}
do_test attach-2.14 {
  execsql {







|







 







>



>







 







>
>
>


>







 







>



>







 







>



>







 







>



>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#    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 and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.32 2004/11/23 10:13:03 danielk1977 Exp $
#

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

for {set i 2} {$i<=15} {incr i} {
  file delete -force test$i.db
................................................................................
proc db_list {db} {
  set list {}
  foreach {idx name file} [execsql {PRAGMA database_list} $db] {
    lappend list $idx $name
  }
  return $list
}
ifcapable schema_pragmas {
do_test attach-1.11b {
  db_list db
} {0 main 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}
} ;# ifcapable schema_pragmas 
do_test attach-1.12 {
  catchsql {
    ATTACH 'test.db' as db2;
  }
} {1 {database db2 is already in use}}
do_test attach-1.13 {
  catchsql {
................................................................................
    ATTACH 'test.db' as db12;
  }
} {1 {too many attached databases - max 10}}
do_test attach-1.20.1 {
  execsql {
    DETACH db5;
  }
} {}
ifcapable schema_pragmas {
do_test attach-1.20.2 {
  db_list db
} {0 main 2 db2 3 db3 4 db4 5 db6 6 db7 7 db8 8 db9 9 db10 10 db11}
} ;# ifcapable schema_pragmas
integrity_check attach-1.20.2
execsql {select * from sqlite_temp_master}
do_test attach-1.21 {
  catchsql {
    ATTACH 'test.db' as db12;
  }
} {0 {}}
................................................................................
    DETACH db7;
    DETACH db6;
    DETACH db4;
    DETACH db3;
    DETACH db2;
  }
} {0 {}}
ifcapable schema_pragmas {
do_test attach-1.29 {
  db_list db
} {0 main 1 temp}
} ;# ifcapable schema_pragmas

ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN
      INSERT INTO tx(x1,x2,y1,y2) VALUES(OLD.x,NEW.x,OLD.y,NEW.y);
................................................................................
  }
} {}
do_test attach-2.7 {
  execsql {
    SELECT type, name, tbl_name FROM db2.sqlite_master;
  }
} {table t2 t2 table tx tx trigger r1 t2}
ifcapable schema_pragmas {
do_test attach-2.8 {
  db_list db
} {0 main 1 temp 2 db2}
} ;# ifcapable schema_pragmas
do_test attach-2.9 {
  execsql {
    CREATE INDEX i2 ON t2(x);
    SELECT * FROM t2 WHERE x>5;
  } db2
} {21 x 22 y}
do_test attach-2.10 {
................................................................................
  } db2
} {table t2 t2 table tx tx trigger r1 t2 index i2 t2}
#do_test attach-2.11 {
#  catchsql { 
#    SELECT * FROM t2 WHERE x>5;
#  }
#} {1 {database schema has changed}}
ifcapable schema_pragmas {
do_test attach-2.12 {
  db_list db
} {0 main 1 temp 2 db2}
} ;# ifcapable schema_pragmas
do_test attach-2.13 {
  catchsql {
    SELECT * FROM t2 WHERE x>5;
  }
} {0 {21 x 22 y}}
do_test attach-2.14 {
  execsql {

Changes to test/attach2.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
57
58
59
60
61
62
63

64
65
66
67

68
69
70
71
72
73
74
#    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 and DETACH commands
# and related functionality.
#
# $Id: attach2.test,v 1.29 2004/11/05 05:10:29 drh Exp $
#

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


# Ticket #354
................................................................................
  # we COMMIT.
  db2 eval {BEGIN}
  db2 eval {UPDATE t1 SET a = 0 WHERE 0}
  catchsql {
    ATTACH 'test2.db' AS t2;
  }
} {0 {}}

do_test attach2-2.2 {
  # make sure test2.db did get attached.
  db_list db
} {0 main 2 t2}

db2 eval {COMMIT}

do_test attach2-2.5 {
  # Make sure we can read test2.db from db
  catchsql {
    SELECT name FROM t2.sqlite_master;
  }







|







 







>




>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#    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 and DETACH commands
# and related functionality.
#
# $Id: attach2.test,v 1.30 2004/11/23 10:13:03 danielk1977 Exp $
#

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


# Ticket #354
................................................................................
  # we COMMIT.
  db2 eval {BEGIN}
  db2 eval {UPDATE t1 SET a = 0 WHERE 0}
  catchsql {
    ATTACH 'test2.db' AS t2;
  }
} {0 {}}
ifcapable schema_pragmas {
do_test attach2-2.2 {
  # make sure test2.db did get attached.
  db_list db
} {0 main 2 t2}
} ;# ifcapable schema_pragmas
db2 eval {COMMIT}

do_test attach2-2.5 {
  # Make sure we can read test2.db from db
  catchsql {
    SELECT name FROM t2.sqlite_master;
  }

Changes to test/auth.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1650
1651
1652
1653
1654
1655
1656

1657
1658
1659

1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671

1672
1673
1674

1675
1676
1677
1678
1679
1680
1681
#    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 and DETACH commands
# and related functionality.
#
# $Id: auth.test,v 1.23 2004/11/22 11:51:14 danielk1977 Exp $
#

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

# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
# defined during compilation.
................................................................................
    }
    return SQLITE_OK
  }
  catchsql {
    DETACH DATABASE test1;
  }
} {0 {}}

do_test auth-1.260 {
  lindex [execsql {PRAGMA database_list}] 7
} {test1}

do_test auth-1.261 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_DETACH"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
    return SQLITE_OK
  }
  catchsql {
    DETACH DATABASE test1;
  }
} {1 {not authorized}}

do_test auth-1.262 {
  lindex [execsql {PRAGMA database_list}] 7
} {test1}

db authorizer {}
execsql {DETACH DATABASE test1}
db authorizer ::auth

# Authorization for ALTER TABLE. These tests are omitted if the library
# was built without ALTER TABLE support.
ifcapable altertable {







|







 







>



>












>



>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
#    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 and DETACH commands
# and related functionality.
#
# $Id: auth.test,v 1.24 2004/11/23 10:13:03 danielk1977 Exp $
#

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

# disable this test if the SQLITE_OMIT_AUTHORIZATION macro is
# defined during compilation.
................................................................................
    }
    return SQLITE_OK
  }
  catchsql {
    DETACH DATABASE test1;
  }
} {0 {}}
ifcapable schema_pragmas {
do_test auth-1.260 {
  lindex [execsql {PRAGMA database_list}] 7
} {test1}
} ;# ifcapable schema_pragmas
do_test auth-1.261 {
  proc auth {code arg1 arg2 arg3 arg4} {
    if {$code=="SQLITE_DETACH"} {
      set ::authargs [list $arg1 $arg2 $arg3 $arg4]
      return SQLITE_DENY
    }
    return SQLITE_OK
  }
  catchsql {
    DETACH DATABASE test1;
  }
} {1 {not authorized}}
ifcapable schema_pragmas {
do_test auth-1.262 {
  lindex [execsql {PRAGMA database_list}] 7
} {test1}
} ;# ifcapable schema_pragmas
db authorizer {}
execsql {DETACH DATABASE test1}
db authorizer ::auth

# Authorization for ALTER TABLE. These tests are omitted if the library
# was built without ALTER TABLE support.
ifcapable altertable {

Changes to test/pragma.test.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
301
302
303
304
305
306
307

308
309
310
311
312
313
314
...
336
337
338
339
340
341
342
343

344
345

346
347
348
349
350
351
352
353

354
355
356
357
358
359
360
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.24 2004/11/14 21:56:31 drh Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
    pragma synchronous;
  } 
} {2}
catchsql {COMMIT;}

# Test schema-query pragmas
#

do_test pragma-6.1 {
  set res {}
  execsql {SELECT * FROM sqlite_temp_master}
  foreach {idx name file} [execsql {pragma database_list}] {
    lappend res $idx $name
  }
  set res
................................................................................
}
do_test pragma-6.5 {
  execsql {
    CREATE INDEX t3i1 ON t3(a,b);
    pragma index_info(t3i1);
  }
} {0 0 a 1 1 b}


# Miscellaneous tests
#

do_test pragma-7.1 {
  # Make sure a pragma knows to read the schema if it needs to
  db close
  sqlite3 db test.db
  execsql {
    pragma index_list(t3);
  }
} {0 t3i1 0 1 sqlite_autoindex_t3_1 1}

ifcapable {utf16} {
  do_test pragma-7.2 {
    db close
    sqlite3 db test.db
    catchsql {
      pragma encoding=bogus;
    }







|







 







>







 







<
>


>








>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
...
337
338
339
340
341
342
343

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.25 2004/11/23 10:13:03 danielk1977 Exp $

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

# Test organization:
#
# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
    pragma synchronous;
  } 
} {2}
catchsql {COMMIT;}

# Test schema-query pragmas
#
ifcapable schema_pragmas {
do_test pragma-6.1 {
  set res {}
  execsql {SELECT * FROM sqlite_temp_master}
  foreach {idx name file} [execsql {pragma database_list}] {
    lappend res $idx $name
  }
  set res
................................................................................
}
do_test pragma-6.5 {
  execsql {
    CREATE INDEX t3i1 ON t3(a,b);
    pragma index_info(t3i1);
  }
} {0 0 a 1 1 b}

} ;# ifcapable schema_pragmas
# Miscellaneous tests
#
ifcapable schema_pragmas {
do_test pragma-7.1 {
  # Make sure a pragma knows to read the schema if it needs to
  db close
  sqlite3 db test.db
  execsql {
    pragma index_list(t3);
  }
} {0 t3i1 0 1 sqlite_autoindex_t3_1 1}
} ;# ifcapable schema_pragmas
ifcapable {utf16} {
  do_test pragma-7.2 {
    db close
    sqlite3 db test.db
    catchsql {
      pragma encoding=bogus;
    }

Changes to test/tclsqlite.test.

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
134
135
136
137
138
139
140



141
142

143
144
145
146
147
148
149
150
# This file implements regression tests for TCL interface to the
# SQLite library. 
#
# Actually, all tests are based on the TCL interface, so the main
# interface is pretty well tested.  This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
# $Id: tclsqlite.test,v 1.33 2004/11/03 16:27:02 drh Exp $

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

# Check the error messages generated by tclsqlite
#
if {[sqlite3 -has-codec]} {
................................................................................
} {1 {wrong # args: should be "db total_changes "}}


if {[sqlite3 -tcl-uses-utf]} {
  catch {unset ::result}
  do_test tcl-2.1 {
    execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"



    execsql "PRAGMA table_info(t\u0123x)"
  } "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"

  do_test tcl-2.2 {
    execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
    db eval "SELECT * FROM t\u0123x" result break
    set result(*)
  } "a b\u1235"
}









|







 







>
>
>
|
|
>
|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# This file implements regression tests for TCL interface to the
# SQLite library. 
#
# Actually, all tests are based on the TCL interface, so the main
# interface is pretty well tested.  This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
# $Id: tclsqlite.test,v 1.34 2004/11/23 10:13:03 danielk1977 Exp $

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

# Check the error messages generated by tclsqlite
#
if {[sqlite3 -has-codec]} {
................................................................................
} {1 {wrong # args: should be "db total_changes "}}


if {[sqlite3 -tcl-uses-utf]} {
  catch {unset ::result}
  do_test tcl-2.1 {
    execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
  } {}
  ifcapable schema_pragmas {
    do_test tcl-2.2 {
      execsql "PRAGMA table_info(t\u0123x)"
    } "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"
  }
  do_test tcl-2.3 {
    execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
    db eval "SELECT * FROM t\u0123x" result break
    set result(*)
  } "a b\u1235"
}