RE: [HACKERS] SPI_prepare() doesn't work well ? - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: [HACKERS] SPI_prepare() doesn't work well ?
Date
Msg-id 000201be44d2$eda09e60$2801007e@cadzone.tpf.co.jp
Whole thread Raw
In response to Re: [HACKERS] SPI_prepare() doesn't work well ?  (jwieck@debis.com (Jan Wieck))
Responses Re: [HACKERS] SPI_prepare() doesn't work well ?  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
> -----Original Message-----
> From: owner-pgsql-hackers@postgreSQL.org
> [mailto:owner-pgsql-hackers@postgreSQL.org]On Behalf Of Jan Wieck
> Sent: Thursday, January 21, 1999 12:57 AM
> To: Hiroshi Inoue
> Cc: pgsql-hackers@postgreSQL.org; mcontzen@dohle.com
> Subject: Re: [HACKERS] SPI_prepare() doesn't work well ?
> 
> 
> Hiroshi Inoue wrote:
> 
> >
> > Hello all,
> >
> > It seems that SPI_prepare() doesn't work well in some cases.
> >
> > Pawel Pierscionek [pawel@astercity.net] reported about the
> > following case 1([SQL] drop table in pgsql).
> > Michael Contzen [mcontzen@dohle.com] reported about the
> > following case 2(PL/PGSQL bug using aggregates).
> > You can find it from pgsql-hackers archive.
> >

[snip]

> >
> > 2. Aggregates in PL/pgSQL cause wrong results.
> >
> >    Is it proper to use set_agg_tlist_references() function to
> >    reconstruct aggs member node for Agg type nodes ?
> 
>     Don't know. It is important, that the copy of  the  tree  has
>     absolutely  NO  references  to  anything outside itself.  The
>     parser/rewrite/planner combo creates all plans in the  actual
>     transactions  memory  context.  So they will get destroyed at
>     transaction end.
>

In my patch set_agg_tlist_refereces() function is appiled for 
copied(new) Agg type nodes,not for original(old) nodes.

This case is a special case of
      How does copyObject() copy multiply referenced objects ?

As to this case,PostgreSQL Executor sets aggno's of Aggreg Nodes 
using aggs member node of Agg type nodes.
As a result,aggno's of the Aggreg nodes contained in TargetList 
are set because they have common pointers.
So multiply referenced Aggreg type nodes must be copied to new 
plan as multiply referenced nodes.

Thanks.

Hiroshi Inoue
Inoue@tpf.co.jp



pgsql-hackers by date:

Previous
From: "D'Arcy" "J.M." Cain
Date:
Subject: Primary key support
Next
From: Vadim Mikheev
Date:
Subject: Re: [HACKERS] Re: Beta test of Postgresql 6.5