/ Hex Artifact Content
Login

Artifact 511bacdbe41c49cf34f9fd1bd3245fe1575bca98:


0000: 23 20 32 30 31 35 2d 31 31 2d 30 37 0a 23 0a 23  # 2015-11-07.#.#
0010: 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73 63   The author disc
0020: 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74 20  laims copyright 
0030: 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20 63  to this source c
0040: 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20 6f  ode.  In place o
0050: 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74 69  f.# a legal noti
0060: 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62 6c  ce, here is a bl
0070: 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20 4d  essing:.#.#    M
0080: 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61  ay you do good a
0090: 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20 20  nd not evil..#  
00a0: 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 66    May you find f
00b0: 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 79  orgiveness for y
00c0: 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 67  ourself and forg
00d0: 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20 20  ive others..#   
00e0: 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 66   May you share f
00f0: 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 6b  reely, never tak
0100: 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 6f  ing more than yo
0110: 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a 2a  u 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 0a 23 20 54 68 69 73 20 66 69 6c 65 20 69  **.# This file i
0170: 6d 70 6c 65 6d 65 6e 74 73 20 72 65 67 72 65 73  mplements regres
0180: 73 69 6f 6e 20 74 65 73 74 73 20 66 6f 72 20 53  sion tests for S
0190: 51 4c 69 74 65 20 6c 69 62 72 61 72 79 2e 20 20  QLite library.  
01a0: 54 68 65 0a 23 20 66 6f 63 75 73 20 6f 66 20 74  The.# focus of t
01b0: 68 69 73 20 66 69 6c 65 20 69 73 20 74 65 73 74  his file is test
01c0: 69 6e 67 20 74 68 65 20 57 49 54 48 20 63 6c 61  ing the WITH cla
01d0: 75 73 65 2e 0a 23 0a 0a 73 65 74 20 74 65 73 74  use..#..set test
01e0: 64 69 72 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d  dir [file dirnam
01f0: 65 20 24 61 72 67 76 30 5d 0a 73 6f 75 72 63 65  e $argv0].source
0200: 20 24 74 65 73 74 64 69 72 2f 74 65 73 74 65 72   $testdir/tester
0210: 2e 74 63 6c 0a 73 65 74 20 3a 3a 74 65 73 74 70  .tcl.set ::testp
0220: 72 65 66 69 78 20 77 69 74 68 33 0a 0a 69 66 63  refix with3..ifc
0230: 61 70 61 62 6c 65 20 7b 21 63 74 65 7d 20 7b 0a  apable {!cte} {.
0240: 20 20 66 69 6e 69 73 68 5f 74 65 73 74 0a 20 20    finish_test.  
0250: 72 65 74 75 72 6e 0a 7d 0a 0a 23 20 54 65 73 74  return.}..# Test
0260: 20 70 72 6f 62 6c 65 6d 73 20 66 6f 75 6e 64 20   problems found 
0270: 62 79 20 4b 6f 73 74 79 61 20 53 65 72 65 62 72  by Kostya Serebr
0280: 79 61 6e 79 20 75 73 69 6e 67 20 0a 23 20 4c 69  yany using .# Li
0290: 62 46 75 7a 7a 65 72 2e 20 20 28 68 74 74 70 3a  bFuzzer.  (http:
02a0: 2f 2f 6c 6c 76 6d 2e 6f 72 67 2f 64 6f 63 73 2f  //llvm.org/docs/
02b0: 4c 69 62 46 75 7a 7a 65 72 2e 68 74 6d 6c 29 0a  LibFuzzer.html).
02c0: 23 0a 64 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65  #.do_catchsql_te
02d0: 73 74 20 31 2e 30 20 7b 0a 20 20 57 49 54 48 20  st 1.0 {.  WITH 
02e0: 69 28 78 29 20 41 53 20 28 0a 20 20 20 20 57 49  i(x) AS (.    WI
02f0: 54 48 20 6a 20 41 53 20 28 53 45 4c 45 43 54 20  TH j AS (SELECT 
0300: 31 30 29 0a 20 20 20 20 53 45 4c 45 43 54 20 35  10).    SELECT 5
0310: 20 46 52 4f 4d 20 74 30 20 55 4e 49 4f 4e 20 53   FROM t0 UNION S
0320: 45 4c 45 43 54 20 38 20 46 52 4f 4d 20 6d 0a 20  ELECT 8 FROM m. 
0330: 20 29 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52   ).  SELECT * FR
0340: 4f 4d 20 69 3b 0a 7d 20 7b 31 20 7b 6e 6f 20 73  OM i;.} {1 {no s
0350: 75 63 68 20 74 61 62 6c 65 3a 20 6d 7d 7d 0a 0a  uch table: m}}..
0360: 23 20 41 64 64 69 74 69 6f 6e 61 6c 20 74 65 73  # Additional tes
0370: 74 20 63 61 73 65 73 20 74 68 61 74 20 63 61 6d  t cases that cam
0380: 65 20 6f 75 74 20 6f 66 20 74 68 65 20 77 6f 72  e out of the wor
0390: 6b 20 74 6f 0a 23 20 66 69 78 20 66 6f 72 20 4b  k to.# fix for K
03a0: 6f 73 74 79 61 27 73 20 70 72 6f 62 6c 65 6d 2e  ostya's problem.
03b0: 0a 23 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  .#.do_execsql_te
03c0: 73 74 20 32 2e 30 20 7b 0a 20 57 49 54 48 0a 20  st 2.0 {. WITH. 
03d0: 20 78 31 20 41 53 20 28 53 45 4c 45 43 54 20 31   x1 AS (SELECT 1
03e0: 30 29 2c 0a 20 20 78 32 20 41 53 20 28 53 45 4c  0),.  x2 AS (SEL
03f0: 45 43 54 20 31 31 29 2c 0a 20 20 78 33 20 41 53  ECT 11),.  x3 AS
0400: 20 28 0a 20 20 20 20 53 45 4c 45 43 54 20 2a 20   (.    SELECT * 
0410: 46 52 4f 4d 20 78 31 20 55 4e 49 4f 4e 20 41 4c  FROM x1 UNION AL
0420: 4c 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20  L SELECT * FROM 
0430: 78 32 0a 20 20 29 2c 0a 20 20 78 34 20 41 53 20  x2.  ),.  x4 AS 
0440: 28 0a 20 20 20 20 57 49 54 48 0a 20 20 20 20 78  (.    WITH.    x
0450: 31 20 41 53 20 28 53 45 4c 45 43 54 20 31 32 29  1 AS (SELECT 12)
0460: 2c 0a 20 20 20 20 78 32 20 41 53 20 28 53 45 4c  ,.    x2 AS (SEL
0470: 45 43 54 20 31 33 29 0a 20 20 20 20 53 45 4c 45  ECT 13).    SELE
0480: 43 54 20 2a 20 46 52 4f 4d 20 78 33 0a 20 20 29  CT * FROM x3.  )
0490: 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
04a0: 20 78 34 3b 0a 0a 7d 20 7b 31 30 20 31 31 7d 0a   x4;..} {10 11}.
04b0: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
04c0: 20 32 2e 31 20 7b 0a 20 20 43 52 45 41 54 45 20   2.1 {.  CREATE 
04d0: 54 41 42 4c 45 20 74 31 28 78 29 3b 0a 20 20 57  TABLE t1(x);.  W
04e0: 49 54 48 0a 20 20 20 20 78 31 28 61 29 20 41 53  ITH.    x1(a) AS
04f0: 20 28 76 61 6c 75 65 73 28 31 30 30 29 29 0a 20   (values(100)). 
0500: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
0510: 78 29 0a 20 20 20 20 53 45 4c 45 43 54 20 2a 20  x).    SELECT * 
0520: 46 52 4f 4d 20 28 57 49 54 48 20 78 32 28 79 29  FROM (WITH x2(y)
0530: 20 41 53 20 28 53 45 4c 45 43 54 20 2a 20 46 52   AS (SELECT * FR
0540: 4f 4d 20 78 31 29 20 53 45 4c 45 43 54 20 79 2b  OM x1) SELECT y+
0550: 61 20 46 52 4f 4d 20 78 31 2c 20 78 32 29 3b 0a  a FROM x1, x2);.
0560: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
0570: 74 31 3b 0a 7d 20 7b 32 30 30 7d 0a 0a 66 69 6e  t1;.} {200}..fin
0580: 69 73 68 5f 74 65 73 74 0a                       ish_test.