[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Regarding bug: menu_generate() too sensitive to non-existing roles
- Subject: Regarding bug: menu_generate() too sensitive to non-existing roles
- From: Erik Huelsmann <..hidden..>
- Date: Sat, 3 Dec 2011 22:58:13 +0100
As we were discussing on IRC, I was looking into the bug
"menu_generate() too sensitive to non-existing roles" (
So far, I see three solutions, some of which we already discussed on IRC:
1. Create a wrapper function around pg_has_role() which doesn't call
pg_has_role() when the role doesn't exist
2. Create a view which can be used in place of menu_acl -- filtered
for all roles which exist
3. Put the filter criteria straight into the menu_generate() and
4. Do nothing, but when we build functionality to load add-ons into
setup.pl, have that verify the validity of any adjustments to the menu
Since you seemed to prefer (2), I've been looking into that.
Unfortunately, the query optimizer seems to re-order things so that
the pg_has_role() function gets called on all records in menu_acl,
only to filter the resulting set against roles in pg_roles. By then,
the damage has been done. It seems this isn't an option after all.
Option (3) suffers from the same problem as option (2). So, that too
isn't an option.
Remain options (4) and (1) which I prefer in exactly that order. I
wouldn't expect a huge performance issue from the wrapper, since the
rolname column is indexed with a btree index. So, looking up will only
mean a few iterations through the index. However, verifying validity
of the menu only once seems a much better solution: why verify
something that's nearly always going to be exactly as expected?
So, that's why I prefer option (4). I think we should close the ticket
and add this to a feature request for setup.pl.
What do you say?