Re: Create a deferrably-unique index - Mailing list pgsql-general

From Tom Lane
Subject Re: Create a deferrably-unique index
Date
Msg-id 24779.1376938894@sss.pgh.pa.us
Whole thread Raw
In response to Re: Create a deferrably-unique index  (Paul Jungwirth <pj@illuminatedcomputing.com>)
List pgsql-general
Paul Jungwirth <pj@illuminatedcomputing.com> writes:
>> Deferrability is a property of a constraint, not an index

> Yes, but creating a unique constraint implicitly creates an index, and
> creating a unique index implicitly creates a constraint.

No, it doesn't.  I'm using "constraint" in a technical sense here,
that is something that is recorded as a constraint in the system
catalogs.

regression=# select count(*) from pg_constraint;
 count
-------
    34
(1 row)

regression=# create table foo(f1 int unique);
CREATE TABLE
regression=# select count(*) from pg_constraint;
 count
-------
    35
(1 row)

regression=# create table bar(f1 int);
CREATE TABLE
regression=# create unique index on bar(f1);
CREATE INDEX
regression=# select count(*) from pg_constraint;
 count
-------
    35
(1 row)

The index on bar didn't create a constraint.

            regards, tom lane


pgsql-general by date:

Previous
From: Paul Jungwirth
Date:
Subject: Re: Create a deferrably-unique index
Next
From: BladeOfLight16
Date:
Subject: Re: Denormalized field