Re: Why is this SELECT evaluated?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Miles Elam <miles(dot)elam(at)productops(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why is this SELECT evaluated?
Date: 2023-01-28 20:55:57
Message-ID: 9E4FC9FF-D2EF-482C-B35A-93DCD01269B0@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Jan 28, 2023, at 11:29, Miles Elam <miles(dot)elam(at)productops(dot)com> wrote:
> Why does this error result?

While the standard order of operations is to evaluate the WHERE before the SELECT list, it's not guaranteed to result in short-cut execution. In particular, constant folding happens very early in the processing of a query, well before the WHERE clause is evaluated:

xof=# SELECT 1/0 WHERE FALSE;
ERROR: division by zero

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Benedict Holland 2023-01-29 01:44:20 Re: Sequence vs UUID
Previous Message Erik Wienhold 2023-01-28 20:39:31 Re: Sequence vs UUID