fix: Avoid casting to table type when select= and media type handler are used
Previously using a generic mimetype handler failed when any kind of select= was given, because we tried to cast the select-result to the original table type. With this change, this cast is only applied when select=* is given implicitly or explicitly. This is the only case where this makes sense, because this guarantees that correct columns are selected in the correct order for this cast to succeed. Resolves #3160
This commit is contained in:
Vendored
+15
-2
@@ -3550,8 +3550,8 @@ returns "application/vnd.geo2+json" as $$
|
||||
select (jsonb_build_object('type', 'FeatureCollection', 'hello', 'world'))::"application/vnd.geo2+json";
|
||||
$$ language sql;
|
||||
|
||||
drop aggregate if exists test.geo2json_agg(anyelement);
|
||||
create aggregate test.geo2json_agg(anyelement) (
|
||||
drop aggregate if exists test.geo2json_agg_any(anyelement);
|
||||
create aggregate test.geo2json_agg_any(anyelement) (
|
||||
initcond = '[]'
|
||||
, stype = "application/vnd.geo2+json"
|
||||
, sfunc = geo2json_trans
|
||||
@@ -3755,3 +3755,16 @@ create aggregate test.some_agg (some_numbers) (
|
||||
|
||||
create view bad_subquery as
|
||||
select * from projects where id = (select id from projects);
|
||||
|
||||
-- custom generic mimetype
|
||||
create domain "pg/outfunc" as text;
|
||||
create function test.outfunc_trans (state text, next anyelement)
|
||||
returns "pg/outfunc" as $$
|
||||
select (state || next::text || E'\n')::"pg/outfunc";
|
||||
$$ language sql;
|
||||
|
||||
create aggregate test.outfunc_agg (anyelement) (
|
||||
initcond = ''
|
||||
, stype = "pg/outfunc"
|
||||
, sfunc = outfunc_trans
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user