Re: Getting sequence-generated IDs from multiple row insert

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting sequence-generated IDs from multiple row insert
Date: 2014-03-31 21:10:41
Message-ID: 20140331211041.GG54796@crankycanuck.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 31, 2014 at 01:34:04PM -0700, David Johnston wrote:
>
> If order is an implicit property of the source data then you need to
> explicitly encode that order during (or before) import.

Sure, but the problem the OP had I thought was that the RETURNING
clause doesn't guarantee that the rows coming back are in the order
they were inserted. This is just a SQL thing. (I guess you could
ORDER BY the RETURNING clause, right?)

> There are numerous
> ways to implement such but except for extremely simple cases PostgreSQL will
> not do the appropriate thing automatically in the face of concurrency.

It _is_ doing the appropriate thing, though: this is SQL. The rows
aren't ordered unless you tell them to be.

A

--
Andrew Sullivan
ajs(at)crankycanuck(dot)ca

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2014-03-31 21:19:29 Re: Wanted: ALTER TRIGGER ... OWNED BY EXTENSION
Previous Message Scott Marlowe 2014-03-31 21:05:27 Re: Why does "checkpointer" is consumig ~1.2Gb of RAM?