Re: A micro-optimisation for walkdir()
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-09-03T23:58:21Z
Lists: pgsql-hackers
Attachments
- v3-0001-Skip-unnecessary-stat-calls-in-walkdir.patch (text/x-patch) patch v3-0001
- v3-0002-Add-d_type-to-Win32-dirent-port.patch (text/x-patch) patch v3-0002
On Fri, Sep 4, 2020 at 3:31 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@gmail.com> writes:
> > Hmm. Well I had it like that in an earlier version, but then I
> > couldn't figure out the right way to write code that would work in
> > both frontend and backend code, without writing two copies in two
> > translation units, or putting the whole thing in a header. What
> > approach do you prefer?
>
> Well, there are plenty of places in src/port/ where we do things like
>
> #ifndef FRONTEND
> ereport(ERROR,
> (errcode_for_file_access(),
> errmsg("could not get junction for \"%s\": %s",
> path, msg)));
> #else
> fprintf(stderr, _("could not get junction for \"%s\": %s\n"),
> path, msg);
> #endif
>
> I don't see a compelling reason why this function couldn't report
> stat() failures similarly, especially if we're just going to have
> the callers do exactly the same thing as that anyway.
Ok, so the main weird thing is that you finish up having to pass in an
elevel, but that has different meanings in FE and BE code. Note that
you still need a PGFILE_ERROR return value, because we don't log
messages at a level that exits non-locally (and that concept doesn't
even exist for FE logging).
Commits
-
Add d_type to our Windows dirent emulation.
- 87e6ed7c8c6a 14.0 landed
-
Skip unnecessary stat() calls in walkdir().
- 861c6e7c8e4d 14.0 landed