AllocSetContextCreate changes breake extensions - Mailing list pgsql-hackers

From Andres Freund
Subject AllocSetContextCreate changes breake extensions
Date
Msg-id 20181012170355.bhxi273skjt6sag4@alap3.anarazel.de
Whole thread Raw
Responses Re: AllocSetContextCreate changes breake extensions  (Christoph Berg <myon@debian.org>)
Re: AllocSetContextCreate changes breake extensions  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Requesting advanced Group By support
Next
From: Christoph Berg
Date:
Subject: Re: AllocSetContextCreate changes breake extensions