Re: get_database_name() from background worker
От | Craig Ringer |
---|---|
Тема | Re: get_database_name() from background worker |
Дата | |
Msg-id | CAMsr+YHuDcV1VvGGSudDwQqs6KRyXWuhLrm04=0a3a6WLh84Xw@mail.gmail.com обсуждение исходный текст |
Ответ на | get_database_name() from background worker (Koichi Suzuki <koichi@2ndquadrant.com>) |
Список | pgsql-hackers |
On Wed, 11 Dec 2019 at 14:38, Koichi Suzuki <koichi@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.
В списке pgsql-hackers по дате отправления: