~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Use NULL-tolerant comparison for DeliveryReceipts

Details
Message ID
<20210914074144.4536-1-hubert@hirtz.pm>
DKIM signature
pass
Download raw message
Patch: +1 -1
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.
---

The PostgreSQL patch also has this issue and will need a v2.

This *might* be a related to #115 since delivery receipts are loaded in
user.run(), though this was not really noticeable on my end.

https://todo.sr.ht/~emersion/soju/115

 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
-- 
2.33.0
Details
Message ID
<eX8GYywbO97U2L7MqBzS0viqHHhaAuvhQx2JSTebj6HQtORjurQ3dTdc2UjKYxkN-V1dQwgvUv6a5G57JXiJ3Vg3dgltSmHggoaudSaskIc=@emersion.fr>
In-Reply-To
<20210914074144.4536-1-hubert@hirtz.pm> (view parent)
DKIM signature
pass
Download raw message
Good catch, thanks! Pushed.

> This *might* be a related to #115

Unlikely, I think #115 was already happening on 0.1.0.
Reply to thread Export thread (mbox)