copyObject() ? again

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgreSQL(dot)org>, "Bruce Momjian" <maillist(at)candle(dot)pha(dot)pa(dot)us>
Subject: copyObject() ? again
Date: 1999-03-02 09:15:40
Message-ID: 000101be648d$3e217920$2801007e@cadzone.tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello all,

"Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> writes:
> "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes
> > "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> writes:
> > > AFAIC the relation between objects is not copied correctly
> > > by copyObject() (i.e the same pointers to an object are copied
> > > to different pointers by copyObject()).
> >
> > True, but it seems irrelevant to me --- as Jan Wieck was just pointing
> > out, no code should ever depend on pointer-equality in parse trees or
> > plan trees anyway.
> >
> > > There is a way to maintain the list of (old,new) pairs during
> > > copyObject() operations.
> >
> > I think we'd be better off fixing any places that mistakenly assume
> > pointer compare is sufficient. You didn't say which version you were
> > testing,
>
> My environment is v6.4.2.
> OK,I would test my cases again after the release of 6.5-BETA(v6.4.3?).
>

This time,I tested the following 2 cases under CURRENT(99/02/23)
environment and the result was same.

Those bugs are caused by copyObject().
The removal of pointer comparison solves those bugs ?
I don't think so.
I think copyObject() should be more reliable.

I made a patch on trial (see attached file) .
After applying it,both return proper results.
This patch changes the implementaion of copyObject() entirely.

Comments ?

[Case -1]
create function subsel() returns int4
as
'
declare
k int4;
begin
SELECT 1 AS one into k WHERE 1 IN (SELECT 1);
return k;
end;
'
language 'plpgsql';
select subsel();

pqReadData() -- backend closed the channel unexpectedly.
This probably means the backend terminated abnormally before or
while pr
ocessing the request.
We have lost the connection to the backend, so further processing is
impossible.
Terminating.

[Case-2]

create table grp (key int4);
insert into grp values(2);
insert into grp values(2);
create function grup() returns int4
as
'
declare
k int4;
begin
select key into k from grp
group by key
having count(*) > 1;
return k;
end;
'
language 'plpgsql';
select grup();

The result is

grup
----

(1 row)

Thanks in advance.

Hiroshi Inoue
Inoue(at)tpf(dot)co(dot)jp

Attachment Content-Type Size
copypatch.tar.gz application/x-gzip 11.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Diestelmann 1999-03-02 13:56:42 Postgres under Windows NT
Previous Message The Hermit Hacker 1999-03-02 04:47:17 datetime.c in v6.4.3beta2 ...