PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
execAmi.c File Reference
#include "postgres.h"
#include "access/amapi.h"
#include "access/htup_details.h"
#include "executor/execdebug.h"
#include "executor/nodeAgg.h"
#include "executor/nodeAppend.h"
#include "executor/nodeBitmapAnd.h"
#include "executor/nodeBitmapHeapscan.h"
#include "executor/nodeBitmapIndexscan.h"
#include "executor/nodeBitmapOr.h"
#include "executor/nodeCtescan.h"
#include "executor/nodeCustom.h"
#include "executor/nodeForeignscan.h"
#include "executor/nodeFunctionscan.h"
#include "executor/nodeGather.h"
#include "executor/nodeGroup.h"
#include "executor/nodeHash.h"
#include "executor/nodeHashjoin.h"
#include "executor/nodeIndexonlyscan.h"
#include "executor/nodeIndexscan.h"
#include "executor/nodeLimit.h"
#include "executor/nodeLockRows.h"
#include "executor/nodeMaterial.h"
#include "executor/nodeMergeAppend.h"
#include "executor/nodeMergejoin.h"
#include "executor/nodeModifyTable.h"
#include "executor/nodeNamedtuplestorescan.h"
#include "executor/nodeNestloop.h"
#include "executor/nodeProjectSet.h"
#include "executor/nodeRecursiveunion.h"
#include "executor/nodeResult.h"
#include "executor/nodeSamplescan.h"
#include "executor/nodeSeqscan.h"
#include "executor/nodeSetOp.h"
#include "executor/nodeSort.h"
#include "executor/nodeSubplan.h"
#include "executor/nodeSubqueryscan.h"
#include "executor/nodeTableFuncscan.h"
#include "executor/nodeTidscan.h"
#include "executor/nodeUnique.h"
#include "executor/nodeValuesscan.h"
#include "executor/nodeWindowAgg.h"
#include "executor/nodeWorktablescan.h"
#include "nodes/nodeFuncs.h"
#include "nodes/relation.h"
#include "utils/rel.h"
#include "utils/syscache.h"
Include dependency graph for execAmi.c:

Go to the source code of this file.

Functions

static bool IndexSupportsBackwardScan (Oid indexid)
 
void ExecReScan (PlanState *node)
 
void ExecMarkPos (PlanState *node)
 
void ExecRestrPos (PlanState *node)
 
bool ExecSupportsMarkRestore (Path *pathnode)
 
bool ExecSupportsBackwardScan (Plan *node)
 
bool ExecMaterializesOutput (NodeTag plantype)
 

Function Documentation

void ExecMarkPos ( PlanState node)

Definition at line 309 of file execAmi.c.

References DEBUG2, elog, ExecCustomMarkPos(), ExecIndexMarkPos(), ExecIndexOnlyMarkPos(), ExecMaterialMarkPos(), ExecResultMarkPos(), ExecSortMarkPos(), nodeTag, T_CustomScanState, T_IndexOnlyScanState, T_IndexScanState, T_MaterialState, T_ResultState, and T_SortState.

Referenced by ExecMergeJoin(), and ExecResultMarkPos().

310 {
311  switch (nodeTag(node))
312  {
313  case T_IndexScanState:
315  break;
316 
319  break;
320 
321  case T_CustomScanState:
323  break;
324 
325  case T_MaterialState:
327  break;
328 
329  case T_SortState:
330  ExecSortMarkPos((SortState *) node);
331  break;
332 
333  case T_ResultState:
334  ExecResultMarkPos((ResultState *) node);
335  break;
336 
337  default:
338  /* don't make hard error unless caller asks to restore... */
339  elog(DEBUG2, "unrecognized node type: %d", (int) nodeTag(node));
340  break;
341  }
342 }
void ExecIndexOnlyMarkPos(IndexOnlyScanState *node)
#define DEBUG2
Definition: elog.h:24
void ExecSortMarkPos(SortState *node)
Definition: nodeSort.c:259
void ExecIndexMarkPos(IndexScanState *node)
void ExecCustomMarkPos(CustomScanState *node)
Definition: nodeCustom.c:137
void ExecResultMarkPos(ResultState *node)
Definition: nodeResult.c:143
#define nodeTag(nodeptr)
Definition: nodes.h:514
void ExecMaterialMarkPos(MaterialState *node)
Definition: nodeMaterial.c:267
#define elog
Definition: elog.h:219
bool ExecMaterializesOutput ( NodeTag  plantype)

Definition at line 571 of file execAmi.c.

References T_CteScan, T_FunctionScan, T_Material, T_NamedTuplestoreScan, T_Sort, T_TableFuncScan, and T_WorkTableScan.

Referenced by build_subplan(), cost_subplan(), and match_unsorted_outer().

572 {
573  switch (plantype)
574  {
575  case T_Material:
576  case T_FunctionScan:
577  case T_TableFuncScan:
578  case T_CteScan:
580  case T_WorkTableScan:
581  case T_Sort:
582  return true;
583 
584  default:
585  break;
586  }
587 
588  return false;
589 }
Definition: nodes.h:75
void ExecReScan ( PlanState node)

Definition at line 75 of file execAmi.c.

References bms_free(), PlanState::chgParam, elog, ERROR, ExecReScanAgg(), ExecReScanAppend(), ExecReScanBitmapAnd(), ExecReScanBitmapHeapScan(), ExecReScanBitmapIndexScan(), ExecReScanBitmapOr(), ExecReScanCteScan(), ExecReScanCustomScan(), ExecReScanForeignScan(), ExecReScanFunctionScan(), ExecReScanGather(), ExecReScanGroup(), ExecReScanHash(), ExecReScanHashJoin(), ExecReScanIndexOnlyScan(), ExecReScanIndexScan(), ExecReScanLimit(), ExecReScanLockRows(), ExecReScanMaterial(), ExecReScanMergeAppend(), ExecReScanMergeJoin(), ExecReScanModifyTable(), ExecReScanNamedTuplestoreScan(), ExecReScanNestLoop(), ExecReScanProjectSet(), ExecReScanRecursiveUnion(), ExecReScanResult(), ExecReScanSampleScan(), ExecReScanSeqScan(), ExecReScanSetOp(), ExecReScanSetParamPlan(), ExecReScanSort(), ExecReScanSubqueryScan(), ExecReScanTableFuncScan(), ExecReScanTidScan(), ExecReScanUnique(), ExecReScanValuesScan(), ExecReScanWindowAgg(), ExecReScanWorkTableScan(), Plan::extParam, PlanState::initPlan, InstrEndLoop(), PlanState::instrument, PlanState::lefttree, lfirst, nodeTag, NULL, PlanState::plan, SubPlanState::planstate, PlanState::ps_ExprContext, ReScanExprContext(), PlanState::righttree, splan, PlanState::subPlan, T_AggState, T_AppendState, T_BitmapAndState, T_BitmapHeapScanState, T_BitmapIndexScanState, T_BitmapOrState, T_CteScanState, T_CustomScanState, T_ForeignScanState, T_FunctionScanState, T_GatherState, T_GroupState, T_HashJoinState, T_HashState, T_IndexOnlyScanState, T_IndexScanState, T_LimitState, T_LockRowsState, T_MaterialState, T_MergeAppendState, T_MergeJoinState, T_ModifyTableState, T_NamedTuplestoreScanState, T_NestLoopState, T_ProjectSetState, T_RecursiveUnionState, T_ResultState, T_SampleScanState, T_SeqScanState, T_SetOpState, T_SortState, T_SubqueryScanState, T_TableFuncScanState, T_TidScanState, T_UniqueState, T_ValuesScanState, T_WindowAggState, T_WorkTableScanState, and UpdateChangedParamSet().

Referenced by buildSubPlanHash(), ExecIndexOnlyScan(), ExecIndexScan(), ExecNestLoop(), ExecProcNode(), ExecReScanAgg(), ExecReScanAppend(), ExecReScanBitmapAnd(), ExecReScanBitmapHeapScan(), ExecReScanBitmapOr(), ExecReScanForeignScan(), ExecReScanGather(), ExecReScanGatherMerge(), ExecReScanGroup(), ExecReScanHash(), ExecReScanHashJoin(), ExecReScanLimit(), ExecReScanLockRows(), ExecReScanMaterial(), ExecReScanMergeAppend(), ExecReScanMergeJoin(), ExecReScanNestLoop(), ExecReScanProjectSet(), ExecReScanRecursiveUnion(), ExecReScanResult(), ExecReScanSetOp(), ExecReScanSort(), ExecReScanSubqueryScan(), ExecReScanUnique(), ExecReScanWindowAgg(), ExecScanSubPlan(), ExecutorRewind(), MultiExecBitmapIndexScan(), and MultiExecProcNode().

76 {
77  /* If collecting timing stats, update them */
78  if (node->instrument)
79  InstrEndLoop(node->instrument);
80 
81  /*
82  * If we have changed parameters, propagate that info.
83  *
84  * Note: ExecReScanSetParamPlan() can add bits to node->chgParam,
85  * corresponding to the output param(s) that the InitPlan will update.
86  * Since we make only one pass over the list, that means that an InitPlan
87  * can depend on the output param(s) of a sibling InitPlan only if that
88  * sibling appears earlier in the list. This is workable for now given
89  * the limited ways in which one InitPlan could depend on another, but
90  * eventually we might need to work harder (or else make the planner
91  * enlarge the extParam/allParam sets to include the params of depended-on
92  * InitPlans).
93  */
94  if (node->chgParam != NULL)
95  {
96  ListCell *l;
97 
98  foreach(l, node->initPlan)
99  {
100  SubPlanState *sstate = (SubPlanState *) lfirst(l);
101  PlanState *splan = sstate->planstate;
102 
103  if (splan->plan->extParam != NULL) /* don't care about child
104  * local Params */
105  UpdateChangedParamSet(splan, node->chgParam);
106  if (splan->chgParam != NULL)
107  ExecReScanSetParamPlan(sstate, node);
108  }
109  foreach(l, node->subPlan)
110  {
111  SubPlanState *sstate = (SubPlanState *) lfirst(l);
112  PlanState *splan = sstate->planstate;
113 
114  if (splan->plan->extParam != NULL)
115  UpdateChangedParamSet(splan, node->chgParam);
116  }
117  /* Well. Now set chgParam for left/right trees. */
118  if (node->lefttree != NULL)
120  if (node->righttree != NULL)
122  }
123 
124  /* Call expression callbacks */
125  if (node->ps_ExprContext)
127 
128  /* And do node-type-specific processing */
129  switch (nodeTag(node))
130  {
131  case T_ResultState:
132  ExecReScanResult((ResultState *) node);
133  break;
134 
135  case T_ProjectSetState:
137  break;
138 
139  case T_ModifyTableState:
141  break;
142 
143  case T_AppendState:
144  ExecReScanAppend((AppendState *) node);
145  break;
146 
147  case T_MergeAppendState:
149  break;
150 
153  break;
154 
155  case T_BitmapAndState:
157  break;
158 
159  case T_BitmapOrState:
161  break;
162 
163  case T_SeqScanState:
165  break;
166 
167  case T_SampleScanState:
169  break;
170 
171  case T_GatherState:
172  ExecReScanGather((GatherState *) node);
173  break;
174 
175  case T_IndexScanState:
177  break;
178 
181  break;
182 
185  break;
186 
189  break;
190 
191  case T_TidScanState:
193  break;
194 
195  case T_SubqueryScanState:
197  break;
198 
199  case T_FunctionScanState:
201  break;
202 
205  break;
206 
207  case T_ValuesScanState:
209  break;
210 
211  case T_CteScanState:
213  break;
214 
217  break;
218 
221  break;
222 
223  case T_ForeignScanState:
225  break;
226 
227  case T_CustomScanState:
229  break;
230 
231  case T_NestLoopState:
233  break;
234 
235  case T_MergeJoinState:
237  break;
238 
239  case T_HashJoinState:
241  break;
242 
243  case T_MaterialState:
245  break;
246 
247  case T_SortState:
248  ExecReScanSort((SortState *) node);
249  break;
250 
251  case T_GroupState:
252  ExecReScanGroup((GroupState *) node);
253  break;
254 
255  case T_AggState:
256  ExecReScanAgg((AggState *) node);
257  break;
258 
259  case T_WindowAggState:
261  break;
262 
263  case T_UniqueState:
264  ExecReScanUnique((UniqueState *) node);
265  break;
266 
267  case T_HashState:
268  ExecReScanHash((HashState *) node);
269  break;
270 
271  case T_SetOpState:
272  ExecReScanSetOp((SetOpState *) node);
273  break;
274 
275  case T_LockRowsState:
277  break;
278 
279  case T_LimitState:
280  ExecReScanLimit((LimitState *) node);
281  break;
282 
283  default:
284  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
285  break;
286  }
287 
288  if (node->chgParam != NULL)
289  {
290  bms_free(node->chgParam);
291  node->chgParam = NULL;
292  }
293 }
void ExecReScanBitmapHeapScan(BitmapHeapScanState *node)
void ExecReScanGroup(GroupState *node)
Definition: nodeGroup.c:240
void ExecReScanModifyTable(ModifyTableState *node)
Instrumentation * instrument
Definition: execnodes.h:809
List * initPlan
Definition: execnodes.h:820
void ExecReScanMaterial(MaterialState *node)
Definition: nodeMaterial.c:318
ExprContext * ps_ExprContext
Definition: execnodes.h:833
void ExecReScanLockRows(LockRowsState *node)
Definition: nodeLockRows.c:454
void ExecReScanFunctionScan(FunctionScanState *node)
List * subPlan
Definition: execnodes.h:822
void ExecReScanIndexOnlyScan(IndexOnlyScanState *node)
void ExecReScanLimit(LimitState *node)
Definition: nodeLimit.c:434
void ExecReScanWorkTableScan(WorkTableScanState *node)
struct PlanState * righttree
Definition: execnodes.h:819
void ExecReScanResult(ResultState *node)
Definition: nodeResult.c:260
void ExecReScanSetOp(SetOpState *node)
Definition: nodeSetOp.c:590
void ExecReScanSort(SortState *node)
Definition: nodeSort.c:292
void ExecReScanForeignScan(ForeignScanState *node)
struct PlanState * lefttree
Definition: execnodes.h:818
void InstrEndLoop(Instrumentation *instr)
Definition: instrument.c:114
void ExecReScanHash(HashState *node)
Definition: nodeHash.c:1263
void ExecReScanProjectSet(ProjectSetState *node)
#define ERROR
Definition: elog.h:43
struct PlanState * planstate
Definition: execnodes.h:726
void ExecReScanSetParamPlan(SubPlanState *node, PlanState *parent)
Definition: nodeSubplan.c:1087
void ExecReScanBitmapIndexScan(BitmapIndexScanState *node)
void ExecReScanUnique(UniqueState *node)
Definition: nodeUnique.c:185
void ExecReScanIndexScan(IndexScanState *node)
void ExecReScanMergeAppend(MergeAppendState *node)
void ExecReScanNestLoop(NestLoopState *node)
Definition: nodeNestloop.c:391
static SPIPlanPtr splan
Definition: regress.c:450
Bitmapset * chgParam
Definition: execnodes.h:827
void ExecReScanGather(GatherState *node)
Definition: nodeGather.c:424
void ExecReScanNamedTuplestoreScan(NamedTuplestoreScanState *node)
void ExecReScanAppend(AppendState *node)
Definition: nodeAppend.c:272
void ExecReScanSubqueryScan(SubqueryScanState *node)
Plan * plan
Definition: execnodes.h:803
void ExecReScanBitmapOr(BitmapOrState *node)
Definition: nodeBitmapOr.c:205
void ExecReScanRecursiveUnion(RecursiveUnionState *node)
void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)
Definition: execUtils.c:671
void bms_free(Bitmapset *a)
Definition: bitmapset.c:201
#define NULL
Definition: c.h:229
#define lfirst(lc)
Definition: pg_list.h:106
void ExecReScanBitmapAnd(BitmapAndState *node)
void ExecReScanAgg(AggState *node)
Definition: nodeAgg.c:3883
Bitmapset * extParam
Definition: plannodes.h:152
void ReScanExprContext(ExprContext *econtext)
Definition: execUtils.c:376
#define nodeTag(nodeptr)
Definition: nodes.h:514
void ExecReScanValuesScan(ValuesScanState *node)
void ExecReScanSampleScan(SampleScanState *node)
void ExecReScanCteScan(CteScanState *node)
Definition: nodeCtescan.c:307
void ExecReScanWindowAgg(WindowAggState *node)
#define elog
Definition: elog.h:219
void ExecReScanTidScan(TidScanState *node)
Definition: nodeTidscan.c:458
void ExecReScanMergeJoin(MergeJoinState *node)
void ExecReScanCustomScan(CustomScanState *node)
Definition: nodeCustom.c:130
void ExecReScanTableFuncScan(TableFuncScanState *node)
void ExecReScanSeqScan(SeqScanState *node)
Definition: nodeSeqscan.c:267
void ExecReScanHashJoin(HashJoinState *node)
Definition: nodeHashjoin.c:895
void ExecRestrPos ( PlanState node)

Definition at line 358 of file execAmi.c.

References elog, ERROR, ExecCustomRestrPos(), ExecIndexOnlyRestrPos(), ExecIndexRestrPos(), ExecMaterialRestrPos(), ExecResultRestrPos(), ExecSortRestrPos(), nodeTag, T_CustomScanState, T_IndexOnlyScanState, T_IndexScanState, T_MaterialState, T_ResultState, and T_SortState.

Referenced by ExecMergeJoin(), and ExecResultRestrPos().

359 {
360  switch (nodeTag(node))
361  {
362  case T_IndexScanState:
364  break;
365 
368  break;
369 
370  case T_CustomScanState:
372  break;
373 
374  case T_MaterialState:
376  break;
377 
378  case T_SortState:
379  ExecSortRestrPos((SortState *) node);
380  break;
381 
382  case T_ResultState:
384  break;
385 
386  default:
387  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
388  break;
389  }
390 }
void ExecMaterialRestrPos(MaterialState *node)
Definition: nodeMaterial.c:295
void ExecIndexOnlyRestrPos(IndexOnlyScanState *node)
void ExecResultRestrPos(ResultState *node)
Definition: nodeResult.c:158
void ExecCustomRestrPos(CustomScanState *node)
Definition: nodeCustom.c:148
#define ERROR
Definition: elog.h:43
void ExecSortRestrPos(SortState *node)
Definition: nodeSort.c:277
void ExecIndexRestrPos(IndexScanState *node)
#define nodeTag(nodeptr)
Definition: nodes.h:514
#define elog
Definition: elog.h:219
bool ExecSupportsBackwardScan ( Plan node)

Definition at line 456 of file execAmi.c.

References CUSTOMPATH_SUPPORT_BACKWARD_SCAN, ExecSupportsBackwardScan(), IndexSupportsBackwardScan(), lfirst, nodeTag, NULL, outerPlan, Plan::parallel_aware, T_Append, T_CteScan, T_CustomScan, T_FunctionScan, T_Gather, T_IndexOnlyScan, T_IndexScan, T_Limit, T_LockRows, T_Material, T_Result, T_SampleScan, T_SeqScan, T_Sort, T_SubqueryScan, T_TidScan, and T_ValuesScan.

Referenced by ExecSupportsBackwardScan(), PerformCursorOpen(), SPI_cursor_open_internal(), and standard_planner().

457 {
458  if (node == NULL)
459  return false;
460 
461  /*
462  * Parallel-aware nodes return a subset of the tuples in each worker, and
463  * in general we can't expect to have enough bookkeeping state to know
464  * which ones we returned in this worker as opposed to some other worker.
465  */
466  if (node->parallel_aware)
467  return false;
468 
469  switch (nodeTag(node))
470  {
471  case T_Result:
472  if (outerPlan(node) != NULL)
473  return ExecSupportsBackwardScan(outerPlan(node));
474  else
475  return false;
476 
477  case T_Append:
478  {
479  ListCell *l;
480 
481  foreach(l, ((Append *) node)->appendplans)
482  {
483  if (!ExecSupportsBackwardScan((Plan *) lfirst(l)))
484  return false;
485  }
486  /* need not check tlist because Append doesn't evaluate it */
487  return true;
488  }
489 
490  case T_SampleScan:
491  /* Simplify life for tablesample methods by disallowing this */
492  return false;
493 
494  case T_Gather:
495  return false;
496 
497  case T_IndexScan:
498  return IndexSupportsBackwardScan(((IndexScan *) node)->indexid);
499 
500  case T_IndexOnlyScan:
501  return IndexSupportsBackwardScan(((IndexOnlyScan *) node)->indexid);
502 
503  case T_SubqueryScan:
504  return ExecSupportsBackwardScan(((SubqueryScan *) node)->subplan);
505 
506  case T_CustomScan:
507  {
508  uint32 flags = ((CustomScan *) node)->flags;
509 
511  return true;
512  }
513  return false;
514 
515  case T_SeqScan:
516  case T_TidScan:
517  case T_FunctionScan:
518  case T_ValuesScan:
519  case T_CteScan:
520  case T_Material:
521  case T_Sort:
522  return true;
523 
524  case T_LockRows:
525  case T_Limit:
526  return ExecSupportsBackwardScan(outerPlan(node));
527 
528  default:
529  return false;
530  }
531 }
#define CUSTOMPATH_SUPPORT_BACKWARD_SCAN
Definition: extensible.h:81
Definition: nodes.h:48
Definition: nodes.h:75
static bool IndexSupportsBackwardScan(Oid indexid)
Definition: execAmi.c:538
Definition: nodes.h:45
bool parallel_aware
Definition: plannodes.h:127
unsigned int uint32
Definition: c.h:268
#define outerPlan(node)
Definition: plannodes.h:164
bool ExecSupportsBackwardScan(Plan *node)
Definition: execAmi.c:456
#define NULL
Definition: c.h:229
#define lfirst(lc)
Definition: pg_list.h:106
#define nodeTag(nodeptr)
Definition: nodes.h:514
Definition: nodes.h:80
Definition: nodes.h:85
bool ExecSupportsMarkRestore ( Path pathnode)

Definition at line 400 of file execAmi.c.

References Assert, castNode, CUSTOMPATH_SUPPORT_MARK_RESTORE, ExecSupportsMarkRestore(), CustomPath::flags, IsA, Path::pathtype, subpath(), T_CustomScan, T_IndexOnlyScan, T_IndexScan, T_Material, T_Result, and T_Sort.

Referenced by ExecSupportsMarkRestore(), and final_cost_mergejoin().

401 {
402  /*
403  * For consistency with the routines above, we do not examine the nodeTag
404  * but rather the pathtype, which is the Plan node type the Path would
405  * produce.
406  */
407  switch (pathnode->pathtype)
408  {
409  case T_IndexScan:
410  case T_IndexOnlyScan:
411  case T_Material:
412  case T_Sort:
413  return true;
414 
415  case T_CustomScan:
416  {
417  CustomPath *customPath = castNode(CustomPath, pathnode);
418  if (customPath->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)
419  return true;
420  return false;
421  }
422  case T_Result:
423 
424  /*
425  * Result supports mark/restore iff it has a child plan that does.
426  *
427  * We have to be careful here because there is more than one Path
428  * type that can produce a Result plan node.
429  */
430  if (IsA(pathnode, ProjectionPath))
431  return ExecSupportsMarkRestore(((ProjectionPath *) pathnode)->subpath);
432  else if (IsA(pathnode, MinMaxAggPath))
433  return false; /* childless Result */
434  else
435  {
436  Assert(IsA(pathnode, ResultPath));
437  return false; /* childless Result */
438  }
439 
440  default:
441  break;
442  }
443 
444  return false;
445 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:560
bool ExecSupportsMarkRestore(Path *pathnode)
Definition: execAmi.c:400
#define castNode(_type_, nodeptr)
Definition: nodes.h:578
#define CUSTOMPATH_SUPPORT_MARK_RESTORE
Definition: extensible.h:82
uint32 flags
Definition: relation.h:1158
Definition: nodes.h:75
NodeTag pathtype
Definition: relation.h:950
Definition: nodes.h:45
#define Assert(condition)
Definition: c.h:675
Datum subpath(PG_FUNCTION_ARGS)
Definition: ltree_op.c:234
static bool IndexSupportsBackwardScan ( Oid  indexid)
static

Definition at line 538 of file execAmi.c.

References IndexAmRoutine::amcanbackward, elog, ERROR, GetIndexAmRoutineByAmId(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, pfree(), ReleaseSysCache(), RELOID, result, and SearchSysCache1.

Referenced by ExecSupportsBackwardScan().

539 {
540  bool result;
541  HeapTuple ht_idxrel;
542  Form_pg_class idxrelrec;
543  IndexAmRoutine *amroutine;
544 
545  /* Fetch the pg_class tuple of the index relation */
546  ht_idxrel = SearchSysCache1(RELOID, ObjectIdGetDatum(indexid));
547  if (!HeapTupleIsValid(ht_idxrel))
548  elog(ERROR, "cache lookup failed for relation %u", indexid);
549  idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
550 
551  /* Fetch the index AM's API struct */
552  amroutine = GetIndexAmRoutineByAmId(idxrelrec->relam, false);
553 
554  result = amroutine->amcanbackward;
555 
556  pfree(amroutine);
557  ReleaseSysCache(ht_idxrel);
558 
559  return result;
560 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
void pfree(void *pointer)
Definition: mcxt.c:950
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
IndexAmRoutine * GetIndexAmRoutineByAmId(Oid amoid, bool noerror)
Definition: amapi.c:56
bool amcanbackward
Definition: amapi.h:175
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define elog
Definition: elog.h:219