Re: WIP: generalized index constraints

Jeff Davis <pgsql@j-davis.com>

From: Jeff Davis <pgsql@j-davis.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Simon Riggs <simon@2ndQuadrant.com>, pgsql-hackers@postgresql.org
Date: 2009-07-07T21:41:46Z
Lists: pgsql-hackers
On Tue, 2009-07-07 at 13:22 -0400, Tom Lane wrote:
> Also, if hash indexes were a realistic alternative to btree for this,
> we'd already have come up against the problem that the CONSTRAINT syntax
> doesn't provide any way to specify what kind of index you want to use
> underneath the constraint.  I think it might be interesting to turn
> around Jeff's syntax sketch and provide a way to say that a CONSTRAINT
> declaration should depend on some previously added index, eg
> something like
> 
> 	ALTER TABLE tab ADD CONSTRAINT UNIQUE (col1, col2) USING index
> 

How about:

	ALTER TABLE tab ADD INDEX CONSTRAINT [name]
		(col1 [op], col2 [op]) USING index

And then just validate the constraint at creation time, and store the
information in pg_constraint.

Regards,
	Jeff Davis