mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Implement an API to let foreign-data wrappers actually be functional.
This commit provides the core code and documentation needed. A contrib module test case will follow shortly. Shigeru Hanada, Jan Urbanski, Heikki Linnakangas
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "miscadmin.h"
|
||||
#include "foreign/fdwapi.h"
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "utils/datum.h"
|
||||
@ -549,6 +550,43 @@ _copyWorkTableScan(WorkTableScan *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyForeignScan
|
||||
*/
|
||||
static ForeignScan *
|
||||
_copyForeignScan(ForeignScan *from)
|
||||
{
|
||||
ForeignScan *newnode = makeNode(ForeignScan);
|
||||
|
||||
/*
|
||||
* copy node superclass fields
|
||||
*/
|
||||
CopyScanFields((Scan *) from, (Scan *) newnode);
|
||||
|
||||
/*
|
||||
* copy remainder of node
|
||||
*/
|
||||
COPY_SCALAR_FIELD(fsSystemCol);
|
||||
COPY_NODE_FIELD(fdwplan);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* _copyFdwPlan
|
||||
*/
|
||||
static FdwPlan *
|
||||
_copyFdwPlan(FdwPlan *from)
|
||||
{
|
||||
FdwPlan *newnode = makeNode(FdwPlan);
|
||||
|
||||
COPY_SCALAR_FIELD(startup_cost);
|
||||
COPY_SCALAR_FIELD(total_cost);
|
||||
COPY_NODE_FIELD(fdw_private);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/*
|
||||
* CopyJoinFields
|
||||
*
|
||||
@ -3839,6 +3877,12 @@ copyObject(void *from)
|
||||
case T_WorkTableScan:
|
||||
retval = _copyWorkTableScan(from);
|
||||
break;
|
||||
case T_ForeignScan:
|
||||
retval = _copyForeignScan(from);
|
||||
break;
|
||||
case T_FdwPlan:
|
||||
retval = _copyFdwPlan(from);
|
||||
break;
|
||||
case T_Join:
|
||||
retval = _copyJoin(from);
|
||||
break;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "lib/stringinfo.h"
|
||||
#include "foreign/fdwapi.h"
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/relation.h"
|
||||
#include "utils/datum.h"
|
||||
@ -537,6 +538,27 @@ _outWorkTableScan(StringInfo str, WorkTableScan *node)
|
||||
WRITE_INT_FIELD(wtParam);
|
||||
}
|
||||
|
||||
static void
|
||||
_outForeignScan(StringInfo str, ForeignScan *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("FOREIGNSCAN");
|
||||
|
||||
_outScanInfo(str, (Scan *) node);
|
||||
|
||||
WRITE_BOOL_FIELD(fsSystemCol);
|
||||
WRITE_NODE_FIELD(fdwplan);
|
||||
}
|
||||
|
||||
static void
|
||||
_outFdwPlan(StringInfo str, FdwPlan *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("FDWPLAN");
|
||||
|
||||
WRITE_FLOAT_FIELD(startup_cost, "%.2f");
|
||||
WRITE_FLOAT_FIELD(total_cost, "%.2f");
|
||||
WRITE_NODE_FIELD(fdw_private);
|
||||
}
|
||||
|
||||
static void
|
||||
_outJoin(StringInfo str, Join *node)
|
||||
{
|
||||
@ -1507,6 +1529,16 @@ _outTidPath(StringInfo str, TidPath *node)
|
||||
WRITE_NODE_FIELD(tidquals);
|
||||
}
|
||||
|
||||
static void
|
||||
_outForeignPath(StringInfo str, ForeignPath *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("FOREIGNPATH");
|
||||
|
||||
_outPathInfo(str, (Path *) node);
|
||||
|
||||
WRITE_NODE_FIELD(fdwplan);
|
||||
}
|
||||
|
||||
static void
|
||||
_outAppendPath(StringInfo str, AppendPath *node)
|
||||
{
|
||||
@ -2672,6 +2704,12 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_WorkTableScan:
|
||||
_outWorkTableScan(str, obj);
|
||||
break;
|
||||
case T_ForeignScan:
|
||||
_outForeignScan(str, obj);
|
||||
break;
|
||||
case T_FdwPlan:
|
||||
_outFdwPlan(str, obj);
|
||||
break;
|
||||
case T_Join:
|
||||
_outJoin(str, obj);
|
||||
break;
|
||||
@ -2877,6 +2915,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_TidPath:
|
||||
_outTidPath(str, obj);
|
||||
break;
|
||||
case T_ForeignPath:
|
||||
_outForeignPath(str, obj);
|
||||
break;
|
||||
case T_AppendPath:
|
||||
_outAppendPath(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user