BUG #11661: CASE ELSE is evaluated although condition is true

From: michael(at)aplaypowered(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #11661: CASE ELSE is evaluated although condition is true
Date: 2014-10-13 11:05:42
Message-ID: 20141013110542.25460.3900@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-docs

The following bug has been logged on the website:

Bug reference: 11661
Logged by: Michael Stieler
Email address: michael(at)aplaypowered(dot)com
PostgreSQL version: 9.2.6
Operating system: RHEL
Description:

I am not sure if it is a bug, a lack in documentation or just a
misunderstanding.
This issue refers to a StackOverflow question at
https://stackoverflow.com/questions/26297035/posgtres-case-condition-with-sum-aggregation-evaluates-not-needed-else-part

The following query:
case when sum( column1 ) = 0
then 0
else round( sum( price
* hours
/ column1 ), 2 )
raises a division by zero error, although the condition sum(column1) = 0 is
true. I would expect that the else part would never be evaluated.
Documentation only describes that this happens for immediates.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-10-13 14:04:41 Re: BUG #11660: TSVector not returning partial match on word "out"
Previous Message david.g.levy 2014-10-13 00:47:42 BUG #11660: TSVector not returning partial match on word "out"

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2014-10-13 21:24:00 Re: Huge pages section needs to describe hugetlb_shm_group, memlock limit
Previous Message Ian Barwick 2014-10-09 22:49:28 Re: Documentation for CREATE USER