From: | James Harper <james(dot)harper(at)bendigoit(dot)com(dot)au> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | spi in bgworker |
Date: | 2014-03-22 23:17:47 |
Message-ID: | F214C06498BC244DB3F9472E1C5368180F41E411@BITCOM1.int.sbss.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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.
I'm initialising my worker as:
strncpy(worker.bgw_name, "tds handler", sizeof(worker.bgw_name));
worker.bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION;
worker.bgw_start_time = BgWorkerStart_RecoveryFinished;
worker.bgw_restart_time = BGW_NEVER_RESTART;
//worker.bgw_main_arg = 1433;
worker.bgw_main = tdsworker;
RegisterDynamicBackgroundWorker(&worker, &handle);
What am I missing? (this is 9.4 obviously, as I'm using a dynamic bgworker)
Thanks
James
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2014-03-22 23:49:28 | Re: spi in bgworker |
Previous Message | Ilya Ivanov | 2014-03-22 16:37:47 | Regexp matching + typecasts |