How to add a column in a executor node?

From: peter(dot)trautmeier(at)gmx(dot)de
To: pgsql-hackers(at)postgresql(dot)org
Subject: How to add a column in a executor node?
Date: 2007-08-24 15:07:34
Message-ID: 20070824150734.216520@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 usually created 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 TargetEntry after copying the child's targetlist in make_foo(Plan *). (I tested it and seems that some client side code complains about '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 TargetEntry and append it to the tuple. Iterate.

Regards,
Peter

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-08-24 15:08:55 Re: Buildfarm failures MSVC
Previous Message Tom Lane 2007-08-24 14:59:36 Re: Undetected corruption of table files