Index: openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql,v
diff -u -r1.36.2.2 -r1.36.2.3
--- openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql	4 Sep 2019 16:44:22 -0000	1.36.2.2
+++ openacs-4/packages/acs-kernel/sql/postgresql/groups-body-create.sql	14 Mar 2020 19:01:42 -0000	1.36.2.3
@@ -1199,37 +1199,40 @@
 select define_function_args('acs_group__member_p','party_id,group_id,cascade_membership');
 
 --
--- procedure acs_group__member_p/3
+-- function acs_group__member_p/3
 --
 CREATE OR REPLACE FUNCTION acs_group__member_p(
    p_party_id integer,
    p_group_id integer,
    p_cascade_membership boolean
 ) RETURNS boolean AS $$
-DECLARE
-BEGIN
-  if p_cascade_membership then
+
+  SELECT CASE
+  WHEN p_cascade_membership = true then
     --
     -- Direct and indirect memberships
     --
-    return count(*) > 0
-      from group_member_map
+    EXISTS (
+      select 1 from group_member_map
       where group_id = p_group_id
-        and member_id = p_party_id;
-  else
+        and member_id = p_party_id
+    )
+  ELSE 
     --
     -- Only direct memberships
     --
-    return count(*) > 0
-      from acs_rels rels
-    where rels.rel_type = 'membership_rel'
-      and rels.object_id_one = p_group_id
-      and rels.object_id_two = p_party_id;
-  end if;
-END;
-$$ LANGUAGE plpgsql stable;
+    EXISTS (
+      select 1 from acs_rels rels
+      where rels.rel_type = 'membership_rel'
+        and rels.object_id_one = p_group_id
+        and rels.object_id_two = p_party_id
+    )
+  END;
 
+$$ LANGUAGE sql strict stable;
 
+
+
 -- function check_representation
 
 
