"Dean" <ratq92nomr(at)hotmail(dot)com> writes:
> If I create a function which relies on the undefined_table exception to test
> if a table exists, it does not behave as expected.
Try issuing the DELETE via EXECUTE --- you're getting burnt by plan
caching.
But actually, do you really want something as destructive as DELETE
for an existence probe? I'd try
PERFORM 'bar'::text::regclass;
and see if that throws an error. (The double cast is important here,
so that you get a runtime lookup not a compile-time one.)
regards, tom lane