Re: Reset sequence to current maximum value of rows

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Rich Shepard <rshepard@appl-ecosys.com>
Cc: pgsql-general@lists.postgresql.org
Date: 2024-06-13T22:29:01Z
Lists: pgsql-general
On Thu, Jun 13, 2024 at 3:13 PM Rich Shepard <rshepard@appl-ecosys.com>
wrote:

> Yes, I'm sure. Early yesterday I did get duplicate key errors. That's when
> I
> looked on stackexchange to learn how to reset the sequence's max value to
> the value of the number of rows in the table. Not only did my attempt to
> add
> a single new company to the companies table change all company names in
> that
> one industry to the new name, but I just discovered that it changed all
> rows
> in that column to the new company name:
>
>
At present the belief there is a bug in PostgreSQL is unsubstantiated.

I suggest you look internally for how an update command that caused the
resultant data could have been executed.  That is much more plausible, and
thus a better use of time, if you want to spend more time on this, than
trying to produce the observed behavior again using just insert and
setval(...) commands.

David J.