Re: Inserting into foreign table with sequences and default values

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "peter(dot)borissow(at)kartographia(dot)com" <peter(dot)borissow(at)kartographia(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Inserting into foreign table with sequences and default values
Date: 2023-12-08 18:31:46
Message-ID: 1468017.1702060306@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"peter(dot)borissow(at)kartographia(dot)com" <peter(dot)borissow(at)kartographia(dot)com> writes:
> I guess the FDW is not "seeing" the default value for status and the bigserial sequence for the id column. Is there anyway around this?

The idea is that you should attach default clauses to the foreign
table definition. A remote serial column is a hard case for that,
though, since you don't have ready access to the remote sequence.
Because of that and some related examples, we don't currently
expect that IMPORT FOREIGN SCHEMA should import the defaults that
exist on the remote server.

Using a view or trigger on the remote side is currently the best
way around that for cases where you can't set up a suitable
default on the local table.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Verite 2023-12-08 19:45:23 Re: Emitting JSON to file using COPY TO
Previous Message Vincent Veyron 2023-12-08 18:12:59 Re: running \copy through perl dbi ?