SQL/MED will have some kinds of planner hooks to support FDW-depending
plan execution. Then, we will need to support user-defined executor nodes.
The proposed SQL/MED has own "executor node hooks" in ForeignTableScan,
  http://wiki.postgresql.org/wiki/SQL/MED#Executor
but I think it will be cleaner to support it in executor level.

The attached patch is an experimental code to do it; Plan struct has
"vtable" field as a set of functions to generate and execute PlanState
nodes. It changes large switch-case blocks in the current executor
into function-pointer calls as like as virtual functions in C++.

Is it worth doing? If we will go to the direction, I'll continue to
research it, like extensibility of Path nodes and EXPLAIN support.

-------- Essence of the patch --------
typedef struct Plan
{
    NodeTag     type;
    PlanVTable *vtable; /* executor procs */
...

struct PlanVTable
{
    ExecInitNode_type   InitNode;
    ExecProcNode_type   ProcNode;
    MultiProcNode_type  MultiProcNode;
    ExecEndNode_type    EndNode;
...

make_seqscan()
{
    node = makeNode(SeqScan);
    node->vtable = &SeqScanVTable;
...

ExecReScan(node)
{
    node->plan->vtable->ReScan(node);
...

--------


-- 
Itagaki Takahiro

Attachment: extensible_execnodes-20101025.patch.gz
Description: GNU Zip compressed data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to