"UNIQUE" not recognized when another attribute is declared as "PRIMARY KEY"

From: "Herr Dumont" <dumont(at)gmx(dot)net>
To: <pgsql-bugs(at)postgresql(dot)org>
Subject: "UNIQUE" not recognized when another attribute is declared as "PRIMARY KEY"
Date: 2000-01-30 23:06:48
Message-ID: 006b01bf6b77$fd5a5860$f33a06d5@powerstation
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : RP. Dumont
Your email address : dumont(at)gmx(dot)net

System Configuration
---------------------
Architecture (example: Intel Pentium) : Intel
Pentium MMX

Operating System (example: Linux 2.0.26 ELF) : Linux 2.2.5 ELF
(i386)

PostgreSQL version (example: PostgreSQL-6.5.1) : PostgreSQL-6.5.1

Compiler used (example: gcc 2.8.0) : gcc
egcs-2.91.66

Please enter a FULL description of your problem:
------------------------------------------------

When a table is created using "CREATE TABLE" and one attribute is
declared as "PRIMARY KEY", the word "UNIQUE" has no effect
on another attribute (i.e. no implicit index is created for the "UNIQUE"
attribute and it is possible to add several records with the same value
for the "UNIQUE" attribute).

PostgreSQL 6.4.2 did not have any problem with that.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

First connect to a database:

psql mydb

Then create the following table:

CREATE TABLE mytest (
x INTEGER PRIMARY KEY,
y VARCHAR(20) UNIQUE
);

Now it is possible to insert this:

INSERT INTO mytest VALUES (1,´test´);
INSERT INTO mytest VALUES (2,´test´);

although this should not be possible, because
y was declared as "UNIQUE" !

This problem only occurs when one attribute is
a "PRIMARY KEY".

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Browse pgsql-bugs by date

  From Date Subject
Next Message Herr Dumont 2000-01-31 19:33:55 Correction of my bug report sent on 2000-01-28
Previous Message Jason Lewis 2000-01-29 03:13:59 a bug