Bug69-50: FTS5 Content Table Creation Fails with Duplicate Column Name When locale=1 and nCol >= 115
(1) By ylwang (yuelinwang) on 2026-06-19 05:19:08 [source]
Summary
ext/fts5/fts5_storage.c:368-369 — snprintf budget uses multiplier 10, the matching alloc uses 20.
int nDefn = 32 + pConfig->nCol*10; /* 368 budget */
char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol*20); /* 369 alloc */
With locale=1 the function writes c0..cN then l0..lN into zDefn. At nCol=115 the budget runs dry at i=114: nDefn-iOff=6, but ", l114\0" needs 7, so sqlite3_snprintf truncates to ", l11". The DDL lists l11 twice and CREATE TABLE ..._content fails.
PoC
python3 -c "print('CREATE VIRTUAL TABLE t USING fts5('+','.join(f'c{i}' for i in range(115))+', locale=1);')" \
| /data/ylwang/LargeScan/targets/sqlite/install/bin/sqlite3
Error near line 1: fts5: error creating shadow table t_content: duplicate column name: l11
Fix
int nDefn = 32 + pConfig->nCol*20;