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

Artifact 96083052bf5765e4518c1ba686ce2bab785670d1:


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 39 20 32 30 30 39 2f 30 34  t,v 1.19 2009/04
0340: 2f 32 38 20 31 31 3a 31 30 3a 33 39 20 64 61 6e  /28 11:10:39 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 47 28 69 73 71  o exists ::G(isq
0400: 75 69 63 6b 29 5d 7d 20 7b 0a 20 20 69 66 20 7b  uick)]} {.  if {
0410: 24 3a 3a 47 28 69 73 71 75 69 63 6b 29 7d 20 7b  $::G(isquick)} {
0420: 20 73 65 74 20 3a 3a 52 45 50 45 41 54 53 20 32   set ::REPEATS 2
0430: 30 20 7d 0a 7d 0a 0a 73 6f 75 72 63 65 20 24 74  0 }.}..source $t
0440: 65 73 74 64 69 72 2f 66 75 7a 7a 5f 63 6f 6d 6d  estdir/fuzz_comm
0450: 6f 6e 2e 74 63 6c 0a 65 78 70 72 20 73 72 61 6e  on.tcl.expr sran
0460: 64 28 30 29 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  d(0)..#---------
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 0a 23 20 54 68 65 73 65 20  -------.# These 
04b0: 74 65 73 74 73 20 63 61 75 73 65 64 20 65 72 72  tests caused err
04c0: 6f 72 73 20 74 68 61 74 20 77 65 72 65 20 66 69  ors that were fi
04d0: 72 73 74 20 63 61 75 67 68 74 20 62 79 20 74 68  rst caught by th
04e0: 65 20 74 65 73 74 73 0a 23 20 69 6e 20 74 68 69  e tests.# in thi
04f0: 73 20 66 69 6c 65 2e 20 54 68 65 79 20 61 72 65  s file. They are
0500: 20 73 74 69 6c 6c 20 68 65 72 65 2e 0a 64 6f 5f   still here..do_
0510: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 20 7b 0a  test fuzz-1.1 {.
0520: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
0530: 53 45 4c 45 43 54 20 27 61 62 63 27 20 4c 49 4b  SELECT 'abc' LIK
0540: 45 20 58 27 41 42 43 44 27 3b 0a 20 20 7d 0a 7d  E X'ABCD';.  }.}
0550: 20 7b 30 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a   {0}.do_test fuz
0560: 7a 2d 31 2e 32 20 7b 0a 20 20 65 78 65 63 73 71  z-1.2 {.  execsq
0570: 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 27  l {.    SELECT '
0580: 61 62 63 27 20 4c 49 4b 45 20 7a 65 72 6f 62 6c  abc' LIKE zerobl
0590: 6f 62 28 31 30 29 3b 0a 20 20 7d 0a 7d 20 7b 30  ob(10);.  }.} {0
05a0: 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  }.do_test fuzz-1
05b0: 2e 33 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b  .3 {.  execsql {
05c0: 0a 20 20 20 20 53 45 4c 45 43 54 20 7a 65 72 6f  .    SELECT zero
05d0: 62 6c 6f 62 28 31 30 29 20 4c 49 4b 45 20 27 61  blob(10) LIKE 'a
05e0: 62 63 27 3b 0a 20 20 7d 0a 7d 20 7b 30 7d 0a 64  bc';.  }.} {0}.d
05f0: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 34 20  o_test fuzz-1.4 
0600: 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  {.  execsql {.  
0610: 20 20 53 45 4c 45 43 54 20 28 2d 20 2d 32 31 29    SELECT (- -21)
0620: 20 25 20 4e 4f 54 20 28 34 35 36 20 4c 49 4b 45   % NOT (456 LIKE
0630: 20 7a 65 72 6f 62 6c 6f 62 28 31 30 29 29 3b 0a   zeroblob(10));.
0640: 20 20 7d 0a 7d 20 7b 30 7d 0a 64 6f 5f 74 65 73    }.} {0}.do_tes
0650: 74 20 66 75 7a 7a 2d 31 2e 35 20 7b 0a 20 20 65  t fuzz-1.5 {.  e
0660: 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c  xecsql {.    SEL
0670: 45 43 54 20 28 53 45 4c 45 43 54 20 28 0a 20 20  ECT (SELECT (.  
0680: 20 20 20 20 20 20 53 45 4c 45 43 54 20 28 53 45        SELECT (SE
0690: 4c 45 43 54 20 2d 32 31 34 37 34 38 33 36 34 38  LECT -2147483648
06a0: 29 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 31  ) FROM (SELECT 1
06b0: 29 20 4f 52 44 45 52 20 42 59 20 31 0a 20 20 20  ) ORDER BY 1.   
06c0: 20 29 29 0a 20 20 7d 0a 7d 20 7b 2d 32 31 34 37   )).  }.} {-2147
06d0: 34 38 33 36 34 38 7d 0a 64 6f 5f 74 65 73 74 20  483648}.do_test 
06e0: 66 75 7a 7a 2d 31 2e 36 20 7b 0a 20 20 65 78 65  fuzz-1.6 {.  exe
06f0: 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43  csql {.    SELEC
0700: 54 20 27 61 62 63 27 2c 20 7a 65 72 6f 62 6c 6f  T 'abc', zeroblo
0710: 62 28 31 29 20 46 52 4f 4d 20 28 53 45 4c 45 43  b(1) FROM (SELEC
0720: 54 20 31 29 20 4f 52 44 45 52 20 42 59 20 31 0a  T 1) ORDER BY 1.
0730: 20 20 7d 0a 7d 20 5b 65 78 65 63 73 71 6c 20 7b    }.} [execsql {
0740: 53 45 4c 45 43 54 20 27 61 62 63 27 2c 20 7a 65  SELECT 'abc', ze
0750: 72 6f 62 6c 6f 62 28 31 29 7d 5d 0a 0a 64 6f 5f  roblob(1)}]..do_
0760: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 37 20 7b 0a  test fuzz-1.7 {.
0770: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
0780: 53 45 4c 45 43 54 20 28 20 53 45 4c 45 43 54 20  SELECT ( SELECT 
0790: 7a 65 72 6f 62 6c 6f 62 28 31 30 30 30 29 20 46  zeroblob(1000) F
07a0: 52 4f 4d 20 28 20 0a 20 20 20 20 20 20 53 45 4c  ROM ( .      SEL
07b0: 45 43 54 20 2a 20 46 52 4f 4d 20 28 53 45 4c 45  ECT * FROM (SELE
07c0: 43 54 20 27 66 69 72 73 74 27 29 20 4f 52 44 45  CT 'first') ORDE
07d0: 52 20 42 59 20 4e 4f 54 20 27 69 6e 27 29 20 0a  R BY NOT 'in') .
07e0: 20 20 20 20 29 0a 20 20 7d 0a 7d 20 5b 65 78 65      ).  }.} [exe
07f0: 63 73 71 6c 20 7b 53 45 4c 45 43 54 20 7a 65 72  csql {SELECT zer
0800: 6f 62 6c 6f 62 28 31 30 30 30 29 7d 5d 0a 0a 64  oblob(1000)}]..d
0810: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 38 20  o_test fuzz-1.8 
0820: 7b 0a 20 20 23 20 50 72 6f 62 6c 65 6d 73 20 77  {.  # Problems w
0830: 69 74 68 20 6f 70 63 6f 64 65 20 4f 50 5f 54 6f  ith opcode OP_To
0840: 54 65 78 74 20 28 64 69 64 20 6e 6f 74 20 61 63  Text (did not ac
0850: 63 6f 75 6e 74 20 66 6f 72 20 4d 45 4d 5f 5a 65  count for MEM_Ze
0860: 72 6f 29 2e 0a 20 20 23 20 41 6c 73 6f 20 4d 65  ro)..  # Also Me
0870: 6d 45 78 70 61 6e 64 42 6c 6f 62 28 29 20 77 61  mExpandBlob() wa
0880: 73 20 6d 61 72 6b 69 6e 67 20 65 78 70 61 6e 64  s marking expand
0890: 65 64 20 62 6c 6f 62 73 20 61 73 20 6e 75 6c 2d  ed blobs as nul-
08a0: 74 65 72 6d 69 6e 61 74 65 64 2e 0a 20 20 23 20  terminated..  # 
08b0: 54 68 65 79 20 61 72 65 20 6e 6f 74 2e 0a 20 20  They are not..  
08c0: 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20 53 45  execsql {.    SE
08d0: 4c 45 43 54 20 43 41 53 54 28 7a 65 72 6f 62 6c  LECT CAST(zerobl
08e0: 6f 62 28 31 30 30 30 29 20 41 53 20 74 65 78 74  ob(1000) AS text
08f0: 29 3b 0a 20 20 7d 0a 7d 20 7b 7b 7d 7d 0a 0a 64  );.  }.} {{}}..d
0900: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 39 20  o_test fuzz-1.9 
0910: 7b 0a 20 20 23 20 54 68 69 73 20 77 61 73 20 63  {.  # This was c
0920: 61 75 73 69 6e 67 20 61 20 4e 55 4c 4c 20 70 6f  ausing a NULL po
0930: 69 6e 74 65 72 20 64 65 72 65 66 65 72 65 6e 63  inter dereferenc
0940: 65 20 6f 66 20 45 78 70 72 2e 70 4c 69 73 74 2e  e of Expr.pList.
0950: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
0960: 20 53 45 4c 45 43 54 20 31 20 46 52 4f 4d 20 28   SELECT 1 FROM (
0970: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 73 71  SELECT * FROM sq
0980: 6c 69 74 65 5f 6d 61 73 74 65 72 20 57 48 45 52  lite_master WHER
0990: 45 20 72 61 6e 64 6f 6d 28 29 29 0a 20 20 7d 0a  E random()).  }.
09a0: 7d 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 66 75  } {}..do_test fu
09b0: 7a 7a 2d 31 2e 31 30 20 7b 0a 20 20 23 20 42 75  zz-1.10 {.  # Bu
09c0: 67 20 69 6e 20 63 61 6c 63 75 6c 61 74 69 6f 6e  g in calculation
09d0: 20 6f 66 20 50 61 72 73 65 2e 63 6b 4f 66 66 73   of Parse.ckOffs
09e0: 65 74 20 63 61 75 73 69 6e 67 20 61 6e 20 61 73  et causing an as
09f0: 73 65 72 74 28 29 20 0a 20 20 23 20 74 6f 20 66  sert() .  # to f
0a00: 61 69 6c 2e 20 50 72 6f 62 61 62 6c 79 20 68 61  ail. Probably ha
0a10: 72 6d 6c 65 73 73 2e 0a 20 20 65 78 65 63 73 71  rmless..  execsq
0a20: 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 63  l {.    SELECT c
0a30: 6f 61 6c 65 73 63 65 28 31 2c 20 73 75 62 73 74  oalesce(1, subst
0a40: 72 28 20 31 2c 20 32 2c 20 6c 65 6e 67 74 68 28  r( 1, 2, length(
0a50: 27 69 6e 27 20 49 4e 20 28 53 45 4c 45 43 54 20  'in' IN (SELECT 
0a60: 31 29 29 29 29 0a 20 20 7d 0a 7d 20 7b 31 7d 0a  1)))).  }.} {1}.
0a70: 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e  .do_test fuzz-1.
0a80: 31 31 20 7b 0a 20 20 23 20 54 68 65 20 6c 69 74  11 {.  # The lit
0a90: 65 72 61 6c 73 20 28 41 2c 20 42 2c 20 43 2c 20  erals (A, B, C, 
0aa0: 44 29 20 61 72 65 20 6e 6f 74 20 69 6d 70 6f 72  D) are not impor
0ab0: 74 61 6e 74 2c 20 74 68 65 79 20 61 72 65 20 6a  tant, they are j
0ac0: 75 73 74 20 75 73 65 64 0a 20 20 23 20 74 6f 20  ust used.  # to 
0ad0: 6d 61 6b 65 20 74 68 65 20 45 58 50 4c 41 49 4e  make the EXPLAIN
0ae0: 20 6f 75 74 70 75 74 20 65 61 73 69 65 72 20 74   output easier t
0af0: 6f 20 72 65 61 64 2e 0a 20 20 23 0a 20 20 23 20  o read..  #.  # 
0b00: 54 68 65 20 70 72 6f 62 6c 65 6d 20 68 65 72 65  The problem here
0b10: 20 69 73 20 74 68 61 74 20 74 68 65 20 45 58 49   is that the EXI
0b20: 53 54 53 28 2e 2e 2e 29 20 65 78 70 72 65 73 73  STS(...) express
0b30: 69 6f 6e 20 6c 65 61 76 65 73 20 61 6e 0a 20 20  ion leaves an.  
0b40: 23 20 65 78 74 72 61 20 76 61 6c 75 65 20 6f 6e  # extra value on
0b50: 20 74 68 65 20 56 44 42 45 20 73 74 61 63 6b 2e   the VDBE stack.
0b60: 20 54 68 69 73 20 69 73 20 63 6f 6e 66 75 73 69   This is confusi
0b70: 6e 67 20 74 68 65 20 70 61 72 65 6e 74 20 61 6e  ng the parent an
0b80: 64 0a 20 20 23 20 6c 65 61 64 73 20 74 6f 20 61  d.  # leads to a
0b90: 6e 20 61 73 73 65 72 74 28 29 20 66 61 69 6c 75  n assert() failu
0ba0: 72 65 20 77 68 65 6e 20 4f 50 5f 49 6e 73 65 72  re when OP_Inser
0bb0: 74 20 65 6e 63 6f 75 6e 74 65 72 73 20 61 6e 20  t encounters an 
0bc0: 69 6e 74 65 67 65 72 0a 20 20 23 20 77 68 65 6e  integer.  # when
0bd0: 20 69 74 20 65 78 70 65 63 74 73 20 61 20 72 65   it expects a re
0be0: 63 6f 72 64 20 62 6c 6f 62 2e 0a 20 20 23 0a 20  cord blob..  #. 
0bf0: 20 23 20 55 70 64 61 74 65 3a 20 41 6e 79 20 71   # Update: Any q
0c00: 75 65 72 79 20 77 69 74 68 20 28 4c 49 4d 49 54  uery with (LIMIT
0c10: 20 30 29 20 77 61 73 20 6c 65 61 6b 69 6e 67 20   0) was leaking 
0c20: 73 74 61 63 6b 2e 0a 20 20 23 0a 20 20 65 78 65  stack..  #.  exe
0c30: 63 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43  csql {.    SELEC
0c40: 54 20 27 41 27 20 46 52 4f 4d 20 28 53 45 4c 45  T 'A' FROM (SELE
0c50: 43 54 20 27 42 27 29 20 4f 52 44 45 52 20 42 59  CT 'B') ORDER BY
0c60: 20 45 58 49 53 54 53 20 28 0a 20 20 20 20 20 20   EXISTS (.      
0c70: 53 45 4c 45 43 54 20 27 43 27 20 46 52 4f 4d 20  SELECT 'C' FROM 
0c80: 28 53 45 4c 45 43 54 20 27 44 27 20 4c 49 4d 49  (SELECT 'D' LIMI
0c90: 54 20 30 29 0a 20 20 20 20 29 0a 20 20 7d 0a 7d  T 0).    ).  }.}
0ca0: 20 7b 41 7d 0a 0a 64 6f 5f 74 65 73 74 20 66 75   {A}..do_test fu
0cb0: 7a 7a 2d 31 2e 31 32 2e 31 20 7b 0a 20 20 23 20  zz-1.12.1 {.  # 
0cc0: 43 72 65 61 74 65 20 61 20 74 61 62 6c 65 20 77  Create a table w
0cd0: 69 74 68 20 61 20 73 69 6e 67 6c 65 20 72 6f 77  ith a single row
0ce0: 2e 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  ..  execsql {.  
0cf0: 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61    CREATE TABLE a
0d00: 62 63 28 62 29 3b 0a 20 20 20 20 49 4e 53 45 52  bc(b);.    INSER
0d10: 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55 45  T INTO abc VALUE
0d20: 53 28 27 41 42 43 44 45 27 29 3b 0a 20 20 7d 0a  S('ABCDE');.  }.
0d30: 0a 20 20 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69  .  # The followi
0d40: 6e 67 20 71 75 65 72 79 20 77 61 73 20 63 72 61  ng query was cra
0d50: 73 68 69 6e 67 2e 20 54 68 65 20 6c 61 74 65 72  shing. The later
0d60: 20 73 75 62 71 75 65 72 79 20 28 69 6e 20 74 68   subquery (in th
0d70: 65 20 46 52 4f 4d 29 0a 20 20 23 20 63 6c 61 75  e FROM).  # clau
0d80: 73 65 20 77 61 73 20 66 6c 61 74 74 65 6e 65 64  se was flattened
0d90: 20 69 6e 74 6f 20 74 68 65 20 70 61 72 65 6e 74   into the parent
0da0: 2c 20 62 75 74 20 74 68 65 20 63 6f 64 65 20 77  , but the code w
0db0: 61 73 20 6e 6f 74 20 72 65 70 61 69 72 6e 67 0a  as not repairng.
0dc0: 20 20 23 20 74 68 65 20 22 62 22 20 72 65 66 65    # the "b" refe
0dd0: 72 65 6e 63 65 20 69 6e 20 74 68 65 20 6f 74 68  rence in the oth
0de0: 65 72 20 73 75 62 2d 71 75 65 72 79 2e 20 57 68  er sub-query. Wh
0df0: 65 6e 20 74 68 65 20 71 75 65 72 79 20 77 61 73  en the query was
0e00: 20 65 78 65 63 75 74 65 64 2c 0a 20 20 23 20 74   executed,.  # t
0e10: 68 61 74 20 22 62 22 20 72 65 66 65 72 65 64 20  hat "b" refered 
0e20: 74 6f 20 61 20 6e 6f 6e 2d 65 78 69 73 74 61 6e  to a non-existan
0e30: 74 20 76 64 62 65 20 74 61 62 6c 65 2d 63 75 72  t vdbe table-cur
0e40: 73 6f 72 2e 0a 20 20 23 0a 20 20 65 78 65 63 73  sor..  #.  execs
0e50: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
0e60: 31 20 49 4e 20 28 20 53 45 4c 45 43 54 20 62 20  1 IN ( SELECT b 
0e70: 55 4e 49 4f 4e 20 53 45 4c 45 43 54 20 31 20 29  UNION SELECT 1 )
0e80: 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 62 20   FROM (SELECT b 
0e90: 46 52 4f 4d 20 61 62 63 29 3b 0a 20 20 7d 0a 7d  FROM abc);.  }.}
0ea0: 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a   {1}.do_test fuz
0eb0: 7a 2d 31 2e 31 32 2e 32 20 7b 0a 20 20 23 20 43  z-1.12.2 {.  # C
0ec0: 6c 65 61 6e 20 75 70 20 61 66 74 65 72 20 74 68  lean up after th
0ed0: 65 20 70 72 65 76 69 6f 75 73 20 71 75 65 72 79  e previous query
0ee0: 2e 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  ..  execsql {.  
0ef0: 20 20 44 52 4f 50 20 54 41 42 4c 45 20 61 62 63    DROP TABLE abc
0f00: 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a 0a 64 6f 5f  ;.  }.} {}...do_
0f10: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 33 20 7b  test fuzz-1.13 {
0f20: 0a 20 20 23 20 54 68 65 20 70 72 6f 62 6c 65 6d  .  # The problem
0f30: 20 68 65 72 65 20 77 61 73 20 74 68 61 74 20 77   here was that w
0f40: 68 65 6e 20 74 68 65 72 65 20 77 65 72 65 20 6d  hen there were m
0f50: 6f 72 65 20 65 78 70 72 65 73 73 69 6f 6e 73 20  ore expressions 
0f60: 69 6e 0a 20 20 23 20 74 68 65 20 4f 52 44 45 52  in.  # the ORDER
0f70: 20 42 59 20 6c 69 73 74 20 74 68 61 6e 20 74 68   BY list than th
0f80: 65 20 72 65 73 75 6c 74 2d 73 65 74 20 6c 69 73  e result-set lis
0f90: 74 2e 20 54 68 65 20 74 65 6d 70 6f 72 61 72 79  t. The temporary
0fa0: 20 62 2d 74 72 65 65 0a 20 20 23 20 75 73 65 64   b-tree.  # used
0fb0: 20 66 6f 72 20 73 6f 72 74 69 6e 67 20 77 61 73   for sorting was
0fc0: 20 62 65 69 6e 67 20 6d 69 73 63 6f 6e 66 69 67   being misconfig
0fd0: 75 72 65 64 20 69 6e 20 74 68 69 73 20 63 61 73  ured in this cas
0fe0: 65 2e 0a 20 20 23 0a 20 20 65 78 65 63 73 71 6c  e..  #.  execsql
0ff0: 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 27 61   {.    SELECT 'a
1000: 62 63 64 27 20 55 4e 49 4f 4e 20 53 45 4c 45 43  bcd' UNION SELEC
1010: 54 20 27 65 66 67 68 27 20 4f 52 44 45 52 20 42  T 'efgh' ORDER B
1020: 59 20 31 20 41 53 43 2c 20 31 20 41 53 43 3b 0a  Y 1 ASC, 1 ASC;.
1030: 20 20 7d 0a 7d 20 7b 61 62 63 64 20 65 66 67 68    }.} {abcd efgh
1040: 7d 0a 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d  }..do_test fuzz-
1050: 31 2e 31 34 2e 31 20 7b 0a 20 20 65 78 65 63 73  1.14.1 {.  execs
1060: 71 6c 20 7b 0a 20 20 20 20 43 52 45 41 54 45 20  ql {.    CREATE 
1070: 54 41 42 4c 45 20 61 62 63 28 61 2c 20 62 2c 20  TABLE abc(a, b, 
1080: 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  c);.    INSERT I
1090: 4e 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 31  NTO abc VALUES(1
10a0: 32 33 2c 20 34 35 36 2c 20 37 38 39 29 3b 0a 20  23, 456, 789);. 
10b0: 20 7d 0a 20 0a 20 20 23 20 54 68 65 20 5b 61 5d   }. .  # The [a]
10c0: 20 72 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68   reference in th
10d0: 65 20 73 75 62 2d 73 65 6c 65 63 74 20 77 61 73  e sub-select was
10e0: 20 63 61 75 73 69 6e 67 20 61 20 70 72 6f 62 6c   causing a probl
10f0: 65 6d 2e 20 42 65 63 61 75 73 65 0a 20 20 23 20  em. Because.  # 
1100: 74 68 65 20 69 6e 74 65 72 6e 61 6c 20 77 61 6c  the internal wal
1110: 6b 53 65 6c 65 63 74 45 78 70 72 28 29 20 66 75  kSelectExpr() fu
1120: 6e 63 74 69 6f 6e 20 77 61 73 20 6e 6f 74 20 63  nction was not c
1130: 6f 6e 73 69 64 65 72 69 6e 67 20 63 6f 6d 70 6f  onsidering compo
1140: 75 6e 64 0a 20 20 23 20 53 45 4c 45 43 54 20 6f  und.  # SELECT o
1150: 70 65 72 61 74 6f 72 73 2e 0a 20 20 65 78 65 63  perators..  exec
1160: 73 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54  sql {.    SELECT
1170: 20 31 20 46 52 4f 4d 20 61 62 63 0a 20 20 20 20   1 FROM abc.    
1180: 47 52 4f 55 50 20 42 59 20 63 20 48 41 56 49 4e  GROUP BY c HAVIN
1190: 47 20 45 58 49 53 54 53 20 28 53 45 4c 45 43 54  G EXISTS (SELECT
11a0: 20 61 20 55 4e 49 4f 4e 20 53 45 4c 45 43 54 20   a UNION SELECT 
11b0: 31 32 33 29 3b 0a 20 20 7d 0a 7d 20 7b 31 7d 0a  123);.  }.} {1}.
11c0: 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31  do_test fuzz-1.1
11d0: 34 2e 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20  4.2 {.  execsql 
11e0: 7b 0a 20 20 20 20 44 52 4f 50 20 54 41 42 4c 45  {.    DROP TABLE
11f0: 20 61 62 63 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 0a   abc;.  }.} {}..
1200: 23 20 4d 61 6b 69 6e 67 20 73 75 72 65 20 70 72  # Making sure pr
1210: 65 76 69 6f 75 73 6c 79 20 64 69 73 63 6f 76 65  eviously discove
1220: 72 65 64 20 65 72 72 6f 72 73 20 68 61 76 65 20  red errors have 
1230: 62 65 65 6e 20 66 69 78 65 64 2e 0a 23 0a 64 6f  been fixed..#.do
1240: 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 35 20  _test fuzz-1.15 
1250: 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  {.  execsql {.  
1260: 20 20 53 45 4c 45 43 54 20 68 65 78 28 43 41 53    SELECT hex(CAS
1270: 54 28 7a 65 72 6f 62 6c 6f 62 28 31 30 30 30 29  T(zeroblob(1000)
1280: 20 41 53 20 69 6e 74 65 67 65 72 29 29 0a 20 20   AS integer)).  
1290: 7d 0a 7d 20 7b 33 30 7d 0a 0a 64 6f 5f 74 65 73  }.} {30}..do_tes
12a0: 74 20 66 75 7a 7a 2d 31 2e 31 36 2e 31 20 7b 0a  t fuzz-1.16.1 {.
12b0: 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20 20    execsql {.    
12c0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62 63  CREATE TABLE abc
12d0: 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 43  (a, b, c);.    C
12e0: 52 45 41 54 45 20 54 41 42 4c 45 20 64 65 66 28  REATE TABLE def(
12f0: 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 43 52  a, b, c);.    CR
1300: 45 41 54 45 20 54 41 42 4c 45 20 67 68 69 28 61  EATE TABLE ghi(a
1310: 2c 20 62 2c 20 63 29 3b 0a 20 20 7d 0a 7d 20 7b  , b, c);.  }.} {
1320: 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  }.do_test fuzz-1
1330: 2e 31 36 2e 32 20 7b 0a 20 20 63 61 74 63 68 73  .16.2 {.  catchs
1340: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
1350: 44 49 53 54 49 4e 43 54 20 45 58 49 53 54 53 28  DISTINCT EXISTS(
1360: 0a 20 20 20 20 20 20 20 53 45 4c 45 43 54 20 31  .       SELECT 1
1370: 0a 20 20 20 20 20 20 20 46 52 4f 4d 20 28 0a 20  .       FROM (. 
1380: 20 20 20 20 20 20 20 20 53 45 4c 45 43 54 20 43          SELECT C
1390: 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 31 29   FROM (SELECT 1)
13a0: 0a 20 20 20 20 20 20 20 29 0a 20 20 20 20 20 20  .       ).      
13b0: 20 57 48 45 52 45 20 28 53 45 4c 45 43 54 20 63   WHERE (SELECT c
13c0: 29 0a 20 20 20 20 29 0a 20 20 20 20 46 52 4f 4d  ).    ).    FROM
13d0: 20 61 62 63 0a 20 20 7d 0a 7d 20 7b 30 20 7b 7d   abc.  }.} {0 {}
13e0: 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  }.do_test fuzz-1
13f0: 2e 31 36 2e 33 20 7b 0a 20 20 63 61 74 63 68 73  .16.3 {.  catchs
1400: 71 6c 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20  ql {.    SELECT 
1410: 44 49 53 54 49 4e 43 54 20 73 75 62 73 74 72 28  DISTINCT substr(
1420: 2d 34 35 36 20 49 53 4e 55 4c 4c 2c 7a 65 72 6f  -456 ISNULL,zero
1430: 62 6c 6f 62 28 31 30 30 30 29 2c 20 45 58 49 53  blob(1000), EXIS
1440: 54 53 28 0a 20 20 20 20 20 20 20 20 20 53 45 4c  TS(.         SEL
1450: 45 43 54 20 44 49 53 54 49 4e 43 54 20 45 58 49  ECT DISTINCT EXI
1460: 53 54 53 28 0a 20 20 20 20 20 20 20 20 20 20 20  STS(.           
1470: 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 20  SELECT DISTINCT 
1480: 62 20 46 52 4f 4d 20 61 62 63 0a 20 20 20 20 20  b FROM abc.     
1490: 20 20 20 20 20 20 4f 52 44 45 52 20 42 59 20 45        ORDER BY E
14a0: 58 49 53 54 53 20 28 0a 20 20 20 20 20 20 20 20  XISTS (.        
14b0: 20 20 20 20 20 53 45 4c 45 43 54 20 44 49 53 54       SELECT DIST
14c0: 49 4e 43 54 20 32 31 34 37 34 38 33 36 34 37 20  INCT 2147483647 
14d0: 55 4e 49 4f 4e 20 41 4c 4c 20 53 45 4c 45 43 54  UNION ALL SELECT
14e0: 20 2d 32 31 34 37 34 38 33 36 34 38 0a 20 20 20   -2147483648.   
14f0: 20 20 20 20 20 20 20 20 29 20 41 53 43 0a 20 20          ) ASC.  
1500: 20 20 20 20 20 20 20 29 0a 20 20 20 20 20 20 20         ).       
1510: 20 20 46 52 4f 4d 20 28 0a 20 20 20 20 20 20 20    FROM (.       
1520: 20 20 20 20 53 45 4c 45 43 54 20 63 2c 20 63 20      SELECT c, c 
1530: 46 52 4f 4d 20 28 0a 20 20 20 20 20 20 20 20 20  FROM (.         
1540: 20 20 20 20 53 45 4c 45 43 54 20 34 35 36 2c 20      SELECT 456, 
1550: 27 69 6e 6a 65 63 74 69 6f 6e 27 20 4f 52 44 45  'injection' ORDE
1560: 52 20 42 59 20 35 36 2e 31 20 41 53 43 2c 20 2d  R BY 56.1 ASC, -
1570: 35 36 2e 31 20 44 45 53 43 0a 20 20 20 20 20 20  56.1 DESC.      
1580: 20 20 20 20 20 29 0a 20 20 20 20 20 20 20 20 20       ).         
1590: 29 0a 20 20 20 20 20 20 20 20 20 47 52 4f 55 50  ).         GROUP
15a0: 20 42 59 20 28 53 45 4c 45 43 54 20 41 4c 4c 20   BY (SELECT ALL 
15b0: 28 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54  (SELECT DISTINCT
15c0: 20 27 68 61 72 64 77 61 72 65 27 29 29 20 0a 20   'hardware')) . 
15d0: 20 20 20 20 20 20 20 20 48 41 56 49 4e 47 20 28          HAVING (
15e0: 0a 20 20 20 20 20 20 20 20 20 20 20 53 45 4c 45  .           SELE
15f0: 43 54 20 44 49 53 54 49 4e 43 54 20 63 0a 20 20  CT DISTINCT c.  
1600: 20 20 20 20 20 20 20 20 20 46 52 4f 4d 20 28 0a           FROM (.
1610: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45 4c               SEL
1620: 45 43 54 20 41 4c 4c 20 2d 32 31 34 37 34 38 33  ECT ALL -2147483
1630: 36 34 38 2c 20 27 65 78 70 65 72 69 6d 65 6e 74  648, 'experiment
1640: 73 27 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  s'.             
1650: 4f 52 44 45 52 20 42 59 20 2d 35 36 2e 31 20 41  ORDER BY -56.1 A
1660: 53 43 2c 20 2d 35 36 2e 31 20 44 45 53 43 0a 20  SC, -56.1 DESC. 
1670: 20 20 20 20 20 20 20 20 20 20 29 0a 20 20 20 20            ).    
1680: 20 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 20         GROUP BY 
1690: 28 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54  (SELECT DISTINCT
16a0: 20 34 35 36 29 20 49 4e 20 0a 20 20 20 20 20 20   456) IN .      
16b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 53 45               (SE
16c0: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 20 27 69  LECT DISTINCT 'i
16d0: 6e 6a 65 63 74 69 6f 6e 27 29 20 4e 4f 54 20 49  njection') NOT I
16e0: 4e 20 28 53 45 4c 45 43 54 20 41 4c 4c 20 2d 34  N (SELECT ALL -4
16f0: 35 36 29 0a 20 20 20 20 20 20 20 20 20 20 20 48  56).           H
1700: 41 56 49 4e 47 20 45 58 49 53 54 53 20 28 0a 20  AVING EXISTS (. 
1710: 20 20 20 20 20 20 20 20 20 20 20 20 53 45 4c 45              SELE
1720: 43 54 20 41 4c 4c 20 27 69 6e 6a 65 63 74 69 6f  CT ALL 'injectio
1730: 6e 27 0a 20 20 20 20 20 20 20 20 20 20 20 29 0a  n'.           ).
1740: 20 20 20 20 20 20 20 20 20 29 0a 20 20 20 20 20           ).     
1750: 20 20 20 20 55 4e 49 4f 4e 20 41 4c 4c 0a 20 20      UNION ALL.  
1760: 20 20 20 20 20 20 20 53 45 4c 45 43 54 20 61 20         SELECT a 
1770: 49 4e 20 28 0a 20 20 20 20 20 20 20 20 20 20 20  IN (.           
1780: 53 45 4c 45 43 54 20 2d 32 31 34 37 34 38 33 36  SELECT -21474836
1790: 34 37 0a 20 20 20 20 20 20 20 20 20 20 20 55 4e  47.           UN
17a0: 49 4f 4e 20 41 4c 4c 0a 20 20 20 20 20 20 20 20  ION ALL.        
17b0: 20 20 20 53 45 4c 45 43 54 20 41 4c 4c 20 27 69     SELECT ALL 'i
17c0: 6e 6a 65 63 74 69 6f 6e 27 0a 20 20 20 20 20 20  njection'.      
17d0: 20 20 20 29 0a 20 20 20 20 20 20 20 20 20 46 52     ).         FR
17e0: 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72  OM sqlite_master
17f0: 0a 20 20 20 20 20 20 20 29 20 2d 2d 20 65 6e 64  .       ) -- end
1800: 20 45 58 49 53 54 53 0a 20 20 20 20 29 20 2f 2a   EXISTS.    ) /*
1810: 20 65 6e 64 20 53 55 42 53 54 52 28 29 20 2a 2f   end SUBSTR() */
1820: 2c 20 63 20 4e 4f 54 4e 55 4c 4c 20 49 53 4e 55  , c NOTNULL ISNU
1830: 4c 4c 0a 20 20 20 20 46 52 4f 4d 20 61 62 63 0a  LL.    FROM abc.
1840: 20 20 20 20 4f 52 44 45 52 20 42 59 20 43 41 53      ORDER BY CAS
1850: 54 28 2d 35 36 2e 31 20 41 53 20 62 6c 6f 62 29  T(-56.1 AS blob)
1860: 20 41 53 43 0a 20 20 7d 0a 7d 20 7b 30 20 7b 7d   ASC.  }.} {0 {}
1870: 7d 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  }.do_test fuzz-1
1880: 2e 31 36 2e 34 20 7b 0a 20 20 65 78 65 63 73 71  .16.4 {.  execsq
1890: 6c 20 7b 0a 20 20 20 20 44 52 4f 50 20 54 41 42  l {.    DROP TAB
18a0: 4c 45 20 61 62 63 3b 20 44 52 4f 50 20 54 41 42  LE abc; DROP TAB
18b0: 4c 45 20 64 65 66 3b 20 44 52 4f 50 20 54 41 42  LE def; DROP TAB
18c0: 4c 45 20 67 68 69 3b 0a 20 20 7d 0a 7d 20 7b 7d  LE ghi;.  }.} {}
18d0: 0a 0a 64 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31  ..do_test fuzz-1
18e0: 2e 31 37 20 7b 0a 20 20 63 61 74 63 68 73 71 6c  .17 {.  catchsql
18f0: 20 7b 0a 20 20 20 20 53 45 4c 45 43 54 20 27 68   {.    SELECT 'h
1900: 61 72 64 77 61 72 65 27 2c 20 35 36 2e 31 20 4e  ardware', 56.1 N
1910: 4f 54 4e 55 4c 4c 2c 20 72 61 6e 64 6f 6d 28 29  OTNULL, random()
1920: 26 30 0a 20 20 20 20 46 52 4f 4d 20 28 0a 20 20  &0.    FROM (.  
1930: 20 20 20 20 20 53 45 4c 45 43 54 20 41 4c 4c 20       SELECT ALL 
1940: 6c 6f 77 65 72 28 7e 20 45 58 49 53 54 53 20 28  lower(~ EXISTS (
1950: 0a 20 20 20 20 20 20 20 20 20 20 20 53 45 4c 45  .           SELE
1960: 43 54 20 31 20 4e 4f 54 20 49 4e 20 28 53 45 4c  CT 1 NOT IN (SEL
1970: 45 43 54 20 41 4c 4c 20 31 29 0a 20 20 20 20 20  ECT ALL 1).     
1980: 20 20 29 29 2c 20 43 41 53 54 28 34 35 36 20 41    )), CAST(456 A
1990: 53 20 69 6e 74 65 67 65 72 29 2c 20 2d 32 31 34  S integer), -214
19a0: 37 34 38 33 36 34 37 0a 20 20 20 20 20 20 20 46  7483647.       F
19b0: 52 4f 4d 20 28 0a 20 20 20 20 20 20 20 20 20 53  ROM (.         S
19c0: 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 20 2d  ELECT DISTINCT -
19d0: 34 35 36 2c 20 43 41 53 54 28 31 20 41 53 20 69  456, CAST(1 AS i
19e0: 6e 74 65 67 65 72 29 20 49 53 4e 55 4c 4c 0a 20  nteger) ISNULL. 
19f0: 20 20 20 20 20 20 20 20 46 52 4f 4d 20 28 53 45          FROM (SE
1a00: 4c 45 43 54 20 41 4c 4c 20 32 31 34 37 34 38 33  LECT ALL 2147483
1a10: 36 34 37 2c 20 74 79 70 65 6f 66 28 32 31 34 37  647, typeof(2147
1a20: 34 38 33 36 34 39 29 29 0a 20 20 20 20 20 20 20  483649)).       
1a30: 29 0a 20 20 20 20 29 0a 20 20 20 20 47 52 4f 55  ).    ).    GROU
1a40: 50 20 42 59 20 43 41 53 54 28 43 41 53 54 28 27  P BY CAST(CAST('
1a50: 65 78 70 65 72 69 6d 65 6e 74 73 27 20 41 53 20  experiments' AS 
1a60: 62 6c 6f 62 29 20 41 53 20 62 6c 6f 62 29 0a 20  blob) AS blob). 
1a70: 20 20 20 48 41 56 49 4e 47 20 72 61 6e 64 6f 6d     HAVING random
1a80: 28 29 0a 20 20 7d 0a 7d 20 7b 30 20 7b 68 61 72  ().  }.} {0 {har
1a90: 64 77 61 72 65 20 31 20 30 7d 7d 0a 0a 64 6f 5f  dware 1 0}}..do_
1aa0: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 38 20 7b  test fuzz-1.18 {
1ab0: 0a 20 20 63 61 74 63 68 73 71 6c 20 7b 0a 20 20  .  catchsql {.  
1ac0: 20 20 20 53 45 4c 45 43 54 20 2d 32 31 34 37 34     SELECT -21474
1ad0: 38 33 36 34 39 20 3c 3c 20 75 70 70 65 72 28 27  83649 << upper('
1ae0: 66 61 75 6c 74 27 20 4e 4f 54 20 49 4e 20 28 0a  fault' NOT IN (.
1af0: 20 20 20 20 20 20 20 20 53 45 4c 45 43 54 20 41          SELECT A
1b00: 4c 4c 20 28 0a 20 20 20 20 20 20 20 20 20 20 20  LL (.           
1b10: 53 45 4c 45 43 54 20 41 4c 4c 20 2d 31 0a 20 20  SELECT ALL -1.  
1b20: 20 20 20 20 20 20 20 20 20 4f 52 44 45 52 20 42           ORDER B
1b30: 59 20 2d 32 31 34 37 34 38 33 36 34 39 0a 20 20  Y -2147483649.  
1b40: 20 20 20 20 20 20 20 20 20 4c 49 4d 49 54 20 28           LIMIT (
1b50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 53  .              S
1b60: 45 4c 45 43 54 20 41 4c 4c 20 28 0a 20 20 20 20  ELECT ALL (.    
1b70: 20 20 20 20 20 20 20 20 20 20 20 20 20 53 45 4c               SEL
1b80: 45 43 54 20 30 20 45 58 43 45 50 54 20 53 45 4c  ECT 0 EXCEPT SEL
1b90: 45 43 54 20 44 49 53 54 49 4e 43 54 20 27 65 78  ECT DISTINCT 'ex
1ba0: 70 65 72 69 6d 65 6e 74 73 27 20 4f 52 44 45 52  periments' ORDER
1bb0: 20 42 59 20 31 20 41 53 43 0a 20 20 20 20 20 20   BY 1 ASC.      
1bc0: 20 20 20 20 20 20 20 20 29 0a 20 20 20 20 20 20          ).      
1bd0: 20 20 20 20 20 29 0a 20 20 20 20 20 20 20 20 20       ).         
1be0: 20 20 4f 46 46 53 45 54 20 45 58 49 53 54 53 20    OFFSET EXISTS 
1bf0: 28 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  (.              
1c00: 53 45 4c 45 43 54 20 41 4c 4c 20 0a 20 20 20 20  SELECT ALL .    
1c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 53                (S
1c20: 45 4c 45 43 54 20 41 4c 4c 20 2d 32 31 34 37 34  ELECT ALL -21474
1c30: 38 33 36 34 38 29 20 4e 4f 54 20 49 4e 20 28 0a  83648) NOT IN (.
1c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1c50: 20 20 20 20 20 53 45 4c 45 43 54 20 41 4c 4c 20       SELECT ALL 
1c60: 31 32 33 34 35 36 37 38 39 2e 31 32 33 34 35 36  123456789.123456
1c70: 37 38 39 39 0a 20 20 20 20 20 20 20 20 20 20 20  7899.           
1c80: 20 20 20 20 20 20 20 29 20 49 4e 20 28 53 45 4c         ) IN (SEL
1c90: 45 43 54 20 32 31 34 37 34 38 33 36 34 39 29 20  ECT 2147483649) 
1ca0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46  .              F
1cb0: 52 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65  ROM sqlite_maste
1cc0: 72 0a 20 20 20 20 20 20 20 20 20 20 20 29 20 4e  r.           ) N
1cd0: 4f 54 20 49 4e 20 28 53 45 4c 45 43 54 20 41 4c  OT IN (SELECT AL
1ce0: 4c 20 27 54 68 65 27 29 0a 20 20 20 20 20 20 20  L 'The').       
1cf0: 20 29 0a 20 20 20 20 20 29 29 0a 20 20 7d 0a 7d   ).     )).  }.}
1d00: 20 7b 30 20 7b 7b 7d 7d 7d 0a 0a 23 20 41 74 20   {0 {{}}}..# At 
1d10: 6f 6e 65 20 70 6f 69 6e 74 20 74 68 65 20 66 6f  one point the fo
1d20: 6c 6c 6f 77 69 6e 67 20 49 4e 53 45 52 54 20 73  llowing INSERT s
1d30: 74 61 74 65 6d 65 6e 74 20 63 61 75 73 65 64 20  tatement caused 
1d40: 61 6e 20 61 73 73 65 72 74 28 29 20 74 6f 20 66  an assert() to f
1d50: 61 69 6c 2e 0a 23 20 0a 64 6f 5f 74 65 73 74 20  ail..# .do_test 
1d60: 66 75 7a 7a 2d 31 2e 31 39 20 7b 0a 20 20 65 78  fuzz-1.19 {.  ex
1d70: 65 63 73 71 6c 20 7b 20 43 52 45 41 54 45 20 54  ecsql { CREATE T
1d80: 41 42 4c 45 20 74 31 28 61 29 20 7d 0a 20 20 63  ABLE t1(a) }.  c
1d90: 61 74 63 68 73 71 6c 20 7b 0a 20 20 20 20 49 4e  atchsql {.    IN
1da0: 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c  SERT INTO t1 VAL
1db0: 55 45 53 28 20 0a 20 20 20 20 20 20 43 41 53 45  UES( .      CASE
1dc0: 20 57 48 45 4e 20 4e 55 4c 4c 20 54 48 45 4e 20   WHEN NULL THEN 
1dd0: 4e 55 4c 4c 20 45 4c 53 45 20 28 20 53 45 4c 45  NULL ELSE ( SELE
1de0: 43 54 20 30 20 4f 52 44 45 52 20 42 59 20 34 35  CT 0 ORDER BY 45
1df0: 36 20 29 20 45 4e 44 20 0a 20 20 20 20 29 0a 20  6 ) END .    ). 
1e00: 20 7d 0a 7d 20 7b 31 20 7b 31 73 74 20 4f 52 44   }.} {1 {1st ORD
1e10: 45 52 20 42 59 20 74 65 72 6d 20 6f 75 74 20 6f  ER BY term out o
1e20: 66 20 72 61 6e 67 65 20 2d 20 73 68 6f 75 6c 64  f range - should
1e30: 20 62 65 20 62 65 74 77 65 65 6e 20 31 20 61 6e   be between 1 an
1e40: 64 20 31 7d 7d 0a 64 6f 5f 74 65 73 74 20 66 75  d 1}}.do_test fu
1e50: 7a 7a 2d 31 2e 32 30 20 7b 0a 20 20 65 78 65 63  zz-1.20 {.  exec
1e60: 73 71 6c 20 7b 20 44 52 4f 50 20 54 41 42 4c 45  sql { DROP TABLE
1e70: 20 74 31 20 7d 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d   t1 }.} {}..#---
1e80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1e90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20  -------------.# 
1ec0: 54 65 73 74 20 73 6f 6d 65 20 66 75 7a 7a 69 6c  Test some fuzzil
1ed0: 79 20 67 65 6e 65 72 61 74 65 64 20 65 78 70 72  y generated expr
1ee0: 65 73 73 69 6f 6e 73 2e 0a 23 0a 64 6f 5f 66 75  essions..#.do_fu
1ef0: 7a 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d 32 20  zzy_test fuzz-2 
1f00: 2d 74 65 6d 70 6c 61 74 65 20 20 7b 20 53 45 4c  -template  { SEL
1f10: 45 43 54 20 5b 45 78 70 72 5d 20 7d 0a 0a 64 6f  ECT [Expr] }..do
1f20: 5f 74 65 73 74 20 66 75 7a 7a 2d 33 2e 31 20 7b  _test fuzz-3.1 {
1f30: 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20 20  .  execsql {.   
1f40: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 61 62   CREATE TABLE ab
1f50: 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20  c(a, b, c);.    
1f60: 43 52 45 41 54 45 20 54 41 42 4c 45 20 64 65 66  CREATE TABLE def
1f70: 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20 43  (a, b, c);.    C
1f80: 52 45 41 54 45 20 54 41 42 4c 45 20 67 68 69 28  REATE TABLE ghi(
1f90: 61 2c 20 62 2c 20 63 29 3b 0a 20 20 7d 0a 7d 20  a, b, c);.  }.} 
1fa0: 7b 7d 0a 73 65 74 20 3a 3a 54 61 62 6c 65 4c 69  {}.set ::TableLi
1fb0: 73 74 20 20 5b 6c 69 73 74 20 61 62 63 20 64 65  st  [list abc de
1fc0: 66 20 67 68 69 5d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  f ghi]..#-------
1fd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1fe0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ff0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2000: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74  ---------.# Test
2010: 20 73 6f 6d 65 20 66 75 7a 7a 69 6c 79 20 67 65   some fuzzily ge
2020: 6e 65 72 61 74 65 64 20 53 45 4c 45 43 54 20 73  nerated SELECT s
2030: 74 61 74 65 6d 65 6e 74 73 2e 0a 23 0a 64 6f 5f  tatements..#.do_
2040: 66 75 7a 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d  fuzzy_test fuzz-
2050: 33 2e 32 20 2d 74 65 6d 70 6c 61 74 65 20 20 7b  3.2 -template  {
2060: 5b 53 65 6c 65 63 74 5d 7d 0a 0a 23 2d 2d 2d 2d  [Select]}..#----
2070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2080: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2090: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
20a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 49  ------------.# I
20b0: 6e 73 65 72 74 20 61 20 73 6d 61 6c 6c 20 61 6d  nsert a small am
20c0: 6f 75 6e 74 20 6f 66 20 64 61 74 61 20 69 6e 74  ount of data int
20d0: 6f 20 74 68 65 20 64 61 74 61 62 61 73 65 20 61  o the database a
20e0: 6e 64 20 74 68 65 6e 20 72 75 6e 20 0a 23 20 73  nd then run .# s
20f0: 6f 6d 65 20 6d 6f 72 65 20 67 65 6e 65 72 61 74  ome more generat
2100: 65 64 20 53 45 4c 45 43 54 20 73 74 61 74 65 6d  ed SELECT statem
2110: 65 6e 74 73 2e 0a 23 0a 64 6f 5f 74 65 73 74 20  ents..#.do_test 
2120: 66 75 7a 7a 2d 34 2e 31 20 7b 0a 20 20 65 78 65  fuzz-4.1 {.  exe
2130: 63 73 71 6c 20 7b 0a 20 20 20 20 49 4e 53 45 52  csql {.    INSER
2140: 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55 45  T INTO abc VALUE
2150: 53 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20  S(1, 2, 3);.    
2160: 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62 63 20  INSERT INTO abc 
2170: 56 41 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b  VALUES(4, 5, 6);
2180: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2190: 20 61 62 63 20 56 41 4c 55 45 53 28 37 2c 20 38   abc VALUES(7, 8
21a0: 2c 20 39 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  , 9);.    INSERT
21b0: 20 49 4e 54 4f 20 64 65 66 20 56 41 4c 55 45 53   INTO def VALUES
21c0: 28 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20 49  (1, 2, 3);.    I
21d0: 4e 53 45 52 54 20 49 4e 54 4f 20 64 65 66 20 56  NSERT INTO def V
21e0: 41 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b 0a  ALUES(4, 5, 6);.
21f0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
2200: 64 65 66 20 56 41 4c 55 45 53 28 37 2c 20 38 2c  def VALUES(7, 8,
2210: 20 39 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20   9);.    INSERT 
2220: 49 4e 54 4f 20 67 68 69 20 56 41 4c 55 45 53 28  INTO ghi VALUES(
2230: 31 2c 20 32 2c 20 33 29 3b 0a 20 20 20 20 49 4e  1, 2, 3);.    IN
2240: 53 45 52 54 20 49 4e 54 4f 20 67 68 69 20 56 41  SERT INTO ghi VA
2250: 4c 55 45 53 28 34 2c 20 35 2c 20 36 29 3b 0a 20  LUES(4, 5, 6);. 
2260: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 67     INSERT INTO g
2270: 68 69 20 56 41 4c 55 45 53 28 37 2c 20 38 2c 20  hi VALUES(7, 8, 
2280: 39 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49  9);.    CREATE I
2290: 4e 44 45 58 20 61 62 63 5f 69 20 4f 4e 20 61 62  NDEX abc_i ON ab
22a0: 63 28 61 2c 20 62 2c 20 63 29 3b 0a 20 20 20 20  c(a, b, c);.    
22b0: 43 52 45 41 54 45 20 49 4e 44 45 58 20 64 65 66  CREATE INDEX def
22c0: 5f 69 20 4f 4e 20 64 65 66 28 63 2c 20 61 2c 20  _i ON def(c, a, 
22d0: 62 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49  b);.    CREATE I
22e0: 4e 44 45 58 20 67 68 69 5f 69 20 4f 4e 20 67 68  NDEX ghi_i ON gh
22f0: 69 28 62 2c 20 63 2c 20 61 29 3b 0a 20 20 7d 0a  i(b, c, a);.  }.
2300: 7d 20 7b 7d 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65  } {}.do_fuzzy_te
2310: 73 74 20 66 75 7a 7a 2d 34 2e 32 20 2d 74 65 6d  st fuzz-4.2 -tem
2320: 70 6c 61 74 65 20 7b 5b 53 65 6c 65 63 74 5d 7d  plate {[Select]}
2330: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
2340: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2350: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2360: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2370: 2d 2d 2d 0a 23 20 54 65 73 74 20 73 6f 6d 65 20  ---.# Test some 
2380: 66 75 7a 7a 79 20 49 4e 53 45 52 54 20 73 74 61  fuzzy INSERT sta
2390: 74 65 6d 65 6e 74 73 3a 0a 23 0a 64 6f 5f 74 65  tements:.#.do_te
23a0: 73 74 20 20 20 20 20 20 20 20 20 66 75 7a 7a 2d  st         fuzz-
23b0: 35 2e 31 20 7b 65 78 65 63 73 71 6c 20 42 45 47  5.1 {execsql BEG
23c0: 49 4e 7d 20 7b 7d 0a 64 6f 5f 66 75 7a 7a 79 5f  IN} {}.do_fuzzy_
23d0: 74 65 73 74 20 20 20 66 75 7a 7a 2d 35 2e 32 20  test   fuzz-5.2 
23e0: 2d 74 65 6d 70 6c 61 74 65 20 20 7b 5b 49 6e 73  -template  {[Ins
23f0: 65 72 74 5d 7d 20 2d 65 72 72 6f 72 6c 69 73 74  ert]} -errorlist
2400: 20 74 61 62 6c 65 0a 69 6e 74 65 67 72 69 74 79   table.integrity
2410: 5f 63 68 65 63 6b 20 66 75 7a 7a 2d 35 2e 32 2e  _check fuzz-5.2.
2420: 69 6e 74 65 67 72 69 74 79 0a 64 6f 5f 74 65 73  integrity.do_tes
2430: 74 20 20 20 20 20 20 20 20 20 66 75 7a 7a 2d 35  t         fuzz-5
2440: 2e 33 20 7b 65 78 65 63 73 71 6c 20 43 4f 4d 4d  .3 {execsql COMM
2450: 49 54 7d 20 7b 7d 0a 69 6e 74 65 67 72 69 74 79  IT} {}.integrity
2460: 5f 63 68 65 63 6b 20 66 75 7a 7a 2d 35 2e 34 2e  _check fuzz-5.4.
2470: 69 6e 74 65 67 72 69 74 79 0a 0a 23 2d 2d 2d 2d  integrity..#----
2480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
24a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
24b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 4e  ------------.# N
24c0: 6f 77 20 74 68 61 74 20 74 68 65 72 65 20 69 73  ow that there is
24d0: 20 64 61 74 61 20 69 6e 20 74 68 65 20 64 61 74   data in the dat
24e0: 61 62 61 73 65 2c 20 72 75 6e 20 73 6f 6d 65 20  abase, run some 
24f0: 6d 6f 72 65 20 53 45 4c 45 43 54 20 0a 23 20 73  more SELECT .# s
2500: 74 61 74 65 6d 65 6e 74 73 0a 23 0a 73 65 74 20  tatements.#.set 
2510: 3a 3a 43 6f 6c 75 6d 6e 4c 69 73 74 20 5b 6c 69  ::ColumnList [li
2520: 73 74 20 61 20 62 20 63 5d 0a 73 65 74 20 45 20  st a b c].set E 
2530: 7b 7b 6e 6f 20 73 75 63 68 20 63 6f 6c 7d 20 7b  {{no such col} {
2540: 61 6d 62 69 67 75 6f 75 73 20 63 6f 6c 75 6d 6e  ambiguous column
2550: 20 6e 61 6d 65 7d 7d 0a 64 6f 5f 66 75 7a 7a 79   name}}.do_fuzzy
2560: 5f 74 65 73 74 20 66 75 7a 7a 2d 36 2e 31 20 2d  _test fuzz-6.1 -
2570: 74 65 6d 70 6c 61 74 65 20 7b 5b 53 65 6c 65 63  template {[Selec
2580: 74 5d 7d 20 2d 65 72 72 6f 72 6c 69 73 74 20 24  t]} -errorlist $
2590: 45 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  E..#------------
25a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
25b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
25c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
25d0: 2d 2d 2d 2d 0a 23 20 52 75 6e 20 73 6f 6d 65 20  ----.# Run some 
25e0: 53 45 4c 45 43 54 73 2c 20 49 4e 53 45 52 54 73  SELECTs, INSERTs
25f0: 2c 20 55 50 44 41 54 45 73 20 61 6e 64 20 44 45  , UPDATEs and DE
2600: 4c 45 54 45 73 20 69 6e 20 61 20 74 72 61 6e 73  LETEs in a trans
2610: 61 63 74 69 6f 6e 2e 0a 23 0a 73 65 74 20 45 20  action..#.set E 
2620: 7b 7b 6e 6f 20 73 75 63 68 20 63 6f 6c 7d 20 7b  {{no such col} {
2630: 61 6d 62 69 67 75 6f 75 73 20 63 6f 6c 75 6d 6e  ambiguous column
2640: 20 6e 61 6d 65 7d 20 7b 74 61 62 6c 65 7d 7d 0a   name} {table}}.
2650: 64 6f 5f 74 65 73 74 20 20 20 20 20 20 20 20 20  do_test         
2660: 66 75 7a 7a 2d 37 2e 31 20 7b 65 78 65 63 73 71  fuzz-7.1 {execsq
2670: 6c 20 42 45 47 49 4e 7d 20 7b 7d 0a 64 6f 5f 66  l BEGIN} {}.do_f
2680: 75 7a 7a 79 5f 74 65 73 74 20 20 20 66 75 7a 7a  uzzy_test   fuzz
2690: 2d 37 2e 32 20 2d 74 65 6d 70 6c 61 74 65 20 7b  -7.2 -template {
26a0: 5b 53 74 61 74 65 6d 65 6e 74 5d 7d 20 2d 65 72  [Statement]} -er
26b0: 72 6f 72 6c 69 73 74 20 24 45 0a 69 6e 74 65 67  rorlist $E.integ
26c0: 72 69 74 79 5f 63 68 65 63 6b 20 66 75 7a 7a 2d  rity_check fuzz-
26d0: 37 2e 33 2e 69 6e 74 65 67 72 69 74 79 0a 64 6f  7.3.integrity.do
26e0: 5f 74 65 73 74 20 20 20 20 20 20 20 20 20 66 75  _test         fu
26f0: 7a 7a 2d 37 2e 34 20 7b 65 78 65 63 73 71 6c 20  zz-7.4 {execsql 
2700: 43 4f 4d 4d 49 54 7d 20 7b 7d 0a 69 6e 74 65 67  COMMIT} {}.integ
2710: 72 69 74 79 5f 63 68 65 63 6b 20 66 75 7a 7a 2d  rity_check fuzz-
2720: 37 2e 35 2e 69 6e 74 65 67 72 69 74 79 0a 0a 23  7.5.integrity..#
2730: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2740: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2750: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2760: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2770: 0a 23 20 4d 61 6e 79 20 43 52 45 41 54 45 20 61  .# Many CREATE a
2780: 6e 64 20 44 52 4f 50 20 54 41 42 4c 45 20 73 74  nd DROP TABLE st
2790: 61 74 65 6d 65 6e 74 73 3a 0a 23 0a 73 65 74 20  atements:.#.set 
27a0: 45 20 5b 6c 69 73 74 20 74 61 62 6c 65 20 64 75  E [list table du
27b0: 70 6c 69 63 61 74 65 20 7b 6e 6f 20 73 75 63 68  plicate {no such
27c0: 20 63 6f 6c 7d 20 7b 61 6d 62 69 67 75 6f 75 73   col} {ambiguous
27d0: 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 7d 20 7b 75   column name} {u
27e0: 73 65 20 44 52 4f 50 7d 5d 0a 64 6f 5f 66 75 7a  se DROP}].do_fuz
27f0: 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d 38 2e 31  zy_test fuzz-8.1
2800: 20 2d 74 65 6d 70 6c 61 74 65 20 7b 5b 43 72 65   -template {[Cre
2810: 61 74 65 4f 72 44 72 6f 70 54 61 62 6c 65 4f 72  ateOrDropTableOr
2820: 56 69 65 77 5d 7d 20 2d 65 72 72 6f 72 6c 69 73  View]} -errorlis
2830: 74 20 24 45 0a 0a 63 6c 6f 73 65 20 24 3a 3a 6c  t $E..close $::l
2840: 6f 67 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a     og.finish_test.