MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecSimpleRelationInsert

Function ExecSimpleRelationInsert

src/backend/executor/execReplication.c:406–462  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

404 * Caller is responsible for opening the indexes.
405 */
406void
407ExecSimpleRelationInsert(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

Callers 1

Calls 9

CheckCmdReplicaIdentityFunction · 0.85
ExecBRInsertTriggersFunction · 0.85
ExecConstraintsFunction · 0.85
ExecPartitionCheckFunction · 0.85
ExecInsertIndexTuplesFunction · 0.85
ExecARInsertTriggersFunction · 0.85
list_freeFunction · 0.50

Tested by

no test coverage detected