Re: Shouldn't pg_(sh)seclabel.provider be marked NOT NULL?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgreSQL(dot)org" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Shouldn't pg_(sh)seclabel.provider be marked NOT NULL?
Date: 2014-06-20 19:49:11
Message-ID: 11510.1403293751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Jun 20, 2014, at 10:01 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Some of my Salesforce colleagues are looking into making every system
>> catalog be declared with a true primary key. They came across the
>> fact that pg_seclabel and pg_shseclabel are declared with unique
>> indexes that include the "provider" column, but that column does not
>> get marked as NOT NULL during initdb. Shouldn't it be?

> At some point, I inferred a rule that catalog columns were intended to
> be either both fixed-width and not nullable; or variable-width and
> nullable. I believe the current situation is the result of that
> inference... but I see no particular reason not to change it.

The actual rule that's embodied in the bootstrap code is to mark
everything that could potentially be referenced via a C struct field
as not nullable: which is to say, fixed-width fields up till we get
to the first variable-width one. It's fairly likely that this is *not*
marking all the columns that the code expects to be non-null in practice.

The idea I'm toying with right now is to additionally mark as not nullable
any column referenced in a DECLARE_UNIQUE_INDEX command in
catalog/indexing.h. But I've not looked through that set carefully; it's
conceivable that we actually have some indexed catalog columns that are
allowed to be null. A possibly better solution is to invent a new macro
that has the same semantics as DECLARE_UNIQUE_INDEX, plus forcing the
columns to be marked NOT NULL.

A bigger-picture question is whether there are yet more columns that
could be marked not null, and how much we care about making them so.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2014-06-20 20:50:15 Re: Shouldn't pg_(sh)seclabel.provider be marked NOT NULL?
Previous Message Robert Haas 2014-06-20 19:34:33 Re: Shouldn't pg_(sh)seclabel.provider be marked NOT NULL?