aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-11-19 15:03:17 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2020-11-19 15:03:17 -0500
commit97390fe8a6e96a153e59b0180f4303acaeb75b84 (patch)
tree9cf64003f4e2a738aa4ea928a94deaecc83789e1 /src/backend/parser/parse_expr.c
parentafaccbba787d5f1470c44ddd61c9ddaaad19e27e (diff)
downloadpostgresql-97390fe8a6e96a153e59b0180f4303acaeb75b84.tar.gz
postgresql-97390fe8a6e96a153e59b0180f4303acaeb75b84.zip
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
Diffstat (limited to 'src/backend/parser/parse_expr.c')
0 files changed, 0 insertions, 0 deletions