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 <[email protected]>
Reviewed-by: Jim Jones <[email protected]>
Reviewed-by: Ayoub Kazar <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Discussion: 
https://postgr.es/m/cahgqgwgwihfv9fmfsbbrmser4fti7ahzfkpymv5-byjfc2e...@mail.gmail.com
Backpatch-through: 16

Branch
------
REL_16_STABLE

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

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(-)

Reply via email to