Re: nextval() on serial using old, existing value on insert?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: nextval() on serial using old, existing value on insert?
Date: 2023-05-11 12:38:21
Message-ID: ZFzhvT/4cvUTRlF2@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, May 10, 2023 at 10:06:28PM -0700, Wells Oliver wrote:
> As a follow up, I've selected max(common_key) from the table and
> setval()'ed on the sequence to that +1 and I think that should make this go
> away. Any reason why that's insane?

If you're on pg 10 or newer, you can make the id to be "generated always
as identity" which will make it impossible to provide id value from
user, thus making the problem impossible to happen.

Best regards,

depesz

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Erik Wienhold 2023-05-11 13:46:31 Re: pg_stat_activity query_id
Previous Message Norbert Poellmann 2023-05-11 11:47:11 Re: pg_stat_activity query_id