Re: GROUP BY in CTE causes ELSE in outer query to be prematurely evaluated

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Björn Kautler <Bjoern(at)kautler(dot)net>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Subject: Re: GROUP BY in CTE causes ELSE in outer query to be prematurely evaluated
Date: 2026-03-04 19:32:04
Message-ID: CAKFQuwZT0UaOiV+2h6f42_U_tU34wXH3Gv8BrjF_U168SWS5PQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wednesday, March 4, 2026, Björn Kautler <Bjoern(at)kautler(dot)net> wrote:

>
> What I tried to do was to provoke the division-by-zero error if I happened
> to forget some WHEN branch as this is a bug.
> Is there some safe way to do something like this you are aware of
>

Write a volatile “fail()” plpgsql function, and call it in the else block.
Raise exception there.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2026-03-04 20:37:22 Re: GROUP BY in CTE causes ELSE in outer query to be prematurely evaluated
Previous Message Björn Kautler 2026-03-04 17:44:54 Re: GROUP BY in CTE causes ELSE in outer query to be prematurely evaluated