* Initialize ResultRelInfo data for one result relation * * Caution: before Postgres 9.1, this function included the relkind checking * that's now in CheckValidResultRel, and it also did ExecOpenIndices if * appropriate. Be sure callers cover those needs. */
| 2376 | * appropriate. Be sure callers cover those needs. |
| 2377 | */ |
| 2378 | void |
| 2379 | InitResultRelInfo(ResultRelInfo *resultRelInfo, |
| 2380 | Relation resultRelationDesc, |
| 2381 | Index resultRelationIndex, |
| 2382 | ResultRelInfo *partition_root_rri, |
| 2383 | int instrument_options) |
| 2384 | { |
| 2385 | MemSet(resultRelInfo, 0, sizeof(ResultRelInfo)); |
| 2386 | resultRelInfo->type = T_ResultRelInfo; |
| 2387 | resultRelInfo->ri_RangeTableIndex = resultRelationIndex; |
| 2388 | resultRelInfo->ri_RelationDesc = resultRelationDesc; |
| 2389 | resultRelInfo->ri_NumIndices = 0; |
| 2390 | resultRelInfo->ri_IndexRelationDescs = NULL; |
| 2391 | resultRelInfo->ri_IndexRelationInfo = NULL; |
| 2392 | /* make a copy so as not to depend on relcache info not changing... */ |
| 2393 | resultRelInfo->ri_TrigDesc = CopyTriggerDesc(resultRelationDesc->trigdesc); |
| 2394 | if (resultRelInfo->ri_TrigDesc) |
| 2395 | { |
| 2396 | int n = resultRelInfo->ri_TrigDesc->numtriggers; |
| 2397 | |
| 2398 | resultRelInfo->ri_TrigFunctions = (FmgrInfo *) |
| 2399 | palloc0(n * sizeof(FmgrInfo)); |
| 2400 | resultRelInfo->ri_TrigWhenExprs = (ExprState **) |
| 2401 | palloc0(n * sizeof(ExprState *)); |
| 2402 | if (instrument_options) |
| 2403 | resultRelInfo->ri_TrigInstrument = InstrAlloc(n, instrument_options, false); |
| 2404 | } |
| 2405 | else |
| 2406 | { |
| 2407 | resultRelInfo->ri_TrigFunctions = NULL; |
| 2408 | resultRelInfo->ri_TrigWhenExprs = NULL; |
| 2409 | resultRelInfo->ri_TrigInstrument = NULL; |
| 2410 | } |
| 2411 | if (resultRelationDesc->rd_rel->relkind == RELKIND_FOREIGN_TABLE) |
| 2412 | resultRelInfo->ri_FdwRoutine = GetFdwRoutineForRelation(resultRelationDesc, true); |
| 2413 | else |
| 2414 | resultRelInfo->ri_FdwRoutine = NULL; |
| 2415 | |
| 2416 | /* The following fields are set later if needed */ |
| 2417 | resultRelInfo->ri_RowIdAttNo = 0; |
| 2418 | resultRelInfo->ri_projectNew = NULL; |
| 2419 | resultRelInfo->ri_newTupleSlot = NULL; |
| 2420 | resultRelInfo->ri_oldTupleSlot = NULL; |
| 2421 | resultRelInfo->ri_projectNewInfoValid = false; |
| 2422 | resultRelInfo->ri_FdwState = NULL; |
| 2423 | resultRelInfo->ri_usesFdwDirectModify = false; |
| 2424 | resultRelInfo->ri_ConstraintExprs = NULL; |
| 2425 | resultRelInfo->ri_GeneratedExprs = NULL; |
| 2426 | resultRelInfo->ri_projectReturning = NULL; |
| 2427 | resultRelInfo->ri_onConflictArbiterIndexes = NIL; |
| 2428 | resultRelInfo->ri_onConflict = NULL; |
| 2429 | resultRelInfo->ri_ReturningSlot = NULL; |
| 2430 | resultRelInfo->ri_TrigOldSlot = NULL; |
| 2431 | resultRelInfo->ri_TrigNewSlot = NULL; |
| 2432 | |
| 2433 | /* |
| 2434 | * Only ExecInitPartitionInfo() and ExecInitPartitionDispatchInfo() pass |
| 2435 | * non-NULL partition_root_rri. For child relations that are part of the |
no test coverage detected