summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2019-03-01 10:37:57 -0800
committerAndres Freund <andres@anarazel.de>2019-03-01 10:37:57 -0800
commitad0bda5d24ea2bcc72b5e50020e3c79bab10836b (patch)
tree9cf0810b842e4de24460fa8e20b21957a9e8ad01 /src/include
parent6cbdbd9e8d8f2986fde44f2431ed8d0c8fce7f5d (diff)
downloadpostgresql-ad0bda5d24ea2bcc72b5e50020e3c79bab10836b.tar.gz
Store tuples for EvalPlanQual in slots, rather than as HeapTuples.
For the upcoming pluggable table access methods it's quite inconvenient to store tuples as HeapTuples, as that'd require converting tuples from a their native format into HeapTuples. Instead use slots to manage epq tuples. To fit into that scheme, change the foreign data wrapper callback RefetchForeignRow, to store the tuple in a slot. Insist on using the caller provided slot, so it conveniently can be stored in the corresponding EPQ slot. As there is no in core user of RefetchForeignRow, that change was done blindly, but we plan to test that soon. To avoid duplicating that work for row locks, move row locks to just directly use the EPQ slots - it previously temporarily stored tuples in LockRowsState.lr_curtuples, but that doesn't seem beneficial, given we'd possibly end up with a significant number of additional slots. The behaviour of es_epqTupleSet[rti -1] is now checked by es_epqTupleSlot[rti -1] != NULL, as that is distinguishable from a slot containing an empty tuple. Author: Andres Freund, Haribabu Kommi, Ashutosh Bapat Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
Diffstat (limited to 'src/include')
-rw-r--r--src/include/executor/executor.h10
-rw-r--r--src/include/executor/tuptable.h1
-rw-r--r--src/include/foreign/fdwapi.h9
-rw-r--r--src/include/nodes/execnodes.h18
4 files changed, 19 insertions, 19 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 25b72c59e2..9003f2ce58 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -197,16 +197,16 @@ extern ExecAuxRowMark *ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist);
extern TupleTableSlot *EvalPlanQual(EState *estate, EPQState *epqstate,
Relation relation, Index rti, LockTupleMode lockmode,
ItemPointer tid, TransactionId priorXmax);
-extern HeapTuple EvalPlanQualFetch(EState *estate, Relation relation,
+extern bool EvalPlanQualFetch(EState *estate, Relation relation,
LockTupleMode lockmode, LockWaitPolicy wait_policy,
- ItemPointer tid, TransactionId priorXmax);
+ ItemPointer tid, TransactionId priorXmax,
+ TupleTableSlot *slot);
extern void EvalPlanQualInit(EPQState *epqstate, EState *estate,
Plan *subplan, List *auxrowmarks, int epqParam);
extern void EvalPlanQualSetPlan(EPQState *epqstate,
Plan *subplan, List *auxrowmarks);
-extern void EvalPlanQualSetTuple(EPQState *epqstate, Index rti,
- HeapTuple tuple);
-extern HeapTuple EvalPlanQualGetTuple(EPQState *epqstate, Index rti);
+extern TupleTableSlot *EvalPlanQualSlot(EPQState *epqstate,
+ Relation relation, Index rti);
#define EvalPlanQualSetSlot(epqstate, slot) ((epqstate)->origslot = (slot))
extern void EvalPlanQualFetchRowMarks(EPQState *epqstate);
diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h
index 834786620a..b0561ebe29 100644
--- a/src/include/executor/tuptable.h
+++ b/src/include/executor/tuptable.h
@@ -320,6 +320,7 @@ extern void ExecForceStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot,
bool shouldFree);
extern TupleTableSlot *ExecStoreVirtualTuple(TupleTableSlot *slot);
extern TupleTableSlot *ExecStoreAllNullTuple(TupleTableSlot *slot);
+extern void ExecStoreHeapTupleDatum(Datum data, TupleTableSlot *slot);
extern HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree);
extern MinimalTuple ExecFetchSlotMinimalTuple(TupleTableSlot *slot,
bool *shouldFree);
diff --git a/src/include/foreign/fdwapi.h b/src/include/foreign/fdwapi.h
index 01c95c3267..fd91eb633e 100644
--- a/src/include/foreign/fdwapi.h
+++ b/src/include/foreign/fdwapi.h
@@ -121,10 +121,11 @@ typedef void (*EndDirectModify_function) (ForeignScanState *node);
typedef RowMarkType (*GetForeignRowMarkType_function) (RangeTblEntry *rte,
LockClauseStrength strength);
-typedef HeapTuple (*RefetchForeignRow_function) (EState *estate,
- ExecRowMark *erm,
- Datum rowid,
- bool *updated);
+typedef void (*RefetchForeignRow_function) (EState *estate,
+ ExecRowMark *erm,
+ Datum rowid,
+ TupleTableSlot *slot,
+ bool *updated);
typedef void (*ExplainForeignScan_function) (ForeignScanState *node,
struct ExplainState *es);
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 09f8217c80..996d872c56 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -562,15 +562,15 @@ typedef struct EState
/*
* These fields are for re-evaluating plan quals when an updated tuple is
- * substituted in READ COMMITTED mode. es_epqTuple[] contains tuples that
- * scan plan nodes should return instead of whatever they'd normally
- * return, or NULL if nothing to return; es_epqTupleSet[] is true if a
- * particular array entry is valid; and es_epqScanDone[] is state to
- * remember if the tuple has been returned already. Arrays are of size
- * es_range_table_size and are indexed by scan node scanrelid - 1.
+ * substituted in READ COMMITTED mode. es_epqTupleSlot[] contains test
+ * tuples that scan plan nodes should return instead of whatever they'd
+ * normally return, or an empty slot if there is nothing to return; if
+ * es_epqTupleSlot[] is not NULL if a particular array entry is valid; and
+ * es_epqScanDone[] is state to remember if the tuple has been returned
+ * already. Arrays are of size es_range_table_size and are indexed by
+ * scan node scanrelid - 1.
*/
- HeapTuple *es_epqTuple; /* array of EPQ substitute tuples */
- bool *es_epqTupleSet; /* true if EPQ tuple is provided */
+ TupleTableSlot **es_epqTupleSlot; /* array of EPQ substitute tuples */
bool *es_epqScanDone; /* true if EPQ tuple has been fetched */
bool es_use_parallel_mode; /* can we use parallel workers? */
@@ -2257,8 +2257,6 @@ 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;
/* ----------------