PostgreSQL Source Code  git master
dest.h File Reference
#include "executor/tuptable.h"
#include "tcop/cmdtag.h"
Include dependency graph for dest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _DestReceiver
 

Macros

#define COMPLETION_TAG_BUFSIZE   64
 

Typedefs

typedef struct _DestReceiver DestReceiver
 

Enumerations

enum  CommandDest {
  DestNone , DestDebug , DestRemote , DestRemoteExecute ,
  DestRemoteSimple , DestSPI , DestTuplestore , DestIntoRel ,
  DestCopyOut , DestSQLFunction , DestTransientRel , DestTupleQueue
}
 

Functions

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

PGDLLIMPORT DestReceiverNone_Receiver
 

Macro Definition Documentation

◆ COMPLETION_TAG_BUFSIZE

#define COMPLETION_TAG_BUFSIZE   64

Definition at line 75 of file dest.h.

Typedef Documentation

◆ DestReceiver

typedef struct _DestReceiver DestReceiver

Definition at line 1 of file dest.h.

Enumeration Type Documentation

◆ CommandDest

Enumerator
DestNone 
DestDebug 
DestRemote 
DestRemoteExecute 
DestRemoteSimple 
DestSPI 
DestTuplestore 
DestIntoRel 
DestCopyOut 
DestSQLFunction 
DestTransientRel 
DestTupleQueue 

Definition at line 87 of file dest.h.

88 {
89  DestNone, /* results are discarded */
90  DestDebug, /* results go to debugging output */
91  DestRemote, /* results sent to frontend process */
92  DestRemoteExecute, /* sent to frontend, in Execute command */
93  DestRemoteSimple, /* sent to frontend, w/no catalog access */
94  DestSPI, /* results sent to SPI manager */
95  DestTuplestore, /* results sent to Tuplestore */
96  DestIntoRel, /* results sent to relation (SELECT INTO) */
97  DestCopyOut, /* results sent to COPY TO code */
98  DestSQLFunction, /* results sent to SQL-language func mgr */
99  DestTransientRel, /* results sent to transient relation */
100  DestTupleQueue /* results sent to tuple queue */
101 } CommandDest;
CommandDest
Definition: dest.h:88
@ DestSQLFunction
Definition: dest.h:98
@ DestTupleQueue
Definition: dest.h:100
@ DestTuplestore
Definition: dest.h:95
@ DestRemote
Definition: dest.h:91
@ DestDebug
Definition: dest.h:90
@ DestRemoteSimple
Definition: dest.h:93
@ DestCopyOut
Definition: dest.h:97
@ DestTransientRel
Definition: dest.h:99
@ DestSPI
Definition: dest.h:94
@ DestIntoRel
Definition: dest.h:96
@ DestRemoteExecute
Definition: dest.h:92
@ DestNone
Definition: dest.h:89

Function Documentation

◆ BeginCommand()

void BeginCommand ( CommandTag  commandTag,
CommandDest  dest 
)

Definition at line 103 of file dest.c.

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

Referenced by exec_execute_message(), and exec_simple_query().

◆ CreateDestReceiver()

DestReceiver* CreateDestReceiver ( CommandDest  dest)

Definition at line 113 of file dest.c.

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 unconstify(underlying_type, expr)
Definition: c.h:1240
#define pg_unreachable()
Definition: c.h:258
DestReceiver * CreateCopyDestReceiver(void)
Definition: copyto.c:1296
DestReceiver * CreateIntoRelDestReceiver(IntoClause *intoClause)
Definition: createas.c:428
static const DestReceiver spi_printtupDR
Definition: dest.c:85
static const DestReceiver debugtupDR
Definition: dest.c:75
static const DestReceiver donothingDR
Definition: dest.c:70
static const DestReceiver printsimpleDR
Definition: dest.c:80
DestReceiver * CreateSQLFunctionDestReceiver(void)
Definition: functions.c:2046
DestReceiver * CreateTransientRelDestReceiver(Oid transientoid)
Definition: matview.c:443
#define InvalidOid
Definition: postgres_ext.h:36
DestReceiver * printtup_create_DR(CommandDest dest)
Definition: printtup.c:71
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(), SPI_cursor_fetch(), SPI_scroll_cursor_fetch(), and StartReplication().

◆ EndCommand()

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

Definition at line 166 of file dest.c.

167 {
168  char completionTag[COMPLETION_TAG_BUFSIZE];
169  CommandTag tag;
170  const char *tagname;
171 
172  switch (dest)
173  {
174  case DestRemote:
175  case DestRemoteExecute:
176  case DestRemoteSimple:
177 
178  /*
179  * We assume the tagname is plain ASCII and therefore requires no
180  * encoding conversion.
181  *
182  * We no longer display LastOid, but to preserve the wire
183  * protocol, we write InvalidOid where the LastOid used to be
184  * written.
185  *
186  * All cases where LastOid was written also write nprocessed
187  * count, so just Assert that rather than having an extra test.
188  */
189  tag = qc->commandTag;
190  tagname = GetCommandTagName(tag);
191 
192  if (command_tag_display_rowcount(tag) && !force_undecorated_output)
193  snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
194  tag == CMDTAG_INSERT ?
195  "%s 0 " UINT64_FORMAT : "%s " UINT64_FORMAT,
196  tagname, qc->nprocessed);
197  else
198  snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s", tagname);
199  pq_putmessage('C', completionTag, strlen(completionTag) + 1);
200 
201  case DestNone:
202  case DestDebug:
203  case DestSPI:
204  case DestTuplestore:
205  case DestIntoRel:
206  case DestCopyOut:
207  case DestSQLFunction:
208  case DestTransientRel:
209  case DestTupleQueue:
210  break;
211  }
212 }
#define UINT64_FORMAT
Definition: c.h:484
bool command_tag_display_rowcount(CommandTag commandTag)
Definition: cmdtag.c:51
const char * GetCommandTagName(CommandTag commandTag)
Definition: cmdtag.c:45
CommandTag
Definition: cmdtag.h:21
#define COMPLETION_TAG_BUFSIZE
Definition: dest.h:75
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:49
#define snprintf
Definition: port.h:222
uint64 nprocessed
Definition: cmdtag.h:31
CommandTag commandTag
Definition: cmdtag.h:30

References command_tag_display_rowcount(), QueryCompletion::commandTag, COMPLETION_TAG_BUFSIZE, generate_unaccent_rules::dest, DestCopyOut, DestDebug, DestIntoRel, DestNone, DestRemote, DestRemoteExecute, DestRemoteSimple, DestSPI, DestSQLFunction, DestTransientRel, DestTupleQueue, DestTuplestore, GetCommandTagName(), QueryCompletion::nprocessed, pq_putmessage, snprintf, and UINT64_FORMAT.

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

◆ EndReplicationCommand()

void EndReplicationCommand ( const char *  commandTag)

Definition at line 221 of file dest.c.

222 {
223  pq_putmessage('C', commandTag, strlen(commandTag) + 1);
224 }

References pq_putmessage.

Referenced by exec_replication_command(), and StartReplication().

◆ NullCommand()

void NullCommand ( CommandDest  dest)

Definition at line 234 of file dest.c.

235 {
236  switch (dest)
237  {
238  case DestRemote:
239  case DestRemoteExecute:
240  case DestRemoteSimple:
241 
242  /* Tell the FE that we saw an empty query string */
243  pq_putemptymessage('I');
244  break;
245 
246  case DestNone:
247  case DestDebug:
248  case DestSPI:
249  case DestTuplestore:
250  case DestIntoRel:
251  case DestCopyOut:
252  case DestSQLFunction:
253  case DestTransientRel:
254  case DestTupleQueue:
255  break;
256  }
257 }
void pq_putemptymessage(char msgtype)
Definition: pqformat.c:390

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

Referenced by exec_execute_message(), and exec_simple_query().

◆ ReadyForQuery()

void ReadyForQuery ( CommandDest  dest)

Definition at line 271 of file dest.c.

272 {
273  switch (dest)
274  {
275  case DestRemote:
276  case DestRemoteExecute:
277  case DestRemoteSimple:
278  {
280 
281  pq_beginmessage(&buf, 'Z');
283  pq_endmessage(&buf);
284  }
285  /* Flush output at end of cycle in any case. */
286  pq_flush();
287  break;
288 
289  case DestNone:
290  case DestDebug:
291  case DestSPI:
292  case DestTuplestore:
293  case DestIntoRel:
294  case DestCopyOut:
295  case DestSQLFunction:
296  case DestTransientRel:
297  case DestTupleQueue:
298  break;
299  }
300 }
#define pq_flush()
Definition: libpq.h:46
static char * buf
Definition: pg_test_fsync.c:70
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:298
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:87
static void pq_sendbyte(StringInfo buf, uint8 byt)
Definition: pqformat.h:161
char TransactionBlockStatusCode(void)
Definition: xact.c:4786

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(), and TransactionBlockStatusCode().

Referenced by PostgresMain().

Variable Documentation

◆ None_Receiver