Re: Get last generated serial sequence and set it up when explicit value is used

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Sebastien FLAESCH <sf(at)4js(dot)com>
Cc: pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: Get last generated serial sequence and set it up when explicit value is used
Date: 2020-11-19 20:04:10
Message-ID: CAKFQuwZeof4FQOuNH5hu7=ci+x+vAai3JfBQye15Dvs_nB7deg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Nov 19, 2020 at 12:21 PM Sebastien FLAESCH <sf(at)4js(dot)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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sebastien FLAESCH 2020-11-20 08:19:57 Re: Get last generated serial sequence and set it up when explicit value is used
Previous Message Sebastien FLAESCH 2020-11-19 19:21:39 Get last generated serial sequence and set it up when explicit value is used