Re: BUG #16631: postgres_fdw tries to insert into generated columns

From: Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com>
To: dacherny(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: peter(dot)eisentraut(at)enterprisedb(dot)com
Subject: Re: BUG #16631: postgres_fdw tries to insert into generated columns
Date: 2021-07-07 07:20:45
Message-ID: CAPmGK173z88dS-us68jm-3ynscYdSK=mnUpiO3pOTBP_5S=AFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sat, Jul 3, 2021 at 7:44 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> But rather
> than computing the generated columns locally, I’m wondering that we
> should compute them remotely, assuming that the corresponding
> generated columns are defined on the remote sides. (It would be the
> user’s responsibility to ensure that.) This seems to me similar to
> the constraint case, and if we did so, I think we could fix the
> reported issue by extending postgresImportForeignSchema to support
> generated columns.

I updated the patch as such:

* Modified nodeModifyTable.c and copyfrom.c so that they don't compute
generated columns for FDWs anymore.
* Modified deparse functions such as deparseInsertSql() so that the
query is deparsed to set target generated columns (if any) to DEFAULT.
* Added an option import_generated to postgres_fdw to support
importing generated columns.
* Added a bit more test cases to postgres_fdw.sql.
* Updated docs.

Currently, foreign tables are not allowed to be updated directly when
they have stored generated columns, but I think they could be. But I
left that as future work as that would be an improvement rather than a
fix.

Attached is an updated version of the patch.

Best regards,
Etsuro Fujita

Attachment Content-Type Size
reconsider-handling-generated-columns-in-foreign-tables.patch application/octet-stream 25.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Adrian Ho 2021-07-07 07:54:59 Re: BUG #17083: [PATCH] PostgreSQL fails to build with OpenLDAP 2.5.x
Previous Message PG Bug reporting form 2021-07-07 07:11:45 BUG #17089: "ERROR: invalid memory alloc request size ..." occurs when updating a fixed number of records