* Insert tuple represented in the slot to the relation, update the indexes, * and execute any constraints and per-row triggers. * * Caller is responsible for opening the indexes. */
| 404 | * Caller is responsible for opening the indexes. |
| 405 | */ |
| 406 | void |
| 407 | ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo, |
| 408 | EState *estate, TupleTableSlot *slot) |
| 409 | { |
| 410 | bool skip_tuple = false; |
| 411 | Relation rel = resultRelInfo->ri_RelationDesc; |
| 412 | |
| 413 | /* For now we support only tables. */ |
| 414 | Assert(rel->rd_rel->relkind == RELKIND_RELATION); |
| 415 | |
| 416 | CheckCmdReplicaIdentity(rel, CMD_INSERT); |
| 417 | |
| 418 | /* BEFORE ROW INSERT Triggers */ |
| 419 | if (resultRelInfo->ri_TrigDesc && |
| 420 | resultRelInfo->ri_TrigDesc->trig_insert_before_row) |
| 421 | { |
| 422 | if (!ExecBRInsertTriggers(estate, resultRelInfo, slot)) |
| 423 | skip_tuple = true; /* "do nothing" */ |
| 424 | } |
| 425 | |
| 426 | if (!skip_tuple) |
| 427 | { |
| 428 | List *recheckIndexes = NIL; |
| 429 | |
| 430 | /* Compute stored generated columns */ |
| 431 | if (rel->rd_att->constr && |
| 432 | rel->rd_att->constr->has_generated_stored) |
| 433 | ExecComputeStoredGenerated(resultRelInfo, estate, slot, |
| 434 | CMD_INSERT); |
| 435 | |
| 436 | /* Check the constraints of the tuple */ |
| 437 | if (rel->rd_att->constr) |
| 438 | ExecConstraints(resultRelInfo, slot, estate); |
| 439 | if (rel->rd_rel->relispartition) |
| 440 | ExecPartitionCheck(resultRelInfo, slot, estate, true); |
| 441 | |
| 442 | /* OK, store the tuple and create index entries for it */ |
| 443 | simple_table_tuple_insert(resultRelInfo->ri_RelationDesc, slot); |
| 444 | |
| 445 | if (resultRelInfo->ri_NumIndices > 0) |
| 446 | recheckIndexes = ExecInsertIndexTuples(resultRelInfo, |
| 447 | slot, estate, false, false, |
| 448 | NULL, NIL); |
| 449 | |
| 450 | /* AFTER ROW INSERT Triggers */ |
| 451 | ExecARInsertTriggers(estate, resultRelInfo, slot, |
| 452 | recheckIndexes, NULL); |
| 453 | |
| 454 | /* |
| 455 | * XXX we should in theory pass a TransitionCaptureState object to the |
| 456 | * above to capture transition tuples, but after statement triggers |
| 457 | * don't actually get fired by replication yet anyway |
| 458 | */ |
| 459 | |
| 460 | list_free(recheckIndexes); |
| 461 | } |
| 462 | } |
| 463 |
no test coverage detected