Hello,
(Postgres 8.3) I'm misusing the current settings at some places to store session variables. The next function retrieve such a variable, or initialized it with a default value. It is working as expected but performances are slow due to the exception block. Is there a way to make the check more smoothly, i.e. without relying on the exception ? maybe some undocumented internal function ? many thanks, Marc Mamin CREATE OR REPLACE FUNCTION public.var_get_check(int,text) RETURNS text AS $BODY$ BEGIN return current_setting('public.' || $2 || pg_backend_pid()); EXCEPTION when undefined_object then perform set_config ('public.' || $2 || pg_backend_pid(), $1::text, false); return $1::text; END ; $BODY$ LANGUAGE plpgsql VOLATILE COST 100;