Re: nextval() on serial using old, existing value on insert? - Mailing list pgsql-admin

From hubert depesz lubaczewski
Subject Re: nextval() on serial using old, existing value on insert?
Date
Msg-id ZFzhvT/4cvUTRlF2@depesz.com
Whole thread Raw
In response to Re: nextval() on serial using old, existing value on insert?  (Wells Oliver <wells.oliver@gmail.com>)
Responses Re: nextval() on serial using old, existing value on insert?
List 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




pgsql-admin by date:

Previous
From: Norbert Poellmann
Date:
Subject: Re: pg_stat_activity query_id
Next
From: Erik Wienhold
Date:
Subject: Re: pg_stat_activity query_id