Re: [Bug]Vacuum full silently NULL out fast default columns

From: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Antonin Houska <ah(at)cybertec(dot)at>
Subject: Re: [Bug]Vacuum full silently NULL out fast default columns
Date: 2026-05-04 14:26:34
Message-ID: CAHg+QDeteXPbPFsThTGTL=qp4dgiP1AH1kKktifcksDbiaRROw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, May 4, 2026 at 6:40 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com> writes:
> > VACUUM FULL silently turns columns added via ALTER TABLE ... ADD COLUMN
> ...
> > DEFAULT <const> into NULL
> > on all pre-existing rows. The issue exists for other operations like
> > CLUSTER, REPACK.
>
> That is a seriously awful bug. Fortunately it is not in any shipping
> release. A quick bisect run agrees that it broke here:
>
> 28d534e2ae0ac888b5460f977a10cd9bb017ef98 is the first bad commit
> commit 28d534e2ae0ac888b5460f977a10cd9bb017ef98 (HEAD)
> Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
> Date: Mon Apr 6 21:55:08 2026 +0200
>
> Add CONCURRENTLY option to REPACK
>
> > Patch attached. Added a regression test in fast_default.sql covering
> > VACUUM FULL, CLUSTER, and REPACK on a table with fast-default columns
> > including a NOT NULL CHECK column.
>
> I don't know if this is the best code fix (I don't like putting extra
> checks into a loop condition like this). But I agree we need some
> more tests covering this area.
>
Thanks for reviewing! Attached v2 patch. Agreed, tried to optimize LOC in
V1. Before the change
loop was not breaking early, I fixed that as well in V2.

Thanks,
Satya

Attachment Content-Type Size
v2-0001-VACUUM-FULL-silently-NULL-out-fast-default-columns.patch application/octet-stream 4.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-05-04 14:43:41 Re: [PATCH] Reject ENCODING option for COPY TO FORMAT JSON
Previous Message Tomas Vondra 2026-05-04 14:21:55 Re: PoC: VALGRIND_MAKE_MEM_NOACCESS for dynamic shared memory