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

Artifact 2bc6451cbe887a9215f5b14ae307c70d850344c9:


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 20 69 66 20 31 20  return.}.. if 1 
0230: 7b 0a 0a 23 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 2d 0a 23 0a  -------------.#.
0280: 73 65 74 20 64 6f 63 20 22 78 20 78 20 5b 73 74  set doc "x x [st
0290: 72 69 6e 67 20 72 65 70 65 61 74 20 7b 79 20 7d  ring repeat {y }
02a0: 20 35 30 5d 7a 20 7a 22 0a 64 6f 5f 65 78 65 63   50]z z".do_exec
02b0: 73 71 6c 5f 74 65 73 74 20 31 2e 30 20 7b 0a 20  sql_test 1.0 {. 
02c0: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20   CREATE VIRTUAL 
02d0: 54 41 42 4c 45 20 74 31 20 55 53 49 4e 47 20 66  TABLE t1 USING f
02e0: 74 73 35 28 78 29 3b 0a 20 20 49 4e 53 45 52 54  ts5(x);.  INSERT
02f0: 20 49 4e 54 4f 20 74 31 28 74 31 2c 20 72 61 6e   INTO t1(t1, ran
0300: 6b 29 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27  k) VALUES('pgsz'
0310: 2c 20 33 32 29 3b 0a 20 20 42 45 47 49 4e 3b 0a  , 32);.  BEGIN;.
0320: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
0330: 74 31 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b  t1 VALUES($doc);
0340: 0a 20 20 43 4f 4d 4d 49 54 3b 0a 7d 0a 0a 64 6f  .  COMMIT;.}..do
0350: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 2e  _execsql_test 1.
0360: 31 20 7b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  1 {.  INSERT INT
0370: 4f 20 74 31 28 74 31 29 20 56 41 4c 55 45 53 28  O t1(t1) VALUES(
0380: 27 69 6e 74 65 67 72 69 74 79 2d 63 68 65 63 6b  'integrity-check
0390: 27 29 3b 0a 7d 0a 0a 23 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: 2d 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f  -.#.reset_db.do_
03f0: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 32 2e 30  execsql_test 2.0
0400: 20 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54   {.  CREATE VIRT
0410: 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53 49  UAL TABLE t1 USI
0420: 4e 47 20 66 74 73 35 28 78 29 3b 0a 20 20 49 4e  NG fts5(x);.  IN
0430: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 74 31 2c  SERT INTO t1(t1,
0440: 20 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70   rank) VALUES('p
0450: 67 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53  gsz', 32);.  INS
0460: 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41 4c 55  ERT INTO t1 VALU
0470: 45 53 28 27 61 20 62 20 63 27 29 3b 0a 20 20 49  ES('a b c');.  I
0480: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 20 56 41  NSERT INTO t1 VA
0490: 4c 55 45 53 28 27 64 20 65 20 66 27 29 3b 0a 20  LUES('d e f');. 
04a0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
04b0: 74 31 29 20 56 41 4c 55 45 53 28 27 6f 70 74 69  t1) VALUES('opti
04c0: 6d 69 7a 65 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78  mize');.}..do_ex
04d0: 65 63 73 71 6c 5f 74 65 73 74 20 32 2e 31 20 7b  ecsql_test 2.1 {
04e0: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
04f0: 31 28 74 31 29 20 56 41 4c 55 45 53 28 27 69 6e  1(t1) VALUES('in
0500: 74 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29 3b  tegrity-check');
0510: 0a 7d 20 7b 7d 0a 0a 0a 23 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 2d 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f  --.#.reset_db.do
0570: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 33 2e  _execsql_test 3.
0580: 30 20 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52  0 {.  CREATE VIR
0590: 54 55 41 4c 20 54 41 42 4c 45 20 74 31 20 55 53  TUAL TABLE t1 US
05a0: 49 4e 47 20 66 74 73 35 28 78 2c 20 70 72 65 66  ING fts5(x, pref
05b0: 69 78 3d 27 31 2c 32 27 29 3b 0a 20 20 49 4e 53  ix='1,2');.  INS
05c0: 45 52 54 20 49 4e 54 4f 20 74 31 28 74 31 2c 20  ERT INTO t1(t1, 
05d0: 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67  rank) VALUES('pg
05e0: 73 7a 27 2c 20 33 32 29 3b 0a 20 20 42 45 47 49  sz', 32);.  BEGI
05f0: 4e 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  N;.  INSERT INTO
0600: 20 74 31 20 56 41 4c 55 45 53 28 27 6f 6e 65 27   t1 VALUES('one'
0610: 29 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  );.  SELECT * FR
0620: 4f 4d 20 74 31 20 57 48 45 52 45 20 74 31 20 4d  OM t1 WHERE t1 M
0630: 41 54 43 48 20 27 6f 2a 27 3b 0a 7d 20 7b 6f 6e  ATCH 'o*';.} {on
0640: 65 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  e}..do_execsql_t
0650: 65 73 74 20 33 2e 31 20 7b 0a 20 20 49 4e 53 45  est 3.1 {.  INSE
0660: 52 54 20 49 4e 54 4f 20 74 31 28 74 31 29 20 56  RT INTO t1(t1) V
0670: 41 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79  ALUES('integrity
0680: 2d 63 68 65 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a  -check');.} {}..
0690: 23 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 2d 0a 72 65 73 65 74  ----------.reset
06e0: 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  _db.do_execsql_t
06f0: 65 73 74 20 34 2e 31 20 7b 0a 20 20 43 52 45 41  est 4.1 {.  CREA
0700: 54 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45  TE VIRTUAL TABLE
0710: 20 74 31 31 20 55 53 49 4e 47 20 66 74 73 35 28   t11 USING fts5(
0720: 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45  content);.  INSE
0730: 52 54 20 49 4e 54 4f 20 74 31 31 28 74 31 31 2c  RT INTO t11(t11,
0740: 20 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70   rank) VALUES('p
0750: 67 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53  gsz', 32);.  INS
0760: 45 52 54 20 49 4e 54 4f 20 74 31 31 20 56 41 4c  ERT INTO t11 VAL
0770: 55 45 53 28 27 61 6e 6f 74 68 65 72 27 29 3b 0a  UES('another');.
0780: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
0790: 31 20 56 41 4c 55 45 53 28 27 73 74 72 69 6e 67  1 VALUES('string
07a0: 27 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ');.  INSERT INT
07b0: 4f 20 74 31 31 20 56 41 4c 55 45 53 28 27 6f 66  O t11 VALUES('of
07c0: 27 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ');.  INSERT INT
07d0: 4f 20 74 31 31 20 56 41 4c 55 45 53 28 27 74 65  O t11 VALUES('te
07e0: 78 74 27 29 3b 0a 7d 0a 64 6f 5f 74 65 73 74 20  xt');.}.do_test 
07f0: 34 2e 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20  4.2 {.  execsql 
0800: 7b 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31  { INSERT INTO t1
0810: 31 28 74 31 31 29 20 56 41 4c 55 45 53 28 27 6f  1(t11) VALUES('o
0820: 70 74 69 6d 69 7a 65 27 29 20 7d 0a 7d 20 7b 7d  ptimize') }.} {}
0830: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
0840: 20 34 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54 20   4.3 {.  INSERT 
0850: 49 4e 54 4f 20 74 31 31 28 74 31 31 29 20 56 41  INTO t11(t11) VA
0860: 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d  LUES('integrity-
0870: 63 68 65 63 6b 27 29 3b 0a 7d 20 7b 7d 0a 0a 23  check');.} {}..#
0880: 64 62 20 65 76 61 6c 20 7b 20 53 45 4c 45 43 54  db eval { SELECT
0890: 20 66 74 73 35 5f 64 65 63 6f 64 65 28 72 6f 77   fts5_decode(row
08a0: 69 64 2c 20 62 6c 6f 63 6b 29 20 61 73 20 78 20  id, block) as x 
08b0: 46 52 4f 4d 20 74 31 31 5f 64 61 74 61 20 7d 20  FROM t11_data } 
08c0: 7b 20 70 75 74 73 20 24 78 20 7d 0a 0a 23 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 2d 0a 72 65 73 65 74 5f 64 62  -------.reset_db
0920: 0a 73 65 74 20 64 6f 63 20 5b 73 74 72 69 6e 67  .set doc [string
0930: 20 72 65 70 65 61 74 20 22 78 20 79 20 22 20 35   repeat "x y " 5
0940: 5d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ].do_execsql_tes
0950: 74 20 35 2e 31 20 7b 0a 20 20 43 52 45 41 54 45  t 5.1 {.  CREATE
0960: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 79   VIRTUAL TABLE y
0970: 79 20 55 53 49 4e 47 20 66 74 73 35 28 63 6f 6e  y USING fts5(con
0980: 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52 54 20  tent);.  INSERT 
0990: 49 4e 54 4f 20 79 79 28 79 79 2c 20 72 61 6e 6b  INTO yy(yy, rank
09a0: 29 20 56 41 4c 55 45 53 28 27 70 67 73 7a 27 2c  ) VALUES('pgsz',
09b0: 20 33 32 29 3b 0a 20 20 42 45 47 49 4e 3b 0a 20   32);.  BEGIN;. 
09c0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 79     INSERT INTO y
09d0: 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b 0a  y VALUES($doc);.
09e0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
09f0: 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29 3b  yy VALUES($doc);
0a00: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
0a10: 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63 29   yy VALUES($doc)
0a20: 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ;.    INSERT INT
0a30: 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f 63  O yy VALUES($doc
0a40: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
0a50: 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64 6f  TO yy VALUES($do
0a60: 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  c);.    INSERT I
0a70: 4e 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24 64  NTO yy VALUES($d
0a80: 6f 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  oc);.    INSERT 
0a90: 49 4e 54 4f 20 79 79 20 56 41 4c 55 45 53 28 24  INTO yy VALUES($
0aa0: 64 6f 63 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  doc);.    INSERT
0ab0: 20 49 4e 54 4f 20 79 79 20 56 41 4c 55 45 53 28   INTO yy VALUES(
0ac0: 24 64 6f 63 29 3b 0a 20 20 43 4f 4d 4d 49 54 3b  $doc);.  COMMIT;
0ad0: 0a 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74  .}..do_execsql_t
0ae0: 65 73 74 20 35 2e 32 20 7b 0a 20 20 53 45 4c 45  est 5.2 {.  SELE
0af0: 43 54 20 72 6f 77 69 64 20 46 52 4f 4d 20 79 79  CT rowid FROM yy
0b00: 20 57 48 45 52 45 20 79 79 20 4d 41 54 43 48 20   WHERE yy MATCH 
0b10: 27 79 27 20 4f 52 44 45 52 20 42 59 20 72 6f 77  'y' ORDER BY row
0b20: 69 64 20 41 53 43 0a 7d 20 7b 31 20 32 20 33 20  id ASC.} {1 2 3 
0b30: 34 20 35 20 36 20 37 20 38 7d 0a 0a 64 6f 5f 65  4 5 6 7 8}..do_e
0b40: 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 33 20  xecsql_test 5.3 
0b50: 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64  {.  SELECT rowid
0b60: 20 46 52 4f 4d 20 79 79 20 57 48 45 52 45 20 79   FROM yy WHERE y
0b70: 79 20 4d 41 54 43 48 20 27 79 27 20 4f 52 44 45  y MATCH 'y' ORDE
0b80: 52 20 42 59 20 72 6f 77 69 64 20 44 45 53 43 0a  R BY rowid DESC.
0b90: 7d 20 7b 38 20 37 20 36 20 35 20 34 20 33 20 32  } {8 7 6 5 4 3 2
0ba0: 20 31 7d 0a 0a 23 64 62 20 65 76 61 6c 20 7b 20   1}..#db eval { 
0bb0: 53 45 4c 45 43 54 20 66 74 73 35 5f 64 65 63 6f  SELECT fts5_deco
0bc0: 64 65 28 72 6f 77 69 64 2c 20 62 6c 6f 63 6b 29  de(rowid, block)
0bd0: 20 61 73 20 78 20 46 52 4f 4d 20 79 79 5f 64 61   as x FROM yy_da
0be0: 74 61 20 7d 20 7b 20 70 75 74 73 20 24 78 20 7d  ta } { puts $x }
0bf0: 0a 0a 23 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 2d 0a 72 65 73  ------------.res
0c40: 65 74 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c  et_db.do_execsql
0c50: 5f 74 65 73 74 20 35 2e 31 20 7b 0a 20 20 43 52  _test 5.1 {.  CR
0c60: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42  EATE VIRTUAL TAB
0c70: 4c 45 20 74 74 20 55 53 49 4e 47 20 66 74 73 35  LE tt USING fts5
0c80: 28 63 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53  (content);.  INS
0c90: 45 52 54 20 49 4e 54 4f 20 74 74 28 74 74 2c 20  ERT INTO tt(tt, 
0ca0: 72 61 6e 6b 29 20 56 41 4c 55 45 53 28 27 70 67  rank) VALUES('pg
0cb0: 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49 4e 53 45  sz', 32);.  INSE
0cc0: 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45  RT INTO tt VALUE
0cd0: 53 28 27 61 61 27 29 3b 0a 7d 0a 0a 64 6f 5f 65  S('aa');.}..do_e
0ce0: 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e 32 20  xecsql_test 5.2 
0cf0: 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64  {.  SELECT rowid
0d00: 20 46 52 4f 4d 20 74 74 20 57 48 45 52 45 20 74   FROM tt WHERE t
0d10: 74 20 4d 41 54 43 48 20 27 61 2a 27 3b 0a 7d 20  t MATCH 'a*';.} 
0d20: 7b 31 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f  {1}..do_execsql_
0d30: 74 65 73 74 20 35 2e 33 20 7b 0a 20 20 44 45 4c  test 5.3 {.  DEL
0d40: 45 54 45 20 46 52 4f 4d 20 74 74 3b 0a 20 20 42  ETE FROM tt;.  B
0d50: 45 47 49 4e 3b 0a 20 20 20 20 49 4e 53 45 52 54  EGIN;.    INSERT
0d60: 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28   INTO tt VALUES(
0d70: 27 61 61 27 29 3b 0a 20 20 20 20 49 4e 53 45 52  'aa');.    INSER
0d80: 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53  T INTO tt VALUES
0d90: 28 27 61 62 27 29 3b 0a 20 20 43 4f 4d 4d 49 54  ('ab');.  COMMIT
0da0: 3b 0a 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73  ;.} {}..do_execs
0db0: 71 6c 5f 74 65 73 74 20 35 2e 34 20 7b 0a 20 20  ql_test 5.4 {.  
0dc0: 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f  SELECT rowid FRO
0dd0: 4d 20 74 74 20 57 48 45 52 45 20 74 74 20 4d 41  M tt WHERE tt MA
0de0: 54 43 48 20 27 61 2a 27 3b 0a 7d 20 7b 31 20 32  TCH 'a*';.} {1 2
0df0: 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  }..do_execsql_te
0e00: 73 74 20 35 2e 35 20 7b 0a 20 20 44 45 4c 45 54  st 5.5 {.  DELET
0e10: 45 20 46 52 4f 4d 20 74 74 3b 0a 20 20 42 45 47  E FROM tt;.  BEG
0e20: 49 4e 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49  IN;.    INSERT I
0e30: 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27 61  NTO tt VALUES('a
0e40: 61 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  a');.    INSERT 
0e50: 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28 27  INTO tt VALUES('
0e60: 61 62 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54  ab');.    INSERT
0e70: 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53 28   INTO tt VALUES(
0e80: 27 61 61 27 29 3b 0a 20 20 20 20 49 4e 53 45 52  'aa');.    INSER
0e90: 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45 53  T INTO tt VALUES
0ea0: 28 27 61 62 27 29 3b 0a 20 20 20 20 49 4e 53 45  ('ab');.    INSE
0eb0: 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55 45  RT INTO tt VALUE
0ec0: 53 28 27 61 61 27 29 3b 0a 20 20 20 20 49 4e 53  S('aa');.    INS
0ed0: 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c 55  ERT INTO tt VALU
0ee0: 45 53 28 27 61 62 27 29 3b 0a 20 20 20 20 49 4e  ES('ab');.    IN
0ef0: 53 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41 4c  SERT INTO tt VAL
0f00: 55 45 53 28 27 61 61 27 29 3b 0a 20 20 20 20 49  UES('aa');.    I
0f10: 4e 53 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41  NSERT INTO tt VA
0f20: 4c 55 45 53 28 27 61 62 27 29 3b 0a 20 20 43 4f  LUES('ab');.  CO
0f30: 4d 4d 49 54 3b 0a 20 20 53 45 4c 45 43 54 20 72  MMIT;.  SELECT r
0f40: 6f 77 69 64 20 46 52 4f 4d 20 74 74 20 57 48 45  owid FROM tt WHE
0f50: 52 45 20 74 74 20 4d 41 54 43 48 20 27 61 2a 27  RE tt MATCH 'a*'
0f60: 3b 0a 7d 20 7b 31 20 32 20 33 20 34 20 35 20 36  ;.} {1 2 3 4 5 6
0f70: 20 37 20 38 7d 0a 0a 64 6f 5f 65 78 65 63 73 71   7 8}..do_execsq
0f80: 6c 5f 74 65 73 74 20 35 2e 36 20 7b 0a 20 20 49  l_test 5.6 {.  I
0f90: 4e 53 45 52 54 20 49 4e 54 4f 20 74 74 28 74 74  NSERT INTO tt(tt
0fa0: 29 20 56 41 4c 55 45 53 28 27 69 6e 74 65 67 72  ) VALUES('integr
0fb0: 69 74 79 2d 63 68 65 63 6b 27 29 3b 0a 7d 0a 0a  ity-check');.}..
0fc0: 72 65 73 65 74 5f 64 62 0a 64 6f 5f 65 78 65 63  reset_db.do_exec
0fd0: 73 71 6c 5f 74 65 73 74 20 35 2e 37 20 7b 0a 20  sql_test 5.7 {. 
0fe0: 20 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20   CREATE VIRTUAL 
0ff0: 54 41 42 4c 45 20 74 74 20 55 53 49 4e 47 20 66  TABLE tt USING f
1000: 74 73 35 28 63 6f 6e 74 65 6e 74 29 3b 0a 20 20  ts5(content);.  
1010: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 74 28 74  INSERT INTO tt(t
1020: 74 2c 20 72 61 6e 6b 29 20 56 41 4c 55 45 53 28  t, rank) VALUES(
1030: 27 70 67 73 7a 27 2c 20 33 32 29 3b 0a 20 20 49  'pgsz', 32);.  I
1040: 4e 53 45 52 54 20 49 4e 54 4f 20 74 74 20 56 41  NSERT INTO tt VA
1050: 4c 55 45 53 28 27 61 61 20 61 62 20 61 63 20 61  LUES('aa ab ac a
1060: 64 20 61 65 20 61 66 27 29 3b 0a 7d 0a 0a 64 6f  d ae af');.}..do
1070: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 35 2e  _execsql_test 5.
1080: 38 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77  8 {.  SELECT row
1090: 69 64 20 46 52 4f 4d 20 74 74 20 57 48 45 52 45  id FROM tt WHERE
10a0: 20 74 74 20 4d 41 54 43 48 20 27 61 2a 27 3b 0a   tt MATCH 'a*';.
10b0: 7d 20 7b 31 7d 0a 0a 23 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: 2d 0a 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f 65  -..reset_db.do_e
1110: 78 65 63 73 71 6c 5f 74 65 73 74 20 36 2e 31 20  xecsql_test 6.1 
1120: 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55  {.  CREATE VIRTU
1130: 41 4c 20 54 41 42 4c 45 20 78 79 7a 20 55 53 49  AL TABLE xyz USI
1140: 4e 47 20 66 74 73 35 28 78 2c 20 79 2c 20 7a 29  NG fts5(x, y, z)
1150: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
1160: 78 79 7a 20 56 41 4c 55 45 53 28 27 78 27 2c 20  xyz VALUES('x', 
1170: 27 79 27 2c 20 27 7a 27 29 3b 0a 7d 0a 0a 64 6f  'y', 'z');.}..do
1180: 5f 63 61 74 63 68 73 71 6c 5f 74 65 73 74 20 36  _catchsql_test 6
1190: 2e 32 20 7b 20 0a 20 20 53 45 4c 45 43 54 20 2a  .2 { .  SELECT *
11a0: 20 46 52 4f 4d 20 78 79 7a 20 57 48 45 52 45 20   FROM xyz WHERE 
11b0: 78 79 7a 20 4d 41 54 43 48 20 27 27 20 0a 7d 20  xyz MATCH '' .} 
11c0: 7b 31 20 7b 66 74 73 35 3a 20 73 79 6e 74 61 78  {1 {fts5: syntax
11d0: 20 65 72 72 6f 72 20 6e 65 61 72 20 22 22 7d 7d   error near ""}}
11e0: 0a 64 6f 5f 63 61 74 63 68 73 71 6c 5f 74 65 73  .do_catchsql_tes
11f0: 74 20 36 2e 33 20 7b 20 0a 20 20 53 45 4c 45 43  t 6.3 { .  SELEC
1200: 54 20 2a 20 46 52 4f 4d 20 78 79 7a 20 57 48 45  T * FROM xyz WHE
1210: 52 45 20 78 79 7a 20 4d 41 54 43 48 20 4e 55 4c  RE xyz MATCH NUL
1220: 4c 20 0a 7d 20 7b 31 20 7b 66 74 73 35 3a 20 73  L .} {1 {fts5: s
1230: 79 6e 74 61 78 20 65 72 72 6f 72 20 6e 65 61 72  yntax error near
1240: 20 22 22 7d 7d 0a 0a 23 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: 2d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  -..do_execsql_te
12a0: 73 74 20 37 2e 31 20 7b 0a 20 20 43 52 45 41 54  st 7.1 {.  CREAT
12b0: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20  E VIRTUAL TABLE 
12c0: 66 74 32 20 55 53 49 4e 47 20 66 74 73 35 28 63  ft2 USING fts5(c
12d0: 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52  ontent);.  INSER
12e0: 54 20 49 4e 54 4f 20 66 74 32 28 72 6f 77 69 64  T INTO ft2(rowid
12f0: 2c 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c 55 45  , content) VALUE
1300: 53 28 31 2c 20 27 61 20 62 20 63 27 29 3b 0a 20  S(1, 'a b c');. 
1310: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 66 74 32   INSERT INTO ft2
1320: 28 72 6f 77 69 64 2c 20 63 6f 6e 74 65 6e 74 29  (rowid, content)
1330: 20 56 41 4c 55 45 53 28 32 2c 20 27 61 20 62 20   VALUES(2, 'a b 
1340: 64 27 29 3b 0a 7d 20 0a 0a 64 6f 5f 63 61 74 63  d');.} ..do_catc
1350: 68 73 71 6c 5f 74 65 73 74 20 37 2e 32 20 7b 0a  hsql_test 7.2 {.
1360: 20 20 42 45 47 49 4e 3b 0a 20 20 20 20 55 50 44    BEGIN;.    UPD
1370: 41 54 45 20 66 74 32 20 53 45 54 20 72 6f 77 69  ATE ft2 SET rowi
1380: 64 3d 32 20 57 48 45 52 45 20 72 6f 77 69 64 3d  d=2 WHERE rowid=
1390: 31 3b 0a 7d 20 7b 31 20 7b 63 6f 6e 73 74 72 61  1;.} {1 {constra
13a0: 69 6e 74 20 66 61 69 6c 65 64 7d 7d 20 0a 0a 64  int failed}} ..d
13b0: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 37  o_execsql_test 7
13c0: 2e 33 20 7b 0a 20 20 43 4f 4d 4d 49 54 3b 0a 20  .3 {.  COMMIT;. 
13d0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 66 74 32   INSERT INTO ft2
13e0: 28 66 74 32 29 20 56 41 4c 55 45 53 28 27 69 6e  (ft2) VALUES('in
13f0: 74 65 67 72 69 74 79 2d 63 68 65 63 6b 27 29 3b  tegrity-check');
1400: 0a 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71  .} {}..do_execsq
1410: 6c 5f 74 65 73 74 20 37 2e 34 20 7b 0a 20 20 53  l_test 7.4 {.  S
1420: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 66 74 32  ELECT * FROM ft2
1430: 3b 0a 7d 20 7b 7b 61 20 62 20 63 7d 20 7b 61 20  ;.} {{a b c} {a 
1440: 62 20 64 7d 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d 2d  b 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: 2d 0a 23 0a 72 65 73 65 74 5f 64 62 0a 64 6f 5f  -.#.reset_db.do_
14a0: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 38 2e 31  execsql_test 8.1
14b0: 20 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54   {.  CREATE VIRT
14c0: 55 41 4c 20 54 41 42 4c 45 20 66 74 32 20 55 53  UAL TABLE ft2 US
14d0: 49 4e 47 20 66 74 73 35 28 63 6f 6e 74 65 6e 74  ING fts5(content
14e0: 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
14f0: 20 66 74 32 28 72 6f 77 69 64 2c 20 63 6f 6e 74   ft2(rowid, cont
1500: 65 6e 74 29 20 56 41 4c 55 45 53 28 31 2c 20 27  ent) VALUES(1, '
1510: 61 20 62 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78 65  a b');.}..do_exe
1520: 63 73 71 6c 5f 74 65 73 74 20 38 2e 32 20 7b 0a  csql_test 8.2 {.
1530: 20 20 42 45 47 49 4e 3b 0a 20 20 20 20 49 4e 53    BEGIN;.    INS
1540: 45 52 54 20 49 4e 54 4f 20 66 74 32 28 72 6f 77  ERT INTO ft2(row
1550: 69 64 2c 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c  id, content) VAL
1560: 55 45 53 28 34 2c 20 27 61 20 78 27 29 3b 0a 7d  UES(4, 'a x');.}
1570: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
1580: 74 20 38 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54  t 8.3 {.  INSERT
1590: 20 49 4e 54 4f 20 66 74 32 28 66 74 32 29 20 56   INTO ft2(ft2) V
15a0: 41 4c 55 45 53 28 27 69 6e 74 65 67 72 69 74 79  ALUES('integrity
15b0: 2d 63 68 65 63 6b 27 29 3b 0a 7d 0a 0a 23 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 2d 0a 23 20 43 68 65 63 6b 20  -------.# Check 
1610: 74 68 61 74 20 74 68 65 20 22 74 61 62 6c 65 20  that the "table 
1620: 66 75 6e 63 74 69 6f 6e 22 20 73 79 6e 74 61 78  function" syntax
1630: 20 77 6f 72 6b 73 2e 0a 23 0a 72 65 73 65 74 5f   works..#.reset_
1640: 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65  db.do_execsql_te
1650: 73 74 20 39 2e 31 20 7b 0a 20 20 43 52 45 41 54  st 9.1 {.  CREAT
1660: 45 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20  E VIRTUAL TABLE 
1670: 66 74 32 20 55 53 49 4e 47 20 66 74 73 35 28 63  ft2 USING fts5(c
1680: 6f 6e 74 65 6e 74 29 3b 0a 20 20 49 4e 53 45 52  ontent);.  INSER
1690: 54 20 49 4e 54 4f 20 66 74 32 28 72 6f 77 69 64  T INTO ft2(rowid
16a0: 2c 20 63 6f 6e 74 65 6e 74 29 20 56 41 4c 55 45  , content) VALUE
16b0: 53 28 31 2c 20 27 61 20 62 27 29 3b 0a 20 20 49  S(1, 'a b');.  I
16c0: 4e 53 45 52 54 20 49 4e 54 4f 20 66 74 32 28 72  NSERT INTO ft2(r
16d0: 6f 77 69 64 2c 20 63 6f 6e 74 65 6e 74 29 20 56  owid, content) V
16e0: 41 4c 55 45 53 28 32 2c 20 27 61 20 62 20 63 20  ALUES(2, 'a b c 
16f0: 64 27 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  d');.  INSERT IN
1700: 54 4f 20 66 74 32 28 72 6f 77 69 64 2c 20 63 6f  TO ft2(rowid, co
1710: 6e 74 65 6e 74 29 20 56 41 4c 55 45 53 28 33 2c  ntent) VALUES(3,
1720: 20 27 63 20 64 20 65 20 66 27 29 3b 0a 7d 0a 0a   'c d e f');.}..
1730: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1740: 39 2e 32 20 7b 0a 20 20 53 45 4c 45 43 54 20 72  9.2 {.  SELECT r
1750: 6f 77 69 64 20 46 52 4f 4d 20 66 74 32 28 27 61  owid FROM ft2('a
1760: 27 29 3b 0a 7d 20 7b 31 20 32 7d 0a 0a 64 6f 5f  ');.} {1 2}..do_
1770: 65 78 65 63 73 71 6c 5f 74 65 73 74 20 39 2e 33  execsql_test 9.3
1780: 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69   {.  SELECT rowi
1790: 64 20 46 52 4f 4d 20 66 74 32 28 27 62 20 41 4e  d FROM ft2('b AN
17a0: 44 20 63 27 29 3b 0a 7d 20 7b 32 7d 0a 0a 23 2d  D 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 2d 0a 23 0a 64 6f 5f 65 78  --------.#.do_ex
1800: 65 63 73 71 6c 5f 74 65 73 74 20 31 30 2e 30 20  ecsql_test 10.0 
1810: 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55  {.  CREATE VIRTU
1820: 41 4c 20 54 41 42 4c 45 20 74 33 20 55 53 49 4e  AL TABLE t3 USIN
1830: 47 20 66 74 73 35 28 61 2c 20 62 2c 20 63 29 3b  G fts5(a, b, c);
1840: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
1850: 33 20 56 41 4c 55 45 53 28 27 62 61 63 20 61 61  3 VALUES('bac aa
1860: 62 20 62 61 62 27 2c 20 27 63 20 62 61 63 20 63  b bab', 'c bac c
1870: 27 2c 20 27 61 63 62 20 61 62 61 20 61 62 62 27  ', 'acb aba abb'
1880: 29 3b 20 2d 2d 20 31 0a 20 20 49 4e 53 45 52 54  ); -- 1.  INSERT
1890: 20 49 4e 54 4f 20 74 33 20 56 41 4c 55 45 53 28   INTO t3 VALUES(
18a0: 27 62 61 62 20 61 62 63 20 63 27 2c 20 27 61 63  'bab abc c', 'ac
18b0: 62 20 63 20 61 62 62 27 2c 20 27 63 20 61 61 61  b c abb', 'c aaa
18c0: 20 63 27 29 3b 20 20 20 20 20 2d 2d 20 32 0a 7d   c');     -- 2.}
18d0: 0a 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  ..do_execsql_tes
18e0: 74 20 31 30 2e 31 20 7b 0a 20 20 53 45 4c 45 43  t 10.1 {.  SELEC
18f0: 54 20 72 6f 77 69 64 20 46 52 4f 4d 20 74 33 28  T rowid FROM t3(
1900: 27 63 3a 20 63 2a 27 29 3b 0a 7d 20 7b 32 7d 0a  'c: c*');.} {2}.
1910: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
1920: 20 31 30 2e 32 20 7b 0a 20 20 53 45 4c 45 43 54   10.2 {.  SELECT
1930: 20 72 6f 77 69 64 20 46 52 4f 4d 20 74 33 28 27   rowid FROM t3('
1940: 62 3a 20 61 63 62 27 29 3b 0a 7d 20 7b 32 7d 0a  b: acb');.} {2}.
1950: 0a 23 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 2d 0a 23 20 54 65  -----------.# Te
19a0: 73 74 20 74 68 61 74 20 63 68 61 72 61 63 74 65  st that characte
19b0: 72 20 30 78 31 41 20 69 73 20 61 6c 6c 6f 77 65  r 0x1A is allowe
19c0: 64 20 69 6e 20 66 74 73 35 20 62 61 72 65 77 6f  d in fts5 barewo
19d0: 72 64 73 2e 0a 23 0a 64 6f 5f 74 65 73 74 20 31  rds..#.do_test 1
19e0: 31 2e 30 20 7b 0a 20 20 65 78 65 63 73 71 6c 20  1.0 {.  execsql 
19f0: 22 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20  "CREATE VIRTUAL 
1a00: 54 41 42 4c 45 20 74 34 20 55 53 49 4e 47 20 66  TABLE t4 USING f
1a10: 74 73 35 28 78 2c 20 74 6f 6b 65 6e 69 7a 65 3d  ts5(x, tokenize=
1a20: 5c 22 61 73 63 69 69 20 74 6f 6b 65 6e 63 68 61  \"ascii tokencha
1a30: 72 73 20 27 5c 78 31 41 27 5c 22 29 22 0a 20 20  rs '\x1A'\")".  
1a40: 65 78 65 63 73 71 6c 20 22 0a 20 20 20 20 49 4e  execsql ".    IN
1a50: 53 45 52 54 20 49 4e 54 4f 20 74 34 20 56 41 4c  SERT INTO t4 VAL
1a60: 55 45 53 28 27 61 20 62 20 63 20 5c 78 31 41 27  UES('a b c \x1A'
1a70: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
1a80: 54 4f 20 74 34 20 56 41 4c 55 45 53 28 27 61 20  TO t4 VALUES('a 
1a90: 62 20 63 20 64 5c 78 31 41 27 29 3b 0a 20 20 20  b c d\x1A');.   
1aa0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 34 20   INSERT INTO t4 
1ab0: 56 41 4c 55 45 53 28 27 61 20 62 20 63 20 5c 78  VALUES('a b c \x
1ac0: 31 41 64 27 29 3b 0a 20 20 20 20 49 4e 53 45 52  1Ad');.    INSER
1ad0: 54 20 49 4e 54 4f 20 74 34 20 56 41 4c 55 45 53  T INTO t4 VALUES
1ae0: 28 27 61 20 62 20 63 20 64 27 29 3b 0a 20 20 22  ('a b c d');.  "
1af0: 0a 7d 20 7b 7d 0a 0a 64 6f 5f 74 65 73 74 20 31  .} {}..do_test 1
1b00: 31 2e 31 20 7b 0a 20 20 65 78 65 63 73 71 6c 20  1.1 {.  execsql 
1b10: 22 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52  "SELECT rowid FR
1b20: 4f 4d 20 74 34 28 27 5c 78 31 41 27 29 22 0a 7d  OM t4('\x1A')".}
1b30: 20 7b 31 7d 0a 64 6f 5f 74 65 73 74 20 31 31 2e   {1}.do_test 11.
1b40: 32 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22 53  2 {.  execsql "S
1b50: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
1b60: 20 74 34 28 27 5c 78 31 41 2a 27 29 22 0a 7d 20   t4('\x1A*')".} 
1b70: 7b 31 20 33 7d 0a 64 6f 5f 74 65 73 74 20 31 31  {1 3}.do_test 11
1b80: 2e 33 20 7b 0a 20 20 65 78 65 63 73 71 6c 20 22  .3 {.  execsql "
1b90: 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f  SELECT rowid FRO
1ba0: 4d 20 74 34 28 27 64 5c 78 31 41 27 29 22 0a 7d  M t4('d\x1A')".}
1bb0: 20 7b 32 7d 0a 0a 64 6f 5f 74 65 73 74 20 31 31   {2}..do_test 11
1bc0: 2e 34 20 7b 0a 20 20 63 61 74 63 68 73 71 6c 20  .4 {.  catchsql 
1bd0: 22 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52  "SELECT rowid FR
1be0: 4f 4d 20 74 34 28 27 64 5c 78 31 42 27 29 22 0a  OM t4('d\x1B')".
1bf0: 7d 20 7b 2f 66 74 73 35 3a 20 73 79 6e 74 61 78  } {/fts5: syntax
1c00: 20 65 72 72 6f 72 2f 7d 0a 64 6f 5f 74 65 73 74   error/}.do_test
1c10: 20 31 31 2e 35 20 7b 0a 20 20 63 61 74 63 68 73   11.5 {.  catchs
1c20: 71 6c 20 22 53 45 4c 45 43 54 20 72 6f 77 69 64  ql "SELECT rowid
1c30: 20 46 52 4f 4d 20 74 34 28 27 64 5c 78 31 39 27   FROM t4('d\x19'
1c40: 29 22 0a 7d 20 7b 2f 66 74 73 35 3a 20 73 79 6e  )".} {/fts5: syn
1c50: 74 61 78 20 65 72 72 6f 72 2f 7d 0a 0a 23 2d 2d  tax 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 2d 0a 23 0a 64 6f 5f 74 65 73  -------.#.do_tes
1cb0: 74 20 31 32 2e 31 20 7b 0a 20 20 65 78 65 63 73  t 12.1 {.  execs
1cc0: 71 6c 20 7b 0a 20 20 20 20 43 52 45 41 54 45 20  ql {.    CREATE 
1cd0: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 78 78  VIRTUAL TABLE xx
1ce0: 20 55 53 49 4e 47 20 66 74 73 35 28 78 2c 79 29   USING fts5(x,y)
1cf0: 3b 0a 20 20 20 20 42 45 47 49 4e 3b 0a 20 20 20  ;.    BEGIN;.   
1d00: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78     INSERT INTO x
1d10: 78 20 56 41 4c 55 45 53 28 27 31 20 32 20 33 27  x VALUES('1 2 3'
1d20: 2c 20 27 61 20 62 20 63 27 29 3b 0a 20 20 7d 0a  , 'a b c');.  }.
1d30: 7d 20 7b 7d 0a 0a 64 6f 5f 65 78 65 63 73 71 6c  } {}..do_execsql
1d40: 5f 74 65 73 74 20 31 32 2e 32 20 7b 0a 20 20 53  _test 12.2 {.  S
1d50: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
1d60: 20 78 78 28 27 78 3a 61 27 29 3b 0a 20 20 43 4f   xx('x:a');.  CO
1d70: 4d 4d 49 54 3b 0a 7d 20 7b 7d 0a 0a 23 2d 2d 2d  MMIT;.} {}..#---
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 2d 0a 23 20 54 72 79 20 61 6e 20  ------.# Try an 
1dd0: 55 50 44 41 54 45 20 4f 52 20 52 45 50 4c 41 43  UPDATE OR REPLAC
1de0: 45 20 71 75 65 72 79 2e 0a 23 0a 64 6f 5f 65 78  E query..#.do_ex
1df0: 65 63 73 71 6c 5f 74 65 73 74 20 31 33 2e 31 20  ecsql_test 13.1 
1e00: 7b 0a 20 20 43 52 45 41 54 45 20 56 49 52 54 55  {.  CREATE VIRTU
1e10: 41 4c 20 54 41 42 4c 45 20 78 79 20 55 53 49 4e  AL TABLE xy USIN
1e20: 47 20 66 74 73 35 28 78 29 3b 0a 20 20 49 4e 53  G fts5(x);.  INS
1e30: 45 52 54 20 49 4e 54 4f 20 78 79 28 72 6f 77 69  ERT INTO xy(rowi
1e40: 64 2c 20 78 29 20 56 41 4c 55 45 53 28 31 2c 20  d, x) VALUES(1, 
1e50: 27 31 20 32 20 33 27 29 3b 0a 20 20 49 4e 53 45  '1 2 3');.  INSE
1e60: 52 54 20 49 4e 54 4f 20 78 79 28 72 6f 77 69 64  RT INTO xy(rowid
1e70: 2c 20 78 29 20 56 41 4c 55 45 53 28 32 2c 20 27  , x) VALUES(2, '
1e80: 32 20 33 20 34 27 29 3b 0a 20 20 49 4e 53 45 52  2 3 4');.  INSER
1e90: 54 20 49 4e 54 4f 20 78 79 28 72 6f 77 69 64 2c  T INTO xy(rowid,
1ea0: 20 78 29 20 56 41 4c 55 45 53 28 33 2c 20 27 33   x) VALUES(3, '3
1eb0: 20 34 20 35 27 29 3b 0a 7d 0a 0a 64 6f 5f 65 78   4 5');.}..do_ex
1ec0: 65 63 73 71 6c 5f 74 65 73 74 20 31 33 2e 32 20  ecsql_test 13.2 
1ed0: 7b 0a 20 20 55 50 44 41 54 45 20 4f 52 20 52 45  {.  UPDATE OR RE
1ee0: 50 4c 41 43 45 20 78 79 20 53 45 54 20 72 6f 77  PLACE xy SET row
1ef0: 69 64 3d 33 20 57 48 45 52 45 20 72 6f 77 69 64  id=3 WHERE rowid
1f00: 20 3d 20 32 3b 0a 20 20 53 45 4c 45 43 54 20 72   = 2;.  SELECT r
1f10: 6f 77 69 64 2c 20 78 20 46 52 4f 4d 20 78 79 3b  owid, x FROM xy;
1f20: 0a 7d 20 7b 0a 20 20 31 20 7b 31 20 32 20 33 7d  .} {.  1 {1 2 3}
1f30: 0a 20 20 33 20 7b 32 20 33 20 34 7d 0a 7d 0a 0a  .  3 {2 3 4}.}..
1f40: 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20  do_execsql_test 
1f50: 31 33 2e 33 20 7b 0a 20 20 49 4e 53 45 52 54 20  13.3 {.  INSERT 
1f60: 49 4e 54 4f 20 78 79 28 78 79 29 20 56 41 4c 55  INTO xy(xy) VALU
1f70: 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d 63 68  ES('integrity-ch
1f80: 65 63 6b 27 29 3b 0a 7d 0a 0a 23 2d 2d 2d 2d 2d  eck');.}..#-----
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 2d 0a 23 0a 64 6f 5f 65 78 65 63 73 71  ----.#.do_execsq
1fe0: 6c 5f 74 65 73 74 20 31 34 2e 31 20 7b 0a 20 20  l_test 14.1 {.  
1ff0: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
2000: 41 42 4c 45 20 74 74 74 20 55 53 49 4e 47 20 66  ABLE ttt USING f
2010: 74 73 35 28 78 29 3b 0a 20 20 42 45 47 49 4e 3b  ts5(x);.  BEGIN;
2020: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2030: 20 74 74 74 28 72 6f 77 69 64 2c 20 78 29 20 56   ttt(rowid, x) V
2040: 41 4c 55 45 53 28 31 2c 20 27 61 20 62 20 63 27  ALUES(1, 'a b c'
2050: 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  );.    INSERT IN
2060: 54 4f 20 74 74 74 28 72 6f 77 69 64 2c 20 78 29  TO ttt(rowid, x)
2070: 20 56 41 4c 55 45 53 28 32 2c 20 27 61 20 62 20   VALUES(2, 'a b 
2080: 63 27 29 3b 0a 20 20 20 20 49 4e 53 45 52 54 20  c');.    INSERT 
2090: 49 4e 54 4f 20 74 74 74 28 72 6f 77 69 64 2c 20  INTO ttt(rowid, 
20a0: 78 29 20 56 41 4c 55 45 53 28 33 2c 20 27 61 20  x) VALUES(3, 'a 
20b0: 62 20 63 27 29 3b 0a 20 20 43 4f 4d 4d 49 54 3b  b c');.  COMMIT;
20c0: 0a 7d 0a 64 6f 5f 74 65 73 74 20 31 34 2e 32 20  .}.do_test 14.2 
20d0: 7b 20 0a 20 20 66 74 73 35 5f 6c 65 76 65 6c 5f  { .  fts5_level_
20e0: 73 65 67 73 20 74 74 74 20 0a 7d 20 7b 31 7d 0a  segs ttt .} {1}.
20f0: 0a 23 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 2d 0a 64 62 20 66  -----------.db f
2140: 75 6e 63 20 72 6e 64 64 6f 63 20 66 74 73 35 5f  unc rnddoc fts5_
2150: 72 6e 64 64 6f 63 0a 64 6f 5f 65 78 65 63 73 71  rnddoc.do_execsq
2160: 6c 5f 74 65 73 74 20 34 2e 30 20 7b 0a 20 20 43  l_test 4.0 {.  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 34 2e 31 20 7b 0a 20  sql_test 4.1 {. 
2250: 20 53 45 4c 45 43 54 20 72 6f 77 69 64 2c 20 78   SELECT rowid, x
2260: 2c 20 78 31 20 46 52 4f 4d 20 78 31 20 57 48 45  , x1 FROM x1 WHE
2270: 52 45 20 78 31 20 4d 41 54 43 48 20 27 2a 72 65  RE x1 MATCH '*re
2280: 61 64 73 27 0a 7d 20 7b 30 20 7b 7d 20 34 7d 0a  ads'.} {0 {} 4}.
2290: 0a 23 2d 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 0a 72 65 73 65  -----------.rese
22e0: 74 5f 64 62 0a 64 6f 5f 65 78 65 63 73 71 6c 5f  t_db.do_execsql_
22f0: 74 65 73 74 20 31 35 2e 30 20 7b 0a 20 20 43 52  test 15.0 {.  CR
2300: 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 42  EATE VIRTUAL TAB
2310: 4c 45 20 78 32 20 55 53 49 4e 47 20 66 74 73 35  LE x2 USING fts5
2320: 28 78 2c 20 70 72 65 66 69 78 3d 31 29 3b 0a 20  (x, prefix=1);. 
2330: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 78 32 20   INSERT INTO x2 
2340: 56 41 4c 55 45 53 28 27 61 62 27 29 3b 0a 7d 0a  VALUES('ab');.}.
2350: 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74  .do_execsql_test
2360: 20 31 35 2e 31 20 7b 0a 20 20 49 4e 53 45 52 54   15.1 {.  INSERT
2370: 20 49 4e 54 4f 20 78 32 28 78 32 29 20 56 41 4c   INTO x2(x2) VAL
2380: 55 45 53 28 27 69 6e 74 65 67 72 69 74 79 2d 63  UES('integrity-c
2390: 68 65 63 6b 27 29 3b 0a 7d 0a 0a 7d 0a 0a 23 2d  heck');.}..}..#-
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 2d 2d 0a 66 6f 72 65 61 63 68  --------.foreach
23f0: 5f 64 65 74 61 69 6c 5f 6d 6f 64 65 20 24 74 65  _detail_mode $te
2400: 73 74 70 72 65 66 69 78 20 7b 0a 20 20 72 65 73  stprefix {.  res
2410: 65 74 5f 64 62 0a 20 20 66 74 73 35 5f 61 75 78  et_db.  fts5_aux
2420: 5f 74 65 73 74 5f 66 75 6e 63 74 69 6f 6e 73 20  _test_functions 
2430: 64 62 0a 20 20 64 6f 5f 65 78 65 63 73 71 6c 5f  db.  do_execsql_
2440: 74 65 73 74 20 31 36 2e 30 20 7b 0a 20 20 20 20  test 16.0 {.    
2450: 43 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54  CREATE VIRTUAL T
2460: 41 42 4c 45 20 78 33 20 55 53 49 4e 47 20 66 74  ABLE x3 USING ft
2470: 73 35 28 78 2c 20 64 65 74 61 69 6c 3d 25 44 45  s5(x, detail=%DE
2480: 54 41 49 4c 25 29 3b 0a 20 20 20 20 49 4e 53 45  TAIL%);.    INSE
2490: 52 54 20 49 4e 54 4f 20 78 33 20 56 41 4c 55 45  RT INTO x3 VALUE
24a0: 53 28 27 61 20 62 20 63 20 64 20 65 20 66 27 29  S('a b c d e f')
24b0: 3b 0a 20 20 7d 0a 20 20 64 6f 5f 65 78 65 63 73  ;.  }.  do_execs
24c0: 71 6c 5f 74 65 73 74 20 31 36 2e 31 20 7b 0a 20  ql_test 16.1 {. 
24d0: 20 20 20 53 45 4c 45 43 54 20 66 74 73 35 5f 74     SELECT fts5_t
24e0: 65 73 74 5f 70 6f 73 6c 69 73 74 28 78 33 29 20  est_poslist(x3) 
24f0: 46 52 4f 4d 20 78 33 28 27 28 61 20 4e 4f 54 20  FROM x3('(a NOT 
2500: 62 29 20 4f 52 20 63 27 29 3b 0a 20 20 7d 20 7b  b) OR c');.  } {
2510: 32 2e 30 2e 32 7d 0a 0a 20 20 64 6f 5f 65 78 65  2.0.2}..  do_exe
2520: 63 73 71 6c 5f 74 65 73 74 20 31 36 2e 31 20 7b  csql_test 16.1 {
2530: 0a 20 20 20 20 53 45 4c 45 43 54 20 66 74 73 35  .    SELECT fts5
2540: 5f 74 65 73 74 5f 70 6f 73 6c 69 73 74 28 78 33  _test_poslist(x3
2550: 29 20 46 52 4f 4d 20 78 33 28 27 61 20 4f 52 20  ) FROM x3('a OR 
2560: 63 27 29 3b 0a 20 20 7d 20 7b 7b 30 2e 30 2e 30  c');.  } {{0.0.0
2570: 20 31 2e 30 2e 32 7d 7d 0a 7d 0a 0a 66 69 6e 69   1.0.2}}.}..fini
2580: 73 68 5f 74 65 73 74 0a 0a                       sh_test..