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 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 (CommandTag commandTag, CommandDest dest)
 
DestReceiverCreateDestReceiver (CommandDest dest)
 
void EndCommand (const QueryCompletion *qc, CommandDest dest, bool force_undecorated_output)
 
void EndReplicationCommand (const char *commandTag)
 
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 ( CommandTag  commandTag,
CommandDest  dest 
)

Definition at line 102 of file dest.c.

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

Referenced by exec_execute_message(), and exec_simple_query().

◆ CreateDestReceiver()

DestReceiver* CreateDestReceiver ( CommandDest  dest)

Definition at line 112 of file dest.c.

113 {
114  /*
115  * It's ok to cast the constness away as any modification of the none
116  * receiver would be a bug (which gets easier to catch this way).
117  */
118 
119  switch (dest)
120  {
121  case DestRemote:
122  case DestRemoteExecute:
123  return printtup_create_DR(dest);
124 
125  case DestRemoteSimple:
127 
128  case DestNone:
129  return unconstify(DestReceiver *, &donothingDR);
130 
131  case DestDebug:
132  return unconstify(DestReceiver *, &debugtupDR);
133 
134  case DestSPI:
136 
137  case DestTuplestore:
139 
140  case DestIntoRel:
141  return CreateIntoRelDestReceiver(NULL);
142 
143  case DestCopyOut:
144  return CreateCopyDestReceiver();
145 
146  case DestSQLFunction:
148 
149  case DestTransientRel:
151 
152  case DestTupleQueue:
153  return CreateTupleQueueDestReceiver(NULL);
154  }
155 
156  /* should never get here */
157  pg_unreachable();
158 }
#define unconstify(underlying_type, expr)
Definition: c.h:1232
#define pg_unreachable()
Definition: c.h:283
DestReceiver * CreateCopyDestReceiver(void)
Definition: copyto.c:1267
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
Definition: createas.c:435
static const DestReceiver spi_printtupDR
Definition: dest.c:84
static const DestReceiver debugtupDR
Definition: dest.c:74
static const DestReceiver donothingDR
Definition: dest.c:69
static const DestReceiver printsimpleDR
Definition: dest.c:79
@ DestSQLFunction
Definition: dest.h:96
@ DestTupleQueue
Definition: dest.h:98
@ DestTuplestore
Definition: dest.h:93
@ DestRemote
Definition: dest.h:89
@ DestDebug
Definition: dest.h:88
@ DestRemoteSimple
Definition: dest.h:91
@ DestCopyOut
Definition: dest.h:95
@ DestTransientRel
Definition: dest.h:97
@ DestSPI
Definition: dest.h:92
@ DestIntoRel
Definition: dest.h:94
@ DestRemoteExecute
Definition: dest.h:90
@ DestNone
Definition: dest.h:87
DestReceiver * CreateSQLFunctionDestReceiver(void)
Definition: functions.c:2062
DestReceiver * CreateTransientRelDestReceiver(Oid transientoid)
Definition: matview.c:432
#define InvalidOid
Definition: postgres_ext.h:36
DestReceiver * printtup_create_DR(CommandDest dest)
Definition: printtup.c:70
DestReceiver * CreateTupleQueueDestReceiver(shm_mq_handle *handle)
Definition: tqueue.c:119
DestReceiver * CreateTuplestoreDestReceiver(void)

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

Referenced by _SPI_execute_plan(), BeginCopyTo(), CreateReplicationSlot(), exec_execute_message(), exec_replication_command(), exec_simple_query(), exec_stmt_return_query(), execute_sql_string(), FillPortalStore(), IdentifySystem(), PersistHoldablePortal(), postquel_start(), ReadReplicationSlot(), SendTablespaceList(), SendTimeLineHistory(), SendXlogRecPtrResult(), SPI_cursor_fetch(), SPI_scroll_cursor_fetch(), and StartReplication().

◆ donothingCleanup()

static void donothingCleanup ( DestReceiver self)
static

Definition at line 60 of file dest.c.

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

◆ donothingReceive()

static bool donothingReceive ( TupleTableSlot slot,
DestReceiver self 
)
static

Definition at line 49 of file dest.c.

50 {
51  return true;
52 }

◆ donothingStartup()

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

Definition at line 55 of file dest.c.

56 {
57 }

◆ EndCommand()

void EndCommand ( const QueryCompletion qc,
CommandDest  dest,
bool  force_undecorated_output 
)

Definition at line 165 of file dest.c.

166 {
167  char completionTag[COMPLETION_TAG_BUFSIZE];
168  Size len;
169 
170  switch (dest)
171  {
172  case DestRemote:
173  case DestRemoteExecute:
174  case DestRemoteSimple:
175 
176  len = BuildQueryCompletionString(completionTag, qc,
177  force_undecorated_output);
178  pq_putmessage(PqMsg_CommandComplete, completionTag, len + 1);
179 
180  case DestNone:
181  case DestDebug:
182  case DestSPI:
183  case DestTuplestore:
184  case DestIntoRel:
185  case DestCopyOut:
186  case DestSQLFunction:
187  case DestTransientRel:
188  case DestTupleQueue:
189  break;
190  }
191 }
size_t Size
Definition: c.h:592
Size BuildQueryCompletionString(char *buff, const QueryCompletion *qc, bool nameonly)
Definition: cmdtag.c:121
#define COMPLETION_TAG_BUFSIZE
Definition: cmdtag.h:17
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:49
const void size_t len
#define PqMsg_CommandComplete
Definition: protocol.h:42

References BuildQueryCompletionString(), COMPLETION_TAG_BUFSIZE, generate_unaccent_rules::dest, DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, len, pq_putmessage, and PqMsg_CommandComplete.

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

◆ EndReplicationCommand()

void EndReplicationCommand ( const char *  commandTag)

Definition at line 200 of file dest.c.

201 {
202  pq_putmessage(PqMsg_CommandComplete, commandTag, strlen(commandTag) + 1);
203 }

References pq_putmessage, and PqMsg_CommandComplete.

Referenced by exec_replication_command(), and StartReplication().

◆ NullCommand()

void NullCommand ( CommandDest  dest)

Definition at line 213 of file dest.c.

214 {
215  switch (dest)
216  {
217  case DestRemote:
218  case DestRemoteExecute:
219  case DestRemoteSimple:
220 
221  /* Tell the FE that we saw an empty query string */
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 }
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:388
#define PqMsg_EmptyQueryResponse
Definition: protocol.h:47

References generate_unaccent_rules::dest, DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, pq_putemptymessage(), and PqMsg_EmptyQueryResponse.

Referenced by exec_execute_message(), and exec_simple_query().

◆ ReadyForQuery()

void ReadyForQuery ( CommandDest  dest)

Definition at line 250 of file dest.c.

251 {
252  switch (dest)
253  {
254  case DestRemote:
255  case DestRemoteExecute:
256  case DestRemoteSimple:
257  {
259 
262  pq_endmessage(&buf);
263  }
264  /* Flush output at end of cycle in any case. */
265  pq_flush();
266  break;
267 
268  case DestNone:
269  case DestDebug:
270  case DestSPI:
271  case DestTuplestore:
272  case DestIntoRel:
273  case DestCopyOut:
274  case DestSQLFunction:
275  case DestTransientRel:
276  case DestTupleQueue:
277  break;
278  }
279 }
#define pq_flush()
Definition: libpq.h:46
static char * buf
Definition: pg_test_fsync.c:73
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:296
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:88
static void pq_sendbyte(StringInfo buf, uint8 byt)
Definition: pqformat.h:160
#define PqMsg_ReadyForQuery
Definition: protocol.h:55
char TransactionBlockStatusCode(void)
Definition: xact.c:4924

References buf, generate_unaccent_rules::dest, DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, pq_beginmessage(), pq_endmessage(), pq_flush, pq_sendbyte(), PqMsg_ReadyForQuery, and TransactionBlockStatusCode().

Referenced by PostgresMain().

Variable Documentation

◆ debugtupDR

const DestReceiver debugtupDR
static
Initial value:
= {
}
static void donothingCleanup(DestReceiver *self)
Definition: dest.c:60
bool debugtup(TupleTableSlot *slot, DestReceiver *self)
Definition: printtup.c:458
void debugStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: printtup.c:440

Definition at line 74 of file dest.c.

Referenced by CreateDestReceiver().

◆ donothingDR

const DestReceiver donothingDR
static
Initial value:
= {
}
static void donothingStartup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: dest.c:55
static bool donothingReceive(TupleTableSlot *slot, DestReceiver *self)
Definition: dest.c:49

Definition at line 69 of file dest.c.

Referenced by CreateDestReceiver().

◆ None_Receiver

◆ printsimpleDR

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

Definition at line 79 of file dest.c.

Referenced by CreateDestReceiver().

◆ spi_printtupDR

const DestReceiver spi_printtupDR
static
Initial value:
= {
}
bool spi_printtup(TupleTableSlot *slot, DestReceiver *self)
Definition: spi.c:2166
void spi_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: spi.c:2118

Definition at line 84 of file dest.c.

Referenced by CreateDestReceiver().