pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
7+ messages / 1 participants
[nested] [flat]

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/87ab464219259abdc06b0492f0d42bc6734ae490

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/159b6775fad9b040fb181e5660a8149e57aa0609

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/97390fe8a6e96a153e59b0180f4303acaeb75b84

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/513db7b7004c8d1fa15dea4747a32cbc8f9621ef

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6631d5f261e9fdc2ccc2a81214a45865d6e59122

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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

* pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential
@ 2020-11-19 20:03  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2020-11-19 20:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fixes for CREATE TABLE LIKE: cope with self-referential FKs.

Commit 502898192 was too careless about the order of execution of the
additional ALTER TABLE operations generated by expandTableLikeClause.
It just stuck them all at the end, which seems okay for most purposes.
But it falls down in the case where LIKE is importing a primary key
or unique index and the outer CREATE TABLE includes a FOREIGN KEY
constraint that needs to depend on that index.  Weird as that is,
it used to work, so we ought to keep it working.

To fix, make parse_utilcmd.c insert LIKE clauses between index-creation
and FK-creation commands in the transformed list of commands, and change
utility.c so that the commands generated by expandTableLikeClause are
executed immediately not at the end.  One could imagine scenarios where
this wouldn't work either; but currently expandTableLikeClause only
makes column default expressions, CHECK constraints, and indexes, and
this ordering seems fine for those.

Per bug #16730 from Sofoklis Papasofokli.  Like the previous patch,
back-patch to all supported branches.

Discussion: https://postgr.es/m/16730-b902f7e6e0276b30@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/98f3f1d5c1bff02a25a0af7dcf3a4676dddf58e1

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 27 +++++++++++++++++++-----
src/backend/tcop/utility.c                      | 28 ++++++++++++-------------
src/test/regress/expected/create_table_like.out | 16 ++++++++++++++
src/test/regress/sql/create_table_like.sql      |  5 +++++
4 files changed, 56 insertions(+), 20 deletions(-)



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


end of thread, other threads:[~2020-11-19 20:03 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>
2020-11-19 20:03 pgsql: Further fixes for CREATE TABLE LIKE: cope with self-referential Tom Lane <tgl@sss.pgh.pa.us>

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