Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 0985E4BB8EB; Wed, 4 Apr 2012 12:00:56 -0300 (ADT) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SFRhf-0005av-25; Wed, 04 Apr 2012 15:00:55 +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 q34F0gXX025940; Wed, 4 Apr 2012 11:00:42 -0400 (EDT) To: umi.tanuki@gmail.com cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: BUG #6572: The example of SPI_execute is bogus In-reply-to: References: Comments: In-reply-to umi.tanuki@gmail.com message dated "Wed, 04 Apr 2012 01:42:01 -0000" Date: Wed, 04 Apr 2012 11:00:41 -0400 Message-ID: <25939.1333551641@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201204/19 X-Sequence-Number: 32770 umi.tanuki@gmail.com writes: > http://www.postgresql.org/docs/9.1/static/spi-spi-execute.html > === > SPI_execute("INSERT INTO foo SELECT * FROM bar", false, 5); > will allow at most 5 rows to be inserted into the table. > === > This seems not true unless I'm missing something. Hmm ... that did work as described, until we broke it :-(. This is an oversight in the 9.0 changes that added separate ModifyTuple nodes to plan trees. ModifyTuple 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? 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. Thoughts? regards, tom lane