Re: Is custom MemoryContext prohibited?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Kohei KaiGai <kaigai(at)heterodb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is custom MemoryContext prohibited?
Date: 2020-02-05 18:09:48
Message-ID: CA+Tgmob7_ET0yhu41w+vqTvEo=531h361z51A8Y_x4uuxj_34w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 5, 2020 at 12:15 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> The core problem that I'm unhappy about is that what you want to do
> adds cognitive burden (including an increased risk of mistakes) and
> extra debugging commands in common cases around inspecting memory
> contexts in a debugger. Sure, it's not a fatal problem, but it's
> still a burden. I judge that putting an enum into the struct would
> greatly reduce that burden at very small cost.

I respect that, but I disagree. I think the annoyance and strangeness
factor of the enum is pretty high for third-party code that wants to
use this, because deliberately concocting an out-of-range value for an
enum is really odd. And I think the gain in debuggability is pretty
low, because even if the enum seems to have the expected value, you
still don't really know that things are OK unless you check the magic
number and the methods field, too. On the other hand, I don't inspect
memory contexts in a debugger all that often, and it sounds like you
do, or you presumably wouldn't feel so strongly about this.

We might have to see if anybody else has an opinion. I'd rather do it
your way than no way, but I feel like it's such a strange design that
I'd be afraid to commit it if anyone other than you had suggested it,
for fear of having you demand an immediate revert and, maybe, the
removal of some of my less important limbs.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2020-02-05 18:26:17 Re: Memory-Bounded Hash Aggregation
Previous Message Alvaro Herrera 2020-02-05 18:08:16 Re: Documentation patch for ALTER SUBSCRIPTION