pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Stelios Sfakianakis <sgsfak@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Keeping state in a foreign data wrapper
Date: Tue, 11 Aug 2020 11:05:54 +0200
Message-ID: <e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at> (raw)
In-Reply-To: <C6E9F37F-0D02-4BA4-8BB8-C808A31508A1@gmail.com>
References: <C6E9F37F-0D02-4BA4-8BB8-C808A31508A1@gmail.com>

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






view thread (8+ messages)

Message-ID: <e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at>
Permalink:  ../e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at/
Also on:    postgresql.org/message-id/e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, sgsfak@gmail.com
  Subject: Re: Keeping state in a foreign data wrapper
  In-Reply-To: <e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at>
  References: <C6E9F37F-0D02-4BA4-8BB8-C808A31508A1@gmail.com> <e3513e40f3ffb064d14e45289806786ebf13b68d.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox