Skip site navigation (1) Skip section navigation (2)

Patch: Extend NOT NULL representation to pg_constraint

From: José Arthur Benetasso Villanova <jose(dot)arthur(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Patch: Extend NOT NULL representation to pg_constraint
Date: 2010-09-25 22:55:02
Message-ID: AANLkTimbjV+-Q+bpycRKRasEu2ThhYQig6e=LoqfTbAX@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi all.

My name is Jose Arthur and I use PostgreSQL for a while, but never
contributed to the main project, until now.

Since nobody else take this patch to review in this commitfest, I'm going to
try :-). The main problem can be found here:
http://archives.postgresql.org/pgsql-hackers/2009-11/msg00146.php

How to simulate:

CREATE TABLE foo(id integer NOT NULL, val text NOT NULL);
CREATE TABLE foo2(another_id integer NOT NULL) INHERITS(foo);
ALTER TABLE foo2 ALTER COLUMN val DROP NOT NULL;
insert into foo2 values (1, null, 1);

Then pg_dump > dump.pgsql and psql -f dump.pgsql

I've applied the patch submitted here:
http://archives.postgresql.org/pgsql-hackers/2010-09/msg00763.php against
current master (635de8365f0299cfa2db24c56abcfccb65d020f0) and compile is
fine

Using the patch, I can't drop NOT NULL from foo2, just from foo, and I think
that makes sense:

postgres=# ALTER TABLE foo2 ALTER COLUMN val DROP NOT NULL;
ERROR:  cannot drop inherited NOT NULL constraint "foo2_val_not_null",
relation "foo2"

One thing that I take notice is when you create a simple table like this
one: select count(*) from pg_constraint ; 12 rows appears in pg_constraint,
10 to the sequence. Is that ok?

Other thing:
#define CONSTRAINT_NOTNULL          'n' in
src/include/catalog/pg_constraint.h is using spaces instead of tabs :-)


-- 
José Arthur Benetasso Villanova

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2010-09-25 23:32:09
Subject: Re: pgsql: git_topo_order script, to match up commits across branches.
Previous:From: Greg StarkDate: 2010-09-25 22:38:14
Subject: Re: Serializable Snapshot Isolation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group