mirror of
https://github.com/postgres/postgres.git
synced 2025-12-08 00:03:14 -05:00
Commit 4a4e6893aa080b9094dadbe0e65f8a75fee41ac6, which introduced this mechanism, failed to account for the fact that the RECORD pseudo-type uses transient typmods that are only meaningful within a single backend. Transferring such tuples without modification between two cooperating backends does not work. This commit installs a system for passing the tuple descriptors over the same shm_mq being used to send the tuples themselves. The two sides might not assign the same transient typmod to any given tuple descriptor, so we must also substitute the appropriate receiver-side typmod for the one used by the sender. That adds some CPU overhead, but still seems better than being unable to pass records between cooperating parallel processes. Along the way, move the logic for handling multiple tuple queues from tqueue.c to nodeGather.c; tqueue.c now provides a TupleQueueReader, which reads from a single queue, rather than a TupleQueueFunnel, which potentially reads from multiple queues. This change was suggested previously as a way to make sure that nodeGather.c rather than tqueue.c had policy control over the order in which to read from queues, but it wasn't clear to me until now how good an idea it was. typmod mapping needs to be performed separately for each queue, and it is much simpler if the tqueue.c code handles that and leaves multiplexing multiple queues to higher layers of the stack.
32 lines
1009 B
C
32 lines
1009 B
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* tqueue.h
|
|
* Use shm_mq to send & receive tuples between parallel backends
|
|
*
|
|
* Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/executor/tqueue.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
|
|
#ifndef TQUEUE_H
|
|
#define TQUEUE_H
|
|
|
|
#include "storage/shm_mq.h"
|
|
#include "tcop/dest.h"
|
|
|
|
/* Use this to send tuples to a shm_mq. */
|
|
extern DestReceiver *CreateTupleQueueDestReceiver(shm_mq_handle *handle);
|
|
|
|
/* Use these to receive tuples from a shm_mq. */
|
|
typedef struct TupleQueueReader TupleQueueReader;
|
|
extern TupleQueueReader *CreateTupleQueueReader(shm_mq_handle *handle,
|
|
TupleDesc tupledesc);
|
|
extern void DestroyTupleQueueReader(TupleQueueReader *funnel);
|
|
extern HeapTuple TupleQueueReaderNext(TupleQueueReader *,
|
|
bool nowait, bool *done);
|
|
|
|
#endif /* TQUEUE_H */
|