/ Hex Artifact Content
Login

Artifact debcd7dbfd847ae97b16ceb7fec6f567902874a6:


0000: 23 20 32 30 30 36 20 53 65 70 74 65 6d 62 65 72  # 2006 September
0010: 20 34 0a 23 0a 23 20 54 68 65 20 61 75 74 68 6f   4.#.# The autho
0020: 72 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70 79  r disclaims copy
0030: 72 69 67 68 74 20 74 6f 20 74 68 69 73 20 73 6f  right to this so
0040: 75 72 63 65 20 63 6f 64 65 2e 20 20 49 6e 20 70  urce code.  In p
0050: 6c 61 63 65 20 6f 66 0a 23 20 61 20 6c 65 67 61  lace of.# a lega
0060: 6c 20 6e 6f 74 69 63 65 2c 20 68 65 72 65 20 69  l notice, here i
0070: 73 20 61 20 62 6c 65 73 73 69 6e 67 3a 0a 23 0a  s a blessing:.#.
0080: 23 20 20 20 20 4d 61 79 20 79 6f 75 20 64 6f 20  #    May you do 
0090: 67 6f 6f 64 20 61 6e 64 20 6e 6f 74 20 65 76 69  good and not evi
00a0: 6c 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20  l..#    May you 
00b0: 66 69 6e 64 20 66 6f 72 67 69 76 65 6e 65 73 73  find forgiveness
00c0: 20 66 6f 72 20 79 6f 75 72 73 65 6c 66 20 61 6e   for yourself an
00d0: 64 20 66 6f 72 67 69 76 65 20 6f 74 68 65 72 73  d forgive others
00e0: 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20 73  ..#    May you s
00f0: 68 61 72 65 20 66 72 65 65 6c 79 2c 20 6e 65 76  hare freely, nev
0100: 65 72 20 74 61 6b 69 6e 67 20 6d 6f 72 65 20 74  er taking more t
0110: 68 61 6e 20 79 6f 75 20 67 69 76 65 2e 0a 23 0a  han you give..#.
0120: 23 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  #***************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 0a 23 20 54 68 69 73 20  ********.# This 
0170: 66 69 6c 65 20 69 6d 70 6c 65 6d 65 6e 74 73 20  file implements 
0180: 72 65 67 72 65 73 73 69 6f 6e 20 74 65 73 74 73  regression tests
0190: 20 66 6f 72 20 53 51 4c 69 74 65 20 6c 69 62 72   for SQLite libr
01a0: 61 72 79 2e 0a 23 0a 23 20 24 49 64 3a 20 6d 69  ary..#.# $Id: mi
01b0: 73 63 37 2e 74 65 73 74 2c 76 20 31 2e 32 38 20  sc7.test,v 1.28 
01c0: 32 30 30 39 2f 30 32 2f 31 30 20 30 35 3a 34 35  2009/02/10 05:45
01d0: 3a 34 32 20 64 61 6e 69 65 6c 6b 31 39 37 37 20  :42 danielk1977 
01e0: 45 78 70 20 24 0a 0a 73 65 74 20 74 65 73 74 64  Exp $..set testd
01f0: 69 72 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65  ir [file dirname
0200: 20 24 61 72 67 76 30 5d 0a 73 6f 75 72 63 65 20   $argv0].source 
0210: 24 74 65 73 74 64 69 72 2f 74 65 73 74 65 72 2e  $testdir/tester.
0220: 74 63 6c 0a 0a 64 6f 5f 74 65 73 74 20 6d 69 73  tcl..do_test mis
0230: 63 37 2d 31 2d 6d 69 73 75 73 65 20 7b 0a 20 20  c7-1-misuse {.  
0240: 63 5f 6d 69 73 75 73 65 5f 74 65 73 74 0a 7d 20  c_misuse_test.} 
0250: 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63  {}..do_test misc
0260: 37 2d 32 20 7b 0a 20 20 63 5f 72 65 61 6c 6c 6f  7-2 {.  c_reallo
0270: 63 5f 74 65 73 74 0a 7d 20 7b 7d 0a 0a 64 6f 5f  c_test.} {}..do_
0280: 74 65 73 74 20 6d 69 73 63 37 2d 33 20 7b 0a 20  test misc7-3 {. 
0290: 20 63 5f 63 6f 6c 6c 61 74 69 6f 6e 5f 74 65 73   c_collation_tes
02a0: 74 0a 7d 20 7b 7d 0a 0a 23 20 54 72 79 20 74 6f  t.} {}..# Try to
02b0: 20 6f 70 65 6e 20 61 20 64 69 72 65 63 74 6f 72   open a director
02c0: 79 3a 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73  y:.#.do_test mis
02d0: 63 37 2d 34 20 7b 0a 20 20 66 69 6c 65 20 64 65  c7-4 {.  file de
02e0: 6c 65 74 65 20 6d 79 64 69 72 0a 20 20 66 69 6c  lete mydir.  fil
02f0: 65 20 6d 6b 64 69 72 20 6d 79 64 69 72 0a 20 20  e mkdir mydir.  
0300: 73 65 74 20 72 63 20 5b 63 61 74 63 68 20 7b 0a  set rc [catch {.
0310: 20 20 20 20 73 71 6c 69 74 65 33 20 64 62 32 20      sqlite3 db2 
0320: 2e 2f 6d 79 64 69 72 0a 20 20 7d 20 6d 73 67 5d  ./mydir.  } msg]
0330: 0a 20 20 6c 69 73 74 20 24 72 63 20 24 6d 73 67  .  list $rc $msg
0340: 0a 7d 20 7b 31 20 7b 75 6e 61 62 6c 65 20 74 6f  .} {1 {unable to
0350: 20 6f 70 65 6e 20 64 61 74 61 62 61 73 65 20 66   open database f
0360: 69 6c 65 7d 7d 0a 0a 23 20 54 72 79 20 74 6f 20  ile}}..# Try to 
0370: 6f 70 65 6e 20 61 20 66 69 6c 65 20 77 69 74 68  open a file with
0380: 20 61 20 64 69 72 65 63 74 6f 72 79 20 77 68 65   a directory whe
0390: 72 65 20 69 74 73 20 6a 6f 75 72 6e 61 6c 20 66  re its journal f
03a0: 69 6c 65 20 73 68 6f 75 6c 64 20 62 65 2e 0a 23  ile should be..#
03b0: 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 35  .do_test misc7-5
03c0: 20 7b 0a 20 20 66 69 6c 65 20 64 65 6c 65 74 65   {.  file delete
03d0: 20 6d 79 64 69 72 0a 20 20 66 69 6c 65 20 6d 6b   mydir.  file mk
03e0: 64 69 72 20 6d 79 64 69 72 2d 6a 6f 75 72 6e 61  dir mydir-journa
03f0: 6c 0a 20 20 73 71 6c 69 74 65 33 20 64 62 32 20  l.  sqlite3 db2 
0400: 2e 2f 6d 79 64 69 72 0a 20 20 63 61 74 63 68 73  ./mydir.  catchs
0410: 71 6c 20 7b 0a 20 20 20 20 43 52 45 41 54 45 20  ql {.    CREATE 
0420: 54 41 42 4c 45 20 61 62 63 28 61 2c 20 62 2c 20  TABLE abc(a, b, 
0430: 63 29 3b 0a 20 20 7d 20 64 62 32 0a 7d 20 7b 31  c);.  } db2.} {1
0440: 20 7b 75 6e 61 62 6c 65 20 74 6f 20 6f 70 65 6e   {unable to open
0450: 20 64 61 74 61 62 61 73 65 20 66 69 6c 65 7d 7d   database file}}
0460: 0a 64 62 32 20 63 6c 6f 73 65 0a 0a 23 2d 2d 2d  .db2 close..#---
0470: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
04b0: 2d 0a 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e  -.# The followin
04c0: 67 20 74 65 73 74 73 2c 20 6d 69 73 63 37 2d 36  g tests, misc7-6
04d0: 2e 2a 20 74 65 73 74 20 74 68 65 20 6c 69 62 72  .* test the libr
04e0: 61 72 69 65 73 20 62 65 68 61 76 69 6f 75 72 20  aries behaviour 
04f0: 77 68 65 6e 0a 23 20 69 74 20 63 61 6e 6e 6f 74  when.# it cannot
0500: 20 6f 70 65 6e 20 61 20 66 69 6c 65 2e 20 54 6f   open a file. To
0510: 20 66 6f 72 63 65 20 74 68 69 73 20 63 6f 6e 64   force this cond
0520: 69 74 69 6f 6e 2c 20 77 65 20 75 73 65 20 75 70  ition, we use up
0530: 20 61 6c 6c 20 74 68 65 0a 23 20 66 69 6c 65 2d   all the.# file-
0540: 64 65 73 63 72 69 70 74 6f 72 73 20 62 65 66 6f  descriptors befo
0550: 72 65 20 72 75 6e 6e 69 6e 67 20 73 71 6c 69 74  re running sqlit
0560: 65 2e 20 54 68 69 73 20 70 72 6f 62 61 62 6c 79  e. This probably
0570: 20 6f 6e 6c 79 20 77 6f 72 6b 73 0a 23 20 6f 6e   only works.# on
0580: 20 75 6e 69 78 2e 0a 23 0a 0a 70 72 6f 63 20 75   unix..#..proc u
0590: 73 65 5f 75 70 5f 66 69 6c 65 73 20 7b 7d 20 7b  se_up_files {} {
05a0: 0a 20 20 73 65 74 20 72 65 74 20 5b 6c 69 73 74  .  set ret [list
05b0: 5d 0a 20 20 63 61 74 63 68 20 7b 0a 20 20 20 20  ].  catch {.    
05c0: 77 68 69 6c 65 20 31 20 7b 20 6c 61 70 70 65 6e  while 1 { lappen
05d0: 64 20 72 65 74 20 5b 6f 70 65 6e 20 74 65 73 74  d ret [open test
05e0: 2e 64 62 5d 20 7d 0a 20 20 7d 0a 20 20 72 65 74  .db] }.  }.  ret
05f0: 75 72 6e 20 24 72 65 74 0a 7d 0a 0a 70 72 6f 63  urn $ret.}..proc
0600: 20 64 6f 5f 66 69 6c 65 6f 70 65 6e 5f 74 65 73   do_fileopen_tes
0610: 74 20 7b 70 72 65 66 69 78 20 73 71 6c 7d 20 7b  t {prefix sql} {
0620: 0a 20 20 73 65 74 20 66 64 5f 6c 69 73 74 20 5b  .  set fd_list [
0630: 75 73 65 5f 75 70 5f 66 69 6c 65 73 5d 0a 20 20  use_up_files].  
0640: 73 65 74 20 3a 3a 67 6f 20 31 0a 20 20 73 65 74  set ::go 1.  set
0650: 20 3a 3a 6e 20 31 0a 20 20 73 65 74 20 3a 3a 73   ::n 1.  set ::s
0660: 71 6c 20 24 73 71 6c 0a 20 20 77 68 69 6c 65 20  ql $sql.  while 
0670: 7b 24 3a 3a 67 6f 7d 20 7b 0a 20 20 20 20 63 61  {$::go} {.    ca
0680: 74 63 68 20 7b 64 62 20 63 6c 6f 73 65 7d 0a 20  tch {db close}. 
0690: 20 20 20 64 6f 5f 74 65 73 74 20 24 7b 70 72 65     do_test ${pre
06a0: 66 69 78 7d 2e 24 7b 3a 3a 6e 7d 20 7b 0a 20 20  fix}.${::n} {.  
06b0: 20 20 20 20 73 65 74 20 72 63 20 5b 63 61 74 63      set rc [catc
06c0: 68 20 7b 0a 20 20 20 20 20 20 20 20 73 71 6c 69  h {.        sqli
06d0: 74 65 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20  te db test.db.  
06e0: 20 20 20 20 20 20 64 62 20 65 76 61 6c 20 24 3a        db eval $:
06f0: 3a 73 71 6c 0a 20 20 20 20 20 20 7d 20 6d 73 67  :sql.      } msg
0700: 5d 0a 20 20 20 20 20 20 69 66 20 7b 24 72 63 20  ].      if {$rc 
0710: 3d 3d 20 30 7d 20 7b 73 65 74 20 3a 3a 67 6f 20  == 0} {set ::go 
0720: 30 7d 0a 20 20 0a 20 20 20 20 20 20 65 78 70 72  0}.  .      expr
0730: 20 7b 24 72 63 20 3d 3d 20 30 20 7c 7c 20 28 24   {$rc == 0 || ($
0740: 72 63 20 3d 3d 20 31 20 26 26 20 5b 73 74 72 69  rc == 1 && [stri
0750: 6e 67 20 66 69 72 73 74 20 75 6e 61 62 6c 65 20  ng first unable 
0760: 24 6d 73 67 5d 3d 3d 30 29 7d 0a 20 20 20 20 7d  $msg]==0)}.    }
0770: 20 31 0a 20 20 0a 20 20 20 20 63 6c 6f 73 65 20   1.  .    close 
0780: 5b 6c 69 6e 64 65 78 20 24 66 64 5f 6c 69 73 74  [lindex $fd_list
0790: 20 30 5d 0a 20 20 20 20 73 65 74 20 66 64 5f 6c   0].    set fd_l
07a0: 69 73 74 20 5b 6c 72 61 6e 67 65 20 24 66 64 5f  ist [lrange $fd_
07b0: 6c 69 73 74 20 31 20 65 6e 64 5d 0a 20 20 20 20  list 1 end].    
07c0: 69 6e 63 72 20 3a 3a 6e 0a 20 20 7d 0a 20 20 66  incr ::n.  }.  f
07d0: 6f 72 65 61 63 68 20 66 64 20 24 66 64 5f 6c 69  oreach fd $fd_li
07e0: 73 74 20 7b 0a 20 20 20 20 63 6c 6f 73 65 20 24  st {.    close $
07f0: 66 64 0a 20 20 7d 0a 20 20 64 62 20 63 6c 6f 73  fd.  }.  db clos
0800: 65 0a 7d 0a 0a 65 78 65 63 73 71 6c 20 7b 20 43  e.}..execsql { C
0810: 52 45 41 54 45 20 54 41 42 4c 45 20 61 62 63 28  REATE TABLE abc(
0820: 61 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  a PRIMARY KEY, b
0830: 2c 20 63 29 3b 20 7d 0a 64 62 20 63 6c 6f 73 65  , c); }.db close
0840: 0a 0a 69 66 20 7b 24 74 63 6c 5f 70 6c 61 74 66  ..if {$tcl_platf
0850: 6f 72 6d 28 70 6c 61 74 66 6f 72 6d 29 21 3d 22  orm(platform)!="
0860: 77 69 6e 64 6f 77 73 22 7d 20 7b 0a 20 20 64 6f  windows"} {.  do
0870: 5f 66 69 6c 65 6f 70 65 6e 5f 74 65 73 74 20 6d  _fileopen_test m
0880: 69 73 63 37 2d 36 2e 31 20 7b 0a 20 20 20 20 42  isc7-6.1 {.    B
0890: 45 47 49 4e 3b 0a 20 20 20 20 49 4e 53 45 52 54  EGIN;.    INSERT
08a0: 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55 45 53   INTO abc VALUES
08b0: 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20 49  (1, 2, 3);.    I
08c0: 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 56  NSERT INTO abc V
08d0: 41 4c 55 45 53 28 32 2c 20 33 2c 20 34 29 3b 0a  ALUES(2, 3, 4);.
08e0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
08f0: 61 62 63 20 53 45 4c 45 43 54 20 61 2b 32 2c 20  abc SELECT a+2, 
0900: 62 2c 20 63 20 46 52 4f 4d 20 61 62 63 3b 0a 20  b, c FROM abc;. 
0910: 20 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 7d 0a 20     COMMIT;.  }. 
0920: 20 0a 20 20 64 6f 5f 66 69 6c 65 6f 70 65 6e 5f   .  do_fileopen_
0930: 74 65 73 74 20 6d 69 73 63 37 2d 36 2e 32 20 7b  test misc7-6.2 {
0940: 0a 20 20 20 20 50 52 41 47 4d 41 20 74 65 6d 70  .    PRAGMA temp
0950: 2e 63 61 63 68 65 5f 73 69 7a 65 20 3d 20 31 30  .cache_size = 10
0960: 30 30 3b 0a 20 20 7d 0a 7d 0a 0a 23 0a 23 20 45  00;.  }.}..#.# E
0970: 6e 64 20 6f 66 20 74 65 73 74 73 20 66 6f 72 20  nd of tests for 
0980: 6f 75 74 2d 6f 66 2d 66 69 6c 65 2d 64 65 73 63  out-of-file-desc
0990: 72 69 70 74 6f 72 73 20 63 6f 6e 64 69 74 69 6f  riptors conditio
09a0: 6e 2e 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  n..#------------
09b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09e0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 73 71 6c 69 74 65  --------..sqlite
09f0: 33 20 64 62 20 74 65 73 74 2e 64 62 0a 65 78 65  3 db test.db.exe
0a00: 63 73 71 6c 20 7b 0a 20 20 44 45 4c 45 54 45 20  csql {.  DELETE 
0a10: 46 52 4f 4d 20 61 62 63 3b 0a 20 20 49 4e 53 45  FROM abc;.  INSE
0a20: 52 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55  RT INTO abc VALU
0a30: 45 53 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 49  ES(1, 2, 3);.  I
0a40: 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 56  NSERT INTO abc V
0a50: 41 4c 55 45 53 28 32 2c 20 33 2c 20 34 29 3b 0a  ALUES(2, 3, 4);.
0a60: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62    INSERT INTO ab
0a70: 63 20 53 45 4c 45 43 54 20 61 2b 32 2c 20 62 2c  c SELECT a+2, b,
0a80: 20 63 20 46 52 4f 4d 20 61 62 63 3b 0a 7d 0a 20   c FROM abc;.}. 
0a90: 20 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d   ..#------------
0aa0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ab0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ac0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ad0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20  --------.# Test 
0ae0: 74 68 61 74 20 74 68 65 20 73 71 6c 69 74 65 33  that the sqlite3
0af0: 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 20 63 61  _busy_timeout ca
0b00: 6c 6c 20 73 65 65 6d 73 20 74 6f 20 64 65 6c 61  ll seems to dela
0b10: 79 20 61 70 70 72 6f 78 69 6d 61 74 65 6c 79 0a  y approximately.
0b20: 23 20 74 68 65 20 72 69 67 68 74 20 61 6d 6f 75  # the right amou
0b30: 6e 74 20 6f 66 20 74 69 6d 65 2e 0a 23 0a 64 6f  nt of time..#.do
0b40: 5f 74 65 73 74 20 6d 69 73 63 37 2d 37 2e 30 20  _test misc7-7.0 
0b50: 7b 0a 20 20 73 71 6c 69 74 65 33 20 64 62 32 20  {.  sqlite3 db2 
0b60: 74 65 73 74 2e 64 62 0a 20 20 73 71 6c 69 74 65  test.db.  sqlite
0b70: 33 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 20 5b  3_busy_timeout [
0b80: 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74 69  sqlite3_connecti
0b90: 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d 20 32  on_pointer db] 2
0ba0: 30 30 30 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a  000.  execsql {.
0bb0: 20 20 20 20 42 45 47 49 4e 20 45 58 43 4c 55 53      BEGIN EXCLUS
0bc0: 49 56 45 3b 0a 20 20 7d 20 64 62 32 0a 0a 20 20  IVE;.  } db2..  
0bd0: 23 20 4e 6f 77 20 64 62 32 20 68 61 73 20 61 6e  # Now db2 has an
0be0: 20 65 78 63 6c 75 73 69 76 65 20 6c 6f 63 6b 20   exclusive lock 
0bf0: 6f 6e 20 74 68 65 20 64 61 74 61 62 61 73 65 20  on the database 
0c00: 66 69 6c 65 2c 20 61 6e 64 20 64 62 20 68 61 73  file, and db has
0c10: 0a 20 20 23 20 61 20 62 75 73 79 2d 74 69 6d 65  .  # a busy-time
0c20: 6f 75 74 20 6f 66 20 32 30 30 30 20 6d 69 6c 6c  out of 2000 mill
0c30: 69 73 65 63 6f 6e 64 73 2e 20 53 6f 20 63 68 65  iseconds. So che
0c40: 63 6b 20 74 68 61 74 20 74 72 79 69 6e 67 20 74  ck that trying t
0c50: 6f 0a 20 20 23 20 61 63 63 65 73 73 20 74 68 65  o.  # access the
0c60: 20 64 61 74 61 62 61 73 65 20 75 73 69 6e 67 20   database using 
0c70: 63 6f 6e 6e 65 63 74 69 6f 6e 20 64 62 20 64 65  connection db de
0c80: 6c 61 79 73 20 66 6f 72 20 61 74 20 6c 65 61 73  lays for at leas
0c90: 74 20 31 35 30 30 20 6d 73 2e 0a 20 20 23 0a 20  t 1500 ms..  #. 
0ca0: 20 73 65 74 20 74 6d 20 5b 74 69 6d 65 20 7b 0a   set tm [time {.
0cb0: 20 20 20 20 73 65 74 20 72 65 73 75 6c 74 20 5b      set result [
0cc0: 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 20  catchsql {.     
0cd0: 20 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d     SELECT * FROM
0ce0: 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 3b 0a   sqlite_master;.
0cf0: 20 20 20 20 20 20 7d 20 64 62 5d 0a 20 20 7d 5d        } db].  }]
0d00: 0a 20 20 73 65 74 20 64 65 6c 61 79 20 5b 6c 69  .  set delay [li
0d10: 6e 64 65 78 20 24 74 6d 20 30 5d 20 20 3b 23 20  ndex $tm 0]  ;# 
0d20: 49 6e 20 6d 69 63 72 6f 73 65 63 6f 6e 64 73 0a  In microseconds.
0d30: 20 20 6c 61 70 70 65 6e 64 20 72 65 73 75 6c 74    lappend result
0d40: 20 5b 65 78 70 72 20 7b 24 64 65 6c 61 79 3e 31   [expr {$delay>1
0d50: 35 30 30 30 30 30 20 26 26 20 24 64 65 6c 61 79  500000 && $delay
0d60: 3c 34 30 30 30 30 30 30 7d 5d 0a 7d 20 7b 31 20  <4000000}].} {1 
0d70: 7b 64 61 74 61 62 61 73 65 20 69 73 20 6c 6f 63  {database is loc
0d80: 6b 65 64 7d 20 31 7d 0a 64 62 32 20 63 6c 6f 73  ked} 1}.db2 clos
0d90: 65 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  e..#------------
0da0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0db0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0dc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0dd0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20  --------.# Test 
0de0: 74 68 61 74 20 6e 6f 74 68 69 6e 67 20 67 6f 65  that nothing goe
0df0: 73 20 68 6f 72 72 69 62 6c 79 20 77 72 6f 6e 67  s horribly wrong
0e00: 20 77 68 65 6e 20 61 74 74 61 63 68 69 6e 67 20   when attaching 
0e10: 61 20 64 61 74 61 62 61 73 65 0a 23 20 61 66 74  a database.# aft
0e20: 65 72 20 74 68 65 20 6f 6d 69 74 5f 72 65 61 64  er the omit_read
0e30: 6c 6f 63 6b 20 70 72 61 67 6d 61 20 68 61 73 20  lock pragma has 
0e40: 62 65 65 6e 20 65 78 65 72 63 69 73 65 64 2e 0a  been exercised..
0e50: 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d  #.do_test misc7-
0e60: 37 2e 31 20 7b 0a 20 20 66 69 6c 65 20 64 65 6c  7.1 {.  file del
0e70: 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74 32  ete -force test2
0e80: 2e 64 62 0a 20 20 66 69 6c 65 20 64 65 6c 65 74  .db.  file delet
0e90: 65 20 2d 66 6f 72 63 65 20 74 65 73 74 32 2e 64  e -force test2.d
0ea0: 62 2d 6a 6f 75 72 6e 61 6c 0a 20 20 65 78 65 63  b-journal.  exec
0eb0: 73 71 6c 20 7b 0a 20 20 20 20 50 52 41 47 4d 41  sql {.    PRAGMA
0ec0: 20 6f 6d 69 74 5f 72 65 61 64 6c 6f 63 6b 20 3d   omit_readlock =
0ed0: 20 31 3b 0a 20 20 20 20 41 54 54 41 43 48 20 27   1;.    ATTACH '
0ee0: 74 65 73 74 32 2e 64 62 27 20 41 53 20 61 75 78  test2.db' AS aux
0ef0: 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54 41 42  ;.    CREATE TAB
0f00: 4c 45 20 61 75 78 2e 68 65 6c 6c 6f 28 77 6f 72  LE aux.hello(wor
0f10: 6c 64 29 3b 0a 20 20 20 20 53 45 4c 45 43 54 20  ld);.    SELECT 
0f20: 6e 61 6d 65 20 46 52 4f 4d 20 61 75 78 2e 73 71  name FROM aux.sq
0f30: 6c 69 74 65 5f 6d 61 73 74 65 72 3b 0a 20 20 7d  lite_master;.  }
0f40: 0a 7d 20 7b 68 65 6c 6c 6f 7d 0a 64 6f 5f 74 65  .} {hello}.do_te
0f50: 73 74 20 6d 69 73 63 37 2d 37 2e 32 20 7b 0a 20  st misc7-7.2 {. 
0f60: 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 44   execsql {.    D
0f70: 45 54 41 43 48 20 61 75 78 3b 0a 20 20 7d 0a 7d  ETACH aux;.  }.}
0f80: 20 7b 7d 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63   {}.do_test misc
0f90: 37 2d 37 2e 33 20 7b 0a 20 20 64 62 20 63 6c 6f  7-7.3 {.  db clo
0fa0: 73 65 0a 20 20 73 71 6c 69 74 65 33 20 64 62 20  se.  sqlite3 db 
0fb0: 74 65 73 74 2e 64 62 20 2d 72 65 61 64 6f 6e 6c  test.db -readonl
0fc0: 79 20 31 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a  y 1.  execsql {.
0fd0: 20 20 20 20 50 52 41 47 4d 41 20 6f 6d 69 74 5f      PRAGMA omit_
0fe0: 72 65 61 64 6c 6f 63 6b 20 3d 20 31 3b 0a 20 20  readlock = 1;.  
0ff0: 20 20 41 54 54 41 43 48 20 27 74 65 73 74 32 2e    ATTACH 'test2.
1000: 64 62 27 20 41 53 20 61 75 78 3b 0a 20 20 20 20  db' AS aux;.    
1010: 53 45 4c 45 43 54 20 6e 61 6d 65 20 46 52 4f 4d  SELECT name FROM
1020: 20 61 75 78 2e 73 71 6c 69 74 65 5f 6d 61 73 74   aux.sqlite_mast
1030: 65 72 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 6e  er;.    SELECT n
1040: 61 6d 65 20 46 52 4f 4d 20 61 75 78 2e 73 71 6c  ame FROM aux.sql
1050: 69 74 65 5f 6d 61 73 74 65 72 3b 0a 20 20 7d 0a  ite_master;.  }.
1060: 7d 20 7b 68 65 6c 6c 6f 20 68 65 6c 6c 6f 7d 0a  } {hello hello}.
1070: 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 37 2e  do_test misc7-7.
1080: 33 20 7b 0a 20 20 64 62 20 63 6c 6f 73 65 0a 20  3 {.  db close. 
1090: 20 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74   sqlite3 db test
10a0: 2e 64 62 0a 20 20 73 65 74 20 3a 3a 44 42 20 5b  .db.  set ::DB [
10b0: 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74 69  sqlite3_connecti
10c0: 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d 0a 20  on_pointer db]. 
10d0: 20 6c 69 73 74 0a 7d 20 7b 7d 0a 0a 23 20 54 65   list.} {}..# Te
10e0: 73 74 20 74 68 65 20 55 54 46 2d 31 36 20 76 65  st the UTF-16 ve
10f0: 72 73 69 6f 6e 20 6f 66 20 74 68 65 20 22 6f 75  rsion of the "ou
1100: 74 20 6f 66 20 6d 65 6d 6f 72 79 22 20 6d 65 73  t of memory" mes
1110: 73 61 67 65 20 28 75 73 65 64 20 77 68 65 6e 0a  sage (used when.
1120: 23 20 6d 61 6c 6c 6f 63 20 66 61 69 6c 73 20 64  # malloc fails d
1130: 75 72 69 6e 67 20 73 71 6c 69 74 65 33 5f 6f 70  uring sqlite3_op
1140: 65 6e 28 29 20 29 2e 0a 23 0a 69 66 63 61 70 61  en() )..#.ifcapa
1150: 62 6c 65 20 75 74 66 31 36 20 7b 0a 20 20 64 6f  ble utf16 {.  do
1160: 5f 74 65 73 74 20 6d 69 73 63 37 2d 38 20 7b 0a  _test misc7-8 {.
1170: 20 20 20 20 65 6e 63 6f 64 69 6e 67 20 63 6f 6e      encoding con
1180: 76 65 72 74 66 72 6f 6d 20 75 6e 69 63 6f 64 65  vertfrom unicode
1190: 20 5b 73 71 6c 69 74 65 33 5f 65 72 72 6d 73 67   [sqlite3_errmsg
11a0: 31 36 20 30 78 30 30 30 30 30 30 30 30 5d 0a 20  16 0x00000000]. 
11b0: 20 7d 20 7b 6f 75 74 20 6f 66 20 6d 65 6d 6f 72   } {out of memor
11c0: 79 7d 0a 7d 0a 0a 64 6f 5f 74 65 73 74 20 6d 69  y}.}..do_test mi
11d0: 73 63 37 2d 39 20 7b 0a 20 20 65 78 65 63 73 71  sc7-9 {.  execsq
11e0: 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 2a  l {.    SELECT *
11f0: 20 0a 20 20 20 20 46 52 4f 4d 20 28 53 45 4c 45   .    FROM (SELE
1200: 43 54 20 6e 61 6d 65 2b 31 20 41 53 20 6f 6e 65  CT name+1 AS one
1210: 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73   FROM sqlite_mas
1220: 74 65 72 20 4c 49 4d 49 54 20 31 20 4f 46 46 53  ter LIMIT 1 OFFS
1230: 45 54 20 31 29 20 0a 20 20 20 20 57 48 45 52 45  ET 1) .    WHERE
1240: 20 6f 6e 65 20 4c 49 4b 45 20 27 68 65 6c 6c 6f   one LIKE 'hello
1250: 25 27 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 23 2d  %';.  }.} {}..#-
1260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1270: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1280: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1290: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
12a0: 2d 2d 2d 0a 23 20 49 6d 70 72 6f 76 65 20 63 6f  ---.# Improve co
12b0: 76 65 72 61 67 65 20 66 6f 72 20 76 74 61 62 20  verage for vtab 
12c0: 63 6f 64 65 2e 0a 23 0a 69 66 63 61 70 61 62 6c  code..#.ifcapabl
12d0: 65 20 76 74 61 62 20 7b 0a 20 20 23 20 52 75 6e  e vtab {.  # Run
12e0: 20 73 6f 6d 65 20 64 65 62 75 67 20 63 6f 64 65   some debug code
12f0: 20 74 6f 20 69 6d 70 72 6f 76 65 20 72 65 70 6f   to improve repo
1300: 72 74 65 64 20 63 6f 76 65 72 61 67 65 0a 20 20  rted coverage.  
1310: 23 0a 0a 20 20 23 20 73 65 74 20 73 71 6c 69 74  #..  # set sqlit
1320: 65 5f 77 68 65 72 65 5f 74 72 61 63 65 20 31 0a  e_where_trace 1.
1330: 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d    do_test misc7-
1340: 31 30 20 7b 0a 20 20 20 20 72 65 67 69 73 74 65  10 {.    registe
1350: 72 5f 65 63 68 6f 5f 6d 6f 64 75 6c 65 20 5b 73  r_echo_module [s
1360: 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74 69 6f  qlite3_connectio
1370: 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d 0a 20 20  n_pointer db].  
1380: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
1390: 20 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c    CREATE VIRTUAL
13a0: 20 54 41 42 4c 45 20 74 31 20 55 53 49 4e 47 20   TABLE t1 USING 
13b0: 65 63 68 6f 28 61 62 63 29 3b 0a 20 20 20 20 20  echo(abc);.     
13c0: 20 53 45 4c 45 43 54 20 61 20 46 52 4f 4d 20 74   SELECT a FROM t
13d0: 31 20 57 48 45 52 45 20 61 20 3d 20 31 20 4f 52  1 WHERE a = 1 OR
13e0: 44 45 52 20 42 59 20 62 3b 0a 20 20 20 20 7d 0a  DER BY b;.    }.
13f0: 20 20 7d 20 7b 31 7d 0a 20 20 73 65 74 20 73 71    } {1}.  set sq
1400: 6c 69 74 65 5f 77 68 65 72 65 5f 74 72 61 63 65  lite_where_trace
1410: 20 30 0a 0a 20 20 23 20 53 70 65 63 69 66 79 20   0..  # Specify 
1420: 61 6e 20 4f 52 44 45 52 20 42 59 20 63 6c 61 75  an ORDER BY clau
1430: 73 65 20 74 68 61 74 20 63 61 6e 6e 6f 74 20 62  se that cannot b
1440: 65 20 69 6e 64 65 78 65 64 2e 0a 20 20 64 6f 5f  e indexed..  do_
1450: 74 65 73 74 20 6d 69 73 63 37 2d 31 31 20 7b 0a  test misc7-11 {.
1460: 20 20 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20      execsql {.  
1470: 20 20 20 20 53 45 4c 45 43 54 20 74 31 2e 61 2c      SELECT t1.a,
1480: 20 74 32 2e 61 20 46 52 4f 4d 20 74 31 2c 20 74   t2.a FROM t1, t
1490: 31 20 41 53 20 74 32 20 4f 52 44 45 52 20 42 59  1 AS t2 ORDER BY
14a0: 20 32 20 4c 49 4d 49 54 20 31 3b 0a 20 20 20 20   2 LIMIT 1;.    
14b0: 7d 0a 20 20 7d 20 7b 31 20 31 7d 0a 0a 20 20 23  }.  } {1 1}..  #
14c0: 20 54 68 65 20 77 68 6f 6c 65 20 70 6f 69 6e 74   The whole point
14d0: 20 6f 66 20 74 68 69 73 20 69 73 20 74 6f 20 74   of this is to t
14e0: 65 73 74 20 61 6e 20 65 72 72 6f 72 20 63 6f 64  est an error cod
14f0: 65 20 6f 74 68 65 72 20 74 68 61 6e 0a 20 20 23  e other than.  #
1500: 20 53 51 4c 49 54 45 5f 4e 4f 4d 45 4d 20 66 72   SQLITE_NOMEM fr
1510: 6f 6d 20 74 68 65 20 76 74 61 62 20 78 42 65 73  om the vtab xBes
1520: 74 49 6e 64 65 78 20 63 61 6c 6c 62 61 63 6b 2e  tIndex callback.
1530: 0a 20 20 23 0a 20 20 64 6f 5f 69 6f 65 72 72 5f  .  #.  do_ioerr_
1540: 74 65 73 74 20 6d 69 73 63 37 2d 31 32 20 2d 74  test misc7-12 -t
1550: 63 6c 70 72 65 70 20 7b 0a 20 20 20 20 73 71 6c  clprep {.    sql
1560: 69 74 65 33 20 64 62 32 20 74 65 73 74 2e 64 62  ite3 db2 test.db
1570: 0a 20 20 20 20 72 65 67 69 73 74 65 72 5f 65 63  .    register_ec
1580: 68 6f 5f 6d 6f 64 75 6c 65 20 5b 73 71 6c 69 74  ho_module [sqlit
1590: 65 33 5f 63 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f  e3_connection_po
15a0: 69 6e 74 65 72 20 64 62 32 5d 0a 20 20 20 20 64  inter db2].    d
15b0: 62 32 20 65 76 61 6c 20 7b 0a 20 20 20 20 20 20  b2 eval {.      
15c0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62 63  CREATE TABLE abc
15d0: 28 61 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (a PRIMARY KEY, 
15e0: 62 2c 20 63 29 3b 0a 20 20 20 20 20 20 49 4e 53  b, c);.      INS
15f0: 45 52 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c  ERT INTO abc VAL
1600: 55 45 53 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20  UES(1, 2, 3);.  
1610: 20 20 20 20 43 52 45 41 54 45 20 56 49 52 54 55      CREATE VIRTU
1620: 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49 4e  AL TABLE t1 USIN
1630: 47 20 65 63 68 6f 28 61 62 63 29 3b 0a 20 20 20  G echo(abc);.   
1640: 20 7d 0a 20 20 20 20 64 62 32 20 63 6c 6f 73 65   }.    db2 close
1650: 0a 20 20 7d 20 2d 74 63 6c 62 6f 64 79 20 7b 0a  .  } -tclbody {.
1660: 20 20 20 20 72 65 67 69 73 74 65 72 5f 65 63 68      register_ech
1670: 6f 5f 6d 6f 64 75 6c 65 20 5b 73 71 6c 69 74 65  o_module [sqlite
1680: 33 5f 63 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f 69  3_connection_poi
1690: 6e 74 65 72 20 64 62 5d 0a 20 20 20 20 65 78 65  nter db].    exe
16a0: 63 73 71 6c 20 7b 53 45 4c 45 43 54 20 2a 20 46  csql {SELECT * F
16b0: 52 4f 4d 20 74 31 20 57 48 45 52 45 20 61 20 3d  ROM t1 WHERE a =
16c0: 20 31 3b 7d 0a 20 20 7d 20 0a 0a 20 20 23 20 54   1;}.  } ..  # T
16d0: 68 65 20 63 61 73 65 20 77 68 65 72 65 20 74 68  he case where th
16e0: 65 20 76 69 72 74 75 61 6c 20 74 61 62 6c 65 20  e virtual table 
16f0: 6d 6f 64 75 6c 65 20 72 65 74 75 72 6e 73 20 61  module returns a
1700: 20 76 65 72 79 20 6c 61 72 67 65 20 6e 75 6d 62   very large numb
1710: 65 72 0a 20 20 23 20 61 73 20 74 68 65 20 63 6f  er.  # as the co
1720: 73 74 20 6f 66 20 61 20 73 63 61 6e 20 28 67 72  st of a scan (gr
1730: 65 61 74 65 72 20 74 68 61 6e 20 53 51 4c 49 54  eater than SQLIT
1740: 45 5f 42 49 47 5f 44 4f 55 42 4c 45 20 69 6e 20  E_BIG_DOUBLE in 
1750: 74 68 65 20 63 6f 64 65 29 2e 0a 20 20 23 0a 20  the code)..  #. 
1760: 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 31   do_test misc7-1
1770: 33 20 7b 0a 20 20 20 20 73 71 6c 69 74 65 33 20  3 {.    sqlite3 
1780: 64 62 20 74 65 73 74 2e 64 62 0a 20 20 20 20 72  db test.db.    r
1790: 65 67 69 73 74 65 72 5f 65 63 68 6f 5f 6d 6f 64  egister_echo_mod
17a0: 75 6c 65 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e  ule [sqlite3_con
17b0: 6e 65 63 74 69 6f 6e 5f 70 6f 69 6e 74 65 72 20  nection_pointer 
17c0: 64 62 5d 0a 20 20 20 20 73 65 74 20 3a 3a 65 63  db].    set ::ec
17d0: 68 6f 5f 6d 6f 64 75 6c 65 5f 63 6f 73 74 20 32  ho_module_cost 2
17e0: 2e 30 65 2b 39 39 0a 20 20 20 20 65 78 65 63 73  .0e+99.    execs
17f0: 71 6c 20 7b 53 45 4c 45 43 54 20 2a 20 46 52 4f  ql {SELECT * FRO
1800: 4d 20 74 31 20 57 48 45 52 45 20 61 20 3d 20 31  M t1 WHERE a = 1
1810: 3b 7d 0a 20 20 7d 20 7b 31 20 32 20 33 7d 0a 20  ;}.  } {1 2 3}. 
1820: 20 75 6e 73 65 74 20 3a 3a 65 63 68 6f 5f 6d 6f   unset ::echo_mo
1830: 64 75 6c 65 5f 63 6f 73 74 0a 7d 0a 0a 64 62 20  dule_cost.}..db 
1840: 63 6c 6f 73 65 0a 66 69 6c 65 20 64 65 6c 65 74  close.file delet
1850: 65 20 2d 66 6f 72 63 65 20 74 65 73 74 2e 64 62  e -force test.db
1860: 0a 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f  .file delete -fo
1870: 72 63 65 20 74 65 73 74 2e 64 62 2d 6a 6f 75 72  rce test.db-jour
1880: 6e 61 6c 0a 73 71 6c 69 74 65 33 20 64 62 20 74  nal.sqlite3 db t
1890: 65 73 74 2e 64 62 0a 0a 69 66 63 61 70 61 62 6c  est.db..ifcapabl
18a0: 65 20 65 78 70 6c 61 69 6e 20 7b 0a 20 20 64 6f  e explain {.  do
18b0: 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 34 2e 31  _test misc7-14.1
18c0: 20 7b 0a 20 20 20 20 65 78 65 63 73 71 6c 20 7b   {.    execsql {
18d0: 0a 20 20 20 20 20 20 43 52 45 41 54 45 20 54 41  .      CREATE TA
18e0: 42 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41 52  BLE abc(a PRIMAR
18f0: 59 20 4b 45 59 2c 20 62 2c 20 63 29 3b 0a 20 20  Y KEY, b, c);.  
1900: 20 20 7d 0a 20 20 20 20 65 78 65 63 73 71 6c 20    }.    execsql 
1910: 7b 0a 20 20 20 20 20 20 45 58 50 4c 41 49 4e 20  {.      EXPLAIN 
1920: 51 55 45 52 59 20 50 4c 41 4e 20 53 45 4c 45 43  QUERY PLAN SELEC
1930: 54 20 2a 20 46 52 4f 4d 20 61 62 63 20 41 53 20  T * FROM abc AS 
1940: 74 32 20 57 48 45 52 45 20 72 6f 77 69 64 20 3d  t2 WHERE rowid =
1950: 20 31 3b 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 30   1;.    }.  } {0
1960: 20 30 20 7b 54 41 42 4c 45 20 61 62 63 20 41 53   0 {TABLE abc AS
1970: 20 74 32 20 55 53 49 4e 47 20 50 52 49 4d 41 52   t2 USING PRIMAR
1980: 59 20 4b 45 59 7d 7d 0a 20 20 64 6f 5f 74 65 73  Y KEY}}.  do_tes
1990: 74 20 6d 69 73 63 37 2d 31 34 2e 32 20 7b 0a 20  t misc7-14.2 {. 
19a0: 20 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20     execsql {.   
19b0: 20 20 20 45 58 50 4c 41 49 4e 20 51 55 45 52 59     EXPLAIN QUERY
19c0: 20 50 4c 41 4e 20 53 45 4c 45 43 54 20 2a 20 46   PLAN SELECT * F
19d0: 52 4f 4d 20 61 62 63 20 41 53 20 74 32 20 57 48  ROM abc AS t2 WH
19e0: 45 52 45 20 61 20 3d 20 31 3b 0a 20 20 20 20 7d  ERE a = 1;.    }
19f0: 0a 20 20 7d 20 7b 30 20 30 20 7b 54 41 42 4c 45  .  } {0 0 {TABLE
1a00: 20 61 62 63 20 41 53 20 74 32 20 57 49 54 48 20   abc AS t2 WITH 
1a10: 49 4e 44 45 58 20 73 71 6c 69 74 65 5f 61 75 74  INDEX sqlite_aut
1a20: 6f 69 6e 64 65 78 5f 61 62 63 5f 31 7d 7d 0a 20  oindex_abc_1}}. 
1a30: 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 31   do_test misc7-1
1a40: 34 2e 33 20 7b 0a 20 20 20 20 65 78 65 63 73 71  4.3 {.    execsq
1a50: 6c 20 7b 0a 20 20 20 20 20 20 45 58 50 4c 41 49  l {.      EXPLAI
1a60: 4e 20 51 55 45 52 59 20 50 4c 41 4e 20 53 45 4c  N QUERY PLAN SEL
1a70: 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63 20 41  ECT * FROM abc A
1a80: 53 20 74 32 20 4f 52 44 45 52 20 42 59 20 61 3b  S t2 ORDER BY a;
1a90: 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 30 20 30 20  .    }.  } {0 0 
1aa0: 7b 54 41 42 4c 45 20 61 62 63 20 41 53 20 74 32  {TABLE abc AS t2
1ab0: 20 57 49 54 48 20 49 4e 44 45 58 20 73 71 6c 69   WITH INDEX sqli
1ac0: 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 61 62 63  te_autoindex_abc
1ad0: 5f 31 20 4f 52 44 45 52 20 42 59 7d 7d 0a 7d 0a  _1 ORDER BY}}.}.
1ae0: 0a 64 62 20 63 6c 6f 73 65 0a 66 69 6c 65 20 64  .db close.file d
1af0: 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73  elete -force tes
1b00: 74 2e 64 62 0a 66 69 6c 65 20 64 65 6c 65 74 65  t.db.file delete
1b10: 20 2d 66 6f 72 63 65 20 74 65 73 74 2e 64 62 2d   -force test.db-
1b20: 6a 6f 75 72 6e 61 6c 0a 73 71 6c 69 74 65 33 20  journal.sqlite3 
1b30: 64 62 20 74 65 73 74 2e 64 62 0a 0a 23 2d 2d 2d  db test.db..#---
1b40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b70: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1b80: 2d 0a 23 20 54 68 69 73 20 69 73 20 61 6c 6c 20  -.# This is all 
1b90: 74 6f 20 66 6f 72 63 65 20 74 68 65 20 70 61 67  to force the pag
1ba0: 65 72 5f 72 65 6d 6f 76 65 5f 66 72 6f 6d 5f 73  er_remove_from_s
1bb0: 74 6d 74 5f 6c 69 73 74 28 29 20 66 75 6e 63 74  tmt_list() funct
1bc0: 69 6f 6e 0a 23 20 28 69 6e 73 69 64 65 20 70 61  ion.# (inside pa
1bd0: 67 65 72 2e 63 29 20 74 6f 20 72 65 6d 6f 76 65  ger.c) to remove
1be0: 20 61 20 70 61 67 65 72 20 66 72 6f 6d 20 74 68   a pager from th
1bf0: 65 20 6d 69 64 64 6c 65 20 6f 66 20 74 68 65 0a  e middle of the.
1c00: 23 20 73 74 61 74 65 6d 65 6e 74 2d 6c 69 73 74  # statement-list
1c10: 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63  ..#.do_test misc
1c20: 37 2d 31 35 2e 31 20 7b 0a 20 20 65 78 65 63 73  7-15.1 {.  execs
1c30: 71 6c 20 7b 0a 20 20 20 20 50 52 41 47 4d 41 20  ql {.    PRAGMA 
1c40: 63 61 63 68 65 5f 73 69 7a 65 20 3d 20 31 30 3b  cache_size = 10;
1c50: 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20 20 20 20  .    BEGIN;.    
1c60: 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62 63  CREATE TABLE abc
1c70: 28 61 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (a PRIMARY KEY, 
1c80: 62 2c 20 63 29 3b 0a 20 20 20 20 49 4e 53 45 52  b, c);.    INSER
1c90: 54 20 49 4e 54 4f 20 61 62 63 20 0a 20 20 20 20  T INTO abc .    
1ca0: 56 41 4c 55 45 53 28 72 61 6e 64 73 74 72 28 31  VALUES(randstr(1
1cb0: 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72  00,100), randstr
1cc0: 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73  (100,100), rands
1cd0: 74 72 28 31 30 30 2c 31 30 30 29 29 3b 0a 20 20  tr(100,100));.  
1ce0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62    INSERT INTO ab
1cf0: 63 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20 20  c SELECT .      
1d00: 20 20 20 20 20 20 72 61 6e 64 73 74 72 28 31 30        randstr(10
1d10: 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28  0,100), randstr(
1d20: 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74  100,100), randst
1d30: 72 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d 20  r(100,100) FROM 
1d40: 61 62 63 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  abc;.    INSERT 
1d50: 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54 20  INTO abc SELECT 
1d60: 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 61 6e  .            ran
1d70: 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72  dstr(100,100), r
1d80: 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c  andstr(100,100),
1d90: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30   randstr(100,100
1da0: 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20  ) FROM abc;.    
1db0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20  INSERT INTO abc 
1dc0: 53 45 4c 45 43 54 20 0a 20 20 20 20 20 20 20 20  SELECT .        
1dd0: 20 20 20 20 72 61 6e 64 73 74 72 28 31 30 30 2c      randstr(100,
1de0: 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30  100), randstr(10
1df0: 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28  0,100), randstr(
1e00: 31 30 30 2c 31 30 30 29 20 46 52 4f 4d 20 61 62  100,100) FROM ab
1e10: 63 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  c;.    INSERT IN
1e20: 54 4f 20 61 62 63 20 53 45 4c 45 43 54 20 0a 20  TO abc SELECT . 
1e30: 20 20 20 20 20 20 20 20 20 20 20 72 61 6e 64 73             rands
1e40: 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e  tr(100,100), ran
1e50: 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72  dstr(100,100), r
1e60: 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 20  andstr(100,100) 
1e70: 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49 4e  FROM abc;.    IN
1e80: 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45  SERT INTO abc SE
1e90: 4c 45 43 54 20 0a 20 20 20 20 20 20 20 20 20 20  LECT .          
1ea0: 20 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30    randstr(100,10
1eb0: 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c  0), randstr(100,
1ec0: 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30  100), randstr(10
1ed0: 30 2c 31 30 30 29 20 46 52 4f 4d 20 61 62 63 3b  0,100) FROM abc;
1ee0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1ef0: 20 61 62 63 20 53 45 4c 45 43 54 20 0a 20 20 20   abc SELECT .   
1f00: 20 20 20 20 20 20 20 20 20 72 61 6e 64 73 74 72           randstr
1f10: 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73  (100,100), rands
1f20: 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e  tr(100,100), ran
1f30: 64 73 74 72 28 31 30 30 2c 31 30 30 29 20 46 52  dstr(100,100) FR
1f40: 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49 4e 53 45  OM abc;.    INSE
1f50: 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45  RT INTO abc SELE
1f60: 43 54 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  CT .            
1f70: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1f80: 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30  , randstr(100,10
1f90: 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c  0), randstr(100,
1fa0: 31 30 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20  100) FROM abc;. 
1fb0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61     INSERT INTO a
1fc0: 62 63 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20  bc SELECT .     
1fd0: 20 20 20 20 20 20 20 72 61 6e 64 73 74 72 28 31         randstr(1
1fe0: 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72  00,100), randstr
1ff0: 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73  (100,100), rands
2000: 74 72 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d  tr(100,100) FROM
2010: 20 61 62 63 3b 0a 20 20 20 20 43 4f 4d 4d 49 54   abc;.    COMMIT
2020: 3b 0a 20 20 7d 0a 20 20 65 78 70 72 20 7b 5b 66  ;.  }.  expr {[f
2030: 69 6c 65 20 73 69 7a 65 20 74 65 73 74 2e 64 62  ile size test.db
2040: 5d 3e 31 30 32 34 30 7d 0a 7d 20 7b 31 7d 0a 64  ]>10240}.} {1}.d
2050: 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 35 2e  o_test misc7-15.
2060: 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a  2 {.  execsql {.
2070: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20      DELETE FROM 
2080: 61 62 63 20 57 48 45 52 45 20 72 6f 77 69 64 20  abc WHERE rowid 
2090: 3e 20 31 32 3b 0a 20 20 20 20 49 4e 53 45 52 54  > 12;.    INSERT
20a0: 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54   INTO abc SELECT
20b0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 61   .            ra
20c0: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20  ndstr(100,100), 
20d0: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
20e0: 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30  , randstr(100,10
20f0: 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 7d  0) FROM abc;.  }
2100: 0a 7d 20 7b 7d 0a 0a 64 62 20 63 6c 6f 73 65 0a  .} {}..db close.
2110: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
2120: 63 65 20 74 65 73 74 2e 64 62 0a 66 69 6c 65 20  ce test.db.file 
2130: 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 74 65  delete -force te
2140: 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 0a 73 71  st.db-journal.sq
2150: 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e 64 62  lite3 db test.db
2160: 0a 0a 64 6f 5f 69 6f 65 72 72 5f 74 65 73 74 20  ..do_ioerr_test 
2170: 6d 69 73 63 37 2d 31 36 20 2d 73 71 6c 70 72 65  misc7-16 -sqlpre
2180: 70 20 7b 0a 20 20 20 50 52 41 47 4d 41 20 63 61  p {.   PRAGMA ca
2190: 63 68 65 5f 73 69 7a 65 20 3d 20 31 30 3b 0a 20  che_size = 10;. 
21a0: 20 20 50 52 41 47 4d 41 20 64 65 66 61 75 6c 74    PRAGMA default
21b0: 5f 63 61 63 68 65 5f 73 69 7a 65 20 3d 20 31 30  _cache_size = 10
21c0: 3b 0a 20 20 20 43 52 45 41 54 45 20 54 41 42 4c  ;.   CREATE TABL
21d0: 45 20 74 33 28 61 2c 20 62 2c 20 55 4e 49 51 55  E t3(a, b, UNIQU
21e0: 45 28 61 2c 20 62 29 29 3b 0a 20 20 20 49 4e 53  E(a, b));.   INS
21f0: 45 52 54 20 49 4e 54 4f 20 74 33 20 56 41 4c 55  ERT INTO t3 VALU
2200: 45 53 28 20 72 61 6e 64 73 74 72 28 31 30 30 2c  ES( randstr(100,
2210: 20 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31   100), randstr(1
2220: 30 30 2c 20 31 30 30 29 20 29 3b 0a 20 20 20 49  00, 100) );.   I
2230: 4e 53 45 52 54 20 49 4e 54 4f 20 74 33 20 53 45  NSERT INTO t3 SE
2240: 4c 45 43 54 20 72 61 6e 64 73 74 72 28 31 30 30  LECT randstr(100
2250: 2c 20 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28  , 100), randstr(
2260: 31 30 30 2c 20 31 30 30 29 20 46 52 4f 4d 20 74  100, 100) FROM t
2270: 33 3b 0a 20 20 20 49 4e 53 45 52 54 20 49 4e 54  3;.   INSERT INT
2280: 4f 20 74 33 20 53 45 4c 45 43 54 20 72 61 6e 64  O t3 SELECT rand
2290: 73 74 72 28 31 30 30 2c 20 31 30 30 29 2c 20 72  str(100, 100), r
22a0: 61 6e 64 73 74 72 28 31 30 30 2c 20 31 30 30 29  andstr(100, 100)
22b0: 20 46 52 4f 4d 20 74 33 3b 0a 20 20 20 49 4e 53   FROM t3;.   INS
22c0: 45 52 54 20 49 4e 54 4f 20 74 33 20 53 45 4c 45  ERT INTO t3 SELE
22d0: 43 54 20 72 61 6e 64 73 74 72 28 31 30 30 2c 20  CT randstr(100, 
22e0: 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30  100), randstr(10
22f0: 30 2c 20 31 30 30 29 20 46 52 4f 4d 20 74 33 3b  0, 100) FROM t3;
2300: 0a 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  .   INSERT INTO 
2310: 74 33 20 53 45 4c 45 43 54 20 72 61 6e 64 73 74  t3 SELECT randst
2320: 72 28 31 30 30 2c 20 31 30 30 29 2c 20 72 61 6e  r(100, 100), ran
2330: 64 73 74 72 28 31 30 30 2c 20 31 30 30 29 20 46  dstr(100, 100) F
2340: 52 4f 4d 20 74 33 3b 0a 20 20 20 49 4e 53 45 52  ROM t3;.   INSER
2350: 54 20 49 4e 54 4f 20 74 33 20 53 45 4c 45 43 54  T INTO t3 SELECT
2360: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 20 31 30   randstr(100, 10
2370: 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c  0), randstr(100,
2380: 20 31 30 30 29 20 46 52 4f 4d 20 74 33 3b 0a 20   100) FROM t3;. 
2390: 20 20 55 50 44 41 54 45 20 74 33 20 0a 20 20 20    UPDATE t3 .   
23a0: 53 45 54 20 62 20 3d 20 27 68 65 6c 6c 6f 20 77  SET b = 'hello w
23b0: 6f 72 6c 64 27 0a 20 20 20 57 48 45 52 45 20 72  orld'.   WHERE r
23c0: 6f 77 69 64 20 3e 3d 20 28 53 45 4c 45 43 54 20  owid >= (SELECT 
23d0: 6d 61 78 28 72 6f 77 69 64 29 2d 31 20 46 52 4f  max(rowid)-1 FRO
23e0: 4d 20 74 33 29 3b 0a 7d 20 2d 74 63 6c 62 6f 64  M t3);.} -tclbod
23f0: 79 20 7b 0a 20 20 73 65 74 20 72 63 20 5b 63 61  y {.  set rc [ca
2400: 74 63 68 20 7b 64 62 20 65 76 61 6c 20 7b 0a 20  tch {db eval {. 
2410: 20 20 20 42 45 47 49 4e 3b 0a 20 20 20 20 20 20     BEGIN;.      
2420: 50 52 41 47 4d 41 20 63 61 63 68 65 5f 73 69 7a  PRAGMA cache_siz
2430: 65 20 3d 20 31 30 3b 0a 20 20 20 20 20 20 49 4e  e = 10;.      IN
2440: 53 45 52 54 20 49 4e 54 4f 20 74 33 20 56 41 4c  SERT INTO t3 VAL
2450: 55 45 53 28 20 72 61 6e 64 73 74 72 28 31 30 30  UES( randstr(100
2460: 2c 20 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28  , 100), randstr(
2470: 31 30 30 2c 20 31 30 30 29 20 29 3b 0a 20 20 20  100, 100) );.   
2480: 20 20 20 55 50 44 41 54 45 20 74 33 20 53 45 54     UPDATE t3 SET
2490: 20 61 20 3d 20 62 3b 0a 20 20 20 20 43 4f 4d 4d   a = b;.    COMM
24a0: 49 54 3b 0a 20 20 7d 7d 20 6d 73 67 5d 0a 0a 20  IT;.  }} msg].. 
24b0: 20 69 66 20 7b 21 24 72 63 20 7c 7c 20 28 24 72   if {!$rc || ($r
24c0: 63 20 26 26 20 5b 73 74 72 69 6e 67 20 66 69 72  c && [string fir
24d0: 73 74 20 22 63 6f 6c 75 6d 6e 73 22 20 24 6d 73  st "columns" $ms
24e0: 67 5d 3d 3d 30 29 7d 20 7b 0a 20 20 20 20 73 65  g]==0)} {.    se
24f0: 74 20 6d 73 67 0a 20 20 7d 20 65 6c 73 65 20 7b  t msg.  } else {
2500: 0a 20 20 20 20 65 72 72 6f 72 20 24 6d 73 67 0a  .    error $msg.
2510: 20 20 7d 0a 7d 0a 0a 73 71 6c 69 74 65 33 20 64    }.}..sqlite3 d
2520: 62 20 74 65 73 74 2e 64 62 0a 0a 64 6f 5f 74 65  b test.db..do_te
2530: 73 74 20 6d 69 73 63 37 2d 31 36 2e 58 20 7b 0a  st misc7-16.X {.
2540: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
2550: 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 2a 29 20  SELECT count(*) 
2560: 46 52 4f 4d 20 74 33 3b 0a 20 20 7d 0a 7d 20 7b  FROM t3;.  }.} {
2570: 33 32 7d 0a 0a 73 65 74 20 73 71 6c 69 74 65 5f  32}..set sqlite_
2580: 70 61 67 65 72 5f 6e 5f 73 6f 72 74 5f 62 75 63  pager_n_sort_buc
2590: 6b 65 74 20 34 0a 64 6f 5f 74 65 73 74 20 6d 69  ket 4.do_test mi
25a0: 73 63 37 2d 31 37 20 7b 0a 20 20 65 78 65 63 73  sc7-17 {.  execs
25b0: 71 6c 20 7b 0a 20 20 20 20 50 52 41 47 4d 41 20  ql {.    PRAGMA 
25c0: 69 6e 74 65 67 72 69 74 79 5f 63 68 65 63 6b 3b  integrity_check;
25d0: 0a 20 20 20 20 56 41 43 55 55 4d 3b 0a 20 20 20  .    VACUUM;.   
25e0: 20 50 52 41 47 4d 41 20 69 6e 74 65 67 72 69 74   PRAGMA integrit
25f0: 79 5f 63 68 65 63 6b 3b 0a 20 20 7d 0a 7d 20 7b  y_check;.  }.} {
2600: 6f 6b 20 6f 6b 7d 0a 73 65 74 20 73 71 6c 69 74  ok ok}.set sqlit
2610: 65 5f 70 61 67 65 72 5f 6e 5f 73 6f 72 74 5f 62  e_pager_n_sort_b
2620: 75 63 6b 65 74 20 30 0a 0a 23 2d 2d 2d 2d 2d 2d  ucket 0..#------
2630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2650: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2660: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2670: 0a 23 20 54 65 73 74 20 74 68 65 20 73 69 74 75  .# Test the situ
2680: 61 74 69 6f 6e 20 77 68 65 72 65 20 61 20 68 6f  ation where a ho
2690: 74 2d 6a 6f 75 72 6e 61 6c 20 69 73 20 64 69 73  t-journal is dis
26a0: 63 6f 76 65 72 65 64 20 62 75 74 20 77 72 69 74  covered but writ
26b0: 65 2d 61 63 63 65 73 73 0a 23 20 74 6f 20 69 74  e-access.# to it
26c0: 20 69 73 20 64 65 6e 69 65 64 2e 20 54 68 69 73   is denied. This
26d0: 20 73 68 6f 75 6c 64 20 72 65 74 75 72 6e 20 53   should return S
26e0: 51 4c 49 54 45 5f 42 55 53 59 2e 0a 23 0a 23 20  QLITE_BUSY..#.# 
26f0: 54 68 65 73 65 20 74 65 73 74 73 20 64 6f 20 6e  These tests do n
2700: 6f 74 20 77 6f 72 6b 20 6f 6e 20 77 69 6e 64 6f  ot work on windo
2710: 77 73 20 64 75 65 20 74 6f 20 72 65 73 74 72 69  ws due to restri
2720: 63 74 69 6f 6e 73 20 69 6e 20 74 68 65 0a 23 20  ctions in the.# 
2730: 77 69 6e 64 6f 77 73 20 66 69 6c 65 20 73 79 73  windows file sys
2740: 74 65 6d 2e 0a 23 0a 69 66 20 7b 24 74 63 6c 5f  tem..#.if {$tcl_
2750: 70 6c 61 74 66 6f 72 6d 28 70 6c 61 74 66 6f 72  platform(platfor
2760: 6d 29 21 3d 22 77 69 6e 64 6f 77 73 22 20 26 26  m)!="windows" &&
2770: 20 24 74 63 6c 5f 70 6c 61 74 66 6f 72 6d 28 70   $tcl_platform(p
2780: 6c 61 74 66 6f 72 6d 29 21 3d 22 6f 73 32 22 7d  latform)!="os2"}
2790: 20 7b 0a 0a 20 20 23 20 53 6f 6d 65 20 6e 65 74   {..  # Some net
27a0: 77 6f 72 6b 20 66 69 6c 65 73 79 73 74 65 6d 73  work filesystems
27b0: 20 28 65 78 3a 20 41 46 50 29 20 64 6f 20 6e 6f   (ex: AFP) do no
27c0: 74 20 73 75 70 70 6f 72 74 20 73 65 74 74 69 6e  t support settin
27d0: 67 20 72 65 61 64 2d 6f 6e 6c 79 0a 20 20 23 20  g read-only.  # 
27e0: 70 65 72 6d 69 73 73 69 6f 6e 73 2e 20 20 4f 6e  permissions.  On
27f0: 6c 79 20 72 75 6e 20 74 68 65 73 65 20 74 65 73  ly run these tes
2800: 74 73 20 69 66 20 66 75 6c 6c 20 75 6e 69 78 20  ts if full unix 
2810: 70 65 72 6d 69 73 73 69 6f 6e 20 73 65 74 74 69  permission setti
2820: 6e 67 0a 20 20 23 20 63 61 70 61 62 69 6c 69 74  ng.  # capabilit
2830: 69 65 73 20 61 72 65 20 73 75 70 70 6f 72 74 65  ies are supporte
2840: 64 2e 0a 20 20 23 0a 20 20 66 69 6c 65 20 61 74  d..  #.  file at
2850: 74 72 69 62 75 74 65 73 20 74 65 73 74 2e 64 62  tributes test.db
2860: 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 72 77   -permissions rw
2870: 2d 72 2d 2d 72 2d 2d 0a 20 20 69 66 20 7b 5b 66  -r--r--.  if {[f
2880: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 74  ile attributes t
2890: 65 73 74 2e 64 62 20 2d 70 65 72 6d 69 73 73 69  est.db -permissi
28a0: 6f 6e 73 5d 3d 3d 30 36 34 34 7d 20 7b 0a 0a 20  ons]==0644} {.. 
28b0: 20 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37     do_test misc7
28c0: 2d 31 37 2e 31 20 7b 0a 20 20 20 20 20 20 65 78  -17.1 {.      ex
28d0: 65 63 73 71 6c 20 7b 0a 20 20 20 20 20 20 20 20  ecsql {.        
28e0: 42 45 47 49 4e 3b 0a 20 20 20 20 20 20 20 20 44  BEGIN;.        D
28f0: 45 4c 45 54 45 20 46 52 4f 4d 20 74 33 20 57 48  ELETE FROM t3 WH
2900: 45 52 45 20 28 6f 69 64 25 33 29 3d 3d 30 3b 0a  ERE (oid%3)==0;.
2910: 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 63 6f        }.      co
2920: 70 79 5f 66 69 6c 65 20 74 65 73 74 2e 64 62 20  py_file test.db 
2930: 62 61 6b 2e 64 62 0a 20 20 20 20 20 20 63 6f 70  bak.db.      cop
2940: 79 5f 66 69 6c 65 20 74 65 73 74 2e 64 62 2d 6a  y_file test.db-j
2950: 6f 75 72 6e 61 6c 20 62 61 6b 2e 64 62 2d 6a 6f  ournal bak.db-jo
2960: 75 72 6e 61 6c 0a 20 20 20 20 20 20 65 78 65 63  urnal.      exec
2970: 73 71 6c 20 7b 0a 20 20 20 20 20 20 20 20 43 4f  sql {.        CO
2980: 4d 4d 49 54 3b 0a 20 20 20 20 20 20 7d 0a 20 20  MMIT;.      }.  
2990: 20 20 0a 20 20 20 20 20 20 64 62 20 63 6c 6f 73    .      db clos
29a0: 65 0a 20 20 20 20 20 20 63 6f 70 79 5f 66 69 6c  e.      copy_fil
29b0: 65 20 62 61 6b 2e 64 62 20 74 65 73 74 2e 64 62  e bak.db test.db
29c0: 0a 20 20 20 20 20 20 63 6f 70 79 5f 66 69 6c 65  .      copy_file
29d0: 20 62 61 6b 2e 64 62 2d 6a 6f 75 72 6e 61 6c 20   bak.db-journal 
29e0: 74 65 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 0a  test.db-journal.
29f0: 20 20 20 20 20 20 73 71 6c 69 74 65 33 20 64 62        sqlite3 db
2a00: 20 74 65 73 74 2e 64 62 0a 20 20 20 20 0a 20 20   test.db.    .  
2a10: 20 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20      catch {file 
2a20: 61 74 74 72 69 62 75 74 65 73 20 74 65 73 74 2e  attributes test.
2a30: 64 62 2d 6a 6f 75 72 6e 61 6c 20 2d 70 65 72 6d  db-journal -perm
2a40: 69 73 73 69 6f 6e 73 20 72 2d 2d 2d 2d 2d 2d 2d  issions r-------
2a50: 2d 7d 0a 20 20 20 20 20 20 63 61 74 63 68 20 7b  -}.      catch {
2a60: 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20  file attributes 
2a70: 74 65 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 20  test.db-journal 
2a80: 2d 72 65 61 64 6f 6e 6c 79 20 31 7d 0a 20 20 20  -readonly 1}.   
2a90: 20 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20     catchsql {.  
2aa0: 20 20 20 20 20 20 53 45 4c 45 43 54 20 63 6f 75        SELECT cou
2ab0: 6e 74 28 2a 29 20 46 52 4f 4d 20 74 33 3b 0a 20  nt(*) FROM t3;. 
2ac0: 20 20 20 20 20 7d 0a 20 20 20 20 7d 20 7b 31 20       }.    } {1 
2ad0: 7b 75 6e 61 62 6c 65 20 74 6f 20 6f 70 65 6e 20  {unable to open 
2ae0: 64 61 74 61 62 61 73 65 20 66 69 6c 65 7d 7d 0a  database file}}.
2af0: 20 20 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63      do_test misc
2b00: 37 2d 31 37 2e 32 20 7b 0a 20 20 20 20 20 20 23  7-17.2 {.      #
2b10: 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 2d   Note that the -
2b20: 72 65 61 64 6f 6e 6c 79 20 66 6c 61 67 20 6d 75  readonly flag mu
2b30: 73 74 20 62 65 20 63 6c 65 61 72 65 64 20 62 65  st be cleared be
2b40: 66 6f 72 65 20 74 68 65 20 2d 70 65 72 6d 69 73  fore the -permis
2b50: 73 69 6f 6e 73 0a 20 20 20 20 20 20 23 20 61 72  sions.      # ar
2b60: 65 20 73 65 74 2e 20 4f 74 68 65 72 77 69 73 65  e set. Otherwise
2b70: 2c 20 77 68 65 6e 20 75 73 69 6e 67 20 74 63 6c  , when using tcl
2b80: 20 38 2e 35 20 6f 6e 20 6d 61 63 2c 20 74 68 65   8.5 on mac, the
2b90: 20 66 61 63 74 20 74 68 61 74 20 74 68 65 20 0a   fact that the .
2ba0: 20 20 20 20 20 20 23 20 2d 72 65 61 64 6f 6e 6c        # -readonl
2bb0: 79 20 66 6c 61 67 20 69 73 20 73 65 74 20 63 61  y flag is set ca
2bc0: 75 73 65 73 20 74 68 65 20 61 74 74 65 6d 70 74  uses the attempt
2bd0: 20 74 6f 20 73 65 74 20 74 68 65 20 70 65 72 6d   to set the perm
2be0: 69 73 73 69 6f 6e 73 0a 20 20 20 20 20 20 23 20  issions.      # 
2bf0: 74 6f 20 66 61 69 6c 2e 0a 20 20 20 20 20 20 63  to fail..      c
2c00: 61 74 63 68 20 7b 66 69 6c 65 20 61 74 74 72 69  atch {file attri
2c10: 62 75 74 65 73 20 74 65 73 74 2e 64 62 2d 6a 6f  butes test.db-jo
2c20: 75 72 6e 61 6c 20 2d 72 65 61 64 6f 6e 6c 79 20  urnal -readonly 
2c30: 30 7d 0a 20 20 20 20 20 20 63 61 74 63 68 20 7b  0}.      catch {
2c40: 66 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20  file attributes 
2c50: 74 65 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 20  test.db-journal 
2c60: 2d 70 65 72 6d 69 73 73 69 6f 6e 73 20 72 77 2d  -permissions rw-
2c70: 2d 2d 2d 2d 2d 2d 7d 0a 20 20 20 20 20 20 63 61  ------}.      ca
2c80: 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 20 20 20  tchsql {.       
2c90: 20 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 2a 29   SELECT count(*)
2ca0: 20 46 52 4f 4d 20 74 33 3b 0a 20 20 20 20 20 20   FROM t3;.      
2cb0: 7d 0a 20 20 20 20 7d 20 7b 30 20 33 32 7d 0a 20  }.    } {0 32}. 
2cc0: 20 20 20 0a 20 20 20 20 23 20 73 71 6c 69 74 65     .    # sqlite
2cd0: 33 5f 74 65 73 74 5f 63 6f 6e 74 72 6f 6c 5f 70  3_test_control_p
2ce0: 65 6e 64 69 6e 67 5f 70 61 67 65 20 5b 65 78 70  ending_page [exp
2cf0: 72 20 28 24 3a 3a 73 71 6c 69 74 65 5f 70 65 6e  r ($::sqlite_pen
2d00: 64 69 6e 67 5f 62 79 74 65 20 2f 20 31 30 32 34  ding_byte / 1024
2d10: 29 20 2b 20 31 5d 0a 20 20 20 20 73 65 74 20 3a  ) + 1].    set :
2d20: 3a 70 65 6e 64 69 6e 67 5f 62 79 74 65 5f 70 61  :pending_byte_pa
2d30: 67 65 20 5b 65 78 70 72 20 28 24 3a 3a 73 71 6c  ge [expr ($::sql
2d40: 69 74 65 5f 70 65 6e 64 69 6e 67 5f 62 79 74 65  ite_pending_byte
2d50: 20 2f 20 31 30 32 34 29 20 2b 20 31 5d 0a 20 20   / 1024) + 1].  
2d60: 20 20 73 71 6c 69 74 65 33 5f 74 65 73 74 5f 63    sqlite3_test_c
2d70: 6f 6e 74 72 6f 6c 5f 70 65 6e 64 69 6e 67 5f 62  ontrol_pending_b
2d80: 79 74 65 20 24 3a 3a 73 71 6c 69 74 65 5f 70 65  yte $::sqlite_pe
2d90: 6e 64 69 6e 67 5f 62 79 74 65 20 0a 20 20 20 20  nding_byte .    
2da0: 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 37  do_test misc7-17
2db0: 2e 33 20 7b 0a 20 20 20 20 20 20 64 62 20 65 76  .3 {.      db ev
2dc0: 61 6c 20 7b 0a 20 20 20 20 20 20 20 20 70 72 61  al {.        pra
2dd0: 67 6d 61 20 77 72 69 74 61 62 6c 65 5f 73 63 68  gma writable_sch
2de0: 65 6d 61 20 3d 20 74 72 75 65 3b 0a 20 20 20 20  ema = true;.    
2df0: 20 20 20 20 55 50 44 41 54 45 20 73 71 6c 69 74      UPDATE sqlit
2e00: 65 5f 6d 61 73 74 65 72 20 0a 20 20 20 20 20 20  e_master .      
2e10: 20 20 20 20 53 45 54 20 72 6f 6f 74 70 61 67 65      SET rootpage
2e20: 20 3d 20 24 70 65 6e 64 69 6e 67 5f 62 79 74 65   = $pending_byte
2e30: 5f 70 61 67 65 0a 20 20 20 20 20 20 20 20 20 20  _page.          
2e40: 57 48 45 52 45 20 74 79 70 65 20 3d 20 27 74 61  WHERE type = 'ta
2e50: 62 6c 65 27 20 41 4e 44 20 6e 61 6d 65 20 3d 20  ble' AND name = 
2e60: 27 74 33 27 3b 0a 20 20 20 20 20 20 7d 0a 20 20  't3';.      }.  
2e70: 20 20 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20      execsql {.  
2e80: 20 20 20 20 20 20 53 45 4c 45 43 54 20 72 6f 6f        SELECT roo
2e90: 74 70 61 67 65 20 46 52 4f 4d 20 73 71 6c 69 74  tpage FROM sqlit
2ea0: 65 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20 74  e_master WHERE t
2eb0: 79 70 65 20 3d 20 27 74 61 62 6c 65 27 20 41 4e  ype = 'table' AN
2ec0: 44 20 6e 61 6d 65 20 3d 20 27 74 33 27 3b 0a 20  D name = 't3';. 
2ed0: 20 20 20 20 20 7d 0a 20 20 20 20 7d 20 24 3a 3a       }.    } $::
2ee0: 70 65 6e 64 69 6e 67 5f 62 79 74 65 5f 70 61 67  pending_byte_pag
2ef0: 65 0a 20 20 20 20 0a 20 20 20 20 64 6f 5f 74 65  e.    .    do_te
2f00: 73 74 20 6d 69 73 63 37 2d 31 37 2e 34 20 7b 0a  st misc7-17.4 {.
2f10: 20 20 20 20 20 20 64 62 20 63 6c 6f 73 65 0a 20        db close. 
2f20: 20 20 20 20 20 73 71 6c 69 74 65 33 20 64 62 20       sqlite3 db 
2f30: 74 65 73 74 2e 64 62 0a 20 20 20 20 20 20 63 61  test.db.      ca
2f40: 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 20 20 20  tchsql {.       
2f50: 20 53 45 4c 45 43 54 20 63 6f 75 6e 74 28 2a 29   SELECT count(*)
2f60: 20 46 52 4f 4d 20 74 33 3b 0a 20 20 20 20 20 20   FROM t3;.      
2f70: 7d 20 0a 20 20 20 20 7d 20 7b 31 20 7b 64 61 74  } .    } {1 {dat
2f80: 61 62 61 73 65 20 64 69 73 6b 20 69 6d 61 67 65  abase disk image
2f90: 20 69 73 20 6d 61 6c 66 6f 72 6d 65 64 7d 7d 0a   is malformed}}.
2fa0: 20 20 7d 0a 7d 0a 0a 23 20 54 69 63 6b 65 74 20    }.}..# Ticket 
2fb0: 23 32 34 37 30 0a 23 0a 64 6f 5f 74 65 73 74 20  #2470.#.do_test 
2fc0: 6d 69 73 63 37 2d 31 38 2e 31 20 7b 0a 20 20 65  misc7-18.1 {.  e
2fd0: 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 43 52 45  xecsql {.    CRE
2fe0: 41 54 45 20 54 41 42 4c 45 20 74 61 62 6c 65 5f  ATE TABLE table_
2ff0: 31 20 28 63 6f 6c 5f 31 30 29 3b 0a 20 20 20 20  1 (col_10);.    
3000: 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 61 62  CREATE TABLE tab
3010: 6c 65 5f 32 20 28 0a 20 20 20 20 20 20 63 6f 6c  le_2 (.      col
3020: 5f 31 2c 20 63 6f 6c 5f 32 2c 20 63 6f 6c 5f 33  _1, col_2, col_3
3030: 2c 20 63 6f 6c 5f 34 2c 20 63 6f 6c 5f 35 2c 0a  , col_4, col_5,.
3040: 20 20 20 20 20 20 63 6f 6c 5f 36 2c 20 63 6f 6c        col_6, col
3050: 5f 37 2c 20 63 6f 6c 5f 38 2c 20 63 6f 6c 5f 39  _7, col_8, col_9
3060: 2c 20 63 6f 6c 5f 31 30 0a 20 20 20 20 29 3b 0a  , col_10.    );.
3070: 20 20 20 20 53 45 4c 45 43 54 20 61 2e 63 6f 6c      SELECT a.col
3080: 5f 31 30 0a 20 20 20 20 46 52 4f 4d 0a 20 20 20  _10.    FROM.   
3090: 20 20 20 28 53 45 4c 45 43 54 20 74 61 62 6c 65     (SELECT table
30a0: 5f 31 2e 63 6f 6c 5f 31 30 20 41 53 20 63 6f 6c  _1.col_10 AS col
30b0: 5f 31 30 20 46 52 4f 4d 20 74 61 62 6c 65 5f 31  _10 FROM table_1
30c0: 29 20 61 2c 0a 20 20 20 20 20 20 28 53 45 4c 45  ) a,.      (SELE
30d0: 43 54 20 74 61 62 6c 65 5f 31 2e 63 6f 6c 5f 31  CT table_1.col_1
30e0: 30 2c 20 74 61 62 6c 65 5f 32 2e 63 6f 6c 5f 39  0, table_2.col_9
30f0: 20 41 53 20 71 63 6f 6c 5f 39 0a 20 20 20 20 20   AS qcol_9.     
3100: 20 20 20 20 46 52 4f 4d 20 74 61 62 6c 65 5f 31      FROM table_1
3110: 2c 20 74 61 62 6c 65 5f 32 0a 20 20 20 20 20 20  , table_2.      
3120: 20 20 47 52 4f 55 50 20 42 59 20 74 61 62 6c 65    GROUP BY table
3130: 5f 31 2e 63 6f 6c 5f 31 30 2c 20 71 63 6f 6c 5f  _1.col_10, qcol_
3140: 39 29 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 23 20  9);.  }.} {}..# 
3150: 54 65 73 74 69 6e 67 20 62 6f 75 6e 64 61 72 79  Testing boundary
3160: 20 63 6f 6e 64 69 74 69 6f 6e 73 20 6f 6e 20 73   conditions on s
3170: 71 6c 69 74 65 33 5f 73 74 61 74 75 73 28 29 0a  qlite3_status().
3180: 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d  #.do_test misc7-
3190: 31 39 2e 31 20 7b 0a 20 20 73 71 6c 69 74 65 33  19.1 {.  sqlite3
31a0: 5f 73 74 61 74 75 73 20 2d 31 20 30 0a 7d 20 7b  _status -1 0.} {
31b0: 32 31 20 30 20 30 7d 0a 64 6f 5f 74 65 73 74 20  21 0 0}.do_test 
31c0: 6d 69 73 63 37 2d 31 39 2e 32 20 7b 0a 20 20 73  misc7-19.2 {.  s
31d0: 71 6c 69 74 65 33 5f 73 74 61 74 75 73 20 31 30  qlite3_status 10
31e0: 30 30 20 30 0a 7d 20 7b 32 31 20 30 20 30 7d 0a  00 0.} {21 0 0}.
31f0: 0a 0a 23 20 73 71 6c 69 74 65 33 5f 67 6c 6f 62  ..# sqlite3_glob
3200: 61 6c 5f 72 65 63 6f 76 65 72 28 29 20 69 73 20  al_recover() is 
3210: 61 20 6e 6f 2d 6f 70 2e 20 20 42 75 74 20 77 65  a no-op.  But we
3220: 20 6d 69 67 68 74 20 61 73 20 77 65 6c 6c 20 74   might as well t
3230: 65 73 74 20 69 74 0a 23 20 69 66 20 6f 6e 6c 79  est it.# if only
3240: 20 74 6f 20 67 65 74 20 74 68 65 20 74 65 73 74   to get the test
3250: 20 63 6f 76 65 72 61 67 65 2e 0a 23 0a 64 6f 5f   coverage..#.do_
3260: 74 65 73 74 20 6d 69 73 63 37 2d 32 30 2e 31 20  test misc7-20.1 
3270: 7b 0a 20 20 73 71 6c 69 74 65 33 5f 67 6c 6f 62  {.  sqlite3_glob
3280: 61 6c 5f 72 65 63 6f 76 65 72 0a 7d 20 7b 53 51  al_recover.} {SQ
3290: 4c 49 54 45 5f 4f 4b 7d 0a 0a 23 20 54 72 79 20  LITE_OK}..# Try 
32a0: 74 6f 20 6f 70 65 6e 20 61 20 72 65 61 6c 6c 79  to open a really
32b0: 20 6c 6f 6e 67 20 66 69 6c 65 20 6e 61 6d 65 2e   long file name.
32c0: 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37  .#.do_test misc7
32d0: 2d 32 31 2e 31 20 7b 0a 20 20 73 65 74 20 7a 46  -21.1 {.  set zF
32e0: 69 6c 65 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 5b  ile [file join [
32f0: 70 77 64 5d 20 22 5b 73 74 72 69 6e 67 20 72 65  pwd] "[string re
3300: 70 65 61 74 20 61 62 63 64 65 20 31 30 34 5d 2e  peat abcde 104].
3310: 64 62 22 5d 0a 20 20 73 65 74 20 72 63 20 5b 63  db"].  set rc [c
3320: 61 74 63 68 20 7b 73 71 6c 69 74 65 33 20 64 62  atch {sqlite3 db
3330: 32 20 24 7a 46 69 6c 65 7d 20 6d 73 67 5d 0a 20  2 $zFile} msg]. 
3340: 20 6c 69 73 74 20 24 72 63 20 24 6d 73 67 0a 7d   list $rc $msg.}
3350: 20 7b 31 20 7b 75 6e 61 62 6c 65 20 74 6f 20 6f   {1 {unable to o
3360: 70 65 6e 20 64 61 74 61 62 61 73 65 20 66 69 6c  pen database fil
3370: 65 7d 7d 0a 0a 0a 64 62 20 63 6c 6f 73 65 0a 66  e}}...db close.f
3380: 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63  ile delete -forc
3390: 65 20 74 65 73 74 2e 64 62 0a 0a 66 69 6e 69 73  e test.db..finis
33a0: 68 5f 74 65 73 74 0a                             h_test.