pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: postgres_fdw: Fix issues with generated columns in foreign table
4+ messages / 1 participants
[nested] [flat]

* pgsql: postgres_fdw: Fix issues with generated columns in foreign table
@ 2021-08-05 11:11  Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Etsuro Fujita @ 2021-08-05 11:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/aa769f80ed80b7adfbdea9a6bc267ba4aeb80fd7

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 |  50 ++++++++---
contrib/postgres_fdw/expected/postgres_fdw.out | 113 +++++++++++++++++++++++--
contrib/postgres_fdw/postgres_fdw.c            |  65 ++++++++++----
contrib/postgres_fdw/postgres_fdw.h            |   5 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      |  31 ++++++-
doc/src/sgml/postgres-fdw.sgml                 |  12 +++
6 files changed, 238 insertions(+), 38 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: postgres_fdw: Fix issues with generated columns in foreign table
@ 2021-08-05 11:11  Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Etsuro Fujita @ 2021-08-05 11:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/588d3f597c67fac6191658c3befc3b9120772905

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 |  50 ++++++++---
contrib/postgres_fdw/expected/postgres_fdw.out | 113 +++++++++++++++++++++++--
contrib/postgres_fdw/postgres_fdw.c            |  65 ++++++++++----
contrib/postgres_fdw/postgres_fdw.h            |   5 +-
contrib/postgres_fdw/sql/postgres_fdw.sql      |  31 ++++++-
doc/src/sgml/postgres-fdw.sgml                 |  12 +++
6 files changed, 238 insertions(+), 38 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: postgres_fdw: Fix issues with generated columns in foreign table
@ 2021-08-05 11:11  Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Etsuro Fujita @ 2021-08-05 11:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/388a81bf4df4fc86a947368d94094e5276c2f255

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 | 24 ++++++--
contrib/postgres_fdw/expected/postgres_fdw.out | 82 ++++++++++++++++++++++++--
contrib/postgres_fdw/postgres_fdw.c            | 59 +++++++++++++-----
contrib/postgres_fdw/sql/postgres_fdw.sql      | 21 ++++++-
doc/src/sgml/postgres-fdw.sgml                 | 12 ++++
5 files changed, 172 insertions(+), 26 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: postgres_fdw: Fix issues with generated columns in foreign table
@ 2021-08-05 11:11  Etsuro Fujita <efujita@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Etsuro Fujita @ 2021-08-05 11:11 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bbc0cd8fa5f158339e07a737550f3322db0fa307

Modified Files
--------------
contrib/postgres_fdw/deparse.c                 | 24 ++++++--
contrib/postgres_fdw/expected/postgres_fdw.out | 82 ++++++++++++++++++++++++--
contrib/postgres_fdw/postgres_fdw.c            | 59 +++++++++++++-----
contrib/postgres_fdw/sql/postgres_fdw.sql      | 21 ++++++-
doc/src/sgml/postgres-fdw.sgml                 | 12 ++++
5 files changed, 172 insertions(+), 26 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2021-08-05 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 11:11 pgsql: postgres_fdw: Fix issues with generated columns in foreign table Etsuro Fujita <efujita@postgresql.org>
2021-08-05 11:11 pgsql: postgres_fdw: Fix issues with generated columns in foreign table Etsuro Fujita <efujita@postgresql.org>
2021-08-05 11:11 pgsql: postgres_fdw: Fix issues with generated columns in foreign table Etsuro Fujita <efujita@postgresql.org>
2021-08-05 11:11 pgsql: postgres_fdw: Fix issues with generated columns in foreign table Etsuro Fujita <efujita@postgresql.org>

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