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-3...@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 -- Sent via pgsql-hackers mailing list (firstname.lastname@example.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers