How to add a column in a executor node? - Mailing list pgsql-hackers

From peter.trautmeier@gmx.de
Subject How to add a column in a executor node?
Date
Msg-id 20070824150734.216520@gmx.net
Whole thread Raw
List pgsql-hackers
Hi all,

I want to add a column, i.e. an additional TargetEntry, in an executor node named Foo that is placed on top of the
usuallycreated plan. This node Foo will calculate the column which is then used to sort the relation subsequently. If
desired,the column added by Foo is finally removed by a projection node, and might thus be a junk col.
 

(Projection 
that removes bar, 
if desired)||
Sort,
sorts by bar||
Foo,
adds column bar||
Usual
Plan||
...


How do I add an additional TargetEntry in my Foo node? Unfortunately, it does not suffice to simply append the
TargetEntryafter copying the child's targetlist in make_foo(Plan *). (I tested it and seems that some client side code
complainsabout 'advertised_#cols != actual_#cols')
 

How do I compute/evaluate the column? I just see ExecProject which  evaluates the _whole_ targetlist with
ExecTargetList.But I would like to retrieve a tuple from the child node, evaluate my expression, wrap it into a
TargetEntryand append it to the tuple. Iterate.
 

Regards,
Peter


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Buildfarm failures MSVC
Next
From: Tom Lane
Date:
Subject: Re: SQL feature requests