A free, self-hostable news aggregator…
PostgreSQL: make commitNewEntries resilient to duplicate keys (#9231)
Ali Gündoğara9a5856d0d59
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.phpindex 323500656..177d3c732 100644--- a/app/Models/EntryDAOPGSQL.php+++ b/app/Models/EntryDAOPGSQL.php@@ -84,7 +84,6 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {#[\Override]public function commitNewEntries(): bool {- //TODO: Update to PostgreSQL 9.5+ syntax with ON CONFLICT DO NOTHING$sql = <<<'SQL'DO $$DECLARE@@ -96,10 +95,8 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite {(SELECT rank + row_number() OVER(ORDER BY etmp.date, etmp.id) AS id, guid, title, author, content,link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags, attributesFROM `_entrytmp` AS etmp- WHERE NOT EXISTS (- SELECT 1 FROM `_entry` AS ereal- WHERE (etmp.id = ereal.id) OR (etmp.id_feed = ereal.id_feed AND etmp.guid = ereal.guid))- ORDER BY etmp.date, etmp.id);+ ORDER BY etmp.date, etmp.id)+ ON CONFLICT DO NOTHING;DELETE FROM `_entrytmp` WHERE id <= maxrank;END $$;SQL;