/ Hex Artifact Content
Login

Artifact 77fd50afc12847af50fcf1941679d90adebadde6:


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 2d 34 32 39 34 39 36 37 32 39 38 7d   {0 -4294967298}
1d10: 0a 0a 23 20 41 74 20 6f 6e 65 20 70 6f 69 6e 74  ..# At one point
1d20: 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 49   the following I
1d30: 4e 53 45 52 54 20 73 74 61 74 65 6d 65 6e 74 20  NSERT statement 
1d40: 63 61 75 73 65 64 20 61 6e 20 61 73 73 65 72 74  caused an assert
1d50: 28 29 20 74 6f 20 66 61 69 6c 2e 0a 23 20 0a 64  () to fail..# .d
1d60: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 31 2e 31 39  o_test fuzz-1.19
1d70: 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 20 43   {.  execsql { C
1d80: 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
1d90: 29 20 7d 0a 20 20 63 61 74 63 68 73 71 6c 20 7b  ) }.  catchsql {
1da0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1db0: 20 74 31 20 56 41 4c 55 45 53 28 20 0a 20 20 20   t1 VALUES( .   
1dc0: 20 20 20 43 41 53 45 20 57 48 45 4e 20 4e 55 4c     CASE WHEN NUL
1dd0: 4c 20 54 48 45 4e 20 4e 55 4c 4c 20 45 4c 53 45  L THEN NULL ELSE
1de0: 20 28 20 53 45 4c 45 43 54 20 30 20 4f 52 44 45   ( SELECT 0 ORDE
1df0: 52 20 42 59 20 34 35 36 20 29 20 45 4e 44 20 0a  R BY 456 ) END .
1e00: 20 20 20 20 29 0a 20 20 7d 0a 7d 20 7b 31 20 7b      ).  }.} {1 {
1e10: 31 73 74 20 4f 52 44 45 52 20 42 59 20 74 65 72  1st ORDER BY ter
1e20: 6d 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 20 2d  m out of range -
1e30: 20 73 68 6f 75 6c 64 20 62 65 20 62 65 74 77 65   should be betwe
1e40: 65 6e 20 31 20 61 6e 64 20 31 7d 7d 0a 64 6f 5f  en 1 and 1}}.do_
1e50: 74 65 73 74 20 66 75 7a 7a 2d 31 2e 32 30 20 7b  test fuzz-1.20 {
1e60: 0a 20 20 65 78 65 63 73 71 6c 20 7b 20 44 52 4f  .  execsql { DRO
1e70: 50 20 54 41 42 4c 45 20 74 31 20 7d 0a 7d 20 7b  P TABLE t1 }.} {
1e80: 7d 0a 0a 23 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 2d 2d 2d  ----------------
1ec0: 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 73 6f 6d 65  ----.# Test some
1ed0: 20 66 75 7a 7a 69 6c 79 20 67 65 6e 65 72 61 74   fuzzily generat
1ee0: 65 64 20 65 78 70 72 65 73 73 69 6f 6e 73 2e 0a  ed expressions..
1ef0: 23 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65 73 74 20  #.do_fuzzy_test 
1f00: 66 75 7a 7a 2d 32 20 2d 74 65 6d 70 6c 61 74 65  fuzz-2 -template
1f10: 20 20 7b 20 53 45 4c 45 43 54 20 5b 45 78 70 72    { SELECT [Expr
1f20: 5d 20 7d 0a 0a 64 6f 5f 74 65 73 74 20 66 75 7a  ] }..do_test fuz
1f30: 7a 2d 33 2e 31 20 7b 0a 20 20 65 78 65 63 73 71  z-3.1 {.  execsq
1f40: 6c 20 7b 0a 20 20 20 20 43 52 45 41 54 45 20 54  l {.    CREATE T
1f50: 41 42 4c 45 20 61 62 63 28 61 2c 20 62 2c 20 63  ABLE abc(a, b, c
1f60: 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54 41  );.    CREATE TA
1f70: 42 4c 45 20 64 65 66 28 61 2c 20 62 2c 20 63 29  BLE def(a, b, c)
1f80: 3b 0a 20 20 20 20 43 52 45 41 54 45 20 54 41 42  ;.    CREATE TAB
1f90: 4c 45 20 67 68 69 28 61 2c 20 62 2c 20 63 29 3b  LE ghi(a, b, c);
1fa0: 0a 20 20 7d 0a 7d 20 7b 7d 0a 73 65 74 20 3a 3a  .  }.} {}.set ::
1fb0: 54 61 62 6c 65 4c 69 73 74 20 20 5b 6c 69 73 74  TableList  [list
1fc0: 20 61 62 63 20 64 65 66 20 67 68 69 5d 0a 0a 23   abc def 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 2d 2d 2d 2d 2d 2d 2d  ----------------
2010: 0a 23 20 54 65 73 74 20 73 6f 6d 65 20 66 75 7a  .# Test some fuz
2020: 7a 69 6c 79 20 67 65 6e 65 72 61 74 65 64 20 53  zily generated S
2030: 45 4c 45 43 54 20 73 74 61 74 65 6d 65 6e 74 73  ELECT statements
2040: 2e 0a 23 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65 73  ..#.do_fuzzy_tes
2050: 74 20 66 75 7a 7a 2d 33 2e 32 20 2d 74 65 6d 70  t fuzz-3.2 -temp
2060: 6c 61 74 65 20 20 7b 5b 53 65 6c 65 63 74 5d 7d  late  {[Select]}
2070: 0a 0a 23 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 2d 2d 2d 2d  ----------------
20b0: 2d 2d 2d 0a 23 20 49 6e 73 65 72 74 20 61 20 73  ---.# Insert a s
20c0: 6d 61 6c 6c 20 61 6d 6f 75 6e 74 20 6f 66 20 64  mall amount of d
20d0: 61 74 61 20 69 6e 74 6f 20 74 68 65 20 64 61 74  ata into the dat
20e0: 61 62 61 73 65 20 61 6e 64 20 74 68 65 6e 20 72  abase and then r
20f0: 75 6e 20 0a 23 20 73 6f 6d 65 20 6d 6f 72 65 20  un .# some more 
2100: 67 65 6e 65 72 61 74 65 64 20 53 45 4c 45 43 54  generated SELECT
2110: 20 73 74 61 74 65 6d 65 6e 74 73 2e 0a 23 0a 64   statements..#.d
2120: 6f 5f 74 65 73 74 20 66 75 7a 7a 2d 34 2e 31 20  o_test fuzz-4.1 
2130: 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b 0a 20 20  {.  execsql {.  
2140: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 61 62    INSERT INTO ab
2150: 63 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 33  c VALUES(1, 2, 3
2160: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
2170: 54 4f 20 61 62 63 20 56 41 4c 55 45 53 28 34 2c  TO abc VALUES(4,
2180: 20 35 2c 20 36 29 3b 0a 20 20 20 20 49 4e 53 45   5, 6);.    INSE
2190: 52 54 20 49 4e 54 4f 20 61 62 63 20 56 41 4c 55  RT INTO abc VALU
21a0: 45 53 28 37 2c 20 38 2c 20 39 29 3b 0a 20 20 20  ES(7, 8, 9);.   
21b0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 64 65 66   INSERT INTO def
21c0: 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 33 29   VALUES(1, 2, 3)
21d0: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
21e0: 4f 20 64 65 66 20 56 41 4c 55 45 53 28 34 2c 20  O def VALUES(4, 
21f0: 35 2c 20 36 29 3b 0a 20 20 20 20 49 4e 53 45 52  5, 6);.    INSER
2200: 54 20 49 4e 54 4f 20 64 65 66 20 56 41 4c 55 45  T INTO def VALUE
2210: 53 28 37 2c 20 38 2c 20 39 29 3b 0a 20 20 20 20  S(7, 8, 9);.    
2220: 49 4e 53 45 52 54 20 49 4e 54 4f 20 67 68 69 20  INSERT INTO ghi 
2230: 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 33 29 3b  VALUES(1, 2, 3);
2240: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2250: 20 67 68 69 20 56 41 4c 55 45 53 28 34 2c 20 35   ghi VALUES(4, 5
2260: 2c 20 36 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  , 6);.    INSERT
2270: 20 49 4e 54 4f 20 67 68 69 20 56 41 4c 55 45 53   INTO ghi VALUES
2280: 28 37 2c 20 38 2c 20 39 29 3b 0a 20 20 20 20 43  (7, 8, 9);.    C
2290: 52 45 41 54 45 20 49 4e 44 45 58 20 61 62 63 5f  REATE INDEX abc_
22a0: 69 20 4f 4e 20 61 62 63 28 61 2c 20 62 2c 20 63  i ON abc(a, b, c
22b0: 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49 4e  );.    CREATE IN
22c0: 44 45 58 20 64 65 66 5f 69 20 4f 4e 20 64 65 66  DEX def_i ON def
22d0: 28 63 2c 20 61 2c 20 62 29 3b 0a 20 20 20 20 43  (c, a, b);.    C
22e0: 52 45 41 54 45 20 49 4e 44 45 58 20 67 68 69 5f  REATE INDEX ghi_
22f0: 69 20 4f 4e 20 67 68 69 28 62 2c 20 63 2c 20 61  i ON ghi(b, c, a
2300: 29 3b 0a 20 20 7d 0a 7d 20 7b 7d 0a 64 6f 5f 66  );.  }.} {}.do_f
2310: 75 7a 7a 79 5f 74 65 73 74 20 66 75 7a 7a 2d 34  uzzy_test fuzz-4
2320: 2e 32 20 2d 74 65 6d 70 6c 61 74 65 20 7b 5b 53  .2 -template {[S
2330: 65 6c 65 63 74 5d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  elect]}..#------
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 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73  ----------.# Tes
2380: 74 20 73 6f 6d 65 20 66 75 7a 7a 79 20 49 4e 53  t some fuzzy INS
2390: 45 52 54 20 73 74 61 74 65 6d 65 6e 74 73 3a 0a  ERT statements:.
23a0: 23 0a 64 6f 5f 74 65 73 74 20 20 20 20 20 20 20  #.do_test       
23b0: 20 20 66 75 7a 7a 2d 35 2e 31 20 7b 65 78 65 63    fuzz-5.1 {exec
23c0: 73 71 6c 20 42 45 47 49 4e 7d 20 7b 7d 0a 64 6f  sql BEGIN} {}.do
23d0: 5f 66 75 7a 7a 79 5f 74 65 73 74 20 20 20 66 75  _fuzzy_test   fu
23e0: 7a 7a 2d 35 2e 32 20 2d 74 65 6d 70 6c 61 74 65  zz-5.2 -template
23f0: 20 20 7b 5b 49 6e 73 65 72 74 5d 7d 20 2d 65 72    {[Insert]} -er
2400: 72 6f 72 6c 69 73 74 20 74 61 62 6c 65 0a 69 6e  rorlist table.in
2410: 74 65 67 72 69 74 79 5f 63 68 65 63 6b 20 66 75  tegrity_check fu
2420: 7a 7a 2d 35 2e 32 2e 69 6e 74 65 67 72 69 74 79  zz-5.2.integrity
2430: 0a 64 6f 5f 74 65 73 74 20 20 20 20 20 20 20 20  .do_test        
2440: 20 66 75 7a 7a 2d 35 2e 33 20 7b 65 78 65 63 73   fuzz-5.3 {execs
2450: 71 6c 20 43 4f 4d 4d 49 54 7d 20 7b 7d 0a 69 6e  ql COMMIT} {}.in
2460: 74 65 67 72 69 74 79 5f 63 68 65 63 6b 20 66 75  tegrity_check fu
2470: 7a 7a 2d 35 2e 34 2e 69 6e 74 65 67 72 69 74 79  zz-5.4.integrity
2480: 0a 0a 23 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 2d 2d 2d 2d  ----------------
24c0: 2d 2d 2d 0a 23 20 4e 6f 77 20 74 68 61 74 20 74  ---.# Now that t
24d0: 68 65 72 65 20 69 73 20 64 61 74 61 20 69 6e 20  here is data in 
24e0: 74 68 65 20 64 61 74 61 62 61 73 65 2c 20 72 75  the database, ru
24f0: 6e 20 73 6f 6d 65 20 6d 6f 72 65 20 53 45 4c 45  n some more SELE
2500: 43 54 20 0a 23 20 73 74 61 74 65 6d 65 6e 74 73  CT .# statements
2510: 0a 23 0a 73 65 74 20 3a 3a 43 6f 6c 75 6d 6e 4c  .#.set ::ColumnL
2520: 69 73 74 20 5b 6c 69 73 74 20 61 20 62 20 63 5d  ist [list a b c]
2530: 0a 73 65 74 20 45 20 7b 7b 6e 6f 20 73 75 63 68  .set E {{no such
2540: 20 63 6f 6c 7d 20 7b 61 6d 62 69 67 75 6f 75 73   col} {ambiguous
2550: 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 7d 7d 0a 64   column name}}.d
2560: 6f 5f 66 75 7a 7a 79 5f 74 65 73 74 20 66 75 7a  o_fuzzy_test fuz
2570: 7a 2d 36 2e 31 20 2d 74 65 6d 70 6c 61 74 65 20  z-6.1 -template 
2580: 7b 5b 53 65 6c 65 63 74 5d 7d 20 2d 65 72 72 6f  {[Select]} -erro
2590: 72 6c 69 73 74 20 24 45 0a 0a 23 2d 2d 2d 2d 2d  rlist $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 2d 2d 2d 2d 2d 2d 2d 0a 23 20 52 75  -----------.# Ru
25e0: 6e 20 73 6f 6d 65 20 53 45 4c 45 43 54 73 2c 20  n some SELECTs, 
25f0: 49 4e 53 45 52 54 73 2c 20 55 50 44 41 54 45 73  INSERTs, UPDATEs
2600: 20 61 6e 64 20 44 45 4c 45 54 45 73 20 69 6e 20   and DELETEs in 
2610: 61 20 74 72 61 6e 73 61 63 74 69 6f 6e 2e 0a 23  a transaction..#
2620: 0a 73 65 74 20 45 20 7b 7b 6e 6f 20 73 75 63 68  .set E {{no such
2630: 20 63 6f 6c 7d 20 7b 61 6d 62 69 67 75 6f 75 73   col} {ambiguous
2640: 20 63 6f 6c 75 6d 6e 20 6e 61 6d 65 7d 20 7b 74   column name} {t
2650: 61 62 6c 65 7d 7d 0a 64 6f 5f 74 65 73 74 20 20  able}}.do_test  
2660: 20 20 20 20 20 20 20 66 75 7a 7a 2d 37 2e 31 20         fuzz-7.1 
2670: 7b 65 78 65 63 73 71 6c 20 42 45 47 49 4e 7d 20  {execsql BEGIN} 
2680: 7b 7d 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65 73 74  {}.do_fuzzy_test
2690: 20 20 20 66 75 7a 7a 2d 37 2e 32 20 2d 74 65 6d     fuzz-7.2 -tem
26a0: 70 6c 61 74 65 20 7b 5b 53 74 61 74 65 6d 65 6e  plate {[Statemen
26b0: 74 5d 7d 20 2d 65 72 72 6f 72 6c 69 73 74 20 24  t]} -errorlist $
26c0: 45 0a 69 6e 74 65 67 72 69 74 79 5f 63 68 65 63  E.integrity_chec
26d0: 6b 20 66 75 7a 7a 2d 37 2e 33 2e 69 6e 74 65 67  k fuzz-7.3.integ
26e0: 72 69 74 79 0a 64 6f 5f 74 65 73 74 20 20 20 20  rity.do_test    
26f0: 20 20 20 20 20 66 75 7a 7a 2d 37 2e 34 20 7b 65       fuzz-7.4 {e
2700: 78 65 63 73 71 6c 20 43 4f 4d 4d 49 54 7d 20 7b  xecsql COMMIT} {
2710: 7d 0a 69 6e 74 65 67 72 69 74 79 5f 63 68 65 63  }.integrity_chec
2720: 6b 20 66 75 7a 7a 2d 37 2e 35 2e 69 6e 74 65 67  k fuzz-7.5.integ
2730: 72 69 74 79 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  rity..#---------
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: 2d 2d 2d 2d 2d 2d 2d 0a 23 20 4d 61 6e 79 20 43  -------.# Many C
2780: 52 45 41 54 45 20 61 6e 64 20 44 52 4f 50 20 54  REATE and DROP T
2790: 41 42 4c 45 20 73 74 61 74 65 6d 65 6e 74 73 3a  ABLE statements:
27a0: 0a 23 0a 73 65 74 20 45 20 5b 6c 69 73 74 20 74  .#.set E [list t
27b0: 61 62 6c 65 20 64 75 70 6c 69 63 61 74 65 20 7b  able duplicate {
27c0: 6e 6f 20 73 75 63 68 20 63 6f 6c 7d 20 7b 61 6d  no such col} {am
27d0: 62 69 67 75 6f 75 73 20 63 6f 6c 75 6d 6e 20 6e  biguous column n
27e0: 61 6d 65 7d 20 7b 75 73 65 20 44 52 4f 50 7d 5d  ame} {use DROP}]
27f0: 0a 64 6f 5f 66 75 7a 7a 79 5f 74 65 73 74 20 66  .do_fuzzy_test f
2800: 75 7a 7a 2d 38 2e 31 20 2d 74 65 6d 70 6c 61 74  uzz-8.1 -templat
2810: 65 20 7b 5b 43 72 65 61 74 65 4f 72 44 72 6f 70  e {[CreateOrDrop
2820: 54 61 62 6c 65 4f 72 56 69 65 77 5d 7d 20 2d 65  TableOrView]} -e
2830: 72 72 6f 72 6c 69 73 74 20 24 45 0a 0a 63 6c 6f  rrorlist $E..clo
2840: 73 65 20 24 3a 3a 6c 6f 67 0a 66 69 6e 69 73 68  se $::log.finish
2850: 5f 74 65 73 74 0a                                _test.