Re: BUG #8393: "ERROR: failed to locate grouping columns" on grouping by varchar returned from function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: postgresql(at)realityexists(dot)net
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8393: "ERROR: failed to locate grouping columns" on grouping by varchar returned from function
Date: 2013-08-23 21:35:34
Message-ID: 22855.1377293734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

postgresql(at)realityexists(dot)net writes:
> CREATE OR REPLACE FUNCTION test_group_by()
> RETURNS TABLE (my_col varchar(5))
> AS $BODY$
> SELECT 'hello'::varchar(5);
> $BODY$ LANGUAGE sql STABLE;

> SELECT my_col
> FROM test_group_by()
> GROUP BY 1;

> ERROR: failed to locate grouping columns

Fixed in our git tree; thanks for the report!

As a workaround in this particular case, you could just not bother with
marking the specific length of the varchar constant. The function
definition essentially ignores the length, storing only "varchar" as the
result column type, and it's the discrepancy between that and the
declaration of the constant that's tickling the bug.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2013-08-23 22:13:26 Re: BUG #7652: Documentation index lacks functions from "Additional Supplied Modules"
Previous Message Yong Zhang 2013-08-23 20:39:56 Re: BUG #8394: SQL command REINDEX doesn't work