postgresql/contrib/postgres_fdw
Etsuro Fujita aa769f80ed postgres_fdw: Fix issues with generated columns in foreign tables.
postgres_fdw imported generated columns from the remote tables as plain
columns, and caused failures like "ERROR: cannot insert a non-DEFAULT
value into column "foo"" when inserting into the foreign tables, as it
tried to insert values into the generated columns.  To fix, we do the
following under the assumption that generated columns in a postgres_fdw
foreign table are defined so that they represent generated columns in
the underlying remote table:

* Send DEFAULT for the generated columns to the foreign server on insert
  or update, not generated column values computed on the local server.
* Add to postgresImportForeignSchema() an option "import_generated" to
  include column generated expressions in the definitions of foreign
  tables imported from a foreign server.  The option is true by default.

The assumption seems reasonable, because that would make a query of the
postgres_fdw foreign table return values for the generated columns that
are consistent with the generated expression.

While here, fix another issue in postgresImportForeignSchema(): it tried
to include column generated expressions as column default expressions in
the foreign table definitions when the import_default option was enabled.

Per bug #16631 from Daniel Cherniy.  Back-patch to v12 where generated
columns were added.

Discussion: https://postgr.es/m/16631-e929fe9db0ffc7cf%40postgresql.org
2021-08-05 20:00:00 +09:00
..
expected postgres_fdw: Fix issues with generated columns in foreign tables. 2021-08-05 20:00:00 +09:00
sql postgres_fdw: Fix issues with generated columns in foreign tables. 2021-08-05 20:00:00 +09:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
Makefile postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
connection.c Allow TRUNCATE command to truncate foreign tables. 2021-04-08 20:56:08 +09:00
deparse.c postgres_fdw: Fix issues with generated columns in foreign tables. 2021-08-05 20:00:00 +09:00
option.c Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:20:16 +09:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c postgres_fdw: Fix issues with generated columns in foreign tables. 2021-08-05 20:00:00 +09:00
postgres_fdw.control postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
postgres_fdw.h postgres_fdw: Fix issues with generated columns in foreign tables. 2021-08-05 20:00:00 +09:00
shippable.c Replace remaining uses of "whitelist". 2021-01-05 14:00:16 +13:00