/ Hex Artifact Content
Login

Artifact 2b20468da3775aba971caf3158e9696a4d99c69a7623fb495f332a596daebbee:


0000: 23 20 32 30 31 36 20 4a 75 6c 79 20 32 39 0a 23  # 2016 July 29.#
0010: 0a 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69  .# The author di
0020: 73 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68  sclaims copyrigh
0030: 74 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65  t to this source
0040: 20 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65   code.  In place
0050: 20 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f   of.# a legal no
0060: 74 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20  tice, here is a 
0070: 62 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20  blessing:.#.#   
0080: 20 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64   May you do good
0090: 20 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23   and not evil..#
00a0: 20 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64      May you find
00b0: 20 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72   forgiveness for
00c0: 20 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f   yourself and fo
00d0: 72 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20  rgive others..# 
00e0: 20 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65     May you share
00f0: 20 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74   freely, never t
0100: 61 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20  aking more than 
0110: 79 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a  you 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 2a 0a 23 20 54 68 69 73 20 66 69 6c 65  ****.# This file
0170: 20 69 6d 70 6c 65 6d 65 6e 74 73 20 72 65 67 72   implements regr
0180: 65 73 73 69 6f 6e 20 74 65 73 74 73 20 66 6f 72  ession tests for
0190: 20 53 51 4c 69 74 65 20 6c 69 62 72 61 72 79 2e   SQLite library.
01a0: 20 20 54 68 65 0a 23 20 66 6f 63 75 73 20 6f 66    The.# focus of
01b0: 20 74 68 69 73 20 66 69 6c 65 20 69 73 20 73 79   this file is sy
01c0: 6e 74 61 78 20 65 72 72 6f 72 73 20 69 6e 76 6f  ntax errors invo
01d0: 6c 76 69 6e 67 20 72 6f 77 2d 76 61 6c 75 65 20  lving row-value 
01e0: 63 6f 6e 73 74 72 75 63 74 6f 72 73 0a 23 20 61  constructors.# a
01f0: 6e 64 20 73 75 62 2d 73 65 6c 65 63 74 73 20 74  nd sub-selects t
0200: 68 61 74 20 72 65 74 75 72 6e 20 6d 75 6c 74 69  hat return multi
0210: 70 6c 65 20 61 72 67 75 6d 65 6e 74 73 2e 0a 23  ple arguments..#
0220: 0a 0a 73 65 74 20 74 65 73 74 64 69 72 20 5b 66  ..set testdir [f
0230: 69 6c 65 20 64 69 72 6e 61 6d 65 20 24 61 72 67  ile dirname $arg
0240: 76 30 5d 0a 73 6f 75 72 63 65 20 24 74 65 73 74  v0].source $test
0250: 64 69 72 2f 74 65 73 74 65 72 2e 74 63 6c 0a 73  dir/tester.tcl.s
0260: 65 74 20 3a 3a 74 65 73 74 70 72 65 66 69 78 20  et ::testprefix 
0270: 72 6f 77 76 61 6c 75 65 34 0a 0a 23 2d 2d 2d 2d  rowvalue4..#----
0280: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0290: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
02c0: 2d 2d 2d 2d 2d 0a 23 20 54 65 73 74 20 73 6f 6d  -----.# Test som
02d0: 65 20 65 72 72 6f 72 20 63 6f 6e 64 69 74 69 6f  e error conditio
02e0: 6e 73 3a 0a 23 20 0a 23 20 20 20 2a 20 72 6f 77  ns:.# .#   * row
02f0: 20 76 61 6c 75 65 73 20 75 73 65 64 20 77 68 65   values used whe
0300: 72 65 20 74 68 65 79 20 61 72 65 20 6e 6f 74 20  re they are not 
0310: 73 75 70 70 6f 72 74 65 64 2c 0a 23 20 20 20 2a  supported,.#   *
0320: 20 72 6f 77 20 76 61 6c 75 65 73 20 6f 72 20 73   row values or s
0330: 75 62 2d 73 65 6c 65 63 74 73 20 74 68 61 74 20  ub-selects that 
0340: 63 6f 6e 74 61 69 6e 2f 72 65 74 75 72 6e 20 74  contain/return t
0350: 68 65 20 77 72 6f 6e 67 20 6e 75 6d 62 65 72 0a  he wrong number.
0360: 23 20 20 20 20 20 6f 66 20 65 6c 65 6d 65 6e 74  #     of element
0370: 73 2e 0a 23 0a 64 6f 5f 65 78 65 63 73 71 6c 5f  s..#.do_execsql_
0380: 74 65 73 74 20 31 2e 30 20 7b 0a 20 20 43 52 45  test 1.0 {.  CRE
0390: 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 20  ATE TABLE t1(a, 
03a0: 62 2c 20 63 29 3b 0a 20 20 43 52 45 41 54 45 20  b, c);.  CREATE 
03b0: 49 4e 44 45 58 20 74 31 62 61 63 20 4f 4e 20 74  INDEX t1bac ON t
03c0: 31 28 62 2c 20 61 2c 20 63 29 3b 0a 7d 0a 0a 66  1(b, a, c);.}..f
03d0: 6f 72 65 61 63 68 20 7b 74 6e 20 65 7d 20 7b 0a  oreach {tn e} {.
03e0: 20 20 31 20 22 28 31 2c 20 32 2c 20 33 29 22 0a    1 "(1, 2, 3)".
03f0: 20 20 32 20 22 31 20 2b 20 28 31 2c 20 32 29 22    2 "1 + (1, 2)"
0400: 0a 20 20 33 20 22 28 31 2c 32 2c 33 29 20 3d 3d  .  3 "(1,2,3) ==
0410: 20 28 31 2c 20 32 29 22 0a 7d 20 7b 0a 20 20 64   (1, 2)".} {.  d
0420: 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65 73 74 20  o_catchsql_test 
0430: 31 2e 24 74 6e 20 22 53 45 4c 45 43 54 20 24 65  1.$tn "SELECT $e
0440: 22 20 7b 31 20 7b 72 6f 77 20 76 61 6c 75 65 20  " {1 {row value 
0450: 6d 69 73 75 73 65 64 7d 7d 0a 7d 0a 0a 66 6f 72  misused}}.}..for
0460: 65 61 63 68 20 7b 74 6e 20 73 20 65 72 72 6f 72  each {tn s error
0470: 7d 20 7b 0a 20 20 31 20 22 53 45 4c 45 43 54 20  } {.  1 "SELECT 
0480: 2a 20 46 52 4f 4d 20 74 31 20 57 48 45 52 45 20  * FROM t1 WHERE 
0490: 61 20 3d 20 28 31 2c 20 32 29 22 20 20 20 20 20  a = (1, 2)"     
04a0: 20 20 7b 72 6f 77 20 76 61 6c 75 65 20 6d 69 73    {row value mis
04b0: 75 73 65 64 7d 0a 20 20 32 20 22 53 45 4c 45 43  used}.  2 "SELEC
04c0: 54 20 2a 20 46 52 4f 4d 20 74 31 20 57 48 45 52  T * FROM t1 WHER
04d0: 45 20 62 20 3d 20 28 31 2c 20 32 29 22 20 20 20  E b = (1, 2)"   
04e0: 20 20 20 20 7b 72 6f 77 20 76 61 6c 75 65 20 6d      {row value m
04f0: 69 73 75 73 65 64 7d 0a 20 20 33 20 22 53 45 4c  isused}.  3 "SEL
0500: 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 20 57 48  ECT * FROM t1 WH
0510: 45 52 45 20 4e 4f 54 20 28 62 20 3d 20 28 31 2c  ERE NOT (b = (1,
0520: 20 32 29 29 22 20 7b 72 6f 77 20 76 61 6c 75 65   2))" {row value
0530: 20 6d 69 73 75 73 65 64 7d 0a 20 20 34 20 22 53   misused}.  4 "S
0540: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 20  ELECT * FROM t1 
0550: 4c 49 4d 49 54 20 28 31 2c 20 32 29 22 20 20 20  LIMIT (1, 2)"   
0560: 20 20 20 20 20 20 20 20 7b 72 6f 77 20 76 61 6c          {row val
0570: 75 65 20 6d 69 73 75 73 65 64 7d 0a 20 20 35 20  ue misused}.  5 
0580: 22 53 45 4c 45 43 54 20 28 61 2c 20 62 29 20 49  "SELECT (a, b) I
0590: 4e 20 28 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  N (SELECT * FROM
05a0: 20 74 31 29 20 46 52 4f 4d 20 74 31 22 20 0a 20   t1) FROM t1" . 
05b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
05c0: 20 20 20 20 20 20 20 20 20 20 20 20 7b 73 75 62              {sub
05d0: 2d 73 65 6c 65 63 74 20 72 65 74 75 72 6e 73 20  -select returns 
05e0: 33 20 63 6f 6c 75 6d 6e 73 20 2d 20 65 78 70 65  3 columns - expe
05f0: 63 74 65 64 20 32 7d 0a 0a 20 20 36 20 22 53 45  cted 2}..  6 "SE
0600: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 20 57  LECT * FROM t1 W
0610: 48 45 52 45 20 28 61 2c 20 62 29 20 49 4e 20 28  HERE (a, b) IN (
0620: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31  SELECT * FROM t1
0630: 29 22 20 0a 20 20 20 20 20 20 20 20 20 20 20 20  )" .            
0640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0650: 20 7b 73 75 62 2d 73 65 6c 65 63 74 20 72 65 74   {sub-select ret
0660: 75 72 6e 73 20 33 20 63 6f 6c 75 6d 6e 73 20 2d  urns 3 columns -
0670: 20 65 78 70 65 63 74 65 64 20 32 7d 0a 20 20 37   expected 2}.  7
0680: 20 22 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20   "SELECT * FROM 
0690: 74 31 20 57 48 45 52 45 20 28 63 2c 20 63 29 20  t1 WHERE (c, c) 
06a0: 3c 3d 20 31 22 20 7b 72 6f 77 20 76 61 6c 75 65  <= 1" {row value
06b0: 20 6d 69 73 75 73 65 64 7d 0a 20 20 38 20 22 53   misused}.  8 "S
06c0: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 20  ELECT * FROM t1 
06d0: 57 48 45 52 45 20 28 62 2c 20 62 29 20 3c 3d 20  WHERE (b, b) <= 
06e0: 31 22 20 7b 72 6f 77 20 76 61 6c 75 65 20 6d 69  1" {row value mi
06f0: 73 75 73 65 64 7d 0a 7d 20 7b 0a 20 20 64 6f 5f  sused}.} {.  do_
0700: 63 61 74 63 68 73 71 6c 5f 74 65 73 74 20 32 2e  catchsql_test 2.
0710: 24 74 6e 20 22 24 73 22 20 5b 6c 69 73 74 20 31  $tn "$s" [list 1
0720: 20 24 65 72 72 6f 72 5d 0a 7d 0a 0a 23 2d 2d 2d   $error].}..#---
0730: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0740: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0750: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0760: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0770: 2d 2d 2d 2d 2d 2d 0a 64 6f 5f 65 78 65 63 73 71  ------.do_execsq
0780: 6c 5f 74 65 73 74 20 32 2e 30 20 7b 0a 20 20 43  l_test 2.0 {.  C
0790: 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 28 61  REATE TABLE t2(a
07a0: 2c 20 62 2c 20 63 2c 20 64 29 3b 0a 20 20 49 4e  , b, c, d);.  IN
07b0: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
07c0: 55 45 53 28 31 2c 20 31 2c 20 31 2c 20 20 20 31  UES(1, 1, 1,   1
07d0: 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
07e0: 20 74 32 20 56 41 4c 55 45 53 28 31 2c 20 31 2c   t2 VALUES(1, 1,
07f0: 20 32 2c 20 20 20 32 29 3b 0a 20 20 49 4e 53 45   2,   2);.  INSE
0800: 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c 55 45  RT INTO t2 VALUE
0810: 53 28 31 2c 20 31 2c 20 33 2c 20 20 20 33 29 3b  S(1, 1, 3,   3);
0820: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
0830: 32 20 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 31  2 VALUES(1, 2, 1
0840: 2c 20 20 20 34 29 3b 0a 20 20 49 4e 53 45 52 54  ,   4);.  INSERT
0850: 20 49 4e 54 4f 20 74 32 20 56 41 4c 55 45 53 28   INTO t2 VALUES(
0860: 31 2c 20 32 2c 20 32 2c 20 20 20 35 29 3b 0a 20  1, 2, 2,   5);. 
0870: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20   INSERT INTO t2 
0880: 56 41 4c 55 45 53 28 31 2c 20 32 2c 20 33 2c 20  VALUES(1, 2, 3, 
0890: 20 20 36 29 3b 0a 20 20 49 4e 53 45 52 54 20 49    6);.  INSERT I
08a0: 4e 54 4f 20 74 32 20 56 41 4c 55 45 53 28 31 2c  NTO t2 VALUES(1,
08b0: 20 33 2c 20 31 2c 20 20 20 37 29 3b 0a 20 20 49   3, 1,   7);.  I
08c0: 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41  NSERT INTO t2 VA
08d0: 4c 55 45 53 28 31 2c 20 33 2c 20 32 2c 20 20 20  LUES(1, 3, 2,   
08e0: 38 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  8);.  INSERT INT
08f0: 4f 20 74 32 20 56 41 4c 55 45 53 28 31 2c 20 33  O t2 VALUES(1, 3
0900: 2c 20 33 2c 20 20 20 39 29 3b 0a 0a 20 20 49 4e  , 3,   9);..  IN
0910: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
0920: 55 45 53 28 32 2c 20 31 2c 20 31 2c 20 20 20 31  UES(2, 1, 1,   1
0930: 30 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  0);.  INSERT INT
0940: 4f 20 74 32 20 56 41 4c 55 45 53 28 32 2c 20 31  O t2 VALUES(2, 1
0950: 2c 20 32 2c 20 20 20 31 31 29 3b 0a 20 20 49 4e  , 2,   11);.  IN
0960: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
0970: 55 45 53 28 32 2c 20 31 2c 20 33 2c 20 20 20 31  UES(2, 1, 3,   1
0980: 32 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  2);.  INSERT INT
0990: 4f 20 74 32 20 56 41 4c 55 45 53 28 32 2c 20 32  O t2 VALUES(2, 2
09a0: 2c 20 31 2c 20 20 20 31 33 29 3b 0a 20 20 49 4e  , 1,   13);.  IN
09b0: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
09c0: 55 45 53 28 32 2c 20 32 2c 20 32 2c 20 20 20 31  UES(2, 2, 2,   1
09d0: 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  4);.  INSERT INT
09e0: 4f 20 74 32 20 56 41 4c 55 45 53 28 32 2c 20 32  O t2 VALUES(2, 2
09f0: 2c 20 33 2c 20 20 20 31 35 29 3b 0a 20 20 49 4e  , 3,   15);.  IN
0a00: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
0a10: 55 45 53 28 32 2c 20 33 2c 20 31 2c 20 20 20 31  UES(2, 3, 1,   1
0a20: 36 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  6);.  INSERT INT
0a30: 4f 20 74 32 20 56 41 4c 55 45 53 28 32 2c 20 33  O t2 VALUES(2, 3
0a40: 2c 20 32 2c 20 20 20 31 37 29 3b 0a 20 20 49 4e  , 2,   17);.  IN
0a50: 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41 4c  SERT INTO t2 VAL
0a60: 55 45 53 28 32 2c 20 33 2c 20 33 2c 20 20 20 31  UES(2, 3, 3,   1
0a70: 38 29 3b 0a 0a 20 20 49 4e 53 45 52 54 20 49 4e  8);..  INSERT IN
0a80: 54 4f 20 74 32 20 56 41 4c 55 45 53 28 33 2c 20  TO t2 VALUES(3, 
0a90: 31 2c 20 31 2c 20 20 20 31 39 29 3b 0a 20 20 49  1, 1,   19);.  I
0aa0: 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41  NSERT INTO t2 VA
0ab0: 4c 55 45 53 28 33 2c 20 31 2c 20 32 2c 20 20 20  LUES(3, 1, 2,   
0ac0: 32 30 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  20);.  INSERT IN
0ad0: 54 4f 20 74 32 20 56 41 4c 55 45 53 28 33 2c 20  TO t2 VALUES(3, 
0ae0: 31 2c 20 33 2c 20 20 20 32 31 29 3b 0a 20 20 49  1, 3,   21);.  I
0af0: 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41  NSERT INTO t2 VA
0b00: 4c 55 45 53 28 33 2c 20 32 2c 20 31 2c 20 20 20  LUES(3, 2, 1,   
0b10: 32 32 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  22);.  INSERT IN
0b20: 54 4f 20 74 32 20 56 41 4c 55 45 53 28 33 2c 20  TO t2 VALUES(3, 
0b30: 32 2c 20 32 2c 20 20 20 32 33 29 3b 0a 20 20 49  2, 2,   23);.  I
0b40: 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41  NSERT INTO t2 VA
0b50: 4c 55 45 53 28 33 2c 20 32 2c 20 33 2c 20 20 20  LUES(3, 2, 3,   
0b60: 32 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  24);.  INSERT IN
0b70: 54 4f 20 74 32 20 56 41 4c 55 45 53 28 33 2c 20  TO t2 VALUES(3, 
0b80: 33 2c 20 31 2c 20 20 20 32 35 29 3b 0a 20 20 49  3, 1,   25);.  I
0b90: 4e 53 45 52 54 20 49 4e 54 4f 20 74 32 20 56 41  NSERT INTO t2 VA
0ba0: 4c 55 45 53 28 33 2c 20 33 2c 20 32 2c 20 20 20  LUES(3, 3, 2,   
0bb0: 32 36 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  26);.  INSERT IN
0bc0: 54 4f 20 74 32 20 56 41 4c 55 45 53 28 33 2c 20  TO t2 VALUES(3, 
0bd0: 33 2c 20 33 2c 20 20 20 32 37 29 3b 0a 7d 0a 0a  3, 3,   27);.}..
0be0: 66 6f 72 65 61 63 68 20 7b 6e 6d 20 69 64 78 7d  foreach {nm idx}
0bf0: 20 7b 0a 20 20 69 64 78 31 20 7b 7d 0a 20 20 69   {.  idx1 {}.  i
0c00: 64 78 32 20 7b 20 43 52 45 41 54 45 20 49 4e 44  dx2 { CREATE IND
0c10: 45 58 20 74 32 61 62 63 20 4f 4e 20 74 32 28 61  EX t2abc ON t2(a
0c20: 2c 20 62 2c 20 63 29 3b 20 7d 0a 20 20 69 64 78  , b, c); }.  idx
0c30: 33 20 7b 20 43 52 45 41 54 45 20 49 4e 44 45 58  3 { CREATE INDEX
0c40: 20 74 32 61 62 63 20 4f 4e 20 74 32 28 61 2c 20   t2abc ON t2(a, 
0c50: 62 20 44 45 53 43 2c 20 63 29 3b 20 7d 0a 20 20  b DESC, c); }.  
0c60: 69 64 78 34 20 7b 20 43 52 45 41 54 45 20 49 4e  idx4 { CREATE IN
0c70: 44 45 58 20 74 32 61 62 63 20 4f 4e 20 74 32 28  DEX t2abc ON t2(
0c80: 61 20 44 45 53 43 2c 20 62 20 44 45 53 43 2c 20  a DESC, b DESC, 
0c90: 63 20 44 45 53 43 29 3b 20 7d 0a 20 20 69 64 78  c DESC); }.  idx
0ca0: 35 20 7b 20 43 52 45 41 54 45 20 49 4e 44 45 58  5 { CREATE INDEX
0cb0: 20 74 32 61 62 63 20 4f 4e 20 74 32 28 61 20 41   t2abc ON t2(a A
0cc0: 53 43 2c 20 62 20 41 53 43 2c 20 63 20 41 53 43  SC, b ASC, c ASC
0cd0: 29 3b 20 7d 0a 20 20 69 64 78 36 20 7b 20 43 52  ); }.  idx6 { CR
0ce0: 45 41 54 45 20 49 4e 44 45 58 20 74 32 61 62 63  EATE INDEX t2abc
0cf0: 20 4f 4e 20 74 32 28 61 20 44 45 53 43 2c 20 62   ON t2(a DESC, b
0d00: 2c 20 63 29 3b 20 7d 0a 20 20 69 64 78 37 20 7b  , c); }.  idx7 {
0d10: 20 43 52 45 41 54 45 20 49 4e 44 45 58 20 74 32   CREATE INDEX t2
0d20: 61 62 63 20 4f 4e 20 74 32 28 61 20 44 45 53 43  abc ON t2(a DESC
0d30: 2c 20 62 20 44 45 53 43 29 20 7d 0a 20 20 69 64  , b DESC) }.  id
0d40: 78 38 20 7b 20 43 52 45 41 54 45 20 49 4e 44 45  x8 { CREATE INDE
0d50: 58 20 74 32 61 62 63 20 4f 4e 20 74 32 28 63 2c  X t2abc ON t2(c,
0d60: 20 62 2c 20 61 29 3b 20 7d 0a 20 20 69 64 78 39   b, a); }.  idx9
0d70: 20 7b 20 43 52 45 41 54 45 20 49 4e 44 45 58 20   { CREATE INDEX 
0d80: 74 32 64 20 4f 4e 20 74 32 28 64 29 3b 20 7d 0a  t2d ON t2(d); }.
0d90: 20 20 69 64 78 31 30 20 7b 20 43 52 45 41 54 45    idx10 { CREATE
0da0: 20 49 4e 44 45 58 20 74 32 61 62 63 20 4f 4e 20   INDEX t2abc ON 
0db0: 74 32 28 61 20 44 45 53 43 2c 20 62 2c 20 63 20  t2(a DESC, b, c 
0dc0: 44 45 53 43 29 3b 20 7d 0a 7d 20 7b 0a 20 20 64  DESC); }.} {.  d
0dd0: 72 6f 70 5f 61 6c 6c 5f 69 6e 64 65 78 65 73 0a  rop_all_indexes.
0de0: 20 20 65 78 65 63 73 71 6c 20 24 69 64 78 0a 0a    execsql $idx..
0df0: 20 20 66 6f 72 65 61 63 68 20 7b 74 6e 20 77 68    foreach {tn wh
0e00: 65 72 65 20 72 65 73 7d 20 7b 0a 20 20 20 20 31  ere res} {.    1
0e10: 20 22 28 61 2c 20 62 2c 20 63 29 20 3c 20 28 32   "(a, b, c) < (2
0e20: 2c 20 32 2c 20 32 29 22 20 20 7b 31 20 32 20 33  , 2, 2)"  {1 2 3
0e30: 20 34 20 35 20 36 20 37 20 38 20 39 20 31 30 20   4 5 6 7 8 9 10 
0e40: 31 31 20 31 32 20 31 33 7d 0a 20 20 20 20 32 20  11 12 13}.    2 
0e50: 22 28 61 2c 20 62 2c 20 63 29 20 3c 3d 20 28 32  "(a, b, c) <= (2
0e60: 2c 20 32 2c 20 32 29 22 20 7b 31 20 32 20 33 20  , 2, 2)" {1 2 3 
0e70: 34 20 35 20 36 20 37 20 38 20 39 20 31 30 20 31  4 5 6 7 8 9 10 1
0e80: 31 20 31 32 20 31 33 20 31 34 7d 0a 20 20 20 20  1 12 13 14}.    
0e90: 33 20 22 28 61 2c 20 62 2c 20 63 29 20 3e 20 28  3 "(a, b, c) > (
0ea0: 32 2c 20 32 2c 20 32 29 22 20 20 7b 31 35 20 31  2, 2, 2)"  {15 1
0eb0: 36 20 31 37 20 31 38 20 31 39 20 32 30 20 32 31  6 17 18 19 20 21
0ec0: 20 32 32 20 32 33 20 32 34 20 32 35 20 32 36 20   22 23 24 25 26 
0ed0: 32 37 7d 0a 20 20 20 20 34 20 22 28 61 2c 20 62  27}.    4 "(a, b
0ee0: 2c 20 63 29 20 3e 3d 20 28 32 2c 20 32 2c 20 32  , c) >= (2, 2, 2
0ef0: 29 22 20 7b 31 34 20 31 35 20 31 36 20 31 37 20  )" {14 15 16 17 
0f00: 31 38 20 31 39 20 32 30 20 32 31 20 32 32 20 32  18 19 20 21 22 2
0f10: 33 20 32 34 20 32 35 20 32 36 20 32 37 7d 0a 20  3 24 25 26 27}. 
0f20: 20 20 20 35 20 22 28 61 2c 20 62 2c 20 63 29 20     5 "(a, b, c) 
0f30: 3e 3d 20 28 32 2c 20 32 2c 20 4e 55 4c 4c 29 22  >= (2, 2, NULL)"
0f40: 20 7b 31 36 20 31 37 20 31 38 20 31 39 20 32 30   {16 17 18 19 20
0f50: 20 32 31 20 32 32 20 32 33 20 32 34 20 32 35 20   21 22 23 24 25 
0f60: 32 36 20 32 37 7d 0a 20 20 20 20 36 20 22 28 61  26 27}.    6 "(a
0f70: 2c 20 62 2c 20 63 29 20 3c 3d 20 28 32 2c 20 32  , b, c) <= (2, 2
0f80: 2c 20 4e 55 4c 4c 29 22 20 7b 31 20 32 20 33 20  , NULL)" {1 2 3 
0f90: 34 20 35 20 36 20 37 20 38 20 39 20 31 30 20 31  4 5 6 7 8 9 10 1
0fa0: 31 20 31 32 7d 0a 20 20 20 20 37 20 22 28 61 2c  1 12}.    7 "(a,
0fb0: 20 62 2c 20 63 29 20 3e 3d 20 28 32 2c 20 4e 55   b, c) >= (2, NU
0fc0: 4c 4c 2c 20 4e 55 4c 4c 29 22 20 7b 31 39 20 32  LL, NULL)" {19 2
0fd0: 30 20 32 31 20 32 32 20 32 33 20 32 34 20 32 35  0 21 22 23 24 25
0fe0: 20 32 36 20 32 37 7d 0a 20 20 20 20 38 20 22 28   26 27}.    8 "(
0ff0: 61 2c 20 62 2c 20 63 29 20 3c 3d 20 28 32 2c 20  a, b, c) <= (2, 
1000: 4e 55 4c 4c 2c 20 4e 55 4c 4c 29 22 20 7b 31 20  NULL, NULL)" {1 
1010: 32 20 33 20 34 20 35 20 36 20 37 20 38 20 39 7d  2 3 4 5 6 7 8 9}
1020: 0a 0a 20 20 20 20 39 20 22 28 61 2c 20 62 2c 20  ..    9 "(a, b, 
1030: 63 29 20 3c 20 28 53 45 4c 45 43 54 20 61 2c 20  c) < (SELECT a, 
1040: 62 2c 20 63 20 46 52 4f 4d 20 74 32 20 57 48 45  b, c FROM t2 WHE
1050: 52 45 20 64 3d 31 34 29 22 20 20 0a 20 20 20 20  RE d=14)"  .    
1060: 20 20 7b 31 20 32 20 33 20 34 20 35 20 36 20 37    {1 2 3 4 5 6 7
1070: 20 38 20 39 20 31 30 20 31 31 20 31 32 20 31 33   8 9 10 11 12 13
1080: 7d 0a 0a 20 20 20 20 31 30 20 22 28 61 2c 20 62  }..    10 "(a, b
1090: 2c 20 63 29 20 3d 20 28 53 45 4c 45 43 54 20 61  , c) = (SELECT a
10a0: 2c 20 62 2c 20 63 20 46 52 4f 4d 20 74 32 20 57  , b, c FROM t2 W
10b0: 48 45 52 45 20 64 3d 31 34 29 22 20 31 34 0a 0a  HERE d=14)" 14..
10c0: 20 20 20 20 31 31 20 22 61 20 3d 20 32 20 41 4e      11 "a = 2 AN
10d0: 44 20 28 62 2c 20 63 29 20 3e 20 28 32 2c 20 32  D (b, c) > (2, 2
10e0: 29 22 20 7b 31 35 20 31 36 20 31 37 20 31 38 7d  )" {15 16 17 18}
10f0: 0a 20 20 20 20 31 32 20 22 61 20 3d 20 32 20 41  .    12 "a = 2 A
1100: 4e 44 20 28 62 2c 20 63 29 20 3c 20 28 33 2c 20  ND (b, c) < (3, 
1110: 33 29 20 41 4e 44 20 28 62 2c 20 63 29 20 3e 20  3) AND (b, c) > 
1120: 28 31 2c 20 31 29 22 20 7b 31 31 20 31 32 20 31  (1, 1)" {11 12 1
1130: 33 20 31 34 20 31 35 20 31 36 20 31 37 7d 0a 20  3 14 15 16 17}. 
1140: 20 7d 20 7b 0a 20 20 20 20 73 65 74 20 72 65 73   } {.    set res
1150: 75 6c 74 20 5b 64 62 20 65 76 61 6c 20 22 53 45  ult [db eval "SE
1160: 4c 45 43 54 20 64 20 46 52 4f 4d 20 74 32 20 57  LECT d FROM t2 W
1170: 48 45 52 45 20 24 77 68 65 72 65 22 5d 0a 20 20  HERE $where"].  
1180: 20 20 64 6f 5f 74 65 73 74 20 32 2e 31 2e 24 6e    do_test 2.1.$n
1190: 6d 2e 24 74 6e 20 7b 20 6c 73 6f 72 74 20 2d 69  m.$tn { lsort -i
11a0: 6e 74 65 67 65 72 20 24 72 65 73 75 6c 74 20 7d  nteger $result }
11b0: 20 24 72 65 73 0a 20 20 7d 0a 0a 20 20 66 6f 72   $res.  }..  for
11c0: 65 61 63 68 20 7b 74 6e 20 65 20 72 65 73 7d 20  each {tn e res} 
11d0: 7b 0a 20 20 20 20 31 20 22 28 32 2c 20 31 29 20  {.    1 "(2, 1) 
11e0: 49 4e 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20  IN (SELECT a, b 
11f0: 46 52 4f 4d 20 74 32 29 22 20 31 0a 20 20 20 20  FROM t2)" 1.    
1200: 32 20 22 28 32 2c 20 31 29 20 49 4e 20 28 53 45  2 "(2, 1) IN (SE
1210: 4c 45 43 54 20 61 2c 20 62 20 46 52 4f 4d 20 74  LECT a, b FROM t
1220: 32 20 4f 52 44 45 52 20 42 59 20 64 29 22 20 31  2 ORDER BY d)" 1
1230: 0a 20 20 20 20 33 20 22 28 32 2c 20 31 29 20 49  .    3 "(2, 1) I
1240: 4e 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20 46  N (SELECT a, b F
1250: 52 4f 4d 20 74 32 20 4f 52 44 45 52 20 42 59 20  ROM t2 ORDER BY 
1260: 64 20 4c 49 4d 49 54 20 39 29 22 20 30 0a 20 20  d LIMIT 9)" 0.  
1270: 20 20 34 20 22 28 32 2c 20 31 29 20 49 4e 20 28    4 "(2, 1) IN (
1280: 53 45 4c 45 43 54 20 61 2c 20 62 20 46 52 4f 4d  SELECT a, b FROM
1290: 20 74 32 20 4f 52 44 45 52 20 42 59 20 64 20 4c   t2 ORDER BY d L
12a0: 49 4d 49 54 20 31 30 29 22 20 31 0a 0a 20 20 20  IMIT 10)" 1..   
12b0: 20 35 20 22 28 33 2c 20 33 29 20 3d 20 28 53 45   5 "(3, 3) = (SE
12c0: 4c 45 43 54 20 61 2c 20 62 20 46 52 4f 4d 20 74  LECT a, b FROM t
12d0: 32 20 4f 52 44 45 52 20 42 59 20 64 20 44 45 53  2 ORDER BY d DES
12e0: 43 20 4c 49 4d 49 54 20 31 29 22 20 31 0a 20 20  C LIMIT 1)" 1.  
12f0: 20 20 36 20 22 28 33 2c 20 33 29 20 3d 20 28 53    6 "(3, 3) = (S
1300: 45 4c 45 43 54 20 61 2c 20 62 20 46 52 4f 4d 20  ELECT a, b FROM 
1310: 74 32 20 4f 52 44 45 52 20 42 59 20 64 20 41 53  t2 ORDER BY d AS
1320: 43 20 4c 49 4d 49 54 20 31 29 22 20 30 0a 20 20  C LIMIT 1)" 0.  
1330: 20 20 37 20 22 28 31 2c 20 4e 55 4c 4c 29 20 3d    7 "(1, NULL) =
1340: 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20 46 52   (SELECT a, b FR
1350: 4f 4d 20 74 32 20 4f 52 44 45 52 20 42 59 20 64  OM t2 ORDER BY d
1360: 20 41 53 43 20 4c 49 4d 49 54 20 31 29 22 20 7b   ASC LIMIT 1)" {
1370: 7b 7d 7d 0a 0a 20 20 20 20 38 20 22 28 33 2c 20  {}}..    8 "(3, 
1380: 31 29 20 3d 20 28 53 45 4c 45 43 54 20 62 2c 20  1) = (SELECT b, 
1390: 63 20 46 52 4f 4d 20 74 32 20 4f 52 44 45 52 20  c FROM t2 ORDER 
13a0: 42 59 20 64 20 44 45 53 43 20 4c 49 4d 49 54 20  BY d DESC LIMIT 
13b0: 31 20 4f 46 46 53 45 54 20 32 29 22 20 31 0a 20  1 OFFSET 2)" 1. 
13c0: 20 20 20 39 20 22 28 33 2c 20 31 29 20 3d 20 28     9 "(3, 1) = (
13d0: 53 45 4c 45 43 54 20 62 2c 20 63 20 46 52 4f 4d  SELECT b, c FROM
13e0: 20 74 32 20 4f 52 44 45 52 20 42 59 20 64 20 41   t2 ORDER BY d A
13f0: 53 43 20 4c 49 4d 49 54 20 31 20 4f 46 46 53 45  SC LIMIT 1 OFFSE
1400: 54 20 32 29 22 20 30 0a 20 20 20 20 31 30 20 22  T 2)" 0.    10 "
1410: 28 31 2c 20 4e 55 4c 4c 29 20 3d 20 28 53 45 4c  (1, NULL) = (SEL
1420: 45 43 54 20 62 2c 20 63 20 46 52 4f 4d 20 74 32  ECT b, c FROM t2
1430: 20 4f 52 44 45 52 20 42 59 20 64 20 41 53 43 20   ORDER BY d ASC 
1440: 4c 49 4d 49 54 20 31 20 4f 46 46 53 45 54 20 32  LIMIT 1 OFFSET 2
1450: 29 22 20 7b 7b 7d 7d 0a 0a 20 20 20 20 31 31 20  )" {{}}..    11 
1460: 22 28 33 2c 20 33 29 20 3d 20 28 53 45 4c 45 43  "(3, 3) = (SELEC
1470: 54 20 6d 61 78 28 61 29 2c 20 6d 61 78 28 62 29  T max(a), max(b)
1480: 20 46 52 4f 4d 20 74 32 29 22 20 31 0a 20 20 20   FROM t2)" 1.   
1490: 20 31 32 20 22 28 33 2c 20 31 29 20 3d 20 28 53   12 "(3, 1) = (S
14a0: 45 4c 45 43 54 20 6d 61 78 28 61 29 2c 20 6d 69  ELECT max(a), mi
14b0: 6e 28 62 29 20 46 52 4f 4d 20 74 32 29 22 20 31  n(b) FROM t2)" 1
14c0: 0a 20 20 20 20 31 33 20 22 28 4e 55 4c 4c 2c 20  .    13 "(NULL, 
14d0: 4e 55 4c 4c 29 20 3d 20 28 53 45 4c 45 43 54 20  NULL) = (SELECT 
14e0: 6d 61 78 28 61 29 2c 20 6d 69 6e 28 62 29 20 46  max(a), min(b) F
14f0: 52 4f 4d 20 74 32 29 22 20 7b 7b 7d 7d 0a 0a 20  ROM t2)" {{}}.. 
1500: 20 20 20 31 34 20 22 28 32 2c 20 31 29 20 49 4e     14 "(2, 1) IN
1510: 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20 46 52   (SELECT a, b FR
1520: 4f 4d 20 74 32 20 4f 52 44 45 52 20 42 59 20 64  OM t2 ORDER BY d
1530: 20 4c 49 4d 49 54 20 35 20 4f 46 46 53 45 54 20   LIMIT 5 OFFSET 
1540: 31 31 29 22 20 31 0a 20 20 20 20 31 35 20 22 28  11)" 1.    15 "(
1550: 32 2c 20 31 29 20 49 4e 20 28 53 45 4c 45 43 54  2, 1) IN (SELECT
1560: 20 61 2c 20 62 20 46 52 4f 4d 20 74 32 20 4f 52   a, b FROM t2 OR
1570: 44 45 52 20 42 59 20 64 20 4c 49 4d 49 54 20 35  DER BY d LIMIT 5
1580: 20 4f 46 46 53 45 54 20 31 32 29 22 20 30 0a 20   OFFSET 12)" 0. 
1590: 20 7d 20 7b 0a 20 20 20 20 64 6f 5f 65 78 65 63   } {.    do_exec
15a0: 73 71 6c 5f 74 65 73 74 20 32 2e 32 2e 24 6e 6d  sql_test 2.2.$nm
15b0: 2e 24 74 6e 20 22 53 45 4c 45 43 54 20 24 65 22  .$tn "SELECT $e"
15c0: 20 24 72 65 73 0a 20 20 7d 0a 7d 0a 0a 69 66 63   $res.  }.}..ifc
15d0: 61 70 61 62 6c 65 20 73 74 61 74 34 20 7b 0a 20  apable stat4 {. 
15e0: 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74   do_execsql_test
15f0: 20 33 2e 30 20 7b 0a 20 20 20 20 43 52 45 41 54   3.0 {.    CREAT
1600: 45 20 54 41 42 4c 45 20 63 31 28 61 2c 20 62 2c  E TABLE c1(a, b,
1610: 20 63 2c 20 64 29 3b 0a 20 20 20 20 49 4e 53 45   c, d);.    INSE
1620: 52 54 20 49 4e 54 4f 20 63 31 28 61 2c 20 62 29  RT INTO c1(a, b)
1630: 20 56 41 4c 55 45 53 28 31 2c 20 27 61 27 29 3b   VALUES(1, 'a');
1640: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1650: 20 63 31 28 61 2c 20 62 29 20 56 41 4c 55 45 53   c1(a, b) VALUES
1660: 28 31 2c 20 27 62 27 29 3b 0a 20 20 20 20 49 4e  (1, 'b');.    IN
1670: 53 45 52 54 20 49 4e 54 4f 20 63 31 28 61 2c 20  SERT INTO c1(a, 
1680: 62 29 20 56 41 4c 55 45 53 28 31 2c 20 27 63 27  b) VALUES(1, 'c'
1690: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
16a0: 54 4f 20 63 31 28 61 2c 20 62 29 20 56 41 4c 55  TO c1(a, b) VALU
16b0: 45 53 28 31 2c 20 27 64 27 29 3b 0a 20 20 20 20  ES(1, 'd');.    
16c0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 31 28 61  INSERT INTO c1(a
16d0: 2c 20 62 29 20 56 41 4c 55 45 53 28 31 2c 20 27  , b) VALUES(1, '
16e0: 65 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  e');.    INSERT 
16f0: 49 4e 54 4f 20 63 31 28 61 2c 20 62 29 20 56 41  INTO c1(a, b) VA
1700: 4c 55 45 53 28 31 2c 20 27 66 27 29 3b 0a 20 20  LUES(1, 'f');.  
1710: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 31    INSERT INTO c1
1720: 28 61 2c 20 62 29 20 56 41 4c 55 45 53 28 31 2c  (a, b) VALUES(1,
1730: 20 27 67 27 29 3b 0a 20 20 20 20 49 4e 53 45 52   'g');.    INSER
1740: 54 20 49 4e 54 4f 20 63 31 28 61 2c 20 62 29 20  T INTO c1(a, b) 
1750: 56 41 4c 55 45 53 28 31 2c 20 27 68 27 29 3b 0a  VALUES(1, 'h');.
1760: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1770: 63 31 28 61 2c 20 62 29 20 56 41 4c 55 45 53 28  c1(a, b) VALUES(
1780: 31 2c 20 27 69 27 29 3b 0a 20 20 20 20 49 4e 53  1, 'i');.    INS
1790: 45 52 54 20 49 4e 54 4f 20 63 31 28 61 2c 20 62  ERT INTO c1(a, b
17a0: 29 20 56 41 4c 55 45 53 28 31 2c 20 27 6a 27 29  ) VALUES(1, 'j')
17b0: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
17c0: 4f 20 63 31 28 61 2c 20 62 29 20 56 41 4c 55 45  O c1(a, b) VALUE
17d0: 53 28 31 2c 20 27 6b 27 29 3b 0a 20 20 20 20 49  S(1, 'k');.    I
17e0: 4e 53 45 52 54 20 49 4e 54 4f 20 63 31 28 61 2c  NSERT INTO c1(a,
17f0: 20 62 29 20 56 41 4c 55 45 53 28 31 2c 20 27 6c   b) VALUES(1, 'l
1800: 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  ');.    INSERT I
1810: 4e 54 4f 20 63 31 28 61 2c 20 62 29 20 56 41 4c  NTO c1(a, b) VAL
1820: 55 45 53 28 31 2c 20 27 6d 27 29 3b 0a 20 20 20  UES(1, 'm');.   
1830: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 31 28   INSERT INTO c1(
1840: 61 2c 20 62 29 20 56 41 4c 55 45 53 28 31 2c 20  a, b) VALUES(1, 
1850: 27 6e 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  'n');.    INSERT
1860: 20 49 4e 54 4f 20 63 31 28 61 2c 20 62 29 20 56   INTO c1(a, b) V
1870: 41 4c 55 45 53 28 31 2c 20 27 6f 27 29 3b 0a 20  ALUES(1, 'o');. 
1880: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 63     INSERT INTO c
1890: 31 28 61 2c 20 62 29 20 56 41 4c 55 45 53 28 31  1(a, b) VALUES(1
18a0: 2c 20 27 70 27 29 3b 0a 20 20 20 20 49 4e 53 45  , 'p');.    INSE
18b0: 52 54 20 49 4e 54 4f 20 63 31 28 61 2c 20 62 29  RT INTO c1(a, b)
18c0: 20 56 41 4c 55 45 53 28 32 2c 20 27 61 27 29 3b   VALUES(2, 'a');
18d0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
18e0: 20 63 31 28 61 2c 20 62 29 20 56 41 4c 55 45 53   c1(a, b) VALUES
18f0: 28 32 2c 20 27 62 27 29 3b 0a 20 20 20 20 49 4e  (2, 'b');.    IN
1900: 53 45 52 54 20 49 4e 54 4f 20 63 31 28 61 2c 20  SERT INTO c1(a, 
1910: 62 29 20 56 41 4c 55 45 53 28 32 2c 20 27 63 27  b) VALUES(2, 'c'
1920: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
1930: 54 4f 20 63 31 28 61 2c 20 62 29 20 56 41 4c 55  TO c1(a, b) VALU
1940: 45 53 28 32 2c 20 27 64 27 29 3b 0a 20 20 20 20  ES(2, 'd');.    
1950: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 31 28 61  INSERT INTO c1(a
1960: 2c 20 62 29 20 56 41 4c 55 45 53 28 32 2c 20 27  , b) VALUES(2, '
1970: 65 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  e');.    INSERT 
1980: 49 4e 54 4f 20 63 31 28 61 2c 20 62 29 20 56 41  INTO c1(a, b) VA
1990: 4c 55 45 53 28 32 2c 20 27 66 27 29 3b 0a 20 20  LUES(2, 'f');.  
19a0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 31    INSERT INTO c1
19b0: 28 61 2c 20 62 29 20 56 41 4c 55 45 53 28 32 2c  (a, b) VALUES(2,
19c0: 20 27 67 27 29 3b 0a 20 20 20 20 49 4e 53 45 52   'g');.    INSER
19d0: 54 20 49 4e 54 4f 20 63 31 28 61 2c 20 62 29 20  T INTO c1(a, b) 
19e0: 56 41 4c 55 45 53 28 32 2c 20 27 68 27 29 3b 0a  VALUES(2, 'h');.
19f0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1a00: 20 63 31 28 63 2c 20 64 29 20 53 45 4c 45 43 54   c1(c, d) SELECT
1a10: 20 61 2c 20 62 20 46 52 4f 4d 20 63 31 3b 0a 0a   a, b FROM c1;..
1a20: 20 20 20 20 43 52 45 41 54 45 20 49 4e 44 45 58      CREATE INDEX
1a30: 20 63 31 61 62 20 4f 4e 20 63 31 28 61 2c 20 62   c1ab ON c1(a, b
1a40: 29 3b 0a 20 20 20 20 43 52 45 41 54 45 20 49 4e  );.    CREATE IN
1a50: 44 45 58 20 63 31 63 64 20 4f 4e 20 63 31 28 63  DEX c1cd ON c1(c
1a60: 2c 20 64 29 3b 0a 20 20 20 20 41 4e 41 4c 59 5a  , d);.    ANALYZ
1a70: 45 3b 0a 20 20 7d 0a 0a 20 20 64 6f 5f 65 71 70  E;.  }..  do_eqp
1a80: 5f 74 65 73 74 20 33 2e 31 2e 31 20 7b 20 53 45  _test 3.1.1 { SE
1a90: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 63 31 20 57  LECT * FROM c1 W
1aa0: 48 45 52 45 20 61 3d 31 20 41 4e 44 20 63 3d 32  HERE a=1 AND c=2
1ab0: 20 7d 20 5c 0a 20 20 20 20 20 7b 53 45 41 52 43   } \.     {SEARC
1ac0: 48 20 54 41 42 4c 45 20 63 31 20 55 53 49 4e 47  H TABLE c1 USING
1ad0: 20 49 4e 44 45 58 20 63 31 63 64 20 28 63 3d 3f   INDEX c1cd (c=?
1ae0: 29 7d 0a 0a 20 20 64 6f 5f 65 71 70 5f 74 65 73  )}..  do_eqp_tes
1af0: 74 20 33 2e 31 2e 32 20 7b 20 53 45 4c 45 43 54  t 3.1.2 { SELECT
1b00: 20 2a 20 46 52 4f 4d 20 63 31 20 57 48 45 52 45   * FROM c1 WHERE
1b10: 20 61 3d 31 20 41 4e 44 20 62 3e 27 64 27 20 41   a=1 AND b>'d' A
1b20: 4e 44 20 63 3d 32 20 7d 20 5c 0a 20 20 20 20 20  ND c=2 } \.     
1b30: 7b 53 45 41 52 43 48 20 54 41 42 4c 45 20 63 31  {SEARCH TABLE c1
1b40: 20 55 53 49 4e 47 20 49 4e 44 45 58 20 63 31 63   USING INDEX c1c
1b50: 64 20 28 63 3d 3f 29 7d 0a 0a 20 20 64 6f 5f 65  d (c=?)}..  do_e
1b60: 71 70 5f 74 65 73 74 20 33 2e 31 2e 33 20 7b 20  qp_test 3.1.3 { 
1b70: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 63 31  SELECT * FROM c1
1b80: 20 57 48 45 52 45 20 61 3d 31 20 41 4e 44 20 62   WHERE a=1 AND b
1b90: 3e 27 6c 27 20 41 4e 44 20 63 3d 32 20 7d 20 5c  >'l' AND c=2 } \
1ba0: 0a 20 20 20 20 20 7b 53 45 41 52 43 48 20 54 41  .     {SEARCH TA
1bb0: 42 4c 45 20 63 31 20 55 53 49 4e 47 20 49 4e 44  BLE c1 USING IND
1bc0: 45 58 20 63 31 61 62 20 28 61 3d 3f 20 41 4e 44  EX c1ab (a=? AND
1bd0: 20 62 3e 3f 29 7d 0a 0a 20 20 64 6f 5f 65 71 70   b>?)}..  do_eqp
1be0: 5f 74 65 73 74 20 33 2e 32 2e 31 20 7b 20 53 45  _test 3.2.1 { SE
1bf0: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 63 31 20 57  LECT * FROM c1 W
1c00: 48 45 52 45 20 61 3d 31 20 41 4e 44 20 63 3e 31  HERE a=1 AND c>1
1c10: 20 7d 20 5c 0a 20 20 20 20 20 7b 53 45 41 52 43   } \.     {SEARC
1c20: 48 20 54 41 42 4c 45 20 63 31 20 55 53 49 4e 47  H TABLE c1 USING
1c30: 20 49 4e 44 45 58 20 63 31 63 64 20 28 63 3e 3f   INDEX c1cd (c>?
1c40: 29 7d 0a 0a 20 20 64 6f 5f 65 71 70 5f 74 65 73  )}..  do_eqp_tes
1c50: 74 20 33 2e 32 2e 32 20 7b 20 53 45 4c 45 43 54  t 3.2.2 { SELECT
1c60: 20 2a 20 46 52 4f 4d 20 63 31 20 57 48 45 52 45   * FROM c1 WHERE
1c70: 20 61 3d 31 20 41 4e 44 20 63 3e 30 20 7d 20 5c   a=1 AND c>0 } \
1c80: 0a 20 20 20 20 20 7b 53 45 41 52 43 48 20 54 41  .     {SEARCH TA
1c90: 42 4c 45 20 63 31 20 55 53 49 4e 47 20 49 4e 44  BLE c1 USING IND
1ca0: 45 58 20 63 31 61 62 20 28 61 3d 3f 29 7d 0a 0a  EX c1ab (a=?)}..
1cb0: 20 20 64 6f 5f 65 71 70 5f 74 65 73 74 20 33 2e    do_eqp_test 3.
1cc0: 32 2e 33 20 7b 20 53 45 4c 45 43 54 20 2a 20 46  2.3 { SELECT * F
1cd0: 52 4f 4d 20 63 31 20 57 48 45 52 45 20 61 3d 31  ROM c1 WHERE a=1
1ce0: 20 41 4e 44 20 63 3e 3d 31 20 7d 20 5c 0a 20 20   AND c>=1 } \.  
1cf0: 20 20 20 7b 53 45 41 52 43 48 20 54 41 42 4c 45     {SEARCH TABLE
1d00: 20 63 31 20 55 53 49 4e 47 20 49 4e 44 45 58 20   c1 USING INDEX 
1d10: 63 31 61 62 20 28 61 3d 3f 29 7d 0a 0a 20 20 64  c1ab (a=?)}..  d
1d20: 6f 5f 65 71 70 5f 74 65 73 74 20 33 2e 32 2e 34  o_eqp_test 3.2.4
1d30: 20 7b 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d   { SELECT * FROM
1d40: 20 63 31 20 57 48 45 52 45 20 61 3d 31 20 41 4e   c1 WHERE a=1 AN
1d50: 44 20 28 63 2c 20 64 29 3e 28 31 2c 20 27 63 27  D (c, d)>(1, 'c'
1d60: 29 20 7d 20 5c 0a 20 20 20 20 20 7b 53 45 41 52  ) } \.     {SEAR
1d70: 43 48 20 54 41 42 4c 45 20 63 31 20 55 53 49 4e  CH TABLE c1 USIN
1d80: 47 20 49 4e 44 45 58 20 63 31 61 62 20 28 61 3d  G INDEX c1ab (a=
1d90: 3f 29 7d 0a 0a 20 20 64 6f 5f 65 71 70 5f 74 65  ?)}..  do_eqp_te
1da0: 73 74 20 33 2e 32 2e 35 20 7b 20 53 45 4c 45 43  st 3.2.5 { SELEC
1db0: 54 20 2a 20 46 52 4f 4d 20 63 31 20 57 48 45 52  T * FROM c1 WHER
1dc0: 45 20 61 3d 31 20 41 4e 44 20 28 63 2c 20 64 29  E a=1 AND (c, d)
1dd0: 3e 28 31 2c 20 27 6f 27 29 20 7d 20 5c 0a 20 20  >(1, 'o') } \.  
1de0: 20 20 20 7b 53 45 41 52 43 48 20 54 41 42 4c 45     {SEARCH TABLE
1df0: 20 63 31 20 55 53 49 4e 47 20 49 4e 44 45 58 20   c1 USING INDEX 
1e00: 63 31 63 64 20 28 28 63 2c 64 29 3e 28 3f 2c 3f  c1cd ((c,d)>(?,?
1e10: 29 29 7d 0a 0a 20 20 64 6f 5f 65 71 70 5f 74 65  ))}..  do_eqp_te
1e20: 73 74 20 33 2e 32 2e 36 20 7b 20 53 45 4c 45 43  st 3.2.6 { SELEC
1e30: 54 20 2a 20 46 52 4f 4d 20 63 31 20 57 48 45 52  T * FROM c1 WHER
1e40: 45 20 61 3d 31 20 41 4e 44 20 28 63 2c 20 2b 62  E a=1 AND (c, +b
1e50: 29 3e 28 31 2c 20 27 63 27 29 20 7d 20 5c 0a 20  )>(1, 'c') } \. 
1e60: 20 20 20 20 7b 53 45 41 52 43 48 20 54 41 42 4c      {SEARCH TABL
1e70: 45 20 63 31 20 55 53 49 4e 47 20 49 4e 44 45 58  E c1 USING INDEX
1e80: 20 63 31 61 62 20 28 61 3d 3f 29 7d 0a 0a 7d 0a   c1ab (a=?)}..}.
1e90: 0a 23 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 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ed0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 0a 64 6f 5f 65  ----------..do_e
1ee0: 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 30 20  xecsql_test 5.0 
1ef0: 7b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  {.  CREATE TABLE
1f00: 20 64 31 28 78 2c 20 79 29 3b 0a 20 20 43 52 45   d1(x, y);.  CRE
1f10: 41 54 45 20 54 41 42 4c 45 20 64 32 28 61 2c 20  ATE TABLE d2(a, 
1f20: 62 2c 20 63 29 3b 0a 20 20 43 52 45 41 54 45 20  b, c);.  CREATE 
1f30: 49 4e 44 45 58 20 64 32 61 62 20 4f 4e 20 64 32  INDEX d2ab ON d2
1f40: 28 61 2c 20 62 29 3b 0a 20 20 43 52 45 41 54 45  (a, b);.  CREATE
1f50: 20 49 4e 44 45 58 20 64 32 63 20 4f 4e 20 64 32   INDEX d2c ON d2
1f60: 28 63 29 3b 0a 0a 20 20 57 49 54 48 20 69 28 69  (c);..  WITH i(i
1f70: 29 20 41 53 20 28 0a 20 20 20 20 56 41 4c 55 45  ) AS (.    VALUE
1f80: 53 28 31 29 20 55 4e 49 4f 4e 20 41 4c 4c 20 53  S(1) UNION ALL S
1f90: 45 4c 45 43 54 20 69 2b 31 20 46 52 4f 4d 20 69  ELECT i+1 FROM i
1fa0: 20 57 48 45 52 45 20 69 3c 31 30 30 30 0a 20 20   WHERE i<1000.  
1fb0: 29 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ).  INSERT INTO 
1fc0: 64 32 20 53 45 4c 45 43 54 20 69 2f 31 30 30 2c  d2 SELECT i/100,
1fd0: 20 69 25 31 30 30 2c 20 69 2f 31 30 30 20 46 52   i%100, i/100 FR
1fe0: 4f 4d 20 69 3b 0a 20 20 41 4e 41 4c 59 5a 45 3b  OM i;.  ANALYZE;
1ff0: 0a 7d 0a 0a 64 6f 5f 65 71 70 5f 74 65 73 74 20  .}..do_eqp_test 
2000: 35 2e 31 20 7b 0a 20 20 53 45 4c 45 43 54 20 2a  5.1 {.  SELECT *
2010: 20 46 52 4f 4d 20 64 32 20 57 48 45 52 45 20 0a   FROM d2 WHERE .
2020: 20 20 20 20 28 61 2c 20 62 29 20 49 4e 20 28 53      (a, b) IN (S
2030: 45 4c 45 43 54 20 78 2c 20 79 20 46 52 4f 4d 20  ELECT x, y FROM 
2040: 64 31 29 20 41 4e 44 0a 20 20 20 20 28 63 29 20  d1) AND.    (c) 
2050: 49 4e 20 28 53 45 4c 45 43 54 20 79 20 46 52 4f  IN (SELECT y FRO
2060: 4d 20 64 31 29 0a 7d 20 7b 0a 20 20 51 55 45 52  M d1).} {.  QUER
2070: 59 20 50 4c 41 4e 0a 20 20 7c 2d 2d 53 45 41 52  Y PLAN.  |--SEAR
2080: 43 48 20 54 41 42 4c 45 20 64 32 20 55 53 49 4e  CH TABLE d2 USIN
2090: 47 20 49 4e 44 45 58 20 64 32 61 62 20 28 61 3d  G INDEX d2ab (a=
20a0: 3f 20 41 4e 44 20 62 3d 3f 29 0a 20 20 7c 2d 2d  ? AND b=?).  |--
20b0: 4c 49 53 54 20 53 55 42 51 55 45 52 59 0a 20 20  LIST SUBQUERY.  
20c0: 7c 20 20 60 2d 2d 53 43 41 4e 20 54 41 42 4c 45  |  `--SCAN TABLE
20d0: 20 64 31 0a 20 20 60 2d 2d 4c 49 53 54 20 53 55   d1.  `--LIST SU
20e0: 42 51 55 45 52 59 0a 20 20 20 20 20 60 2d 2d 53  BQUERY.     `--S
20f0: 43 41 4e 20 54 41 42 4c 45 20 64 31 0a 7d 0a 0a  CAN TABLE d1.}..
2100: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
2110: 36 2e 30 20 7b 0a 20 20 43 52 45 41 54 45 20 54  6.0 {.  CREATE T
2120: 41 42 4c 45 20 65 31 28 61 2c 20 62 2c 20 63 2c  ABLE e1(a, b, c,
2130: 20 64 2c 20 65 29 3b 0a 20 20 43 52 45 41 54 45   d, e);.  CREATE
2140: 20 49 4e 44 45 58 20 65 31 61 62 20 4f 4e 20 65   INDEX e1ab ON e
2150: 31 28 61 2c 20 62 29 3b 0a 20 20 43 52 45 41 54  1(a, b);.  CREAT
2160: 45 20 49 4e 44 45 58 20 65 31 63 64 65 20 4f 4e  E INDEX e1cde ON
2170: 20 65 31 28 63 2c 20 64 2c 20 65 29 3b 0a 7d 0a   e1(c, d, e);.}.
2180: 0a 64 6f 5f 65 71 70 5f 74 65 73 74 20 36 2e 31  .do_eqp_test 6.1
2190: 20 7b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52   {.  SELECT * FR
21a0: 4f 4d 20 65 31 20 57 48 45 52 45 20 28 61 2c 20  OM e1 WHERE (a, 
21b0: 62 29 20 3e 20 28 3f 2c 20 3f 29 0a 7d 20 7b 53  b) > (?, ?).} {S
21c0: 45 41 52 43 48 20 54 41 42 4c 45 20 65 31 20 55  EARCH TABLE e1 U
21d0: 53 49 4e 47 20 49 4e 44 45 58 20 65 31 61 62 20  SING INDEX e1ab 
21e0: 28 28 61 2c 62 29 3e 28 3f 2c 3f 29 29 7d 0a 0a  ((a,b)>(?,?))}..
21f0: 64 6f 5f 65 71 70 5f 74 65 73 74 20 36 2e 32 20  do_eqp_test 6.2 
2200: 7b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  {.  SELECT * FRO
2210: 4d 20 65 31 20 57 48 45 52 45 20 28 61 2c 20 62  M e1 WHERE (a, b
2220: 29 20 3c 20 28 3f 2c 20 3f 29 0a 7d 20 7b 53 45  ) < (?, ?).} {SE
2230: 41 52 43 48 20 54 41 42 4c 45 20 65 31 20 55 53  ARCH TABLE e1 US
2240: 49 4e 47 20 49 4e 44 45 58 20 65 31 61 62 20 28  ING INDEX e1ab (
2250: 28 61 2c 62 29 3c 28 3f 2c 3f 29 29 7d 0a 0a 64  (a,b)<(?,?))}..d
2260: 6f 5f 65 71 70 5f 74 65 73 74 20 36 2e 33 20 7b  o_eqp_test 6.3 {
2270: 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
2280: 20 65 31 20 57 48 45 52 45 20 63 20 3d 20 3f 20   e1 WHERE c = ? 
2290: 41 4e 44 20 28 64 2c 20 65 29 20 3e 20 28 3f 2c  AND (d, e) > (?,
22a0: 20 3f 29 0a 7d 20 7b 53 45 41 52 43 48 20 54 41   ?).} {SEARCH TA
22b0: 42 4c 45 20 65 31 20 55 53 49 4e 47 20 49 4e 44  BLE e1 USING IND
22c0: 45 58 20 65 31 63 64 65 20 28 63 3d 3f 20 41 4e  EX e1cde (c=? AN
22d0: 44 20 28 64 2c 65 29 3e 28 3f 2c 3f 29 29 7d 0a  D (d,e)>(?,?))}.
22e0: 0a 64 6f 5f 65 71 70 5f 74 65 73 74 20 36 2e 34  .do_eqp_test 6.4
22f0: 20 7b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52   {.  SELECT * FR
2300: 4f 4d 20 65 31 20 57 48 45 52 45 20 63 20 3d 20  OM e1 WHERE c = 
2310: 3f 20 41 4e 44 20 28 64 2c 20 65 29 20 3c 20 28  ? AND (d, e) < (
2320: 3f 2c 20 3f 29 0a 7d 20 7b 53 45 41 52 43 48 20  ?, ?).} {SEARCH 
2330: 54 41 42 4c 45 20 65 31 20 55 53 49 4e 47 20 49  TABLE e1 USING I
2340: 4e 44 45 58 20 65 31 63 64 65 20 28 63 3d 3f 20  NDEX e1cde (c=? 
2350: 41 4e 44 20 28 64 2c 65 29 3c 28 3f 2c 3f 29 29  AND (d,e)<(?,?))
2360: 7d 0a 0a 64 6f 5f 65 71 70 5f 74 65 73 74 20 36  }..do_eqp_test 6
2370: 2e 35 20 7b 0a 20 20 53 45 4c 45 43 54 20 2a 20  .5 {.  SELECT * 
2380: 46 52 4f 4d 20 65 31 20 57 48 45 52 45 20 28 64  FROM e1 WHERE (d
2390: 2c 20 65 29 20 42 45 54 57 45 45 4e 20 28 3f 2c  , e) BETWEEN (?,
23a0: 20 3f 29 20 41 4e 44 20 28 3f 2c 20 3f 29 20 41   ?) AND (?, ?) A
23b0: 4e 44 20 63 20 3d 20 3f 0a 7d 20 7b 53 45 41 52  ND c = ?.} {SEAR
23c0: 43 48 20 54 41 42 4c 45 20 65 31 20 55 53 49 4e  CH TABLE e1 USIN
23d0: 47 20 49 4e 44 45 58 20 65 31 63 64 65 20 28 63  G INDEX e1cde (c
23e0: 3d 3f 20 41 4e 44 20 28 64 2c 65 29 3e 28 3f 2c  =? AND (d,e)>(?,
23f0: 3f 29 20 41 4e 44 20 28 64 2c 65 29 3c 28 3f 2c  ?) AND (d,e)<(?,
2400: 3f 29 29 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  ?))}..#---------
2410: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2420: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2430: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2440: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2450: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
2460: 74 20 37 2e 31 20 7b 0a 20 20 43 52 45 41 54 45  t 7.1 {.  CREATE
2470: 20 54 41 42 4c 45 20 66 31 28 61 2c 20 62 2c 20   TABLE f1(a, b, 
2480: 63 29 3b 0a 20 20 43 52 45 41 54 45 20 49 4e 44  c);.  CREATE IND
2490: 45 58 20 66 31 61 62 20 4f 4e 20 66 31 28 61 2c  EX f1ab ON f1(a,
24a0: 20 62 29 3b 0a 7d 0a 0a 64 6f 5f 63 61 74 63 68   b);.}..do_catch
24b0: 73 71 6c 5f 74 65 73 74 20 37 2e 32 20 7b 0a 20  sql_test 7.2 {. 
24c0: 20 53 45 4c 45 43 54 20 28 61 20 43 4f 4c 4c 41   SELECT (a COLLA
24d0: 54 45 20 6e 6f 63 61 73 65 2c 20 62 29 20 49 4e  TE nocase, b) IN
24e0: 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20 46 52   (SELECT a, b FR
24f0: 4f 4d 20 66 31 29 20 46 52 4f 4d 20 66 31 3b 0a  OM f1) FROM f1;.
2500: 7d 20 7b 30 20 7b 7d 7d 0a 0a 64 6f 5f 63 61 74  } {0 {}}..do_cat
2510: 63 68 73 71 6c 5f 74 65 73 74 20 37 2e 33 20 7b  chsql_test 7.3 {
2520: 0a 20 20 53 45 4c 45 43 54 20 28 61 20 43 4f 4c  .  SELECT (a COL
2530: 4c 41 54 45 20 6e 6f 73 65 2c 20 62 29 20 49 4e  LATE nose, b) IN
2540: 20 28 53 45 4c 45 43 54 20 61 2c 20 62 20 46 52   (SELECT a, b FR
2550: 4f 4d 20 66 31 29 20 46 52 4f 4d 20 66 31 3b 0a  OM f1) FROM f1;.
2560: 7d 20 7b 31 20 7b 6e 6f 20 73 75 63 68 20 63 6f  } {1 {no such co
2570: 6c 6c 61 74 69 6f 6e 20 73 65 71 75 65 6e 63 65  llation sequence
2580: 3a 20 6e 6f 73 65 7d 7d 0a 0a 64 6f 5f 63 61 74  : nose}}..do_cat
2590: 63 68 73 71 6c 5f 74 65 73 74 20 37 2e 34 20 7b  chsql_test 7.4 {
25a0: 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
25b0: 20 66 31 20 57 48 45 52 45 20 28 3f 2c 20 3f 20   f1 WHERE (?, ? 
25c0: 43 4f 4c 4c 41 54 45 20 6e 6f 73 65 29 20 3e 20  COLLATE nose) > 
25d0: 28 61 2c 20 62 29 3b 0a 7d 20 7b 31 20 7b 6e 6f  (a, b);.} {1 {no
25e0: 20 73 75 63 68 20 63 6f 6c 6c 61 74 69 6f 6e 20   such collation 
25f0: 73 65 71 75 65 6e 63 65 3a 20 6e 6f 73 65 7d 7d  sequence: nose}}
2600: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
2610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 64 72 6f  ------------.dro
2650: 70 5f 61 6c 6c 5f 74 61 62 6c 65 73 0a 64 6f 5f  p_all_tables.do_
2660: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 38 2e 31  execsql_test 8.1
2670: 20 7b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c   {.  CREATE TABL
2680: 45 20 63 31 28 78 2c 20 79 29 3b 0a 20 20 43 52  E c1(x, y);.  CR
2690: 45 41 54 45 20 54 41 42 4c 45 20 63 32 28 61 2c  EATE TABLE c2(a,
26a0: 20 62 2c 20 63 29 3b 0a 20 20 43 52 45 41 54 45   b, c);.  CREATE
26b0: 20 49 4e 44 45 58 20 63 32 61 62 20 4f 4e 20 63   INDEX c2ab ON c
26c0: 32 28 61 2c 20 62 29 3b 0a 20 20 43 52 45 41 54  2(a, b);.  CREAT
26d0: 45 20 49 4e 44 45 58 20 63 32 63 20 4f 4e 20 63  E INDEX c2c ON c
26e0: 32 28 63 29 3b 0a 0a 20 20 43 52 45 41 54 45 20  2(c);..  CREATE 
26f0: 54 41 42 4c 45 20 63 33 28 64 29 3b 0a 7d 0a 64  TABLE c3(d);.}.d
2700: 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65 73 74 20  o_catchsql_test 
2710: 38 2e 32 20 7b 0a 20 20 53 45 4c 45 43 54 20 2a  8.2 {.  SELECT *
2720: 20 46 52 4f 4d 20 63 32 20 43 52 4f 53 53 20 4a   FROM c2 CROSS J
2730: 4f 49 4e 20 63 33 20 57 48 45 52 45 20 0a 20 20  OIN c3 WHERE .  
2740: 20 20 28 20 28 61 2c 20 62 29 20 3d 3d 20 28 53    ( (a, b) == (S
2750: 45 4c 45 43 54 20 78 2c 20 79 20 46 52 4f 4d 20  ELECT x, y FROM 
2760: 63 31 29 20 41 4e 44 20 63 33 2e 64 20 3d 20 63  c1) AND c3.d = c
2770: 20 29 20 4f 52 0a 20 20 20 20 28 20 63 20 3d 3d   ) OR.    ( c ==
2780: 20 28 53 45 4c 45 43 54 20 78 2c 20 79 20 46 52   (SELECT x, y FR
2790: 4f 4d 20 63 31 29 20 41 4e 44 20 63 33 2e 64 20  OM c1) AND c3.d 
27a0: 3d 20 63 20 29 0a 7d 20 7b 31 20 7b 72 6f 77 20  = c ).} {1 {row 
27b0: 76 61 6c 75 65 20 6d 69 73 75 73 65 64 7d 7d 0a  value misused}}.
27c0: 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a           .finish_test.