From b19b03fa6d3d4c17828d0f363a876e1fd5781e15 Mon Sep 17 00:00:00 2001 From: hubert Date: Tue, 14 Sep 2021 16:38:58 +0000 Subject: [PATCH] Use NULL-tolerant comparison for DeliveryReceipts Since NULL = NULL is always FALSE, this query needs to use IS instead. This should fix the flood of DeliveryReceipts in the DB. See https://www.sqlite.org/lang_expr.html > The IS and IS NOT operators work like = and != except when one or both > of the operands are NULL. In this case, if both operands are NULL, > then the IS operator evaluates to 1 (true) and the IS NOT operator > evaluates to 0 (false). If one operand is NULL and the other is not, > then the IS operator evaluates to 0 (false) and the IS NOT operator is > 1 (true). It is not possible for an IS or IS NOT expression to > evaluate to NULL. git-svn-id: file:///srv/svn/repo/suika/trunk@589 f0ae65fe-ee39-954e-97ec-027ff2717ef4 --- db_sqlite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db_sqlite.go b/db_sqlite.go index 6413acc..393f9d6 100644 --- a/db_sqlite.go +++ b/db_sqlite.go @@ -542,7 +542,7 @@ func (db *SqliteDB) StoreClientDeliveryReceipts(networkID int64, client string, } defer tx.Rollback() - _, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ? AND client = ?", + _, err = tx.Exec("DELETE FROM DeliveryReceipt WHERE network = ? AND client IS ?", networkID, toNullString(client)) if err != nil { return err