Re: NOT NULL markings for BKI columns - Mailing list pgsql-hackers

From Andres Freund
Subject Re: NOT NULL markings for BKI columns
Date
Msg-id 20150220213441.GG12653@awork2.anarazel.de
Whole thread Raw
In response to Re: NOT NULL markings for BKI columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: NOT NULL markings for BKI columns  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
On 2015-02-15 12:54:45 -0500, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > Hm, I was thinking about
> >     /* extversion should never be null, but the others can be. */
> >     text        extversion PG_FORCENOTNULL; /* extension version name */
> > but pgindent then removes some of the space between text and extversion,
> > making it
> >     text extversion PG_FORCENOTNULL;    /* extension version name */
> > an alternative where it doesn't do that is
> >     text        PG_FORCENOTNULL(extversion);    /* extension version name */
>
> > Not sure what's the best way here.
>
> The former is clearly a lot more sane semantically, so I'd go with
> that even if the whitespace is a bit less nice.

Yea.

> I notice that pgindent does a similar not-very-nice thing with
> PG_USED_FOR_ASSERTS_ONLY.  I wonder if we could hack it to handle
> those two identifiers specially?

I looked for about a minute and it didn't seem trivial to
do. Unfortunately that's pretty much all I'm willing to do.

> BTW, the precedent of PG_USED_FOR_ASSERTS_ONLY would suggest calling
> this one PG_FORCE_NOT_NULL, or at least using underscores for word
> breaks in whatever we end up calling it.

I've named it BKI_FORCE_(NOT_)?NULL.

So, I've implemented this - turned out to be a bit more work than I'd
expected... I had to whack around the representation Catalog.pm returns
for columns, but I think the new representation for columns is better
anyway. Doesn't look too bad.

The second patch attached adds BKI_FORCE_NOT_NULL marker to the system
columns that, based on a single scan through the relevant headers, are
missing NOT NULL.

I've also added BKI_FORCE_NULL as you mentioned it as being possibly
useful, was easy enough. I haven't identified a user so far though, so
we could just remove it if we want.

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Abbreviated keys for Numeric (was: Re: B-Tree support function number 3 (strxfrm() optimization))
Next
From: Peter Eisentraut
Date:
Subject: Re: Turning recovery.conf into GUCs