Re: Optimze usage of immutable functions as relation - Mailing list pgsql-hackers

From rmrodriguez@carto.com
Subject Re: Optimze usage of immutable functions as relation
Date
Msg-id CAM6_UM4isP+buRA5sWodO_MUEgutms-KDfnkwGmryc5DGj9XuQ@mail.gmail.com
Whole thread Raw
In response to Re: Optimze usage of immutable functions as relation  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Optimze usage of immutable functions as relation
List pgsql-hackers
Hi,

This commit is breaking some Postgis tests with custom types.

Here is a minimal repro (Postgis not required)

```
-- test custom types
create type t_custom_type AS (
valid bool,
reason varchar,
location varchar
);

create or replace function f_immutable_custom_type(i integer)
returns t_custom_type as
$$ declare oCustom t_custom_type;
begin
select into oCustom true as valid, 'OK' as reason, NULL as location;
return oCustom;
end; $$ language plpgsql immutable;

select valid, reason, location from f_immutable_custom_type(3);

drop function f_immutable_custom_type;
drop type t_custom_type;
```

Expected (PG12):
```
valid | reason | location
-------+--------+----------
 t     | OK     |
(1 row)
```

Instead with master/HEAD (eb57bd9c1d) we are getting:
```
ERROR:  could not find attribute 2 in subquery targetlist
```

Reverting 8613eda50488c27d848f8e8caa493c9d8e1b5271 fixes it,
but I haven't looked into the reason behind the bug.

Regards
--
Raúl Marín Rodríguez
carto.com



pgsql-hackers by date:

Previous
From: Dilip Kumar
Date:
Subject: Re: abort-time portal cleanup
Next
From: Andrew Gierth
Date:
Subject: Excessive disk usage in WindowAgg