pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?)
2+ messages / 2 participants
[nested] [flat]

* BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?)
@ 2019-01-11 15:25 PG Bug reporting form <noreply@postgresql.org>
  2019-01-11 17:24 ` Re: BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?) Andrew Gierth <andrew@tao11.riddles.org.uk>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2019-01-11 15:25 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: guillaume-postgresql@outters.eu

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;



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?)
  2019-01-11 15:25 BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?) PG Bug reporting form <noreply@postgresql.org>
@ 2019-01-11 17:24 ` Andrew Gierth <andrew@tao11.riddles.org.uk>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew Gierth @ 2019-01-11 17:24 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; guillaume-postgresql@outters.eu

>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> Encapsulating crosstab_hash in a function (to define its return
 PG> type) does not work when the (user-defined) return type owns
 PG> 'dropped' attributes.

Yeah. The code to generate tuples doesn't make any attempt to handle
dropped columns in the result. This is nothing to do with
CreateTupleDescCopy.

I guess this has always been broken; there's no evidence that the code
ever made any attempt to handle it. I'll see about fixing it.

-- 
Andrew (irc:RhodiumToad)




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-01-11 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-11 15:25 BUG #15590: crosstab_hash unable to work with modified types (CreateTupleDescCopy returning dropped attributes?) PG Bug reporting form <noreply@postgresql.org>
2019-01-11 17:24 ` Andrew Gierth <andrew@tao11.riddles.org.uk>

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