From a10272d1d236e30142f042f9382b861e5c0638cd Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 10 Apr 2011 14:42:08 +0000 Subject: [PATCH] list-domain.php: - add explicit field list in SELECT to avoid PgSQL problems with custom columns Reported by ksb (ksb4ever@SF), https://sourceforge.net/tracker/?func=detail&aid=2859165&group_id=191583&atid=937964 git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1028 a1433add-5e2c-0410-b055-b7f2511e0802 --- list-domain.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/list-domain.php b/list-domain.php index e93c3ff1..1c9cac31 100644 --- a/list-domain.php +++ b/list-domain.php @@ -63,16 +63,21 @@ if ($list_all_domains == 1) { } # fetch domain data and number of mailboxes -# (PgSQL requires the extensive GROUP BY statement, https://sourceforge.net/forum/message.php?msg_id=7386240) -# TODO: SELECT domain.* -> domain.field1, domain.field2 -> see bugreport +# PgSQL requires the extensive GROUP BY statement (https://sourceforge.net/forum/message.php?msg_id=7386240) +# and also in the field list (https://sourceforge.net/tracker/?func=detail&aid=2859165&group_id=191583&atid=937964) +# Note: future versions should auto-generate the field list based on $struct in DomainHandler (use all fields from the domain table) +$table_domain_fieldlist = " + $table_domain.domain, $table_domain.description, $table_domain.aliases, $table_domain.mailboxes, + $table_domain.maxquota, $table_domain.quota, $table_domain.transport, $table_domain.backupmx, $table_domain.created, + $table_domain.modified, $table_domain.active +"; + $query = " - SELECT $table_domain.* , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count + SELECT $table_domain_fieldlist , COUNT( DISTINCT $table_mailbox.username ) AS mailbox_count FROM $table_domain LEFT JOIN $table_mailbox ON $table_domain.domain = $table_mailbox.domain $where - GROUP BY $table_domain.domain, $table_domain.description, $table_domain.aliases, $table_domain.mailboxes, - $table_domain.maxquota, $table_domain.quota, $table_domain.transport, $table_domain.backupmx, $table_domain.created, - $table_domain.modified, $table_domain.active + GROUP BY $table_domain_fieldlist ORDER BY $table_domain.domain "; $result = db_query($query);