pgsql: file_fdw: Fix ANALYZE crashes with DEFAULT markers

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: file_fdw: Fix ANALYZE crashes with DEFAULT markers
Date: 2026-11-06 14:34:00
Message-ID: E1xPL0y-00000000TNW-486A@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

file_fdw: Fix ANALYZE crashes with DEFAULT markers

ANALYZE on a file_fdw foreign table failed an assertion when the input
contained a DEFAULT marker, and could crash in builds without assertions.

This happened because the sampling code passed a NULL ExprContext to
NextCopyFrom(), which requires one to evaluate column defaults. Fix
this by providing an expression context for sampling, allowing defaults
to be evaluated without assertion failures or crashes.

Backpatch to v16, which introduced DEFAULT marker support.

Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Reviewed-by: Ayoub Kazar <ayoub(dot)kazar(at)data-bene(dot)io>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwGwihFV9FmfSbbrMsEr4fti7aHZFkpyMv5-byjfc2EmOw@mail.gmail.com
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/72b9498df9a369e747f8d96efb5a6cd33c2451e2

Modified Files
--------------
contrib/file_fdw/expected/file_fdw.out | 10 ++++++++++
contrib/file_fdw/file_fdw.c | 24 +++++++++++++-----------
contrib/file_fdw/sql/file_fdw.sql | 5 +++++
3 files changed, 28 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-06 14:34:26 pgsql: file_fdw: Fix ANALYZE crashes with DEFAULT markers
Previous Message Michael Paquier 2026-11-06 11:21:21 pgsql: Fix some typos in comments