* Find the searchslot tuple and update it with data in the slot, * update the indexes, and execute any constraints and per-row triggers. * * Caller is responsible for opening the indexes. */
| 468 | * Caller is responsible for opening the indexes. |
| 469 | */ |
| 470 | void |
| 471 | ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo, |
| 472 | EState *estate, EPQState *epqstate, |
| 473 | TupleTableSlot *searchslot, TupleTableSlot *slot) |
| 474 | { |
| 475 | bool skip_tuple = false; |
| 476 | Relation rel = resultRelInfo->ri_RelationDesc; |
| 477 | ItemPointer tid = &(searchslot->tts_tid); |
| 478 | |
| 479 | /* For now we support only tables. */ |
| 480 | Assert(rel->rd_rel->relkind == RELKIND_RELATION); |
| 481 | |
| 482 | CheckCmdReplicaIdentity(rel, CMD_UPDATE); |
| 483 | |
| 484 | /* BEFORE ROW UPDATE Triggers */ |
| 485 | if (resultRelInfo->ri_TrigDesc && |
| 486 | resultRelInfo->ri_TrigDesc->trig_update_before_row) |
| 487 | { |
| 488 | if (!ExecBRUpdateTriggers(estate, epqstate, resultRelInfo, |
| 489 | tid, NULL, slot)) |
| 490 | skip_tuple = true; /* "do nothing" */ |
| 491 | } |
| 492 | |
| 493 | if (!skip_tuple) |
| 494 | { |
| 495 | List *recheckIndexes = NIL; |
| 496 | bool update_indexes; |
| 497 | |
| 498 | /* Compute stored generated columns */ |
| 499 | if (rel->rd_att->constr && |
| 500 | rel->rd_att->constr->has_generated_stored) |
| 501 | ExecComputeStoredGenerated(resultRelInfo, estate, slot, |
| 502 | CMD_UPDATE); |
| 503 | |
| 504 | /* Check the constraints of the tuple */ |
| 505 | if (rel->rd_att->constr) |
| 506 | ExecConstraints(resultRelInfo, slot, estate); |
| 507 | if (rel->rd_rel->relispartition) |
| 508 | ExecPartitionCheck(resultRelInfo, slot, estate, true); |
| 509 | |
| 510 | simple_table_tuple_update(rel, tid, slot, estate->es_snapshot, |
| 511 | &update_indexes); |
| 512 | |
| 513 | if (resultRelInfo->ri_NumIndices > 0 && update_indexes) |
| 514 | recheckIndexes = ExecInsertIndexTuples(resultRelInfo, |
| 515 | slot, estate, true, false, |
| 516 | NULL, NIL); |
| 517 | |
| 518 | /* AFTER ROW UPDATE Triggers */ |
| 519 | ExecARUpdateTriggers(estate, resultRelInfo, |
| 520 | tid, NULL, slot, |
| 521 | recheckIndexes, NULL); |
| 522 | |
| 523 | list_free(recheckIndexes); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | /* |
no test coverage detected