PostgreSQL Source Code  git master
dest.c File Reference
#include "postgres.h"
#include "access/printsimple.h"
#include "access/printtup.h"
#include "access/xact.h"
#include "commands/copy.h"
#include "commands/createas.h"
#include "commands/matview.h"
#include "executor/functions.h"
#include "executor/tqueue.h"
#include "executor/tstoreReceiver.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "utils/portal.h"
Include dependency graph for dest.c:

Go to the source code of this file.

Functions

static bool donothingReceive (TupleTableSlot *slot, DestReceiver *self)
 
static void donothingStartup (DestReceiver *self, int operation, TupleDesc typeinfo)
 
static void donothingCleanup (DestReceiver *self)
 
void BeginCommand (const char *commandTag, CommandDest dest)
 
DestReceiverCreateDestReceiver (CommandDest dest)
 
void EndCommand (const char *commandTag, CommandDest dest)
 
void NullCommand (CommandDest dest)
 
void ReadyForQuery (CommandDest dest)
 

Variables

static const DestReceiver donothingDR
 
static const DestReceiver debugtupDR
 
static const DestReceiver printsimpleDR
 
static const DestReceiver spi_printtupDR
 
DestReceiverNone_Receiver = (DestReceiver *) &donothingDR
 

Function Documentation

◆ BeginCommand()

void BeginCommand ( const char *  commandTag,
CommandDest  dest 
)

Definition at line 103 of file dest.c.

Referenced by exec_execute_message(), and exec_simple_query().

104 {
105  /* Nothing to do at present */
106 }

◆ CreateDestReceiver()

DestReceiver* CreateDestReceiver ( CommandDest  dest)

Definition at line 113 of file dest.c.

References CreateCopyDestReceiver(), CreateIntoRelDestReceiver(), CreateSQLFunctionDestReceiver(), CreateTransientRelDestReceiver(), CreateTupleQueueDestReceiver(), CreateTuplestoreDestReceiver(), DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, InvalidOid, pg_unreachable, printtup_create_DR(), and unconstify.

Referenced by _SPI_execute_plan(), BeginCopy(), CreateReplicationSlot(), exec_execute_message(), exec_replication_command(), exec_simple_query(), execute_sql_string(), FillPortalStore(), IdentifySystem(), PersistHoldablePortal(), postquel_start(), SPI_cursor_fetch(), SPI_scroll_cursor_fetch(), and StartReplication().

114 {
115  /*
116  * It's ok to cast the constness away as any modification of the none
117  * receiver would be a bug (which gets easier to catch this way).
118  */
119 
120  switch (dest)
121  {
122  case DestRemote:
123  case DestRemoteExecute:
124  return printtup_create_DR(dest);
125 
126  case DestRemoteSimple:
128 
129  case DestNone:
130  return unconstify(DestReceiver *, &donothingDR);
131 
132  case DestDebug:
133  return unconstify(DestReceiver *, &debugtupDR);
134 
135  case DestSPI:
137 
138  case DestTuplestore:
140 
141  case DestIntoRel:
142  return CreateIntoRelDestReceiver(NULL);
143 
144  case DestCopyOut:
145  return CreateCopyDestReceiver();
146 
147  case DestSQLFunction:
149 
150  case DestTransientRel:
152 
153  case DestTupleQueue:
154  return CreateTupleQueueDestReceiver(NULL);
155  }
156 
157  /* should never get here */
158  pg_unreachable();
159 }
#define pg_unreachable()
Definition: c.h:193
static const DestReceiver debugtupDR
Definition: dest.c:75
Definition: dest.h:93
static const DestReceiver printsimpleDR
Definition: dest.c:80
Definition: dest.h:88
DestReceiver * printtup_create_DR(CommandDest dest)
Definition: printtup.c:78
Definition: dest.h:89
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
Definition: createas.c:412
DestReceiver * CreateSQLFunctionDestReceiver(void)
Definition: functions.c:1955
#define unconstify(underlying_type, expr)
Definition: c.h:1194
#define InvalidOid
Definition: postgres_ext.h:36
static const DestReceiver spi_printtupDR
Definition: dest.c:85
DestReceiver * CreateTuplestoreDestReceiver(void)
DestReceiver * CreateTransientRelDestReceiver(Oid transientoid)
Definition: matview.c:430
DestReceiver * CreateCopyDestReceiver(void)
Definition: copy.c:5199
static const DestReceiver donothingDR
Definition: dest.c:70
DestReceiver * CreateTupleQueueDestReceiver(shm_mq_handle *handle)
Definition: tqueue.c:119

◆ donothingCleanup()

static void donothingCleanup ( DestReceiver self)
static

Definition at line 61 of file dest.c.

62 {
63  /* this is used for both shutdown and destroy methods */
64 }

◆ donothingReceive()

static bool donothingReceive ( TupleTableSlot slot,
DestReceiver self 
)
static

Definition at line 50 of file dest.c.

51 {
52  return true;
53 }

◆ donothingStartup()

static void donothingStartup ( DestReceiver self,
int  operation,
TupleDesc  typeinfo 
)
static

Definition at line 56 of file dest.c.

57 {
58 }

◆ EndCommand()

void EndCommand ( const char *  commandTag,
CommandDest  dest 
)

Definition at line 166 of file dest.c.

References DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, and pq_putmessage.

Referenced by DropReplicationSlot(), exec_execute_message(), exec_replication_command(), exec_simple_query(), StartLogicalReplication(), and WalSndDone().

167 {
168  switch (dest)
169  {
170  case DestRemote:
171  case DestRemoteExecute:
172  case DestRemoteSimple:
173 
174  /*
175  * We assume the commandTag is plain ASCII and therefore requires
176  * no encoding conversion.
177  */
178  pq_putmessage('C', commandTag, strlen(commandTag) + 1);
179  break;
180 
181  case DestNone:
182  case DestDebug:
183  case DestSPI:
184  case DestTuplestore:
185  case DestIntoRel:
186  case DestCopyOut:
187  case DestSQLFunction:
188  case DestTransientRel:
189  case DestTupleQueue:
190  break;
191  }
192 }
Definition: dest.h:93
Definition: dest.h:88
Definition: dest.h:89
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:42

◆ NullCommand()

void NullCommand ( CommandDest  dest)

Definition at line 207 of file dest.c.

References DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, FrontendProtocol, PG_PROTOCOL_MAJOR, pq_putemptymessage(), and pq_putmessage.

Referenced by exec_execute_message(), and exec_simple_query().

208 {
209  switch (dest)
210  {
211  case DestRemote:
212  case DestRemoteExecute:
213  case DestRemoteSimple:
214 
215  /*
216  * tell the fe that we saw an empty query string. In protocols
217  * before 3.0 this has a useless empty-string message body.
218  */
220  pq_putemptymessage('I');
221  else
222  pq_putmessage('I', "", 1);
223  break;
224 
225  case DestNone:
226  case DestDebug:
227  case DestSPI:
228  case DestTuplestore:
229  case DestIntoRel:
230  case DestCopyOut:
231  case DestSQLFunction:
232  case DestTransientRel:
233  case DestTupleQueue:
234  break;
235  }
236 }
Definition: dest.h:93
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:390
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
Definition: dest.h:88
Definition: dest.h:89
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:42
ProtocolVersion FrontendProtocol
Definition: globals.c:28

◆ ReadyForQuery()

void ReadyForQuery ( CommandDest  dest)

Definition at line 250 of file dest.c.

References buf, DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, FrontendProtocol, PG_PROTOCOL_MAJOR, pq_beginmessage(), pq_endmessage(), pq_flush, pq_putemptymessage(), pq_sendbyte(), and TransactionBlockStatusCode().

Referenced by PostgresMain().

251 {
252  switch (dest)
253  {
254  case DestRemote:
255  case DestRemoteExecute:
256  case DestRemoteSimple:
258  {
260 
261  pq_beginmessage(&buf, 'Z');
263  pq_endmessage(&buf);
264  }
265  else
266  pq_putemptymessage('Z');
267  /* Flush output at end of cycle in any case. */
268  pq_flush();
269  break;
270 
271  case DestNone:
272  case DestDebug:
273  case DestSPI:
274  case DestTuplestore:
275  case DestIntoRel:
276  case DestCopyOut:
277  case DestSQLFunction:
278  case DestTransientRel:
279  case DestTupleQueue:
280  break;
281  }
282 }
#define pq_flush()
Definition: libpq.h:39
Definition: dest.h:93
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:390
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
char TransactionBlockStatusCode(void)
Definition: xact.c:4667
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:87
static void pq_sendbyte(StringInfo buf, uint8 byt)
Definition: pqformat.h:161
Definition: dest.h:88
static char * buf
Definition: pg_test_fsync.c:67
Definition: dest.h:89
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:298
ProtocolVersion FrontendProtocol
Definition: globals.c:28

Variable Documentation

◆ debugtupDR

const DestReceiver debugtupDR
static
Initial value:
= {
}
Definition: dest.h:89
bool debugtup(TupleTableSlot *slot, DestReceiver *self)
Definition: printtup.c:614
void debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: printtup.c:596
static void donothingCleanup(DestReceiver *self)
Definition: dest.c:61

Definition at line 75 of file dest.c.

◆ donothingDR

const DestReceiver donothingDR
static
Initial value:
= {
}
static bool donothingReceive(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.c:50
Definition: dest.h:88
static void donothingStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.c:56
static void donothingCleanup(DestReceiver *self)
Definition: dest.c:61

Definition at line 70 of file dest.c.

◆ None_Receiver

◆ printsimpleDR

const DestReceiver printsimpleDR
static
Initial value:
= {
}
bool printsimple(TupleTableSlot *slot, DestReceiver *self)
Definition: printsimple.c:58
void printsimple_startup(DestReceiver *self, int operation, TupleDesc tupdesc)
Definition: printsimple.c:30
static void donothingCleanup(DestReceiver *self)
Definition: dest.c:61

Definition at line 80 of file dest.c.

◆ spi_printtupDR

const DestReceiver spi_printtupDR
static
Initial value:
= {
}
Definition: dest.h:93
void spi_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: spi.c:1841
static void donothingCleanup(DestReceiver *self)
Definition: dest.c:61
bool spi_printtup(TupleTableSlot *slot, DestReceiver *self)
Definition: spi.c:1889

Definition at line 85 of file dest.c.