Fossil Forum
Post: `fossil sql -R` lost the search functions (search_init, title, body…) since SQLite 3.51 was brought in
In 2.28 and current trunk (2d6bfabc9e), fossil sql -R REPO no longer has
search_init, search_match, search_score, search_snippet, stext,
title, body, urlencode or wiki_to_text. On a clone of the Tk
repository:
$ echo "SELECT search_init('x','','','',0);" | fossil sql -R tk.fossil --readonly
Parse error near line 1: no such function: search_init
With --no-repository they are there; 2.26 has them with -R too.
Bisected to 92871e0c79
("Update the built-in SQLite to the latest 3.51.0 code"). The new shell's
deduceDatabaseType() (now isDatabaseFile()) opens the database file once
with sqlite3_open_v2() to probe it. sqlcmd_autoinit runs on that probe
connection first, and search_sql_setup() (search.c) registers the functions
there behind static int once, so the real connection opened next never gets
them. The wiki_to_text registration in timeline.c has the same once-only
guard.
Dropping the once guard in search_sql_setup() fixes it. With that change,
2.28 gives the same answer as 2.26 to
SELECT search_init('menubutton','<','>',' .. ',0);
SELECT count(*) FROM ticket
WHERE search_match(title('t',tkt_id,NULL), body('t',tkt_id,NULL));
on tk.fossil (127). Registering a function again on the same connection is harmless, so the guard doesn't seem needed.