From 03155dc7649d85ec1ea6fecdaf6e9f8094fa6830 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 21 Jan 1999 22:55:41 +0000 Subject: [PATCH] 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. 1. PL/pgSQL can't execute UTILITY commands. SPI_prepare() doesn't copy(save) the utilityStmt member of Query type nodes,because copyObject() is not implemented for nodes of (Create/Destroy etc)Stmt type. 2. Aggregates in PL/pgSQL cause wrong results. ... It's a list including Aggreg type nodes which exist in TargetList(i.e Aggreg type nodes are common to aggs member list and TargetList). AFAIC the common pointer is not copied to the same pointer by copyObject() function. In my patch I reconstruct aggs member node from new(copied) Agg type node. Is it proper to use set_agg_tlist_references() function to reconstruct aggs member node for Agg type nodes ? Thanks. Hiroshi Inoue Inoue@tpf.co.jp --- src/backend/nodes/copyfuncs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 70910ac4b6..46776ae5e0 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.52 1999/01/21 16:38:36 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.53 1999/01/21 22:55:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -506,7 +506,7 @@ _copyAgg(Agg *from) CopyPlanFields((Plan *) from, (Plan *) newnode); - Node_Copy(from, newnode, aggs); + newnode->aggs = set_agg_tlist_references(newnode); Node_Copy(from, newnode, aggstate); return newnode;