/ Check-in [d9135cc7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix fts5vocab.test so that it works with detail=none tables.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts5-offsets
Files: files | file ages | folders
SHA1: d9135cc723fc4227aace6dcf4ffa4630c9d23aa0
User & Date: dan 2016-01-08 07:53:09
Context
2016-01-08
17:21
Begin adding fts5 tests involving synonyms and detail=none/col tables. check-in: b3e6f15e user: dan tags: fts5-offsets
07:53
Fix fts5vocab.test so that it works with detail=none tables. check-in: d9135cc7 user: dan tags: fts5-offsets
2016-01-07
20:07
Update the fts5vocab module to work with detail=col and detail=none tables. check-in: eedd095d user: dan tags: fts5-offsets
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/fts5/test/fts5vocab.test.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
..
52
53
54
55
56
57
58









59
60
61
62
63
64
65
...
136
137
138
139
140
141
142



143
144
145
146
147
148
149
...
310
311
312
313
314
315
316

317
318
319
320
321
322
323
...
374
375
376
377
378
379
380

381
382
383
384

385
386
387
388
389
ifcapable !fts5 {
  finish_test
  return
}

foreach_detail_mode $testprefix {

if {[detail_is_none]} continue

proc null_list_entries {iFirst nInterval L} {
  for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} {
    lset L $i {}
  }
  return $L
}

proc null_insert {iFirst nInterval L} {
  for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} {
    lset L $i {}
  }
  return $L
}

proc star_from_row {L} {
................................................................................
  }
  if {[detail_is_none]} {
    set L [null_list_entries 1 4 $L]
    set L [null_list_entries 3 4 $L]
  }
  return $L
}










do_execsql_test 1.1.1 {
  CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%);
  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row');
  PRAGMA table_info = v1;
} {
  0 term {} 0 {} 0
................................................................................
  c a 6 12    c b 5 8 
  d a 4 6     d b 9 13 
  e a 6 7     e b 6 6 
  f a 9 10    f b 7 10 
  g a 5 7     g b 5 7
  x a 1 1     y b 1 1
}]




foreach {tn tbl resname} {
  1 "fts5vocab(tt, 'col')" res_col
  2 "fts5vocab(tt, 'row')" res_row
  3 "fts5vocab(tt, \"row\")" res_row
  4 "fts5vocab(tt, [row])" res_row
  5 "fts5vocab(tt, `row`)" res_row
................................................................................
  }]
  if {[lindex $r2 2]==0} {set r2 [list]}

  set resc [concat $r1 $r2]

  set resc [star_from_col $resc]
  set resr [star_from_row $resr]

  do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc
  do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr
}

do_execsql_test 7.1 {
  CREATE TABLE txr_c AS SELECT * FROM txr;
  CREATE TABLE txc_c AS SELECT * FROM txc;
................................................................................
  } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}]
}

do_execsql_test 7.3.1 {
  SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term;
} {30}


do_execsql_test 7.3.2 {
  SELECT count(*) FROM txc, txc_c 
  WHERE txc.term = txc_c.term AND txc.col=txc_c.col;
} {57}


}

finish_test








<
<

<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>







 







>
>
>







 







>







 







>
|
|
|
|
>





19
20
21
22
23
24
25


26







27
28
29
30
31
32
33
..
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
...
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
ifcapable !fts5 {
  finish_test
  return
}

foreach_detail_mode $testprefix {



proc null_list_entries {iFirst nInterval L} {







  for {set i $iFirst} {$i < [llength $L]} {incr i $nInterval} {
    lset L $i {}
  }
  return $L
}

proc star_from_row {L} {
................................................................................
  }
  if {[detail_is_none]} {
    set L [null_list_entries 1 4 $L]
    set L [null_list_entries 3 4 $L]
  }
  return $L
}

proc row_to_col {L} {
  if {[detail_is_none]==0} { error "this is for detail=none mode" }
  set ret [list]
  foreach {a b c} $L {
    lappend ret $a {} $b {}
  }
  set ret
}

do_execsql_test 1.1.1 {
  CREATE VIRTUAL TABLE t1 USING fts5(one, prefix=1, detail=%DETAIL%);
  CREATE VIRTUAL TABLE v1 USING fts5vocab(t1, 'row');
  PRAGMA table_info = v1;
} {
  0 term {} 0 {} 0
................................................................................
  c a 6 12    c b 5 8 
  d a 4 6     d b 9 13 
  e a 6 7     e b 6 6 
  f a 9 10    f b 7 10 
  g a 5 7     g b 5 7
  x a 1 1     y b 1 1
}]
if {[detail_is_none]} {
  set res_col [row_to_col $res_row]
}

foreach {tn tbl resname} {
  1 "fts5vocab(tt, 'col')" res_col
  2 "fts5vocab(tt, 'row')" res_row
  3 "fts5vocab(tt, \"row\")" res_row
  4 "fts5vocab(tt, [row])" res_row
  5 "fts5vocab(tt, `row`)" res_row
................................................................................
  }]
  if {[lindex $r2 2]==0} {set r2 [list]}

  set resc [concat $r1 $r2]

  set resc [star_from_col $resc]
  set resr [star_from_row $resr]
  if {[detail_is_none]} { set resc [row_to_col $resr] }
  do_execsql_test 7.$term.1 {SELECT * FROM txc WHERE term=$term} $resc
  do_execsql_test 7.$term.2 {SELECT * FROM txr WHERE term=$term} $resr
}

do_execsql_test 7.1 {
  CREATE TABLE txr_c AS SELECT * FROM txr;
  CREATE TABLE txc_c AS SELECT * FROM txc;
................................................................................
  } [db eval {SELECT * FROM txc_c WHERE term>$a AND term <$b}]
}

do_execsql_test 7.3.1 {
  SELECT count(*) FROM txr, txr_c WHERE txr.term = txr_c.term;
} {30}

if {![detail_is_none]} {
  do_execsql_test 7.3.2 {
    SELECT count(*) FROM txc, txc_c
      WHERE txc.term = txc_c.term AND txc.col=txc_c.col;
  } {57}
}

}

finish_test