NOT NULL constraints in foreign tables - Mailing list pgsql-hackers

From Alvaro Herrera
Subject NOT NULL constraints in foreign tables
Date
Msg-id 1345229520-sup-4761@alvh.no-ip.org
Whole thread Raw
Responses Re: NOT NULL constraints in foreign tables
Re: NOT NULL constraints in foreign tables
List pgsql-hackers
Hi,

I noticed one more problem with NOT NULL constraints and foreign tables
-- which is that they are allowed at all (see also
http://archives.postgresql.org/message-id/1345214955-sup-3970@alvh.no-ip.org
earlier today).

Right now, with my patch, foreign table creation fails if you have a NOT
NULL column, because that NOT NULL will create a check constraint, and
those are disallowed for foreign tables.  So while HEAD allows you to
create the table, my patch causes that to fail.

There are two things I could do about this:

1. Avoid creating the CHECK constraint for NOT NULL declarations in
foreign tables.  This is the easiest to code, but it leaves us in the
situation that foreign tables will lack pg_constraint rows for NOT NULL
columns.  Not sure how undesirable this is.

2. Avoid having DefineRelation complain if it sees CHECK constraints
which correspond to some NOT NULL column declaration.  This is more
complex to implement, because basically we'd have to decompile the CHECK
constraint to find out whether it corresponds to something that had
previously been declared as just NOT NULL, and throw an error otherwise.
But this would mean we would have pg_constraint rows for those columns
... which I'm not really sure is a good thing.

I mean, what are NOT NULL in foreign tables for?  Are they harmed or
helped by having pg_constraint rows?

Thanks.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: psql \set vs \copy - bug or expected behaviour?
Next
From: Tom Lane
Date:
Subject: Re: NOT NULL constraints in foreign tables