Avoid holding a directory FD open across assorted SRF calls.
Tom Lane <tgl@sss.pgh.pa.us>
Avoid holding a directory FD open across assorted SRF calls. This extends the fixes made in commit 085b6b667 to other SRFs with the same bug, namely pg_logdir_ls(), pgrowlocks(), pg_timezone_names(), pg_ls_dir(), and pg_tablespace_databases(). Also adjust various comments and documentation to warn against expecting to clean up resources during a ValuePerCall SRF's final call. Back-patch to all supported branches, since these functions were all born broken. Justin Pryzby, with cosmetic tweaks by me Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com
Files
| Path | Change | +/− |
|---|---|---|
| contrib/adminpack/adminpack.c | modified | +38 −42 |
| contrib/pgrowlocks/pgrowlocks.c | modified | +77 −96 |
| doc/src/sgml/xfunc.sgml | modified | +61 −35 |
| src/backend/utils/adt/datetime.c | modified | +40 −61 |
| src/backend/utils/adt/genfile.c | modified | +56 −56 |
| src/backend/utils/adt/misc.c | modified | +65 −52 |
| src/backend/utils/fmgr/README | modified | +10 −6 |
| src/include/funcapi.h | modified | +12 −1 |
| src/test/regress/expected/misc_functions.out | modified | +21 −0 |
| src/test/regress/sql/misc_functions.sql | modified | +9 −0 |
Documentation touched
Discussion
- pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction 30 messages · 2020-03-08 → 2020-11-13