ADD CONSTRAINT behaviour question

From: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>
To: "Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: ADD CONSTRAINT behaviour question
Date: 2001-07-09 01:26:33
Message-ID: ECEHIKNFIMMECLEBJFIGMEDFCBAA.chriskl@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

When adding unique keys:

* If you do this, you get two unique keys (7.0.3):

create table test (int4 a, int4 b);
create unique index indx1 on test(a, b);
create unique index indx2 on test(a, b);

Then you get this:

Table "test"
Attribute | Type | Modifier
-----------+---------+----------
a | integer |
b | integer |
Indices: asdf,
asdf2

* If you do this, you only get two unique keys (7.0.3):

create table test (a int4, b int4, unique(a, b), unique(a, b));

Then you get this:

Table "test"
Attribute | Type | Modifier
-----------+---------+----------
a | integer |
b | integer |
Indices: test_a_key,
test_a_key1

* So, does this mean that my ALTER TABLE/ADD CONSTRAINT code should happily
let people define multiple unique indices over the same columns?

* As a corollary, should it prevent people from adding more than one primary
key constraint?

Chris

ps. I know I only tested these on 7.0.3 - but I assume HEAD has similar
behaviour?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2001-07-09 01:29:43 RE: Re: [GENERAL] Vacuum and Transactions
Previous Message Peter Eisentraut 2001-07-08 22:15:31 Re: [PATCH] Patch to make pg_hba.conf handle virtualhost access control and samehost keyword