From cd9da663630b6e12a1f4b0c82646e989410aed51 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 21 Aug 2011 16:36:08 +0400 Subject: [PATCH] ccache_cleanup: fix sql syntax for mysql --- functions.php | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/functions.php b/functions.php index 0c5819656..f17fe4484 100644 --- a/functions.php +++ b/functions.php @@ -6125,15 +6125,34 @@ function ccache_cleanup($link, $owner_uid) { - db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE - (SELECT count(*) FROM ttrss_counters_cache AS c2 - WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1 - AND owner_uid = '$owner_uid'"); - - db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE - (SELECT count(*) FROM ttrss_cat_counters_cache AS c2 - WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1 + if (DB_TYPE == "pgsql") { + db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE + (SELECT count(*) FROM ttrss_counters_cache AS c2 + WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1 AND owner_uid = '$owner_uid'"); + + db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE + (SELECT count(*) FROM ttrss_cat_counters_cache AS c2 + WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1 + AND owner_uid = '$owner_uid'"); + } else { + db_query($link, "DELETE c1 FROM + ttrss_counters_cache AS c1, + ttrss_counters_cache AS c2 + WHERE + c1.owner_uid = '$owner_uid' AND + c1.owner_uid = c2.owner_uid AND + c1.feed_id = c2.feed_id"); + + db_query($link, "DELETE c1 FROM + ttrss_cat_counters_cache AS c1, + ttrss_cat_counters_cache AS c2 + WHERE + c1.owner_uid = '$owner_uid' AND + c1.owner_uid = c2.owner_uid AND + c1.feed_id = c2.feed_id"); + + } } function label_find_id($link, $label, $owner_uid) {