Re: spi in bgworker

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: James Harper <james(dot)harper(at)bendigoit(dot)com(dot)au>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: spi in bgworker
Date: 2014-03-22 23:49:28
Message-ID: 20140322234927.GA12094@eldon.alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

James Harper wrote:
> The docs say I'm supposed to call BackgroundWorkerInitializeConnection in a bgworker and then I can start using spi functions, but they aren't clear on if I should call SPI_connect too.
>
> If I call BackgroundWorkerInitializeConnection and then SPI_execute I get a return code of SPI_ERROR_UNCONNECTED. If I call BackgroundWorkerInitializeConnection then SPI_connect I get a segfault.

You need to start a transaction after initializing the database
connection. Did you see the sample worker_spi code in contrib?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Harper 2014-03-22 23:54:45 Re: spi in bgworker
Previous Message James Harper 2014-03-22 23:17:47 spi in bgworker