Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW09H-0000dv-Lt for pgsql-general@arkaria.postgresql.org; Wed, 29 May 2019 15:05:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hW09F-0002IK-P3 for pgsql-general@arkaria.postgresql.org; Wed, 29 May 2019 15:05:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW09F-0002IC-Dj for pgsql-general@lists.postgresql.org; Wed, 29 May 2019 15:05:49 +0000 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW09C-000605-LZ for pgsql-general@lists.postgresql.org; Wed, 29 May 2019 15:05:49 +0000 Received: by mail-ot1-x341.google.com with SMTP id g18so2328131otj.11 for ; Wed, 29 May 2019 08:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=qoCW16PfJfbgsVDLdvzSnA5rh6j6RUId5nGDriaOi6E=; b=aoie2MG+LhTsPUFKvAyUeKBmOES0o8+FTiCurvYEQfZjt5uMpF6v5+P092osChVOgV 5F9tl8H49m4APf1BXE6B64nDmYT74tNM3IkOSKHP8U3/PsQqgWsOL1vNMbC7QgNgEqzC EStqrVgd+FJsSSac8Ve+cLdWPt5PcBn6qpYPJPqLTD8Fr8DcLWFAABnFqT/EqV0Y5iZi KQev0sob+P6JOSPO1iQiFrOKgw8QWjGE/OU/gzkjbLSdPbhQ62x6HWZYGK3siVQWXipq 0cFZJ09zw77KGB5CfB19mF9mceGl8R9fPteUjHQ7dy4nb2WRXoadrHo81ETwzc284VzV neNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=qoCW16PfJfbgsVDLdvzSnA5rh6j6RUId5nGDriaOi6E=; b=i4fT3mgcl2E4kFZ4xt1t5gJdxn9hRo93ai6uQwGufQAlW4hVVeiE6nFYgLrRxEinKj +FcKleUFTPxQh3c+03WOnSnf2H1NCm4yVFc82KJ4BOdNsI9rl6+tzJqFJ5cO0ZezpREb y9pt2j6T1e1DvZuKTrgCezL+hZsWXbzVxRRQBLoGf3Ja43HR/4+5l27NKeM2ZMU//pWb ME8HU6ISo+KUk0M6CBhmYE/NKXhjp3WR6aEIml7orVFlCRyn35m4pD3FJQSJajkEfm/2 pbFQcpBeebdnSipZoNgDYuuA5AF+Rn27t0FcxSB95gw46OQ30GDsV+SHBdeVXoy6OFTt MQ5w== X-Gm-Message-State: APjAAAUd0W+x/kZyimkYy5G4pqWd7L1DwSjirRw/R9CKPrHc/KepNS5q PV+mGcEIDDzgkU3IVN/Z0sbLK9FXwHo= X-Google-Smtp-Source: APXvYqwQp6BAIhiLMfMg+pPq0VsP4QVsCA6QbDG3yFIMy9kMwHbJMpwroWRco1ko8eGMlbz1C1Kn1Q== X-Received: by 2002:a9d:7a93:: with SMTP id l19mr26459130otn.49.1559142338156; Wed, 29 May 2019 08:05:38 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id d204sm6694507oif.3.2019.05.29.08.05.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 08:05:37 -0700 (PDT) Subject: Re: with and trigger To: pgsql-general@lists.postgresql.org References: <1559130758966-0.post@n3.nabble.com> <2487.1559136365@sss.pgh.pa.us> From: Ron Message-ID: <3ae9c51b-2552-a7e9-bbc5-f3d385461f74@gmail.com> Date: Wed, 29 May 2019 10:05:36 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <2487.1559136365@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 5/29/19 8:26 AM, Tom Lane wrote: > PegoraroF10 writes: >> We like to use With to insert, update and return some value to user. But some >> informations of those related tables are not available on that time, is that >> a bug ? > No, see the "WITH Clause" section of the SELECT reference page: > > The primary query and the WITH queries are all (notionally) executed > at the same time. This implies that the effects of a data-modifying > statement in WITH cannot be seen from other parts of the query, other > than by reading its RETURNING output. If two such data-modifying > statements attempt to modify the same row, the results are > unspecified. > > This doesn't explicitly talk about triggers, but I think our attitude > about the case you're discussing is that the results are unspecified. > If a trigger fired in one WITH arm tries to look at the table(s) > modified by other WITH arms, it might or might not see those changes. Are CTEs still optimization fences? https://www.2ndquadrant.com/en/blog/postgresql-ctes-are-optimization-fences/ -- Angular momentum makes the world go 'round.