Tom Lane wrote:
> "Sam Mason" <sam@samason.me.uk> writes:
>> p.s. the reason for creating this strange index was to ensure that a maximum
>> of one row was inserted into the table---I can do this different ways for
>> now.
>
> Please explain how you thought it would help you do that, because
> without some evidence that there's a use-case, I'm inclined to fix it
> as above ...
Note that it was a unique index:
postgres=# CREATE TABLE silly (id integer);
CREATE TABLE
postgres=# CREATE UNIQUE INDEX i_silly ON silly ((1));
CREATE INDEX
postgres=# INSERT INTO silly VALUES (1);
INSERT 0 1
postgres=# INSERT INTO silly VALUES (2);
ERROR: duplicate key value violates unique constraint "i_silly"
Not sure that's enough of a use case to justify not banning it...
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com