How to Brew Install SQLite3 FTS5 extension?

Viewed 379

Is there an easy way to enable the FTS5 extension for SQLite3 installed with Brew? Some older posts say there should be an install option --with-fts5, however:

$ brew reinstall sqlite3 --with-fts5
...
Error: invalid option: --with-fts5

The fts3_tokenizer is not enabled. I assume there must be an easy way to install/enabled the extension with Brew without compiling from source outside of Brew.

$ sqlite3
SQLite version 3.35.5 2021-04-19 18:32:05
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .dbconfig
          defensive off
            dqs_ddl on
            dqs_dml on
        enable_fkey off
        enable_qpsg off
     enable_trigger on
        enable_view on
     fts3_tokenizer off
 legacy_alter_table off
 legacy_file_format off
     load_extension on
   no_ckpt_on_close off
     reset_database off
        trigger_eqp off
     trusted_schema on
    writable_schema off

$ brew info sqlite3
sqlite: stable 3.35.5 (bottled) [keg-only]
Command-line interface for SQLite
https://sqlite.org/
/usr/local/Cellar/sqlite/3.35.5 (11 files, 4.2MB)
  Built from source on 2021-05-18 at 08:54:33
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/sqlite.rb
...
3 Answers

Try to use CFLAGS environment:

CFLAGS="-DSQLITE_ENABLE_FTS5" brew reinstall sqlite

Edited:

Rebuild to enable fts5 is unnecessary. The sqlite 3.35.5 package is already fts5 module enabled.

$ brew fetch sqlite
...
$ tar xzf ~/Library/Caches/Homebrew/downloads/61d40ad2021e894bcf4c7475eea2dbbfee14c4426b1bbb1816c4055ad1c70b50--sqlite--3.35.5.catalina.bottle.tar.gz -O sqlite/3.35.5/lib/libsqlite3.0.dylib \
  | strings - | grep '^fts5: 20\|trigram'
trigram
fts5: 2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886

I wrote you on the trac mailing list too but will post here too.

If you check https://sqlite.org/fts5.html there seems to be a option --enable-fts5 but it also seems disabled by the fault. That said they point to a " amalgamation" (there is a link to it in the page) where you can use this option if you compile the " amalgamation".

Markus

FTS5 is enabled. I was mistaken about the source of the problem I'm experiencing.

>>> import sqlite3
>>> import pprint
>>> db = sqlite3.connect(':memory:')
>>> cursor = db.execute('PRAGMA COMPILE_OPTIONS')
>>> pprint.pprint(cursor.fetchall())
[(u'BUG_COMPATIBLE_20160819',),
 (u'COMPILER=clang-12.0.5',),
 (u'DEFAULT_CACHE_SIZE=2000',),
 (u'DEFAULT_CKPTFULLFSYNC',),
 (u'DEFAULT_JOURNAL_SIZE_LIMIT=32768',),
 (u'DEFAULT_PAGE_SIZE=4096',),
 (u'DEFAULT_SYNCHRONOUS=2',),
 (u'DEFAULT_WAL_SYNCHRONOUS=1',),
 (u'ENABLE_API_ARMOR',),
 (u'ENABLE_COLUMN_METADATA',),
 (u'ENABLE_DBSTAT_VTAB',),
 (u'ENABLE_FTS3',),
 (u'ENABLE_FTS3_PARENTHESIS',),
 (u'ENABLE_FTS3_TOKENIZER',),
 (u'ENABLE_FTS4',),
 (u'ENABLE_FTS5',),
 (u'ENABLE_JSON1',),
 (u'ENABLE_LOCKING_STYLE=1',),
 (u'ENABLE_PREUPDATE_HOOK',),
 (u'ENABLE_RTREE',),
 (u'ENABLE_SESSION',),
 (u'ENABLE_SNAPSHOT',),
 (u'ENABLE_SQLLOG',),
 (u'ENABLE_STMT_SCANSTATUS',),
 (u'ENABLE_UNKNOWN_SQL_FUNCTION',),
 (u'ENABLE_UPDATE_DELETE_LIMIT',),
 (u'HAS_CODEC_RESTRICTED',),
 (u'HAVE_ISNAN',),
 (u'MAX_LENGTH=2147483645',),
 (u'MAX_MMAP_SIZE=1073741824',),
 (u'MAX_VARIABLE_NUMBER=500000',),
 (u'OMIT_AUTORESET',),
 (u'OMIT_LOAD_EXTENSION',),
 (u'STMTJRNL_SPILL=131072',),
 (u'THREADSAFE=2',),
 (u'USE_URI',)]
Related