Re: Crazy query plan. - Mailing list pgsql-bugs

From Craig Ringer
Subject Re: Crazy query plan.
Date
Msg-id 4AFE3E23.1060304@postnewspapers.com.au
Whole thread Raw
In response to Re: Crazy query plan.  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-bugs
Sorry for the multiple replies-to-self, but this seemed worth
specifically noting: the expansion also results in multiple calls to
tuple-returning functions, even functions marked VOLATILE. For example:

CREATE OR REPLACE FUNCTION expandtest(INTEGER) RETURNS test AS $$
DECLARE
    rec test;
BEGIN
    RAISE NOTICE 'expandtest(%)',$1;
    rec.a := $1;
    rec.b := $1;
    rec.c := $1;
    rec.d := $1;
    RETURN rec;
END;
$$ LANGUAGE 'plpgsql' STRICT VOLATILE;


craig=# SELECT (expandtest(1)).*;
NOTICE:  expandtest(1)
NOTICE:  expandtest(1)
NOTICE:  expandtest(1)
NOTICE:  expandtest(1)
 a | b | c | d
---+---+---+---
 1 | 1 | 1 | 1
(1 row)


I don't know if that's intended behaviour or not, but I certainly find
it very _surprising_ behaviour, especially given the otherwise
equivalent translation:

craig=# SELECT t.* FROM expandtest(1) t;
NOTICE:  expandtest(1)
 a | b | c | d
---+---+---+---
 1 | 1 | 1 | 1
(1 row)

pgsql-bugs by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Crazy query plan.
Next
From: Scott Mead
Date:
Subject: Re: BUG #5186: Not install daemon