PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
tqueue.h File Reference
#include "storage/shm_mq.h"
#include "tcop/dest.h"
Include dependency graph for tqueue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct TupleQueueReader TupleQueueReader
 

Functions

DestReceiverCreateTupleQueueDestReceiver (shm_mq_handle *handle)
 
TupleQueueReaderCreateTupleQueueReader (shm_mq_handle *handle)
 
void DestroyTupleQueueReader (TupleQueueReader *reader)
 
MinimalTuple TupleQueueReaderNext (TupleQueueReader *reader, bool nowait, bool *done)
 

Typedef Documentation

◆ TupleQueueReader

Definition at line 21 of file tqueue.h.

Function Documentation

◆ CreateTupleQueueDestReceiver()

DestReceiver * CreateTupleQueueDestReceiver ( shm_mq_handle handle)

Definition at line 119 of file tqueue.c.

120{
121 TQueueDestReceiver *self;
122
124
129 self->pub.mydest = DestTupleQueue;
130 self->queue = handle;
131
132 return (DestReceiver *) self;
133}
@ DestTupleQueue
Definition: dest.h:98
void * palloc0(Size size)
Definition: mcxt.c:1347
DestReceiver pub
Definition: tqueue.c:32
shm_mq_handle * queue
Definition: tqueue.c:33
void(* rStartup)(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.h:121
void(* rShutdown)(DestReceiver *self)
Definition: dest.h:124
bool(* receiveSlot)(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.h:118
void(* rDestroy)(DestReceiver *self)
Definition: dest.h:126
CommandDest mydest
Definition: dest.h:128
static void tqueueStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: tqueue.c:83
static void tqueueShutdownReceiver(DestReceiver *self)
Definition: tqueue.c:92
static bool tqueueReceiveSlot(TupleTableSlot *slot, DestReceiver *self)
Definition: tqueue.c:54
static void tqueueDestroyReceiver(DestReceiver *self)
Definition: tqueue.c:105

References DestTupleQueue, _DestReceiver::mydest, palloc0(), TQueueDestReceiver::pub, TQueueDestReceiver::queue, _DestReceiver::rDestroy, _DestReceiver::receiveSlot, _DestReceiver::rShutdown, _DestReceiver::rStartup, tqueueDestroyReceiver(), tqueueReceiveSlot(), tqueueShutdownReceiver(), and tqueueStartupReceiver().

Referenced by CreateDestReceiver(), and ExecParallelGetReceiver().

◆ CreateTupleQueueReader()

TupleQueueReader * CreateTupleQueueReader ( shm_mq_handle handle)

Definition at line 139 of file tqueue.c.

140{
141 TupleQueueReader *reader = palloc0(sizeof(TupleQueueReader));
142
143 reader->queue = handle;
144
145 return reader;
146}
shm_mq_handle * queue
Definition: tqueue.c:45

References palloc0(), and TupleQueueReader::queue.

Referenced by ExecParallelCreateReaders().

◆ DestroyTupleQueueReader()

void DestroyTupleQueueReader ( TupleQueueReader reader)

Definition at line 155 of file tqueue.c.

156{
157 pfree(reader);
158}
void pfree(void *pointer)
Definition: mcxt.c:1521

References pfree().

Referenced by ExecParallelFinish().

◆ TupleQueueReaderNext()

MinimalTuple TupleQueueReaderNext ( TupleQueueReader reader,
bool  nowait,
bool *  done 
)

Definition at line 176 of file tqueue.c.

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}
#define Assert(condition)
Definition: c.h:812
size_t Size
Definition: c.h:559
MinimalTupleData * MinimalTuple
Definition: htup.h:27
const void * data
shm_mq_result shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
Definition: shm_mq.c:572
shm_mq_result
Definition: shm_mq.h:37
@ SHM_MQ_SUCCESS
Definition: shm_mq.h:38
@ SHM_MQ_WOULD_BLOCK
Definition: shm_mq.h:39
@ SHM_MQ_DETACHED
Definition: shm_mq.h:40

References Assert, data, TupleQueueReader::queue, SHM_MQ_DETACHED, shm_mq_receive(), SHM_MQ_SUCCESS, SHM_MQ_WOULD_BLOCK, and MinimalTupleData::t_len.

Referenced by gather_readnext(), and gm_readnext_tuple().