Re: Query on postgres_fdw extension - Mailing list pgsql-general

From Tom Lane
Subject Re: Query on postgres_fdw extension
Date
Msg-id 1885558.1621006361@sss.pgh.pa.us
Whole thread Raw
In response to Re: Query on postgres_fdw extension  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
List pgsql-general
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> writes:
> On Fri, May 14, 2021 at 8:23 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> One conceivable workaround is to do your insertions through a
>> foreign table that doesn't even have the serial column, so that
>> the INSERT command received by the remote server lacks that
>> column and the default gets applied.  Probably too messy though.

> Then the serial column cannot be selected via the foreign table.

Yeah, you'd probably need to use different tables for inserting
and reading, which is why I called it messy.

The idea you pointed to in Michael's blog might work though,
ie make a local function that reaches over to the remote server
to get a globally-valid next sequence value, and use that as
the default expression of the foreign table.

            regards, tom lane



pgsql-general by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Query on postgres_fdw extension
Next
From: Pól Ua Laoínecháin
Date:
Subject: RETURNING, CTEs and TRANSACTION ISOLATION levels...