Re: PL/pgSQL trigger and sequence increment

From: jonesd(at)xmission(dot)com
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/pgSQL trigger and sequence increment
Date: 2011-09-07 16:32:09
Message-ID: 20110907103209.pysjcfey4oos48sg@webmail.xmission.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Seems like you would be a lot better off enforcing this with a unique
> index on (submitter_id, date_trunc('month',entry_timestamp)). The above
> not only doesn't provide any feedback, it's got serious race-condition
> problems.

Unfortunately, it didn't work.

CREATE UNIQUE INDEX one_entry_per_submitter_per_month ON table_entry
(submitter_id , date_trunc('month',entry_timestamp));

runs into

ERROR: functions in index expression must be marked IMMUTABLE.

If I'm reading this correctly, date_trunc is not IMMUTABLE and thus
not usable in an index.

Dominic Jones, Ph.D.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2011-09-07 16:37:13 Re: SSL certificates issue
Previous Message Radosław Smogura 2011-09-07 16:32:08 Re: SSL certificates issue