thanks , this is a example of my application.
the ans is here, http://www.postgresql.org/docs/9.0/static/xaggr.html
sql command:
CREATE AGGREGATE array_accum (anyelement)
(
sfunc = array_append,
stype = anyarray,
initcond = '{}'
);
SELECT r.role_name, array_accum(permission) from roles r, roles_permissions rp group by r.role_name;
and the result:
role_name | array_accum
-----------+---------------------------------------
role2 | {permission1,permission2,permission1}
role1 | {permission1,permission2,permission1}