From 345d4ad286be4cc95ffdf56991d5fbacb0cc040f Mon Sep 17 00:00:00 2001 From: cuihaikuo Date: Fri, 17 Feb 2017 10:39:51 +0800 Subject: [PATCH] Modify sql syntax for pgsql --- server/repo-mgr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/server/repo-mgr.c b/server/repo-mgr.c index 779f9818..62383947 100644 --- a/server/repo-mgr.c +++ b/server/repo-mgr.c @@ -3583,13 +3583,24 @@ gint64 seaf_get_total_storage (GError **error) { gint64 size = 0; - int ret = seaf_db_statement_foreach_row (seaf->db, + int ret; + if (seaf_db_type(seaf->db) == SEAF_DB_TYPE_PGSQL) { + ret = seaf_db_statement_foreach_row (seaf->db, + "SELECT \"size\" FROM RepoSize s " + "LEFT JOIN VirtualRepo v " + "ON s.repo_id=v.repo_id " + "WHERE v.repo_id IS NULL", + get_total_storage_cb, + &size, 0); + } else { + ret = seaf_db_statement_foreach_row (seaf->db, "SELECT size FROM RepoSize s " "LEFT JOIN VirtualRepo v " "ON s.repo_id=v.repo_id " "WHERE v.repo_id IS NULL", get_total_storage_cb, &size, 0); + } if (ret < 0) { seaf_warning ("Failed to get total storage occupation.\n"); g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,