Re: Wrong results from function that selects from vier after "created or replace" - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Wrong results from function that selects from vier after "created or replace"
Date
Msg-id 3401031.1602549490@sss.pgh.pa.us
Whole thread Raw
In response to Wrong results from function that selects from vier after "created or replace"  (Bryn Llewellyn <bryn@yugabyte.com>)
Responses Re: Wrong results from function that selects from vier after "created or replace"
List pgsql-bugs
Bryn Llewellyn <bryn@yugabyte.com> writes:
> The attached self-contained testcase, "pg-bad-invalidation-bug.sql", seems to me definitely to demonstrate a bug.
I'veattached the spooled output as "pg-bad-invalidation-bug.txt" Do you agree that this is a bug? 

No.  You marked the functions as "immutable", and then you broke that
promise by changing what they'd need to output.  The planner had
already inlined the original output value of f1() into the calling
expressions in f2(), on the strength of it being allegedly immutable.
There is no mechanism for undoing that (short of a forced cache flush
or session end), nor should there need to be.

If I mark the functions as either stable or volatile, I see the
desired behavior.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Bryn Llewellyn
Date:
Subject: Wrong results from function that selects from vier after "created or replace"
Next
From: "David G. Johnston"
Date:
Subject: Re: Wrong results from function that selects from vier after "created or replace"