From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid statically allocating gmtsub()'s timezone workspace.
Date: Tue, 16 Oct 2018 15:50:42 +0000
Message-ID: <E1gCRcI-0007bt-K9@gemulon.postgresql.org> (raw)
Avoid statically allocating gmtsub()'s timezone workspace.
localtime.c's "struct state" is a rather large object, ~23KB. We were
statically allocating one for gmtsub() to use to represent the GMT
timezone, even though that function is not at all heavily used and is
never reached in most backends. Let's malloc it on-demand, instead.
This does pose the question of how to handle a malloc failure, but
there's already a well-defined error report convention here, ie
set errno and return NULL.
We have but one caller of pg_gmtime in HEAD, and two in back branches,
neither of which were troubling to check for error. Make them do so.
The possible errors are sufficiently unlikely (out-of-range timestamp,
and now malloc failure) that I think elog() is adequate.
Back-patch to all supported branches to keep our copies of the IANA
timezone code in sync. This particular change is in a stanza that
already differs from upstream, so it's a wash for maintenance purposes
--- but only as long as we keep the branches the same.
Discussion: https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de
Branch
------
REL9_3_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/baa94ebe2cc819c118f844c08a28fc52eb88c949
Modified Files
--------------
src/backend/utils/adt/nabstime.c | 3 +++
src/backend/utils/adt/timestamp.c | 3 +++
src/timezone/localtime.c | 11 ++++++-----
3 files changed, 12 insertions(+), 5 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Avoid statically allocating gmtsub()'s timezone workspace.
In-Reply-To: <E1gCRcI-0007bt-K9@gemulon.postgresql.org>
References: <E1gCRcI-0007bt-K9@gemulon.postgresql.org>
* 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