MCPcopy Create free account
hub / github.com/apache/cloudberry / TupleQueueReaderNext

Function TupleQueueReaderNext

src/backend/executor/tqueue.c:175–210  ·  view source on GitHub ↗

* Fetch a tuple from a tuple queue reader. * * The return value is NULL if there are no remaining tuples or if * nowait = true and no tuple is ready to return. *done, if not NULL, * is set to true when there are no remaining tuples and otherwise to false. * * The returned tuple, if any, is either in shared memory or a private buffer * and should not be freed. The pointer is invalid after

Source from the content-addressed store, hash-verified

173 * this with nowait = true even if nothing is returned.
174 */
175MinimalTuple
176TupleQueueReaderNext(TupleQueueReader *reader, bool nowait, bool *done)
177{
178 MinimalTuple tuple;
179 shm_mq_result result;
180 Size nbytes;
181 void *data;
182
183 if (done != NULL)
184 *done = false;
185
186 /* Attempt to read a message. */
187 result = shm_mq_receive(reader->queue, &nbytes, &data, nowait);
188
189 /* If queue is detached, set *done and return NULL. */
190 if (result == SHM_MQ_DETACHED)
191 {
192 if (done != NULL)
193 *done = true;
194 return NULL;
195 }
196
197 /* In non-blocking mode, bail out if no message ready yet. */
198 if (result == SHM_MQ_WOULD_BLOCK)
199 return NULL;
200 Assert(result == SHM_MQ_SUCCESS);
201
202 /*
203 * Return a pointer to the queue memory directly (which had better be
204 * sufficiently aligned).
205 */
206 tuple = (MinimalTuple) data;
207 Assert(tuple->t_len == nbytes);
208
209 return tuple;
210}

Callers 3

retrieve_next_tupleFunction · 0.85
gm_readnext_tupleFunction · 0.85
gather_readnextFunction · 0.85

Calls 1

shm_mq_receiveFunction · 0.85

Tested by

no test coverage detected