Re: using calculated column in where-clause - Mailing list pgsql-sql

From Tom Lane
Subject Re: using calculated column in where-clause
Date
Msg-id 19546.1213900704@sss.pgh.pa.us
Whole thread Raw
In response to Re: using calculated column in where-clause  ("Fernando Hevia" <fhevia@ip-tel.com.ar>)
List pgsql-sql
"Fernando Hevia" <fhevia@ip-tel.com.ar> writes:
> -- In this case function test is called only once:
> pg=# select res[0] as sum, res[1] as prod, res[2] as dif from
> pg-# (select (test(1, 2))::integer[] as res) t ;

That's an implementation artifact, not a guaranteed behavior;
if you change the example a bit you'll find multiple calls
happening.

(In recent releases you'd actually have a better chance of
not having multiple calls if you'd declared it volatile
instead of immutable.)
        regards, tom lane


pgsql-sql by date:

Previous
From: "Fernando Hevia"
Date:
Subject: Re: using calculated column in where-clause
Next
From: "Peter Kovacs"
Date:
Subject: "TZ"/"tz" not supported