PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
nodeModifyTable.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeModifyTable.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ModifyTableStateExecInitModifyTable (ModifyTable *node, EState *estate, int eflags)
 
TupleTableSlotExecModifyTable (ModifyTableState *node)
 
void ExecEndModifyTable (ModifyTableState *node)
 
void ExecReScanModifyTable (ModifyTableState *node)
 

Function Documentation

void ExecEndModifyTable ( ModifyTableState node)

Definition at line 2118 of file nodeModifyTable.c.

References FdwRoutine::EndForeignModify, EvalPlanQualEnd(), ExecClearTuple(), ExecCloseIndices(), ExecDropSingleTupleTableSlot(), ExecEndNode(), ExecFreeExprContext(), heap_close, i, ModifyTableState::mt_epqstate, ModifyTableState::mt_nplans, ModifyTableState::mt_num_dispatch, ModifyTableState::mt_num_partitions, ModifyTableState::mt_partition_dispatch_info, ModifyTableState::mt_partition_tuple_slot, ModifyTableState::mt_partitions, ModifyTableState::mt_plans, NoLock, NULL, ModifyTableState::ps, PlanState::ps_ResultTupleSlot, PartitionDispatchData::reldesc, ModifyTableState::resultRelInfo, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_usesFdwDirectModify, PlanState::state, and PartitionDispatchData::tupslot.

Referenced by ExecEndNode().

2119 {
2120  int i;
2121 
2122  /*
2123  * Allow any FDWs to shut down
2124  */
2125  for (i = 0; i < node->mt_nplans; i++)
2126  {
2127  ResultRelInfo *resultRelInfo = node->resultRelInfo + i;
2128 
2129  if (!resultRelInfo->ri_usesFdwDirectModify &&
2130  resultRelInfo->ri_FdwRoutine != NULL &&
2131  resultRelInfo->ri_FdwRoutine->EndForeignModify != NULL)
2132  resultRelInfo->ri_FdwRoutine->EndForeignModify(node->ps.state,
2133  resultRelInfo);
2134  }
2135 
2136  /*
2137  * Close all the partitioned tables, leaf partitions, and their indices
2138  *
2139  * Remember node->mt_partition_dispatch_info[0] corresponds to the root
2140  * partitioned table, which we must not try to close, because it is the
2141  * main target table of the query that will be closed by ExecEndPlan().
2142  * Also, tupslot is NULL for the root partitioned table.
2143  */
2144  for (i = 1; i < node->mt_num_dispatch; i++)
2145  {
2147 
2148  heap_close(pd->reldesc, NoLock);
2150  }
2151  for (i = 0; i < node->mt_num_partitions; i++)
2152  {
2153  ResultRelInfo *resultRelInfo = node->mt_partitions + i;
2154 
2155  ExecCloseIndices(resultRelInfo);
2156  heap_close(resultRelInfo->ri_RelationDesc, NoLock);
2157  }
2158 
2159  /* Release the standalone partition tuple descriptor, if any */
2160  if (node->mt_partition_tuple_slot)
2162 
2163  /*
2164  * Free the exprcontext
2165  */
2166  ExecFreeExprContext(&node->ps);
2167 
2168  /*
2169  * clean out the tuple table
2170  */
2172 
2173  /*
2174  * Terminate EPQ execution if active
2175  */
2176  EvalPlanQualEnd(&node->mt_epqstate);
2177 
2178  /*
2179  * shut down subplans
2180  */
2181  for (i = 0; i < node->mt_nplans; i++)
2182  ExecEndNode(node->mt_plans[i]);
2183 }
Relation ri_RelationDesc
Definition: execnodes.h:335
ResultRelInfo * mt_partitions
Definition: execnodes.h:1175
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:624
ResultRelInfo * resultRelInfo
Definition: execnodes.h:1157
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
#define heap_close(r, l)
Definition: heapam.h:97
EState * state
Definition: execnodes.h:1049
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:685
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:3030
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1077
PlanState ps
Definition: execnodes.h:1150
bool ri_usesFdwDirectModify
Definition: execnodes.h:345
#define NoLock
Definition: lockdefs.h:34
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
Definition: execTuples.c:216
EPQState mt_epqstate
Definition: execnodes.h:1159
struct FdwRoutine * ri_FdwRoutine
Definition: execnodes.h:343
EndForeignModify_function EndForeignModify
Definition: fdwapi.h:199
PlanState ** mt_plans
Definition: execnodes.h:1154
TupleTableSlot * tupslot
Definition: partition.h:66
TupleTableSlot * mt_partition_tuple_slot
Definition: execnodes.h:1178
#define NULL
Definition: c.h:226
int i
struct PartitionDispatchData ** mt_partition_dispatch_info
Definition: execnodes.h:1169
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
Definition: execIndexing.c:224
ModifyTableState* ExecInitModifyTable ( ModifyTable node,
EState estate,
int  eflags 
)

Definition at line 1626 of file nodeModifyTable.c.

References ModifyTable::arbiterIndexes, Assert, AttributeNumberIsValid, FdwRoutine::BeginForeignModify, bms_is_member(), ModifyTable::canSetTag, ModifyTableState::canSetTag, castNode, CheckValidResultRel(), CMD_DELETE, CMD_INSERT, CMD_UPDATE, CreateExprContext(), elog, ModifyTable::epqParam, ERROR, EState::es_auxmodifytables, EState::es_result_relation_info, EState::es_result_relations, EState::es_trig_tuple_slot, EvalPlanQualInit(), EvalPlanQualSetPlan(), ModifyTable::exclRelTlist, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultType(), ExecBuildAuxRowMark(), ExecBuildProjectionInfo(), ExecCheckPlanOutput(), ExecFindJunkAttribute(), ExecFindRowMark(), ExecInitExpr(), ExecInitExtraTupleSlot(), ExecInitJunkFilter(), ExecInitNode(), ExecInitResultTupleSlot(), ExecOpenIndices(), ExecSetSlotDescriptor(), ExecSetupPartitionTupleRouting(), ExecTypeFromTL(), ModifyTable::fdwDirectModifyPlans, ModifyTable::fdwPrivLists, ModifyTableState::fireBSTriggers, i, PlanRowMark::isParent, JunkFilter::jf_junkAttNo, lappend(), lcons(), lfirst, linitial, list_length(), list_nth(), makeNode, map_partition_varattnos(), ModifyTableState::mt_arbiterindexes, ModifyTableState::mt_arowmarks, ModifyTableState::mt_conflproj, ModifyTableState::mt_done, ModifyTableState::mt_epqstate, ModifyTableState::mt_excludedtlist, ModifyTableState::mt_existing, ModifyTableState::mt_nplans, ModifyTableState::mt_num_dispatch, ModifyTableState::mt_num_partitions, ModifyTableState::mt_onconflict, ModifyTableState::mt_partition_dispatch_info, ModifyTableState::mt_partition_tupconv_maps, ModifyTableState::mt_partition_tuple_slot, ModifyTableState::mt_partitions, ModifyTableState::mt_plans, ModifyTableState::mt_whichplan, NIL, ModifyTable::nominalRelation, NULL, ONCONFLICT_NONE, ONCONFLICT_UPDATE, ModifyTable::onConflictAction, ModifyTable::onConflictSet, ModifyTable::onConflictWhere, ModifyTable::operation, ModifyTableState::operation, palloc0(), PlanState::plan, ModifyTable::plans, ModifyTableState::ps, PlanState::ps_ExprContext, PlanState::ps_ResultTupleSlot, WithCheckOption::qual, RelationData::rd_att, RelationData::rd_rel, RELKIND_FOREIGN_TABLE, RELKIND_MATVIEW, RELKIND_PARTITIONED_TABLE, RELKIND_RELATION, TargetEntry::resjunk, ModifyTable::resultRelIndex, ModifyTableState::resultRelInfo, ModifyTable::returningLists, ResultRelInfo::ri_FdwRoutine, ResultRelInfo::ri_IndexRelationDescs, ResultRelInfo::ri_junkFilter, ResultRelInfo::ri_onConflictSetProj, ResultRelInfo::ri_onConflictSetWhere, ResultRelInfo::ri_projectReturning, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_usesFdwDirectModify, ResultRelInfo::ri_WithCheckOptionExprs, ResultRelInfo::ri_WithCheckOptions, ModifyTable::rowMarks, PlanRowMark::rti, PlanState::state, Plan::targetlist, PlanState::targetlist, tupleDesc::tdhasoid, and ModifyTable::withCheckOptionLists.

Referenced by ExecInitNode().

1627 {
1628  ModifyTableState *mtstate;
1629  CmdType operation = node->operation;
1630  int nplans = list_length(node->plans);
1631  ResultRelInfo *saved_resultRelInfo;
1632  ResultRelInfo *resultRelInfo;
1633  TupleDesc tupDesc;
1634  Plan *subplan;
1635  ListCell *l;
1636  int i;
1637  Relation rel;
1638 
1639  /* check for unsupported flags */
1640  Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
1641 
1642  /*
1643  * create state structure
1644  */
1645  mtstate = makeNode(ModifyTableState);
1646  mtstate->ps.plan = (Plan *) node;
1647  mtstate->ps.state = estate;
1648  mtstate->ps.targetlist = NIL; /* not actually used */
1649 
1650  mtstate->operation = operation;
1651  mtstate->canSetTag = node->canSetTag;
1652  mtstate->mt_done = false;
1653 
1654  mtstate->mt_plans = (PlanState **) palloc0(sizeof(PlanState *) * nplans);
1655  mtstate->resultRelInfo = estate->es_result_relations + node->resultRelIndex;
1656  mtstate->mt_arowmarks = (List **) palloc0(sizeof(List *) * nplans);
1657  mtstate->mt_nplans = nplans;
1658  mtstate->mt_onconflict = node->onConflictAction;
1659  mtstate->mt_arbiterindexes = node->arbiterIndexes;
1660 
1661  /* set up epqstate with dummy subplan data for the moment */
1662  EvalPlanQualInit(&mtstate->mt_epqstate, estate, NULL, NIL, node->epqParam);
1663  mtstate->fireBSTriggers = true;
1664 
1665  /*
1666  * call ExecInitNode on each of the plans to be executed and save the
1667  * results into the array "mt_plans". This is also a convenient place to
1668  * verify that the proposed target relations are valid and open their
1669  * indexes for insertion of new index entries. Note we *must* set
1670  * estate->es_result_relation_info correctly while we initialize each
1671  * sub-plan; ExecContextForcesOids depends on that!
1672  */
1673  saved_resultRelInfo = estate->es_result_relation_info;
1674 
1675  resultRelInfo = mtstate->resultRelInfo;
1676  i = 0;
1677  foreach(l, node->plans)
1678  {
1679  subplan = (Plan *) lfirst(l);
1680 
1681  /* Initialize the usesFdwDirectModify flag */
1682  resultRelInfo->ri_usesFdwDirectModify = bms_is_member(i,
1683  node->fdwDirectModifyPlans);
1684 
1685  /*
1686  * Verify result relation is a valid target for the current operation
1687  */
1688  CheckValidResultRel(resultRelInfo->ri_RelationDesc, operation);
1689 
1690  /*
1691  * If there are indices on the result relation, open them and save
1692  * descriptors in the result relation info, so that we can add new
1693  * index entries for the tuples we add/update. We need not do this
1694  * for a DELETE, however, since deletion doesn't affect indexes. Also,
1695  * inside an EvalPlanQual operation, the indexes might be open
1696  * already, since we share the resultrel state with the original
1697  * query.
1698  */
1699  if (resultRelInfo->ri_RelationDesc->rd_rel->relhasindex &&
1700  operation != CMD_DELETE &&
1701  resultRelInfo->ri_IndexRelationDescs == NULL)
1702  ExecOpenIndices(resultRelInfo, mtstate->mt_onconflict != ONCONFLICT_NONE);
1703 
1704  /* Now init the plan for this result rel */
1705  estate->es_result_relation_info = resultRelInfo;
1706  mtstate->mt_plans[i] = ExecInitNode(subplan, estate, eflags);
1707 
1708  /* Also let FDWs init themselves for foreign-table result rels */
1709  if (!resultRelInfo->ri_usesFdwDirectModify &&
1710  resultRelInfo->ri_FdwRoutine != NULL &&
1711  resultRelInfo->ri_FdwRoutine->BeginForeignModify != NULL)
1712  {
1713  List *fdw_private = (List *) list_nth(node->fdwPrivLists, i);
1714 
1715  resultRelInfo->ri_FdwRoutine->BeginForeignModify(mtstate,
1716  resultRelInfo,
1717  fdw_private,
1718  i,
1719  eflags);
1720  }
1721 
1722  resultRelInfo++;
1723  i++;
1724  }
1725 
1726  estate->es_result_relation_info = saved_resultRelInfo;
1727 
1728  /* Build state for INSERT tuple routing */
1729  rel = mtstate->resultRelInfo->ri_RelationDesc;
1730  if (operation == CMD_INSERT &&
1731  rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
1732  {
1733  PartitionDispatch *partition_dispatch_info;
1734  ResultRelInfo *partitions;
1735  TupleConversionMap **partition_tupconv_maps;
1736  TupleTableSlot *partition_tuple_slot;
1737  int num_parted,
1738  num_partitions;
1739 
1741  &partition_dispatch_info,
1742  &partitions,
1743  &partition_tupconv_maps,
1744  &partition_tuple_slot,
1745  &num_parted, &num_partitions);
1746  mtstate->mt_partition_dispatch_info = partition_dispatch_info;
1747  mtstate->mt_num_dispatch = num_parted;
1748  mtstate->mt_partitions = partitions;
1749  mtstate->mt_num_partitions = num_partitions;
1750  mtstate->mt_partition_tupconv_maps = partition_tupconv_maps;
1751  mtstate->mt_partition_tuple_slot = partition_tuple_slot;
1752  }
1753 
1754  /*
1755  * Initialize any WITH CHECK OPTION constraints if needed.
1756  */
1757  resultRelInfo = mtstate->resultRelInfo;
1758  i = 0;
1759  foreach(l, node->withCheckOptionLists)
1760  {
1761  List *wcoList = (List *) lfirst(l);
1762  List *wcoExprs = NIL;
1763  ListCell *ll;
1764 
1765  foreach(ll, wcoList)
1766  {
1767  WithCheckOption *wco = (WithCheckOption *) lfirst(ll);
1768  ExprState *wcoExpr = ExecInitExpr((Expr *) wco->qual,
1769  mtstate->mt_plans[i]);
1770 
1771  wcoExprs = lappend(wcoExprs, wcoExpr);
1772  }
1773 
1774  resultRelInfo->ri_WithCheckOptions = wcoList;
1775  resultRelInfo->ri_WithCheckOptionExprs = wcoExprs;
1776  resultRelInfo++;
1777  i++;
1778  }
1779 
1780  /*
1781  * Build WITH CHECK OPTION constraints for each leaf partition rel.
1782  * Note that we didn't build the withCheckOptionList for each partition
1783  * within the planner, but simple translation of the varattnos for each
1784  * partition will suffice. This only occurs for the INSERT case;
1785  * UPDATE/DELETE cases are handled above.
1786  */
1787  if (node->withCheckOptionLists != NIL && mtstate->mt_num_partitions > 0)
1788  {
1789  List *wcoList;
1790 
1791  Assert(operation == CMD_INSERT);
1792  resultRelInfo = mtstate->mt_partitions;
1793  wcoList = linitial(node->withCheckOptionLists);
1794  for (i = 0; i < mtstate->mt_num_partitions; i++)
1795  {
1796  Relation partrel = resultRelInfo->ri_RelationDesc;
1797  List *mapped_wcoList;
1798  List *wcoExprs = NIL;
1799  ListCell *ll;
1800 
1801  /* varno = node->nominalRelation */
1802  mapped_wcoList = map_partition_varattnos(wcoList,
1803  node->nominalRelation,
1804  partrel, rel);
1805  foreach(ll, mapped_wcoList)
1806  {
1807  WithCheckOption *wco = (WithCheckOption *) lfirst(ll);
1808  ExprState *wcoExpr = ExecInitExpr((Expr *) wco->qual,
1809  mtstate->mt_plans[i]);
1810 
1811  wcoExprs = lappend(wcoExprs, wcoExpr);
1812  }
1813 
1814  resultRelInfo->ri_WithCheckOptions = mapped_wcoList;
1815  resultRelInfo->ri_WithCheckOptionExprs = wcoExprs;
1816  resultRelInfo++;
1817  }
1818  }
1819 
1820  /*
1821  * Initialize RETURNING projections if needed.
1822  */
1823  if (node->returningLists)
1824  {
1825  TupleTableSlot *slot;
1826  ExprContext *econtext;
1827  List *returningList;
1828 
1829  /*
1830  * Initialize result tuple slot and assign its rowtype using the first
1831  * RETURNING list. We assume the rest will look the same.
1832  */
1833  tupDesc = ExecTypeFromTL((List *) linitial(node->returningLists),
1834  false);
1835 
1836  /* Set up a slot for the output of the RETURNING projection(s) */
1837  ExecInitResultTupleSlot(estate, &mtstate->ps);
1838  ExecAssignResultType(&mtstate->ps, tupDesc);
1839  slot = mtstate->ps.ps_ResultTupleSlot;
1840 
1841  /* Need an econtext too */
1842  econtext = CreateExprContext(estate);
1843  mtstate->ps.ps_ExprContext = econtext;
1844 
1845  /*
1846  * Build a projection for each result rel.
1847  */
1848  resultRelInfo = mtstate->resultRelInfo;
1849  foreach(l, node->returningLists)
1850  {
1851  List *rlist = (List *) lfirst(l);
1852  List *rliststate;
1853 
1854  rliststate = (List *) ExecInitExpr((Expr *) rlist, &mtstate->ps);
1855  resultRelInfo->ri_projectReturning =
1856  ExecBuildProjectionInfo(rliststate, econtext, slot,
1857  resultRelInfo->ri_RelationDesc->rd_att);
1858  resultRelInfo++;
1859  }
1860 
1861  /*
1862  * Build a projection for each leaf partition rel. Note that we
1863  * didn't build the returningList for each partition within the
1864  * planner, but simple translation of the varattnos for each partition
1865  * will suffice. This only occurs for the INSERT case; UPDATE/DELETE
1866  * are handled above.
1867  */
1868  resultRelInfo = mtstate->mt_partitions;
1869  returningList = linitial(node->returningLists);
1870  for (i = 0; i < mtstate->mt_num_partitions; i++)
1871  {
1872  Relation partrel = resultRelInfo->ri_RelationDesc;
1873  List *rlist,
1874  *rliststate;
1875 
1876  /* varno = node->nominalRelation */
1877  rlist = map_partition_varattnos(returningList,
1878  node->nominalRelation,
1879  partrel, rel);
1880  rliststate = (List *) ExecInitExpr((Expr *) rlist, &mtstate->ps);
1881  resultRelInfo->ri_projectReturning =
1882  ExecBuildProjectionInfo(rliststate, econtext, slot,
1883  resultRelInfo->ri_RelationDesc->rd_att);
1884  resultRelInfo++;
1885  }
1886  }
1887  else
1888  {
1889  /*
1890  * We still must construct a dummy result tuple type, because InitPlan
1891  * expects one (maybe should change that?).
1892  */
1893  tupDesc = ExecTypeFromTL(NIL, false);
1894  ExecInitResultTupleSlot(estate, &mtstate->ps);
1895  ExecAssignResultType(&mtstate->ps, tupDesc);
1896 
1897  mtstate->ps.ps_ExprContext = NULL;
1898  }
1899 
1900  /*
1901  * If needed, Initialize target list, projection and qual for ON CONFLICT
1902  * DO UPDATE.
1903  */
1904  resultRelInfo = mtstate->resultRelInfo;
1905  if (node->onConflictAction == ONCONFLICT_UPDATE)
1906  {
1907  ExprContext *econtext;
1908  ExprState *setexpr;
1909  TupleDesc tupDesc;
1910 
1911  /* insert may only have one plan, inheritance is not expanded */
1912  Assert(nplans == 1);
1913 
1914  /* already exists if created by RETURNING processing above */
1915  if (mtstate->ps.ps_ExprContext == NULL)
1916  ExecAssignExprContext(estate, &mtstate->ps);
1917 
1918  econtext = mtstate->ps.ps_ExprContext;
1919 
1920  /* initialize slot for the existing tuple */
1921  mtstate->mt_existing = ExecInitExtraTupleSlot(mtstate->ps.state);
1923  resultRelInfo->ri_RelationDesc->rd_att);
1924 
1925  /* carried forward solely for the benefit of explain */
1926  mtstate->mt_excludedtlist = node->exclRelTlist;
1927 
1928  /* create target slot for UPDATE SET projection */
1929  tupDesc = ExecTypeFromTL((List *) node->onConflictSet,
1930  resultRelInfo->ri_RelationDesc->rd_rel->relhasoids);
1931  mtstate->mt_conflproj = ExecInitExtraTupleSlot(mtstate->ps.state);
1932  ExecSetSlotDescriptor(mtstate->mt_conflproj, tupDesc);
1933 
1934  /* build UPDATE SET expression and projection state */
1935  setexpr = ExecInitExpr((Expr *) node->onConflictSet, &mtstate->ps);
1936  resultRelInfo->ri_onConflictSetProj =
1937  ExecBuildProjectionInfo((List *) setexpr, econtext,
1938  mtstate->mt_conflproj,
1939  resultRelInfo->ri_RelationDesc->rd_att);
1940 
1941  /* build DO UPDATE WHERE clause expression */
1942  if (node->onConflictWhere)
1943  {
1944  ExprState *qualexpr;
1945 
1946  qualexpr = ExecInitExpr((Expr *) node->onConflictWhere,
1947  &mtstate->ps);
1948 
1949  resultRelInfo->ri_onConflictSetWhere = (List *) qualexpr;
1950  }
1951  }
1952 
1953  /*
1954  * If we have any secondary relations in an UPDATE or DELETE, they need to
1955  * be treated like non-locked relations in SELECT FOR UPDATE, ie, the
1956  * EvalPlanQual mechanism needs to be told about them. Locate the
1957  * relevant ExecRowMarks.
1958  */
1959  foreach(l, node->rowMarks)
1960  {
1962  ExecRowMark *erm;
1963 
1964  /* ignore "parent" rowmarks; they are irrelevant at runtime */
1965  if (rc->isParent)
1966  continue;
1967 
1968  /* find ExecRowMark (same for all subplans) */
1969  erm = ExecFindRowMark(estate, rc->rti, false);
1970 
1971  /* build ExecAuxRowMark for each subplan */
1972  for (i = 0; i < nplans; i++)
1973  {
1974  ExecAuxRowMark *aerm;
1975 
1976  subplan = mtstate->mt_plans[i]->plan;
1977  aerm = ExecBuildAuxRowMark(erm, subplan->targetlist);
1978  mtstate->mt_arowmarks[i] = lappend(mtstate->mt_arowmarks[i], aerm);
1979  }
1980  }
1981 
1982  /* select first subplan */
1983  mtstate->mt_whichplan = 0;
1984  subplan = (Plan *) linitial(node->plans);
1985  EvalPlanQualSetPlan(&mtstate->mt_epqstate, subplan,
1986  mtstate->mt_arowmarks[0]);
1987 
1988  /*
1989  * Initialize the junk filter(s) if needed. INSERT queries need a filter
1990  * if there are any junk attrs in the tlist. UPDATE and DELETE always
1991  * need a filter, since there's always a junk 'ctid' or 'wholerow'
1992  * attribute present --- no need to look first.
1993  *
1994  * If there are multiple result relations, each one needs its own junk
1995  * filter. Note multiple rels are only possible for UPDATE/DELETE, so we
1996  * can't be fooled by some needing a filter and some not.
1997  *
1998  * This section of code is also a convenient place to verify that the
1999  * output of an INSERT or UPDATE matches the target table(s).
2000  */
2001  {
2002  bool junk_filter_needed = false;
2003 
2004  switch (operation)
2005  {
2006  case CMD_INSERT:
2007  foreach(l, subplan->targetlist)
2008  {
2009  TargetEntry *tle = (TargetEntry *) lfirst(l);
2010 
2011  if (tle->resjunk)
2012  {
2013  junk_filter_needed = true;
2014  break;
2015  }
2016  }
2017  break;
2018  case CMD_UPDATE:
2019  case CMD_DELETE:
2020  junk_filter_needed = true;
2021  break;
2022  default:
2023  elog(ERROR, "unknown operation");
2024  break;
2025  }
2026 
2027  if (junk_filter_needed)
2028  {
2029  resultRelInfo = mtstate->resultRelInfo;
2030  for (i = 0; i < nplans; i++)
2031  {
2032  JunkFilter *j;
2033 
2034  subplan = mtstate->mt_plans[i]->plan;
2035  if (operation == CMD_INSERT || operation == CMD_UPDATE)
2036  ExecCheckPlanOutput(resultRelInfo->ri_RelationDesc,
2037  subplan->targetlist);
2038 
2039  j = ExecInitJunkFilter(subplan->targetlist,
2040  resultRelInfo->ri_RelationDesc->rd_att->tdhasoid,
2041  ExecInitExtraTupleSlot(estate));
2042 
2043  if (operation == CMD_UPDATE || operation == CMD_DELETE)
2044  {
2045  /* For UPDATE/DELETE, find the appropriate junk attr now */
2046  char relkind;
2047 
2048  relkind = resultRelInfo->ri_RelationDesc->rd_rel->relkind;
2049  if (relkind == RELKIND_RELATION ||
2050  relkind == RELKIND_MATVIEW ||
2051  relkind == RELKIND_PARTITIONED_TABLE)
2052  {
2053  j->jf_junkAttNo = ExecFindJunkAttribute(j, "ctid");
2055  elog(ERROR, "could not find junk ctid column");
2056  }
2057  else if (relkind == RELKIND_FOREIGN_TABLE)
2058  {
2059  /*
2060  * When there is an AFTER trigger, there should be a
2061  * wholerow attribute.
2062  */
2063  j->jf_junkAttNo = ExecFindJunkAttribute(j, "wholerow");
2064  }
2065  else
2066  {
2067  j->jf_junkAttNo = ExecFindJunkAttribute(j, "wholerow");
2069  elog(ERROR, "could not find junk wholerow column");
2070  }
2071  }
2072 
2073  resultRelInfo->ri_junkFilter = j;
2074  resultRelInfo++;
2075  }
2076  }
2077  else
2078  {
2079  if (operation == CMD_INSERT)
2081  subplan->targetlist);
2082  }
2083  }
2084 
2085  /*
2086  * Set up a tuple table slot for use for trigger output tuples. In a plan
2087  * containing multiple ModifyTable nodes, all can share one such slot, so
2088  * we keep it in the estate.
2089  */
2090  if (estate->es_trig_tuple_slot == NULL)
2091  estate->es_trig_tuple_slot = ExecInitExtraTupleSlot(estate);
2092 
2093  /*
2094  * Lastly, if this is not the primary (canSetTag) ModifyTable node, add it
2095  * to estate->es_auxmodifytables so that it will be run to completion by
2096  * ExecPostprocessPlan. (It'd actually work fine to add the primary
2097  * ModifyTable node too, but there's no need.) Note the use of lcons not
2098  * lappend: we need later-initialized ModifyTable nodes to be shut down
2099  * before earlier ones. This ensures that we don't throw away RETURNING
2100  * rows that need to be seen by a later CTE subplan.
2101  */
2102  if (!mtstate->canSetTag)
2103  estate->es_auxmodifytables = lcons(mtstate,
2104  estate->es_auxmodifytables);
2105 
2106  return mtstate;
2107 }
AttrNumber jf_junkAttNo
Definition: execnodes.h:297
#define NIL
Definition: pg_list.h:69
JunkFilter * ri_junkFilter
Definition: execnodes.h:349
List * arbiterIndexes
Definition: plannodes.h:215
Relation ri_RelationDesc
Definition: execnodes.h:335
Bitmapset * fdwDirectModifyPlans
Definition: plannodes.h:211
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate)
Definition: execTuples.c:852
Index nominalRelation
Definition: plannodes.h:204
bool tdhasoid
Definition: tupdesc.h:79
ProjectionInfo * ri_onConflictSetProj
Definition: execnodes.h:351
ResultRelInfo * mt_partitions
Definition: execnodes.h:1175
List * withCheckOptionLists
Definition: plannodes.h:208
#define castNode(_type_, nodeptr)
Definition: nodes.h:577
int resultRelIndex
Definition: plannodes.h:206
ResultRelInfo * resultRelInfo
Definition: execnodes.h:1157
AttrNumber ExecFindJunkAttribute(JunkFilter *junkfilter, const char *attrName)
Definition: execJunk.c:209
ExprContext * ps_ExprContext
Definition: execnodes.h:1078
TupleTableSlot * mt_conflproj
Definition: execnodes.h:1167
#define RELKIND_MATVIEW
Definition: pg_class.h:167
bool canSetTag
Definition: plannodes.h:203
CmdType operation
Definition: execnodes.h:1151
List * targetlist
Definition: execnodes.h:1061
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition: execMain.c:2638
EState * state
Definition: execnodes.h:1049
Form_pg_class rd_rel
Definition: rel.h:113
List * plans
Definition: plannodes.h:207
void ExecAssignResultType(PlanState *planstate, TupleDesc tupDesc)
Definition: execUtils.c:418
List * onConflictSet
Definition: plannodes.h:216
void ExecOpenIndices(ResultRelInfo *resultRelInfo, bool speculative)
Definition: execIndexing.c:149
TupleTableSlot * mt_existing
Definition: execnodes.h:1164
List * ri_WithCheckOptionExprs
Definition: execnodes.h:347
OnConflictAction mt_onconflict
Definition: execnodes.h:1161
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1077
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execQual.c:4266
List * rowMarks
Definition: plannodes.h:212
void ExecSetupPartitionTupleRouting(Relation rel, PartitionDispatch **pd, ResultRelInfo **partitions, TupleConversionMap ***tup_conv_maps, TupleTableSlot **partition_tuple_slot, int *num_parted, int *num_partitions)
Definition: execMain.c:3099
bool resjunk
Definition: primnodes.h:1337
#define linitial(l)
Definition: pg_list.h:110
#define ERROR
Definition: elog.h:43
PlanState ps
Definition: execnodes.h:1150
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
bool ri_usesFdwDirectModify
Definition: execnodes.h:345
#define EXEC_FLAG_BACKWARD
Definition: executor.h:60
void * list_nth(const List *list, int n)
Definition: list.c:410
ResultRelInfo * es_result_relations
Definition: execnodes.h:382
JunkFilter * ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
Definition: execJunk.c:61
List * fdwPrivLists
Definition: plannodes.h:210
EPQState mt_epqstate
Definition: execnodes.h:1159
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, TupleDesc inputDesc)
Definition: execUtils.c:482
ProjectionInfo * ri_projectReturning
Definition: execnodes.h:350
void CheckValidResultRel(Relation resultRel, CmdType operation)
Definition: execMain.c:1021
struct FdwRoutine * ri_FdwRoutine
Definition: execnodes.h:343
#define RELKIND_FOREIGN_TABLE
Definition: pg_class.h:166
TupleTableSlot * es_trig_tuple_slot
Definition: execnodes.h:388
TupleDesc ExecTypeFromTL(List *targetList, bool hasoid)
Definition: execTuples.c:888
List * lappend(List *list, void *datum)
Definition: list.c:128
PlanState ** mt_plans
Definition: execnodes.h:1154
#define AttributeNumberIsValid(attributeNumber)
Definition: attnum.h:34
#define RELKIND_PARTITIONED_TABLE
Definition: pg_class.h:168
void * palloc0(Size size)
Definition: mcxt.c:920
List * es_auxmodifytables
Definition: execnodes.h:414
void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)
Definition: execTuples.c:247
List * ri_WithCheckOptions
Definition: execnodes.h:346
TupleTableSlot * mt_partition_tuple_slot
Definition: execnodes.h:1178
TupleDesc rd_att
Definition: rel.h:114
void EvalPlanQualInit(EPQState *epqstate, EState *estate, Plan *subplan, List *auxrowmarks, int epqParam)
Definition: execMain.c:2619
Plan * plan
Definition: execnodes.h:1047
List * ri_onConflictSetWhere
Definition: execnodes.h:352
Index rti
Definition: plannodes.h:940
List * lcons(void *datum, List *list)
Definition: list.c:259
#define makeNode(_type_)
Definition: nodes.h:556
static void ExecCheckPlanOutput(Relation resultRel, List *targetList)
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
#define lfirst(lc)
Definition: pg_list.h:106
#define EXEC_FLAG_MARK
Definition: executor.h:61
OnConflictAction onConflictAction
Definition: plannodes.h:214
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:408
static int list_length(const List *l)
Definition: pg_list.h:89
List * targetlist
Definition: plannodes.h:129
List * mt_arbiterindexes
Definition: execnodes.h:1162
List * mt_excludedtlist
Definition: execnodes.h:1165
CmdType operation
Definition: plannodes.h:202
int i
struct PartitionDispatchData ** mt_partition_dispatch_info
Definition: execnodes.h:1169
ExprContext * CreateExprContext(EState *estate)
Definition: execUtils.c:208
List * returningLists
Definition: plannodes.h:209
bool isParent
Definition: plannodes.h:947
TupleConversionMap ** mt_partition_tupconv_maps
Definition: execnodes.h:1176
#define elog
Definition: elog.h:219
BeginForeignModify_function BeginForeignModify
Definition: fdwapi.h:195
#define RELKIND_RELATION
Definition: pg_class.h:160
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:137
Definition: pg_list.h:45
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:419
CmdType
Definition: nodes.h:641
RelationPtr ri_IndexRelationDescs
Definition: execnodes.h:337
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition: execMain.c:2232
List * exclRelTlist
Definition: plannodes.h:219
List ** mt_arowmarks
Definition: execnodes.h:1158
int epqParam
Definition: plannodes.h:213
List * map_partition_varattnos(List *expr, int target_varno, Relation partrel, Relation parent)
Definition: partition.c:935
Node * onConflictWhere
Definition: plannodes.h:217
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition: execMain.c:2208
ResultRelInfo * es_result_relation_info
Definition: execnodes.h:384
TupleTableSlot* ExecModifyTable ( ModifyTableState node)

Definition at line 1386 of file nodeModifyTable.c.

References Assert, AttributeNumberIsValid, ModifyTableState::canSetTag, CMD_DELETE, CMD_INSERT, CMD_UPDATE, DatumGetHeapTupleHeader, DatumGetPointer, elog, ERROR, EState::es_epqTuple, EState::es_result_relation_info, EvalPlanQualSetPlan(), EvalPlanQualSetSlot, ExecDelete(), ExecFilterJunk(), ExecGetJunkAttribute(), ExecInsert(), ExecProcessReturning(), ExecProcNode(), ExecUpdate(), fireASTriggers(), ModifyTableState::fireBSTriggers, fireBSTriggers(), HeapTupleHeaderGetDatumLength, InvalidOid, ItemPointerSetInvalid, JunkFilter::jf_junkAttNo, ModifyTableState::mt_arbiterindexes, ModifyTableState::mt_arowmarks, ModifyTableState::mt_done, ModifyTableState::mt_epqstate, ModifyTableState::mt_nplans, ModifyTableState::mt_onconflict, ModifyTableState::mt_plans, ModifyTableState::mt_whichplan, NULL, ModifyTableState::operation, PlanState::plan, ModifyTableState::ps, RelationData::rd_rel, RelationGetRelid, RELKIND_FOREIGN_TABLE, RELKIND_MATVIEW, RELKIND_RELATION, RELKIND_VIEW, ResetPerTupleExprContext, ModifyTableState::resultRelInfo, ResultRelInfo::ri_junkFilter, ResultRelInfo::ri_projectReturning, ResultRelInfo::ri_RelationDesc, ResultRelInfo::ri_usesFdwDirectModify, PlanState::state, HeapTupleData::t_data, HeapTupleData::t_len, HeapTupleData::t_self, HeapTupleData::t_tableOid, and TupIsNull.

Referenced by ExecProcNode().

1387 {
1388  EState *estate = node->ps.state;
1389  CmdType operation = node->operation;
1390  ResultRelInfo *saved_resultRelInfo;
1391  ResultRelInfo *resultRelInfo;
1392  PlanState *subplanstate;
1393  JunkFilter *junkfilter;
1394  TupleTableSlot *slot;
1395  TupleTableSlot *planSlot;
1396  ItemPointer tupleid = NULL;
1397  ItemPointerData tuple_ctid;
1398  HeapTupleData oldtupdata;
1399  HeapTuple oldtuple;
1400 
1401  /*
1402  * This should NOT get called during EvalPlanQual; we should have passed a
1403  * subplan tree to EvalPlanQual, instead. Use a runtime test not just
1404  * Assert because this condition is easy to miss in testing. (Note:
1405  * although ModifyTable should not get executed within an EvalPlanQual
1406  * operation, we do have to allow it to be initialized and shut down in
1407  * case it is within a CTE subplan. Hence this test must be here, not in
1408  * ExecInitModifyTable.)
1409  */
1410  if (estate->es_epqTuple != NULL)
1411  elog(ERROR, "ModifyTable should not be called during EvalPlanQual");
1412 
1413  /*
1414  * If we've already completed processing, don't try to do more. We need
1415  * this test because ExecPostprocessPlan might call us an extra time, and
1416  * our subplan's nodes aren't necessarily robust against being called
1417  * extra times.
1418  */
1419  if (node->mt_done)
1420  return NULL;
1421 
1422  /*
1423  * On first call, fire BEFORE STATEMENT triggers before proceeding.
1424  */
1425  if (node->fireBSTriggers)
1426  {
1427  fireBSTriggers(node);
1428  node->fireBSTriggers = false;
1429  }
1430 
1431  /* Preload local variables */
1432  resultRelInfo = node->resultRelInfo + node->mt_whichplan;
1433  subplanstate = node->mt_plans[node->mt_whichplan];
1434  junkfilter = resultRelInfo->ri_junkFilter;
1435 
1436  /*
1437  * es_result_relation_info must point to the currently active result
1438  * relation while we are within this ModifyTable node. Even though
1439  * ModifyTable nodes can't be nested statically, they can be nested
1440  * dynamically (since our subplan could include a reference to a modifying
1441  * CTE). So we have to save and restore the caller's value.
1442  */
1443  saved_resultRelInfo = estate->es_result_relation_info;
1444 
1445  estate->es_result_relation_info = resultRelInfo;
1446 
1447  /*
1448  * Fetch rows from subplan(s), and execute the required table modification
1449  * for each row.
1450  */
1451  for (;;)
1452  {
1453  /*
1454  * Reset the per-output-tuple exprcontext. This is needed because
1455  * triggers expect to use that context as workspace. It's a bit ugly
1456  * to do this below the top level of the plan, however. We might need
1457  * to rethink this later.
1458  */
1459  ResetPerTupleExprContext(estate);
1460 
1461  planSlot = ExecProcNode(subplanstate);
1462 
1463  if (TupIsNull(planSlot))
1464  {
1465  /* advance to next subplan if any */
1466  node->mt_whichplan++;
1467  if (node->mt_whichplan < node->mt_nplans)
1468  {
1469  resultRelInfo++;
1470  subplanstate = node->mt_plans[node->mt_whichplan];
1471  junkfilter = resultRelInfo->ri_junkFilter;
1472  estate->es_result_relation_info = resultRelInfo;
1473  EvalPlanQualSetPlan(&node->mt_epqstate, subplanstate->plan,
1474  node->mt_arowmarks[node->mt_whichplan]);
1475  continue;
1476  }
1477  else
1478  break;
1479  }
1480 
1481  /*
1482  * If resultRelInfo->ri_usesFdwDirectModify is true, all we need to do
1483  * here is compute the RETURNING expressions.
1484  */
1485  if (resultRelInfo->ri_usesFdwDirectModify)
1486  {
1487  Assert(resultRelInfo->ri_projectReturning);
1488 
1489  /*
1490  * A scan slot containing the data that was actually inserted,
1491  * updated or deleted has already been made available to
1492  * ExecProcessReturning by IterateDirectModify, so no need to
1493  * provide it here.
1494  */
1495  slot = ExecProcessReturning(resultRelInfo, NULL, planSlot);
1496 
1497  estate->es_result_relation_info = saved_resultRelInfo;
1498  return slot;
1499  }
1500 
1501  EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
1502  slot = planSlot;
1503 
1504  oldtuple = NULL;
1505  if (junkfilter != NULL)
1506  {
1507  /*
1508  * extract the 'ctid' or 'wholerow' junk attribute.
1509  */
1510  if (operation == CMD_UPDATE || operation == CMD_DELETE)
1511  {
1512  char relkind;
1513  Datum datum;
1514  bool isNull;
1515 
1516  relkind = resultRelInfo->ri_RelationDesc->rd_rel->relkind;
1517  if (relkind == RELKIND_RELATION || relkind == RELKIND_MATVIEW)
1518  {
1519  datum = ExecGetJunkAttribute(slot,
1520  junkfilter->jf_junkAttNo,
1521  &isNull);
1522  /* shouldn't ever get a null result... */
1523  if (isNull)
1524  elog(ERROR, "ctid is NULL");
1525 
1526  tupleid = (ItemPointer) DatumGetPointer(datum);
1527  tuple_ctid = *tupleid; /* be sure we don't free
1528  * ctid!! */
1529  tupleid = &tuple_ctid;
1530  }
1531 
1532  /*
1533  * Use the wholerow attribute, when available, to reconstruct
1534  * the old relation tuple.
1535  *
1536  * Foreign table updates have a wholerow attribute when the
1537  * relation has an AFTER ROW trigger. Note that the wholerow
1538  * attribute does not carry system columns. Foreign table
1539  * triggers miss seeing those, except that we know enough here
1540  * to set t_tableOid. Quite separately from this, the FDW may
1541  * fetch its own junk attrs to identify the row.
1542  *
1543  * Other relevant relkinds, currently limited to views, always
1544  * have a wholerow attribute.
1545  */
1546  else if (AttributeNumberIsValid(junkfilter->jf_junkAttNo))
1547  {
1548  datum = ExecGetJunkAttribute(slot,
1549  junkfilter->jf_junkAttNo,
1550  &isNull);
1551  /* shouldn't ever get a null result... */
1552  if (isNull)
1553  elog(ERROR, "wholerow is NULL");
1554 
1555  oldtupdata.t_data = DatumGetHeapTupleHeader(datum);
1556  oldtupdata.t_len =
1558  ItemPointerSetInvalid(&(oldtupdata.t_self));
1559  /* Historically, view triggers see invalid t_tableOid. */
1560  oldtupdata.t_tableOid =
1561  (relkind == RELKIND_VIEW) ? InvalidOid :
1562  RelationGetRelid(resultRelInfo->ri_RelationDesc);
1563 
1564  oldtuple = &oldtupdata;
1565  }
1566  else
1567  Assert(relkind == RELKIND_FOREIGN_TABLE);
1568  }
1569 
1570  /*
1571  * apply the junkfilter if needed.
1572  */
1573  if (operation != CMD_DELETE)
1574  slot = ExecFilterJunk(junkfilter, slot);
1575  }
1576 
1577  switch (operation)
1578  {
1579  case CMD_INSERT:
1580  slot = ExecInsert(node, slot, planSlot,
1581  node->mt_arbiterindexes, node->mt_onconflict,
1582  estate, node->canSetTag);
1583  break;
1584  case CMD_UPDATE:
1585  slot = ExecUpdate(tupleid, oldtuple, slot, planSlot,
1586  &node->mt_epqstate, estate, node->canSetTag);
1587  break;
1588  case CMD_DELETE:
1589  slot = ExecDelete(tupleid, oldtuple, planSlot,
1590  &node->mt_epqstate, estate, node->canSetTag);
1591  break;
1592  default:
1593  elog(ERROR, "unknown operation");
1594  break;
1595  }
1596 
1597  /*
1598  * If we got a RETURNING result, return it to caller. We'll continue
1599  * the work on next call.
1600  */
1601  if (slot)
1602  {
1603  estate->es_result_relation_info = saved_resultRelInfo;
1604  return slot;
1605  }
1606  }
1607 
1608  /* Restore es_result_relation_info before exiting */
1609  estate->es_result_relation_info = saved_resultRelInfo;
1610 
1611  /*
1612  * We're done, but fire AFTER STATEMENT triggers before exiting.
1613  */
1614  fireASTriggers(node);
1615 
1616  node->mt_done = true;
1617 
1618  return NULL;
1619 }
AttrNumber jf_junkAttNo
Definition: execnodes.h:297
JunkFilter * ri_junkFilter
Definition: execnodes.h:349
HeapTuple * es_epqTuple
Definition: execnodes.h:432
Relation ri_RelationDesc
Definition: execnodes.h:335
TupleTableSlot * ExecProcNode(PlanState *node)
Definition: execProcnode.c:380
#define ResetPerTupleExprContext(estate)
Definition: executor.h:347
static TupleTableSlot * ExecUpdate(ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *slot, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, bool canSetTag)
ResultRelInfo * resultRelInfo
Definition: execnodes.h:1157
static void fireBSTriggers(ModifyTableState *node)
#define RELKIND_MATVIEW
Definition: pg_class.h:167
CmdType operation
Definition: execnodes.h:1151
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
Definition: execMain.c:2638
EState * state
Definition: execnodes.h:1049
Form_pg_class rd_rel
Definition: rel.h:113
#define DatumGetHeapTupleHeader(X)
Definition: fmgr.h:254
ItemPointerData * ItemPointer
Definition: itemptr.h:48
HeapTupleHeader t_data
Definition: htup.h:67
static TupleTableSlot * ExecDelete(ItemPointer tupleid, HeapTuple oldtuple, TupleTableSlot *planSlot, EPQState *epqstate, EState *estate, bool canSetTag)
OnConflictAction mt_onconflict
Definition: execnodes.h:1161
#define ERROR
Definition: elog.h:43
PlanState ps
Definition: execnodes.h:1150
ItemPointerData t_self
Definition: htup.h:65
bool ri_usesFdwDirectModify
Definition: execnodes.h:345
uint32 t_len
Definition: htup.h:64
EPQState mt_epqstate
Definition: execnodes.h:1159
ProjectionInfo * ri_projectReturning
Definition: execnodes.h:350
#define TupIsNull(slot)
Definition: tuptable.h:138
Oid t_tableOid
Definition: htup.h:66
#define RELKIND_FOREIGN_TABLE
Definition: pg_class.h:166
static TupleTableSlot * ExecProcessReturning(ResultRelInfo *resultRelInfo, TupleTableSlot *tupleSlot, TupleTableSlot *planSlot)
PlanState ** mt_plans
Definition: execnodes.h:1154
#define AttributeNumberIsValid(attributeNumber)
Definition: attnum.h:34
static void fireASTriggers(ModifyTableState *node)
uintptr_t Datum
Definition: postgres.h:374
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
Definition: execJunk.c:262
Plan * plan
Definition: execnodes.h:1047
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
static TupleTableSlot * ExecInsert(ModifyTableState *mtstate, TupleTableSlot *slot, TupleTableSlot *planSlot, List *arbiterIndexes, OnConflictAction onconflict, EState *estate, bool canSetTag)
#define DatumGetPointer(X)
Definition: postgres.h:557
List * mt_arbiterindexes
Definition: execnodes.h:1162
#define ItemPointerSetInvalid(pointer)
Definition: itemptr.h:131
Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
Definition: execJunk.c:248
#define RELKIND_VIEW
Definition: pg_class.h:164
#define elog
Definition: elog.h:219
#define RELKIND_RELATION
Definition: pg_class.h:160
#define RelationGetRelid(relation)
Definition: rel.h:413
CmdType
Definition: nodes.h:641
List ** mt_arowmarks
Definition: execnodes.h:1158
#define EvalPlanQualSetSlot(epqstate, slot)
Definition: executor.h:228
#define HeapTupleHeaderGetDatumLength(tup)
Definition: htup_details.h:439
ResultRelInfo * es_result_relation_info
Definition: execnodes.h:384
void ExecReScanModifyTable ( ModifyTableState node)

Definition at line 2186 of file nodeModifyTable.c.

References elog, and ERROR.

Referenced by ExecReScan().

2187 {
2188  /*
2189  * Currently, we don't need to support rescan on ModifyTable nodes. The
2190  * semantics of that would be a bit debatable anyway.
2191  */
2192  elog(ERROR, "ExecReScanModifyTable is not implemented");
2193 }
#define ERROR
Definition: elog.h:43
#define elog
Definition: elog.h:219