From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Let's start using setenv()
Date: Tue, 29 Dec 2020 16:25:51 -0500
Message-ID: <2197258.1609277151@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKGLnssyqtzjrsMjMZRD=piYxkO5K9iJwbPemdw2MTmZTmQ@mail.gmail.com>
References: <2065122.1609212051@sss.pgh.pa.us>
<CA+hUKGK=3Q1rjmjmSp++emRNMZMfDCb-8hdUDPujeKxQNWe-Hw@mail.gmail.com>
<2079685.1609219313@sss.pgh.pa.us>
<2152500.1609260303@sss.pgh.pa.us>
<CA+hUKGLnssyqtzjrsMjMZRD=piYxkO5K9iJwbPemdw2MTmZTmQ@mail.gmail.com>
Thomas Munro <thomas.munro@gmail.com> writes:
> On Wed, Dec 30, 2020 at 5:45 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> + /* We assume the error must be "out of memory" */
> + ereport(LOG,
> + (errcode(ERRCODE_OUT_OF_MEMORY),
> + errmsg("out of memory")));
> Wouldn't it be better to do "cannot set environment: %m" or similar,
> and let ENOMEM do its thing if that be the cause?
That's no problem as far as the error text goes, but we lack a way to
choose a relevant errcode(). I guess I could fix it for ENOMEM
specifically, along the lines of
errcode(errno == ENOMEM ? ERRCODE_OUT_OF_MEMORY :
ERRCODE_INTERNAL_ERROR)
This is a bit trickier than it looks though, because code within an
ereport macro isn't really supposed to rely on errno still being
the same as at entry. Is it worth inventing an errcode_for_errno()
helper routine, which could look at the stashed errno? Or maybe
extending/abusing errcode_for_file_access() so it recognizes ENOMEM?
Or we could just use ERRCODE_OUT_OF_MEMORY, without being too picky
about whether that's accurate.
> Did you want to drop the canonicalize_path() logic here and nearby?
Yeah, because the results of get_locale_path et al are already
canonicalized, so those canonicalize_path calls are redundant.
Thanks for looking at the patch!
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, thomas.munro@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Let's start using setenv()
In-Reply-To: <2197258.1609277151@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox