Re: Query on postgres_fdw extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Swathi P <swathi(dot)bluepearl(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Query on postgres_fdw extension
Date: 2021-05-14 15:32:41
Message-ID: 1885558.1621006361@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> writes:
> On Fri, May 14, 2021 at 8:23 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2021-05-14 15:47:49 Re: BUG #16833: postgresql 13.1 process crash every hour
Previous Message Tom Lane 2021-05-14 15:20:35 Re: Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3)

Browse pgsql-general by date

  From Date Subject
Next Message Pól Ua Laoínecháin 2021-05-14 15:33:04 RETURNING, CTEs and TRANSACTION ISOLATION levels...
Previous Message Bharath Rupireddy 2021-05-14 15:10:52 Re: Query on postgres_fdw extension