aboutsummaryrefslogtreecommitdiff
path: root/src/tutorial/basics.source
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-03-11 15:27:59 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-03-11 15:27:59 -0400
commit63b51dfec18eb3c280adfa0f6e970946c441f574 (patch)
treea4fd098d706228b4773265016f0982b315806654 /src/tutorial/basics.source
parent7c094a11c70d4790ae4067023806a026c6fd2fe1 (diff)
downloadpostgresql-63b51dfec18eb3c280adfa0f6e970946c441f574.tar.gz
postgresql-63b51dfec18eb3c280adfa0f6e970946c441f574.zip
Avoid holding a directory FD open across pg_ls_dir_files() calls.
This coding technique is undesirable because (a) it leaks the FD for the rest of the transaction if the SRF is not run to completion, and (b) allocated FDs are a scarce resource, but multiple interleaved uses of the relevant functions could eat many such FDs. In v11 and later, a query such as "SELECT pg_ls_waldir() LIMIT 1" yields a warning about the leaked FD, and the only reason there's no warning in earlier branches is that fd.c didn't whine about such leaks before commit 9cb7db3f0. Even disregarding the warning, it wouldn't be too hard to run a backend out of FDs with careless use of these SQL functions. Hence, rewrite the function so that it reads the directory within a single call, returning the results as a tuplestore rather than via value-per-call mode. There are half a dozen other built-in SRFs with similar problems, but let's fix this one to start with, just to see if the buildfarm finds anything wrong with the code. In passing, fix bogus error report for stat() failure: it was whining about the directory when it should be fingering the individual file. Doubtless a copy-and-paste error. Back-patch to v10 where this function was added. Justin Pryzby, with cosmetic tweaks and test cases by me Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com
Diffstat (limited to 'src/tutorial/basics.source')
0 files changed, 0 insertions, 0 deletions