From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: guillaume-postgresql@outters.eu
Subject: BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?)
Date: Fri, 11 Jan 2019 15:25:56 +0000
Message-ID: <15590-c8b3ea603dbece1e@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15590
Logged by: Guillaume Outters
Email address: guillaume-postgresql@outters.eu
PostgreSQL version: 9.6.11
Operating system: FreeBSD 10.2
Description:
Encapsulating crosstab_hash in a function (to define its return type) does
not work when the (user-defined) return type owns 'dropped' attributes.
begin transaction;
create type t as (id int, i int, j int);
create function ctt(text, text)
returns setof t
as '$libdir/tablefunc', 'crosstab_hash' language c;
select * from ctt($$ select * from (values (1, 'j', 123), (1, 'i', 0)) t $$,
$$ select * from (values ('i'), ('j')) t $$);
-- -> Works as expected, returns 3 columns: 1 0 123
alter type t add attribute bla text;
alter type t drop attribute bla;
create table tab of t;
select a.* from pg_class c, pg_attribute a where relname in ('t', 'tab') and
c.oid = a.attrelid;
-- -> Type t shows its 4 columns, with bla having been renamed to
'........pg.dropped.4........' an flagged attisdropped
-- -> Table tab was created with 3 columns (correctly ignored t's dropped
column).
select * from ctt($$ select * from (values (1, 'j', 123), (1, 'i', 0)) t $$,
$$ select * from (values ('i'), ('j')) t $$);
-- -> Crashes with:
-- Error: ERROR: invalid return type
-- Détail : Query-specified return tuple has 4 columns but crosstab
returns 3.
-- SQLState: 42601
-- ErrorCode: 0
rollback;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, guillaume-postgresql@outters.eu
Subject: Re: BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?)
In-Reply-To: <15590-c8b3ea603dbece1e@postgresql.org>
References: <15590-c8b3ea603dbece1e@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox