Re: custom average window function failure - Mailing list pgsql-general

From Adrian Klaver
Subject Re: custom average window function failure
Date
Msg-id 1156e81d-0903-f453-6751-347d5105d4ca@aklaver.com
Whole thread Raw
In response to Re: custom average window function failure  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: custom average window function failure  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 10/09/2016 08:46 AM, Tom Lane wrote:
> Seb <spluque@gmail.com> writes:
>> Any thoughts on what has changed that is leading to this failure?
>
> Clearly a bug --- the wrong type OIDs are being passed down to
> array_append.  It should be told that it's getting called as
>
>     (angle_vectors[], angle_vectors) returns angle_vectors[]
>
> but what it's actually getting told is
>
>     (vector, angle_vectors) returns vector
>
> which naturally makes it spit up because "vector" isn't an array type.
> I don't think control ever reaches your custom finalfunc at all.

For my edification, why does this work?:

test[5442]=# select version();
                                                            version


-----------------------------------------------------------------------------------------------------------------------------
  PostgreSQL 9.6.0 on i686-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.3 20140627 [gcc-4_8-branch revision 212064], 32-bit
(1 row)

test[5442]=# select avg((random(), random())::angle_vectors);
                  avg
--------------------------------------
  (25.0294036061885,0.892887489473068)
(1 row)

>
> Probably somebody fat-fingered this while refactoring code in the
> aggregate/windowfunction area.  Possibly me :-(.  Haven't found
> exactly where things are going off the rails, but it's clearly
> a PG bug.  Thanks for the report!
>
>             regards, tom lane
>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: custom average window function failure
Next
From: Tom Lane
Date:
Subject: Re: custom average window function failure