Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id BDF02164F4A; Sun, 15 Apr 2012 13:29:54 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SJSKm-0000Wd-Ki; Sun, 15 Apr 2012 16:29:54 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q3FGTdQF009675; Sun, 15 Apr 2012 12:29:39 -0400 (EDT) To: Robert Haas cc: Hitoshi Harada , pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #6572: The example of SPI_execute is bogus In-reply-to: References: <25939.1333551641@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Fri, 13 Apr 2012 18:53:48 -0400" Date: Sun, 15 Apr 2012 12:29:39 -0400 Message-ID: <9674.1334507379@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/96 X-Sequence-Number: 32847 Robert Haas writes: > On Thu, Apr 5, 2012 at 2:39 AM, Hitoshi Harada wrote: >> On Wed, Apr 4, 2012 at 8:00 AM, Tom Lane wrote: >>> Given the lack of complaints since 9.0, maybe we should not fix this >>> but just redefine the new behavior as being correct? But it seems >>> mighty inconsistent that the tuple limit would apply if you have >>> RETURNING but not when you don't. In any case, the ramifications >>> are wider than one example in the SPI docs. >> To be honest, I was surprised when I found tcount parameter is said to >> be applied to even INSERT. I believe people think that parameter is >> to limit memory consumption when returning tuples thus it'd be applied >> for only SELECT or DML with RETURNING. So I'm +1 for non-fix but >> redefine the behavior. Who wants to limit the number of rows >> processed inside the backend, from SPI? > Yeah. Okay, apparently nobody cares about RETURNING behaving differently from non-RETURNING, so the consensus is to redefine the current behavior as correct. That means what we need is to go through the docs and see what places need to be updated (and, I guess, back-patch the changes to 9.0). I will get to this if nobody else does, but not right away. > I think it would be a good idea for UPDATE and DELETE to expose > a LIMIT option, but I can't really see the virtue in making that > functionality available only through SPI. FWIW, I'm not excited about that. You can get well-defined behavior today from a SELECT/LIMIT drawing from a writable CTE (namely, that the UPDATE/DELETE runs to completion but you only see a subset of its RETURNING result). LIMIT directly on the UPDATE/DELETE would be ill-defined, unless perhaps you want to also invent a way of specifying the order in which rows get selected for update; but I don't want to go there. regards, tom lane