Re: AllocSetContextCreate changes breake extensions

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

On 2018-10-12 13:20:16 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-10-12 17:51:53 Re: AllocSetContextCreate changes breake extensions
Previous Message Robert Haas 2018-10-12 17:43:48 Re: Index Skip Scan