pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Matt Magoffin <postgresql.org@msqr.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Properly handling aggregate in nested function call
Date: Tue, 14 Dec 2021 17:51:18 -0500
Message-ID: <559031.1639522278@sss.pgh.pa.us> (raw)
In-Reply-To: <0005FD8A-0FBE-4D53-BBDE-7242A4DC525C@msqr.us>
References: <0005FD8A-0FBE-4D53-BBDE-7242A4DC525C@msqr.us>

Matt Magoffin <postgresql.org@msqr.us> writes:
> Any ideas what I’m doing wrong here? The source is available here:

> https://github.com/SolarNetwork/aggs_for_vecs/blob/9e742cdc32a113268fd3c1f928c8ac724acec9f5/vec_agg_...

Hmm, I think you're abusing the ArrayBuildState API.  In particular,
what guarantees that the astate->dvalues and astate->dnulls arrays
are long enough for what you're stuffing into them?  You should
probably palloc temp arrays right here and then use construct_md_array
directly instead of dealing with an ArrayBuildState.

Also, I wonder what happens when state->vec_counts[i] is zero.
That's seemingly not your problem right now, since the ereport(NOTICE)
is being reached; but it sure looks like trouble waiting to happen.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <559031.1639522278@sss.pgh.pa.us>
Permalink:  ../559031.1639522278@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/559031.1639522278@sss.pgh.pa.us

 · 

reply

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, postgresql.org@msqr.us
  Subject: Re: Properly handling aggregate in nested function call
  In-Reply-To: <559031.1639522278@sss.pgh.pa.us>
  References: <0005FD8A-0FBE-4D53-BBDE-7242A4DC525C@msqr.us> <559031.1639522278@sss.pgh.pa.us>

* 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