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

Artifact 6f59801b47e042e353a71d282f697782baac2f9d:


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 38 20 32  sc7.test,v 1.8 2
01c0: 30 30 37 2f 30 33 2f 33 30 20 31 38 3a 32 31 3a  007/03/30 18:21:
01d0: 35 33 20 64 61 6e 69 65 6c 6b 31 39 37 37 20 45  53 danielk1977 E
01e0: 78 70 20 24 0a 0a 73 65 74 20 74 65 73 74 64 69  xp $..set testdi
01f0: 72 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20  r [file dirname 
0200: 24 61 72 67 76 30 5d 0a 73 6f 75 72 63 65 20 24  $argv0].source $
0210: 74 65 73 74 64 69 72 2f 74 65 73 74 65 72 2e 74  testdir/tester.t
0220: 63 6c 0a 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63  cl..do_test misc
0230: 37 2d 31 20 7b 0a 20 20 63 5f 6d 69 73 75 73 65  7-1 {.  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 27 73 20  tory where it's 
0390: 6a 6f 75 72 6e 61 6c 20 66 69 6c 65 20 73 68 6f  journal file sho
03a0: 75 6c 64 20 62 65 2e 0a 23 0a 64 6f 5f 74 65 73  uld be..#.do_tes
03b0: 74 20 6d 69 73 63 37 2d 35 20 7b 0a 20 20 66 69  t misc7-5 {.  fi
03c0: 6c 65 20 64 65 6c 65 74 65 20 6d 79 64 69 72 0a  le delete mydir.
03d0: 20 20 66 69 6c 65 20 6d 6b 64 69 72 20 6d 79 64    file mkdir myd
03e0: 69 72 2d 6a 6f 75 72 6e 61 6c 0a 20 20 73 71 6c  ir-journal.  sql
03f0: 69 74 65 33 20 64 62 32 20 2e 2f 6d 79 64 69 72  ite3 db2 ./mydir
0400: 0a 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20  .  catchsql {.  
0410: 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61    CREATE TABLE a
0420: 62 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 7d  bc(a, b, c);.  }
0430: 20 64 62 32 0a 7d 20 7b 31 20 7b 75 6e 61 62 6c   db2.} {1 {unabl
0440: 65 20 74 6f 20 6f 70 65 6e 20 64 61 74 61 62 61  e to open databa
0450: 73 65 20 66 69 6c 65 7d 7d 0a 64 62 32 20 63 6c  se file}}.db2 cl
0460: 6f 73 65 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ose..#----------
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 0a 23 20 54 68 65  ----------.# The
04b0: 20 66 6f 6c 6c 6f 77 69 6e 67 20 74 65 73 74 73   following tests
04c0: 2c 20 6d 69 73 63 37 2d 36 2e 2a 20 74 65 73 74  , misc7-6.* test
04d0: 20 74 68 65 20 6c 69 62 72 61 72 69 65 73 20 62   the libraries b
04e0: 65 68 61 76 69 6f 75 72 20 77 68 65 6e 0a 23 20  ehaviour when.# 
04f0: 69 74 20 63 61 6e 6e 6f 74 20 6f 70 65 6e 20 61  it cannot open a
0500: 20 66 69 6c 65 2e 20 54 6f 20 66 6f 72 63 65 20   file. To force 
0510: 74 68 69 73 20 63 6f 6e 64 69 74 69 6f 6e 2c 20  this condition, 
0520: 77 65 20 75 73 65 20 75 70 20 61 6c 6c 20 74 68  we use up all th
0530: 65 0a 23 20 66 69 6c 65 2d 64 65 73 63 72 69 70  e.# file-descrip
0540: 74 6f 72 73 20 62 65 66 6f 72 65 20 72 75 6e 6e  tors before runn
0550: 69 6e 67 20 73 71 6c 69 74 65 2e 20 54 68 69 73  ing sqlite. This
0560: 20 70 72 6f 62 61 62 6c 79 20 6f 6e 6c 79 20 77   probably only w
0570: 6f 72 6b 73 0a 23 20 6f 6e 20 75 6e 69 78 2e 0a  orks.# on unix..
0580: 23 0a 0a 70 72 6f 63 20 75 73 65 5f 75 70 5f 66  #..proc use_up_f
0590: 69 6c 65 73 20 7b 7d 20 7b 0a 20 20 73 65 74 20  iles {} {.  set 
05a0: 72 65 74 20 5b 6c 69 73 74 5d 0a 20 20 63 61 74  ret [list].  cat
05b0: 63 68 20 7b 0a 20 20 20 20 77 68 69 6c 65 20 31  ch {.    while 1
05c0: 20 7b 20 6c 61 70 70 65 6e 64 20 72 65 74 20 5b   { lappend ret [
05d0: 6f 70 65 6e 20 74 65 73 74 2e 64 62 5d 20 7d 0a  open test.db] }.
05e0: 20 20 7d 0a 20 20 72 65 74 75 72 6e 20 24 72 65    }.  return $re
05f0: 74 0a 7d 0a 0a 70 72 6f 63 20 64 6f 5f 66 69 6c  t.}..proc do_fil
0600: 65 6f 70 65 6e 5f 74 65 73 74 20 7b 70 72 65 66  eopen_test {pref
0610: 69 78 20 73 71 6c 7d 20 7b 0a 20 20 73 65 74 20  ix sql} {.  set 
0620: 66 64 5f 6c 69 73 74 20 5b 75 73 65 5f 75 70 5f  fd_list [use_up_
0630: 66 69 6c 65 73 5d 0a 20 20 73 65 74 20 3a 3a 67  files].  set ::g
0640: 6f 20 31 0a 20 20 73 65 74 20 3a 3a 6e 20 31 0a  o 1.  set ::n 1.
0650: 20 20 73 65 74 20 3a 3a 73 71 6c 20 24 73 71 6c    set ::sql $sql
0660: 0a 20 20 77 68 69 6c 65 20 7b 24 3a 3a 67 6f 7d  .  while {$::go}
0670: 20 7b 0a 20 20 20 20 63 61 74 63 68 20 7b 64 62   {.    catch {db
0680: 20 63 6c 6f 73 65 7d 0a 20 20 20 20 64 6f 5f 74   close}.    do_t
0690: 65 73 74 20 24 7b 70 72 65 66 69 78 7d 2e 24 7b  est ${prefix}.${
06a0: 3a 3a 6e 7d 20 7b 0a 20 20 20 20 20 20 73 65 74  ::n} {.      set
06b0: 20 72 63 20 5b 63 61 74 63 68 20 7b 0a 20 20 20   rc [catch {.   
06c0: 20 20 20 20 20 73 71 6c 69 74 65 20 64 62 20 74       sqlite db t
06d0: 65 73 74 2e 64 62 0a 20 20 20 20 20 20 20 20 64  est.db.        d
06e0: 62 20 65 76 61 6c 20 24 3a 3a 73 71 6c 0a 20 20  b eval $::sql.  
06f0: 20 20 20 20 7d 20 6d 73 67 5d 0a 20 20 20 20 20      } msg].     
0700: 20 69 66 20 7b 24 72 63 20 3d 3d 20 30 7d 20 7b   if {$rc == 0} {
0710: 73 65 74 20 3a 3a 67 6f 20 30 7d 0a 20 20 0a 20  set ::go 0}.  . 
0720: 20 20 20 20 20 65 78 70 72 20 7b 24 72 63 20 3d       expr {$rc =
0730: 3d 20 30 20 7c 7c 20 28 24 72 63 20 3d 3d 20 31  = 0 || ($rc == 1
0740: 20 26 26 20 5b 73 74 72 69 6e 67 20 66 69 72 73   && [string firs
0750: 74 20 75 6e 61 62 6c 65 20 24 6d 73 67 5d 3d 3d  t unable $msg]==
0760: 30 29 7d 0a 20 20 20 20 7d 20 31 0a 20 20 0a 20  0)}.    } 1.  . 
0770: 20 20 20 63 6c 6f 73 65 20 5b 6c 69 6e 64 65 78     close [lindex
0780: 20 24 66 64 5f 6c 69 73 74 20 30 5d 0a 20 20 20   $fd_list 0].   
0790: 20 73 65 74 20 66 64 5f 6c 69 73 74 20 5b 6c 72   set fd_list [lr
07a0: 61 6e 67 65 20 24 66 64 5f 6c 69 73 74 20 31 20  ange $fd_list 1 
07b0: 65 6e 64 5d 0a 20 20 20 20 69 6e 63 72 20 3a 3a  end].    incr ::
07c0: 6e 0a 20 20 7d 0a 20 20 66 6f 72 65 61 63 68 20  n.  }.  foreach 
07d0: 66 64 20 24 66 64 5f 6c 69 73 74 20 7b 0a 20 20  fd $fd_list {.  
07e0: 20 20 63 6c 6f 73 65 20 24 66 64 0a 20 20 7d 0a    close $fd.  }.
07f0: 20 20 64 62 20 63 6c 6f 73 65 0a 7d 0a 0a 65 78    db close.}..ex
0800: 65 63 73 71 6c 20 7b 20 43 52 45 41 54 45 20 54  ecsql { CREATE T
0810: 41 42 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41  ABLE abc(a PRIMA
0820: 52 59 20 4b 45 59 2c 20 62 2c 20 63 29 3b 20 7d  RY KEY, b, c); }
0830: 0a 64 62 20 63 6c 6f 73 65 0a 0a 64 6f 5f 66 69  .db close..do_fi
0840: 6c 65 6f 70 65 6e 5f 74 65 73 74 20 6d 69 73 63  leopen_test misc
0850: 37 2d 36 2e 31 20 7b 0a 20 20 42 45 47 49 4e 3b  7-6.1 {.  BEGIN;
0860: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61  .  INSERT INTO a
0870: 62 63 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20  bc VALUES(1, 2, 
0880: 33 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  3);.  INSERT INT
0890: 4f 20 61 62 63 20 56 41 4c 55 45 53 28 32 2c 20  O abc VALUES(2, 
08a0: 33 2c 20 34 29 3b 0a 20 20 49 4e 53 45 52 54 20  3, 4);.  INSERT 
08b0: 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54 20  INTO abc SELECT 
08c0: 61 2b 32 2c 20 62 2c 20 63 20 46 52 4f 4d 20 61  a+2, b, c FROM a
08d0: 62 63 3b 0a 20 20 43 4f 4d 4d 49 54 3b 0a 7d 0a  bc;.  COMMIT;.}.
08e0: 0a 64 6f 5f 66 69 6c 65 6f 70 65 6e 5f 74 65 73  .do_fileopen_tes
08f0: 74 20 6d 69 73 63 37 2d 36 2e 32 20 7b 0a 20 20  t misc7-6.2 {.  
0900: 50 52 41 47 4d 41 20 74 65 6d 70 2e 63 61 63 68  PRAGMA temp.cach
0910: 65 5f 73 69 7a 65 20 3d 20 31 30 30 30 3b 0a 7d  e_size = 1000;.}
0920: 0a 0a 23 0a 23 20 45 6e 64 20 6f 66 20 74 65 73  ..#.# End of tes
0930: 74 73 20 66 6f 72 20 6f 75 74 2d 6f 66 2d 66 69  ts for out-of-fi
0940: 6c 65 2d 64 65 73 63 72 69 70 74 6f 72 73 20 63  le-descriptors c
0950: 6f 6e 64 69 74 69 6f 6e 2e 0a 23 2d 2d 2d 2d 2d  ondition..#-----
0960: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0970: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0980: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0990: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
09a0: 0a 73 71 6c 69 74 65 33 20 64 62 20 74 65 73 74  .sqlite3 db test
09b0: 2e 64 62 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .db.#-----------
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 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
09f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74  ---------.# Test
0a00: 20 74 68 61 74 20 74 68 65 20 73 71 6c 69 74 65   that the sqlite
0a10: 33 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 20 63  3_busy_timeout c
0a20: 61 6c 6c 20 73 65 65 6d 73 20 74 6f 20 64 65 6c  all seems to del
0a30: 61 79 20 61 70 70 72 6f 78 69 6d 61 74 65 6c 79  ay approximately
0a40: 0a 23 20 74 68 65 20 72 69 67 68 74 20 61 6d 6f  .# the right amo
0a50: 75 6e 74 20 6f 66 20 74 69 6d 65 2e 0a 23 0a 64  unt of time..#.d
0a60: 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d 37 2e 30  o_test misc7-7.0
0a70: 20 7b 0a 20 20 73 71 6c 69 74 65 33 20 64 62 32   {.  sqlite3 db2
0a80: 20 74 65 73 74 2e 64 62 0a 20 20 73 71 6c 69 74   test.db.  sqlit
0a90: 65 33 5f 62 75 73 79 5f 74 69 6d 65 6f 75 74 20  e3_busy_timeout 
0aa0: 5b 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74  [sqlite3_connect
0ab0: 69 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d 20  ion_pointer db] 
0ac0: 32 30 30 30 0a 20 20 65 78 65 63 73 71 6c 20 7b  2000.  execsql {
0ad0: 0a 20 20 20 20 42 45 47 49 4e 20 45 58 43 4c 55  .    BEGIN EXCLU
0ae0: 53 49 56 45 3b 0a 20 20 7d 20 64 62 32 0a 0a 20  SIVE;.  } db2.. 
0af0: 20 23 20 4e 6f 77 20 64 62 32 20 68 61 73 20 61   # Now db2 has a
0b00: 6e 20 65 78 63 6c 75 73 69 76 65 20 6c 6f 63 6b  n exclusive lock
0b10: 20 6f 6e 20 74 68 65 20 64 61 74 61 62 61 73 65   on the database
0b20: 20 66 69 6c 65 2c 20 61 6e 64 20 64 62 20 68 61   file, and db ha
0b30: 73 0a 20 20 23 20 61 20 62 75 73 79 2d 74 69 6d  s.  # a busy-tim
0b40: 65 6f 75 74 20 6f 66 20 32 30 30 30 20 6d 69 6c  eout of 2000 mil
0b50: 6c 69 73 65 63 6f 6e 64 73 2e 20 53 6f 20 63 68  liseconds. So ch
0b60: 65 63 6b 20 74 68 61 74 20 74 72 79 69 6e 67 20  eck that trying 
0b70: 74 6f 0a 20 20 23 20 61 63 63 65 73 73 20 74 68  to.  # access th
0b80: 65 20 64 61 74 61 62 61 73 65 20 75 73 69 6e 67  e database using
0b90: 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 64 62 20 64   connection db d
0ba0: 65 6c 61 79 73 20 66 6f 72 20 61 74 20 6c 65 61  elays for at lea
0bb0: 73 74 20 31 35 30 30 20 6d 73 2e 0a 20 20 23 0a  st 1500 ms..  #.
0bc0: 20 20 73 65 74 20 74 6d 20 5b 74 69 6d 65 20 7b    set tm [time {
0bd0: 0a 20 20 20 20 73 65 74 20 72 65 73 75 6c 74 20  .    set result 
0be0: 5b 63 61 74 63 68 73 71 6c 20 7b 0a 20 20 20 20  [catchsql {.    
0bf0: 20 20 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f      SELECT * FRO
0c00: 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 3b  M sqlite_master;
0c10: 0a 20 20 20 20 20 20 7d 20 64 62 5d 0a 20 20 7d  .      } db].  }
0c20: 5d 0a 20 20 73 65 74 20 64 65 6c 61 79 20 5b 6c  ].  set delay [l
0c30: 69 6e 64 65 78 20 24 74 6d 20 30 5d 20 20 3b 23  index $tm 0]  ;#
0c40: 20 49 6e 20 6d 69 63 72 6f 73 65 63 6f 6e 64 73   In microseconds
0c50: 0a 20 20 6c 61 70 70 65 6e 64 20 72 65 73 75 6c  .  lappend resul
0c60: 74 20 5b 65 78 70 72 20 7b 24 64 65 6c 61 79 3e  t [expr {$delay>
0c70: 31 35 30 30 30 30 30 20 26 26 20 24 64 65 6c 61  1500000 && $dela
0c80: 79 3c 33 30 30 30 30 30 30 7d 5d 0a 7d 20 7b 31  y<3000000}].} {1
0c90: 20 7b 64 61 74 61 62 61 73 65 20 69 73 20 6c 6f   {database is lo
0ca0: 63 6b 65 64 7d 20 31 7d 0a 64 62 32 20 63 6c 6f  cked} 1}.db2 clo
0cb0: 73 65 0a 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  se...#----------
0cc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0cd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0ce0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0cf0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73  ----------.# Tes
0d00: 74 20 74 68 61 74 20 6e 6f 74 68 69 6e 67 20 67  t that nothing g
0d10: 6f 65 73 20 68 6f 72 72 69 62 6c 79 20 77 72 6f  oes horribly wro
0d20: 6e 67 20 77 68 65 6e 20 61 74 74 61 63 68 69 6e  ng when attachin
0d30: 67 20 61 20 64 61 74 61 62 61 73 65 0a 23 20 61  g a database.# a
0d40: 66 74 65 72 20 74 68 65 20 6f 6d 69 74 5f 72 65  fter the omit_re
0d50: 61 64 6c 6f 63 6b 20 70 72 61 67 6d 61 20 68 61  adlock pragma ha
0d60: 73 20 62 65 65 6e 20 65 78 65 72 63 69 73 65 64  s been exercised
0d70: 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63  ..#.do_test misc
0d80: 37 2d 37 2e 31 20 7b 0a 20 20 66 69 6c 65 20 64  7-7.1 {.  file d
0d90: 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73  elete -force tes
0da0: 74 32 2e 64 62 0a 20 20 66 69 6c 65 20 64 65 6c  t2.db.  file del
0db0: 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74 32  ete -force test2
0dc0: 2e 64 62 2d 6a 6f 75 72 6e 61 6c 0a 20 20 65 78  .db-journal.  ex
0dd0: 65 63 73 71 6c 20 7b 0a 20 20 20 20 50 52 41 47  ecsql {.    PRAG
0de0: 4d 41 20 6f 6d 69 74 5f 72 65 61 64 6c 6f 63 6b  MA omit_readlock
0df0: 20 3d 20 31 3b 0a 20 20 20 20 41 54 54 41 43 48   = 1;.    ATTACH
0e00: 20 27 74 65 73 74 32 2e 64 62 27 20 41 53 20 61   'test2.db' AS a
0e10: 75 78 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54  ux;.    CREATE T
0e20: 41 42 4c 45 20 61 75 78 2e 68 65 6c 6c 6f 28 77  ABLE aux.hello(w
0e30: 6f 72 6c 64 29 3b 0a 20 20 20 20 53 45 4c 45 43  orld);.    SELEC
0e40: 54 20 6e 61 6d 65 20 46 52 4f 4d 20 61 75 78 2e  T name FROM aux.
0e50: 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 3b 0a 20  sqlite_master;. 
0e60: 20 7d 0a 7d 20 7b 68 65 6c 6c 6f 7d 0a 64 6f 5f   }.} {hello}.do_
0e70: 74 65 73 74 20 6d 69 73 63 37 2d 37 2e 32 20 7b  test misc7-7.2 {
0e80: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
0e90: 20 44 45 54 41 43 48 20 61 75 78 3b 0a 20 20 7d   DETACH aux;.  }
0ea0: 0a 7d 20 7b 7d 0a 0a 23 20 54 65 73 74 20 6d 61  .} {}..# Test ma
0eb0: 6c 6c 6f 63 20 66 61 69 6c 75 72 65 20 77 68 69  lloc failure whi
0ec0: 6c 73 74 20 69 6e 73 74 61 6c 6c 69 6e 67 20 61  lst installing a
0ed0: 20 66 6f 72 69 65 67 6e 20 6b 65 79 2e 0a 23 0a   foriegn key..#.
0ee0: 69 66 63 61 70 61 62 6c 65 20 75 74 66 31 36 20  ifcapable utf16 
0ef0: 7b 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63  {.  do_test misc
0f00: 37 2d 38 20 7b 0a 20 20 20 20 65 6e 63 6f 64 69  7-8 {.    encodi
0f10: 6e 67 20 63 6f 6e 76 65 72 74 66 72 6f 6d 20 75  ng convertfrom u
0f20: 6e 69 63 6f 64 65 20 5b 73 71 6c 69 74 65 33 5f  nicode [sqlite3_
0f30: 65 72 72 6d 73 67 31 36 20 30 78 30 30 30 30 30  errmsg16 0x00000
0f40: 30 30 30 5d 0a 20 20 7d 20 7b 6f 75 74 20 6f 66  000].  } {out of
0f50: 20 6d 65 6d 6f 72 79 7d 0a 7d 0a 0a 64 6f 5f 74   memory}.}..do_t
0f60: 65 73 74 20 6d 69 73 63 37 2d 39 20 7b 0a 20 20  est misc7-9 {.  
0f70: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45  execsql {.    SE
0f80: 4c 45 43 54 20 2a 20 0a 20 20 20 20 46 52 4f 4d  LECT * .    FROM
0f90: 20 28 53 45 4c 45 43 54 20 6e 61 6d 65 2b 31 20   (SELECT name+1 
0fa0: 41 53 20 6f 6e 65 20 46 52 4f 4d 20 73 71 6c 69  AS one FROM sqli
0fb0: 74 65 5f 6d 61 73 74 65 72 20 4c 49 4d 49 54 20  te_master LIMIT 
0fc0: 31 20 4f 46 46 53 45 54 20 31 29 20 0a 20 20 20  1 OFFSET 1) .   
0fd0: 20 57 48 45 52 45 20 6f 6e 65 20 4c 49 4b 45 20   WHERE one LIKE 
0fe0: 27 68 65 6c 6c 6f 25 27 3b 0a 20 20 7d 0a 7d 20  'hello%';.  }.} 
0ff0: 7b 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  {}..#-----------
1000: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 49 6d 70 72  ---------.# Impr
1040: 6f 76 65 20 63 6f 76 65 72 61 67 65 20 66 6f 72  ove coverage for
1050: 20 76 74 61 62 20 63 6f 64 65 2e 0a 23 0a 69 66   vtab code..#.if
1060: 63 61 70 61 62 6c 65 20 76 74 61 62 20 7b 0a 20  capable vtab {. 
1070: 20 23 20 52 75 6e 20 73 6f 6d 65 20 64 65 62 75   # Run some debu
1080: 67 20 63 6f 64 65 20 74 6f 20 69 6d 70 72 6f 76  g code to improv
1090: 65 20 72 65 70 6f 72 74 65 64 20 63 6f 76 65 72  e reported cover
10a0: 61 67 65 0a 20 20 23 0a 0a 20 20 23 20 73 65 74  age.  #..  # set
10b0: 20 73 71 6c 69 74 65 5f 77 68 65 72 65 5f 74 72   sqlite_where_tr
10c0: 61 63 65 20 31 0a 20 20 64 6f 5f 74 65 73 74 20  ace 1.  do_test 
10d0: 6d 69 73 63 37 2d 31 30 20 7b 0a 20 20 20 20 72  misc7-10 {.    r
10e0: 65 67 69 73 74 65 72 5f 65 63 68 6f 5f 6d 6f 64  egister_echo_mod
10f0: 75 6c 65 20 5b 73 71 6c 69 74 65 33 5f 63 6f 6e  ule [sqlite3_con
1100: 6e 65 63 74 69 6f 6e 5f 70 6f 69 6e 74 65 72 20  nection_pointer 
1110: 64 62 5d 0a 20 20 20 20 65 78 65 63 73 71 6c 20  db].    execsql 
1120: 7b 0a 20 20 20 20 20 20 43 52 45 41 54 45 20 56  {.      CREATE V
1130: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 20  IRTUAL TABLE t1 
1140: 55 53 49 4e 47 20 65 63 68 6f 28 61 62 63 29 3b  USING echo(abc);
1150: 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20 61 20  .      SELECT a 
1160: 46 52 4f 4d 20 74 31 20 57 48 45 52 45 20 61 20  FROM t1 WHERE a 
1170: 3d 20 31 20 4f 52 44 45 52 20 42 59 20 62 3b 0a  = 1 ORDER BY b;.
1180: 20 20 20 20 7d 0a 20 20 7d 20 7b 31 7d 0a 20 20      }.  } {1}.  
1190: 73 65 74 20 73 71 6c 69 74 65 5f 77 68 65 72 65  set sqlite_where
11a0: 5f 74 72 61 63 65 20 30 0a 0a 20 20 23 20 53 70  _trace 0..  # Sp
11b0: 65 63 69 66 79 20 61 6e 20 4f 52 44 45 52 20 42  ecify an ORDER B
11c0: 59 20 63 6c 61 75 73 65 20 74 68 61 74 20 63 61  Y clause that ca
11d0: 6e 6e 6f 74 20 62 65 20 69 6e 64 65 78 65 64 2e  nnot be indexed.
11e0: 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63 37  .  do_test misc7
11f0: 2d 31 31 20 7b 0a 20 20 20 20 65 78 65 63 73 71  -11 {.    execsq
1200: 6c 20 7b 0a 20 20 20 20 20 20 53 45 4c 45 43 54  l {.      SELECT
1210: 20 74 31 2e 61 2c 20 74 32 2e 61 20 46 52 4f 4d   t1.a, t2.a FROM
1220: 20 74 31 2c 20 74 31 20 41 53 20 74 32 20 4f 52   t1, t1 AS t2 OR
1230: 44 45 52 20 42 59 20 32 20 4c 49 4d 49 54 20 31  DER BY 2 LIMIT 1
1240: 3b 0a 20 20 20 20 7d 0a 20 20 7d 20 7b 31 20 31  ;.    }.  } {1 1
1250: 7d 0a 0a 20 20 23 20 54 68 65 20 77 68 6f 6c 65  }..  # The whole
1260: 20 70 6f 69 6e 74 20 6f 66 20 74 68 69 73 20 69   point of this i
1270: 73 20 74 6f 20 74 65 73 74 20 61 6e 20 65 72 72  s to test an err
1280: 6f 72 20 63 6f 64 65 20 6f 74 68 65 72 20 74 68  or code other th
1290: 61 6e 0a 20 20 23 20 53 51 4c 49 54 45 5f 4e 4f  an.  # SQLITE_NO
12a0: 4d 45 4d 20 66 72 6f 6d 20 74 68 65 20 76 74 61  MEM from the vta
12b0: 62 20 78 42 65 73 74 49 6e 64 65 78 20 63 61 6c  b xBestIndex cal
12c0: 6c 62 61 63 6b 2e 0a 20 20 23 0a 20 20 64 6f 5f  lback..  #.  do_
12d0: 69 6f 65 72 72 5f 74 65 73 74 20 6d 69 73 63 37  ioerr_test misc7
12e0: 2d 31 32 20 2d 74 63 6c 70 72 65 70 20 7b 0a 20  -12 -tclprep {. 
12f0: 20 20 20 73 71 6c 69 74 65 33 20 64 62 32 20 74     sqlite3 db2 t
1300: 65 73 74 2e 64 62 0a 20 20 20 20 72 65 67 69 73  est.db.    regis
1310: 74 65 72 5f 65 63 68 6f 5f 6d 6f 64 75 6c 65 20  ter_echo_module 
1320: 5b 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74  [sqlite3_connect
1330: 69 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 32 5d  ion_pointer db2]
1340: 0a 20 20 20 20 64 62 32 20 65 76 61 6c 20 7b 0a  .    db2 eval {.
1350: 20 20 20 20 20 20 43 52 45 41 54 45 20 54 41 42        CREATE TAB
1360: 4c 45 20 61 62 63 28 61 20 50 52 49 4d 41 52 59  LE abc(a PRIMARY
1370: 20 4b 45 59 2c 20 62 2c 20 63 29 3b 0a 20 20 20   KEY, b, c);.   
1380: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61     INSERT INTO a
1390: 62 63 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20  bc VALUES(1, 2, 
13a0: 33 29 3b 0a 20 20 20 20 20 20 43 52 45 41 54 45  3);.      CREATE
13b0: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74   VIRTUAL TABLE t
13c0: 31 20 55 53 49 4e 47 20 65 63 68 6f 28 61 62 63  1 USING echo(abc
13d0: 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 64 62 32  );.    }.    db2
13e0: 20 63 6c 6f 73 65 0a 20 20 7d 20 2d 74 63 6c 62   close.  } -tclb
13f0: 6f 64 79 20 7b 0a 20 20 20 20 72 65 67 69 73 74  ody {.    regist
1400: 65 72 5f 65 63 68 6f 5f 6d 6f 64 75 6c 65 20 5b  er_echo_module [
1410: 73 71 6c 69 74 65 33 5f 63 6f 6e 6e 65 63 74 69  sqlite3_connecti
1420: 6f 6e 5f 70 6f 69 6e 74 65 72 20 64 62 5d 0a 20  on_pointer db]. 
1430: 20 20 20 65 78 65 63 73 71 6c 20 7b 53 45 4c 45     execsql {SELE
1440: 43 54 20 2a 20 46 52 4f 4d 20 74 31 20 57 48 45  CT * FROM t1 WHE
1450: 52 45 20 61 20 3d 20 31 3b 7d 0a 20 20 7d 20 0a  RE a = 1;}.  } .
1460: 0a 20 20 23 20 54 68 65 20 63 61 73 65 20 77 68  .  # The case wh
1470: 65 72 65 20 74 68 65 20 76 69 72 74 75 61 6c 20  ere the virtual 
1480: 74 61 62 6c 65 20 6d 6f 64 75 6c 65 20 72 65 74  table module ret
1490: 75 72 6e 73 20 61 20 76 65 72 79 20 6c 61 72 67  urns a very larg
14a0: 65 20 6e 75 6d 62 65 72 0a 20 20 23 20 61 73 20  e number.  # as 
14b0: 74 68 65 20 63 6f 73 74 20 6f 66 20 61 20 73 63  the cost of a sc
14c0: 61 6e 20 28 67 72 65 61 74 65 72 20 74 68 61 6e  an (greater than
14d0: 20 53 51 4c 49 54 45 5f 42 49 47 5f 44 4f 55 42   SQLITE_BIG_DOUB
14e0: 4c 45 20 69 6e 20 74 68 65 20 63 6f 64 65 29 2e  LE in the code).
14f0: 0a 20 20 23 0a 20 20 64 6f 5f 74 65 73 74 20 6d  .  #.  do_test m
1500: 69 73 63 37 2d 31 33 20 7b 0a 20 20 20 20 73 71  isc7-13 {.    sq
1510: 6c 69 74 65 33 20 64 62 20 74 65 73 74 2e 64 62  lite3 db test.db
1520: 0a 20 20 20 20 72 65 67 69 73 74 65 72 5f 65 63  .    register_ec
1530: 68 6f 5f 6d 6f 64 75 6c 65 20 5b 73 71 6c 69 74  ho_module [sqlit
1540: 65 33 5f 63 6f 6e 6e 65 63 74 69 6f 6e 5f 70 6f  e3_connection_po
1550: 69 6e 74 65 72 20 64 62 5d 0a 20 20 20 20 73 65  inter db].    se
1560: 74 20 3a 3a 65 63 68 6f 5f 6d 6f 64 75 6c 65 5f  t ::echo_module_
1570: 63 6f 73 74 20 32 2e 30 65 2b 39 39 0a 20 20 20  cost 2.0e+99.   
1580: 20 65 78 65 63 73 71 6c 20 7b 53 45 4c 45 43 54   execsql {SELECT
1590: 20 2a 20 46 52 4f 4d 20 74 31 20 57 48 45 52 45   * FROM t1 WHERE
15a0: 20 61 20 3d 20 31 3b 7d 0a 20 20 7d 20 7b 31 20   a = 1;}.  } {1 
15b0: 32 20 33 7d 0a 20 20 75 6e 73 65 74 20 3a 3a 65  2 3}.  unset ::e
15c0: 63 68 6f 5f 6d 6f 64 75 6c 65 5f 63 6f 73 74 0a  cho_module_cost.
15d0: 7d 0a 0a 64 62 20 63 6c 6f 73 65 0a 66 69 6c 65  }..db close.file
15e0: 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 74   delete -force t
15f0: 65 73 74 2e 64 62 0a 66 69 6c 65 20 64 65 6c 65  est.db.file dele
1600: 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74 2e 64  te -force test.d
1610: 62 2d 6a 6f 75 72 6e 61 6c 0a 73 71 6c 69 74 65  b-journal.sqlite
1620: 33 20 64 62 20 74 65 73 74 2e 64 62 0a 0a 69 66  3 db test.db..if
1630: 63 61 70 61 62 6c 65 20 65 78 70 6c 61 69 6e 20  capable explain 
1640: 7b 0a 20 20 64 6f 5f 74 65 73 74 20 6d 69 73 63  {.  do_test misc
1650: 37 2d 31 34 20 7b 0a 20 20 20 20 65 78 65 63 73  7-14 {.    execs
1660: 71 6c 20 7b 0a 20 20 20 20 20 20 43 52 45 41 54  ql {.      CREAT
1670: 45 20 54 41 42 4c 45 20 61 62 63 28 61 20 50 52  E TABLE abc(a PR
1680: 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 20 63 29  IMARY KEY, b, c)
1690: 3b 0a 20 20 20 20 7d 0a 20 20 20 20 65 78 65 63  ;.    }.    exec
16a0: 73 71 6c 20 7b 0a 20 20 20 20 20 20 45 58 50 4c  sql {.      EXPL
16b0: 41 49 4e 20 51 55 45 52 59 20 50 4c 41 4e 20 53  AIN QUERY PLAN S
16c0: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 61 62 63  ELECT * FROM abc
16d0: 20 41 53 20 74 32 20 57 48 45 52 45 20 72 6f 77   AS t2 WHERE row
16e0: 69 64 20 3d 20 31 3b 0a 20 20 20 20 7d 0a 20 20  id = 1;.    }.  
16f0: 7d 20 7b 30 20 30 20 7b 54 41 42 4c 45 20 61 62  } {0 0 {TABLE ab
1700: 63 20 41 53 20 74 32 20 55 53 49 4e 47 20 50 52  c AS t2 USING PR
1710: 49 4d 41 52 59 20 4b 45 59 7d 7d 0a 20 20 64 6f  IMARY KEY}}.  do
1720: 5f 74 65 73 74 20 6d 69 73 63 37 2d 31 35 20 7b  _test misc7-15 {
1730: 0a 20 20 20 20 65 78 65 63 73 71 6c 20 7b 0a 20  .    execsql {. 
1740: 20 20 20 20 20 45 58 50 4c 41 49 4e 20 51 55 45       EXPLAIN QUE
1750: 52 59 20 50 4c 41 4e 20 53 45 4c 45 43 54 20 2a  RY PLAN SELECT *
1760: 20 46 52 4f 4d 20 61 62 63 20 41 53 20 74 32 20   FROM abc AS t2 
1770: 57 48 45 52 45 20 61 20 3d 20 31 3b 0a 20 20 20  WHERE a = 1;.   
1780: 20 7d 0a 20 20 7d 20 7b 30 20 30 20 7b 54 41 42   }.  } {0 0 {TAB
1790: 4c 45 20 61 62 63 20 41 53 20 74 32 20 57 49 54  LE abc AS t2 WIT
17a0: 48 20 49 4e 44 45 58 20 73 71 6c 69 74 65 5f 61  H INDEX sqlite_a
17b0: 75 74 6f 69 6e 64 65 78 5f 61 62 63 5f 31 7d 7d  utoindex_abc_1}}
17c0: 0a 7d 0a 0a 64 62 20 63 6c 6f 73 65 0a 66 69 6c  .}..db close.fil
17d0: 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20  e delete -force 
17e0: 74 65 73 74 2e 64 62 0a 66 69 6c 65 20 64 65 6c  test.db.file del
17f0: 65 74 65 20 2d 66 6f 72 63 65 20 74 65 73 74 2e  ete -force test.
1800: 64 62 2d 6a 6f 75 72 6e 61 6c 0a 73 71 6c 69 74  db-journal.sqlit
1810: 65 33 20 64 62 20 74 65 73 74 2e 64 62 0a 0a 23  e3 db test.db..#
1820: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1830: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1840: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1850: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1860: 2d 2d 2d 2d 0a 23 20 54 68 69 73 20 69 73 20 61  ----.# This is a
1870: 6c 6c 20 74 6f 20 66 6f 72 63 65 20 74 68 65 20  ll to force the 
1880: 70 61 67 65 72 5f 72 65 6d 6f 76 65 5f 66 72 6f  pager_remove_fro
1890: 6d 5f 73 74 6d 74 5f 6c 69 73 74 28 29 20 66 75  m_stmt_list() fu
18a0: 6e 63 74 69 6f 6e 0a 23 20 28 69 6e 73 69 64 65  nction.# (inside
18b0: 20 70 61 67 65 72 2e 63 29 20 74 6f 20 72 65 6d   pager.c) to rem
18c0: 6f 76 65 20 61 20 70 61 67 65 72 20 66 72 6f 6d  ove a pager from
18d0: 20 74 68 65 20 6d 69 64 64 6c 65 20 6f 66 20 74   the middle of t
18e0: 68 65 0a 23 20 73 74 61 74 65 6d 65 6e 74 2d 6c  he.# statement-l
18f0: 69 73 74 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 6d  ist..#.do_test m
1900: 69 73 63 37 2d 31 35 2e 31 20 7b 0a 20 20 65 78  isc7-15.1 {.  ex
1910: 65 63 73 71 6c 20 7b 0a 20 20 20 20 50 52 41 47  ecsql {.    PRAG
1920: 4d 41 20 63 61 63 68 65 5f 73 69 7a 65 20 3d 20  MA cache_size = 
1930: 31 30 3b 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20  10;.    BEGIN;. 
1940: 20 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20     CREATE TABLE 
1950: 61 62 63 28 61 20 50 52 49 4d 41 52 59 20 4b 45  abc(a PRIMARY KE
1960: 59 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 49 4e  Y, b, c);.    IN
1970: 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 0a 20  SERT INTO abc . 
1980: 20 20 20 56 41 4c 55 45 53 28 72 61 6e 64 73 74     VALUES(randst
1990: 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64  r(100,100), rand
19a0: 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61  str(100,100), ra
19b0: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 29 3b  ndstr(100,100));
19c0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
19d0: 20 61 62 63 20 53 45 4c 45 43 54 20 0a 20 20 20   abc SELECT .   
19e0: 20 20 20 20 20 20 20 20 20 72 61 6e 64 73 74 72           randstr
19f0: 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73  (100,100), rands
1a00: 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e  tr(100,100), ran
1a10: 64 73 74 72 28 31 30 30 2c 31 30 30 29 20 46 52  dstr(100,100) FR
1a20: 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49 4e 53 45  OM abc;.    INSE
1a30: 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45  RT INTO abc SELE
1a40: 43 54 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  CT .            
1a50: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1a60: 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30  , randstr(100,10
1a70: 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c  0), randstr(100,
1a80: 31 30 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20  100) FROM abc;. 
1a90: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61     INSERT INTO a
1aa0: 62 63 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20  bc SELECT .     
1ab0: 20 20 20 20 20 20 20 72 61 6e 64 73 74 72 28 31         randstr(1
1ac0: 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72  00,100), randstr
1ad0: 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73  (100,100), rands
1ae0: 74 72 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d  tr(100,100) FROM
1af0: 20 61 62 63 3b 0a 20 20 20 20 49 4e 53 45 52 54   abc;.    INSERT
1b00: 20 49 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54   INTO abc SELECT
1b10: 20 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 61   .            ra
1b20: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20  ndstr(100,100), 
1b30: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1b40: 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30  , randstr(100,10
1b50: 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20  0) FROM abc;.   
1b60: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63   INSERT INTO abc
1b70: 20 53 45 4c 45 43 54 20 0a 20 20 20 20 20 20 20   SELECT .       
1b80: 20 20 20 20 20 72 61 6e 64 73 74 72 28 31 30 30       randstr(100
1b90: 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31  ,100), randstr(1
1ba0: 30 30 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72  00,100), randstr
1bb0: 28 31 30 30 2c 31 30 30 29 20 46 52 4f 4d 20 61  (100,100) FROM a
1bc0: 62 63 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  bc;.    INSERT I
1bd0: 4e 54 4f 20 61 62 63 20 53 45 4c 45 43 54 20 0a  NTO abc SELECT .
1be0: 20 20 20 20 20 20 20 20 20 20 20 20 72 61 6e 64              rand
1bf0: 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61  str(100,100), ra
1c00: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20  ndstr(100,100), 
1c10: 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29  randstr(100,100)
1c20: 20 46 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20 49   FROM abc;.    I
1c30: 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20 53  NSERT INTO abc S
1c40: 45 4c 45 43 54 20 0a 20 20 20 20 20 20 20 20 20  ELECT .         
1c50: 20 20 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31     randstr(100,1
1c60: 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30  00), randstr(100
1c70: 2c 31 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31  ,100), randstr(1
1c80: 30 30 2c 31 30 30 29 20 46 52 4f 4d 20 61 62 63  00,100) FROM abc
1c90: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
1ca0: 4f 20 61 62 63 20 53 45 4c 45 43 54 20 0a 20 20  O abc SELECT .  
1cb0: 20 20 20 20 20 20 20 20 20 20 72 61 6e 64 73 74            randst
1cc0: 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61 6e 64  r(100,100), rand
1cd0: 73 74 72 28 31 30 30 2c 31 30 30 29 2c 20 72 61  str(100,100), ra
1ce0: 6e 64 73 74 72 28 31 30 30 2c 31 30 30 29 20 46  ndstr(100,100) F
1cf0: 52 4f 4d 20 61 62 63 3b 0a 20 20 20 20 43 4f 4d  ROM abc;.    COM
1d00: 4d 49 54 3b 0a 20 20 7d 0a 20 20 65 78 70 72 20  MIT;.  }.  expr 
1d10: 7b 5b 66 69 6c 65 20 73 69 7a 65 20 74 65 73 74  {[file size test
1d20: 2e 64 62 5d 3e 31 30 32 34 30 7d 0a 7d 20 7b 31  .db]>10240}.} {1
1d30: 7d 0a 64 6f 5f 74 65 73 74 20 6d 69 73 63 37 2d  }.do_test misc7-
1d40: 31 35 2e 32 20 7b 0a 20 20 65 78 65 63 73 71 6c  15.2 {.  execsql
1d50: 20 7b 0a 20 20 20 20 44 45 4c 45 54 45 20 46 52   {.    DELETE FR
1d60: 4f 4d 20 61 62 63 20 57 48 45 52 45 20 72 6f 77  OM abc WHERE row
1d70: 69 64 20 3e 20 31 32 3b 0a 20 20 20 20 49 4e 53  id > 12;.    INS
1d80: 45 52 54 20 49 4e 54 4f 20 61 62 63 20 53 45 4c  ERT INTO abc SEL
1d90: 45 43 54 20 0a 20 20 20 20 20 20 20 20 20 20 20  ECT .           
1da0: 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31 30 30   randstr(100,100
1db0: 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30 2c 31  ), randstr(100,1
1dc0: 30 30 29 2c 20 72 61 6e 64 73 74 72 28 31 30 30  00), randstr(100
1dd0: 2c 31 30 30 29 20 46 52 4f 4d 20 61 62 63 3b 0a  ,100) FROM abc;.
1de0: 20 20 7d 0a 7d 20 7b 7d 0a 0a 0a 0a 0a 66 69 6e    }.} {}.....fin
1df0: 69 73 68 5f 74 65 73 74 0a                       ish_test.