From d7376209ee6eea14fd54db0f1d15b24714fb018d Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Sat, 21 Sep 2024 00:51:03 +0100 Subject: [PATCH] Fix. --- ext/bloom/bloom.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/bloom/bloom.go b/ext/bloom/bloom.go index 46190a9..1df49d9 100644 --- a/ext/bloom/bloom.go +++ b/ext/bloom/bloom.go @@ -79,6 +79,12 @@ func create(db *sqlite3.Conn, _, schema, table string, arg ...string) (_ *bloom, t.bytes = numBytes(nelem, t.prob) + err = db.DeclareVTab( + `CREATE TABLE x(present, word HIDDEN NOT NULL PRIMARY KEY) WITHOUT ROWID`) + if err != nil { + return nil, err + } + err = db.Exec(fmt.Sprintf( `CREATE TABLE %s.%s (data BLOB, p REAL, n INTEGER, m INTEGER, k INTEGER)`, sqlite3.QuoteIdentifier(t.schema), sqlite3.QuoteIdentifier(t.storage))) @@ -94,12 +100,6 @@ func create(db *sqlite3.Conn, _, schema, table string, arg ...string) (_ *bloom, VALUES (1, zeroblob(%d), %f, %d, %d, %d)`, sqlite3.QuoteIdentifier(t.schema), sqlite3.QuoteIdentifier(t.storage), t.bytes, t.prob, nelem, 8*t.bytes, t.hashes)) - if err != nil { - return nil, err - } - - err = db.DeclareVTab( - `CREATE TABLE x(present, word HIDDEN NOT NULL PRIMARY KEY) WITHOUT ROWID`) if err != nil { t.Destroy() return nil, err @@ -198,10 +198,10 @@ func (t *bloom) Integrity(schema, table string, flags int) error { } func (b *bloom) BestIndex(idx *sqlite3.IndexInfo) error { - for n, cst := range idx.Constraint { + for i, cst := range idx.Constraint { if cst.Usable && cst.Column == 1 && cst.Op == sqlite3.INDEX_CONSTRAINT_EQ { - idx.ConstraintUsage[n].ArgvIndex = 1 + idx.ConstraintUsage[i].ArgvIndex = 1 idx.OrderByConsumed = true idx.EstimatedRows = 1 idx.EstimatedCost = float64(b.hashes)