Forum OpenACS Development: Re: improving permission queries

Collapse
Posted by Dave Bauer on
This seems to work on Postgresql reliably. I can run it multiple times without an error.

Tested on PG 8.0.7. I am not aware of any change in the system catalogs that would make this incompatible with PG 8.1 or 8.2.

create or replace function inline_0() returns integer as '
declare v_exists integer;
begin
select into v_exists count(*) from pg_class where relname = ''acs_permissions_object_id_idx'';
if v_exists = 0 then
create index acs_permissions_object_id_idx on acs_permissions(object_id);
end if;
return null;
end;' language 'plpgsql';
select inline_0();
drop function inline_0();