Craig Ringer wrote:
> See the attached demo (pop all files in the same directory then run "make").
>
>
> > I would have
> > imagined that ultimately, the call to the Pg C function must return,
> > and therefore cannot affect stack unwinding within the C++ part of the
> > program.
>
> That's the whole point; a longjmp breaks the call chain, and the
> guarantee that eventually the stack will unwind as functions return.
>
> It's OK if you setjmp(a), do some work, setjmp(b), longjmp(a), do some
> work, longjmp(b), return.
>
> My understanding, which is likely imperfect, is that Pg's error handling
> does NOT guarantee that, ie it's quite possible that a function may call
> longjmp() without preparing any jmp_env to "jump back to" and therefore
> will never return.
You are correct that a longjump() jumps back to the query entry loop,
hopping over any user-defined C or C++ functions in the call stack, and
you are right that if we were just using longjump() without unwinding
C++ calls, we would be OK using non-POD structures.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ None of us is going to be here forever. +