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

Function BuildInsertionList

pg_documentdb/src/commands/insert.c:464–491  ·  view source on GitHub ↗

* BuildInsertionList iterates over an array of documents in an insert spec and * returns a list of pgbson documents to insert. */

Source from the content-addressed store, hash-verified

462 * returns a list of pgbson documents to insert.
463 */
464static List *
465BuildInsertionList(bson_iter_t *insertArrayIter, bool *hasSkippedDocuments)
466{
467 List *documents = NIL;
468 *hasSkippedDocuments = false;
469
470 while (bson_iter_next(insertArrayIter))
471 {
472 StringInfo fieldNameStr = makeStringInfo();
473 int arrIdx = list_length(documents);
474 appendStringInfo(fieldNameStr, "insert.documents.%d", arrIdx);
475
476 EnsureTopLevelFieldType(fieldNameStr->data, insertArrayIter, BSON_TYPE_DOCUMENT);
477 const bson_value_t *docValue = bson_iter_value(insertArrayIter);
478 if (ValidateAndCheckShouldInsertDocument(docValue))
479 {
480 bson_value_t *clonedValue = palloc(sizeof(bson_value_t));
481 *clonedValue = *docValue;
482 documents = lappend(documents, clonedValue);
483 }
484 else
485 {
486 *hasSkippedDocuments = true;
487 }
488 }
489
490 return documents;
491}
492
493
494/*

Callers 1

BuildBatchInsertionSpecFunction · 0.85

Tested by

no test coverage detected