mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
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
This commit is contained in:
@ -40,7 +40,7 @@ ExecScanFetch(ScanState *node,
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
if (estate->es_epqTuple != NULL)
|
||||
if (estate->es_epqTupleSlot != NULL)
|
||||
{
|
||||
/*
|
||||
* We are inside an EvalPlanQual recheck. Return the test tuple if
|
||||
@ -63,7 +63,7 @@ ExecScanFetch(ScanState *node,
|
||||
ExecClearTuple(slot); /* would not be returned by scan */
|
||||
return slot;
|
||||
}
|
||||
else if (estate->es_epqTupleSet[scanrelid - 1])
|
||||
else if (estate->es_epqTupleSlot[scanrelid - 1] != NULL)
|
||||
{
|
||||
TupleTableSlot *slot = node->ss_ScanTupleSlot;
|
||||
|
||||
@ -73,17 +73,15 @@ ExecScanFetch(ScanState *node,
|
||||
/* Else mark to remember that we shouldn't return more */
|
||||
estate->es_epqScanDone[scanrelid - 1] = true;
|
||||
|
||||
/* Return empty slot if we haven't got a test tuple */
|
||||
if (estate->es_epqTuple[scanrelid - 1] == NULL)
|
||||
return ExecClearTuple(slot);
|
||||
slot = estate->es_epqTupleSlot[scanrelid - 1];
|
||||
|
||||
/* Store test tuple in the plan node's scan slot */
|
||||
ExecForceStoreHeapTuple(estate->es_epqTuple[scanrelid - 1],
|
||||
slot);
|
||||
/* Return empty slot if we haven't got a test tuple */
|
||||
if (TupIsNull(slot))
|
||||
return NULL;
|
||||
|
||||
/* Check if it meets the access-method conditions */
|
||||
if (!(*recheckMtd) (node, slot))
|
||||
ExecClearTuple(slot); /* would not be returned by scan */
|
||||
return ExecClearTuple(slot); /* would not be returned by scan */
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
Reference in New Issue
Block a user