Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed atend-of-transaction - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed atend-of-transaction
Date
Msg-id 20200311111921.GQ29065@telsasoft.com
Whole thread Raw
In response to Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sun, Mar 08, 2020 at 03:40:09PM -0400, Tom Lane wrote:
> Justin Pryzby <pryzby@telsasoft.com> writes:
> > On Sun, Mar 08, 2020 at 02:37:49PM -0400, Tom Lane wrote:
> >> I guess we ought to change that function to use returns-a-tuplestore
> >> protocol instead of thinking it can hold a directory open across calls.
> > Thanks for the analysis.
> > Do you mean it should enumerate all files during the initial SRF call, or use
> > something other than the SRF_* macros ?
> It has to enumerate all the files during the first call.  I suppose it

> I've just finished scanning the source code and concluding that all
> of these functions are similarly broken:
> pg_ls_dir_files

I patched this one to see what it looks like and to allow /hopefully/ moving
forward one way or another with the pg_ls_tmpfile() patch set (or at least
avoid trying to do anything there which is too inconsistent with this fix).

> I don't see anything in the documentation (either funcapi.h or
> xfunc.sgml) warning that the function might not get run to completion,
> either ...

Also, at first glance, these seem to be passing constant "randomAccess=true"
rather than (bool) (rsinfo->allowedModes&SFRM_Materialize_Random)

$ git grep -wl SFRM_Materialize |xargs grep -l 'tuplestore_begin_heap(true'
contrib/dblink/dblink.c
contrib/pageinspect/brinfuncs.c
contrib/pg_stat_statements/pg_stat_statements.c
src/backend/access/transam/xlogfuncs.c
src/backend/commands/event_trigger.c
src/backend/commands/extension.c
src/backend/foreign/foreign.c
src/backend/replication/logical/launcher.c
src/backend/replication/logical/logicalfuncs.c
src/backend/replication/logical/origin.c
src/backend/replication/slotfuncs.c
src/backend/replication/walsender.c
src/backend/storage/ipc/shmem.c
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/pg_config.c

-- 
Justin

Attachment

pgsql-hackers by date:

Previous
From: Andy Fan
Date:
Subject: Re: Index Skip Scan
Next
From: Amit Kapila
Date:
Subject: Re: [PATCH] Add schema and table names to partition error