Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "P(dot) Christeas" <xrg(at)linux(dot)gr>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Date: 2012-10-17 13:56:22
Message-ID: 19445.1350482182@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"P. Christeas" <xrg(at)linux(dot)gr> writes:
> It has been a fact that the RETURNING clause on an INSERT will return
> multiple rows with the same order as multiple VALUES have been fed.

> eg: INSERT INTO tbl1(code) VALUES ('abc'), ('def'), ('agh')
> RETURNING id, code;

> is expected to yield:
> id | code
> -----------
> 1 | abc
> 2 | def
> 3 | agh

> Clarify that in the documentation, and also write a test case that will
> prevent us from breaking the rule in the future.

I don't believe this is a good idea in the slightest. Yeah, the current
implementation happens to act like that, but there is no reason that we
should make it guaranteed behavior. Nor is a regression test case going
to stop someone from changing it, anyway.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2012-10-17 14:29:08 Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows
Previous Message Merlin Moncure 2012-10-17 13:53:44 Re: [PATCH] Enforce that INSERT...RETURNING preserves the order of multi rows