pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix application of identity values in some cases 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix application of identity values in some cases @ 2018-02-02 20:07 Peter Eisentraut <peter_e@gmx.net> 0 siblings, 0 replies; 2+ messages in thread From: Peter Eisentraut @ 2018-02-02 20:07 UTC (permalink / raw) To: pgsql-committers Fix application of identity values in some cases Investigation of 2d2d06b7e27e3177d5bef0061801c75946871db3 revealed that identity values were not applied in some further cases, including logical replication subscribers, VALUES RTEs, and ALTER TABLE ... ADD COLUMN. To fix all that, apply the identity column expression in build_column_default() instead of repeating the same logic at each call site. For ALTER TABLE ... ADD COLUMN ... IDENTITY, the previous coding completely ignored that existing rows for the new column should have values filled in from the identity sequence. The coding using build_column_default() fails for this because the sequence ownership isn't registered until after ALTER TABLE, and we can't do it before because we don't have the column in the catalog yet. So we specially remember in ColumnDef the sequence name that we decided on and build a custom NextValueExpr using that. Reviewed-by: Michael Paquier <michael.paquier@gmail.com> Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/533c5d8bddf0feb1785b3da17c0d17feeaac76d8 Modified Files -------------- src/backend/commands/copy.c | 16 ++-------------- src/backend/commands/tablecmds.c | 16 +++++++++++++++- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/parse_utilcmd.c | 8 ++++++++ src/backend/rewrite/rewriteHandler.c | 22 +++++++++++----------- src/include/nodes/parsenodes.h | 2 ++ src/test/regress/expected/identity.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/identity.sql | 19 +++++++++++++++++++ src/test/subscription/t/008_diff_schema.pl | 18 ++++++++++++++---- 11 files changed, 102 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix application of identity values in some cases @ 2018-02-02 20:07 Peter Eisentraut <peter_e@gmx.net> 0 siblings, 0 replies; 2+ messages in thread From: Peter Eisentraut @ 2018-02-02 20:07 UTC (permalink / raw) To: pgsql-committers Fix application of identity values in some cases Investigation of 2d2d06b7e27e3177d5bef0061801c75946871db3 revealed that identity values were not applied in some further cases, including logical replication subscribers, VALUES RTEs, and ALTER TABLE ... ADD COLUMN. To fix all that, apply the identity column expression in build_column_default() instead of repeating the same logic at each call site. For ALTER TABLE ... ADD COLUMN ... IDENTITY, the previous coding completely ignored that existing rows for the new column should have values filled in from the identity sequence. The coding using build_column_default() fails for this because the sequence ownership isn't registered until after ALTER TABLE, and we can't do it before because we don't have the column in the catalog yet. So we specially remember in ColumnDef the sequence name that we decided on and build a custom NextValueExpr using that. Reviewed-by: Michael Paquier <michael.paquier@gmail.com> Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1597948c962a1407c01fc492c44917c097efa92e Modified Files -------------- src/backend/commands/copy.c | 16 ++-------------- src/backend/commands/tablecmds.c | 16 +++++++++++++++- src/backend/nodes/copyfuncs.c | 1 + src/backend/nodes/equalfuncs.c | 1 + src/backend/nodes/outfuncs.c | 1 + src/backend/parser/parse_utilcmd.c | 8 ++++++++ src/backend/rewrite/rewriteHandler.c | 22 +++++++++++----------- src/include/nodes/parsenodes.h | 2 ++ src/test/regress/expected/identity.out | 28 ++++++++++++++++++++++++++++ src/test/regress/sql/identity.sql | 19 +++++++++++++++++++ src/test/subscription/t/008_diff_schema.pl | 18 ++++++++++++++---- 11 files changed, 102 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-02-02 20:07 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-02-02 20:07 pgsql: Fix application of identity values in some cases Peter Eisentraut <peter_e@gmx.net> 2018-02-02 20:07 pgsql: Fix application of identity values in some cases Peter Eisentraut <peter_e@gmx.net>
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