/ Hex Artifact Content
Login

Artifact 1368738e3298a7ce0dee3a44d6ebb8f468b2a76f3d1dd18d4ea6d8bc2eeccc1b:


0000: 23 20 32 30 30 36 20 53 65 70 74 65 6d 62 65 72  # 2006 September
0010: 20 39 0a 23 0a 23 20 54 68 65 20 61 75 74 68 6f   9.#.# The autho
0020: 72 20 64 69 73 63 6c 61 69 6d 73 20 63 6f 70 79  r disclaims copy
0030: 72 69 67 68 74 20 74 6f 20 74 68 69 73 20 73 6f  right to this so
0040: 75 72 63 65 20 63 6f 64 65 2e 20 20 49 6e 20 70  urce code.  In p
0050: 6c 61 63 65 20 6f 66 0a 23 20 61 20 6c 65 67 61  lace of.# a lega
0060: 6c 20 6e 6f 74 69 63 65 2c 20 68 65 72 65 20 69  l notice, here i
0070: 73 20 61 20 62 6c 65 73 73 69 6e 67 3a 0a 23 0a  s a blessing:.#.
0080: 23 20 20 20 20 4d 61 79 20 79 6f 75 20 64 6f 20  #    May you do 
0090: 67 6f 6f 64 20 61 6e 64 20 6e 6f 74 20 65 76 69  good and not evi
00a0: 6c 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20  l..#    May you 
00b0: 66 69 6e 64 20 66 6f 72 67 69 76 65 6e 65 73 73  find forgiveness
00c0: 20 66 6f 72 20 79 6f 75 72 73 65 6c 66 20 61 6e   for yourself an
00d0: 64 20 66 6f 72 67 69 76 65 20 6f 74 68 65 72 73  d forgive others
00e0: 2e 0a 23 20 20 20 20 4d 61 79 20 79 6f 75 20 73  ..#    May you s
00f0: 68 61 72 65 20 66 72 65 65 6c 79 2c 20 6e 65 76  hare freely, nev
0100: 65 72 20 74 61 6b 69 6e 67 20 6d 6f 72 65 20 74  er taking more t
0110: 68 61 6e 20 79 6f 75 20 67 69 76 65 2e 0a 23 0a  han you give..#.
0120: 23 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  #***************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 0a 23 20 54 68 69  **********.# Thi
0170: 73 20 66 69 6c 65 20 69 6d 70 6c 65 6d 65 6e 74  s file implement
0180: 73 20 72 65 67 72 65 73 73 69 6f 6e 20 74 65 73  s regression tes
0190: 74 73 20 66 6f 72 20 53 51 4c 69 74 65 20 6c 69  ts for SQLite li
01a0: 62 72 61 72 79 2e 20 20 54 68 65 0a 23 20 66 6f  brary.  The.# fo
01b0: 63 75 73 20 6f 66 20 74 68 69 73 20 73 63 72 69  cus of this scri
01c0: 70 74 20 69 73 20 74 65 73 74 69 6e 67 20 74 68  pt is testing th
01d0: 65 20 46 54 53 33 20 6d 6f 64 75 6c 65 2e 0a 23  e FTS3 module..#
01e0: 0a 0a 73 65 74 20 74 65 73 74 64 69 72 20 5b 66  ..set testdir [f
01f0: 69 6c 65 20 64 69 72 6e 61 6d 65 20 24 61 72 67  ile dirname $arg
0200: 76 30 5d 0a 73 6f 75 72 63 65 20 24 74 65 73 74  v0].source $test
0210: 64 69 72 2f 74 65 73 74 65 72 2e 74 63 6c 0a 73  dir/tester.tcl.s
0220: 65 74 20 74 65 73 74 70 72 65 66 69 78 20 66 74  et testprefix ft
0230: 73 33 65 78 70 72 35 0a 0a 23 20 49 66 20 53 51  s3expr5..# If SQ
0240: 4c 49 54 45 5f 45 4e 41 42 4c 45 5f 46 54 53 33  LITE_ENABLE_FTS3
0250: 20 69 73 20 64 65 66 69 6e 65 64 2c 20 6f 6d 69   is defined, omi
0260: 74 20 74 68 69 73 20 66 69 6c 65 2e 0a 69 66 63  t this file..ifc
0270: 61 70 61 62 6c 65 20 21 66 74 73 33 20 7b 0a 20  apable !fts3 {. 
0280: 20 66 69 6e 69 73 68 5f 74 65 73 74 0a 20 20 72   finish_test.  r
0290: 65 74 75 72 6e 0a 7d 0a 0a 70 72 6f 63 20 74 65  eturn.}..proc te
02a0: 73 74 5f 66 74 73 33 65 78 70 72 20 7b 65 78 70  st_fts3expr {exp
02b0: 72 7d 20 7b 0a 20 20 64 62 20 6f 6e 65 20 7b 53  r} {.  db one {S
02c0: 45 4c 45 43 54 20 66 74 73 33 5f 65 78 70 72 74  ELECT fts3_exprt
02d0: 65 73 74 28 27 73 69 6d 70 6c 65 27 2c 20 24 65  est('simple', $e
02e0: 78 70 72 2c 20 27 61 27 2c 20 27 62 27 2c 20 27  xpr, 'a', 'b', '
02f0: 63 27 29 7d 0a 7d 0a 0a 23 2d 2d 2d 2d 2d 2d 2d  c')}.}..#-------
0300: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0310: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0320: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0330: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0340: 2d 2d 0a 23 20 56 61 72 69 6f 75 73 20 66 6f 72  --.# Various for
0350: 6d 73 20 6f 66 20 65 6d 70 74 79 20 70 68 72 61  ms of empty phra
0360: 73 65 20 65 78 70 72 65 73 73 69 6f 6e 73 2e 0a  se expressions..
0370: 23 0a 64 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73  #.do_execsql_tes
0380: 74 20 31 2e 30 20 7b 0a 20 20 43 52 45 41 54 45  t 1.0 {.  CREATE
0390: 20 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74   VIRTUAL TABLE t
03a0: 30 20 55 53 49 4e 47 20 66 74 73 33 28 78 29 3b  0 USING fts3(x);
03b0: 0a 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 20  .  SELECT rowid 
03c0: 46 52 4f 4d 20 74 30 20 57 48 45 52 45 20 78 20  FROM t0 WHERE x 
03d0: 4d 41 54 43 48 20 27 27 3b 0a 7d 20 7b 7d 0a 64  MATCH '';.} {}.d
03e0: 6f 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31  o_execsql_test 1
03f0: 2e 31 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f  .1 {.  SELECT ro
0400: 77 69 64 20 46 52 4f 4d 20 74 30 20 57 48 45 52  wid FROM t0 WHER
0410: 45 20 78 20 4d 41 54 43 48 20 27 22 22 27 3b 0a  E x MATCH '""';.
0420: 7d 20 7b 7d 0a 64 6f 5f 65 78 65 63 73 71 6c 5f  } {}.do_execsql_
0430: 74 65 73 74 20 31 2e 32 20 7b 0a 20 20 53 45 4c  test 1.2 {.  SEL
0440: 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d 20 74  ECT rowid FROM t
0450: 30 20 57 48 45 52 45 20 78 20 4d 41 54 43 48 20  0 WHERE x MATCH 
0460: 27 22 22 20 22 22 27 3b 0a 7d 20 7b 7d 0a 64 6f  '"" ""';.} {}.do
0470: 5f 65 78 65 63 73 71 6c 5f 74 65 73 74 20 31 2e  _execsql_test 1.
0480: 33 20 7b 0a 20 20 53 45 4c 45 43 54 20 72 6f 77  3 {.  SELECT row
0490: 69 64 20 46 52 4f 4d 20 74 30 20 57 48 45 52 45  id FROM t0 WHERE
04a0: 20 78 20 4d 41 54 43 48 20 27 22 22 20 4f 52 20   x MATCH '"" OR 
04b0: 22 22 27 3b 0a 7d 20 7b 7d 0a 64 6f 5f 65 78 65  ""';.} {}.do_exe
04c0: 63 73 71 6c 5f 74 65 73 74 20 31 2e 34 20 7b 0a  csql_test 1.4 {.
04d0: 20 20 53 45 4c 45 43 54 20 72 6f 77 69 64 20 46    SELECT rowid F
04e0: 52 4f 4d 20 74 30 20 57 48 45 52 45 20 78 20 4d  ROM t0 WHERE x M
04f0: 41 54 43 48 20 27 22 22 20 4e 4f 54 20 22 22 27  ATCH '"" NOT ""'
0500: 3b 0a 7d 20 7b 7d 0a 64 6f 5f 65 78 65 63 73 71  ;.} {}.do_execsq
0510: 6c 5f 74 65 73 74 20 31 2e 35 20 7b 0a 20 20 53  l_test 1.5 {.  S
0520: 45 4c 45 43 54 20 72 6f 77 69 64 20 46 52 4f 4d  ELECT rowid FROM
0530: 20 74 30 20 57 48 45 52 45 20 78 20 4d 41 54 43   t0 WHERE x MATC
0540: 48 20 27 22 22 22 22 27 3b 0a 7d 20 7b 7d 0a 0a  H '""""';.} {}..
0550: 23 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  #---------------
0560: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0570: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0580: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0590: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 23 20 56 61 72  ----------.# Var
05a0: 69 6f 75 73 20 66 6f 72 6d 73 20 6f 66 20 65 6d  ious forms of em
05b0: 70 74 79 20 70 68 72 61 73 65 20 65 78 70 72 65  pty phrase expre
05c0: 73 73 69 6f 6e 73 2e 0a 23 0a 73 65 74 20 73 71  ssions..#.set sq
05d0: 6c 69 74 65 5f 66 74 73 33 5f 65 6e 61 62 6c 65  lite_fts3_enable
05e0: 5f 70 61 72 65 6e 74 68 65 73 65 73 20 31 0a 64  _parentheses 1.d
05f0: 6f 5f 74 65 73 74 20 32 2e 30 20 7b 0a 20 20 74  o_test 2.0 {.  t
0600: 65 73 74 5f 66 74 73 33 65 78 70 72 20 7b 28 61  est_fts3expr {(a
0610: 3a 31 32 33 29 28 62 3a 32 33 34 29 28 29 28 63  :123)(b:234)()(c
0620: 3a 34 35 36 29 7d 0a 7d 20 7b 41 4e 44 20 7b 41  :456)}.} {AND {A
0630: 4e 44 20 7b 50 48 52 41 53 45 20 30 20 30 20 31  ND {PHRASE 0 0 1
0640: 32 33 7d 20 7b 50 48 52 41 53 45 20 31 20 30 20  23} {PHRASE 1 0 
0650: 32 33 34 7d 7d 20 7b 50 48 52 41 53 45 20 32 20  234}} {PHRASE 2 
0660: 30 20 34 35 36 7d 7d 0a 64 6f 5f 74 65 73 74 20  0 456}}.do_test 
0670: 32 2e 31 20 7b 0a 20 20 74 65 73 74 5f 66 74 73  2.1 {.  test_fts
0680: 33 65 78 70 72 20 7b 28 61 3a 31 32 33 29 28 62  3expr {(a:123)(b
0690: 3a 32 33 34 29 28 63 3a 34 35 36 29 7d 0a 7d 20  :234)(c:456)}.} 
06a0: 7b 41 4e 44 20 7b 41 4e 44 20 7b 50 48 52 41 53  {AND {AND {PHRAS
06b0: 45 20 30 20 30 20 31 32 33 7d 20 7b 50 48 52 41  E 0 0 123} {PHRA
06c0: 53 45 20 31 20 30 20 32 33 34 7d 7d 20 7b 50 48  SE 1 0 234}} {PH
06d0: 52 41 53 45 20 32 20 30 20 34 35 36 7d 7d 0a 64  RASE 2 0 456}}.d
06e0: 6f 5f 74 65 73 74 20 32 2e 32 20 7b 0a 20 20 6c  o_test 2.2 {.  l
06f0: 69 73 74 20 5b 63 61 74 63 68 20 7b 20 74 65 73  ist [catch { tes
0700: 74 5f 66 74 73 33 65 78 70 72 20 7b 22 31 32 33  t_fts3expr {"123
0710: 22 20 41 4e 44 20 28 20 29 7d 20 7d 20 6d 73 67  " AND ( )} } msg
0720: 5d 20 24 6d 73 67 0a 7d 20 7b 31 20 7b 45 72 72  ] $msg.} {1 {Err
0730: 6f 72 20 70 61 72 73 69 6e 67 20 65 78 70 72 65  or parsing expre
0740: 73 73 69 6f 6e 7d 7d 0a 0a 66 69 6e 69 73 68 5f  ssion}}..finish_
0750: 74 65 73 74 0a 0a                                test..