3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # Tests focusing on the fts5 xSetAuxdata() and xGetAuxdata() APIs.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5auxdata
18 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
25 CREATE VIRTUAL TABLE f1 USING fts5(a, b);
26 INSERT INTO f1(rowid, a, b) VALUES(1, 'a', 'b1');
27 INSERT INTO f1(rowid, a, b) VALUES(2, 'a', 'b2');
28 INSERT INTO f1(rowid, a, b) VALUES(3, 'a', 'b3');
29 INSERT INTO f1(rowid, a, b) VALUES(4, 'a', 'b4');
30 INSERT INTO f1(rowid, a, b) VALUES(5, 'a', 'b5');
33 proc aux_function_1 {cmd tn} {
34 switch [$cmd xRowid] {
36 do_test $tn.1 [list $cmd xGetAuxdata 0 ] {}
37 $cmd xSetAuxdata "one"
41 do_test $tn.2 [list $cmd xGetAuxdata 0 ] {one}
42 $cmd xSetAuxdata "two"
46 do_test $tn.3 [list $cmd xGetAuxdata 0 ] {two}
50 do_test $tn.4 [list $cmd xGetAuxdata 1 ] {two}
54 do_test $tn.5 [list $cmd xGetAuxdata 0 ] {}
59 sqlite3_fts5_create_function db aux_function_1 aux_function_1
61 SELECT aux_function_1(f1, 1) FROM f1 WHERE f1 MATCH 'a'
65 proc aux_function_2 {cmd tn inst} {
67 switch [$cmd xRowid] {
69 do_test $tn.1.$inst [list $cmd xGetAuxdata 0 ] {}
70 $cmd xSetAuxdata "one $inst"
73 do_test $tn.2.$inst [list $cmd xGetAuxdata 0 ] "one $inst"
74 $cmd xSetAuxdata "two $inst"
77 do_test $tn.3.$inst [list $cmd xGetAuxdata 0 ] "two $inst"
80 do_test $tn.4.$inst [list $cmd xGetAuxdata 1 ] "two $inst"
83 do_test $tn.5.$inst [list $cmd xGetAuxdata 0 ] {}
87 switch [$cmd xRowid] {
89 do_test $tn.1.$inst [list $cmd xGetAuxdata 0 ] "one A"
92 do_test $tn.2.$inst [list $cmd xGetAuxdata 0 ] "two A"
95 do_test $tn.3.$inst [list $cmd xGetAuxdata 0 ] "two A"
98 do_test $tn.4.$inst [list $cmd xGetAuxdata 0 ] {}
101 do_test $tn.5.$inst [list $cmd xGetAuxdata 0 ] {}
107 sqlite3_fts5_create_function db aux_function_2 aux_function_2
109 SELECT aux_function_2(f1, 2, 'A'), aux_function_2(f1, 2, 'B')
110 FROM f1 WHERE f1 MATCH 'a'