Regarding ext::auth - I was trying to make a point that we couldn't properly track down the root cause of the problem and if you are trying to find a performance problem (or bug) you shouldn't jump at a conclusion all too quickly.
I played a bit with psql trying to find a way to hardwire values into views and PL/PGSQL functions who have been looked up dynamically. Here is what I found to work:
create function inline_0 ()
returns integer as '
declare
v_magic_object_id acs_magic_objects.object_id%TYPE;
begin
select object_id
into v_magic_object_id
from acs_magic_objects
where name = ''registered_users'';
EXECUTE ''create or replace view cc_users '' ||
'' as '' ||
'' select o.*, pa.*, pe.*, u.*, mr.member_state, mr.rel_id '' ||
'' from acs_objects o, parties pa, persons pe, users u, group_member_map m, membership_rels mr '' ||
'' where o.object_id = pa.party_id '' ||
'' and pa.party_id = pe.person_id '' ||
'' and pe.person_id = u.user_id '' ||
'' and u.user_id = m.member_id '' ||
'' and m.group_id = '' || v_magic_object_id ||
'' and m.rel_id = mr.rel_id '' ||
'' and m.container_id = m.group_id '' ||
'' and m.rel_type = ''''membership_rel'''' '';
return 0;
end;' language 'plpgsql';
select inline_0 ();
drop function inline_0 ();
There is no equivalent to sql*plus variables yet, so this is a bit klunky. (psql variables don't work here)
Should the most obvious invocations of acs_magic_objects be replaced?
(cc_users doesn't have pl/pgsql anymore anyway, I just meant to find a development query)