Re: MemoryContext reset/delete callbacks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: MemoryContext reset/delete callbacks
Date: 2015-02-27 22:22:01
Message-ID: 20196.1425075721@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2015-02-26 19:28:50 -0500, Tom Lane wrote:
>> 1. I used ilists for the linked list of callback requests. This creates a
>> dependency from memory contexts to lib/ilist. That's all right at the
>> moment since lib/ilist does no memory allocation, but it might be
>> logically problematic. We could just use explicit "struct foo *" links
>> with little if any notational penalty, so I wonder if that would be
>> better.

> Maybe I'm partial here, but I don't see a problem. Actually the reason I
> started the ilist stuff was that I wrote a different memory context
> implementation ;). Wish I'd time/energy to go back to that...

After further reflection, I concluded that it was better to go with the
low-tech "struct foo *next" approach. Aside from the question of whether
we really want mcxt.c to have any more dependencies than it already does,
there's the stylistic point that mcxt.c is already managing lists (of
child contexts) that way; it would be odd to have two different list
technologies in use in the one data structure.

You could of course argue that both of these should be changed to slists,
but that would be a matter for a separate patch. (And frankly, I'm not
so in love with the slist notation that I'd think it an improvement.)

I also rearranged the bool fields as you suggested to avoid wasted padding
space. I'm still not exactly convinced that it's worth the ugliness, but
it's not worth arguing about.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2015-02-27 22:29:59 Re: deparsing utility commands
Previous Message Tom Lane 2015-02-27 22:17:01 pgsql: Invent a memory context reset/delete callback mechanism.