On Wed, 11 Dec 2019 at 14:38, Koichi Suzuki <koi...@2ndquadrant.com> wrote:

> Hello PG hackers;
>
> I'm writing an extension running on background workers and found
> get_database_name() causes SEGV and found internally resource owner was wet
> to NULL.   Could anybody let me know how it happens and how I can use this
> function.   Argument to get_database_name() looks correct.
>
>
I think the main question is answered; if the advice given does not help
please supply your code and a backtrace from the crash obtained from a core
file.

However, this reminds me of something. I'd like to make our
syscache/relcache/catcache and all snapshot access functions
Assert(IsTransactionState()); directly or at key locations. That'd make
these mistakes much more obvious - and as bgworkers become a more popular
way to write code for PostgreSQL that's going to be important.

Similarly, it might make sense to assert that we have a valid snapshot in
the SPI, which we don't presently do for read-only SPI calls. I recall that
one biting me repeatedly when I was learning this stuff.

-- 
 Craig Ringer                   http://www.2ndQuadrant.com/
 2ndQuadrant - PostgreSQL Solutions for the Enterprise

Reply via email to