diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-05-12 14:10:10 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-05-12 14:10:17 -0400 |
| commit | afb9249d06f47d7a6d4a89fea0c3625fe43c5a5d (patch) | |
| tree | e7f62e6cb2b6baefa9489536966229e4af912695 /src/include/nodes/execnodes.h | |
| parent | aa4a0b9571232f44e4b8d9effca3c540e657cebb (diff) | |
| download | postgresql-afb9249d06f47d7a6d4a89fea0c3625fe43c5a5d.tar.gz | |
Add support for doing late row locking in FDWs.
Previously, FDWs could only do "early row locking", that is lock a row as
soon as it's fetched, even though local restriction/join conditions might
discard the row later. This patch adds callbacks that allow FDWs to do
late locking in the same way that it's done for regular tables.
To make use of this feature, an FDW must support the "ctid" column as a
unique row identifier. Currently, since ctid has to be of type TID,
the feature is of limited use, though in principle it could be used by
postgres_fdw. We may eventually allow FDWs to specify another data type
for ctid, which would make it possible for more FDWs to use this feature.
This commit does not modify postgres_fdw to use late locking. We've
tested some prototype code for that, but it's not in committable shape,
and besides it's quite unclear whether it actually makes sense to do late
locking against a remote server. The extra round trips required are likely
to outweigh any benefit from improved concurrency.
Etsuro Fujita, reviewed by Ashutosh Bapat, and hacked up a lot by me
Diffstat (limited to 'src/include/nodes/execnodes.h')
| -rw-r--r-- | src/include/nodes/execnodes.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 9de6d1484e..5ad2cc2358 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -429,8 +429,11 @@ typedef struct EState * parent RTEs, which can be ignored at runtime). Virtual relations such as * subqueries-in-FROM will have an ExecRowMark with relation == NULL. See * PlanRowMark for details about most of the fields. In addition to fields - * directly derived from PlanRowMark, we store curCtid, which is used by the - * WHERE CURRENT OF code. + * directly derived from PlanRowMark, we store an activity flag (to denote + * inactive children of inheritance trees), curCtid, which is used by the + * WHERE CURRENT OF code, and ermExtra, which is available for use by the plan + * node that sources the relation (e.g., for a foreign table the FDW can use + * ermExtra to hold information). * * EState->es_rowMarks is a list of these structs. */ @@ -442,8 +445,11 @@ typedef struct ExecRowMark Index prti; /* parent range table index, if child */ Index rowmarkId; /* unique identifier for resjunk columns */ RowMarkType markType; /* see enum in nodes/plannodes.h */ + LockClauseStrength strength; /* LockingClause's strength, or LCS_NONE */ LockWaitPolicy waitPolicy; /* NOWAIT and SKIP LOCKED */ + bool ermActive; /* is this mark relevant for current tuple? */ ItemPointerData curCtid; /* ctid of currently locked tuple, if any */ + void *ermExtra; /* available for use by relation source node */ } ExecRowMark; /* @@ -1921,6 +1927,8 @@ typedef struct LockRowsState PlanState ps; /* its first field is NodeTag */ List *lr_arowMarks; /* List of ExecAuxRowMarks */ EPQState lr_epqstate; /* for evaluating EvalPlanQual rechecks */ + HeapTuple *lr_curtuples; /* locked tuples (one entry per RT entry) */ + int lr_ntables; /* length of lr_curtuples[] array */ } LockRowsState; /* ---------------- |
