Re: Passing current_database to BackgroundWorkerInitializeConnection

From: Jeremy Finzel <finzelj(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Passing current_database to BackgroundWorkerInitializeConnection
Date: 2018-04-02 19:24:53
Message-ID: CAMa1XUiGpgGh0PD84X9y-FhYjufdyp=16g5czaB+uWwmjy53Sg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 30, 2018 at 5:37 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:

>
>
> On March 30, 2018 3:16:31 PM PDT, Jeremy Finzel <finzelj(at)gmail(dot)com> wrote:
> >> What do you mean with "current database"? Before you
> >> BackgroundWorkerInitializeConnection() there is no such thing?
> >
> >
> >My module is based directly off the worker_spi example. The worker is
> >dynamically launched via SQL command. But in the worker_spi example,
> >the
> >database postgres is just hardcoded as the database in which to start
> >the
> >background worker process. Instead, I want to start it in the database
> >in
> >which I run the SQL command.
>
> The started worker isn't associated with the original database. You can
> pass the database oid as an argument to the launched bgworker.
>
>
Thank you, this makes sense. However, how can this be done since I can
only pass one argument to bgw_main? Is there any way to do this without
having to store the value in shared memory? I was going to try passing an
array instead of an int, but I'm not liking that much. I am trying to pass
naptime and database_name (or oid).

Thanks,
Jeremy

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2018-04-02 19:27:30 Re: Passing current_database to BackgroundWorkerInitializeConnection
Previous Message Alvaro Herrera 2018-04-02 19:11:12 Re: Commit 4dba331cb3 broke ATTACH PARTITION behaviour.