Re: Get last generated serial sequence and set it up when explicit value is used - Mailing list pgsql-sql

From David G. Johnston
Subject Re: Get last generated serial sequence and set it up when explicit value is used
Date
Msg-id CAKFQuwZeof4FQOuNH5hu7=ci+x+vAai3JfBQye15Dvs_nB7deg@mail.gmail.com
Whole thread Raw
In response to Get last generated serial sequence and set it up when explicit value is used  (Sebastien FLAESCH <sf@4js.com>)
Responses Re: Get last generated serial sequence and set it up when explicit value is used
List pgsql-sql
On Thu, Nov 19, 2020 at 12:21 PM Sebastien FLAESCH <sf@4js.com> wrote:
Is this ok

subjective; I find it confusing.
 
/ legal

expect that the system will tell you if what you are doing is illegal.
 
/ without risk? (when multiple users insert rows at the same time?)

add a unique index and it will be risk free - and you will see whether the rate of errors is acceptable for you.

Seems if you are going to allow direct inserts though you should test multiple inserted rows at a time, not just single-row.

I'd suggest using the newer GENERATED ALWAYS feature and prohibiting direct specification of values for the sequence-backed column.

David J.

pgsql-sql by date:

Previous
From: Sebastien FLAESCH
Date:
Subject: Get last generated serial sequence and set it up when explicit value is used
Next
From: Sebastien FLAESCH
Date:
Subject: Re: Get last generated serial sequence and set it up when explicit value is used