Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aWRnE-00013u-57 for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Feb 2016 16:51:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aWRnD-0003tw-4a for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Feb 2016 16:51:03 +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_SHA384:256) (Exim 4.84) (envelope-from ) id 1aWRnC-0003tq-RU for pgsql-bugs@postgresql.org; Thu, 18 Feb 2016 16:51:02 +0000 Received: from out.smtp-auth.no-ip.com ([8.23.224.60]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aWRn7-0002gH-Qk for pgsql-bugs@postgresql.org; Thu, 18 Feb 2016 16:51:02 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [200.83.202.40]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 1FE8D400E99; Thu, 18 Feb 2016 08:50:54 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 23AF2584; Thu, 18 Feb 2016 17:50:52 +0100 (CET) Date: Thu, 18 Feb 2016 13:50:52 -0300 From: Alvaro Herrera To: harry.townsend@eflowglobal.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #13973: Constants resolved in then/else clauses Message-ID: <20160218165052.GA952091@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160218135755.2655.72680@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org harry.townsend@eflowglobal.com wrote: > The following bug has been logged on the website: > > Bug reference: 13973 > Logged by: Harry Townsend > Email address: harry.townsend@eflowglobal.com > PostgreSQL version: 9.1.20 > Operating system: Windows Server 2008 > Description: > > I attempted to create a safety check in a query using a "case when" > statement such that if the condition evaluated to false, it would return (1 > / 0) in order to nullify the entire transaction. With small conditions, this > works fine. With larger ones, it seems that the constants in the "else" > clause (didn't test for "then" clause) are evaluated before the condition, > causing it to fail every time. If the "else" part requires a column value, > it seems to force the condition to evaluate first though. Can you show a complete example? -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs