/ Hex Artifact Content
Login

Artifact cd23d4072ea095d652c9b6db12284cc642e49c98:


0000: 23 20 32 30 31 35 20 53 65 70 74 65 6d 62 65 72  # 2015 September
0010: 20 30 35 0a 23 0a 23 20 54 68 65 20 61 75 74 68   05.#.# The auth
0020: 6f 72 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70  or disclaims cop
0030: 79 72 69 67 68 74 20 74 6f 20 74 68 69 73 20 73  yright to this s
0040: 6f 75 72 63 65 20 63 6f 64 65 2e 20 20 49 6e 20  ource code.  In 
0050: 70 6c 61 63 65 20 6f 66 0a 23 20 61 20 6c 65 67  place of.# a leg
0060: 61 6c 20 6e 6f 74 69 63 65 2c 20 68 65 72 65 20  al notice, here 
0070: 69 73 20 61 20 62 6c 65 73 73 69 6e 67 3a 0a 23  is a blessing:.#
0080: 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20 64 6f  .#    May you do
0090: 20 67 6f 6f 64 20 61 6e 64 20 6e 6f 74 20 65 76   good and not ev
00a0: 69 6c 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75  il..#    May you
00b0: 20 66 69 6e 64 20 66 6f 72 67 69 76 65 6e 65 73   find forgivenes
00c0: 73 20 66 6f 72 20 79 6f 75 72 73 65 6c 66 20 61  s for yourself a
00d0: 6e 64 20 66 6f 72 67 69 76 65 20 6f 74 68 65 72  nd forgive other
00e0: 73 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20  s..#    May you 
00f0: 73 68 61 72 65 20 66 72 65 65 6c 79 2c 20 6e 65  share freely, ne
0100: 76 65 72 20 74 61 6b 69 6e 67 20 6d 6f 72 65 20  ver taking more 
0110: 74 68 61 6e 20 79 6f 75 20 67 69 76 65 2e 0a 23  than you give..#
0120: 0a 23 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 2a 2a 2a 2a 2a 2a 2a 0a 23 0a 0a 73  ***********.#..s
0170: 6f 75 72 63 65 20 5b 66 69 6c 65 20 6a 6f 69 6e  ource [file join
0180: 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 5b   [file dirname [
0190: 69 6e 66 6f 20 73 63 72 69 70 74 5d 5d 20 66 74  info script]] ft
01a0: 73 35 5f 63 6f 6d 6d 6f 6e 2e 74 63 6c 5d 0a 73  s5_common.tcl].s
01b0: 65 74 20 74 65 73 74 70 72 65 66 69 78 20 66 74  et testprefix ft
01c0: 73 35 73 69 6d 70 6c 65 0a 0a 23 20 49 66 20 53  s5simple..# If S
01d0: 51 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 46 54 53  QLITE_ENABLE_FTS
01e0: 35 20 69 73 20 64 65 66 69 6e 65 64 2c 20 6f 6d  5 is defined, om
01f0: 69 74 20 74 68 69 73 20 66 69 6c 65 2e 0a 69 66  it this file..if
0200: 63 61 70 61 62 6c 65 20 21 66 74 73 35 20 7b 0a  capable !fts5 {.
0210: 20 20 66 69 6e 69 73 68 5f 74 65 73 74 0a 20 20    finish_test.  
0220: 72 65 74 75 72 6e 0a 7d 0a 0a 69 66 20 31 20 7b  return.}..if 1 {
0230: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
0240: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0250: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0270: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 0a 73  ------------.#.s
0280: 65 74 20 64 6f 63 20 22 78 20 78 20 5b 73 74 72  et doc "x x [str
0290: 69 6e 67 20 72 65 70 65 61 74 20 7b 79 20 7d 20  ing repeat {y } 
02a0: 35 30 5d 7a 20 7a 22 0a 64 6f 5f 65 78 65 63 73  50]z z".do_execs
02b0: 71 6c 5f 74 65 73 74 20 31 2e 30 20 7b 0a 20 20  ql_test 1.0 {.  
02c0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
02d0: 41 42 4c 45 20 74 31 20 55 53 49 4e 47 20 66 74  ABLE t1 USING ft
02e0: 73 35 28 78 29 3b 0a 20 20 49 4e 53 45 52 54 20  s5(x);.  INSERT 
02f0: 49 4e 54 4f 20 74 31 28 74 31 2c 20 72 61 6e 6b  INTO t1(t1, rank
0300: 29 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27 2c  ) VALUES('pgsz',
0310: 20 33 32 29 3b 0a 20 20 42 45 47 49 4e 3b 0a 20   32);.  BEGIN;. 
0320: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74     INSERT INTO t
0330: 31 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b 0a  1 VALUES($doc);.
0340: 20 20 43 4f 4d 4d 49 54 3b 0a 7d 0a 0a 64 6f 5f    COMMIT;.}..do_
0350: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 2e 31  execsql_test 1.1
0360: 20 7b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f   {.  INSERT INTO
0370: 20 74 31 28 74 31 29 20 56 41 4c 55 45 53 28 27   t1(t1) VALUES('
0380: 69 6e 74 65 67 72 69 74 79 2d 63 68 65 63 6b 27  integrity-check'
0390: 29 3b 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  );.}..#---------
03a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
03e0: 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f 65  .#.reset_db.do_e
03f0: 78 65 63 73 71 6c 5f 74 65 73 74 20 32 2e 30 20  xecsql_test 2.0 
0400: 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55  {.  CREATE VIRTU
0410: 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49 4e  AL TABLE t1 USIN
0420: 47 20 66 74 73 35 28 78 29 3b 0a 20 20 49 4e 53  G fts5(x);.  INS
0430: 45 52 54 20 49 4e 54 4f 20 74 31 28 74 31 2c 20  ERT INTO t1(t1, 
0440: 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67  rank) VALUES('pg
0450: 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53 45  sz', 32);.  INSE
0460: 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55 45  RT INTO t1 VALUE
0470: 53 28 27 61 20 62 20 63 27 29 3b 0a 20 20 49 4e  S('a b c');.  IN
0480: 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c  SERT INTO t1 VAL
0490: 55 45 53 28 27 64 20 65 20 66 27 29 3b 0a 20 20  UES('d e f');.  
04a0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 74  INSERT INTO t1(t
04b0: 31 29 20 56 41 4c 55 45 53 28 27 6f 70 74 69 6d  1) VALUES('optim
04c0: 69 7a 65 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65  ize');.}..do_exe
04d0: 63 73 71 6c 5f 74 65 73 74 20 32 2e 31 20 7b 0a  csql_test 2.1 {.
04e0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
04f0: 28 74 31 29 20 56 41 4c 55 45 53 28 27 69 6e 74  (t1) VALUES('int
0500: 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29 3b 0a  egrity-check');.
0510: 7d 20 7b 7d 0a 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d  } {}...#--------
0520: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0530: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0540: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0550: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0560: 2d 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f  -.#.reset_db.do_
0570: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 33 2e 30  execsql_test 3.0
0580: 20 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54   {.  CREATE VIRT
0590: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49  UAL TABLE t1 USI
05a0: 4e 47 20 66 74 73 35 28 78 2c 20 70 72 65 66 69  NG fts5(x, prefi
05b0: 78 3d 27 31 2c 32 27 29 3b 0a 20 20 49 4e 53 45  x='1,2');.  INSE
05c0: 52 54 20 49 4e 54 4f 20 74 31 28 74 31 2c 20 72  RT INTO t1(t1, r
05d0: 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67 73  ank) VALUES('pgs
05e0: 7a 27 2c 20 33 32 29 3b 0a 20 20 42 45 47 49 4e  z', 32);.  BEGIN
05f0: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
0600: 74 31 20 56 41 4c 55 45 53 28 27 6f 6e 65 27 29  t1 VALUES('one')
0610: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
0620: 4d 20 74 31 20 57 48 45 52 45 20 74 31 20 4d 41  M t1 WHERE t1 MA
0630: 54 43 48 20 27 6f 2a 27 3b 0a 7d 20 7b 6f 6e 65  TCH 'o*';.} {one
0640: 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  }..do_execsql_te
0650: 73 74 20 33 2e 31 20 7b 0a 20 20 49 4e 53 45 52  st 3.1 {.  INSER
0660: 54 20 49 4e 54 4f 20 74 31 28 74 31 29 20 56 41  T INTO t1(t1) VA
0670: 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d  LUES('integrity-
0680: 63 68 65 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a 23  check');.} {}..#
0690: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
06d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74 5f  ---------.reset_
06e0: 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  db.do_execsql_te
06f0: 73 74 20 34 2e 31 20 7b 0a 20 20 43 52 45 41 54  st 4.1 {.  CREAT
0700: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20  E VIRTUAL TABLE 
0710: 74 31 31 20 55 53 49 4e 47 20 66 74 73 35 28 63  t11 USING fts5(c
0720: 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52  ontent);.  INSER
0730: 54 20 49 4e 54 4f 20 74 31 31 28 74 31 31 2c 20  T INTO t11(t11, 
0740: 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67  rank) VALUES('pg
0750: 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53 45  sz', 32);.  INSE
0760: 52 54 20 49 4e 54 4f 20 74 31 31 20 56 41 4c 55  RT INTO t11 VALU
0770: 45 53 28 27 61 6e 6f 74 68 65 72 27 29 3b 0a 20  ES('another');. 
0780: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 31   INSERT INTO t11
0790: 20 56 41 4c 55 45 53 28 27 73 74 72 69 6e 67 27   VALUES('string'
07a0: 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
07b0: 20 74 31 31 20 56 41 4c 55 45 53 28 27 6f 66 27   t11 VALUES('of'
07c0: 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
07d0: 20 74 31 31 20 56 41 4c 55 45 53 28 27 74 65 78   t11 VALUES('tex
07e0: 74 27 29 3b 0a 7d 0a 64 6f 5f 74 65 73 74 20 34  t');.}.do_test 4
07f0: 2e 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 7b  .2 {.  execsql {
0800: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 31   INSERT INTO t11
0810: 28 74 31 31 29 20 56 41 4c 55 45 53 28 27 6f 70  (t11) VALUES('op
0820: 74 69 6d 69 7a 65 27 29 20 7d 0a 7d 20 7b 7d 0a  timize') }.} {}.
0830: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
0840: 34 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54 20 49  4.3 {.  INSERT I
0850: 4e 54 4f 20 74 31 31 28 74 31 31 29 20 56 41 4c  NTO t11(t11) VAL
0860: 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d 63  UES('integrity-c
0870: 68 65 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a 23 64  heck');.} {}..#d
0880: 62 20 65 76 61 6c 20 7b 20 53 45 4c 45 43 54 20  b eval { SELECT 
0890: 66 74 73 35 5f 64 65 63 6f 64 65 28 72 6f 77 69  fts5_decode(rowi
08a0: 64 2c 20 62 6c 6f 63 6b 29 20 61 73 20 78 20 46  d, block) as x F
08b0: 52 4f 4d 20 74 31 31 5f 64 61 74 61 20 7d 20 7b  ROM t11_data } {
08c0: 20 70 75 74 73 20 24 78 20 7d 0a 0a 23 2d 2d 2d   puts $x }..#---
08d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
08e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
08f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0900: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0910: 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74 5f 64 62 0a  ------.reset_db.
0920: 73 65 74 20 64 6f 63 20 5b 73 74 72 69 6e 67 20  set doc [string 
0930: 72 65 70 65 61 74 20 22 78 20 79 20 22 20 35 5d  repeat "x y " 5]
0940: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
0950: 20 35 2e 31 20 7b 0a 20 20 43 52 45 41 54 45 20   5.1 {.  CREATE 
0960: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 79 79  VIRTUAL TABLE yy
0970: 20 55 53 49 4e 47 20 66 74 73 35 28 63 6f 6e 74   USING fts5(cont
0980: 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  ent);.  INSERT I
0990: 4e 54 4f 20 79 79 28 79 79 2c 20 72 61 6e 6b 29  NTO yy(yy, rank)
09a0: 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27 2c 20   VALUES('pgsz', 
09b0: 33 32 29 3b 0a 20 20 42 45 47 49 4e 3b 0a 20 20  32);.  BEGIN;.  
09c0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 79 79    INSERT INTO yy
09d0: 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b 0a 20   VALUES($doc);. 
09e0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 79     INSERT INTO y
09f0: 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b 0a  y VALUES($doc);.
0a00: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
0a10: 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b  yy VALUES($doc);
0a20: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
0a30: 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29   yy VALUES($doc)
0a40: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
0a50: 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63  O yy VALUES($doc
0a60: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
0a70: 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f  TO yy VALUES($do
0a80: 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  c);.    INSERT I
0a90: 4e 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64  NTO yy VALUES($d
0aa0: 6f 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  oc);.    INSERT 
0ab0: 49 4e 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24  INTO yy VALUES($
0ac0: 64 6f 63 29 3b 0a 20 20 43 4f 4d 4d 49 54 3b 0a  doc);.  COMMIT;.
0ad0: 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  }..do_execsql_te
0ae0: 73 74 20 35 2e 32 20 7b 0a 20 20 53 45 4c 45 43  st 5.2 {.  SELEC
0af0: 54 20 72 6f 77 69 64 20 46 52 4f 4d 20 79 79 20  T rowid FROM yy 
0b00: 57 48 45 52 45 20 79 79 20 4d 41 54 43 48 20 27  WHERE yy MATCH '
0b10: 79 27 20 4f 52 44 45 52 20 42 59 20 72 6f 77 69  y' ORDER BY rowi
0b20: 64 20 41 53 43 0a 7d 20 7b 31 20 32 20 33 20 34  d ASC.} {1 2 3 4
0b30: 20 35 20 36 20 37 20 38 7d 0a 0a 64 6f 5f 65 78   5 6 7 8}..do_ex
0b40: 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 33 20 7b  ecsql_test 5.3 {
0b50: 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 20  .  SELECT rowid 
0b60: 46 52 4f 4d 20 79 79 20 57 48 45 52 45 20 79 79  FROM yy WHERE yy
0b70: 20 4d 41 54 43 48 20 27 79 27 20 4f 52 44 45 52   MATCH 'y' ORDER
0b80: 20 42 59 20 72 6f 77 69 64 20 44 45 53 43 0a 7d   BY rowid DESC.}
0b90: 20 7b 38 20 37 20 36 20 35 20 34 20 33 20 32 20   {8 7 6 5 4 3 2 
0ba0: 31 7d 0a 0a 23 64 62 20 65 76 61 6c 20 7b 20 53  1}..#db eval { S
0bb0: 45 4c 45 43 54 20 66 74 73 35 5f 64 65 63 6f 64  ELECT fts5_decod
0bc0: 65 28 72 6f 77 69 64 2c 20 62 6c 6f 63 6b 29 20  e(rowid, block) 
0bd0: 61 73 20 78 20 46 52 4f 4d 20 79 79 5f 64 61 74  as x FROM yy_dat
0be0: 61 20 7d 20 7b 20 70 75 74 73 20 24 78 20 7d 0a  a } { puts $x }.
0bf0: 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .#--------------
0c00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0c30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73 65  -----------.rese
0c40: 74 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f  t_db.do_execsql_
0c50: 74 65 73 74 20 35 2e 31 20 7b 0a 20 20 43 52 45  test 5.1 {.  CRE
0c60: 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c  ATE VIRTUAL TABL
0c70: 45 20 74 74 20 55 53 49 4e 47 20 66 74 73 35 28  E tt USING fts5(
0c80: 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45  content);.  INSE
0c90: 52 54 20 49 4e 54 4f 20 74 74 28 74 74 2c 20 72  RT INTO tt(tt, r
0ca0: 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67 73  ank) VALUES('pgs
0cb0: 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53 45 52  z', 32);.  INSER
0cc0: 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53  T INTO tt VALUES
0cd0: 28 27 61 61 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78  ('aa');.}..do_ex
0ce0: 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 32 20 7b  ecsql_test 5.2 {
0cf0: 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 20  .  SELECT rowid 
0d00: 46 52 4f 4d 20 74 74 20 57 48 45 52 45 20 74 74  FROM tt WHERE tt
0d10: 20 4d 41 54 43 48 20 27 61 2a 27 3b 0a 7d 20 7b   MATCH 'a*';.} {
0d20: 31 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  1}..do_execsql_t
0d30: 65 73 74 20 35 2e 33 20 7b 0a 20 20 44 45 4c 45  est 5.3 {.  DELE
0d40: 54 45 20 46 52 4f 4d 20 74 74 3b 0a 20 20 42 45  TE FROM tt;.  BE
0d50: 47 49 4e 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  GIN;.    INSERT 
0d60: 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27  INTO tt VALUES('
0d70: 61 61 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  aa');.    INSERT
0d80: 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28   INTO tt VALUES(
0d90: 27 61 62 27 29 3b 0a 20 20 43 4f 4d 4d 49 54 3b  'ab');.  COMMIT;
0da0: 0a 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71  .} {}..do_execsq
0db0: 6c 5f 74 65 73 74 20 35 2e 34 20 7b 0a 20 20 53  l_test 5.4 {.  S
0dc0: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
0dd0: 20 74 74 20 57 48 45 52 45 20 74 74 20 4d 41 54   tt WHERE tt MAT
0de0: 43 48 20 27 61 2a 27 3b 0a 7d 20 7b 31 20 32 7d  CH 'a*';.} {1 2}
0df0: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
0e00: 74 20 35 2e 35 20 7b 0a 20 20 44 45 4c 45 54 45  t 5.5 {.  DELETE
0e10: 20 46 52 4f 4d 20 74 74 3b 0a 20 20 42 45 47 49   FROM tt;.  BEGI
0e20: 4e 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  N;.    INSERT IN
0e30: 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27 61 61  TO tt VALUES('aa
0e40: 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  ');.    INSERT I
0e50: 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27 61  NTO tt VALUES('a
0e60: 62 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  b');.    INSERT 
0e70: 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27  INTO tt VALUES('
0e80: 61 61 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  aa');.    INSERT
0e90: 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28   INTO tt VALUES(
0ea0: 27 61 62 27 29 3b 0a 20 20 20 20 49 4e 53 45 52  'ab');.    INSER
0eb0: 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53  T INTO tt VALUES
0ec0: 28 27 61 61 27 29 3b 0a 20 20 20 20 49 4e 53 45  ('aa');.    INSE
0ed0: 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45  RT INTO tt VALUE
0ee0: 53 28 27 61 62 27 29 3b 0a 20 20 20 20 49 4e 53  S('ab');.    INS
0ef0: 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55  ERT INTO tt VALU
0f00: 45 53 28 27 61 61 27 29 3b 0a 20 20 20 20 49 4e  ES('aa');.    IN
0f10: 53 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c  SERT INTO tt VAL
0f20: 55 45 53 28 27 61 62 27 29 3b 0a 20 20 43 4f 4d  UES('ab');.  COM
0f30: 4d 49 54 3b 0a 20 20 53 45 4c 45 43 54 20 72 6f  MIT;.  SELECT ro
0f40: 77 69 64 20 46 52 4f 4d 20 74 74 20 57 48 45 52  wid FROM tt WHER
0f50: 45 20 74 74 20 4d 41 54 43 48 20 27 61 2a 27 3b  E tt MATCH 'a*';
0f60: 0a 7d 20 7b 31 20 32 20 33 20 34 20 35 20 36 20  .} {1 2 3 4 5 6 
0f70: 37 20 38 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c  7 8}..do_execsql
0f80: 5f 74 65 73 74 20 35 2e 36 20 7b 0a 20 20 49 4e  _test 5.6 {.  IN
0f90: 53 45 52 54 20 49 4e 54 4f 20 74 74 28 74 74 29  SERT INTO tt(tt)
0fa0: 20 56 41 4c 55 45 53 28 27 69 6e 74 65 67 72 69   VALUES('integri
0fb0: 74 79 2d 63 68 65 63 6b 27 29 3b 0a 7d 0a 0a 72  ty-check');.}..r
0fc0: 65 73 65 74 5f 64 62 0a 64 6f 5f 65 78 65 63 73  eset_db.do_execs
0fd0: 71 6c 5f 74 65 73 74 20 35 2e 37 20 7b 0a 20 20  ql_test 5.7 {.  
0fe0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
0ff0: 41 42 4c 45 20 74 74 20 55 53 49 4e 47 20 66 74  ABLE tt USING ft
1000: 73 35 28 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 49  s5(content);.  I
1010: 4e 53 45 52 54 20 49 4e 54 4f 20 74 74 28 74 74  NSERT INTO tt(tt
1020: 2c 20 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27  , rank) VALUES('
1030: 70 67 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e  pgsz', 32);.  IN
1040: 53 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c  SERT INTO tt VAL
1050: 55 45 53 28 27 61 61 20 61 62 20 61 63 20 61 64  UES('aa ab ac ad
1060: 20 61 65 20 61 66 27 29 3b 0a 7d 0a 0a 64 6f 5f   ae af');.}..do_
1070: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 38  execsql_test 5.8
1080: 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69   {.  SELECT rowi
1090: 64 20 46 52 4f 4d 20 74 74 20 57 48 45 52 45 20  d FROM tt WHERE 
10a0: 74 74 20 4d 41 54 43 48 20 27 61 2a 27 3b 0a 7d  tt MATCH 'a*';.}
10b0: 20 7b 31 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d   {1}..#---------
10c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
10d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
10e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
10f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1100: 0a 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f 65 78  ..reset_db.do_ex
1110: 65 63 73 71 6c 5f 74 65 73 74 20 36 2e 31 20 7b  ecsql_test 6.1 {
1120: 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55 41  .  CREATE VIRTUA
1130: 4c 20 54 41 42 4c 45 20 78 79 7a 20 55 53 49 4e  L TABLE xyz USIN
1140: 47 20 66 74 73 35 28 78 2c 20 79 2c 20 7a 29 3b  G fts5(x, y, z);
1150: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78  .  INSERT INTO x
1160: 79 7a 20 56 41 4c 55 45 53 28 27 78 27 2c 20 27  yz VALUES('x', '
1170: 79 27 2c 20 27 7a 27 29 3b 0a 7d 0a 0a 64 6f 5f  y', 'z');.}..do_
1180: 63 61 74 63 68 73 71 6c 5f 74 65 73 74 20 36 2e  catchsql_test 6.
1190: 32 20 7b 20 0a 20 20 53 45 4c 45 43 54 20 2a 20  2 { .  SELECT * 
11a0: 46 52 4f 4d 20 78 79 7a 20 57 48 45 52 45 20 78  FROM xyz WHERE x
11b0: 79 7a 20 4d 41 54 43 48 20 27 27 20 0a 7d 20 7b  yz MATCH '' .} {
11c0: 31 20 7b 66 74 73 35 3a 20 73 79 6e 74 61 78 20  1 {fts5: syntax 
11d0: 65 72 72 6f 72 20 6e 65 61 72 20 22 22 7d 7d 0a  error near ""}}.
11e0: 64 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65 73 74  do_catchsql_test
11f0: 20 36 2e 33 20 7b 20 0a 20 20 53 45 4c 45 43 54   6.3 { .  SELECT
1200: 20 2a 20 46 52 4f 4d 20 78 79 7a 20 57 48 45 52   * FROM xyz WHER
1210: 45 20 78 79 7a 20 4d 41 54 43 48 20 4e 55 4c 4c  E xyz MATCH NULL
1220: 20 0a 7d 20 7b 31 20 7b 66 74 73 35 3a 20 73 79   .} {1 {fts5: sy
1230: 6e 74 61 78 20 65 72 72 6f 72 20 6e 65 61 72 20  ntax error near 
1240: 22 22 7d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d  ""}}..#---------
1250: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1270: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1280: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1290: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
12a0: 74 20 37 2e 31 20 7b 0a 20 20 43 52 45 41 54 45  t 7.1 {.  CREATE
12b0: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 66   VIRTUAL TABLE f
12c0: 74 32 20 55 53 49 4e 47 20 66 74 73 35 28 63 6f  t2 USING fts5(co
12d0: 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52 54  ntent);.  INSERT
12e0: 20 49 4e 54 4f 20 66 74 32 28 72 6f 77 69 64 2c   INTO ft2(rowid,
12f0: 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c 55 45 53   content) VALUES
1300: 28 31 2c 20 27 61 20 62 20 63 27 29 3b 0a 20 20  (1, 'a b c');.  
1310: 49 4e 53 45 52 54 20 49 4e 54 4f 20 66 74 32 28  INSERT INTO ft2(
1320: 72 6f 77 69 64 2c 20 63 6f 6e 74 65 6e 74 29 20  rowid, content) 
1330: 56 41 4c 55 45 53 28 32 2c 20 27 61 20 62 20 64  VALUES(2, 'a b d
1340: 27 29 3b 0a 7d 20 0a 0a 64 6f 5f 63 61 74 63 68  ');.} ..do_catch
1350: 73 71 6c 5f 74 65 73 74 20 37 2e 32 20 7b 0a 20  sql_test 7.2 {. 
1360: 20 42 45 47 49 4e 3b 0a 20 20 20 20 55 50 44 41   BEGIN;.    UPDA
1370: 54 45 20 66 74 32 20 53 45 54 20 72 6f 77 69 64  TE ft2 SET rowid
1380: 3d 32 20 57 48 45 52 45 20 72 6f 77 69 64 3d 31  =2 WHERE rowid=1
1390: 3b 0a 7d 20 7b 31 20 7b 63 6f 6e 73 74 72 61 69  ;.} {1 {constrai
13a0: 6e 74 20 66 61 69 6c 65 64 7d 7d 20 0a 0a 64 6f  nt failed}} ..do
13b0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 37 2e  _execsql_test 7.
13c0: 33 20 7b 0a 20 20 43 4f 4d 4d 49 54 3b 0a 20 20  3 {.  COMMIT;.  
13d0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 66 74 32 28  INSERT INTO ft2(
13e0: 66 74 32 29 20 56 41 4c 55 45 53 28 27 69 6e 74  ft2) VALUES('int
13f0: 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29 3b 0a  egrity-check');.
1400: 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c  } {}..do_execsql
1410: 5f 74 65 73 74 20 37 2e 34 20 7b 0a 20 20 53 45  _test 7.4 {.  SE
1420: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 66 74 32 3b  LECT * FROM ft2;
1430: 0a 7d 20 7b 7b 61 20 62 20 63 7d 20 7b 61 20 62  .} {{a b c} {a b
1440: 20 64 7d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d   d}}..#---------
1450: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1460: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1470: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1490: 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f 65  .#.reset_db.do_e
14a0: 78 65 63 73 71 6c 5f 74 65 73 74 20 38 2e 31 20  xecsql_test 8.1 
14b0: 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55  {.  CREATE VIRTU
14c0: 41 4c 20 54 41 42 4c 45 20 66 74 32 20 55 53 49  AL TABLE ft2 USI
14d0: 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74 29  NG fts5(content)
14e0: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
14f0: 66 74 32 28 72 6f 77 69 64 2c 20 63 6f 6e 74 65  ft2(rowid, conte
1500: 6e 74 29 20 56 41 4c 55 45 53 28 31 2c 20 27 61  nt) VALUES(1, 'a
1510: 20 62 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63   b');.}..do_exec
1520: 73 71 6c 5f 74 65 73 74 20 38 2e 32 20 7b 0a 20  sql_test 8.2 {. 
1530: 20 42 45 47 49 4e 3b 0a 20 20 20 20 49 4e 53 45   BEGIN;.    INSE
1540: 52 54 20 49 4e 54 4f 20 66 74 32 28 72 6f 77 69  RT INTO ft2(rowi
1550: 64 2c 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c 55  d, content) VALU
1560: 45 53 28 34 2c 20 27 61 20 78 27 29 3b 0a 7d 0a  ES(4, 'a x');.}.
1570: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
1580: 20 38 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54 20   8.3 {.  INSERT 
1590: 49 4e 54 4f 20 66 74 32 28 66 74 32 29 20 56 41  INTO ft2(ft2) VA
15a0: 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d  LUES('integrity-
15b0: 63 68 65 63 6b 27 29 3b 0a 7d 0a 0a 23 2d 2d 2d  check');.}..#---
15c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
15f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1600: 2d 2d 2d 2d 2d 2d 0a 23 20 43 68 65 63 6b 20 74  ------.# Check t
1610: 68 61 74 20 74 68 65 20 22 74 61 62 6c 65 20 66  hat the "table f
1620: 75 6e 63 74 69 6f 6e 22 20 73 79 6e 74 61 78 20  unction" syntax 
1630: 77 6f 72 6b 73 2e 0a 23 0a 72 65 73 65 74 5f 64  works..#.reset_d
1640: 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  b.do_execsql_tes
1650: 74 20 39 2e 31 20 7b 0a 20 20 43 52 45 41 54 45  t 9.1 {.  CREATE
1660: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 66   VIRTUAL TABLE f
1670: 74 32 20 55 53 49 4e 47 20 66 74 73 35 28 63 6f  t2 USING fts5(co
1680: 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52 54  ntent);.  INSERT
1690: 20 49 4e 54 4f 20 66 74 32 28 72 6f 77 69 64 2c   INTO ft2(rowid,
16a0: 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c 55 45 53   content) VALUES
16b0: 28 31 2c 20 27 61 20 62 27 29 3b 0a 20 20 49 4e  (1, 'a b');.  IN
16c0: 53 45 52 54 20 49 4e 54 4f 20 66 74 32 28 72 6f  SERT INTO ft2(ro
16d0: 77 69 64 2c 20 63 6f 6e 74 65 6e 74 29 20 56 41  wid, content) VA
16e0: 4c 55 45 53 28 32 2c 20 27 61 20 62 20 63 20 64  LUES(2, 'a b c d
16f0: 27 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ');.  INSERT INT
1700: 4f 20 66 74 32 28 72 6f 77 69 64 2c 20 63 6f 6e  O ft2(rowid, con
1710: 74 65 6e 74 29 20 56 41 4c 55 45 53 28 33 2c 20  tent) VALUES(3, 
1720: 27 63 20 64 20 65 20 66 27 29 3b 0a 7d 0a 0a 64  'c d e f');.}..d
1730: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 39  o_execsql_test 9
1740: 2e 32 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f  .2 {.  SELECT ro
1750: 77 69 64 20 46 52 4f 4d 20 66 74 32 28 27 61 27  wid FROM ft2('a'
1760: 29 3b 0a 7d 20 7b 31 20 32 7d 0a 0a 64 6f 5f 65  );.} {1 2}..do_e
1770: 78 65 63 73 71 6c 5f 74 65 73 74 20 39 2e 33 20  xecsql_test 9.3 
1780: 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64  {.  SELECT rowid
1790: 20 46 52 4f 4d 20 66 74 32 28 27 62 20 41 4e 44   FROM ft2('b AND
17a0: 20 63 27 29 3b 0a 7d 20 7b 32 7d 0a 0a 23 2d 2d   c');.} {2}..#--
17b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
17c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
17d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
17e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
17f0: 2d 2d 2d 2d 2d 2d 2d 0a 23 0a 64 6f 5f 65 78 65  -------.#.do_exe
1800: 63 73 71 6c 5f 74 65 73 74 20 31 30 2e 30 20 7b  csql_test 10.0 {
1810: 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55 41  .  CREATE VIRTUA
1820: 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e 47  L TABLE t3 USING
1830: 20 66 74 73 35 28 61 2c 20 62 2c 20 63 29 3b 0a   fts5(a, b, c);.
1840: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 33    INSERT INTO t3
1850: 20 56 41 4c 55 45 53 28 27 62 61 63 20 61 61 62   VALUES('bac aab
1860: 20 62 61 62 27 2c 20 27 63 20 62 61 63 20 63 27   bab', 'c bac c'
1870: 2c 20 27 61 63 62 20 61 62 61 20 61 62 62 27 29  , 'acb aba abb')
1880: 3b 20 2d 2d 20 31 0a 20 20 49 4e 53 45 52 54 20  ; -- 1.  INSERT 
1890: 49 4e 54 4f 20 74 33 20 56 41 4c 55 45 53 28 27  INTO t3 VALUES('
18a0: 62 61 62 20 61 62 63 20 63 27 2c 20 27 61 63 62  bab abc c', 'acb
18b0: 20 63 20 61 62 62 27 2c 20 27 63 20 61 61 61 20   c abb', 'c aaa 
18c0: 63 27 29 3b 20 20 20 20 20 2d 2d 20 32 0a 7d 0a  c');     -- 2.}.
18d0: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
18e0: 20 31 30 2e 31 20 7b 0a 20 20 53 45 4c 45 43 54   10.1 {.  SELECT
18f0: 20 72 6f 77 69 64 20 46 52 4f 4d 20 74 33 28 27   rowid FROM t3('
1900: 63 3a 20 63 2a 27 29 3b 0a 7d 20 7b 32 7d 0a 0a  c: c*');.} {2}..
1910: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1920: 31 30 2e 32 20 7b 0a 20 20 53 45 4c 45 43 54 20  10.2 {.  SELECT 
1930: 72 6f 77 69 64 20 46 52 4f 4d 20 74 33 28 27 62  rowid FROM t3('b
1940: 3a 20 61 63 62 27 29 3b 0a 7d 20 7b 32 7d 0a 0a  : acb');.} {2}..
1950: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
1960: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1970: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1980: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1990: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 54 65 73  ----------.# Tes
19a0: 74 20 74 68 61 74 20 63 68 61 72 61 63 74 65 72  t that character
19b0: 20 30 78 31 41 20 69 73 20 61 6c 6c 6f 77 65 64   0x1A is allowed
19c0: 20 69 6e 20 66 74 73 35 20 62 61 72 65 77 6f 72   in fts5 barewor
19d0: 64 73 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 31 31  ds..#.do_test 11
19e0: 2e 30 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22  .0 {.  execsql "
19f0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
1a00: 41 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66 74  ABLE t4 USING ft
1a10: 73 35 28 78 2c 20 74 6f 6b 65 6e 69 7a 65 3d 5c  s5(x, tokenize=\
1a20: 22 61 73 63 69 69 20 74 6f 6b 65 6e 63 68 61 72  "ascii tokenchar
1a30: 73 20 27 5c 78 31 41 27 5c 22 29 22 0a 20 20 65  s '\x1A'\")".  e
1a40: 78 65 63 73 71 6c 20 22 0a 20 20 20 20 49 4e 53  xecsql ".    INS
1a50: 45 52 54 20 49 4e 54 4f 20 74 34 20 56 41 4c 55  ERT INTO t4 VALU
1a60: 45 53 28 27 61 20 62 20 63 20 5c 78 31 41 27 29  ES('a b c \x1A')
1a70: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
1a80: 4f 20 74 34 20 56 41 4c 55 45 53 28 27 61 20 62  O t4 VALUES('a b
1a90: 20 63 20 64 5c 78 31 41 27 29 3b 0a 20 20 20 20   c d\x1A');.    
1aa0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 34 20 56  INSERT INTO t4 V
1ab0: 41 4c 55 45 53 28 27 61 20 62 20 63 20 5c 78 31  ALUES('a b c \x1
1ac0: 41 64 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  Ad');.    INSERT
1ad0: 20 49 4e 54 4f 20 74 34 20 56 41 4c 55 45 53 28   INTO t4 VALUES(
1ae0: 27 61 20 62 20 63 20 64 27 29 3b 0a 20 20 22 0a  'a b c d');.  ".
1af0: 7d 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 31 31  } {}..do_test 11
1b00: 2e 31 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22  .1 {.  execsql "
1b10: 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f  SELECT rowid FRO
1b20: 4d 20 74 34 28 27 5c 78 31 41 27 29 22 0a 7d 20  M t4('\x1A')".} 
1b30: 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 31 31 2e 32  {1}.do_test 11.2
1b40: 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22 53 45   {.  execsql "SE
1b50: 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d 20  LECT rowid FROM 
1b60: 74 34 28 27 5c 78 31 41 2a 27 29 22 0a 7d 20 7b  t4('\x1A*')".} {
1b70: 31 20 33 7d 0a 64 6f 5f 74 65 73 74 20 31 31 2e  1 3}.do_test 11.
1b80: 33 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22 53  3 {.  execsql "S
1b90: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
1ba0: 20 74 34 28 27 64 5c 78 31 41 27 29 22 0a 7d 20   t4('d\x1A')".} 
1bb0: 7b 32 7d 0a 0a 64 6f 5f 74 65 73 74 20 31 31 2e  {2}..do_test 11.
1bc0: 34 20 7b 0a 20 20 63 61 74 63 68 73 71 6c 20 22  4 {.  catchsql "
1bd0: 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f  SELECT rowid FRO
1be0: 4d 20 74 34 28 27 64 5c 78 31 42 27 29 22 0a 7d  M t4('d\x1B')".}
1bf0: 20 7b 2f 66 74 73 35 3a 20 73 79 6e 74 61 78 20   {/fts5: syntax 
1c00: 65 72 72 6f 72 2f 7d 0a 64 6f 5f 74 65 73 74 20  error/}.do_test 
1c10: 31 31 2e 35 20 7b 0a 20 20 63 61 74 63 68 73 71  11.5 {.  catchsq
1c20: 6c 20 22 53 45 4c 45 43 54 20 72 6f 77 69 64 20  l "SELECT rowid 
1c30: 46 52 4f 4d 20 74 34 28 27 64 5c 78 31 39 27 29  FROM t4('d\x19')
1c40: 22 0a 7d 20 7b 2f 66 74 73 35 3a 20 73 79 6e 74  ".} {/fts5: synt
1c50: 61 78 20 65 72 72 6f 72 2f 7d 0a 0a 23 2d 2d 2d  ax error/}..#---
1c60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c70: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1c90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1ca0: 2d 2d 2d 2d 2d 2d 0a 23 0a 64 6f 5f 74 65 73 74  ------.#.do_test
1cb0: 20 31 32 2e 31 20 7b 0a 20 20 65 78 65 63 73 71   12.1 {.  execsq
1cc0: 6c 20 7b 0a 20 20 20 20 43 52 45 41 54 45 20 56  l {.    CREATE V
1cd0: 49 52 54 55 41 4c 20 54 41 42 4c 45 20 78 78 20  IRTUAL TABLE xx 
1ce0: 55 53 49 4e 47 20 66 74 73 35 28 78 2c 79 29 3b  USING fts5(x,y);
1cf0: 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20 20 20 20  .    BEGIN;.    
1d00: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78 78    INSERT INTO xx
1d10: 20 56 41 4c 55 45 53 28 27 31 20 32 20 33 27 2c   VALUES('1 2 3',
1d20: 20 27 61 20 62 20 63 27 29 3b 0a 20 20 7d 0a 7d   'a b c');.  }.}
1d30: 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f   {}..do_execsql_
1d40: 74 65 73 74 20 31 32 2e 32 20 7b 0a 20 20 53 45  test 12.2 {.  SE
1d50: 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d 20  LECT rowid FROM 
1d60: 78 78 28 27 78 3a 61 27 29 3b 0a 20 20 43 4f 4d  xx('x:a');.  COM
1d70: 4d 49 54 3b 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d 2d  MIT;.} {}..#----
1d80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1d90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1da0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1db0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1dc0: 2d 2d 2d 2d 2d 0a 23 20 54 72 79 20 61 6e 20 55  -----.# Try an U
1dd0: 50 44 41 54 45 20 4f 52 20 52 45 50 4c 41 43 45  PDATE OR REPLACE
1de0: 20 71 75 65 72 79 2e 0a 23 0a 64 6f 5f 65 78 65   query..#.do_exe
1df0: 63 73 71 6c 5f 74 65 73 74 20 31 33 2e 31 20 7b  csql_test 13.1 {
1e00: 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55 41  .  CREATE VIRTUA
1e10: 4c 20 54 41 42 4c 45 20 78 79 20 55 53 49 4e 47  L TABLE xy USING
1e20: 20 66 74 73 35 28 78 29 3b 0a 20 20 49 4e 53 45   fts5(x);.  INSE
1e30: 52 54 20 49 4e 54 4f 20 78 79 28 72 6f 77 69 64  RT INTO xy(rowid
1e40: 2c 20 78 29 20 56 41 4c 55 45 53 28 31 2c 20 27  , x) VALUES(1, '
1e50: 31 20 32 20 33 27 29 3b 0a 20 20 49 4e 53 45 52  1 2 3');.  INSER
1e60: 54 20 49 4e 54 4f 20 78 79 28 72 6f 77 69 64 2c  T INTO xy(rowid,
1e70: 20 78 29 20 56 41 4c 55 45 53 28 32 2c 20 27 32   x) VALUES(2, '2
1e80: 20 33 20 34 27 29 3b 0a 20 20 49 4e 53 45 52 54   3 4');.  INSERT
1e90: 20 49 4e 54 4f 20 78 79 28 72 6f 77 69 64 2c 20   INTO xy(rowid, 
1ea0: 78 29 20 56 41 4c 55 45 53 28 33 2c 20 27 33 20  x) VALUES(3, '3 
1eb0: 34 20 35 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65  4 5');.}..do_exe
1ec0: 63 73 71 6c 5f 74 65 73 74 20 31 33 2e 32 20 7b  csql_test 13.2 {
1ed0: 0a 20 20 55 50 44 41 54 45 20 4f 52 20 52 45 50  .  UPDATE OR REP
1ee0: 4c 41 43 45 20 78 79 20 53 45 54 20 72 6f 77 69  LACE xy SET rowi
1ef0: 64 3d 33 20 57 48 45 52 45 20 72 6f 77 69 64 20  d=3 WHERE rowid 
1f00: 3d 20 32 3b 0a 20 20 53 45 4c 45 43 54 20 72 6f  = 2;.  SELECT ro
1f10: 77 69 64 2c 20 78 20 46 52 4f 4d 20 78 79 3b 0a  wid, x FROM xy;.
1f20: 7d 20 7b 0a 20 20 31 20 7b 31 20 32 20 33 7d 0a  } {.  1 {1 2 3}.
1f30: 20 20 33 20 7b 32 20 33 20 34 7d 0a 7d 0a 0a 64    3 {2 3 4}.}..d
1f40: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31  o_execsql_test 1
1f50: 33 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54 20 49  3.3 {.  INSERT I
1f60: 4e 54 4f 20 78 79 28 78 79 29 20 56 41 4c 55 45  NTO xy(xy) VALUE
1f70: 53 28 27 69 6e 74 65 67 72 69 74 79 2d 63 68 65  S('integrity-che
1f80: 63 6b 27 29 3b 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  ck');.}..#------
1f90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1fa0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1fb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1fc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
1fd0: 2d 2d 2d 0a 23 0a 64 6f 5f 65 78 65 63 73 71 6c  ---.#.do_execsql
1fe0: 5f 74 65 73 74 20 31 34 2e 31 20 7b 0a 20 20 43  _test 14.1 {.  C
1ff0: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41  REATE VIRTUAL TA
2000: 42 4c 45 20 74 74 74 20 55 53 49 4e 47 20 66 74  BLE ttt USING ft
2010: 73 35 28 78 29 3b 0a 20 20 42 45 47 49 4e 3b 0a  s5(x);.  BEGIN;.
2020: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
2030: 74 74 74 28 72 6f 77 69 64 2c 20 78 29 20 56 41  ttt(rowid, x) VA
2040: 4c 55 45 53 28 31 2c 20 27 61 20 62 20 63 27 29  LUES(1, 'a b c')
2050: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
2060: 4f 20 74 74 74 28 72 6f 77 69 64 2c 20 78 29 20  O ttt(rowid, x) 
2070: 56 41 4c 55 45 53 28 32 2c 20 27 61 20 62 20 63  VALUES(2, 'a b c
2080: 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  ');.    INSERT I
2090: 4e 54 4f 20 74 74 74 28 72 6f 77 69 64 2c 20 78  NTO ttt(rowid, x
20a0: 29 20 56 41 4c 55 45 53 28 33 2c 20 27 61 20 62  ) VALUES(3, 'a b
20b0: 20 63 27 29 3b 0a 20 20 43 4f 4d 4d 49 54 3b 0a   c');.  COMMIT;.
20c0: 7d 0a 64 6f 5f 74 65 73 74 20 31 34 2e 32 20 7b  }.do_test 14.2 {
20d0: 20 0a 20 20 66 74 73 35 5f 6c 65 76 65 6c 5f 73   .  fts5_level_s
20e0: 65 67 73 20 74 74 74 20 0a 7d 20 7b 31 7d 0a 0a  egs ttt .} {1}..
20f0: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
2100: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2110: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2120: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2130: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 64 62 20 66 75  ----------.db fu
2140: 6e 63 20 72 6e 64 64 6f 63 20 66 74 73 35 5f 72  nc rnddoc fts5_r
2150: 6e 64 64 6f 63 0a 64 6f 5f 65 78 65 63 73 71 6c  nddoc.do_execsql
2160: 5f 74 65 73 74 20 31 34 2e 33 20 7b 0a 20 20 43  _test 14.3 {.  C
2170: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41  REATE VIRTUAL TA
2180: 42 4c 45 20 78 31 20 55 53 49 4e 47 20 66 74 73  BLE x1 USING fts
2190: 35 28 78 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  5(x);.  INSERT I
21a0: 4e 54 4f 20 78 31 28 78 31 2c 20 72 61 6e 6b 29  NTO x1(x1, rank)
21b0: 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27 2c 20   VALUES('pgsz', 
21c0: 33 32 29 3b 0a 0a 20 20 57 49 54 48 20 69 69 28  32);..  WITH ii(
21d0: 69 29 20 41 53 20 28 20 53 45 4c 45 43 54 20 31  i) AS ( SELECT 1
21e0: 20 55 4e 49 4f 4e 20 41 4c 4c 20 53 45 4c 45 43   UNION ALL SELEC
21f0: 54 20 69 2b 31 20 46 52 4f 4d 20 69 69 20 57 48  T i+1 FROM ii WH
2200: 45 52 45 20 69 3c 31 30 20 29 0a 20 20 49 4e 53  ERE i<10 ).  INS
2210: 45 52 54 20 49 4e 54 4f 20 78 31 20 53 45 4c 45  ERT INTO x1 SELE
2220: 43 54 20 72 6e 64 64 6f 63 28 35 29 20 46 52 4f  CT rnddoc(5) FRO
2230: 4d 20 69 69 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63  M ii;.}..do_exec
2240: 73 71 6c 5f 74 65 73 74 20 31 34 2e 34 20 7b 0a  sql_test 14.4 {.
2250: 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 2c 20    SELECT rowid, 
2260: 78 2c 20 78 31 20 46 52 4f 4d 20 78 31 20 57 48  x, x1 FROM x1 WH
2270: 45 52 45 20 78 31 20 4d 41 54 43 48 20 27 2a 72  ERE x1 MATCH '*r
2280: 65 61 64 73 27 0a 7d 20 7b 30 20 7b 7d 20 33 7d  eads'.} {0 {} 3}
2290: 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ..#-------------
22a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
22b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
22c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
22d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73  ------------.res
22e0: 65 74 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c  et_db.do_execsql
22f0: 5f 74 65 73 74 20 31 35 2e 30 20 7b 0a 20 20 43  _test 15.0 {.  C
2300: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41  REATE VIRTUAL TA
2310: 42 4c 45 20 78 32 20 55 53 49 4e 47 20 66 74 73  BLE x2 USING fts
2320: 35 28 78 2c 20 70 72 65 66 69 78 3d 31 29 3b 0a  5(x, prefix=1);.
2330: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78 32    INSERT INTO x2
2340: 20 56 41 4c 55 45 53 28 27 61 62 27 29 3b 0a 7d   VALUES('ab');.}
2350: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
2360: 74 20 31 35 2e 31 20 7b 0a 20 20 49 4e 53 45 52  t 15.1 {.  INSER
2370: 54 20 49 4e 54 4f 20 78 32 28 78 32 29 20 56 41  T INTO x2(x2) VA
2380: 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d  LUES('integrity-
2390: 63 68 65 63 6b 27 29 3b 0a 7d 0a 0a 23 2d 2d 2d  check');.}..#---
23a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
23b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
23c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
23d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
23e0: 2d 2d 2d 2d 2d 2d 0a 66 6f 72 65 61 63 68 5f 64  ------.foreach_d
23f0: 65 74 61 69 6c 5f 6d 6f 64 65 20 24 74 65 73 74  etail_mode $test
2400: 70 72 65 66 69 78 20 7b 0a 20 20 72 65 73 65 74  prefix {.  reset
2410: 5f 64 62 0a 20 20 66 74 73 35 5f 61 75 78 5f 74  _db.  fts5_aux_t
2420: 65 73 74 5f 66 75 6e 63 74 69 6f 6e 73 20 64 62  est_functions db
2430: 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  .  do_execsql_te
2440: 73 74 20 31 36 2e 30 20 7b 0a 20 20 20 20 43 52  st 16.0 {.    CR
2450: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42  EATE VIRTUAL TAB
2460: 4c 45 20 78 33 20 55 53 49 4e 47 20 66 74 73 35  LE x3 USING fts5
2470: 28 78 2c 20 64 65 74 61 69 6c 3d 25 44 45 54 41  (x, detail=%DETA
2480: 49 4c 25 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  IL%);.    INSERT
2490: 20 49 4e 54 4f 20 78 33 20 56 41 4c 55 45 53 28   INTO x3 VALUES(
24a0: 27 61 20 62 20 63 20 64 20 65 20 66 27 29 3b 0a  'a b c d e f');.
24b0: 20 20 7d 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c    }.  do_execsql
24c0: 5f 74 65 73 74 20 31 36 2e 31 20 7b 0a 20 20 20  _test 16.1 {.   
24d0: 20 53 45 4c 45 43 54 20 66 74 73 35 5f 74 65 73   SELECT fts5_tes
24e0: 74 5f 70 6f 73 6c 69 73 74 28 78 33 29 20 46 52  t_poslist(x3) FR
24f0: 4f 4d 20 78 33 28 27 28 61 20 4e 4f 54 20 62 29  OM x3('(a NOT b)
2500: 20 4f 52 20 63 27 29 3b 0a 20 20 7d 20 7b 32 2e   OR c');.  } {2.
2510: 30 2e 32 7d 0a 0a 20 20 64 6f 5f 65 78 65 63 73  0.2}..  do_execs
2520: 71 6c 5f 74 65 73 74 20 31 36 2e 31 20 7b 0a 20  ql_test 16.1 {. 
2530: 20 20 20 53 45 4c 45 43 54 20 66 74 73 35 5f 74     SELECT fts5_t
2540: 65 73 74 5f 70 6f 73 6c 69 73 74 28 78 33 29 20  est_poslist(x3) 
2550: 46 52 4f 4d 20 78 33 28 27 61 20 4f 52 20 63 27  FROM x3('a OR c'
2560: 29 3b 0a 20 20 7d 20 7b 7b 30 2e 30 2e 30 20 31  );.  } {{0.0.0 1
2570: 2e 30 2e 32 7d 7d 0a 7d 0a 0a 7d 0a 0a 23 2d 2d  .0.2}}.}..}..#--
2580: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2590: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
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 0a 72 65 73 65 74 5f 64 62  -------.reset_db
25d0: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
25e0: 20 31 37 2e 30 20 7b 0a 20 20 43 52 45 41 54 45   17.0 {.  CREATE
25f0: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 78   VIRTUAL TABLE x
2600: 33 20 55 53 49 4e 47 20 66 74 73 35 28 78 29 3b  3 USING fts5(x);
2610: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78  .  INSERT INTO x
2620: 33 20 56 41 4c 55 45 53 28 27 61 20 62 20 63 27  3 VALUES('a b c'
2630: 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c  );.}..do_execsql
2640: 5f 74 65 73 74 20 31 37 2e 31 20 7b 0a 20 20 53  _test 17.1 {.  S
2650: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
2660: 20 78 33 28 27 62 20 41 4e 44 20 64 27 29 3b 0a   x3('b AND d');.
2670: 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  }..#------------
2680: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2690: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
26a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
26b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 64 6f  -------------.do
26c0: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 38  _execsql_test 18
26d0: 2e 31 20 7b 0a 20 20 43 52 45 41 54 45 20 56 49  .1 {.  CREATE VI
26e0: 52 54 55 41 4c 20 54 41 42 4c 45 20 78 34 20 55  RTUAL TABLE x4 U
26f0: 53 49 4e 47 20 66 74 73 35 28 78 29 3b 0a 20 20  SING fts5(x);.  
2700: 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f  SELECT rowid FRO
2710: 4d 20 78 34 28 27 22 22 27 29 3b 0a 7d 0a 0a 23  M x4('""');.}..#
2720: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2730: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2740: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2750: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
2760: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74 5f  ---------.reset_
2770: 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  db.do_execsql_te
2780: 73 74 20 31 39 2e 31 20 7b 0a 20 20 43 52 45 41  st 19.1 {.  CREA
2790: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45  TE VIRTUAL TABLE
27a0: 20 78 31 20 55 53 49 4e 47 20 66 74 73 35 28 61   x1 USING fts5(a
27b0: 2c 62 2c 63 29 3b 0a 7d 0a 0a 64 6f 5f 63 61 74  ,b,c);.}..do_cat
27c0: 63 68 73 71 6c 5f 74 65 73 74 20 31 39 2e 32 20  chsql_test 19.2 
27d0: 7b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  {.  SELECT * FRO
27e0: 4d 20 78 31 20 57 48 45 52 45 20 78 31 20 4d 41  M x1 WHERE x1 MA
27f0: 54 43 48 20 27 63 30 20 41 4e 44 20 28 63 31 20  TCH 'c0 AND (c1 
2800: 41 4e 44 20 28 63 32 20 41 4e 44 20 28 63 33 20  AND (c2 AND (c3 
2810: 41 4e 44 20 28 63 34 20 41 4e 44 20 28 63 35 20  AND (c4 AND (c5 
2820: 41 4e 44 20 28 63 36 20 41 4e 44 20 28 63 37 20  AND (c6 AND (c7 
2830: 41 4e 44 20 28 63 38 20 41 4e 44 20 28 63 39 20  AND (c8 AND (c9 
2840: 41 4e 44 20 28 63 31 30 20 41 4e 44 20 28 63 31  AND (c10 AND (c1
2850: 31 20 41 4e 44 20 28 63 31 32 20 41 4e 44 20 28  1 AND (c12 AND (
2860: 63 31 33 20 41 4e 44 20 28 63 31 34 20 41 4e 44  c13 AND (c14 AND
2870: 20 28 63 31 35 20 41 4e 44 20 28 63 31 36 20 41   (c15 AND (c16 A
2880: 4e 44 20 28 63 31 37 20 41 4e 44 20 28 63 31 38  ND (c17 AND (c18
2890: 20 41 4e 44 20 28 63 31 39 20 41 4e 44 20 28 63   AND (c19 AND (c
28a0: 32 30 20 41 4e 44 20 28 63 32 31 20 41 4e 44 20  20 AND (c21 AND 
28b0: 28 63 32 32 20 41 4e 44 20 28 63 32 33 20 41 4e  (c22 AND (c23 AN
28c0: 44 20 28 63 32 34 20 41 4e 44 20 28 63 32 35 20  D (c24 AND (c25 
28d0: 41 4e 44 20 28 63 32 36 20 41 4e 44 20 28 63 32  AND (c26 AND (c2
28e0: 37 20 41 4e 44 20 28 63 32 38 20 41 4e 44 20 28  7 AND (c28 AND (
28f0: 63 32 39 20 41 4e 44 20 28 63 33 30 20 41 4e 44  c29 AND (c30 AND
2900: 20 28 63 33 31 20 41 4e 44 20 28 63 33 32 20 41   (c31 AND (c32 A
2910: 4e 44 20 28 63 33 33 20 41 4e 44 20 28 63 33 34  ND (c33 AND (c34
2920: 20 41 4e 44 20 28 63 33 35 20 41 4e 44 20 28 63   AND (c35 AND (c
2930: 33 36 20 41 4e 44 20 28 63 33 37 20 41 4e 44 20  36 AND (c37 AND 
2940: 28 63 33 38 20 41 4e 44 20 28 63 33 39 20 41 4e  (c38 AND (c39 AN
2950: 44 20 28 63 34 30 20 41 4e 44 20 28 63 34 31 20  D (c40 AND (c41 
2960: 41 4e 44 20 28 63 34 32 20 41 4e 44 20 28 63 34  AND (c42 AND (c4
2970: 33 20 41 4e 44 20 28 63 34 34 20 41 4e 44 20 28  3 AND (c44 AND (
2980: 63 34 35 20 41 4e 44 20 28 63 34 36 20 41 4e 44  c45 AND (c46 AND
2990: 20 28 63 34 37 20 41 4e 44 20 28 63 34 38 20 41   (c47 AND (c48 A
29a0: 4e 44 20 28 63 34 39 20 41 4e 44 20 28 63 35 30  ND (c49 AND (c50
29b0: 20 41 4e 44 20 28 63 35 31 20 41 4e 44 20 28 63   AND (c51 AND (c
29c0: 35 32 20 41 4e 44 20 28 63 35 33 20 41 4e 44 20  52 AND (c53 AND 
29d0: 28 63 35 34 20 41 4e 44 20 28 63 35 35 20 41 4e  (c54 AND (c55 AN
29e0: 44 20 28 63 35 36 20 41 4e 44 20 28 63 35 37 20  D (c56 AND (c57 
29f0: 41 4e 44 20 28 63 35 38 20 41 4e 44 20 28 63 35  AND (c58 AND (c5
2a00: 39 20 41 4e 44 20 28 63 36 30 20 41 4e 44 20 28  9 AND (c60 AND (
2a10: 63 36 31 20 41 4e 44 20 28 63 36 32 20 41 4e 44  c61 AND (c62 AND
2a20: 20 28 63 36 33 20 41 4e 44 20 28 63 36 34 20 41   (c63 AND (c64 A
2a30: 4e 44 20 28 63 36 35 20 41 4e 44 20 28 63 36 36  ND (c65 AND (c66
2a40: 20 41 4e 44 20 28 63 36 37 20 41 4e 44 20 28 63   AND (c67 AND (c
2a50: 36 38 20 41 4e 44 20 28 63 36 39 20 41 4e 44 20  68 AND (c69 AND 
2a60: 28 63 37 30 20 41 4e 44 20 28 63 37 31 20 41 4e  (c70 AND (c71 AN
2a70: 44 20 28 63 37 32 20 41 4e 44 20 28 63 37 33 20  D (c72 AND (c73 
2a80: 41 4e 44 20 28 63 37 34 20 41 4e 44 20 28 63 37  AND (c74 AND (c7
2a90: 35 20 41 4e 44 20 28 63 37 36 20 41 4e 44 20 28  5 AND (c76 AND (
2aa0: 63 37 37 20 41 4e 44 20 28 63 37 38 20 41 4e 44  c77 AND (c78 AND
2ab0: 20 28 63 37 39 20 41 4e 44 20 28 63 38 30 20 41   (c79 AND (c80 A
2ac0: 4e 44 20 28 63 38 31 20 41 4e 44 20 28 63 38 32  ND (c81 AND (c82
2ad0: 20 41 4e 44 20 28 63 38 33 20 41 4e 44 20 28 63   AND (c83 AND (c
2ae0: 38 34 20 41 4e 44 20 28 63 38 35 20 41 4e 44 20  84 AND (c85 AND 
2af0: 28 63 38 36 20 41 4e 44 20 28 63 38 37 20 41 4e  (c86 AND (c87 AN
2b00: 44 20 28 63 38 38 20 41 4e 44 20 28 63 38 39 20  D (c88 AND (c89 
2b10: 41 4e 44 20 28 63 39 30 20 41 4e 44 20 28 63 39  AND (c90 AND (c9
2b20: 31 20 41 4e 44 20 28 63 39 32 20 41 4e 44 20 28  1 AND (c92 AND (
2b30: 63 39 33 20 41 4e 44 20 28 63 39 34 20 41 4e 44  c93 AND (c94 AND
2b40: 20 28 63 39 35 20 41 4e 44 20 28 63 39 36 20 41   (c95 AND (c96 A
2b50: 4e 44 20 28 63 39 37 20 41 4e 44 20 28 63 39 38  ND (c97 AND (c98
2b60: 20 41 4e 44 20 28 63 39 39 20 41 4e 44 20 28 63   AND (c99 AND (c
2b70: 31 30 30 20 41 4e 44 20 28 63 31 30 31 20 41 4e  100 AND (c101 AN
2b80: 44 20 28 63 31 30 32 20 41 4e 44 20 28 63 31 30  D (c102 AND (c10
2b90: 33 20 41 4e 44 20 28 63 31 30 34 20 41 4e 44 20  3 AND (c104 AND 
2ba0: 28 63 31 30 35 20 41 4e 44 20 28 63 31 30 36 20  (c105 AND (c106 
2bb0: 41 4e 44 20 28 63 31 30 37 20 41 4e 44 20 28 63  AND (c107 AND (c
2bc0: 31 30 38 20 41 4e 44 20 28 63 31 30 39 20 41 4e  108 AND (c109 AN
2bd0: 44 20 28 63 31 31 30 20 41 4e 44 20 28 63 31 31  D (c110 AND (c11
2be0: 31 20 41 4e 44 20 28 63 31 31 32 20 41 4e 44 20  1 AND (c112 AND 
2bf0: 28 63 31 31 33 20 41 4e 44 20 28 63 31 31 34 20  (c113 AND (c114 
2c00: 41 4e 44 20 28 63 31 31 35 20 41 4e 44 20 28 63  AND (c115 AND (c
2c10: 31 31 36 20 41 4e 44 20 28 63 31 31 37 20 41 4e  116 AND (c117 AN
2c20: 44 20 28 63 31 31 38 20 41 4e 44 20 28 63 31 31  D (c118 AND (c11
2c30: 39 20 41 4e 44 20 28 63 31 32 30 20 41 4e 44 20  9 AND (c120 AND 
2c40: 28 63 31 32 31 20 41 4e 44 20 28 63 31 32 32 20  (c121 AND (c122 
2c50: 41 4e 44 20 28 63 31 32 33 20 41 4e 44 20 28 63  AND (c123 AND (c
2c60: 31 32 34 20 41 4e 44 20 28 63 31 32 35 20 41 4e  124 AND (c125 AN
2c70: 44 20 28 63 31 32 36 20 41 4e 44 20 28 63 31 32  D (c126 AND (c12
2c80: 37 20 41 4e 44 20 28 63 31 32 38 20 41 4e 44 20  7 AND (c128 AND 
2c90: 28 63 31 32 39 20 41 4e 44 20 28 63 31 33 30 20  (c129 AND (c130 
2ca0: 41 4e 44 20 28 63 31 33 31 20 41 4e 44 20 28 63  AND (c131 AND (c
2cb0: 31 33 32 20 41 4e 44 20 28 63 31 33 33 20 41 4e  132 AND (c133 AN
2cc0: 44 20 28 63 31 33 34 20 41 4e 44 20 28 63 31 33  D (c134 AND (c13
2cd0: 35 20 41 4e 44 20 28 63 31 33 36 20 41 4e 44 20  5 AND (c136 AND 
2ce0: 28 63 31 33 37 20 41 4e 44 20 28 63 31 33 38 20  (c137 AND (c138 
2cf0: 41 4e 44 20 28 63 31 33 39 20 41 4e 44 20 28 63  AND (c139 AND (c
2d00: 31 34 30 20 41 4e 44 20 28 63 31 34 31 20 41 4e  140 AND (c141 AN
2d10: 44 20 28 63 31 34 32 20 41 4e 44 20 28 63 31 34  D (c142 AND (c14
2d20: 33 20 41 4e 44 20 28 63 31 34 34 20 41 4e 44 20  3 AND (c144 AND 
2d30: 28 63 31 34 35 20 41 4e 44 20 28 63 31 34 36 20  (c145 AND (c146 
2d40: 41 4e 44 20 28 63 31 34 37 20 41 4e 44 20 28 63  AND (c147 AND (c
2d50: 31 34 38 20 41 4e 44 20 28 63 31 34 39 20 41 4e  148 AND (c149 AN
2d60: 44 20 28 63 31 35 30 20 41 4e 44 20 28 63 31 35  D (c150 AND (c15
2d70: 31 20 41 4e 44 20 28 63 31 35 32 20 41 4e 44 20  1 AND (c152 AND 
2d80: 28 63 31 35 33 20 41 4e 44 20 28 63 31 35 34 20  (c153 AND (c154 
2d90: 41 4e 44 20 28 63 31 35 35 20 41 4e 44 20 28 63  AND (c155 AND (c
2da0: 31 35 36 20 41 4e 44 20 28 63 31 35 37 20 41 4e  156 AND (c157 AN
2db0: 44 20 28 63 31 35 38 20 41 4e 44 20 28 63 31 35  D (c158 AND (c15
2dc0: 39 20 41 4e 44 20 28 63 31 36 30 20 41 4e 44 20  9 AND (c160 AND 
2dd0: 28 63 31 36 31 20 41 4e 44 20 28 63 31 36 32 20  (c161 AND (c162 
2de0: 41 4e 44 20 28 63 31 36 33 20 41 4e 44 20 28 63  AND (c163 AND (c
2df0: 31 36 34 20 41 4e 44 20 28 63 31 36 35 20 41 4e  164 AND (c165 AN
2e00: 44 20 28 63 31 36 36 20 41 4e 44 20 28 63 31 36  D (c166 AND (c16
2e10: 37 20 41 4e 44 20 28 63 31 36 38 20 41 4e 44 20  7 AND (c168 AND 
2e20: 28 63 31 36 39 20 41 4e 44 20 28 63 31 37 30 20  (c169 AND (c170 
2e30: 41 4e 44 20 28 63 31 37 31 20 41 4e 44 20 28 63  AND (c171 AND (c
2e40: 31 37 32 20 41 4e 44 20 28 63 31 37 33 20 41 4e  172 AND (c173 AN
2e50: 44 20 28 63 31 37 34 20 41 4e 44 20 28 63 31 37  D (c174 AND (c17
2e60: 35 20 41 4e 44 20 28 63 31 37 36 20 41 4e 44 20  5 AND (c176 AND 
2e70: 28 63 31 37 37 20 41 4e 44 20 28 63 31 37 38 20  (c177 AND (c178 
2e80: 41 4e 44 20 28 63 31 37 39 20 41 4e 44 20 28 63  AND (c179 AND (c
2e90: 31 38 30 20 41 4e 44 20 28 63 31 38 31 20 41 4e  180 AND (c181 AN
2ea0: 44 20 28 63 31 38 32 20 41 4e 44 20 28 63 31 38  D (c182 AND (c18
2eb0: 33 20 41 4e 44 20 28 63 31 38 34 20 41 4e 44 20  3 AND (c184 AND 
2ec0: 28 63 31 38 35 20 41 4e 44 20 28 63 31 38 36 20  (c185 AND (c186 
2ed0: 41 4e 44 20 28 63 31 38 37 20 41 4e 44 20 28 63  AND (c187 AND (c
2ee0: 31 38 38 20 41 4e 44 20 28 63 31 38 39 20 41 4e  188 AND (c189 AN
2ef0: 44 20 28 63 31 39 30 20 41 4e 44 20 28 63 31 39  D (c190 AND (c19
2f00: 31 20 41 4e 44 20 28 63 31 39 32 20 41 4e 44 20  1 AND (c192 AND 
2f10: 28 63 31 39 33 20 41 4e 44 20 28 63 31 39 34 20  (c193 AND (c194 
2f20: 41 4e 44 20 28 63 31 39 35 20 41 4e 44 20 28 63  AND (c195 AND (c
2f30: 31 39 36 20 41 4e 44 20 28 63 31 39 37 20 41 4e  196 AND (c197 AN
2f40: 44 20 28 63 31 39 38 20 41 4e 44 20 28 63 31 39  D (c198 AND (c19
2f50: 39 20 41 4e 44 20 63 32 30 30 29 29 29 29 29 29  9 AND c200))))))
2f60: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2f70: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2f80: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2f90: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2fa0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2fb0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2fc0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2fd0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2fe0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
2ff0: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
3000: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
3010: 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29  ))))))))))))))))
3020: 29 27 3b 0a 7d 20 7b 31 20 7b 66 74 73 35 3a 20  )';.} {1 {fts5: 
3030: 70 61 72 73 65 72 20 73 74 61 63 6b 20 6f 76 65  parser stack ove
3040: 72 66 6c 6f 77 7d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d  rflow}}..#------
3050: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3060: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3080: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3090: 2d 2d 2d 0a 72 65 73 65 74 5f 64 62 0a 62 72 65  ---.reset_db.bre
30a0: 61 6b 70 6f 69 6e 74 0a 64 6f 5f 65 78 65 63 73  akpoint.do_execs
30b0: 71 6c 5f 74 65 73 74 20 32 30 2e 30 20 7b 0a 20  ql_test 20.0 {. 
30c0: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20   CREATE VIRTUAL 
30d0: 54 41 42 4c 45 20 78 31 20 55 53 49 4e 47 20 66  TABLE x1 USING f
30e0: 74 73 35 28 78 29 3b 0a 20 20 49 4e 53 45 52 54  ts5(x);.  INSERT
30f0: 20 49 4e 54 4f 20 78 31 28 78 31 2c 20 72 61 6e   INTO x1(x1, ran
3100: 6b 29 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27  k) VALUES('pgsz'
3110: 2c 20 33 32 29 3b 0a 20 20 49 4e 53 45 52 54 20  , 32);.  INSERT 
3120: 49 4e 54 4f 20 78 31 28 72 6f 77 69 64 2c 20 78  INTO x1(rowid, x
3130: 29 20 56 41 4c 55 45 53 28 31 31 31 31 31 2c 20  ) VALUES(11111, 
3140: 27 6f 6e 65 74 77 6f 74 68 72 65 65 27 29 3b 0a  'onetwothree');.
3150: 7d 0a 64 6f 5f 74 65 73 74 20 32 30 2e 31 20 7b  }.do_test 20.1 {
3160: 0a 20 20 66 6f 72 20 7b 73 65 74 20 69 20 31 7d  .  for {set i 1}
3170: 20 7b 24 69 20 3c 3d 20 32 30 30 7d 20 7b 69 6e   {$i <= 200} {in
3180: 63 72 20 69 7d 20 7b 0a 20 20 20 20 65 78 65 63  cr i} {.    exec
3190: 73 71 6c 20 7b 20 49 4e 53 45 52 54 20 49 4e 54  sql { INSERT INT
31a0: 4f 20 78 31 28 72 6f 77 69 64 2c 20 78 29 20 56  O x1(rowid, x) V
31b0: 41 4c 55 45 53 28 24 69 2c 20 27 6f 6e 65 20 74  ALUES($i, 'one t
31c0: 77 6f 20 74 68 72 65 65 27 29 3b 20 7d 0a 20 20  wo three'); }.  
31d0: 7d 0a 20 20 65 78 65 63 73 71 6c 20 7b 20 49 4e  }.  execsql { IN
31e0: 53 45 52 54 20 49 4e 54 4f 20 78 31 28 78 31 29  SERT INTO x1(x1)
31f0: 20 56 41 4c 55 45 53 28 27 6f 70 74 69 6d 69 7a   VALUES('optimiz
3200: 65 27 29 3b 20 7d 0a 20 20 65 78 65 63 73 71 6c  e'); }.  execsql
3210: 20 7b 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 78   { DELETE FROM x
3220: 31 20 57 48 45 52 45 20 72 6f 77 69 64 20 3d 20  1 WHERE rowid = 
3230: 34 3b 20 7d 0a 7d 20 7b 7d 0a 64 6f 5f 65 78 65  4; }.} {}.do_exe
3240: 63 73 71 6c 5f 74 65 73 74 20 32 30 2e 32 20 7b  csql_test 20.2 {
3250: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78  .  INSERT INTO x
3260: 31 28 78 31 29 20 56 41 4c 55 45 53 28 27 6f 70  1(x1) VALUES('op
3270: 74 69 6d 69 7a 65 27 29 3b 0a 20 20 49 4e 53 45  timize');.  INSE
3280: 52 54 20 49 4e 54 4f 20 78 31 28 78 31 29 20 56  RT INTO x1(x1) V
3290: 41 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79  ALUES('integrity
32a0: 2d 63 68 65 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a  -check');.} {}..
32b0: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
32c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
32d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
32e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
32f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74  ----------.reset
3300: 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  _db.do_execsql_t
3310: 65 73 74 20 32 30 2e 30 20 7b 0a 20 20 43 52 45  est 20.0 {.  CRE
3320: 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c  ATE VIRTUAL TABL
3330: 45 20 78 31 20 55 53 49 4e 47 20 66 74 73 35 28  E x1 USING fts5(
3340: 78 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  x);.  INSERT INT
3350: 4f 20 78 31 28 78 31 2c 20 72 61 6e 6b 29 20 56  O x1(x1, rank) V
3360: 41 4c 55 45 53 28 27 70 67 73 7a 27 2c 20 33 32  ALUES('pgsz', 32
3370: 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
3380: 20 78 31 28 72 6f 77 69 64 2c 20 78 29 20 56 41   x1(rowid, x) VA
3390: 4c 55 45 53 28 31 31 31 31 31 2c 20 27 6f 6e 65  LUES(11111, 'one
33a0: 74 77 6f 74 68 72 65 65 27 29 3b 0a 7d 0a 64 6f  twothree');.}.do
33b0: 5f 74 65 73 74 20 32 30 2e 31 20 7b 0a 20 20 66  _test 20.1 {.  f
33c0: 6f 72 20 7b 73 65 74 20 69 20 31 7d 20 7b 24 69  or {set i 1} {$i
33d0: 20 3c 3d 20 32 30 30 7d 20 7b 69 6e 63 72 20 69   <= 200} {incr i
33e0: 7d 20 7b 0a 20 20 20 20 65 78 65 63 73 71 6c 20  } {.    execsql 
33f0: 7b 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78 31  { INSERT INTO x1
3400: 28 72 6f 77 69 64 2c 20 78 29 20 56 41 4c 55 45  (rowid, x) VALUE
3410: 53 28 24 69 2c 20 27 6f 6e 65 20 74 77 6f 20 74  S($i, 'one two t
3420: 68 72 65 65 27 29 3b 20 7d 0a 20 20 7d 0a 20 20  hree'); }.  }.  
3430: 65 78 65 63 73 71 6c 20 7b 20 49 4e 53 45 52 54  execsql { INSERT
3440: 20 49 4e 54 4f 20 78 31 28 78 31 29 20 56 41 4c   INTO x1(x1) VAL
3450: 55 45 53 28 27 6f 70 74 69 6d 69 7a 65 27 29 3b  UES('optimize');
3460: 20 7d 0a 20 20 65 78 65 63 73 71 6c 20 7b 20 44   }.  execsql { D
3470: 45 4c 45 54 45 20 46 52 4f 4d 20 78 31 20 57 48  ELETE FROM x1 WH
3480: 45 52 45 20 72 6f 77 69 64 20 3d 20 34 3b 20 7d  ERE rowid = 4; }
3490: 0a 7d 20 7b 7d 0a 64 6f 5f 65 78 65 63 73 71 6c  .} {}.do_execsql
34a0: 5f 74 65 73 74 20 32 30 2e 32 20 7b 0a 20 20 49  _test 20.2 {.  I
34b0: 4e 53 45 52 54 20 49 4e 54 4f 20 78 31 28 78 31  NSERT INTO x1(x1
34c0: 29 20 56 41 4c 55 45 53 28 27 6f 70 74 69 6d 69  ) VALUES('optimi
34d0: 7a 65 27 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  ze');.  INSERT I
34e0: 4e 54 4f 20 78 31 28 78 31 29 20 56 41 4c 55 45  NTO x1(x1) VALUE
34f0: 53 28 27 69 6e 74 65 67 72 69 74 79 2d 63 68 65  S('integrity-che
3500: 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d  ck');.} {}..#---
3510: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3520: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3530: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3540: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3550: 2d 2d 2d 2d 2d 2d 0a 72 65 73 65 74 5f 64 62 0a  ------.reset_db.
3560: 73 65 74 20 64 6f 63 20 22 61 20 62 20 5b 73 74  set doc "a b [st
3570: 72 69 6e 67 20 72 65 70 65 61 74 20 78 20 31 30  ring repeat x 10
3580: 30 30 30 30 5d 22 0a 64 6f 5f 65 78 65 63 73 71  0000]".do_execsq
3590: 6c 5f 74 65 73 74 20 32 31 2e 30 20 7b 0a 20 20  l_test 21.0 {.  
35a0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
35b0: 41 42 4c 45 20 78 31 20 55 53 49 4e 47 20 66 74  ABLE x1 USING ft
35c0: 73 35 28 78 29 3b 0a 20 20 49 4e 53 45 52 54 20  s5(x);.  INSERT 
35d0: 49 4e 54 4f 20 78 31 28 72 6f 77 69 64 2c 20 78  INTO x1(rowid, x
35e0: 29 20 56 41 4c 55 45 53 28 31 31 31 31 31 2c 20  ) VALUES(11111, 
35f0: 24 64 6f 63 29 3b 0a 20 20 49 4e 53 45 52 54 20  $doc);.  INSERT 
3600: 49 4e 54 4f 20 78 31 28 72 6f 77 69 64 2c 20 78  INTO x1(rowid, x
3610: 29 20 56 41 4c 55 45 53 28 31 31 31 31 32 2c 20  ) VALUES(11112, 
3620: 24 64 6f 63 29 3b 0a 7d 0a 64 6f 5f 65 78 65 63  $doc);.}.do_exec
3630: 73 71 6c 5f 74 65 73 74 20 32 31 2e 31 20 7b 0a  sql_test 21.1 {.
3640: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78 31    INSERT INTO x1
3650: 28 78 31 29 20 56 41 4c 55 45 53 28 27 69 6e 74  (x1) VALUES('int
3660: 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29 3b 0a  egrity-check');.
3670: 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  }.do_execsql_tes
3680: 74 20 32 31 2e 32 20 7b 0a 20 20 53 45 4c 45 43  t 21.2 {.  SELEC
3690: 54 20 72 6f 77 69 64 20 46 52 4f 4d 20 78 31 28  T rowid FROM x1(
36a0: 24 64 6f 63 29 3b 0a 7d 20 7b 31 31 31 31 31 20  $doc);.} {11111 
36b0: 31 31 31 31 32 7d 0a 64 6f 5f 65 78 65 63 73 71  11112}.do_execsq
36c0: 6c 5f 74 65 73 74 20 32 31 2e 33 20 7b 0a 20 20  l_test 21.3 {.  
36d0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 78 31 20 57  DELETE FROM x1 W
36e0: 48 45 52 45 20 72 6f 77 69 64 3d 31 31 31 31 31  HERE rowid=11111
36f0: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
3700: 78 31 28 78 31 29 20 56 41 4c 55 45 53 28 27 69  x1(x1) VALUES('i
3710: 6e 74 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29  ntegrity-check')
3720: 3b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64  ;.  SELECT rowid
3730: 20 46 52 4f 4d 20 78 31 28 24 64 6f 63 29 3b 0a   FROM x1($doc);.
3740: 7d 20 7b 31 31 31 31 32 7d 0a 0a 66 69 6e 69 73  } {11112}..finis
3750: 68 5f 74 65 73 74 0a                             h_test.