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

Function PersistentDestReceiverReceive

pg_documentdb/src/commands/cursors.c:1261–1308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1259
1260
1261static bool
1262PersistentDestReceiverReceive(TupleTableSlot *slot,
1263 DestReceiver *destReceiver)
1264{
1265 PersistentTupleDestReceiver *receiver =
1266 (PersistentTupleDestReceiver *) destReceiver;
1267 BsonStoreTupleDestReceiverBase *base = &receiver->base;
1268
1269 bool isNull = false;
1270 Datum result = slot_getattr(slot, 1, &isNull);
1271 if (isNull)
1272 {
1273 if (receiver->isSingleResult)
1274 {
1275 /*
1276 * For single-result receivers (count/distinct): NULL means "no data".
1277 * Return false (stop) — nothing to fetch; the caller reads
1278 * receiver->singleResult which stays NULL.
1279 */
1280 return false;
1281 }
1282 else
1283 {
1284 /*
1285 * For multi-row persistent receivers: NULL data rows are
1286 * skipped. Return true (continue) so the executor keeps sending
1287 * rows, matching the old SPI path behaviour. The col2 continuation
1288 * token is intentionally not processed here — for non-tailable
1289 * cursors the old SPI path (FetchCursorAndWriteUntilPageOrSize)
1290 * also skips continuation when isDataNull is true. Tailable
1291 * cursors use a separate code path (DrainTailableQuery /
1292 * FetchTailableCursorAndWriteUntilPageOrSize).
1293 */
1294 return true;
1295 }
1296 }
1297
1298 if (receiver->isSingleResult)
1299 {
1300 MemoryContext oldContext = MemoryContextSwitchTo(base->writerContext);
1301 receiver->singleResult = (pgbson *) PG_DETOAST_DATUM_COPY(result);
1302 MemoryContextSwitchTo(oldContext);
1303 return false; /* stop after first row */
1304 }
1305
1306 pgbson *resultBson = DatumGetPgBsonPacked(result);
1307 return PersistentDestReceiveCore(resultBson, receiver);
1308}
1309
1310
1311static void

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected