Re: WIP: generalized index constraints - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: WIP: generalized index constraints
Date
Msg-id 4A8D0D98.7070202@enterprisedb.com
Whole thread Raw
In response to Re: WIP: generalized index constraints  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: WIP: generalized index constraints  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
Jeff Davis wrote:
> I'm going to try to get this patch ready for the 9-15 commitfest. Here
> are a few design updates:
> 
> (1) Language:
> 
> I think that the new language should be a table constraint, and I think
> there's a consensus on that. The specific language I have in mind is:
> 
>   CREATE TABLE (
>     ...,
>     INDEX CONSTRAINT (<attname> <op>, ...) USING INDEX <indexname>
>   );

That sounds like the constraint is based on an existing index, but there
can't be any existing indexes on a table that hasn't been created yet.
If this creates the index, then the syntax needs to support specifying
index access method and an opclass for all the columns.

>   ALTER TABLE ADD INDEX CONSTRAINT (<attname> <op>, ...)
>     USING INDEX <indexname>;
> 
> Where <op> is the constraint operator. For example, if all <op>s are
> "=" (or whatever the operator for BTEqualStragey is for that type), that
> would be semantically identical to a UNIQUE constraint.

This makes more sense.

It would be nice to have syntax to create the index and constraint in
one command, so that the constraint can be checked while the index is
being created. Otherwise you need an extra heap scan to check it.

--  Heikki Linnakangas EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: FDW-based dblink (WIP)
Next
From: Robert Haas
Date:
Subject: Re: hot standby - merged up to CVS HEAD