Re: [HACKERS] It would be nice if this could be fixed...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: [HACKERS] It would be nice if this could be fixed...
Date: 1999-05-06 16:12:13
Message-ID: 9009.926007133@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> writes:
>> COALESCE sql function causes postgres to CRASH!
>> httpd=> SELECT story.title, COALESCE(story.image, mfr.image)
>> httpd-> FROM story, mfr where story.category= mfr.oid;

> The problem is in combining columns from multiple tables in the
> COALESCE result.

I see at least part of the problem: flatten_tlistentry forgets to
recurse into the 'expr' part of a CaseWhen node. There may be some
other contributing bugs in setrefs.c.

There are dozens of routines in the backend that know all about how to
walk a parse tree --- or, in some cases like this one, not quite all
about how to walk a parse tree :-(. I just spent some time yesterday
teaching a couple of other routines about ArrayRef nodes, for example,
and I've seen way too many other bugs of exactly this ilk.

I think it'd be a good idea to try to centralize this knowledge so that
there are fewer places to change to add a new node type. For example,
a routine that wants to examine all the Var nodes in a tree should be
able to look something like this:

if (IsA(node, Var))
{
process var node;
}
else
standard_tree_walker(node, myself, ...);

rather than having another copy of a bunch of error-prone boilerplate.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-05-06 16:12:33 Hashjoin status report
Previous Message Michael J Davis 1999-05-06 15:20:02 RE: [HACKERS] I'm planning some changes in lmgr...