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

Function command_insert_bulk

pg_documentdb/src/commands/insert.c:180–210  ·  view source on GitHub ↗

* command_insert_bulk handles the insert command invocation through a PostgreSQL procedure and commits after each batch. */

Source from the content-addressed store, hash-verified

178 * command_insert_bulk handles the insert command invocation through a PostgreSQL procedure and commits after each batch.
179 */
180Datum
181command_insert_bulk(PG_FUNCTION_ARGS)
182{
183 ReportFeatureUsage(FEATURE_COMMAND_INSERT_BULK);
184 bool isTopLevel = true;
185 if (IsInTransactionBlock(isTopLevel))
186 {
187 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_OPERATIONNOTSUPPORTEDINTRANSACTION),
188 errmsg("the insert procedure cannot be used in transactions."
189 " Please use the insert function instead")));
190 }
191
192
193 /* For results we need a stable memory context across transactions */
194 MemoryContext stableContext = fcinfo->flinfo->fn_mcxt;
195 Datum result = CommandInsertCore(fcinfo, WriteMode_Bulk_Proc, stableContext);
196
197 /* If it's not transactional, pop the active snapshot created during the transaction start */
198 if (ActiveSnapshotSet())
199 {
200 Snapshot snapshot = GetActiveSnapshot();
201 if (ActivePortal != NULL && ActivePortal->portalSnapshot == snapshot)
202 {
203 ActivePortal->portalSnapshot = NULL;
204 }
205
206 PopActiveSnapshot();
207 }
208
209 PG_RETURN_DATUM(result);
210}
211
212
213/*

Callers

nothing calls this directly

Calls 2

ReportFeatureUsageFunction · 0.85
CommandInsertCoreFunction · 0.85

Tested by

no test coverage detected