PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 DestReceiver donothingDR
 
static DestReceiver debugtupDR
 
static DestReceiver printsimpleDR
 
static DestReceiver spi_printtupDR
 
DestReceiverNone_Receiver = &donothingDR
 

Function Documentation

void BeginCommand ( const char *  commandTag,
CommandDest  dest 
)

Definition at line 99 of file dest.c.

Referenced by exec_execute_message(), and exec_simple_query().

100 {
101  /* Nothing to do at present */
102 }
DestReceiver* CreateDestReceiver ( CommandDest  dest)

Definition at line 109 of file dest.c.

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

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().

110 {
111  switch (dest)
112  {
113  case DestRemote:
114  case DestRemoteExecute:
115  return printtup_create_DR(dest);
116 
117  case DestRemoteSimple:
118  return &printsimpleDR;
119 
120  case DestNone:
121  return &donothingDR;
122 
123  case DestDebug:
124  return &debugtupDR;
125 
126  case DestSPI:
127  return &spi_printtupDR;
128 
129  case DestTuplestore:
131 
132  case DestIntoRel:
134 
135  case DestCopyOut:
136  return CreateCopyDestReceiver();
137 
138  case DestSQLFunction:
140 
141  case DestTransientRel:
143 
144  case DestTupleQueue:
146  }
147 
148  /* should never get here */
149  return &donothingDR;
150 }
Definition: dest.h:93
static DestReceiver debugtupDR
Definition: dest.c:75
Definition: dest.h:88
DestReceiver * printtup_create_DR(CommandDest dest)
Definition: printtup.c:73
Definition: dest.h:89
static DestReceiver donothingDR
Definition: dest.c:70
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
Definition: createas.c:423
static DestReceiver spi_printtupDR
Definition: dest.c:85
DestReceiver * CreateSQLFunctionDestReceiver(void)
Definition: functions.c:1884
#define InvalidOid
Definition: postgres_ext.h:36
#define NULL
Definition: c.h:229
DestReceiver * CreateTuplestoreDestReceiver(void)
DestReceiver * CreateTransientRelDestReceiver(Oid transientoid)
Definition: matview.c:443
DestReceiver * CreateCopyDestReceiver(void)
Definition: copy.c:4757
DestReceiver * CreateTupleQueueDestReceiver(shm_mq_handle *handle)
Definition: tqueue.c:606
static DestReceiver printsimpleDR
Definition: dest.c:80
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 }
static bool donothingReceive ( TupleTableSlot slot,
DestReceiver self 
)
static

Definition at line 50 of file dest.c.

51 {
52  return true;
53 }
static void donothingStartup ( DestReceiver self,
int  operation,
TupleDesc  typeinfo 
)
static

Definition at line 56 of file dest.c.

57 {
58 }
void EndCommand ( const char *  commandTag,
CommandDest  dest 
)

Definition at line 157 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().

158 {
159  switch (dest)
160  {
161  case DestRemote:
162  case DestRemoteExecute:
163  case DestRemoteSimple:
164 
165  /*
166  * We assume the commandTag is plain ASCII and therefore requires
167  * no encoding conversion.
168  */
169  pq_putmessage('C', commandTag, strlen(commandTag) + 1);
170  break;
171 
172  case DestNone:
173  case DestDebug:
174  case DestSPI:
175  case DestTuplestore:
176  case DestIntoRel:
177  case DestCopyOut:
178  case DestSQLFunction:
179  case DestTransientRel:
180  case DestTupleQueue:
181  break;
182  }
183 }
Definition: dest.h:93
Definition: dest.h:88
Definition: dest.h:89
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:42
void NullCommand ( CommandDest  dest)

Definition at line 198 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().

199 {
200  switch (dest)
201  {
202  case DestRemote:
203  case DestRemoteExecute:
204  case DestRemoteSimple:
205 
206  /*
207  * tell the fe that we saw an empty query string. In protocols
208  * before 3.0 this has a useless empty-string message body.
209  */
211  pq_putemptymessage('I');
212  else
213  pq_putmessage('I', "", 1);
214  break;
215 
216  case DestNone:
217  case DestDebug:
218  case DestSPI:
219  case DestTuplestore:
220  case DestIntoRel:
221  case DestCopyOut:
222  case DestSQLFunction:
223  case DestTransientRel:
224  case DestTupleQueue:
225  break;
226  }
227 }
Definition: dest.h:93
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:421
#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:27
void ReadyForQuery ( CommandDest  dest)

Definition at line 241 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().

242 {
243  switch (dest)
244  {
245  case DestRemote:
246  case DestRemoteExecute:
247  case DestRemoteSimple:
249  {
251 
252  pq_beginmessage(&buf, 'Z');
254  pq_endmessage(&buf);
255  }
256  else
257  pq_putemptymessage('Z');
258  /* Flush output at end of cycle in any case. */
259  pq_flush();
260  break;
261 
262  case DestNone:
263  case DestDebug:
264  case DestSPI:
265  case DestTuplestore:
266  case DestIntoRel:
267  case DestCopyOut:
268  case DestSQLFunction:
269  case DestTransientRel:
270  case DestTupleQueue:
271  break;
272  }
273 }
#define pq_flush()
Definition: libpq.h:39
void pq_sendbyte(StringInfo buf, int byt)
Definition: pqformat.c:105
Definition: dest.h:93
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:421
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
char TransactionBlockStatusCode(void)
Definition: xact.c:4337
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:88
Definition: dest.h:88
static char * buf
Definition: pg_test_fsync.c:66
Definition: dest.h:89
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:344
ProtocolVersion FrontendProtocol
Definition: globals.c:27

Variable Documentation

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

Definition at line 75 of file dest.c.

Referenced by CreateDestReceiver().

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.

Referenced by CreateDestReceiver().

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

Definition at line 80 of file dest.c.

Referenced by CreateDestReceiver().

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

Definition at line 85 of file dest.c.

Referenced by CreateDestReceiver().