MCPcopy Create free account
hub / github.com/documentdb/documentdb / command_update

Function command_update

pg_documentdb/src/commands/update.c:518–554  ·  view source on GitHub ↗

* command_update handles a single update on a collection. */

Source from the content-addressed store, hash-verified

516 * command_update handles a single update on a collection.
517 */
518Datum
519command_update(PG_FUNCTION_ARGS)
520{
521 if (PG_ARGISNULL(1))
522 {
523 ereport(ERROR, (errmsg("update document cannot be NULL")));
524 }
525
526 Datum databaseNameDatum = PG_ARGISNULL(0) ? (Datum) 0 : PG_GETARG_DATUM(0);
527 pgbson *updateSpec = PG_GETARG_PGBSON(1);
528
529 pgbsonsequence *updateDocs = PG_GETARG_MAYBE_NULL_PGBSON_SEQUENCE(2);
530
531 text *transactionId = NULL;
532 if (!PG_ARGISNULL(3))
533 {
534 transactionId = PG_GETARG_TEXT_P(3);
535 }
536
537 ReportFeatureUsage(FEATURE_COMMAND_UPDATE);
538
539 /* fetch TupleDesc for return value, not interested in resultTypeId */
540 Oid *resultTypeId = NULL;
541 TupleDesc resultTupDesc;
542 TypeFuncClass resultTypeClass =
543 get_call_result_type(fcinfo, resultTypeId, &resultTupDesc);
544
545 if (resultTypeClass != TYPEFUNC_COMPOSITE)
546 {
547 ereport(ERROR, (errmsg("return type must be a row type")));
548 }
549
550 HeapTuple resultTuple = PerformUpdateCore(&databaseNameDatum, updateSpec, updateDocs,
551 transactionId, resultTupDesc,
552 WriteMode_Txn_Func, CurrentMemoryContext);
553 PG_RETURN_DATUM(HeapTupleGetDatum(resultTuple));
554}
555
556
557inline static bool

Callers

nothing calls this directly

Calls 2

ReportFeatureUsageFunction · 0.85
PerformUpdateCoreFunction · 0.85

Tested by

no test coverage detected