Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* extensible.h
|
2016-06-10 00:02:36 +02:00
|
|
|
* Definitions for extensible nodes and custom scans
|
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
*
|
|
|
|
*
|
2017-01-03 19:48:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
* src/include/nodes/extensible.h
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef EXTENSIBLE_H
|
|
|
|
#define EXTENSIBLE_H
|
|
|
|
|
2016-03-29 17:00:18 +02:00
|
|
|
#include "access/parallel.h"
|
|
|
|
#include "commands/explain.h"
|
|
|
|
#include "nodes/execnodes.h"
|
|
|
|
#include "nodes/plannodes.h"
|
|
|
|
#include "nodes/relation.h"
|
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
|
2016-03-29 17:00:18 +02:00
|
|
|
/* maximum length of an extensible node identifier */
|
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
#define EXTNODENAME_MAX_LEN 64
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An extensible node is a new type of node defined by an extension. The
|
|
|
|
* type is always T_ExtensibleNode, while the extnodename identifies the
|
|
|
|
* specific type of node. extnodename can be looked up to find the
|
|
|
|
* ExtensibleNodeMethods for this node type.
|
|
|
|
*/
|
|
|
|
typedef struct ExtensibleNode
|
|
|
|
{
|
|
|
|
NodeTag type;
|
|
|
|
const char *extnodename; /* identifier of ExtensibleNodeMethods */
|
|
|
|
} ExtensibleNode;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* node_size is the size of an extensible node of this type in bytes.
|
|
|
|
*
|
|
|
|
* nodeCopy is a function which performs a deep copy from oldnode to newnode.
|
|
|
|
* It does not need to copy type or extnodename, which are copied by the
|
|
|
|
* core system.
|
|
|
|
*
|
|
|
|
* nodeEqual is a function which performs a deep equality comparison between
|
|
|
|
* a and b and returns true or false accordingly. It does not need to compare
|
|
|
|
* type or extnodename, which are compared by the core system.
|
|
|
|
*
|
|
|
|
* nodeOut is a serialization function for the node type. It should use the
|
|
|
|
* output conventions typical for outfuncs.c. It does not need to output
|
|
|
|
* type or extnodename; the core system handles those.
|
|
|
|
*
|
|
|
|
* nodeRead is a deserialization function for the node type. It does not need
|
|
|
|
* to read type or extnodename; the core system handles those. It should fetch
|
|
|
|
* the next token using pg_strtok() from the current input stream, and then
|
|
|
|
* reconstruct the private fields according to the manner in readfuncs.c.
|
|
|
|
*
|
|
|
|
* All callbacks are mandatory.
|
|
|
|
*/
|
|
|
|
typedef struct ExtensibleNodeMethods
|
|
|
|
{
|
|
|
|
const char *extnodename;
|
|
|
|
Size node_size;
|
2016-06-10 00:02:36 +02:00
|
|
|
void (*nodeCopy) (struct ExtensibleNode *newnode,
|
2017-06-21 20:39:04 +02:00
|
|
|
const struct ExtensibleNode *oldnode);
|
2016-06-10 00:02:36 +02:00
|
|
|
bool (*nodeEqual) (const struct ExtensibleNode *a,
|
2017-06-21 20:39:04 +02:00
|
|
|
const struct ExtensibleNode *b);
|
2016-06-10 00:02:36 +02:00
|
|
|
void (*nodeOut) (struct StringInfoData *str,
|
2017-06-21 20:39:04 +02:00
|
|
|
const struct ExtensibleNode *node);
|
2016-06-10 00:02:36 +02:00
|
|
|
void (*nodeRead) (struct ExtensibleNode *node);
|
Introduce extensible node types.
An extensible node is always tagged T_Extensible, but the extnodename
field identifies it more specifically; it may also include arbitrary
private data. Extensible nodes can be copied, tested for equality,
serialized, and deserialized, but the core system doesn't know
anything about them otherwise. Some extensions may find it useful to
include these nodes in fdw_private or custom_private lists in lieu of
arm-wrestling their data into a format that the core code can
understand.
Along the way, so as not to burden the authors of such extensible
node types too much, expose the functions for writing serialized
tokens, and for serializing and deserializing bitmapsets.
KaiGai Kohei, per a design suggested by me. Reviewed by Andres Freund
and by me, and further edited by me.
2016-02-12 15:31:16 +01:00
|
|
|
} ExtensibleNodeMethods;
|
|
|
|
|
|
|
|
extern void RegisterExtensibleNodeMethods(const ExtensibleNodeMethods *method);
|
|
|
|
extern const ExtensibleNodeMethods *GetExtensibleNodeMethods(const char *name,
|
|
|
|
bool missing_ok);
|
|
|
|
|
2016-03-29 17:00:18 +02:00
|
|
|
/*
|
|
|
|
* Flags for custom paths, indicating what capabilities the resulting scan
|
|
|
|
* will have.
|
|
|
|
*/
|
|
|
|
#define CUSTOMPATH_SUPPORT_BACKWARD_SCAN 0x0001
|
|
|
|
#define CUSTOMPATH_SUPPORT_MARK_RESTORE 0x0002
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Custom path methods. Mostly, we just need to know how to convert a
|
|
|
|
* CustomPath to a plan.
|
|
|
|
*/
|
|
|
|
typedef struct CustomPathMethods
|
|
|
|
{
|
|
|
|
const char *CustomName;
|
|
|
|
|
|
|
|
/* Convert Path to a Plan */
|
|
|
|
struct Plan *(*PlanCustomPath) (PlannerInfo *root,
|
2017-06-21 20:39:04 +02:00
|
|
|
RelOptInfo *rel,
|
|
|
|
struct CustomPath *best_path,
|
|
|
|
List *tlist,
|
|
|
|
List *clauses,
|
|
|
|
List *custom_plans);
|
|
|
|
} CustomPathMethods;
|
2016-03-29 17:00:18 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Custom scan. Here again, there's not much to do: we need to be able to
|
|
|
|
* generate a ScanState corresponding to the scan.
|
|
|
|
*/
|
|
|
|
typedef struct CustomScanMethods
|
|
|
|
{
|
|
|
|
const char *CustomName;
|
|
|
|
|
|
|
|
/* Create execution state (CustomScanState) from a CustomScan plan node */
|
|
|
|
Node *(*CreateCustomScanState) (CustomScan *cscan);
|
|
|
|
} CustomScanMethods;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Execution-time methods for a CustomScanState. This is more complex than
|
|
|
|
* what we need for a custom path or scan.
|
|
|
|
*/
|
|
|
|
typedef struct CustomExecMethods
|
|
|
|
{
|
|
|
|
const char *CustomName;
|
|
|
|
|
|
|
|
/* Required executor methods */
|
|
|
|
void (*BeginCustomScan) (CustomScanState *node,
|
2017-06-21 20:39:04 +02:00
|
|
|
EState *estate,
|
|
|
|
int eflags);
|
2016-03-29 17:00:18 +02:00
|
|
|
TupleTableSlot *(*ExecCustomScan) (CustomScanState *node);
|
|
|
|
void (*EndCustomScan) (CustomScanState *node);
|
|
|
|
void (*ReScanCustomScan) (CustomScanState *node);
|
|
|
|
|
|
|
|
/* Optional methods: needed if mark/restore is supported */
|
|
|
|
void (*MarkPosCustomScan) (CustomScanState *node);
|
|
|
|
void (*RestrPosCustomScan) (CustomScanState *node);
|
|
|
|
|
|
|
|
/* Optional methods: needed if parallel execution is supported */
|
|
|
|
Size (*EstimateDSMCustomScan) (CustomScanState *node,
|
2017-06-21 20:39:04 +02:00
|
|
|
ParallelContext *pcxt);
|
2016-03-29 17:00:18 +02:00
|
|
|
void (*InitializeDSMCustomScan) (CustomScanState *node,
|
2017-06-21 20:39:04 +02:00
|
|
|
ParallelContext *pcxt,
|
|
|
|
void *coordinate);
|
2016-03-29 17:00:18 +02:00
|
|
|
void (*InitializeWorkerCustomScan) (CustomScanState *node,
|
2017-06-21 20:39:04 +02:00
|
|
|
shm_toc *toc,
|
|
|
|
void *coordinate);
|
2017-02-26 09:06:49 +01:00
|
|
|
void (*ShutdownCustomScan) (CustomScanState *node);
|
2016-03-29 17:00:18 +02:00
|
|
|
|
|
|
|
/* Optional: print additional information in EXPLAIN */
|
|
|
|
void (*ExplainCustomScan) (CustomScanState *node,
|
2017-06-21 20:39:04 +02:00
|
|
|
List *ancestors,
|
|
|
|
ExplainState *es);
|
2016-03-29 17:00:18 +02:00
|
|
|
} CustomExecMethods;
|
|
|
|
|
|
|
|
extern void RegisterCustomScanMethods(const CustomScanMethods *methods);
|
|
|
|
extern const CustomScanMethods *GetCustomScanMethods(const char *CustomName,
|
2016-06-10 00:02:36 +02:00
|
|
|
bool missing_ok);
|
2016-03-29 17:00:18 +02:00
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
#endif /* EXTENSIBLE_H */
|