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 1gfMhb-0005jk-Tp for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 10:27:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfMha-00087c-GB for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 10:27:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfMhZ-00083f-V9 for pgsql-general@lists.postgresql.org; Fri, 04 Jan 2019 10:27:42 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfMhS-00057f-JE for pgsql-general@postgresql.org; Fri, 04 Jan 2019 10:27:40 +0000 Received: from [192.168.127.1] (port=46209 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gfMhO-0006sx-L5; Fri, 04 Jan 2019 10:27:30 +0000 Received: from [127.0.0.1] (port=20480 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gfMhN-0009Cs-UU; Fri, 04 Jan 2019 10:27:30 +0000 From: Andrew Gierth To: Zexuan Luo Cc: "pgsql-general\@postgresql.org" Subject: Re: Function `set_config` doesn't work in with query? In-Reply-To: (Zexuan Luo's message of "Fri, 4 Jan 2019 17:36:55 +0800") Message-ID: <87a7kgsorn.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 04 Jan 2019 10:27:29 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Zexuan" == Zexuan Luo writes: Zexuan> For instance: Zexuan> ``` Zexuan> with t as ( Zexuan> select set_config('blah', '1', false) Zexuan> ) Zexuan> select current_setting('blah'); A CTE containing a SELECT query which is not referenced anywhere will not be executed, even if it contains volatile functions. (CTEs containing INSERT/UPDATE/DELETE that are not referenced _will_ still be executed.) -- Andrew (irc:RhodiumToad)