Re: Keeping state in a foreign data wrapper

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Stelios Sfakianakis <sgsfak(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Keeping state in a foreign data wrapper
Date: 2020-08-11 09:05:54
Message-ID: e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2020-08-03 at 19:23 +0300, Stelios Sfakianakis wrote:
> I am trying to implement a FDW in Postgres for accessing a web api and I would
> like to keep information like for example the total number of requests submiited.
> Ideally these data should be kept “per-user” and of course with the proper locking
> to eliminate race conditions. So the question I have is how to design such a global
> (but per user and database) state, using the C FDW API of Postgres. I have gone
> through the API and for example I see various fdw_private fields in the query
> planning structures and callbacks but these do not seem to be relevant to my requirements.
> Another possiblity seems to be to use shared memory
> (https://www.postgresql.org/docs/12/xfunc-c.html#id-1.8.3.13.14) but it is even
> less clear how to do it.
>
> So is there any simple way to do implement such shared thread/process safe state?

I would create a table as part of the extension and use SPI to store
the data there.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mohand oubelkacem makhoukhene 2020-08-11 11:31:03 Implement a new data type
Previous Message Flaris Roland Feller 2020-08-11 02:30:18 Re: ERROR: invalid memory alloc request size 18446744073709551613