diff options
| author | 2021-02-02 00:03:59 +0100 | |
|---|---|---|
| committer | 2021-02-02 00:03:59 +0100 | |
| commit | 1ee1fcce91d64c8cee6b8621aaedbdeae0c9c330 (patch) | |
| tree | 2359a744b9711cd5bd51d168461333095d4a64c2 /app/Models/EntryDAOPGSQL.php | |
| parent | 8285f1df43ce19bbd533c70c3fd1487908883725 (diff) | |
INSERT ... ON CONFLIT DO NOTHING for addEntry (#3409)
#fix https://github.com/FreshRSS/FreshRSS/issues/3402
Explicit `INSERT OR IGNORE` / `ON CONFLICT DO NOTHING` for the
`addEntry()` method, which does expect some duplicates.
Diffstat (limited to 'app/Models/EntryDAOPGSQL.php')
| -rw-r--r-- | app/Models/EntryDAOPGSQL.php | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php index 9afea279f..a9304bbaa 100644 --- a/app/Models/EntryDAOPGSQL.php +++ b/app/Models/EntryDAOPGSQL.php @@ -14,6 +14,10 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { return 'encode(' . $x . ", 'hex')"; } + public function sqlIgnoreConflict($sql) { + return rtrim($sql, ' ;') . ' ON CONFLICT DO NOTHING'; + } + protected function autoUpdateDb($errorInfo) { if (isset($errorInfo[0])) { if ($errorInfo[0] === FreshRSS_DatabaseDAOPGSQL::UNDEFINED_TABLE) { @@ -33,6 +37,7 @@ class FreshRSS_EntryDAOPGSQL extends FreshRSS_EntryDAOSQLite { } public function commitNewEntries() { + //TODO: Update to PostgreSQL 9.5+ syntax with ON CONFLICT DO NOTHING $sql = 'DO $$ DECLARE maxrank bigint := (SELECT MAX(id) FROM `_entrytmp`); |
