AllocSetContextCreate changes breake extensions

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christoph Berg <cb(at)df7cb(dot)de>
Subject: AllocSetContextCreate changes breake extensions
Date: 2018-10-12 17:03:55
Message-ID: 20181012170355.bhxi273skjt6sag4@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Christoph Berg, on IRC, raised the issue that at least one extension
failed compiling in v11. The extension currently does:
https://github.com/pgq/pgq/blob/master/triggers/common.c#L225
tbl_cache_ctx = AllocSetContextCreate(TopMemoryContext,
"pgq_triggers table info",
ALLOCSET_SMALL_MINSIZE,
ALLOCSET_SMALL_INITSIZE,
ALLOCSET_SMALL_MAXSIZE);

which makes sense, because it has to support versions below 9.6, which
introduced ALLOCSET_SMALL_SIZES etc.

But 9fa6f00b1308dd10da4eca2f31ccbfc7b35bb461 / Rethink MemoryContext creation to improve performance
causes this to fail to compile because since then AllocSetContextCreate
is declared to have three parameters:

#ifdef HAVE__BUILTIN_CONSTANT_P
#define AllocSetContextCreate(parent, name, allocparams) \
(StaticAssertExpr(__builtin_constant_p(name), \
"memory context names must be constant strings"), \
AllocSetContextCreateExtended(parent, name, allocparams))
#else
#define AllocSetContextCreate(parent, name, allocparams) \
AllocSetContextCreateExtended(parent, name, allocparams)
#endif

which means it only compiles if ALLOCSET_*_SIZES is passed, rather than
individual parameters.

I think we should fix that. If the goal was to only allow passing the
*SIZES parameters, we should have called it out as that.

Based on a quick look, ISTM the easiest fix is to have the
AllocSetContextCreate accept five parameters, and move it below the
ALLOCSET_*_SIZES macros. That way they should be expanded before
AllocSetContextCreate(), and thus 5 params should be fine.

Greetings,

Andres Freund

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2018-10-12 17:10:41 Re: AllocSetContextCreate changes breake extensions
Previous Message Robert Haas 2018-10-12 17:00:54 Re: Requesting advanced Group By support