Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XGqzu-0000zg-Ff for pgsql-sql@arkaria.postgresql.org; Mon, 11 Aug 2014 14:54:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XGqzt-0003l5-AI for pgsql-sql@arkaria.postgresql.org; Mon, 11 Aug 2014 14:54:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XGWkv-0006xA-9O for pgsql-sql@postgresql.org; Sun, 10 Aug 2014 17:18:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XGWkn-00066Y-QM for pgsql-sql@postgresql.org; Sun, 10 Aug 2014 17:18:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s7AHHmY4016831; Sun, 10 Aug 2014 13:17:48 -0400 From: Tom Lane To: pascal+postgres@ensieve.org cc: pgsql-sql@postgresql.org Subject: Re: Update Returning as subquery In-reply-to: References: Comments: In-reply-to pascal+postgres@ensieve.org message dated "Sun, 10 Aug 2014 17:15:20 +0100" Date: Sun, 10 Aug 2014 13:17:48 -0400 Message-ID: <16830.1407691068@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org pascal+postgres@ensieve.org writes: > Why is that forbidden? Isn't the purpose of a RETURNING clause to return values like a SELECT statement would, and shouldn't it therefore be allowed to occur in the same places? An INSERT/UPDATE/DELETE RETURNING can be used as a CTE, not as a sub-select. Sub-selects aren't sufficiently independent of the outer query, eg they might be evaluated more than once, or not at all, or only partially. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql