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

Function SerializeUnshardedUpdateParams

pg_documentdb/src/commands/update.c:2601–2638  ·  view source on GitHub ↗

Serializes the update spec if any and if it is ordered or not as a pgbson to send to the worker. */

Source from the content-addressed store, hash-verified

2599
2600/* Serializes the update spec if any and if it is ordered or not as a pgbson to send to the worker. */
2601static pgbson *
2602SerializeUnshardedUpdateParams(const bson_value_t *updateSpec, bool isOrdered,
2603 bool bypassDocumentValidation,
2604 const bson_value_t *variableSpec)
2605{
2606 if (updateSpec != NULL && updateSpec->value_type != BSON_TYPE_ARRAY)
2607 {
2608 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_LOCATION40414),
2609 errmsg("Required field 'update.updates' is missing")));
2610 }
2611
2612 pgbson_writer writer;
2613 PgbsonWriterInit(&writer);
2614
2615 pgbson_writer innerWriter;
2616 PgbsonWriterInit(&innerWriter);
2617
2618 PgbsonWriterStartDocument(&writer, "updateUnsharded", -1, &innerWriter);
2619
2620 if (updateSpec != NULL)
2621 {
2622 PgbsonWriterAppendValue(&innerWriter, "specs", -1, updateSpec);
2623 }
2624
2625 PgbsonWriterAppendBool(&innerWriter, "isOrdered", -1, isOrdered);
2626 PgbsonWriterAppendBool(&innerWriter, "bypassDocumentValidation", -1,
2627 bypassDocumentValidation);
2628
2629 if (variableSpec != NULL &&
2630 variableSpec->value_type == BSON_TYPE_DOCUMENT)
2631 {
2632 PgbsonWriterAppendValue(&innerWriter, "variableSpec", -1, variableSpec);
2633 }
2634
2635 PgbsonWriterEndDocument(&writer, &innerWriter);
2636
2637 return PgbsonWriterGetPgbson(&writer);
2638}
2639
2640
2641static void

Callers 1

Calls 6

PgbsonWriterInitFunction · 0.85
PgbsonWriterAppendValueFunction · 0.85
PgbsonWriterAppendBoolFunction · 0.85
PgbsonWriterEndDocumentFunction · 0.85
PgbsonWriterGetPgbsonFunction · 0.85

Tested by

no test coverage detected