[GENERAL] Is is safe to use SPI in multiple threads? - Mailing list pgsql-general

From Qiu Xiafei
Subject [GENERAL] Is is safe to use SPI in multiple threads?
Date
Msg-id CA+ag+4PGWbnHQx35Hswmd0aeMg8LkH5HTwApPtEwuGv=EJKUXA@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] Is is safe to use SPI in multiple threads?
Re: [GENERAL] Is is safe to use SPI in multiple threads?
List pgsql-general
Hi, buddies!

I'm new to PG and want to implement my domain-specific system based on PG. I wish to arrange my data as several tables in database and translate my DSL into SQL statements for query. Since one DSL statement may be mapped to several SQL statements, it's better to push the DSL server as close to the PG server as possible. I found PG's backgroud worker meet my needs. I can setup a background worker bounded to PG server and listen to a port for network requests. 

But I encounter a problem that the Server Programing Interfaces are not THREAD SAFE. There are some global variables defined like: SPI_processed, SPI_tuptable, etc. This limit to my DSL server to work in single thread mode which is quite inefficient. So my questions are:

1. Is there a way to use SPI in multi-thread style?
2. Another option is to use libpq, like normal clients do. Is libpq as efficient as SPI?


Thanks in advance!

Xiafei Qiu

pgsql-general by date:

Previous
From: Thomas.Deboben.ext@rohde-schwarz.com
Date:
Subject: [GENERAL] Windows installation - could not connect to server: Connectionrefused (0x0000274D/10061)
Next
From: Johann Spies
Date:
Subject: Re: [GENERAL] After upgrade to 9.6: waiting column does not exist