As to your very last point (suggestions about other approaches), is it impossible or impractical to migrate to a scheme in which each user actually has a data base role and their own password? Postgresql has really great facility for managing database authorization and access by means of login roles assignable membership in group roles. Why not let the tool do what it can already do very effectively?
-- B
Ken
AGENCY Software
A Free Software data system
By and for non-profits
learn more about AGENCY or
follow the discussion.