
diff -r e4e0975dbe85 -r 2cd2860c8fb3 prototyp/prototyp.sql
--- a/prototyp/prototyp.sql	Mon Sep 01 15:36:16 2014 +0200
+++ b/prototyp/prototyp.sql	Mon Sep 01 15:56:05 2014 +0200
@@ -2,6 +2,9 @@
 
 SET search_path TO unix_sql_api;
 
+
+-- fstab: --------------------------------------------------------------------
+
 DROP VIEW IF EXISTS fstab;
 DROP FUNCTION IF EXISTS fstab();
 DROP TYPE IF EXISTS unix_sql_api_fstab;
@@ -55,4 +58,40 @@
 
 CREATE OR REPLACE VIEW fstab AS
 	SELECT * FROM fstab()
-; 
+;
+
+
+-- user groups: --------------------------------------------------------------
+
+DROP VIEW IF EXISTS user_group;
+DROP FUNCTION IF EXISTS user_group();
+DROP TYPE IF EXISTS unix_sql_api_user_group;
+
+CREATE TYPE unix_sql_api_user_group AS (
+	id INTEGER,
+	name VARCHAR,
+	members VARCHAR[]
+);
+
+CREATE OR REPLACE FUNCTION user_group()
+RETURNS SETOF unix_sql_api_user_group AS $$
+	use strict;
+	use warnings;
+	
+	use User::grent;
+
+	while (my $group = getgrent) {
+		return_next({
+			id => $group->gid,
+			name => $group->name,
+			members => [@{$group->members}]
+		});
+	}
+	
+	return undef;
+$$ LANGUAGE plperlu;
+
+CREATE OR REPLACE VIEW user_group AS
+	SELECT * FROM user_group()
+;
+




