Frank van Vugt <ftm.van.vugt@foxi.nl> writes:
> CREATE FUNCTION get_level(varchar) RETURNS int LANGUAGE 'sql' IMMUTABLE STRICT
> SECURITY INVOKER AS 'SELECT id FROM level WHERE abbreviation = $1';
The bug is in this function: it's assuming that "level" will always be
in the current search path. Perhaps you want "FROM public.level".
Frankly, since this function is clearly *not* immutable, almost any
misbehavior of an index depending on it is going to be considered
not-a-bug...
regards, tom lane