Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id B49441BA1318; Thu, 5 Apr 2012 03:40:08 -0300 (ADT) Received: from mail-qc0-f174.google.com ([209.85.216.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SFgMY-00050e-Hq; Thu, 05 Apr 2012 06:40:08 +0000 Received: by qcro28 with SMTP id o28so658760qcr.19 for ; Wed, 04 Apr 2012 23:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=UXwr5YjG71jrLxLAGeitvYLJifA1/6LncmJNV58xljY=; b=JcrdYJjiWWU0/fH+zws/6cYqsLdhXrcyX6LjovbjIXi3MUjdrTFZd/nD6ODwdxghRm 8CsKy6VTOj2IoMb5y2hrWR1BATA6JTDytC2aiFOSnK+vlbxPtjOj7TsReFnnay+P+A8z n+lRqDUxnbiRgB86l3KY9JhV+GCForiN3YD4TswXm1jTdVn8ZpBGtQt5YafWca/D4w6N 6edOhCKcoSw8ITRC3STh+yQWKakAKP6u3IXr7tn3huMDV/+DMMHqHejZ9I3NweRqdUIy eja0qxq5jigQKD+lq6U1GXw3uZmaReEvT63IbNHVQbTJSrXhZ9jppAIhJ3foL5OxuPN4 x7NQ== MIME-Version: 1.0 Received: by 10.224.98.3 with SMTP id o3mr2400209qan.62.1333607993718; Wed, 04 Apr 2012 23:39:53 -0700 (PDT) Received: by 10.229.65.74 with HTTP; Wed, 4 Apr 2012 23:39:53 -0700 (PDT) In-Reply-To: <25939.1333551641@sss.pgh.pa.us> References: <25939.1333551641@sss.pgh.pa.us> Date: Wed, 4 Apr 2012 23:39:53 -0700 Message-ID: Subject: Re: BUG #6572: The example of SPI_execute is bogus From: Hitoshi Harada To: Tom Lane Cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201204/21 X-Sequence-Number: 32772 On Wed, Apr 4, 2012 at 8:00 AM, Tom Lane wrote: > umi.tanuki@gmail.com writes: >> http://www.postgresql.org/docs/9.1/static/spi-spi-execute.html > >> =3D=3D=3D >> SPI_execute("INSERT INTO foo SELECT * FROM bar", false, 5); >> will allow at most 5 rows to be inserted into the table. >> =3D=3D=3D > >> This seems not true unless I'm missing something. > > Hmm ... that did work as described, until we broke it :-(. =A0This is an > oversight in the 9.0 changes that added separate ModifyTuple nodes to > plan trees. =A0ModifyTuple doesn't return after each updated row, unless > there's a RETURNING clause; which means that the current_tuple_count > check logic in ExecutePlan() no longer stops execution as intended. > > Given the lack of complaints since 9.0, maybe we should not fix this > but just redefine the new behavior as being correct? =A0But it seems > mighty inconsistent that the tuple limit would apply if you have > RETURNING but not when you don't. =A0In any case, the ramifications > are wider than one example in the SPI docs. > > Thoughts? 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? Thanks, --=20 Hitoshi Harada