/ Hex Artifact Content
Login

Artifact 62fc19dd36a427777fd671b569df07166548628a:


0000: 23 20 32 30 30 37 20 4d 61 79 20 31 30 0a 23 0a  # 2007 May 10.#.
0010: 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73  # The author dis
0020: 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74  claims copyright
0030: 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20   to this source 
0040: 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20  code.  In place 
0050: 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74  of.# a legal not
0060: 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62  ice, here is a b
0070: 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20  lessing:.#.#    
0080: 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20  May you do good 
0090: 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20  and not evil..# 
00a0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20     May you find 
00b0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20  forgiveness for 
00c0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72  yourself and for
00d0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20  give others..#  
00e0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20    May you share 
00f0: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61  freely, never ta
0100: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79  king more than y
0110: 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a  ou give..#.#****
0120: 2a 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 0a 23 20 54 68 69 73 20 66 69 6c 65 20  ***.# This file 
0170: 69 6d 70 6c 65 6d 65 6e 74 73 20 72 65 67 72 65  implements regre
0180: 73 73 69 6f 6e 20 74 65 73 74 73 20 66 6f 72 20  ssion tests for 
0190: 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79 2e 20  SQLite library. 
01a0: 20 54 68 65 0a 23 20 66 6f 63 75 73 20 6f 66 20   The.# focus of 
01b0: 74 68 69 73 20 66 69 6c 65 20 69 73 20 67 65 6e  this file is gen
01c0: 65 72 61 74 69 6e 67 20 73 65 6d 69 2d 72 61 6e  erating semi-ran
01d0: 64 6f 6d 20 73 74 72 69 6e 67 73 20 6f 66 20 53  dom strings of S
01e0: 51 4c 0a 23 20 28 61 2e 6b 2e 61 2e 20 22 66 75  QL.# (a.k.a. "fu
01f0: 7a 7a 22 29 20 61 6e 64 20 73 65 6e 64 69 6e 67  zz") and sending
0200: 20 69 74 20 69 6e 74 6f 20 74 68 65 20 70 61 72   it into the par
0210: 73 65 72 20 74 6f 20 74 72 79 20 74 6f 20 0a 23  ser to try to .#
0220: 20 67 65 6e 65 72 61 74 65 20 65 72 72 6f 72 73   generate errors
0230: 2e 0a 23 0a 23 20 54 68 65 20 74 65 73 74 73 20  ..#.# The tests 
0240: 69 6e 20 74 68 69 73 20 66 69 6c 65 20 61 72 65  in this file are
0250: 20 72 65 61 6c 6c 79 20 61 62 6f 75 74 20 74 65   really about te
0260: 73 74 69 6e 67 20 66 75 7a 7a 69 6c 79 20 67 65  sting fuzzily ge
0270: 6e 65 72 61 74 65 64 0a 23 20 53 51 4c 20 70 61  nerated.# SQL pa
0280: 72 73 65 2d 74 72 65 65 73 2e 20 54 68 65 20 6d  rse-trees. The m
0290: 61 6a 6f 72 69 74 79 20 6f 66 20 74 68 65 20 66  ajority of the f
02a0: 75 7a 7a 69 6c 79 20 67 65 6e 65 72 61 74 65 64  uzzily generated
02b0: 20 53 51 4c 20 69 73 20 0a 23 20 76 61 6c 69 64   SQL is .# valid
02c0: 20 61 73 20 66 61 72 20 61 73 20 74 68 65 20 70   as far as the p
02d0: 61 72 73 65 72 20 69 73 20 63 6f 6e 63 65 72 6e  arser is concern
02e0: 65 64 2e 20 0a 23 0a 23 20 54 68 65 20 6d 6f 73  ed. .#.# The mos
02f0: 74 20 63 6f 6d 70 6c 69 63 61 74 65 64 20 74 72  t complicated tr
0300: 65 65 73 20 61 72 65 20 66 6f 72 20 53 45 4c 45  ees are for SELE
0310: 43 54 20 73 74 61 74 65 6d 65 6e 74 73 2e 0a 23  CT statements..#
0320: 0a 23 20 24 49 64 3a 20 66 75 7a 7a 2e 74 65 73  .# $Id: fuzz.tes
0330: 74 2c 76 20 31 2e 31 34 20 32 30 30 37 2f 30 35  t,v 1.14 2007/05
0340: 2f 33 30 20 31 30 3a 33 36 3a 34 37 20 64 61 6e  /30 10:36:47 dan
0350: 69 65 6c 6b 31 39 37 37 20 45 78 70 20 24 0a 0a  ielk1977 Exp $..
0360: 73 65 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c  set testdir [fil
0370: 65 20 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30  e dirname $argv0
0380: 5d 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69  ].source $testdi
0390: 72 2f 74 65 73 74 65 72 2e 74 63 6c 0a 0a 73 65  r/tester.tcl..se
03a0: 74 20 3a 3a 52 45 50 45 41 54 53 20 35 30 30 30  t ::REPEATS 5000
03b0: 0a 0a 23 20 49 66 20 72 75 6e 6e 69 6e 67 20 71  ..# If running q
03c0: 75 69 63 6b 2e 74 65 73 74 2c 20 64 6f 6e 27 74  uick.test, don't
03d0: 20 64 6f 20 73 6f 20 6d 61 6e 79 20 69 74 65 72   do so many iter
03e0: 61 74 69 6f 6e 73 2e 0a 69 66 20 7b 5b 69 6e 66  ations..if {[inf
03f0: 6f 20 65 78 69 73 74 73 20 3a 3a 49 53 51 55 49  o exists ::ISQUI
0400: 43 4b 5d 7d 20 7b 0a 20 20 69 66 20 7b 24 3a 3a  CK]} {.  if {$::
0410: 49 53 51 55 49 43 4b 7d 20 7b 20 73 65 74 20 3a  ISQUICK} { set :
0420: 3a 52 45 50 45 41 54 53 20 32 30 20 7d 0a 7d 0a  :REPEATS 20 }.}.
0430: 0a 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72  .source $testdir
0440: 2f 66 75 7a 7a 5f 63 6f 6d 6d 6f 6e 2e 74 63 6c  /fuzz_common.tcl
0450: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
0460: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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 0a 23 20 54 68 65 73 65 20 74 65 73 74  ---.# These test
04a0: 73 20 63 61 75 73 65 64 20 65 72 72 6f 72 73 20  s caused errors 
04b0: 74 68 61 74 20 77 65 72 65 20 66 69 72 73 74 20  that were first 
04c0: 63 61 75 67 68 74 20 62 79 20 74 68 65 20 74 65  caught by the te
04d0: 73 74 73 0a 23 20 69 6e 20 74 68 69 73 20 66 69  sts.# in this fi
04e0: 6c 65 2e 20 54 68 65 79 20 61 72 65 20 73 74 69  le. They are sti
04f0: 6c 6c 20 68 65 72 65 2e 0a 64 6f 5f 74 65 73 74  ll here..do_test
0500: 20 66 75 7a 7a 2d 31 2e 31 20 7b 0a 20 20 65 78   fuzz-1.1 {.  ex
0510: 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45  ecsql {.    SELE
0520: 43 54 20 27 61 62 63 27 20 4c 49 4b 45 20 58 27  CT 'abc' LIKE X'
0530: 41 42 43 44 27 3b 0a 20 20 7d 0a 7d 20 7b 30 7d  ABCD';.  }.} {0}
0540: 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e  .do_test fuzz-1.
0550: 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a  2 {.  execsql {.
0560: 20 20 20 20 53 45 4c 45 43 54 20 27 61 62 63 27      SELECT 'abc'
0570: 20 4c 49 4b 45 20 7a 65 72 6f 62 6c 6f 62 28 31   LIKE zeroblob(1
0580: 30 29 3b 0a 20 20 7d 0a 7d 20 7b 30 7d 0a 64 6f  0);.  }.} {0}.do
0590: 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 33 20 7b  _test fuzz-1.3 {
05a0: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
05b0: 20 53 45 4c 45 43 54 20 7a 65 72 6f 62 6c 6f 62   SELECT zeroblob
05c0: 28 31 30 29 20 4c 49 4b 45 20 27 61 62 63 27 3b  (10) LIKE 'abc';
05d0: 0a 20 20 7d 0a 7d 20 7b 30 7d 0a 64 6f 5f 74 65  .  }.} {0}.do_te
05e0: 73 74 20 66 75 7a 7a 2d 31 2e 34 20 7b 0a 20 20  st fuzz-1.4 {.  
05f0: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45  execsql {.    SE
0600: 4c 45 43 54 20 28 2d 20 2d 32 31 29 20 25 20 4e  LECT (- -21) % N
0610: 4f 54 20 28 34 35 36 20 4c 49 4b 45 20 7a 65 72  OT (456 LIKE zer
0620: 6f 62 6c 6f 62 28 31 30 29 29 3b 0a 20 20 7d 0a  oblob(10));.  }.
0630: 7d 20 7b 30 7d 0a 64 6f 5f 74 65 73 74 20 66 75  } {0}.do_test fu
0640: 7a 7a 2d 31 2e 35 20 7b 0a 20 20 65 78 65 63 73  zz-1.5 {.  execs
0650: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
0660: 28 53 45 4c 45 43 54 20 28 0a 20 20 20 20 20 20  (SELECT (.      
0670: 20 20 53 45 4c 45 43 54 20 28 53 45 4c 45 43 54    SELECT (SELECT
0680: 20 2d 32 31 34 37 34 38 33 36 34 38 29 20 46 52   -2147483648) FR
0690: 4f 4d 20 28 53 45 4c 45 43 54 20 31 29 20 4f 52  OM (SELECT 1) OR
06a0: 44 45 52 20 42 59 20 31 0a 20 20 20 20 29 29 0a  DER BY 1.    )).
06b0: 20 20 7d 0a 7d 20 7b 2d 32 31 34 37 34 38 33 36    }.} {-21474836
06c0: 34 38 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a  48}.do_test fuzz
06d0: 2d 31 2e 36 20 7b 0a 20 20 65 78 65 63 73 71 6c  -1.6 {.  execsql
06e0: 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 27 61   {.    SELECT 'a
06f0: 62 63 27 2c 20 7a 65 72 6f 62 6c 6f 62 28 31 29  bc', zeroblob(1)
0700: 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 31 29   FROM (SELECT 1)
0710: 20 4f 52 44 45 52 20 42 59 20 31 0a 20 20 7d 0a   ORDER BY 1.  }.
0720: 7d 20 5b 65 78 65 63 73 71 6c 20 7b 53 45 4c 45  } [execsql {SELE
0730: 43 54 20 27 61 62 63 27 2c 20 7a 65 72 6f 62 6c  CT 'abc', zerobl
0740: 6f 62 28 31 29 7d 5d 0a 0a 64 6f 5f 74 65 73 74  ob(1)}]..do_test
0750: 20 66 75 7a 7a 2d 31 2e 37 20 7b 0a 20 20 65 78   fuzz-1.7 {.  ex
0760: 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45  ecsql {.    SELE
0770: 43 54 20 28 20 53 45 4c 45 43 54 20 7a 65 72 6f  CT ( SELECT zero
0780: 62 6c 6f 62 28 31 30 30 30 29 20 46 52 4f 4d 20  blob(1000) FROM 
0790: 28 20 0a 20 20 20 20 20 20 53 45 4c 45 43 54 20  ( .      SELECT 
07a0: 2a 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 27  * FROM (SELECT '
07b0: 66 69 72 73 74 27 29 20 4f 52 44 45 52 20 42 59  first') ORDER BY
07c0: 20 4e 4f 54 20 27 69 6e 27 29 20 0a 20 20 20 20   NOT 'in') .    
07d0: 29 0a 20 20 7d 0a 7d 20 5b 65 78 65 63 73 71 6c  ).  }.} [execsql
07e0: 20 7b 53 45 4c 45 43 54 20 7a 65 72 6f 62 6c 6f   {SELECT zeroblo
07f0: 62 28 31 30 30 30 29 7d 5d 0a 0a 64 6f 5f 74 65  b(1000)}]..do_te
0800: 73 74 20 66 75 7a 7a 2d 31 2e 38 20 7b 0a 20 20  st fuzz-1.8 {.  
0810: 23 20 50 72 6f 62 6c 65 6d 73 20 77 69 74 68 20  # Problems with 
0820: 6f 70 63 6f 64 65 20 4f 50 5f 54 6f 54 65 78 74  opcode OP_ToText
0830: 20 28 64 69 64 20 6e 6f 74 20 61 63 63 6f 75 6e   (did not accoun
0840: 74 20 66 6f 72 20 4d 45 4d 5f 5a 65 72 6f 29 2e  t for MEM_Zero).
0850: 0a 20 20 23 20 41 6c 73 6f 20 4d 65 6d 45 78 70  .  # Also MemExp
0860: 61 6e 64 42 6c 6f 62 28 29 20 77 61 73 20 6d 61  andBlob() was ma
0870: 72 6b 69 6e 67 20 65 78 70 61 6e 64 65 64 20 62  rking expanded b
0880: 6c 6f 62 73 20 61 73 20 6e 75 6c 2d 74 65 72 6d  lobs as nul-term
0890: 69 6e 61 74 65 64 2e 0a 20 20 23 20 54 68 65 79  inated..  # They
08a0: 20 61 72 65 20 6e 6f 74 2e 0a 20 20 65 78 65 63   are not..  exec
08b0: 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54  sql {.    SELECT
08c0: 20 43 41 53 54 28 7a 65 72 6f 62 6c 6f 62 28 31   CAST(zeroblob(1
08d0: 30 30 30 29 20 41 53 20 74 65 78 74 29 3b 0a 20  000) AS text);. 
08e0: 20 7d 0a 7d 20 7b 7b 7d 7d 0a 0a 64 6f 5f 74 65   }.} {{}}..do_te
08f0: 73 74 20 66 75 7a 7a 2d 31 2e 39 20 7b 0a 20 20  st fuzz-1.9 {.  
0900: 23 20 54 68 69 73 20 77 61 73 20 63 61 75 73 69  # This was causi
0910: 6e 67 20 61 20 4e 55 4c 4c 20 70 6f 69 6e 74 65  ng a NULL pointe
0920: 72 20 64 65 72 65 66 65 72 65 6e 63 65 20 6f 66  r dereference of
0930: 20 45 78 70 72 2e 70 4c 69 73 74 2e 0a 20 20 65   Expr.pList..  e
0940: 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c  xecsql {.    SEL
0950: 45 43 54 20 31 20 46 52 4f 4d 20 28 53 45 4c 45  ECT 1 FROM (SELE
0960: 43 54 20 2a 20 46 52 4f 4d 20 73 71 6c 69 74 65  CT * FROM sqlite
0970: 5f 6d 61 73 74 65 72 20 57 48 45 52 45 20 72 61  _master WHERE ra
0980: 6e 64 6f 6d 28 29 29 0a 20 20 7d 0a 7d 20 7b 7d  ndom()).  }.} {}
0990: 0a 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  ..do_test fuzz-1
09a0: 2e 31 30 20 7b 0a 20 20 23 20 42 75 67 20 69 6e  .10 {.  # Bug in
09b0: 20 63 61 6c 63 75 6c 61 74 69 6f 6e 20 6f 66 20   calculation of 
09c0: 50 61 72 73 65 2e 63 6b 4f 66 66 73 65 74 20 63  Parse.ckOffset c
09d0: 61 75 73 69 6e 67 20 61 6e 20 61 73 73 65 72 74  ausing an assert
09e0: 28 29 20 0a 20 20 23 20 74 6f 20 66 61 69 6c 2e  () .  # to fail.
09f0: 20 50 72 6f 62 61 62 6c 79 20 68 61 72 6d 6c 65   Probably harmle
0a00: 73 73 2e 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a  ss..  execsql {.
0a10: 20 20 20 20 53 45 4c 45 43 54 20 63 6f 61 6c 65      SELECT coale
0a20: 73 63 65 28 31 2c 20 73 75 62 73 74 72 28 20 31  sce(1, substr( 1
0a30: 2c 20 32 2c 20 6c 65 6e 67 74 68 28 27 69 6e 27  , 2, length('in'
0a40: 20 49 4e 20 28 53 45 4c 45 43 54 20 31 29 29 29   IN (SELECT 1)))
0a50: 29 0a 20 20 7d 0a 7d 20 7b 31 7d 0a 0a 64 6f 5f  ).  }.} {1}..do_
0a60: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 31 20 7b  test fuzz-1.11 {
0a70: 0a 20 20 23 20 54 68 65 20 6c 69 74 65 72 61 6c  .  # The literal
0a80: 73 20 28 41 2c 20 42 2c 20 43 2c 20 44 29 20 61  s (A, B, C, D) a
0a90: 72 65 20 6e 6f 74 20 69 6d 70 6f 72 74 61 6e 74  re not important
0aa0: 2c 20 74 68 65 79 20 61 72 65 20 6a 75 73 74 20  , they are just 
0ab0: 75 73 65 64 0a 20 20 23 20 74 6f 20 6d 61 6b 65  used.  # to make
0ac0: 20 74 68 65 20 45 58 50 4c 41 49 4e 20 6f 75 74   the EXPLAIN out
0ad0: 70 75 74 20 65 61 73 69 65 72 20 74 6f 20 72 65  put easier to re
0ae0: 61 64 2e 0a 20 20 23 0a 20 20 23 20 54 68 65 20  ad..  #.  # The 
0af0: 70 72 6f 62 6c 65 6d 20 68 65 72 65 20 69 73 20  problem here is 
0b00: 74 68 61 74 20 74 68 65 20 45 58 49 53 54 53 28  that the EXISTS(
0b10: 2e 2e 2e 29 20 65 78 70 72 65 73 73 69 6f 6e 20  ...) expression 
0b20: 6c 65 61 76 65 73 20 61 6e 0a 20 20 23 20 65 78  leaves an.  # ex
0b30: 74 72 61 20 76 61 6c 75 65 20 6f 6e 20 74 68 65  tra value on the
0b40: 20 56 44 42 45 20 73 74 61 63 6b 2e 20 54 68 69   VDBE stack. Thi
0b50: 73 20 69 73 20 63 6f 6e 66 75 73 69 6e 67 20 74  s is confusing t
0b60: 68 65 20 70 61 72 65 6e 74 20 61 6e 64 0a 20 20  he parent and.  
0b70: 23 20 6c 65 61 64 73 20 74 6f 20 61 6e 20 61 73  # leads to an as
0b80: 73 65 72 74 28 29 20 66 61 69 6c 75 72 65 20 77  sert() failure w
0b90: 68 65 6e 20 4f 50 5f 49 6e 73 65 72 74 20 65 6e  hen OP_Insert en
0ba0: 63 6f 75 6e 74 65 72 73 20 61 6e 20 69 6e 74 65  counters an inte
0bb0: 67 65 72 0a 20 20 23 20 77 68 65 6e 20 69 74 20  ger.  # when it 
0bc0: 65 78 70 65 63 74 73 20 61 20 72 65 63 6f 72 64  expects a record
0bd0: 20 62 6c 6f 62 2e 0a 20 20 23 0a 20 20 23 20 55   blob..  #.  # U
0be0: 70 64 61 74 65 3a 20 41 6e 79 20 71 75 65 72 79  pdate: Any query
0bf0: 20 77 69 74 68 20 28 4c 49 4d 49 54 20 30 29 20   with (LIMIT 0) 
0c00: 77 61 73 20 6c 65 61 6b 69 6e 67 20 73 74 61 63  was leaking stac
0c10: 6b 2e 0a 20 20 23 0a 20 20 65 78 65 63 73 71 6c  k..  #.  execsql
0c20: 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 27 41   {.    SELECT 'A
0c30: 27 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 27  ' FROM (SELECT '
0c40: 42 27 29 20 4f 52 44 45 52 20 42 59 20 45 58 49  B') ORDER BY EXI
0c50: 53 54 53 20 28 0a 20 20 20 20 20 20 53 45 4c 45  STS (.      SELE
0c60: 43 54 20 27 43 27 20 46 52 4f 4d 20 28 53 45 4c  CT 'C' FROM (SEL
0c70: 45 43 54 20 27 44 27 20 4c 49 4d 49 54 20 30 29  ECT 'D' LIMIT 0)
0c80: 0a 20 20 20 20 29 0a 20 20 7d 0a 7d 20 7b 41 7d  .    ).  }.} {A}
0c90: 0a 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  ..do_test fuzz-1
0ca0: 2e 31 32 2e 31 20 7b 0a 20 20 23 20 43 72 65 61  .12.1 {.  # Crea
0cb0: 74 65 20 61 20 74 61 62 6c 65 20 77 69 74 68 20  te a table with 
0cc0: 61 20 73 69 6e 67 6c 65 20 72 6f 77 2e 0a 20 20  a single row..  
0cd0: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 43 52  execsql {.    CR
0ce0: 45 41 54 45 20 54 41 42 4c 45 20 61 62 63 28 62  EATE TABLE abc(b
0cf0: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
0d00: 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 27 41  TO abc VALUES('A
0d10: 42 43 44 45 27 29 3b 0a 20 20 7d 0a 0a 20 20 23  BCDE');.  }..  #
0d20: 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 71   The following q
0d30: 75 65 72 79 20 77 61 73 20 63 72 61 73 68 69 6e  uery was crashin
0d40: 67 2e 20 54 68 65 20 6c 61 74 65 72 20 73 75 62  g. The later sub
0d50: 71 75 65 72 79 20 28 69 6e 20 74 68 65 20 46 52  query (in the FR
0d60: 4f 4d 29 0a 20 20 23 20 63 6c 61 75 73 65 20 77  OM).  # clause w
0d70: 61 73 20 66 6c 61 74 74 65 6e 65 64 20 69 6e 74  as flattened int
0d80: 6f 20 74 68 65 20 70 61 72 65 6e 74 2c 20 62 75  o the parent, bu
0d90: 74 20 74 68 65 20 63 6f 64 65 20 77 61 73 20 6e  t the code was n
0da0: 6f 74 20 72 65 70 61 69 72 6e 67 0a 20 20 23 20  ot repairng.  # 
0db0: 74 68 65 20 22 62 22 20 72 65 66 65 72 65 6e 63  the "b" referenc
0dc0: 65 20 69 6e 20 74 68 65 20 6f 74 68 65 72 20 73  e in the other s
0dd0: 75 62 2d 71 75 65 72 79 2e 20 57 68 65 6e 20 74  ub-query. When t
0de0: 68 65 20 71 75 65 72 79 20 77 61 73 20 65 78 65  he query was exe
0df0: 63 75 74 65 64 2c 0a 20 20 23 20 74 68 61 74 20  cuted,.  # that 
0e00: 22 62 22 20 72 65 66 65 72 65 64 20 74 6f 20 61  "b" refered to a
0e10: 20 6e 6f 6e 2d 65 78 69 73 74 61 6e 74 20 76 64   non-existant vd
0e20: 62 65 20 74 61 62 6c 65 2d 63 75 72 73 6f 72 2e  be table-cursor.
0e30: 0a 20 20 23 0a 20 20 65 78 65 63 73 71 6c 20 7b  .  #.  execsql {
0e40: 0a 20 20 20 20 53 45 4c 45 43 54 20 31 20 49 4e  .    SELECT 1 IN
0e50: 20 28 20 53 45 4c 45 43 54 20 62 20 55 4e 49 4f   ( SELECT b UNIO
0e60: 4e 20 53 45 4c 45 43 54 20 31 20 29 20 46 52 4f  N SELECT 1 ) FRO
0e70: 4d 20 28 53 45 4c 45 43 54 20 62 20 46 52 4f 4d  M (SELECT b FROM
0e80: 20 61 62 63 29 3b 0a 20 20 7d 0a 7d 20 7b 31 7d   abc);.  }.} {1}
0e90: 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e  .do_test fuzz-1.
0ea0: 31 32 2e 32 20 7b 0a 20 20 23 20 43 6c 65 61 6e  12.2 {.  # Clean
0eb0: 20 75 70 20 61 66 74 65 72 20 74 68 65 20 70 72   up after the pr
0ec0: 65 76 69 6f 75 73 20 71 75 65 72 79 2e 0a 20 20  evious query..  
0ed0: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 44 52  execsql {.    DR
0ee0: 4f 50 20 54 41 42 4c 45 20 61 62 63 3b 0a 20 20  OP TABLE abc;.  
0ef0: 7d 0a 7d 20 7b 7d 0a 0a 0a 64 6f 5f 74 65 73 74  }.} {}...do_test
0f00: 20 66 75 7a 7a 2d 31 2e 31 33 20 7b 0a 20 20 23   fuzz-1.13 {.  #
0f10: 20 54 68 65 20 70 72 6f 62 6c 65 6d 20 68 65 72   The problem her
0f20: 65 20 77 61 73 20 74 68 61 74 20 77 68 65 6e 20  e was that when 
0f30: 74 68 65 72 65 20 77 65 72 65 20 6d 6f 72 65 20  there were more 
0f40: 65 78 70 72 65 73 73 69 6f 6e 73 20 69 6e 0a 20  expressions in. 
0f50: 20 23 20 74 68 65 20 4f 52 44 45 52 20 42 59 20   # the ORDER BY 
0f60: 6c 69 73 74 20 74 68 61 6e 20 74 68 65 20 72 65  list than the re
0f70: 73 75 6c 74 2d 73 65 74 20 6c 69 73 74 2e 20 54  sult-set list. T
0f80: 68 65 20 74 65 6d 70 6f 72 61 72 79 20 62 2d 74  he temporary b-t
0f90: 72 65 65 0a 20 20 23 20 75 73 65 64 20 66 6f 72  ree.  # used for
0fa0: 20 73 6f 72 74 69 6e 67 20 77 61 73 20 62 65 69   sorting was bei
0fb0: 6e 67 20 6d 69 73 63 6f 6e 66 69 67 75 72 65 64  ng misconfigured
0fc0: 20 69 6e 20 74 68 69 73 20 63 61 73 65 2e 0a 20   in this case.. 
0fd0: 20 23 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20   #.  execsql {. 
0fe0: 20 20 20 53 45 4c 45 43 54 20 27 61 62 63 64 27     SELECT 'abcd'
0ff0: 20 55 4e 49 4f 4e 20 53 45 4c 45 43 54 20 27 65   UNION SELECT 'e
1000: 66 67 68 27 20 4f 52 44 45 52 20 42 59 20 31 20  fgh' ORDER BY 1 
1010: 41 53 43 2c 20 31 20 41 53 43 3b 0a 20 20 7d 0a  ASC, 1 ASC;.  }.
1020: 7d 20 7b 61 62 63 64 20 65 66 67 68 7d 0a 0a 64  } {abcd efgh}..d
1030: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 34  o_test fuzz-1.14
1040: 2e 31 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b  .1 {.  execsql {
1050: 0a 20 20 20 20 43 52 45 41 54 45 20 54 41 42 4c  .    CREATE TABL
1060: 45 20 61 62 63 28 61 2c 20 62 2c 20 63 29 3b 0a  E abc(a, b, c);.
1070: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1080: 61 62 63 20 56 41 4c 55 45 53 28 31 32 33 2c 20  abc VALUES(123, 
1090: 34 35 36 2c 20 37 38 39 29 3b 0a 20 20 7d 0a 20  456, 789);.  }. 
10a0: 0a 20 20 23 20 54 68 65 20 5b 61 5d 20 72 65 66  .  # The [a] ref
10b0: 65 72 65 6e 63 65 20 69 6e 20 74 68 65 20 73 75  erence in the su
10c0: 62 2d 73 65 6c 65 63 74 20 77 61 73 20 63 61 75  b-select was cau
10d0: 73 69 6e 67 20 61 20 70 72 6f 62 6c 65 6d 2e 20  sing a problem. 
10e0: 42 65 63 61 75 73 65 0a 20 20 23 20 74 68 65 20  Because.  # the 
10f0: 69 6e 74 65 72 6e 61 6c 20 77 61 6c 6b 53 65 6c  internal walkSel
1100: 65 63 74 45 78 70 72 28 29 20 66 75 6e 63 74 69  ectExpr() functi
1110: 6f 6e 20 77 61 73 20 6e 6f 74 20 63 6f 6e 73 69  on was not consi
1120: 64 65 72 69 6e 67 20 63 6f 6d 70 6f 75 6e 64 0a  dering compound.
1130: 20 20 23 20 53 45 4c 45 43 54 20 6f 70 65 72 61    # SELECT opera
1140: 74 6f 72 73 2e 0a 20 20 65 78 65 63 73 71 6c 20  tors..  execsql 
1150: 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 31 20 46  {.    SELECT 1 F
1160: 52 4f 4d 20 61 62 63 0a 20 20 20 20 47 52 4f 55  ROM abc.    GROU
1170: 50 20 42 59 20 63 20 48 41 56 49 4e 47 20 45 58  P BY c HAVING EX
1180: 49 53 54 53 20 28 53 45 4c 45 43 54 20 61 20 55  ISTS (SELECT a U
1190: 4e 49 4f 4e 20 53 45 4c 45 43 54 20 31 32 33 29  NION SELECT 123)
11a0: 3b 0a 20 20 7d 0a 7d 20 7b 31 7d 0a 64 6f 5f 74  ;.  }.} {1}.do_t
11b0: 65 73 74 20 66 75 7a 7a 2d 31 2e 31 34 2e 32 20  est fuzz-1.14.2 
11c0: 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  {.  execsql {.  
11d0: 20 20 44 52 4f 50 20 54 41 42 4c 45 20 61 62 63    DROP TABLE abc
11e0: 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d  ;.  }.} {}..#---
11f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1200: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1210: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1220: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20  -------------.# 
1230: 54 65 73 74 20 73 6f 6d 65 20 66 75 7a 7a 69 6c  Test some fuzzil
1240: 79 20 67 65 6e 65 72 61 74 65 64 20 65 78 70 72  y generated expr
1250: 65 73 73 69 6f 6e 73 2e 0a 23 0a 64 6f 5f 66 75  essions..#.do_fu
1260: 7a 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d 32 20  zzy_test fuzz-2 
1270: 2d 74 65 6d 70 6c 61 74 65 20 20 7b 20 53 45 4c  -template  { SEL
1280: 45 43 54 20 5b 45 78 70 72 5d 20 7d 0a 0a 64 6f  ECT [Expr] }..do
1290: 5f 74 65 73 74 20 66 75 7a 7a 2d 33 2e 31 20 7b  _test fuzz-3.1 {
12a0: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
12b0: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62   CREATE TABLE ab
12c0: 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20  c(a, b, c);.    
12d0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 64 65 66  CREATE TABLE def
12e0: 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 43  (a, b, c);.    C
12f0: 52 45 41 54 45 20 54 41 42 4c 45 20 67 68 69 28  REATE TABLE ghi(
1300: 61 2c 20 62 2c 20 63 29 3b 0a 20 20 7d 0a 7d 20  a, b, c);.  }.} 
1310: 7b 7d 0a 73 65 74 20 3a 3a 54 61 62 6c 65 4c 69  {}.set ::TableLi
1320: 73 74 20 20 5b 6c 69 73 74 20 61 62 63 20 64 65  st  [list abc de
1330: 66 20 67 68 69 5d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  f ghi]..#-------
1340: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1350: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1360: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1370: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74  ---------.# Test
1380: 20 73 6f 6d 65 20 66 75 7a 7a 69 6c 79 20 67 65   some fuzzily ge
1390: 6e 65 72 61 74 65 64 20 53 45 4c 45 43 54 20 73  nerated SELECT s
13a0: 74 61 74 65 6d 65 6e 74 73 2e 0a 23 0a 64 6f 5f  tatements..#.do_
13b0: 66 75 7a 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d  fuzzy_test fuzz-
13c0: 33 2e 32 20 2d 74 65 6d 70 6c 61 74 65 20 20 7b  3.2 -template  {
13d0: 5b 53 65 6c 65 63 74 5d 7d 0a 0a 23 2d 2d 2d 2d  [Select]}..#----
13e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
13f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1400: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1410: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 49  ------------.# I
1420: 6e 73 65 72 74 20 61 20 73 6d 61 6c 6c 20 61 6d  nsert a small am
1430: 6f 75 6e 74 20 6f 66 20 64 61 74 61 20 69 6e 74  ount of data int
1440: 6f 20 74 68 65 20 64 61 74 61 62 61 73 65 20 61  o the database a
1450: 6e 64 20 74 68 65 6e 20 72 75 6e 20 0a 23 20 73  nd then run .# s
1460: 6f 6d 65 20 6d 6f 72 65 20 67 65 6e 65 72 61 74  ome more generat
1470: 65 64 20 53 45 4c 45 43 54 20 73 74 61 74 65 6d  ed SELECT statem
1480: 65 6e 74 73 2e 0a 23 0a 64 6f 5f 74 65 73 74 20  ents..#.do_test 
1490: 66 75 7a 7a 2d 34 2e 31 20 7b 0a 20 20 65 78 65  fuzz-4.1 {.  exe
14a0: 63 73 71 6c 20 7b 0a 20 20 20 20 49 4e 53 45 52  csql {.    INSER
14b0: 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55 45  T INTO abc VALUE
14c0: 53 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20  S(1, 2, 3);.    
14d0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20  INSERT INTO abc 
14e0: 56 41 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b  VALUES(4, 5, 6);
14f0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1500: 20 61 62 63 20 56 41 4c 55 45 53 28 37 2c 20 38   abc VALUES(7, 8
1510: 2c 20 39 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  , 9);.    INSERT
1520: 20 49 4e 54 4f 20 64 65 66 20 56 41 4c 55 45 53   INTO def VALUES
1530: 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20 49  (1, 2, 3);.    I
1540: 4e 53 45 52 54 20 49 4e 54 4f 20 64 65 66 20 56  NSERT INTO def V
1550: 41 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b 0a  ALUES(4, 5, 6);.
1560: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1570: 64 65 66 20 56 41 4c 55 45 53 28 37 2c 20 38 2c  def VALUES(7, 8,
1580: 20 39 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20   9);.    INSERT 
1590: 49 4e 54 4f 20 67 68 69 20 56 41 4c 55 45 53 28  INTO ghi VALUES(
15a0: 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20 49 4e  1, 2, 3);.    IN
15b0: 53 45 52 54 20 49 4e 54 4f 20 67 68 69 20 56 41  SERT INTO ghi VA
15c0: 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b 0a 20  LUES(4, 5, 6);. 
15d0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 67     INSERT INTO g
15e0: 68 69 20 56 41 4c 55 45 53 28 37 2c 20 38 2c 20  hi VALUES(7, 8, 
15f0: 39 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49  9);.    CREATE I
1600: 4e 44 45 58 20 61 62 63 5f 69 20 4f 4e 20 61 62  NDEX abc_i ON ab
1610: 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20  c(a, b, c);.    
1620: 43 52 45 41 54 45 20 49 4e 44 45 58 20 64 65 66  CREATE INDEX def
1630: 5f 69 20 4f 4e 20 64 65 66 28 63 2c 20 61 2c 20  _i ON def(c, a, 
1640: 62 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49  b);.    CREATE I
1650: 4e 44 45 58 20 67 68 69 5f 69 20 4f 4e 20 67 68  NDEX ghi_i ON gh
1660: 69 28 62 2c 20 63 2c 20 61 29 3b 0a 20 20 7d 0a  i(b, c, a);.  }.
1670: 7d 20 7b 7d 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65  } {}.do_fuzzy_te
1680: 73 74 20 66 75 7a 7a 2d 34 2e 32 20 2d 74 65 6d  st fuzz-4.2 -tem
1690: 70 6c 61 74 65 20 7b 5b 53 65 6c 65 63 74 5d 7d  plate {[Select]}
16a0: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
16b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
16e0: 2d 2d 2d 0a 23 20 54 65 73 74 20 73 6f 6d 65 20  ---.# Test some 
16f0: 66 75 7a 7a 79 20 49 4e 53 45 52 54 20 73 74 61  fuzzy INSERT sta
1700: 74 65 6d 65 6e 74 73 3a 0a 23 0a 64 6f 5f 74 65  tements:.#.do_te
1710: 73 74 20 20 20 20 20 20 20 20 20 66 75 7a 7a 2d  st         fuzz-
1720: 35 2e 31 20 7b 65 78 65 63 73 71 6c 20 42 45 47  5.1 {execsql BEG
1730: 49 4e 7d 20 7b 7d 0a 64 6f 5f 66 75 7a 7a 79 5f  IN} {}.do_fuzzy_
1740: 74 65 73 74 20 20 20 66 75 7a 7a 2d 35 2e 32 20  test   fuzz-5.2 
1750: 2d 74 65 6d 70 6c 61 74 65 20 20 7b 5b 49 6e 73  -template  {[Ins
1760: 65 72 74 5d 7d 20 2d 65 72 72 6f 72 6c 69 73 74  ert]} -errorlist
1770: 20 74 61 62 6c 65 0a 69 6e 74 65 67 72 69 74 79   table.integrity
1780: 5f 63 68 65 63 6b 20 66 75 7a 7a 2d 35 2e 32 2e  _check fuzz-5.2.
1790: 69 6e 74 65 67 72 69 74 79 0a 64 6f 5f 74 65 73  integrity.do_tes
17a0: 74 20 20 20 20 20 20 20 20 20 66 75 7a 7a 2d 35  t         fuzz-5
17b0: 2e 33 20 7b 65 78 65 63 73 71 6c 20 43 4f 4d 4d  .3 {execsql COMM
17c0: 49 54 7d 20 7b 7d 0a 69 6e 74 65 67 72 69 74 79  IT} {}.integrity
17d0: 5f 63 68 65 63 6b 20 66 75 7a 7a 2d 35 2e 34 2e  _check fuzz-5.4.
17e0: 69 6e 74 65 67 72 69 74 79 0a 0a 23 2d 2d 2d 2d  integrity..#----
17f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1800: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1810: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1820: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 4e  ------------.# N
1830: 6f 77 20 74 68 61 74 20 74 68 65 72 65 20 69 73  ow that there is
1840: 20 64 61 74 61 20 69 6e 20 74 68 65 20 64 61 74   data in the dat
1850: 61 62 61 73 65 2c 20 72 75 6e 20 73 6f 6d 65 20  abase, run some 
1860: 6d 6f 72 65 20 53 45 4c 45 43 54 20 0a 23 20 73  more SELECT .# s
1870: 74 61 74 65 6d 65 6e 74 73 0a 23 0a 73 65 74 20  tatements.#.set 
1880: 3a 3a 43 6f 6c 75 6d 6e 4c 69 73 74 20 5b 6c 69  ::ColumnList [li
1890: 73 74 20 61 20 62 20 63 5d 0a 73 65 74 20 45 20  st a b c].set E 
18a0: 7b 7b 6e 6f 20 73 75 63 68 20 63 6f 6c 7d 20 7b  {{no such col} {
18b0: 61 6d 62 69 67 75 6f 75 73 20 63 6f 6c 75 6d 6e  ambiguous column
18c0: 20 6e 61 6d 65 7d 7d 0a 64 6f 5f 66 75 7a 7a 79   name}}.do_fuzzy
18d0: 5f 74 65 73 74 20 66 75 7a 7a 2d 36 2e 31 20 2d  _test fuzz-6.1 -
18e0: 74 65 6d 70 6c 61 74 65 20 7b 5b 53 65 6c 65 63  template {[Selec
18f0: 74 5d 7d 20 2d 65 72 72 6f 72 6c 69 73 74 20 24  t]} -errorlist $
1900: 45 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  E..#------------
1910: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1920: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1930: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1940: 2d 2d 2d 2d 0a 23 20 52 75 6e 20 73 6f 6d 65 20  ----.# Run some 
1950: 53 45 4c 45 43 54 73 2c 20 49 4e 53 45 52 54 73  SELECTs, INSERTs
1960: 2c 20 55 50 44 41 54 45 73 20 61 6e 64 20 44 45  , UPDATEs and DE
1970: 4c 45 54 45 73 20 69 6e 20 61 20 74 72 61 6e 73  LETEs in a trans
1980: 61 63 74 69 6f 6e 2e 0a 23 0a 73 65 74 20 45 20  action..#.set E 
1990: 7b 7b 6e 6f 20 73 75 63 68 20 63 6f 6c 7d 20 7b  {{no such col} {
19a0: 61 6d 62 69 67 75 6f 75 73 20 63 6f 6c 75 6d 6e  ambiguous column
19b0: 20 6e 61 6d 65 7d 20 7b 74 61 62 6c 65 7d 7d 0a   name} {table}}.
19c0: 64 6f 5f 74 65 73 74 20 20 20 20 20 20 20 20 20  do_test         
19d0: 66 75 7a 7a 2d 37 2e 31 20 7b 65 78 65 63 73 71  fuzz-7.1 {execsq
19e0: 6c 20 42 45 47 49 4e 7d 20 7b 7d 0a 64 6f 5f 66  l BEGIN} {}.do_f
19f0: 75 7a 7a 79 5f 74 65 73 74 20 20 20 66 75 7a 7a  uzzy_test   fuzz
1a00: 2d 37 2e 32 20 2d 74 65 6d 70 6c 61 74 65 20 7b  -7.2 -template {
1a10: 5b 53 74 61 74 65 6d 65 6e 74 5d 7d 20 2d 65 72  [Statement]} -er
1a20: 72 6f 72 6c 69 73 74 20 24 45 0a 69 6e 74 65 67  rorlist $E.integ
1a30: 72 69 74 79 5f 63 68 65 63 6b 20 66 75 7a 7a 2d  rity_check fuzz-
1a40: 37 2e 33 2e 69 6e 74 65 67 72 69 74 79 0a 64 6f  7.3.integrity.do
1a50: 5f 74 65 73 74 20 20 20 20 20 20 20 20 20 66 75  _test         fu
1a60: 7a 7a 2d 37 2e 34 20 7b 65 78 65 63 73 71 6c 20  zz-7.4 {execsql 
1a70: 43 4f 4d 4d 49 54 7d 20 7b 7d 0a 69 6e 74 65 67  COMMIT} {}.integ
1a80: 72 69 74 79 5f 63 68 65 63 6b 20 66 75 7a 7a 2d  rity_check fuzz-
1a90: 37 2e 35 2e 69 6e 74 65 67 72 69 74 79 0a 0a 23  7.5.integrity..#
1aa0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ab0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ac0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ad0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ae0: 0a 23 20 4d 61 6e 79 20 43 52 45 41 54 45 20 61  .# Many CREATE a
1af0: 6e 64 20 44 52 4f 50 20 54 41 42 4c 45 20 73 74  nd DROP TABLE st
1b00: 61 74 65 6d 65 6e 74 73 3a 0a 23 0a 73 65 74 20  atements:.#.set 
1b10: 45 20 5b 6c 69 73 74 20 74 61 62 6c 65 20 64 75  E [list table du
1b20: 70 6c 69 63 61 74 65 20 7b 6e 6f 20 73 75 63 68  plicate {no such
1b30: 20 63 6f 6c 7d 20 7b 61 6d 62 69 67 75 6f 75 73   col} {ambiguous
1b40: 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 7d 20 7b 75   column name} {u
1b50: 73 65 20 44 52 4f 50 7d 5d 0a 64 6f 5f 66 75 7a  se DROP}].do_fuz
1b60: 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d 38 2e 31  zy_test fuzz-8.1
1b70: 20 2d 74 65 6d 70 6c 61 74 65 20 7b 5b 43 72 65   -template {[Cre
1b80: 61 74 65 4f 72 44 72 6f 70 54 61 62 6c 65 4f 72  ateOrDropTableOr
1b90: 56 69 65 77 5d 7d 20 2d 65 72 72 6f 72 6c 69 73  View]} -errorlis
1ba0: 74 20 24 45 0a 0a 63 6c 6f 73 65 20 24 3a 3a 6c  t $E..close $::l
1bb0: 6f 67 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a     og.finish_test.