Re: Feature request - function-based deferrable uniques.

From: Dmitry Fefelov <fozzy(at)ac-sw(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Feature request - function-based deferrable uniques.
Date: 2010-04-02 03:07:37
Message-ID: 201004021007.37176.fozzy@ac-sw.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> Sure -- use CREATE UNIQUE INDEX.
>
> alvherre=# create function singleton(int) returns int immutable language sql
as $$ select 1 $$;
> CREATE FUNCTION
> alvherre=# create table singleton (a int);
> CREATE TABLE
> alvherre=# create unique index only_one on singleton (singleton(a));
> CREATE INDEX
> alvherre=# insert into singleton values (3);
> INSERT 0 1
> alvherre=# insert into singleton values (6);
> ERROR: llave duplicada viola restricción de unicidad «only_one»

And it's possible to make this check deferrable? Uniqueness will be validated
on commit or SET ALL CONSTRAINTS IMMEDIATE command?

>
>
> The reason it's not supported in table_constraint, IIUC, is that the
> standard doesn't allow it, and that syntax is standards-mandated.
> CREATE INDEX, however, is not.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2010-04-02 03:25:27 Re: Alpha release this week?
Previous Message Fujii Masao 2010-04-02 02:53:37 Re: pending patch: Re: Streaming replication and pg_xlogfile_name()