Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aWRQA-0006dj-4R for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Feb 2016 16:27:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aWRQ8-0004K5-L1 for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Feb 2016 16:27:12 +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 1aWP5p-0002Nx-Ik for pgsql-bugs@postgresql.org; Thu, 18 Feb 2016 13:58:05 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aWP5m-0007QZ-Ua for pgsql-bugs@postgresql.org; Thu, 18 Feb 2016 13:58:04 +0000 MIME-Version: 1.0 Subject: BUG #13973: Constants resolved in then/else clauses To: pgsql-bugs@postgresql.org From: harry.townsend@eflowglobal.com Date: Thu, 18 Feb 2016 13:57:55 +0000 Message-ID: <20160218135755.2655.72680@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" 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 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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs