pgsql: Fix application of identity values in some cases

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема pgsql: Fix application of identity values in some cases
Дата
Msg-id E1ehhc6-0001sh-EP@gemulon.postgresql.org
обсуждение исходный текст
Список 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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: Support parallel btree index builds.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: First-draft release notes for 10.2.