diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-17 10:22:44 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-06-17 10:22:44 +0200 |
commit | 448ee4e7a92e96a6a57e52384193342c7987de9f (patch) | |
tree | 57edef84b0f6201d6aaf492b5c7ae59f1eb07e1e | |
parent | 99d03daf655cc1476cea9aee6254e5f0ad9c39a7 (diff) | |
parent | 07ef143fdeba3fe40ed61659dd32662e040b6766 (diff) | |
download | nextcloud-server-448ee4e7a92e96a6a57e52384193342c7987de9f.tar.gz nextcloud-server-448ee4e7a92e96a6a57e52384193342c7987de9f.zip |
Merge pull request #16969 from owncloud/stable7-backport-15549
[Stable7] don't update identical values
-rw-r--r-- | lib/private/files/cache/cache.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index 7ea00325a10..a41ff12ba0e 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -266,10 +266,17 @@ class Cache { } list($queryParts, $params) = $this->buildParts($data); + // duplicate $params because we need the parts twice in the SQL statement + // once for the SET part, once in the WHERE clause + $params = array_merge($params, $params); $params[] = $id; - $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? WHERE `fileid` = ?'; + // don't update if the data we try to set is the same as the one in the record + // some databases (Postgres) don't like superfluous updates + $sql = 'UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? ' . + 'WHERE (' . implode(' <> ? OR ', $queryParts) . ' <> ? ) AND `fileid` = ? '; \OC_DB::executeAudited($sql, $params); + } /** |