From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Swathi P <swathi.bluepearl@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Query on postgres_fdw extension
Date: Fri, 14 May 2021 18:04:59 +0200
Message-ID: <342e0b863a3b6fc4c31ab18c827cb9b165cdb365.camel@cybertec.at> (raw)
In-Reply-To: <1883853.1621003992@sss.pgh.pa.us>
References: <CAKtL=nkXe1zXK5SMcqnzDpCON+CUPHdnjJZfZonwYQa0BDkCGQ@mail.gmail.com>
<CALj2ACUejnxHERB4QNvKV3qVW4VQ=a8Y+kuuPTseuwq0prVe3Q@mail.gmail.com>
<CAKtL=n=OND+AYqztr57Njanj8M9iyy6uvfmp1yX2Zgk164Ejww@mail.gmail.com>
<1883853.1621003992@sss.pgh.pa.us>
On Fri, 2021-05-14 at 10:53 -0400, Tom Lane wrote:
> Swathi P <swathi.bluepearl@gmail.com> writes:
> > Hence we decided to have the coordinator nodes as stateless and hence
> > declared the column with no serial/sequence. Let me know if this makes
> > sense.
>
> Attaching serial-sequence defaults on both sides would certainly not
> work very well, because the sequences wouldn't stay in sync.
>
> Unfortunately, postgres_fdw just doesn't have a good way right now
> to make use of dynamically-generated defaults at the remote server.
> If you leave out a column in your INSERT, it's going to compute
> and send the locally-defined default (which is just null in this
> case), so the remote's default expression is never used.
>
> I remember that we spent a great deal of effort in postgres_fdw's
> early days, trying to find a way that we could use the remote's
> defaults in cases like this. But everything we tried ended up
> causing horrible semantic inconsistencies, so we ended up with
> the always-use-the-local-default approach. There was some feeling
> that maybe this could be revisited later, but no one's done so.
>
> 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.
One possibility might be to define a trigger on the remote table
that fetches the next sequence value if you try to insert NULL.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
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, tgl@sss.pgh.pa.us, swathi.bluepearl@gmail.com, bharath.rupireddyforpostgres@gmail.com
Subject: Re: Query on postgres_fdw extension
In-Reply-To: <342e0b863a3b6fc4c31ab18c827cb9b165cdb365.camel@cybertec.at>
References: <CAKtL=nkXe1zXK5SMcqnzDpCON+CUPHdnjJZfZonwYQa0BDkCGQ@mail.gmail.com> <CALj2ACUejnxHERB4QNvKV3qVW4VQ=a8Y+kuuPTseuwq0prVe3Q@mail.gmail.com> <CAKtL=n=OND+AYqztr57Njanj8M9iyy6uvfmp1yX2Zgk164Ejww@mail.gmail.com> <1883853.1621003992@sss.pgh.pa.us> <342e0b863a3b6fc4c31ab18c827cb9b165cdb365.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