* ExecInitPartitionInfo * Lock the partition and initialize ResultRelInfo. Also setup other * information for the partition and store it in the next empty slot in * the proute->partitions array. * * Returns the ResultRelInfo */
| 541 | * Returns the ResultRelInfo |
| 542 | */ |
| 543 | static ResultRelInfo * |
| 544 | ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, |
| 545 | PartitionTupleRouting *proute, |
| 546 | PartitionDispatch dispatch, |
| 547 | ResultRelInfo *rootResultRelInfo, |
| 548 | int partidx) |
| 549 | { |
| 550 | ModifyTable *node = (ModifyTable *) mtstate->ps.plan; |
| 551 | Oid partOid = dispatch->partdesc->oids[partidx]; |
| 552 | Relation partrel; |
| 553 | int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex; |
| 554 | Relation firstResultRel = mtstate->resultRelInfo[0].ri_RelationDesc; |
| 555 | ResultRelInfo *leaf_part_rri; |
| 556 | MemoryContext oldcxt; |
| 557 | AttrMap *part_attmap = NULL; |
| 558 | bool found_whole_row; |
| 559 | |
| 560 | oldcxt = MemoryContextSwitchTo(proute->memcxt); |
| 561 | |
| 562 | partrel = table_open(partOid, RowExclusiveLock); |
| 563 | |
| 564 | leaf_part_rri = makeNode(ResultRelInfo); |
| 565 | |
| 566 | /* |
| 567 | * Init leaf partition ResultRelInfo |
| 568 | * Here ResultRelInfo->ri_RangeTableIndex is a dummy element, because we |
| 569 | * will rebuild ri_RelationDesc later. So we assign 1 for it instead of 0 |
| 570 | * which cause failure in EPQ process, and fwd scenarios should still keep 0 |
| 571 | * since it will handle 0 in their own fwd process. |
| 572 | * related issue https://github.com/greenplum-db/gpdb/issues/14935 |
| 573 | */ |
| 574 | InitResultRelInfo(leaf_part_rri, |
| 575 | partrel, |
| 576 | partrel->rd_rel->relkind != RELKIND_FOREIGN_TABLE ? 1 : 0, |
| 577 | rootResultRelInfo, |
| 578 | estate->es_instrument); |
| 579 | |
| 580 | /* |
| 581 | * Verify result relation is a valid target for an INSERT. An UPDATE of a |
| 582 | * partition-key becomes a DELETE+INSERT operation, so this check is still |
| 583 | * required when the operation is CMD_UPDATE. |
| 584 | */ |
| 585 | CheckValidResultRel(leaf_part_rri, CMD_INSERT, NULL); |
| 586 | |
| 587 | /* |
| 588 | * Open partition indices. The user may have asked to check for conflicts |
| 589 | * within this leaf partition and do "nothing" instead of throwing an |
| 590 | * error. Be prepared in that case by initializing the index information |
| 591 | * needed by ExecInsert() to perform speculative insertions. |
| 592 | */ |
| 593 | if (partrel->rd_rel->relhasindex && |
| 594 | leaf_part_rri->ri_IndexRelationDescs == NULL) |
| 595 | ExecOpenIndices(leaf_part_rri, |
| 596 | (node != NULL && |
| 597 | node->onConflictAction != ONCONFLICT_NONE)); |
| 598 | |
| 599 | /* |
| 600 | * Build WITH CHECK OPTION constraints for the partition. Note that we |
no test coverage detected