Re: AllocSetContextCreate changes breake extensions - Mailing list pgsql-hackers

From Andres Freund
Subject Re: AllocSetContextCreate changes breake extensions
Date
Msg-id 20181012174624.tp2hwxxebso7giyy@alap3.anarazel.de
Whole thread Raw
In response to Re: AllocSetContextCreate changes breake extensions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: AllocSetContextCreate changes breake extensions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2018-10-12 13:20:16 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> > 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.
> 
> Yeah, we discussed that at the time and thought it was acceptable
> collateral damage.  It's not like nobody ever breaks API in new major
> versions.

Sure, we do that all the time.  It just seems quite unnecessarily
painful here, especially because ALLOCSET_*_SIZES wasn't backpatched.


> > 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.
> 
> Huh?  The order in which you #define macros doesn't affect expansion.

return -ENOCOFFEE;


But can't we just do something like:

#if defined(HAVE__BUILTIN_CONSTANT_P) && defined(HAVE__VA_ARGS)
#define AllocSetContextCreate(parent, name, ...) \
    (StaticAssertExpr(__builtin_constant_p(name), \
                      "memory context names must be constant strings"), \
     AllocSetContextCreateExtended(parent, name, __VA_ARGS__))
#else
#define AllocSetContextCreate \
    AllocSetContextCreateExtended
#endif

The set of compilers that have __builtin_constant_p and not vararg
macros got to be about empty.


Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Index Skip Scan
Next
From: Tom Lane
Date:
Subject: Re: AllocSetContextCreate changes breake extensions