Re: spi/timetravel: unique constraint violation on UPDATE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgresql(at)get-experience(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: spi/timetravel: unique constraint violation on UPDATE
Date: 2017-07-15 21:15:33
Message-ID: 28981.1500153333@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

postgresql(at)get-experience(dot)com writes:
> I'm having a problem with the timetravel extension. Following simple schema:
> ...
> What am I doing wrong here? According to the function comment in
> timetravel.c it should:
> a) set last-version row to NEW data; valid_from=now()
> b) insert a new row with OLD data; valid_to=now() - at this point the
> old valid_from is already supposed to be updated.

I don't see anywhere in that comment that says "the old valid_from is
already supposed to be updated". Given that the INSERT of the cloned row
happens during the BEFORE UPDATE trigger, it would take a lot of magic
for things to happen that way ;-).

Perhaps you could make your PK be on (id, valid_from, valid_to).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message postgresql 2017-07-15 21:36:27 Re: spi/timetravel: unique constraint violation on UPDATE
Previous Message postgresql 2017-07-15 18:56:27 spi/timetravel: unique constraint violation on UPDATE