/ Hex Artifact Content
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Artifact c5f4e6a82e04e71820c0f9f64f6733f04c8ae0ae:


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 39 20  sc7.test,v 1.29 
01c0: 32 30 30 39 2f 30 37 2f 31 36 20 31 38 3a 32 31  2009/07/16 18:21
01d0: 3a 31 38 20 64 72 68 20 45 78 70 20 24 0a 0a 73  :18 drh Exp $..s
01e0: 65 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c 65  et testdir [file
01f0: 20 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30 5d   dirname $argv0]
0200: 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72  .source $testdir
0210: 2f 74 65 73 74 65 72 2e 74 63 6c 0a 0a 64 6f 5f  /tester.tcl..do_
0220: 74 65 73 74 20 6d 69 73 63 37 2d 31 2d 6d 69 73  test misc7-1-mis
0230: 75 73 65 20 7b 0a 20 20 63 5f 6d 69 73 75 73 65  use {.  c_misuse
0240: 5f 74 65 73 74 0a 7d 20 7b 7d 0a 0a 64 6f 5f 74  _test.} {}..do_t
0250: 65 73 74 20 6d 69 73 63 37 2d 32 20 7b 0a 20 20  est misc7-2 {.  
0260: 63 5f 72 65 61 6c 6c 6f 63 5f 74 65 73 74 0a 7d  c_realloc_test.}
0270: 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 6d 69 73   {}..do_test mis
0280: 63 37 2d 33 20 7b 0a 20 20 63 5f 63 6f 6c 6c 61  c7-3 {.  c_colla
0290: 74 69 6f 6e 5f 74 65 73 74 0a 7d 20 7b 7d 0a 0a  tion_test.} {}..
02a0: 23 20 54 72 79 20 74 6f 20 6f 70 65 6e 20 61 20  # Try to open a 
02b0: 64 69 72 65 63 74 6f 72 79 3a 0a 23 0a 64 6f 5f  directory:.#.do_
02c0: 74 65 73 74 20 6d 69 73 63 37 2d 34 20 7b 0a 20  test misc7-4 {. 
02d0: 20 66 69 6c 65 20 64 65 6c 65 74 65 20 6d 79 64   file delete myd
02e0: 69 72 0a 20 20 66 69 6c 65 20 6d 6b 64 69 72 20  ir.  file mkdir 
02f0: 6d 79 64 69 72 0a 20 20 73 65 74 20 72 63 20 5b  mydir.  set rc [
0300: 63 61 74 63 68 20 7b 0a 20 20 20 20 73 71 6c 69  catch {.    sqli
0310: 74 65 33 20 64 62 32 20 2e 2f 6d 79 64 69 72 0a  te3 db2 ./mydir.
0320: 20 20 7d 20 6d 73 67 5d 0a 20 20 6c 69 73 74 20    } msg].  list 
0330: 24 72 63 20 24 6d 73 67 0a 7d 20 7b 31 20 7b 75  $rc $msg.} {1 {u
0340: 6e 61 62 6c 65 20 74 6f 20 6f 70 65 6e 20 64 61  nable to open da
0350: 74 61 62 61 73 65 20 66 69 6c 65 7d 7d 0a 0a 23  tabase file}}..#
0360: 20 54 72 79 20 74 6f 20 6f 70 65 6e 20 61 20 66   Try to open a f
0370: 69 6c 65 20 77 69 74 68 20 61 20 64 69 72 65 63  ile with a direc
0380: 74 6f 72 79 20 77 68 65 72 65 20 69 74 73 20 6a  tory where its j
0390: 6f 75 72 6e 61 6c 20 66 69 6c 65 20 73 68 6f 75  ournal file shou
03a0: 6c 64 20 62 65 2e 0a 23 0a 64 6f 5f 74 65 73 74  ld be..#.do_test
03b0: 20 6d 69 73 63 37 2d 35 20 7b 0a 20 20 66 69 6c   misc7-5 {.  fil
03c0: 65 20 64 65 6c 65 74 65 20 6d 79 64 69 72 0a 20  e delete mydir. 
03d0: 20 66 69 6c 65 20 6d 6b 64 69 72 20 6d 79 64 69   file mkdir mydi
03e0: 72 2d 6a 6f 75 72 6e 61 6c 0a 20 20 73 71 6c 69  r-journal.  sqli
03f0: 74 65 33 20 64 62 32 20 2e 2f 6d 79 64 69 72 0a  te3 db2 ./mydir.
0400: 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20    catchsql {.   
0410: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62   CREATE TABLE ab
0420: 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 7d 20  c(a, b, c);.  } 
0430: 64 62 32 0a 7d 20 7b 31 20 7b 75 6e 61 62 6c 65  db2.} {1 {unable
0440: 20 74 6f 20 6f 70 65 6e 20 64 61 74 61 62 61 73   to open databas
0450: 65 20 66 69 6c 65 7d 7d 0a 64 62 32 20 63 6c 6f  e file}}.db2 clo
0460: 73 65 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  se..#-----------
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 0a 23 20 54 68 65 20  ---------.# The 
04b0: 66 6f 6c 6c 6f 77 69 6e 67 20 74 65 73 74 73 2c  following tests,
04c0: 20 6d 69 73 63 37 2d 36 2e 2a 20 74 65 73 74 20   misc7-6.* test 
04d0: 74 68 65 20 6c 69 62 72 61 72 69 65 73 20 62 65  the libraries be
04e0: 68 61 76 69 6f 75 72 20 77 68 65 6e 0a 23 20 69  haviour when.# i
04f0: 74 20 63 61 6e 6e 6f 74 20 6f 70 65 6e 20 61 20  t cannot open a 
0500: 66 69 6c 65 2e 20 54 6f 20 66 6f 72 63 65 20 74  file. To force t
0510: 68 69 73 20 63 6f 6e 64 69 74 69 6f 6e 2c 20 77  his condition, w
0520: 65 20 75 73 65 20 75 70 20 61 6c 6c 20 74 68 65  e use up all the
0530: 0a 23 20 66 69 6c 65 2d 64 65 73 63 72 69 70 74  .# file-descript
0540: 6f 72 73 20 62 65 66 6f 72 65 20 72 75 6e 6e 69  ors before runni
0550: 6e 67 20 73 71 6c 69 74 65 2e 20 54 68 69 73 20  ng sqlite. This 
0560: 70 72 6f 62 61 62 6c 79 20 6f 6e 6c 79 20 77 6f  probably only wo
0570: 72 6b 73 0a 23 20 6f 6e 20 75 6e 69 78 2e 0a 23  rks.# on unix..#
0580: 0a 0a 70 72 6f 63 20 75 73 65 5f 75 70 5f 66 69  ..proc use_up_fi
0590: 6c 65 73 20 7b 7d 20 7b 0a 20 20 73 65 74 20 72  les {} {.  set r
05a0: 65 74 20 5b 6c 69 73 74 5d 0a 20 20 63 61 74 63  et [list].  catc
05b0: 68 20 7b 0a 20 20 20 20 77 68 69 6c 65 20 31 20  h {.    while 1 
05c0: 7b 20 6c 61 70 70 65 6e 64 20 72 65 74 20 5b 6f  { lappend ret [o
05d0: 70 65 6e 20 74 65 73 74 2e 64 62 5d 20 7d 0a 20  pen test.db] }. 
05e0: 20 7d 0a 20 20 72 65 74 75 72 6e 20 24 72 65 74   }.  return $ret
05f0: 0a 7d 0a 0a 70 72 6f 63 20 64 6f 5f 66 69 6c 65  .}..proc do_file
0600: 6f 70 65 6e 5f 74 65 73 74 20 7b 70 72 65 66 69  open_test {prefi
0610: 78 20 73 71 6c 7d 20 7b 0a 20 20 73 65 74 20 66  x sql} {.  set f
0620: 64 5f 6c 69 73 74 20 5b 75 73 65 5f 75 70 5f 66  d_list [use_up_f
0630: 69 6c 65 73 5d 0a 20 20 73 65 74 20 3a 3a 67 6f  iles].  set ::go
0640: 20 31 0a 20 20 73 65 74 20 3a 3a 6e 20 31 0a 20   1.  set ::n 1. 
0650: 20 73 65 74 20 3a 3a 73 71 6c 20 24 73 71 6c 0a   set ::sql $sql.
0660: 20 20 77 68 69 6c 65 20 7b 24 3a 3a 67 6f 7d 20    while {$::go} 
0670: 7b 0a 20 20 20 20 63 61 74 63 68 20 7b 64 62 20  {.    catch {db 
0680: 63 6c 6f 73 65 7d 0a 20 20 20 20 64 6f 5f 74 65  close}.    do_te
0690: 73 74 20 24 7b 70 72 65 66 69 78 7d 2e 24 7b 3a  st ${prefix}.${:
06a0: 3a 6e 7d 20 7b 0a 20 20 20 20 20 20 73 65 74 20  :n} {.      set 
06b0: 72 63 20 5b 63 61 74 63 68 20 7b 0a 20 20 20 20  rc [catch {.    
06c0: 20 20 20 20 73 71 6c 69 74 65 20 64 62 20 74 65      sqlite db te
06d0: 73 74 2e 64 62 0a 20 20 20 20 20 20 20 20 64 62  st.db.        db
06e0: 20 65 76 61 6c 20 24 3a 3a 73 71 6c 0a 20 20 20   eval $::sql.   
06f0: 20 20 20 7d 20 6d 73 67 5d 0a 20 20 20 20 20 20     } msg].      
0700: 69 66 20 7b 24 72 63 20 3d 3d 20 30 7d 20 7b 73  if {$rc == 0} {s
0710: 65 74 20 3a 3a 67 6f 20 30 7d 0a 20 20 0a 20 20  et ::go 0}.  .  
0720: 20 20 20 20 65 78 70 72 20 7b 24 72 63 20 3d 3d      expr {$rc ==
0730: 20 30 20 7c 7c 20 28 24 72 63 20 3d 3d 20 31 20   0 || ($rc == 1 
0740: 26 26 20 5b 73 74 72 69 6e 67 20 66 69 72 73 74  && [string first
0750: 20 75 6e 61 62 6c 65 20 24 6d 73 67 5d 3d 3d 30   unable $msg]==0
0760: 29 7d 0a 20 20 20 20 7d 20 31 0a 20 20 0a 20 20  )}.    } 1.  .  
0770: 20 20 63 6c 6f 73 65 20 5b 6c 69 6e 64 65 78 20    close [lindex 
0780: 24 66 64 5f 6c 69 73 74 20 30 5d 0a 20 20 20 20  $fd_list 0].    
0790: 73 65 74 20 66 64 5f 6c 69 73 74 20 5b 6c 72 61  set fd_list [lra
07a0: 6e 67 65 20 24 66 64 5f 6c 69 73 74 20 31 20 65  nge $fd_list 1 e
07b0: 6e 64 5d 0a 20 20 20 20 69 6e 63 72 20 3a 3a 6e  nd].    incr ::n
07c0: 0a 20 20 7d 0a 20 20 66 6f 72 65 61 63 68 20 66  .  }.  foreach f
07d0: 64 20 24 66 64 5f 6c 69 73 74 20 7b 0a 20 20 20  d $fd_list {.   
07e0: 20 63 6c 6f 73 65 20 24 66 64 0a 20 20 7d 0a 20   close $fd.  }. 
07f0: 20 64 62 20 63 6c 6f 73 65 0a 7d 0a 0a 65 78 65   db close.}..exe
0800: 63 73 71 6c 20 7b 20 43 52 45 41 54 45 20 54 41  csql { CREATE TA
0810: 42 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41 52  BLE abc(a PRIMAR
0820: 59 20 4b 45 59 2c 20 62 2c 20 63 29 3b 20 7d 0a  Y KEY, b, c); }.
0830: 64 62 20 63 6c 6f 73 65 0a 0a 69 66 20 7b 24 74  db close..if {$t
0840: 63 6c 5f 70 6c 61 74 66 6f 72 6d 28 70 6c 61 74  cl_platform(plat
0850: 66 6f 72 6d 29 21 3d 22 77 69 6e 64 6f 77 73 22  form)!="windows"
0860: 7d 20 7b 0a 20 20 64 6f 5f 66 69 6c 65 6f 70 65  } {.  do_fileope
0870: 6e 5f 74 65 73 74 20 6d 69 73 63 37 2d 36 2e 31  n_test misc7-6.1
0880: 20 7b 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20 20   {.    BEGIN;.  
0890: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62    INSERT INTO ab
08a0: 63 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 33  c VALUES(1, 2, 3
08b0: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
08c0: 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 32 2c  TO abc VALUES(2,
08d0: 20 33 2c 20 34 29 3b 0a 20 20 20 20 49 4e 53 45   3, 4);.    INSE
08e0: 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45  RT INTO abc SELE
08f0: 43 54 20 61 2b 32 2c 20 62 2c 20 63 20 46 52 4f  CT a+2, b, c FRO
0900: 4d 20 61 62 63 3b 0a 20 20 20 20 43 4f 4d 4d 49  M abc;.    COMMI
0910: 54 3b 0a 20 20 7d 0a 20 20 0a 20 20 64 6f 5f 66  T;.  }.  .  do_f
0920: 69 6c 65 6f 70 65 6e 5f 74 65 73 74 20 6d 69 73  ileopen_test mis
0930: 63 37 2d 36 2e 32 20 7b 0a 20 20 20 20 50 52 41  c7-6.2 {.    PRA
0940: 47 4d 41 20 74 65 6d 70 2e 63 61 63 68 65 5f 73  GMA temp.cache_s
0950: 69 7a 65 20 3d 20 31 30 30 30 3b 0a 20 20 7d 0a  ize = 1000;.  }.
0960: 7d 0a 0a 23 0a 23 20 45 6e 64 20 6f 66 20 74 65  }..#.# End of te
0970: 73 74 73 20 66 6f 72 20 6f 75 74 2d 6f 66 2d 66  sts for out-of-f
0980: 69 6c 65 2d 64 65 73 63 72 69 70 74 6f 72 73 20  ile-descriptors 
0990: 63 6f 6e 64 69 74 69 6f 6e 2e 0a 23 2d 2d 2d 2d  condition..#----
09a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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: 0a 0a 73 71 6c 69 74 65 33 20 64 62 20 74 65 73  ..sqlite3 db tes
09f0: 74 2e 64 62 0a 65 78 65 63 73 71 6c 20 7b 0a 20  t.db.execsql {. 
0a00: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 61 62 63   DELETE FROM abc
0a10: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
0a20: 61 62 63 20 56 41 4c 55 45 53 28 31 2c 20 32 2c  abc VALUES(1, 2,
0a30: 20 33 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e   3);.  INSERT IN
0a40: 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 32 2c  TO abc VALUES(2,
0a50: 20 33 2c 20 34 29 3b 0a 20 20 49 4e 53 45 52 54   3, 4);.  INSERT
0a60: 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54   INTO abc SELECT
0a70: 20 61 2b 32 2c 20 62 2c 20 63 20 46 52 4f 4d 20   a+2, b, c FROM 
0a80: 61 62 63 3b 0a 7d 0a 20 20 0a 0a 23 2d 2d 2d 2d  abc;.}.  ..#----
0a90: 2d 2d 2d 2d 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: 0a 23 20 54 65 73 74 20 74 68 61 74 20 74 68 65  .# Test that the
0ae0: 20 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 74 69   sqlite3_busy_ti
0af0: 6d 65 6f 75 74 20 63 61 6c 6c 20 73 65 65 6d 73  meout call seems
0b00: 20 74 6f 20 64 65 6c 61 79 20 61 70 70 72 6f 78   to delay approx
0b10: 69 6d 61 74 65 6c 79 0a 23 20 74 68 65 20 72 69  imately.# the ri
0b20: 67 68 74 20 61 6d 6f 75 6e 74 20 6f 66 20 74 69  ght amount of ti
0b30: 6d 65 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69  me..#.do_test mi
0b40: 73 63 37 2d 37 2e 30 20 7b 0a 20 20 73 71 6c 69  sc7-7.0 {.  sqli
0b50: 74 65 33 20 64 62 32 20 74 65 73 74 2e 64 62 0a  te3 db2 test.db.
0b60: 20 20 73 71 6c 69 74 65 33 5f 62 75 73 79 5f 74    sqlite3_busy_t
0b70: 69 6d 65 6f 75 74 20 5b 73 71 6c 69 74 65 33 5f  imeout [sqlite3_
0b80: 63 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f 69 6e 74  connection_point
0b90: 65 72 20 64 62 5d 20 32 30 30 30 0a 20 20 65 78  er db] 2000.  ex
0ba0: 65 63 73 71 6c 20 7b 0a 20 20 20 20 42 45 47 49  ecsql {.    BEGI
0bb0: 4e 20 45 58 43 4c 55 53 49 56 45 3b 0a 20 20 7d  N EXCLUSIVE;.  }
0bc0: 20 64 62 32 0a 0a 20 20 23 20 4e 6f 77 20 64 62   db2..  # Now db
0bd0: 32 20 68 61 73 20 61 6e 20 65 78 63 6c 75 73 69  2 has an exclusi
0be0: 76 65 20 6c 6f 63 6b 20 6f 6e 20 74 68 65 20 64  ve lock on the d
0bf0: 61 74 61 62 61 73 65 20 66 69 6c 65 2c 20 61 6e  atabase file, an
0c00: 64 20 64 62 20 68 61 73 0a 20 20 23 20 61 20 62  d db has.  # a b
0c10: 75 73 79 2d 74 69 6d 65 6f 75 74 20 6f 66 20 32  usy-timeout of 2
0c20: 30 30 30 20 6d 69 6c 6c 69 73 65 63 6f 6e 64 73  000 milliseconds
0c30: 2e 20 53 6f 20 63 68 65 63 6b 20 74 68 61 74 20  . So check that 
0c40: 74 72 79 69 6e 67 20 74 6f 0a 20 20 23 20 61 63  trying to.  # ac
0c50: 63 65 73 73 20 74 68 65 20 64 61 74 61 62 61 73  cess the databas
0c60: 65 20 75 73 69 6e 67 20 63 6f 6e 6e 65 63 74 69  e using connecti
0c70: 6f 6e 20 64 62 20 64 65 6c 61 79 73 20 66 6f 72  on db delays for
0c80: 20 61 74 20 6c 65 61 73 74 20 31 35 30 30 20 6d   at least 1500 m
0c90: 73 2e 0a 20 20 23 0a 20 20 73 65 74 20 74 6d 20  s..  #.  set tm 
0ca0: 5b 74 69 6d 65 20 7b 0a 20 20 20 20 73 65 74 20  [time {.    set 
0cb0: 72 65 73 75 6c 74 20 5b 63 61 74 63 68 73 71 6c  result [catchsql
0cc0: 20 7b 0a 20 20 20 20 20 20 20 20 53 45 4c 45 43   {.        SELEC
0cd0: 54 20 2a 20 46 52 4f 4d 20 73 71 6c 69 74 65 5f  T * FROM sqlite_
0ce0: 6d 61 73 74 65 72 3b 0a 20 20 20 20 20 20 7d 20  master;.      } 
0cf0: 64 62 5d 0a 20 20 7d 5d 0a 20 20 73 65 74 20 64  db].  }].  set d
0d00: 65 6c 61 79 20 5b 6c 69 6e 64 65 78 20 24 74 6d  elay [lindex $tm
0d10: 20 30 5d 20 20 3b 23 20 49 6e 20 6d 69 63 72 6f   0]  ;# In micro
0d20: 73 65 63 6f 6e 64 73 0a 20 20 6c 61 70 70 65 6e  seconds.  lappen
0d30: 64 20 72 65 73 75 6c 74 20 5b 65 78 70 72 20 7b  d result [expr {
0d40: 24 64 65 6c 61 79 3e 31 35 30 30 30 30 30 20 26  $delay>1500000 &
0d50: 26 20 24 64 65 6c 61 79 3c 34 30 30 30 30 30 30  & $delay<4000000
0d60: 7d 5d 0a 7d 20 7b 31 20 7b 64 61 74 61 62 61 73  }].} {1 {databas
0d70: 65 20 69 73 20 6c 6f 63 6b 65 64 7d 20 31 7d 0a  e is locked} 1}.
0d80: 64 62 32 20 63 6c 6f 73 65 0a 0a 23 2d 2d 2d 2d  db2 close..#----
0d90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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: 0a 23 20 54 65 73 74 20 74 68 61 74 20 6e 6f 74  .# Test that not
0de0: 68 69 6e 67 20 67 6f 65 73 20 68 6f 72 72 69 62  hing goes horrib
0df0: 6c 79 20 77 72 6f 6e 67 20 77 68 65 6e 20 61 74  ly wrong when at
0e00: 74 61 63 68 69 6e 67 20 61 20 64 61 74 61 62 61  taching a databa
0e10: 73 65 0a 23 20 61 66 74 65 72 20 74 68 65 20 6f  se.# after the o
0e20: 6d 69 74 5f 72 65 61 64 6c 6f 63 6b 20 70 72 61  mit_readlock pra
0e30: 67 6d 61 20 68 61 73 20 62 65 65 6e 20 65 78 65  gma has been exe
0e40: 72 63 69 73 65 64 2e 0a 23 0a 64 6f 5f 74 65 73  rcised..#.do_tes
0e50: 74 20 6d 69 73 63 37 2d 37 2e 31 20 7b 0a 20 20  t misc7-7.1 {.  
0e60: 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72  file delete -for
0e70: 63 65 20 74 65 73 74 32 2e 64 62 0a 20 20 66 69  ce test2.db.  fi
0e80: 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65  le delete -force
0e90: 20 74 65 73 74 32 2e 64 62 2d 6a 6f 75 72 6e 61   test2.db-journa
0ea0: 6c 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  l.  execsql {.  
0eb0: 20 20 50 52 41 47 4d 41 20 6f 6d 69 74 5f 72 65    PRAGMA omit_re
0ec0: 61 64 6c 6f 63 6b 20 3d 20 31 3b 0a 20 20 20 20  adlock = 1;.    
0ed0: 41 54 54 41 43 48 20 27 74 65 73 74 32 2e 64 62  ATTACH 'test2.db
0ee0: 27 20 41 53 20 61 75 78 3b 0a 20 20 20 20 43 52  ' AS aux;.    CR
0ef0: 45 41 54 45 20 54 41 42 4c 45 20 61 75 78 2e 68  EATE TABLE aux.h
0f00: 65 6c 6c 6f 28 77 6f 72 6c 64 29 3b 0a 20 20 20  ello(world);.   
0f10: 20 53 45 4c 45 43 54 20 6e 61 6d 65 20 46 52 4f   SELECT name FRO
0f20: 4d 20 61 75 78 2e 73 71 6c 69 74 65 5f 6d 61 73  M aux.sqlite_mas
0f30: 74 65 72 3b 0a 20 20 7d 0a 7d 20 7b 68 65 6c 6c  ter;.  }.} {hell
0f40: 6f 7d 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37  o}.do_test misc7
0f50: 2d 37 2e 32 20 7b 0a 20 20 65 78 65 63 73 71 6c  -7.2 {.  execsql
0f60: 20 7b 0a 20 20 20 20 44 45 54 41 43 48 20 61 75   {.    DETACH au
0f70: 78 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 64 6f 5f 74  x;.  }.} {}.do_t
0f80: 65 73 74 20 6d 69 73 63 37 2d 37 2e 33 20 7b 0a  est misc7-7.3 {.
0f90: 20 20 64 62 20 63 6c 6f 73 65 0a 20 20 73 71 6c    db close.  sql
0fa0: 69 74 65 33 20 64 62 20 74 65 73 74 2e 64 62 20  ite3 db test.db 
0fb0: 2d 72 65 61 64 6f 6e 6c 79 20 31 0a 20 20 65 78  -readonly 1.  ex
0fc0: 65 63 73 71 6c 20 7b 0a 20 20 20 20 50 52 41 47  ecsql {.    PRAG
0fd0: 4d 41 20 6f 6d 69 74 5f 72 65 61 64 6c 6f 63 6b  MA omit_readlock
0fe0: 20 3d 20 31 3b 0a 20 20 20 20 41 54 54 41 43 48   = 1;.    ATTACH
0ff0: 20 27 74 65 73 74 32 2e 64 62 27 20 41 53 20 61   'test2.db' AS a
1000: 75 78 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 6e  ux;.    SELECT n
1010: 61 6d 65 20 46 52 4f 4d 20 61 75 78 2e 73 71 6c  ame FROM aux.sql
1020: 69 74 65 5f 6d 61 73 74 65 72 3b 0a 20 20 20 20  ite_master;.    
1030: 53 45 4c 45 43 54 20 6e 61 6d 65 20 46 52 4f 4d  SELECT name FROM
1040: 20 61 75 78 2e 73 71 6c 69 74 65 5f 6d 61 73 74   aux.sqlite_mast
1050: 65 72 3b 0a 20 20 7d 0a 7d 20 7b 68 65 6c 6c 6f  er;.  }.} {hello
1060: 20 68 65 6c 6c 6f 7d 0a 64 6f 5f 74 65 73 74 20   hello}.do_test 
1070: 6d 69 73 63 37 2d 37 2e 33 20 7b 0a 20 20 64 62  misc7-7.3 {.  db
1080: 20 63 6c 6f 73 65 0a 20 20 73 71 6c 69 74 65 33   close.  sqlite3
1090: 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20 73 65   db test.db.  se
10a0: 74 20 3a 3a 44 42 20 5b 73 71 6c 69 74 65 33 5f  t ::DB [sqlite3_
10b0: 63 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f 69 6e 74  connection_point
10c0: 65 72 20 64 62 5d 0a 20 20 6c 69 73 74 0a 7d 20  er db].  list.} 
10d0: 7b 7d 0a 0a 23 20 54 65 73 74 20 74 68 65 20 55  {}..# Test the U
10e0: 54 46 2d 31 36 20 76 65 72 73 69 6f 6e 20 6f 66  TF-16 version of
10f0: 20 74 68 65 20 22 6f 75 74 20 6f 66 20 6d 65 6d   the "out of mem
1100: 6f 72 79 22 20 6d 65 73 73 61 67 65 20 28 75 73  ory" message (us
1110: 65 64 20 77 68 65 6e 0a 23 20 6d 61 6c 6c 6f 63  ed when.# malloc
1120: 20 66 61 69 6c 73 20 64 75 72 69 6e 67 20 73 71   fails during sq
1130: 6c 69 74 65 33 5f 6f 70 65 6e 28 29 20 29 2e 0a  lite3_open() )..
1140: 23 0a 69 66 63 61 70 61 62 6c 65 20 75 74 66 31  #.ifcapable utf1
1150: 36 20 7b 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69  6 {.  do_test mi
1160: 73 63 37 2d 38 20 7b 0a 20 20 20 20 65 6e 63 6f  sc7-8 {.    enco
1170: 64 69 6e 67 20 63 6f 6e 76 65 72 74 66 72 6f 6d  ding convertfrom
1180: 20 75 6e 69 63 6f 64 65 20 5b 73 71 6c 69 74 65   unicode [sqlite
1190: 33 5f 65 72 72 6d 73 67 31 36 20 30 78 30 30 30  3_errmsg16 0x000
11a0: 30 30 30 30 30 5d 0a 20 20 7d 20 7b 6f 75 74 20  00000].  } {out 
11b0: 6f 66 20 6d 65 6d 6f 72 79 7d 0a 7d 0a 0a 64 6f  of memory}.}..do
11c0: 5f 74 65 73 74 20 6d 69 73 63 37 2d 39 20 7b 0a  _test misc7-9 {.
11d0: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
11e0: 53 45 4c 45 43 54 20 2a 20 0a 20 20 20 20 46 52  SELECT * .    FR
11f0: 4f 4d 20 28 53 45 4c 45 43 54 20 6e 61 6d 65 2b  OM (SELECT name+
1200: 31 20 41 53 20 6f 6e 65 20 46 52 4f 4d 20 73 71  1 AS one FROM sq
1210: 6c 69 74 65 5f 6d 61 73 74 65 72 20 4c 49 4d 49  lite_master LIMI
1220: 54 20 31 20 4f 46 46 53 45 54 20 31 29 20 0a 20  T 1 OFFSET 1) . 
1230: 20 20 20 57 48 45 52 45 20 6f 6e 65 20 4c 49 4b     WHERE one LIK
1240: 45 20 27 68 65 6c 6c 6f 25 27 3b 0a 20 20 7d 0a  E 'hello%';.  }.
1250: 7d 20 7b 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 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 0a 23 20 49 6d  -----------.# Im
12a0: 70 72 6f 76 65 20 63 6f 76 65 72 61 67 65 20 66  prove coverage f
12b0: 6f 72 20 76 74 61 62 20 63 6f 64 65 2e 0a 23 0a  or vtab code..#.
12c0: 69 66 63 61 70 61 62 6c 65 20 76 74 61 62 20 7b  ifcapable vtab {
12d0: 0a 20 20 23 20 52 75 6e 20 73 6f 6d 65 20 64 65  .  # Run some de
12e0: 62 75 67 20 63 6f 64 65 20 74 6f 20 69 6d 70 72  bug code to impr
12f0: 6f 76 65 20 72 65 70 6f 72 74 65 64 20 63 6f 76  ove reported cov
1300: 65 72 61 67 65 0a 20 20 23 0a 0a 20 20 23 20 73  erage.  #..  # s
1310: 65 74 20 73 71 6c 69 74 65 5f 77 68 65 72 65 5f  et sqlite_where_
1320: 74 72 61 63 65 20 31 0a 20 20 64 6f 5f 74 65 73  trace 1.  do_tes
1330: 74 20 6d 69 73 63 37 2d 31 30 20 7b 0a 20 20 20  t misc7-10 {.   
1340: 20 72 65 67 69 73 74 65 72 5f 65 63 68 6f 5f 6d   register_echo_m
1350: 6f 64 75 6c 65 20 5b 73 71 6c 69 74 65 33 5f 63  odule [sqlite3_c
1360: 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f 69 6e 74 65  onnection_pointe
1370: 72 20 64 62 5d 0a 20 20 20 20 65 78 65 63 73 71  r db].    execsq
1380: 6c 20 7b 0a 20 20 20 20 20 20 43 52 45 41 54 45  l {.      CREATE
1390: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74   VIRTUAL TABLE t
13a0: 31 20 55 53 49 4e 47 20 65 63 68 6f 28 61 62 63  1 USING echo(abc
13b0: 29 3b 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20  );.      SELECT 
13c0: 61 20 46 52 4f 4d 20 74 31 20 57 48 45 52 45 20  a FROM t1 WHERE 
13d0: 61 20 3d 20 31 20 4f 52 44 45 52 20 42 59 20 62  a = 1 ORDER BY b
13e0: 3b 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 31 7d 0a  ;.    }.  } {1}.
13f0: 20 20 73 65 74 20 73 71 6c 69 74 65 5f 77 68 65    set sqlite_whe
1400: 72 65 5f 74 72 61 63 65 20 30 0a 0a 20 20 23 20  re_trace 0..  # 
1410: 53 70 65 63 69 66 79 20 61 6e 20 4f 52 44 45 52  Specify an ORDER
1420: 20 42 59 20 63 6c 61 75 73 65 20 74 68 61 74 20   BY clause that 
1430: 63 61 6e 6e 6f 74 20 62 65 20 69 6e 64 65 78 65  cannot be indexe
1440: 64 2e 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69 73  d..  do_test mis
1450: 63 37 2d 31 31 20 7b 0a 20 20 20 20 65 78 65 63  c7-11 {.    exec
1460: 73 71 6c 20 7b 0a 20 20 20 20 20 20 53 45 4c 45  sql {.      SELE
1470: 43 54 20 74 31 2e 61 2c 20 74 32 2e 61 20 46 52  CT t1.a, t2.a FR
1480: 4f 4d 20 74 31 2c 20 74 31 20 41 53 20 74 32 20  OM t1, t1 AS t2 
1490: 4f 52 44 45 52 20 42 59 20 32 20 4c 49 4d 49 54  ORDER BY 2 LIMIT
14a0: 20 31 3b 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 31   1;.    }.  } {1
14b0: 20 31 7d 0a 0a 20 20 23 20 54 68 65 20 77 68 6f   1}..  # The who
14c0: 6c 65 20 70 6f 69 6e 74 20 6f 66 20 74 68 69 73  le point of this
14d0: 20 69 73 20 74 6f 20 74 65 73 74 20 61 6e 20 65   is to test an e
14e0: 72 72 6f 72 20 63 6f 64 65 20 6f 74 68 65 72 20  rror code other 
14f0: 74 68 61 6e 0a 20 20 23 20 53 51 4c 49 54 45 5f  than.  # SQLITE_
1500: 4e 4f 4d 45 4d 20 66 72 6f 6d 20 74 68 65 20 76  NOMEM from the v
1510: 74 61 62 20 78 42 65 73 74 49 6e 64 65 78 20 63  tab xBestIndex c
1520: 61 6c 6c 62 61 63 6b 2e 0a 20 20 23 0a 20 20 64  allback..  #.  d
1530: 6f 5f 69 6f 65 72 72 5f 74 65 73 74 20 6d 69 73  o_ioerr_test mis
1540: 63 37 2d 31 32 20 2d 74 63 6c 70 72 65 70 20 7b  c7-12 -tclprep {
1550: 0a 20 20 20 20 73 71 6c 69 74 65 33 20 64 62 32  .    sqlite3 db2
1560: 20 74 65 73 74 2e 64 62 0a 20 20 20 20 72 65 67   test.db.    reg
1570: 69 73 74 65 72 5f 65 63 68 6f 5f 6d 6f 64 75 6c  ister_echo_modul
1580: 65 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65  e [sqlite3_conne
1590: 63 74 69 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62  ction_pointer db
15a0: 32 5d 0a 20 20 20 20 64 62 32 20 65 76 61 6c 20  2].    db2 eval 
15b0: 7b 0a 20 20 20 20 20 20 43 52 45 41 54 45 20 54  {.      CREATE T
15c0: 41 42 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41  ABLE abc(a PRIMA
15d0: 52 59 20 4b 45 59 2c 20 62 2c 20 63 29 3b 0a 20  RY KEY, b, c);. 
15e0: 20 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f       INSERT INTO
15f0: 20 61 62 63 20 56 41 4c 55 45 53 28 31 2c 20 32   abc VALUES(1, 2
1600: 2c 20 33 29 3b 0a 20 20 20 20 20 20 43 52 45 41  , 3);.      CREA
1610: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45  TE VIRTUAL TABLE
1620: 20 74 31 20 55 53 49 4e 47 20 65 63 68 6f 28 61   t1 USING echo(a
1630: 62 63 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 64  bc);.    }.    d
1640: 62 32 20 63 6c 6f 73 65 0a 20 20 7d 20 2d 74 63  b2 close.  } -tc
1650: 6c 62 6f 64 79 20 7b 0a 20 20 20 20 72 65 67 69  lbody {.    regi
1660: 73 74 65 72 5f 65 63 68 6f 5f 6d 6f 64 75 6c 65  ster_echo_module
1670: 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63   [sqlite3_connec
1680: 74 69 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d  tion_pointer db]
1690: 0a 20 20 20 20 65 78 65 63 73 71 6c 20 7b 53 45  .    execsql {SE
16a0: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 20 57  LECT * FROM t1 W
16b0: 48 45 52 45 20 61 20 3d 20 31 3b 7d 0a 20 20 7d  HERE a = 1;}.  }
16c0: 20 0a 0a 20 20 23 20 54 68 65 20 63 61 73 65 20   ..  # The case 
16d0: 77 68 65 72 65 20 74 68 65 20 76 69 72 74 75 61  where the virtua
16e0: 6c 20 74 61 62 6c 65 20 6d 6f 64 75 6c 65 20 72  l table module r
16f0: 65 74 75 72 6e 73 20 61 20 76 65 72 79 20 6c 61  eturns a very la
1700: 72 67 65 20 6e 75 6d 62 65 72 0a 20 20 23 20 61  rge number.  # a
1710: 73 20 74 68 65 20 63 6f 73 74 20 6f 66 20 61 20  s the cost of a 
1720: 73 63 61 6e 20 28 67 72 65 61 74 65 72 20 74 68  scan (greater th
1730: 61 6e 20 53 51 4c 49 54 45 5f 42 49 47 5f 44 4f  an SQLITE_BIG_DO
1740: 55 42 4c 45 20 69 6e 20 74 68 65 20 63 6f 64 65  UBLE in the code
1750: 29 2e 0a 20 20 23 0a 20 20 64 6f 5f 74 65 73 74  )..  #.  do_test
1760: 20 6d 69 73 63 37 2d 31 33 20 7b 0a 20 20 20 20   misc7-13 {.    
1770: 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e  sqlite3 db test.
1780: 64 62 0a 20 20 20 20 72 65 67 69 73 74 65 72 5f  db.    register_
1790: 65 63 68 6f 5f 6d 6f 64 75 6c 65 20 5b 73 71 6c  echo_module [sql
17a0: 69 74 65 33 5f 63 6f 6e 6e 65 63 74 69 6f 6e 5f  ite3_connection_
17b0: 70 6f 69 6e 74 65 72 20 64 62 5d 0a 20 20 20 20  pointer db].    
17c0: 73 65 74 20 3a 3a 65 63 68 6f 5f 6d 6f 64 75 6c  set ::echo_modul
17d0: 65 5f 63 6f 73 74 20 32 2e 30 65 2b 39 39 0a 20  e_cost 2.0e+99. 
17e0: 20 20 20 65 78 65 63 73 71 6c 20 7b 53 45 4c 45     execsql {SELE
17f0: 43 54 20 2a 20 46 52 4f 4d 20 74 31 20 57 48 45  CT * FROM t1 WHE
1800: 52 45 20 61 20 3d 20 31 3b 7d 0a 20 20 7d 20 7b  RE a = 1;}.  } {
1810: 31 20 32 20 33 7d 0a 20 20 75 6e 73 65 74 20 3a  1 2 3}.  unset :
1820: 3a 65 63 68 6f 5f 6d 6f 64 75 6c 65 5f 63 6f 73  :echo_module_cos
1830: 74 0a 7d 0a 0a 64 62 20 63 6c 6f 73 65 0a 66 69  t.}..db close.fi
1840: 6c 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65  le delete -force
1850: 20 74 65 73 74 2e 64 62 0a 66 69 6c 65 20 64 65   test.db.file de
1860: 6c 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74  lete -force test
1870: 2e 64 62 2d 6a 6f 75 72 6e 61 6c 0a 73 71 6c 69  .db-journal.sqli
1880: 74 65 33 20 64 62 20 74 65 73 74 2e 64 62 0a 0a  te3 db test.db..
1890: 69 66 63 61 70 61 62 6c 65 20 65 78 70 6c 61 69  ifcapable explai
18a0: 6e 20 7b 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69  n {.  do_test mi
18b0: 73 63 37 2d 31 34 2e 31 20 7b 0a 20 20 20 20 65  sc7-14.1 {.    e
18c0: 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 20 20 43  xecsql {.      C
18d0: 52 45 41 54 45 20 54 41 42 4c 45 20 61 62 63 28  REATE TABLE abc(
18e0: 61 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  a PRIMARY KEY, b
18f0: 2c 20 63 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20  , c);.    }.    
1900: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 20 20  execsql {.      
1910: 45 58 50 4c 41 49 4e 20 51 55 45 52 59 20 50 4c  EXPLAIN QUERY PL
1920: 41 4e 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  AN SELECT * FROM
1930: 20 61 62 63 20 41 53 20 74 32 20 57 48 45 52 45   abc AS t2 WHERE
1940: 20 72 6f 77 69 64 20 3d 20 31 3b 0a 20 20 20 20   rowid = 1;.    
1950: 7d 0a 20 20 7d 20 7b 30 20 30 20 7b 54 41 42 4c  }.  } {0 0 {TABL
1960: 45 20 61 62 63 20 41 53 20 74 32 20 55 53 49 4e  E abc AS t2 USIN
1970: 47 20 50 52 49 4d 41 52 59 20 4b 45 59 7d 7d 0a  G PRIMARY KEY}}.
1980: 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d    do_test misc7-
1990: 31 34 2e 32 20 7b 0a 20 20 20 20 65 78 65 63 73  14.2 {.    execs
19a0: 71 6c 20 7b 0a 20 20 20 20 20 20 45 58 50 4c 41  ql {.      EXPLA
19b0: 49 4e 20 51 55 45 52 59 20 50 4c 41 4e 20 53 45  IN QUERY PLAN SE
19c0: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63 20  LECT * FROM abc 
19d0: 41 53 20 74 32 20 57 48 45 52 45 20 61 20 3d 20  AS t2 WHERE a = 
19e0: 31 3b 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 30 20  1;.    }.  } {0 
19f0: 30 20 7b 54 41 42 4c 45 20 61 62 63 20 41 53 20  0 {TABLE abc AS 
1a00: 74 32 20 57 49 54 48 20 49 4e 44 45 58 20 73 71  t2 WITH INDEX sq
1a10: 6c 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 61  lite_autoindex_a
1a20: 62 63 5f 31 7d 7d 0a 20 20 64 6f 5f 74 65 73 74  bc_1}}.  do_test
1a30: 20 6d 69 73 63 37 2d 31 34 2e 33 20 7b 0a 20 20   misc7-14.3 {.  
1a40: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
1a50: 20 20 45 58 50 4c 41 49 4e 20 51 55 45 52 59 20    EXPLAIN QUERY 
1a60: 50 4c 41 4e 20 53 45 4c 45 43 54 20 2a 20 46 52  PLAN SELECT * FR
1a70: 4f 4d 20 61 62 63 20 41 53 20 74 32 20 4f 52 44  OM abc AS t2 ORD
1a80: 45 52 20 42 59 20 61 3b 0a 20 20 20 20 7d 0a 20  ER BY a;.    }. 
1a90: 20 7d 20 7b 30 20 30 20 7b 54 41 42 4c 45 20 61   } {0 0 {TABLE a
1aa0: 62 63 20 41 53 20 74 32 20 57 49 54 48 20 49 4e  bc AS t2 WITH IN
1ab0: 44 45 58 20 73 71 6c 69 74 65 5f 61 75 74 6f 69  DEX sqlite_autoi
1ac0: 6e 64 65 78 5f 61 62 63 5f 31 20 4f 52 44 45 52  ndex_abc_1 ORDER
1ad0: 20 42 59 7d 7d 0a 7d 0a 0a 64 62 20 63 6c 6f 73   BY}}.}..db clos
1ae0: 65 0a 66 69 6c 65 20 64 65 6c 65 74 65 20 2d 66  e.file delete -f
1af0: 6f 72 63 65 20 74 65 73 74 2e 64 62 0a 66 69 6c  orce test.db.fil
1b00: 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20  e delete -force 
1b10: 74 65 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 0a  test.db-journal.
1b20: 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e  sqlite3 db test.
1b30: 64 62 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  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 0a 23 20 54 68 69 73  ---------.# This
1b80: 20 69 73 20 61 6c 6c 20 74 6f 20 66 6f 72 63 65   is all to force
1b90: 20 74 68 65 20 70 61 67 65 72 5f 72 65 6d 6f 76   the pager_remov
1ba0: 65 5f 66 72 6f 6d 5f 73 74 6d 74 5f 6c 69 73 74  e_from_stmt_list
1bb0: 28 29 20 66 75 6e 63 74 69 6f 6e 0a 23 20 28 69  () function.# (i
1bc0: 6e 73 69 64 65 20 70 61 67 65 72 2e 63 29 20 74  nside pager.c) t
1bd0: 6f 20 72 65 6d 6f 76 65 20 61 20 70 61 67 65 72  o remove a pager
1be0: 20 66 72 6f 6d 20 74 68 65 20 6d 69 64 64 6c 65   from the middle
1bf0: 20 6f 66 20 74 68 65 0a 23 20 73 74 61 74 65 6d   of the.# statem
1c00: 65 6e 74 2d 6c 69 73 74 2e 0a 23 0a 64 6f 5f 74  ent-list..#.do_t
1c10: 65 73 74 20 6d 69 73 63 37 2d 31 35 2e 31 20 7b  est misc7-15.1 {
1c20: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
1c30: 20 50 52 41 47 4d 41 20 63 61 63 68 65 5f 73 69   PRAGMA cache_si
1c40: 7a 65 20 3d 20 31 30 3b 0a 20 20 20 20 42 45 47  ze = 10;.    BEG
1c50: 49 4e 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54  IN;.    CREATE T
1c60: 41 42 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41  ABLE abc(a PRIMA
1c70: 52 59 20 4b 45 59 2c 20 62 2c 20 63 29 3b 0a 20  RY KEY, b, c);. 
1c80: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61     INSERT INTO a
1c90: 62 63 20 0a 20 20 20 20 56 41 4c 55 45 53 28 72  bc .    VALUES(r
1ca0: 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c  andstr(100,100),
1cb0: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30   randstr(100,100
1cc0: 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31  ), randstr(100,1
1cd0: 30 30 29 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  00));.    INSERT
1ce0: 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54   INTO abc SELECT
1cf0: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 61   .            ra
1d00: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20  ndstr(100,100), 
1d10: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1d20: 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30  , randstr(100,10
1d30: 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20  0) FROM abc;.   
1d40: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63   INSERT INTO abc
1d50: 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20 20 20   SELECT .       
1d60: 20 20 20 20 20 72 61 6e 64 73 74 72 28 31 30 30       randstr(100
1d70: 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31  ,100), randstr(1
1d80: 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72  00,100), randstr
1d90: 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d 20 61  (100,100) FROM a
1da0: 62 63 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  bc;.    INSERT I
1db0: 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54 20 0a  NTO abc SELECT .
1dc0: 20 20 20 20 20 20 20 20 20 20 20 20 72 61 6e 64              rand
1dd0: 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61  str(100,100), ra
1de0: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20  ndstr(100,100), 
1df0: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1e00: 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49   FROM abc;.    I
1e10: 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 53  NSERT INTO abc S
1e20: 45 4c 45 43 54 20 0a 20 20 20 20 20 20 20 20 20  ELECT .         
1e30: 20 20 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31     randstr(100,1
1e40: 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30  00), randstr(100
1e50: 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31  ,100), randstr(1
1e60: 30 30 2c 31 30 30 29 20 46 52 4f 4d 20 61 62 63  00,100) FROM abc
1e70: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
1e80: 4f 20 61 62 63 20 53 45 4c 45 43 54 20 0a 20 20  O abc SELECT .  
1e90: 20 20 20 20 20 20 20 20 20 20 72 61 6e 64 73 74            randst
1ea0: 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64  r(100,100), rand
1eb0: 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61  str(100,100), ra
1ec0: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 20 46  ndstr(100,100) F
1ed0: 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49 4e 53  ROM abc;.    INS
1ee0: 45 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c  ERT INTO abc SEL
1ef0: 45 43 54 20 0a 20 20 20 20 20 20 20 20 20 20 20  ECT .           
1f00: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30   randstr(100,100
1f10: 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31  ), randstr(100,1
1f20: 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30  00), randstr(100
1f30: 2c 31 30 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a  ,100) FROM abc;.
1f40: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1f50: 61 62 63 20 53 45 4c 45 43 54 20 0a 20 20 20 20  abc SELECT .    
1f60: 20 20 20 20 20 20 20 20 72 61 6e 64 73 74 72 28          randstr(
1f70: 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74  100,100), randst
1f80: 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64  r(100,100), rand
1f90: 73 74 72 28 31 30 30 2c 31 30 30 29 20 46 52 4f  str(100,100) FRO
1fa0: 4d 20 61 62 63 3b 0a 20 20 20 20 49 4e 53 45 52  M abc;.    INSER
1fb0: 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43  T INTO abc SELEC
1fc0: 54 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 72  T .            r
1fd0: 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c  andstr(100,100),
1fe0: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30   randstr(100,100
1ff0: 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31  ), randstr(100,1
2000: 30 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20  00) FROM abc;.  
2010: 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 7d 0a 20 20    COMMIT;.  }.  
2020: 65 78 70 72 20 7b 5b 66 69 6c 65 20 73 69 7a 65  expr {[file size
2030: 20 74 65 73 74 2e 64 62 5d 3e 31 30 32 34 30 7d   test.db]>10240}
2040: 0a 7d 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 6d  .} {1}.do_test m
2050: 69 73 63 37 2d 31 35 2e 32 20 7b 0a 20 20 65 78  isc7-15.2 {.  ex
2060: 65 63 73 71 6c 20 7b 0a 20 20 20 20 44 45 4c 45  ecsql {.    DELE
2070: 54 45 20 46 52 4f 4d 20 61 62 63 20 57 48 45 52  TE FROM abc WHER
2080: 45 20 72 6f 77 69 64 20 3e 20 31 32 3b 0a 20 20  E rowid > 12;.  
2090: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62    INSERT INTO ab
20a0: 63 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20 20  c SELECT .      
20b0: 20 20 20 20 20 20 72 61 6e 64 73 74 72 28 31 30        randstr(10
20c0: 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28  0,100), randstr(
20d0: 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74  100,100), randst
20e0: 72 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d 20  r(100,100) FROM 
20f0: 61 62 63 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 64  abc;.  }.} {}..d
2100: 62 20 63 6c 6f 73 65 0a 66 69 6c 65 20 64 65 6c  b close.file del
2110: 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74 2e  ete -force test.
2120: 64 62 0a 66 69 6c 65 20 64 65 6c 65 74 65 20 2d  db.file delete -
2130: 66 6f 72 63 65 20 74 65 73 74 2e 64 62 2d 6a 6f  force test.db-jo
2140: 75 72 6e 61 6c 0a 73 71 6c 69 74 65 33 20 64 62  urnal.sqlite3 db
2150: 20 74 65 73 74 2e 64 62 0a 0a 64 6f 5f 69 6f 65   test.db..do_ioe
2160: 72 72 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 36  rr_test misc7-16
2170: 20 2d 73 71 6c 70 72 65 70 20 7b 0a 20 20 20 50   -sqlprep {.   P
2180: 52 41 47 4d 41 20 63 61 63 68 65 5f 73 69 7a 65  RAGMA cache_size
2190: 20 3d 20 31 30 3b 0a 20 20 20 50 52 41 47 4d 41   = 10;.   PRAGMA
21a0: 20 64 65 66 61 75 6c 74 5f 63 61 63 68 65 5f 73   default_cache_s
21b0: 69 7a 65 20 3d 20 31 30 3b 0a 20 20 20 43 52 45  ize = 10;.   CRE
21c0: 41 54 45 20 54 41 42 4c 45 20 74 33 28 61 2c 20  ATE TABLE t3(a, 
21d0: 62 2c 20 55 4e 49 51 55 45 28 61 2c 20 62 29 29  b, UNIQUE(a, b))
21e0: 3b 0a 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  ;.   INSERT INTO
21f0: 20 74 33 20 56 41 4c 55 45 53 28 20 72 61 6e 64   t3 VALUES( rand
2200: 73 74 72 28 31 30 30 2c 20 31 30 30 29 2c 20 72  str(100, 100), r
2210: 61 6e 64 73 74 72 28 31 30 30 2c 20 31 30 30 29  andstr(100, 100)
2220: 20 29 3b 0a 20 20 20 49 4e 53 45 52 54 20 49 4e   );.   INSERT IN
2230: 54 4f 20 74 33 20 53 45 4c 45 43 54 20 72 61 6e  TO t3 SELECT ran
2240: 64 73 74 72 28 31 30 30 2c 20 31 30 30 29 2c 20  dstr(100, 100), 
2250: 72 61 6e 64 73 74 72 28 31 30 30 2c 20 31 30 30  randstr(100, 100
2260: 29 20 46 52 4f 4d 20 74 33 3b 0a 20 20 20 49 4e  ) FROM t3;.   IN
2270: 53 45 52 54 20 49 4e 54 4f 20 74 33 20 53 45 4c  SERT INTO t3 SEL
2280: 45 43 54 20 72 61 6e 64 73 74 72 28 31 30 30 2c  ECT randstr(100,
2290: 20 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31   100), randstr(1
22a0: 30 30 2c 20 31 30 30 29 20 46 52 4f 4d 20 74 33  00, 100) FROM t3
22b0: 3b 0a 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  ;.   INSERT INTO
22c0: 20 74 33 20 53 45 4c 45 43 54 20 72 61 6e 64 73   t3 SELECT rands
22d0: 74 72 28 31 30 30 2c 20 31 30 30 29 2c 20 72 61  tr(100, 100), ra
22e0: 6e 64 73 74 72 28 31 30 30 2c 20 31 30 30 29 20  ndstr(100, 100) 
22f0: 46 52 4f 4d 20 74 33 3b 0a 20 20 20 49 4e 53 45  FROM t3;.   INSE
2300: 52 54 20 49 4e 54 4f 20 74 33 20 53 45 4c 45 43  RT INTO t3 SELEC
2310: 54 20 72 61 6e 64 73 74 72 28 31 30 30 2c 20 31  T randstr(100, 1
2320: 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30  00), randstr(100
2330: 2c 20 31 30 30 29 20 46 52 4f 4d 20 74 33 3b 0a  , 100) FROM t3;.
2340: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74     INSERT INTO t
2350: 33 20 53 45 4c 45 43 54 20 72 61 6e 64 73 74 72  3 SELECT randstr
2360: 28 31 30 30 2c 20 31 30 30 29 2c 20 72 61 6e 64  (100, 100), rand
2370: 73 74 72 28 31 30 30 2c 20 31 30 30 29 20 46 52  str(100, 100) FR
2380: 4f 4d 20 74 33 3b 0a 20 20 20 55 50 44 41 54 45  OM t3;.   UPDATE
2390: 20 74 33 20 0a 20 20 20 53 45 54 20 62 20 3d 20   t3 .   SET b = 
23a0: 27 68 65 6c 6c 6f 20 77 6f 72 6c 64 27 0a 20 20  'hello world'.  
23b0: 20 57 48 45 52 45 20 72 6f 77 69 64 20 3e 3d 20   WHERE rowid >= 
23c0: 28 53 45 4c 45 43 54 20 6d 61 78 28 72 6f 77 69  (SELECT max(rowi
23d0: 64 29 2d 31 20 46 52 4f 4d 20 74 33 29 3b 0a 7d  d)-1 FROM t3);.}
23e0: 20 2d 74 63 6c 62 6f 64 79 20 7b 0a 20 20 73 65   -tclbody {.  se
23f0: 74 20 72 63 20 5b 63 61 74 63 68 20 7b 64 62 20  t rc [catch {db 
2400: 65 76 61 6c 20 7b 0a 20 20 20 20 42 45 47 49 4e  eval {.    BEGIN
2410: 3b 0a 20 20 20 20 20 20 50 52 41 47 4d 41 20 63  ;.      PRAGMA c
2420: 61 63 68 65 5f 73 69 7a 65 20 3d 20 31 30 3b 0a  ache_size = 10;.
2430: 20 20 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54        INSERT INT
2440: 4f 20 74 33 20 56 41 4c 55 45 53 28 20 72 61 6e  O t3 VALUES( ran
2450: 64 73 74 72 28 31 30 30 2c 20 31 30 30 29 2c 20  dstr(100, 100), 
2460: 72 61 6e 64 73 74 72 28 31 30 30 2c 20 31 30 30  randstr(100, 100
2470: 29 20 29 3b 0a 20 20 20 20 20 20 55 50 44 41 54  ) );.      UPDAT
2480: 45 20 74 33 20 53 45 54 20 61 20 3d 20 62 3b 0a  E t3 SET a = b;.
2490: 20 20 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 7d 7d      COMMIT;.  }}
24a0: 20 6d 73 67 5d 0a 0a 20 20 69 66 20 7b 21 24 72   msg]..  if {!$r
24b0: 63 20 7c 7c 20 28 24 72 63 20 26 26 20 5b 73 74  c || ($rc && [st
24c0: 72 69 6e 67 20 66 69 72 73 74 20 22 63 6f 6c 75  ring first "colu
24d0: 6d 6e 73 22 20 24 6d 73 67 5d 3d 3d 30 29 7d 20  mns" $msg]==0)} 
24e0: 7b 0a 20 20 20 20 73 65 74 20 6d 73 67 0a 20 20  {.    set msg.  
24f0: 7d 20 65 6c 73 65 20 7b 0a 20 20 20 20 65 72 72  } else {.    err
2500: 6f 72 20 24 6d 73 67 0a 20 20 7d 0a 7d 0a 0a 73  or $msg.  }.}..s
2510: 71 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e 64  qlite3 db test.d
2520: 62 0a 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37  b..do_test misc7
2530: 2d 31 36 2e 58 20 7b 0a 20 20 65 78 65 63 73 71  -16.X {.  execsq
2540: 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 63  l {.    SELECT c
2550: 6f 75 6e 74 28 2a 29 20 46 52 4f 4d 20 74 33 3b  ount(*) FROM t3;
2560: 0a 20 20 7d 0a 7d 20 7b 33 32 7d 0a 0a 23 2d 2d  .  }.} {32}..#--
2570: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2580: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2590: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
25a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
25b0: 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 74 68 65 20  ----.# Test the 
25c0: 73 69 74 75 61 74 69 6f 6e 20 77 68 65 72 65 20  situation where 
25d0: 61 20 68 6f 74 2d 6a 6f 75 72 6e 61 6c 20 69 73  a hot-journal is
25e0: 20 64 69 73 63 6f 76 65 72 65 64 20 62 75 74 20   discovered but 
25f0: 77 72 69 74 65 2d 61 63 63 65 73 73 0a 23 20 74  write-access.# t
2600: 6f 20 69 74 20 69 73 20 64 65 6e 69 65 64 2e 20  o it is denied. 
2610: 54 68 69 73 20 73 68 6f 75 6c 64 20 72 65 74 75  This should retu
2620: 72 6e 20 53 51 4c 49 54 45 5f 42 55 53 59 2e 0a  rn SQLITE_BUSY..
2630: 23 0a 23 20 54 68 65 73 65 20 74 65 73 74 73 20  #.# These tests 
2640: 64 6f 20 6e 6f 74 20 77 6f 72 6b 20 6f 6e 20 77  do not work on w
2650: 69 6e 64 6f 77 73 20 64 75 65 20 74 6f 20 72 65  indows due to re
2660: 73 74 72 69 63 74 69 6f 6e 73 20 69 6e 20 74 68  strictions in th
2670: 65 0a 23 20 77 69 6e 64 6f 77 73 20 66 69 6c 65  e.# windows file
2680: 20 73 79 73 74 65 6d 2e 0a 23 0a 69 66 20 7b 24   system..#.if {$
2690: 74 63 6c 5f 70 6c 61 74 66 6f 72 6d 28 70 6c 61  tcl_platform(pla
26a0: 74 66 6f 72 6d 29 21 3d 22 77 69 6e 64 6f 77 73  tform)!="windows
26b0: 22 20 26 26 20 24 74 63 6c 5f 70 6c 61 74 66 6f  " && $tcl_platfo
26c0: 72 6d 28 70 6c 61 74 66 6f 72 6d 29 21 3d 22 6f  rm(platform)!="o
26d0: 73 32 22 7d 20 7b 0a 0a 20 20 23 20 53 6f 6d 65  s2"} {..  # Some
26e0: 20 6e 65 74 77 6f 72 6b 20 66 69 6c 65 73 79 73   network filesys
26f0: 74 65 6d 73 20 28 65 78 3a 20 41 46 50 29 20 64  tems (ex: AFP) d
2700: 6f 20 6e 6f 74 20 73 75 70 70 6f 72 74 20 73 65  o not support se
2710: 74 74 69 6e 67 20 72 65 61 64 2d 6f 6e 6c 79 0a  tting read-only.
2720: 20 20 23 20 70 65 72 6d 69 73 73 69 6f 6e 73 2e    # permissions.
2730: 20 20 4f 6e 6c 79 20 72 75 6e 20 74 68 65 73 65    Only run these
2740: 20 74 65 73 74 73 20 69 66 20 66 75 6c 6c 20 75   tests if full u
2750: 6e 69 78 20 70 65 72 6d 69 73 73 69 6f 6e 20 73  nix permission s
2760: 65 74 74 69 6e 67 0a 20 20 23 20 63 61 70 61 62  etting.  # capab
2770: 69 6c 69 74 69 65 73 20 61 72 65 20 73 75 70 70  ilities are supp
2780: 6f 72 74 65 64 2e 0a 20 20 23 0a 20 20 66 69 6c  orted..  #.  fil
2790: 65 20 61 74 74 72 69 62 75 74 65 73 20 74 65 73  e attributes tes
27a0: 74 2e 64 62 20 2d 70 65 72 6d 69 73 73 69 6f 6e  t.db -permission
27b0: 73 20 72 77 2d 72 2d 2d 72 2d 2d 0a 20 20 69 66  s rw-r--r--.  if
27c0: 20 7b 5b 66 69 6c 65 20 61 74 74 72 69 62 75 74   {[file attribut
27d0: 65 73 20 74 65 73 74 2e 64 62 20 2d 70 65 72 6d  es test.db -perm
27e0: 69 73 73 69 6f 6e 73 5d 3d 3d 30 36 34 34 7d 20  issions]==0644} 
27f0: 7b 0a 0a 20 20 20 20 64 6f 5f 74 65 73 74 20 6d  {..    do_test m
2800: 69 73 63 37 2d 31 37 2e 31 20 7b 0a 20 20 20 20  isc7-17.1 {.    
2810: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
2820: 20 20 20 20 42 45 47 49 4e 3b 0a 20 20 20 20 20      BEGIN;.     
2830: 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 74     DELETE FROM t
2840: 33 20 57 48 45 52 45 20 28 6f 69 64 25 33 29 3d  3 WHERE (oid%3)=
2850: 3d 30 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20  =0;.      }.    
2860: 20 20 63 6f 70 79 5f 66 69 6c 65 20 74 65 73 74    copy_file test
2870: 2e 64 62 20 62 61 6b 2e 64 62 0a 20 20 20 20 20  .db bak.db.     
2880: 20 63 6f 70 79 5f 66 69 6c 65 20 74 65 73 74 2e   copy_file test.
2890: 64 62 2d 6a 6f 75 72 6e 61 6c 20 62 61 6b 2e 64  db-journal bak.d
28a0: 62 2d 6a 6f 75 72 6e 61 6c 0a 20 20 20 20 20 20  b-journal.      
28b0: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 20 20  execsql {.      
28c0: 20 20 43 4f 4d 4d 49 54 3b 0a 20 20 20 20 20 20    COMMIT;.      
28d0: 7d 0a 20 20 20 20 0a 20 20 20 20 20 20 64 62 20  }.    .      db 
28e0: 63 6c 6f 73 65 0a 20 20 20 20 20 20 63 6f 70 79  close.      copy
28f0: 5f 66 69 6c 65 20 62 61 6b 2e 64 62 20 74 65 73  _file bak.db tes
2900: 74 2e 64 62 0a 20 20 20 20 20 20 63 6f 70 79 5f  t.db.      copy_
2910: 66 69 6c 65 20 62 61 6b 2e 64 62 2d 6a 6f 75 72  file bak.db-jour
2920: 6e 61 6c 20 74 65 73 74 2e 64 62 2d 6a 6f 75 72  nal test.db-jour
2930: 6e 61 6c 0a 20 20 20 20 20 20 73 71 6c 69 74 65  nal.      sqlite
2940: 33 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20 20  3 db test.db.   
2950: 20 0a 20 20 20 20 20 20 63 61 74 63 68 20 7b 66   .      catch {f
2960: 69 6c 65 20 61 74 74 72 69 62 75 74 65 73 20 74  ile attributes t
2970: 65 73 74 2e 64 62 2d 6a 6f 75 72 6e 61 6c 20 2d  est.db-journal -
2980: 70 65 72 6d 69 73 73 69 6f 6e 73 20 72 2d 2d 2d  permissions r---
2990: 2d 2d 2d 2d 2d 7d 0a 20 20 20 20 20 20 63 61 74  -----}.      cat
29a0: 63 68 20 7b 66 69 6c 65 20 61 74 74 72 69 62 75  ch {file attribu
29b0: 74 65 73 20 74 65 73 74 2e 64 62 2d 6a 6f 75 72  tes test.db-jour
29c0: 6e 61 6c 20 2d 72 65 61 64 6f 6e 6c 79 20 31 7d  nal -readonly 1}
29d0: 0a 20 20 20 20 20 20 63 61 74 63 68 73 71 6c 20  .      catchsql 
29e0: 7b 0a 20 20 20 20 20 20 20 20 53 45 4c 45 43 54  {.        SELECT
29f0: 20 63 6f 75 6e 74 28 2a 29 20 46 52 4f 4d 20 74   count(*) FROM t
2a00: 33 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d  3;.      }.    }
2a10: 20 7b 31 20 7b 75 6e 61 62 6c 65 20 74 6f 20 6f   {1 {unable to o
2a20: 70 65 6e 20 64 61 74 61 62 61 73 65 20 66 69 6c  pen database fil
2a30: 65 7d 7d 0a 20 20 20 20 64 6f 5f 74 65 73 74 20  e}}.    do_test 
2a40: 6d 69 73 63 37 2d 31 37 2e 32 20 7b 0a 20 20 20  misc7-17.2 {.   
2a50: 20 20 20 23 20 4e 6f 74 65 20 74 68 61 74 20 74     # Note that t
2a60: 68 65 20 2d 72 65 61 64 6f 6e 6c 79 20 66 6c 61  he -readonly fla
2a70: 67 20 6d 75 73 74 20 62 65 20 63 6c 65 61 72 65  g must be cleare
2a80: 64 20 62 65 66 6f 72 65 20 74 68 65 20 2d 70 65  d before the -pe
2a90: 72 6d 69 73 73 69 6f 6e 73 0a 20 20 20 20 20 20  rmissions.      
2aa0: 23 20 61 72 65 20 73 65 74 2e 20 4f 74 68 65 72  # are set. Other
2ab0: 77 69 73 65 2c 20 77 68 65 6e 20 75 73 69 6e 67  wise, when using
2ac0: 20 74 63 6c 20 38 2e 35 20 6f 6e 20 6d 61 63 2c   tcl 8.5 on mac,
2ad0: 20 74 68 65 20 66 61 63 74 20 74 68 61 74 20 74   the fact that t
2ae0: 68 65 20 0a 20 20 20 20 20 20 23 20 2d 72 65 61  he .      # -rea
2af0: 64 6f 6e 6c 79 20 66 6c 61 67 20 69 73 20 73 65  donly flag is se
2b00: 74 20 63 61 75 73 65 73 20 74 68 65 20 61 74 74  t causes the att
2b10: 65 6d 70 74 20 74 6f 20 73 65 74 20 74 68 65 20  empt to set the 
2b20: 70 65 72 6d 69 73 73 69 6f 6e 73 0a 20 20 20 20  permissions.    
2b30: 20 20 23 20 74 6f 20 66 61 69 6c 2e 0a 20 20 20    # to fail..   
2b40: 20 20 20 63 61 74 63 68 20 7b 66 69 6c 65 20 61     catch {file a
2b50: 74 74 72 69 62 75 74 65 73 20 74 65 73 74 2e 64  ttributes test.d
2b60: 62 2d 6a 6f 75 72 6e 61 6c 20 2d 72 65 61 64 6f  b-journal -reado
2b70: 6e 6c 79 20 30 7d 0a 20 20 20 20 20 20 63 61 74  nly 0}.      cat
2b80: 63 68 20 7b 66 69 6c 65 20 61 74 74 72 69 62 75  ch {file attribu
2b90: 74 65 73 20 74 65 73 74 2e 64 62 2d 6a 6f 75 72  tes test.db-jour
2ba0: 6e 61 6c 20 2d 70 65 72 6d 69 73 73 69 6f 6e 73  nal -permissions
2bb0: 20 72 77 2d 2d 2d 2d 2d 2d 2d 7d 0a 20 20 20 20   rw-------}.    
2bc0: 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20    catchsql {.   
2bd0: 20 20 20 20 20 53 45 4c 45 43 54 20 63 6f 75 6e       SELECT coun
2be0: 74 28 2a 29 20 46 52 4f 4d 20 74 33 3b 0a 20 20  t(*) FROM t3;.  
2bf0: 20 20 20 20 7d 0a 20 20 20 20 7d 20 7b 30 20 33      }.    } {0 3
2c00: 32 7d 0a 20 20 20 20 0a 20 20 20 20 23 20 73 71  2}.    .    # sq
2c10: 6c 69 74 65 33 5f 74 65 73 74 5f 63 6f 6e 74 72  lite3_test_contr
2c20: 6f 6c 5f 70 65 6e 64 69 6e 67 5f 70 61 67 65 20  ol_pending_page 
2c30: 5b 65 78 70 72 20 28 24 3a 3a 73 71 6c 69 74 65  [expr ($::sqlite
2c40: 5f 70 65 6e 64 69 6e 67 5f 62 79 74 65 20 2f 20  _pending_byte / 
2c50: 31 30 32 34 29 20 2b 20 31 5d 0a 20 20 20 20 73  1024) + 1].    s
2c60: 65 74 20 3a 3a 70 65 6e 64 69 6e 67 5f 62 79 74  et ::pending_byt
2c70: 65 5f 70 61 67 65 20 5b 65 78 70 72 20 28 24 3a  e_page [expr ($:
2c80: 3a 73 71 6c 69 74 65 5f 70 65 6e 64 69 6e 67 5f  :sqlite_pending_
2c90: 62 79 74 65 20 2f 20 31 30 32 34 29 20 2b 20 31  byte / 1024) + 1
2ca0: 5d 0a 20 20 20 20 73 71 6c 69 74 65 33 5f 74 65  ].    sqlite3_te
2cb0: 73 74 5f 63 6f 6e 74 72 6f 6c 5f 70 65 6e 64 69  st_control_pendi
2cc0: 6e 67 5f 62 79 74 65 20 24 3a 3a 73 71 6c 69 74  ng_byte $::sqlit
2cd0: 65 5f 70 65 6e 64 69 6e 67 5f 62 79 74 65 20 0a  e_pending_byte .
2ce0: 20 20 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63      do_test misc
2cf0: 37 2d 31 37 2e 33 20 7b 0a 20 20 20 20 20 20 64  7-17.3 {.      d
2d00: 62 20 65 76 61 6c 20 7b 0a 20 20 20 20 20 20 20  b eval {.       
2d10: 20 70 72 61 67 6d 61 20 77 72 69 74 61 62 6c 65   pragma writable
2d20: 5f 73 63 68 65 6d 61 20 3d 20 74 72 75 65 3b 0a  _schema = true;.
2d30: 20 20 20 20 20 20 20 20 55 50 44 41 54 45 20 73          UPDATE s
2d40: 71 6c 69 74 65 5f 6d 61 73 74 65 72 20 0a 20 20  qlite_master .  
2d50: 20 20 20 20 20 20 20 20 53 45 54 20 72 6f 6f 74          SET root
2d60: 70 61 67 65 20 3d 20 24 70 65 6e 64 69 6e 67 5f  page = $pending_
2d70: 62 79 74 65 5f 70 61 67 65 0a 20 20 20 20 20 20  byte_page.      
2d80: 20 20 20 20 57 48 45 52 45 20 74 79 70 65 20 3d      WHERE type =
2d90: 20 27 74 61 62 6c 65 27 20 41 4e 44 20 6e 61 6d   'table' AND nam
2da0: 65 20 3d 20 27 74 33 27 3b 0a 20 20 20 20 20 20  e = 't3';.      
2db0: 7d 0a 20 20 20 20 20 20 65 78 65 63 73 71 6c 20  }.      execsql 
2dc0: 7b 0a 20 20 20 20 20 20 20 20 53 45 4c 45 43 54  {.        SELECT
2dd0: 20 72 6f 6f 74 70 61 67 65 20 46 52 4f 4d 20 73   rootpage FROM s
2de0: 71 6c 69 74 65 5f 6d 61 73 74 65 72 20 57 48 45  qlite_master WHE
2df0: 52 45 20 74 79 70 65 20 3d 20 27 74 61 62 6c 65  RE type = 'table
2e00: 27 20 41 4e 44 20 6e 61 6d 65 20 3d 20 27 74 33  ' AND name = 't3
2e10: 27 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d  ';.      }.    }
2e20: 20 24 3a 3a 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 0a 20 20 20 20 64  _page.    .    d
2e40: 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 37 2e  o_test misc7-17.
2e50: 34 20 7b 0a 20 20 20 20 20 20 64 62 20 63 6c 6f  4 {.      db clo
2e60: 73 65 0a 20 20 20 20 20 20 73 71 6c 69 74 65 33  se.      sqlite3
2e70: 20 64 62 20 74 65 73 74 2e 64 62 0a 20 20 20 20   db test.db.    
2e80: 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20    catchsql {.   
2e90: 20 20 20 20 20 53 45 4c 45 43 54 20 63 6f 75 6e       SELECT coun
2ea0: 74 28 2a 29 20 46 52 4f 4d 20 74 33 3b 0a 20 20  t(*) FROM t3;.  
2eb0: 20 20 20 20 7d 20 0a 20 20 20 20 7d 20 7b 31 20      } .    } {1 
2ec0: 7b 64 61 74 61 62 61 73 65 20 64 69 73 6b 20 69  {database disk i
2ed0: 6d 61 67 65 20 69 73 20 6d 61 6c 66 6f 72 6d 65  mage is malforme
2ee0: 64 7d 7d 0a 20 20 7d 0a 7d 0a 0a 23 20 54 69 63  d}}.  }.}..# Tic
2ef0: 6b 65 74 20 23 32 34 37 30 0a 23 0a 64 6f 5f 74  ket #2470.#.do_t
2f00: 65 73 74 20 6d 69 73 63 37 2d 31 38 2e 31 20 7b  est misc7-18.1 {
2f10: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
2f20: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 61   CREATE TABLE ta
2f30: 62 6c 65 5f 31 20 28 63 6f 6c 5f 31 30 29 3b 0a  ble_1 (col_10);.
2f40: 20 20 20 20 43 52 45 41 54 45 20 54 41 42 4c 45      CREATE TABLE
2f50: 20 74 61 62 6c 65 5f 32 20 28 0a 20 20 20 20 20   table_2 (.     
2f60: 20 63 6f 6c 5f 31 2c 20 63 6f 6c 5f 32 2c 20 63   col_1, col_2, c
2f70: 6f 6c 5f 33 2c 20 63 6f 6c 5f 34 2c 20 63 6f 6c  ol_3, col_4, col
2f80: 5f 35 2c 0a 20 20 20 20 20 20 63 6f 6c 5f 36 2c  _5,.      col_6,
2f90: 20 63 6f 6c 5f 37 2c 20 63 6f 6c 5f 38 2c 20 63   col_7, col_8, c
2fa0: 6f 6c 5f 39 2c 20 63 6f 6c 5f 31 30 0a 20 20 20  ol_9, col_10.   
2fb0: 20 29 3b 0a 20 20 20 20 53 45 4c 45 43 54 20 61   );.    SELECT a
2fc0: 2e 63 6f 6c 5f 31 30 0a 20 20 20 20 46 52 4f 4d  .col_10.    FROM
2fd0: 0a 20 20 20 20 20 20 28 53 45 4c 45 43 54 20 74  .      (SELECT t
2fe0: 61 62 6c 65 5f 31 2e 63 6f 6c 5f 31 30 20 41 53  able_1.col_10 AS
2ff0: 20 63 6f 6c 5f 31 30 20 46 52 4f 4d 20 74 61 62   col_10 FROM tab
3000: 6c 65 5f 31 29 20 61 2c 0a 20 20 20 20 20 20 28  le_1) a,.      (
3010: 53 45 4c 45 43 54 20 74 61 62 6c 65 5f 31 2e 63  SELECT table_1.c
3020: 6f 6c 5f 31 30 2c 20 74 61 62 6c 65 5f 32 2e 63  ol_10, table_2.c
3030: 6f 6c 5f 39 20 41 53 20 71 63 6f 6c 5f 39 0a 20  ol_9 AS qcol_9. 
3040: 20 20 20 20 20 20 20 20 46 52 4f 4d 20 74 61 62          FROM tab
3050: 6c 65 5f 31 2c 20 74 61 62 6c 65 5f 32 0a 20 20  le_1, table_2.  
3060: 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 20 74        GROUP BY t
3070: 61 62 6c 65 5f 31 2e 63 6f 6c 5f 31 30 2c 20 71  able_1.col_10, q
3080: 63 6f 6c 5f 39 29 3b 0a 20 20 7d 0a 7d 20 7b 7d  col_9);.  }.} {}
3090: 0a 0a 23 20 54 65 73 74 69 6e 67 20 62 6f 75 6e  ..# Testing boun
30a0: 64 61 72 79 20 63 6f 6e 64 69 74 69 6f 6e 73 20  dary conditions 
30b0: 6f 6e 20 73 71 6c 69 74 65 33 5f 73 74 61 74 75  on sqlite3_statu
30c0: 73 28 29 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69  s().#.do_test mi
30d0: 73 63 37 2d 31 39 2e 31 20 7b 0a 20 20 73 71 6c  sc7-19.1 {.  sql
30e0: 69 74 65 33 5f 73 74 61 74 75 73 20 2d 31 20 30  ite3_status -1 0
30f0: 0a 7d 20 7b 32 31 20 30 20 30 7d 0a 64 6f 5f 74  .} {21 0 0}.do_t
3100: 65 73 74 20 6d 69 73 63 37 2d 31 39 2e 32 20 7b  est misc7-19.2 {
3110: 0a 20 20 73 71 6c 69 74 65 33 5f 73 74 61 74 75  .  sqlite3_statu
3120: 73 20 31 30 30 30 20 30 0a 7d 20 7b 32 31 20 30  s 1000 0.} {21 0
3130: 20 30 7d 0a 0a 0a 23 20 73 71 6c 69 74 65 33 5f   0}...# sqlite3_
3140: 67 6c 6f 62 61 6c 5f 72 65 63 6f 76 65 72 28 29  global_recover()
3150: 20 69 73 20 61 20 6e 6f 2d 6f 70 2e 20 20 42 75   is a no-op.  Bu
3160: 74 20 77 65 20 6d 69 67 68 74 20 61 73 20 77 65  t we might as we
3170: 6c 6c 20 74 65 73 74 20 69 74 0a 23 20 69 66 20  ll test it.# if 
3180: 6f 6e 6c 79 20 74 6f 20 67 65 74 20 74 68 65 20  only to get the 
3190: 74 65 73 74 20 63 6f 76 65 72 61 67 65 2e 0a 23  test coverage..#
31a0: 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 32  .do_test misc7-2
31b0: 30 2e 31 20 7b 0a 20 20 73 71 6c 69 74 65 33 5f  0.1 {.  sqlite3_
31c0: 67 6c 6f 62 61 6c 5f 72 65 63 6f 76 65 72 0a 7d  global_recover.}
31d0: 20 7b 53 51 4c 49 54 45 5f 4f 4b 7d 0a 0a 23 20   {SQLITE_OK}..# 
31e0: 54 72 79 20 74 6f 20 6f 70 65 6e 20 61 20 72 65  Try to open a re
31f0: 61 6c 6c 79 20 6c 6f 6e 67 20 66 69 6c 65 20 6e  ally long file n
3200: 61 6d 65 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 6d  ame..#.do_test m
3210: 69 73 63 37 2d 32 31 2e 31 20 7b 0a 20 20 73 65  isc7-21.1 {.  se
3220: 74 20 7a 46 69 6c 65 20 5b 66 69 6c 65 20 6a 6f  t zFile [file jo
3230: 69 6e 20 5b 70 77 64 5d 20 22 5b 73 74 72 69 6e  in [pwd] "[strin
3240: 67 20 72 65 70 65 61 74 20 61 62 63 64 65 20 31  g repeat abcde 1
3250: 30 34 5d 2e 64 62 22 5d 0a 20 20 73 65 74 20 72  04].db"].  set r
3260: 63 20 5b 63 61 74 63 68 20 7b 73 71 6c 69 74 65  c [catch {sqlite
3270: 33 20 64 62 32 20 24 7a 46 69 6c 65 7d 20 6d 73  3 db2 $zFile} ms
3280: 67 5d 0a 20 20 6c 69 73 74 20 24 72 63 20 24 6d  g].  list $rc $m
3290: 73 67 0a 7d 20 7b 31 20 7b 75 6e 61 62 6c 65 20  sg.} {1 {unable 
32a0: 74 6f 20 6f 70 65 6e 20 64 61 74 61 62 61 73 65  to open database
32b0: 20 66 69 6c 65 7d 7d 0a 0a 0a 64 62 20 63 6c 6f   file}}...db clo
32c0: 73 65 0a 66 69 6c 65 20 64 65 6c 65 74 65 20 2d  se.file delete -
32d0: 66 6f 72 63 65 20 74 65 73 74 2e 64 62 0a 0a 66  force test.db..f
32e0: 69 6e 69 73 68 5f 74 65 73 74 0a                 inish_test.