Re: expression_tree_walker() and primitive node types

Lists: pgsql-bugs
From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: expression_tree_walker() and primitive node types
Date: 2007-10-12 06:16:43
Message-ID: 1192169803.9420.6.camel@goldbach
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

I wouldn't call this behavior buggy, but I found it somewhat surprising.

expression_tree_walker() assumes that the walker has already been
invoked on the current node (the node that a given recursive call of
expression_tree_walker() has been invoked on). Therefore, calling
expression_tree_walker() on a primitive node type, such as a Var, is a
no-op.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: expression_tree_walker() and primitive node types
Date: 2007-10-12 14:23:17
Message-ID: 26246.1192198997@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Neil Conway <neilc(at)samurai(dot)com> writes:
> I wouldn't call this behavior buggy, but I found it somewhat surprising.
> expression_tree_walker() assumes that the walker has already been
> invoked on the current node (the node that a given recursive call of
> expression_tree_walker() has been invoked on). Therefore, calling
> expression_tree_walker() on a primitive node type, such as a Var, is a
> no-op.

The documented usage method is to call the walker itself at the top
level of recursion. The walker calls expression_tree_walker (after
doing its thing on the node); other code should not call
expression_tree_walker directly.

regards, tom lane