pgsql: Force tuple conversion when the source has missing attributes. - Mailing list pgsql-committers

From Andrew Gierth
Subject pgsql: Force tuple conversion when the source has missing attributes.
Date
Msg-id E1izRE4-00052M-0u@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Force tuple conversion when the source has missing attributes.

Tuple conversion incorrectly concluded that no conversion was needed
as long as all the attributes lined up. But if the source tuple has a
missing attribute (from addition of a column with default), then the
destination tupdesc might not reflect the same default. The typical
symptom was that the affected columns would be unexpectedly NULL.

Repair by always forcing conversion if the source has missing
attributes, which will be filled in by the deform operation. (In
theory we could optimize for when the destination has the same
default, but that seemed overkill.)

Backpatch to 11 where missing attributes were added.

Per bug #16242.

Vik Fearing (discovery, code, testing) and me (analysis, testcase).

Discussion: https://postgr.es/m/16242-d1c9fca28445966b@postgresql.org

Branch
------
master

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

Modified Files
--------------
src/backend/access/common/attmap.c        | 12 ++++++----
src/test/regress/expected/alter_table.out | 38 ++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 39 +++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Make vacuum buffer counters 64 bits wide
Next
From: Michael Paquier
Date:
Subject: pgsql: Add leader_pid to pg_stat_activity