1
/*-------------------------------------------------------------------------
4
* an implementation of DestReceiver that stores the result tuples in
8
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
9
* Portions Copyright (c) 1994, Regents of the University of California
12
* $PostgreSQL: pgsql/src/backend/executor/tstoreReceiver.c,v 1.13 2004-12-31 21:59:45 pgsql Exp $
14
*-------------------------------------------------------------------------
19
#include "executor/tstoreReceiver.h"
25
Tuplestorestate *tstore;
31
* Prepare to receive tuples from executor.
34
tstoreStartupReceiver(DestReceiver *self, int operation, TupleDesc typeinfo)
40
* Receive a tuple from the executor and store it in the tuplestore.
43
tstoreReceiveTuple(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
45
TStoreState *myState = (TStoreState *) self;
46
MemoryContext oldcxt = MemoryContextSwitchTo(myState->cxt);
48
tuplestore_puttuple(myState->tstore, tuple);
50
MemoryContextSwitchTo(oldcxt);
54
* Clean up at end of an executor run
57
tstoreShutdownReceiver(DestReceiver *self)
63
* Destroy receiver when done with it
66
tstoreDestroyReceiver(DestReceiver *self)
72
* Initially create a DestReceiver object.
75
CreateTuplestoreDestReceiver(Tuplestorestate *tStore,
76
MemoryContext tContext)
78
TStoreState *self = (TStoreState *) palloc(sizeof(TStoreState));
80
self->pub.receiveTuple = tstoreReceiveTuple;
81
self->pub.rStartup = tstoreStartupReceiver;
82
self->pub.rShutdown = tstoreShutdownReceiver;
83
self->pub.rDestroy = tstoreDestroyReceiver;
84
self->pub.mydest = Tuplestore;
86
self->tstore = tStore;
89
return (DestReceiver *) self;