PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pqformat.c File Reference
#include "postgres.h"
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "mb/pg_wchar.h"
Include dependency graph for pqformat.c:

Go to the source code of this file.

Functions

void pq_beginmessage (StringInfo buf, char msgtype)
 
void pq_sendbyte (StringInfo buf, int byt)
 
void pq_sendbytes (StringInfo buf, const char *data, int datalen)
 
void pq_sendcountedtext (StringInfo buf, const char *str, int slen, bool countincludesself)
 
void pq_sendtext (StringInfo buf, const char *str, int slen)
 
void pq_sendstring (StringInfo buf, const char *str)
 
void pq_send_ascii_string (StringInfo buf, const char *str)
 
void pq_sendint (StringInfo buf, int i, int b)
 
void pq_sendint64 (StringInfo buf, int64 i)
 
void pq_sendfloat4 (StringInfo buf, float4 f)
 
void pq_sendfloat8 (StringInfo buf, float8 f)
 
void pq_endmessage (StringInfo buf)
 
void pq_begintypsend (StringInfo buf)
 
byteapq_endtypsend (StringInfo buf)
 
void pq_puttextmessage (char msgtype, const char *str)
 
void pq_putemptymessage (char msgtype)
 
int pq_getmsgbyte (StringInfo msg)
 
unsigned int pq_getmsgint (StringInfo msg, int b)
 
int64 pq_getmsgint64 (StringInfo msg)
 
float4 pq_getmsgfloat4 (StringInfo msg)
 
float8 pq_getmsgfloat8 (StringInfo msg)
 
const char * pq_getmsgbytes (StringInfo msg, int datalen)
 
void pq_copymsgbytes (StringInfo msg, char *buf, int datalen)
 
char * pq_getmsgtext (StringInfo msg, int rawbytes, int *nbytes)
 
const char * pq_getmsgstring (StringInfo msg)
 
const char * pq_getmsgrawstring (StringInfo msg)
 
void pq_getmsgend (StringInfo msg)
 

Function Documentation

void pq_beginmessage ( StringInfo  buf,
char  msgtype 
)

Definition at line 88 of file pqformat.c.

References StringInfoData::cursor, and initStringInfo().

Referenced by exec_describe_statement_message(), NotifyMyFrontEnd(), ParallelWorkerMain(), perform_base_backup(), PostgresMain(), printsimple(), printsimple_startup(), printtup(), printtup_20(), printtup_internal_20(), ReadyForQuery(), ReceiveCopyBegin(), ReportGUCOption(), send_message_to_frontend(), sendAuthRequest(), SendBackupHeader(), SendCopyBegin(), SendFunctionResult(), SendRowDescriptionMessage(), SendTimeLineHistory(), SendXlogRecPtrResult(), StartLogicalReplication(), and StartReplication().

89 {
90  initStringInfo(buf);
91 
92  /*
93  * We stash the message type into the buffer's cursor field, expecting
94  * that the pq_sendXXX routines won't touch it. We could alternatively
95  * make it the first byte of the buffer contents, but this seems easier.
96  */
97  buf->cursor = msgtype;
98 }
void initStringInfo(StringInfo str)
Definition: stringinfo.c:65
void pq_copymsgbytes ( StringInfo  msg,
char *  buf,
int  datalen 
)

Definition at line 570 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, and StringInfoData::len.

Referenced by bit_recv(), bytearecv(), CopyGetData(), pq_getmsgint(), pq_getmsgint64(), and varbit_recv().

571 {
572  if (datalen < 0 || datalen > (msg->len - msg->cursor))
573  ereport(ERROR,
574  (errcode(ERRCODE_PROTOCOL_VIOLATION),
575  errmsg("insufficient data left in message")));
576  memcpy(buf, &msg->data[msg->cursor], datalen);
577  msg->cursor += datalen;
578 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
static char * buf
Definition: pg_test_fsync.c:65
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
void pq_endmessage ( StringInfo  buf)

Definition at line 344 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, StringInfoData::len, NULL, pfree(), and pq_putmessage.

Referenced by exec_describe_statement_message(), HandleParallelMessage(), NotifyMyFrontEnd(), ParallelWorkerMain(), perform_base_backup(), PostgresMain(), printsimple(), printsimple_startup(), printtup(), printtup_20(), printtup_internal_20(), ReadyForQuery(), ReceiveCopyBegin(), ReportGUCOption(), send_message_to_frontend(), sendAuthRequest(), SendBackupHeader(), SendCopyBegin(), SendFunctionResult(), SendRowDescriptionMessage(), SendTimeLineHistory(), SendXlogRecPtrResult(), StartLogicalReplication(), and StartReplication().

345 {
346  /* msgtype was saved in cursor field */
347  (void) pq_putmessage(buf->cursor, buf->data, buf->len);
348  /* no need to complain about any failure, since pqcomm.c already did */
349  pfree(buf->data);
350  buf->data = NULL;
351 }
void pfree(void *pointer)
Definition: mcxt.c:992
#define NULL
Definition: c.h:226
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:43
bytea* pq_endtypsend ( StringInfo  buf)
int pq_getmsgbyte ( StringInfo  msg)

Definition at line 432 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, and StringInfoData::len.

Referenced by apply_dispatch(), ApplyLoop(), boolrecv(), charrecv(), HandleParallelMessage(), logicalrep_read_attrs(), logicalrep_read_commit(), logicalrep_read_delete(), logicalrep_read_insert(), logicalrep_read_rel(), logicalrep_read_tuple(), logicalrep_read_update(), macaddr_recv(), network_recv(), path_recv(), PostgresMain(), pq_parse_errornotice(), ProcessStandbyMessage(), ProcessStandbyReplyMessage(), range_recv(), and XLogWalRcvProcessMsg().

433 {
434  if (msg->cursor >= msg->len)
435  ereport(ERROR,
436  (errcode(ERRCODE_PROTOCOL_VIOLATION),
437  errmsg("no data left in message")));
438  return (unsigned char) msg->data[msg->cursor++];
439 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
const char* pq_getmsgbytes ( StringInfo  msg,
int  datalen 
)

Definition at line 550 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, and StringInfoData::len.

Referenced by exec_bind_message(), logicalrep_read_tuple(), parse_fcall_arguments(), parse_fcall_arguments_20(), range_recv(), uuid_recv(), and xml_recv().

551 {
552  const char *result;
553 
554  if (datalen < 0 || datalen > (msg->len - msg->cursor))
555  ereport(ERROR,
556  (errcode(ERRCODE_PROTOCOL_VIOLATION),
557  errmsg("insufficient data left in message")));
558  result = &msg->data[msg->cursor];
559  msg->cursor += datalen;
560  return result;
561 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
void pq_getmsgend ( StringInfo  msg)

Definition at line 677 of file pqformat.c.

References StringInfoData::cursor, ereport, errcode(), errmsg(), ERROR, and StringInfoData::len.

Referenced by exec_bind_message(), HandleFunctionRequest(), HandleParallelMessage(), int8_avg_deserialize(), numeric_avg_deserialize(), numeric_deserialize(), numeric_poly_deserialize(), PostgresMain(), pq_parse_errornotice(), and range_recv().

678 {
679  if (msg->cursor != msg->len)
680  ereport(ERROR,
681  (errcode(ERRCODE_PROTOCOL_VIOLATION),
682  errmsg("invalid message format")));
683 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
float4 pq_getmsgfloat4 ( StringInfo  msg)

Definition at line 511 of file pqformat.c.

References i, pq_getmsgint(), and swap.

Referenced by float4recv().

512 {
513  union
514  {
515  float4 f;
516  uint32 i;
517  } swap;
518 
519  swap.i = pq_getmsgint(msg, 4);
520  return swap.f;
521 }
#define swap(a, b)
Definition: qsort.c:94
unsigned int uint32
Definition: c.h:265
float float4
Definition: c.h:376
int i
unsigned int pq_getmsgint(StringInfo msg, int b)
Definition: pqformat.c:448
float8 pq_getmsgfloat8 ( StringInfo  msg)

Definition at line 530 of file pqformat.c.

References i, pq_getmsgint64(), and swap.

Referenced by box_recv(), circle_recv(), complex_recv(), float8recv(), interval_recv(), line_recv(), lseg_recv(), path_recv(), point_recv(), poly_recv(), time_recv(), timestamp_recv(), timestamptz_recv(), and timetz_recv().

531 {
532  union
533  {
534  float8 f;
535  int64 i;
536  } swap;
537 
538  swap.i = pq_getmsgint64(msg);
539  return swap.f;
540 }
#define swap(a, b)
Definition: qsort.c:94
double float8
Definition: c.h:377
int i
int64 pq_getmsgint64(StringInfo msg)
Definition: pqformat.c:486
unsigned int pq_getmsgint ( StringInfo  msg,
int  b 
)

Definition at line 448 of file pqformat.c.

References elog, ERROR, and pq_copymsgbytes().

Referenced by abstimerecv(), array_recv(), bit_recv(), cidrecv(), date_recv(), exec_bind_message(), HandleFunctionRequest(), HandleParallelMessage(), hstore_recv(), int2recv(), int4recv(), interval_recv(), jsonb_recv(), logicalrep_read_attrs(), logicalrep_read_begin(), logicalrep_read_delete(), logicalrep_read_insert(), logicalrep_read_rel(), logicalrep_read_tuple(), logicalrep_read_typ(), logicalrep_read_update(), numeric_avg_deserialize(), numeric_deserialize(), numeric_recv(), oidrecv(), parse_fcall_arguments(), parse_fcall_arguments_20(), path_recv(), poly_recv(), PostgresMain(), pq_getmsgfloat4(), ProcessStandbyHSFeedbackMessage(), range_recv(), ReadArrayBinary(), record_recv(), reltimerecv(), tidrecv(), timetz_recv(), tintervalrecv(), tsqueryrecv(), tsvectorrecv(), txid_snapshot_recv(), varbit_recv(), and xidrecv().

449 {
450  unsigned int result;
451  unsigned char n8;
452  uint16 n16;
453  uint32 n32;
454 
455  switch (b)
456  {
457  case 1:
458  pq_copymsgbytes(msg, (char *) &n8, 1);
459  result = n8;
460  break;
461  case 2:
462  pq_copymsgbytes(msg, (char *) &n16, 2);
463  result = ntohs(n16);
464  break;
465  case 4:
466  pq_copymsgbytes(msg, (char *) &n32, 4);
467  result = ntohl(n32);
468  break;
469  default:
470  elog(ERROR, "unsupported integer size %d", b);
471  result = 0; /* keep compiler quiet */
472  break;
473  }
474  return result;
475 }
unsigned short uint16
Definition: c.h:264
#define ERROR
Definition: elog.h:43
unsigned int uint32
Definition: c.h:265
void pq_copymsgbytes(StringInfo msg, char *buf, int datalen)
Definition: pqformat.c:570
#define elog
Definition: elog.h:219
int64 pq_getmsgint64 ( StringInfo  msg)

Definition at line 486 of file pqformat.c.

References pq_copymsgbytes().

Referenced by ApplyLoop(), cash_recv(), int8_avg_deserialize(), int8recv(), interval_recv(), logicalrep_read_begin(), logicalrep_read_commit(), logicalrep_read_origin(), numeric_avg_deserialize(), numeric_deserialize(), numeric_poly_deserialize(), pg_lsn_recv(), pq_getmsgfloat8(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), time_recv(), timestamp_recv(), timestamptz_recv(), timetz_recv(), txid_snapshot_recv(), and XLogWalRcvProcessMsg().

487 {
488  int64 result;
489  uint32 h32;
490  uint32 l32;
491 
492  pq_copymsgbytes(msg, (char *) &h32, 4);
493  pq_copymsgbytes(msg, (char *) &l32, 4);
494  h32 = ntohl(h32);
495  l32 = ntohl(l32);
496 
497  result = h32;
498  result <<= 32;
499  result |= l32;
500 
501  return result;
502 }
unsigned int uint32
Definition: c.h:265
void pq_copymsgbytes(StringInfo msg, char *buf, int datalen)
Definition: pqformat.c:570
const char* pq_getmsgrawstring ( StringInfo  msg)

Definition at line 650 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, and StringInfoData::len.

Referenced by HandleParallelMessage(), and pq_parse_errornotice().

651 {
652  char *str;
653  int slen;
654 
655  str = &msg->data[msg->cursor];
656 
657  /*
658  * It's safe to use strlen() here because a StringInfo is guaranteed to
659  * have a trailing null byte. But check we found a null inside the
660  * message.
661  */
662  slen = strlen(str);
663  if (msg->cursor + slen >= msg->len)
664  ereport(ERROR,
665  (errcode(ERRCODE_PROTOCOL_VIOLATION),
666  errmsg("invalid string in message")));
667  msg->cursor += slen + 1;
668 
669  return str;
670 }
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
const char* pq_getmsgstring ( StringInfo  msg)

Definition at line 621 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, StringInfoData::len, and pg_client_to_server().

Referenced by CopyGetData(), exec_bind_message(), HandleFunctionRequest(), logicalrep_read_attrs(), logicalrep_read_namespace(), logicalrep_read_origin(), logicalrep_read_rel(), logicalrep_read_typ(), PostgresMain(), tsqueryrecv(), and tsvectorrecv().

622 {
623  char *str;
624  int slen;
625 
626  str = &msg->data[msg->cursor];
627 
628  /*
629  * It's safe to use strlen() here because a StringInfo is guaranteed to
630  * have a trailing null byte. But check we found a null inside the
631  * message.
632  */
633  slen = strlen(str);
634  if (msg->cursor + slen >= msg->len)
635  ereport(ERROR,
636  (errcode(ERRCODE_PROTOCOL_VIOLATION),
637  errmsg("invalid string in message")));
638  msg->cursor += slen + 1;
639 
640  return pg_client_to_server(str, slen);
641 }
int errcode(int sqlerrcode)
Definition: elog.c:575
char * pg_client_to_server(const char *s, int len)
Definition: mbutils.c:556
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
int errmsg(const char *fmt,...)
Definition: elog.c:797
char* pq_getmsgtext ( StringInfo  msg,
int  rawbytes,
int *  nbytes 
)

Definition at line 588 of file pqformat.c.

References StringInfoData::cursor, StringInfoData::data, ereport, errcode(), errmsg(), ERROR, StringInfoData::len, palloc(), and pg_client_to_server().

Referenced by bpcharrecv(), cstring_recv(), enum_recv(), hstore_recv(), json_recv(), jsonb_recv(), namerecv(), textrecv(), unknownrecv(), and varcharrecv().

589 {
590  char *str;
591  char *p;
592 
593  if (rawbytes < 0 || rawbytes > (msg->len - msg->cursor))
594  ereport(ERROR,
595  (errcode(ERRCODE_PROTOCOL_VIOLATION),
596  errmsg("insufficient data left in message")));
597  str = &msg->data[msg->cursor];
598  msg->cursor += rawbytes;
599 
600  p = pg_client_to_server(str, rawbytes);
601  if (p != str) /* actual conversion has been done? */
602  *nbytes = strlen(p);
603  else
604  {
605  p = (char *) palloc(rawbytes + 1);
606  memcpy(p, str, rawbytes);
607  p[rawbytes] = '\0';
608  *nbytes = rawbytes;
609  }
610  return p;
611 }
int errcode(int sqlerrcode)
Definition: elog.c:575
char * pg_client_to_server(const char *s, int len)
Definition: mbutils.c:556
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void * palloc(Size size)
Definition: mcxt.c:891
int errmsg(const char *fmt,...)
Definition: elog.c:797
void pq_putemptymessage ( char  msgtype)

Definition at line 421 of file pqformat.c.

References NULL, and pq_putmessage.

Referenced by exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_execute_message(), exec_parse_message(), NullCommand(), perform_base_backup(), PostgresMain(), ReadyForQuery(), ReceiveCopyBegin(), SendCopyBegin(), and SendCopyEnd().

422 {
423  (void) pq_putmessage(msgtype, NULL, 0);
424 }
#define NULL
Definition: c.h:226
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:43
void pq_puttextmessage ( char  msgtype,
const char *  str 
)

Definition at line 400 of file pqformat.c.

References pfree(), pg_server_to_client(), and pq_putmessage.

Referenced by printtup_startup(), SendBackupHeader(), SendXlogRecPtrResult(), and StartReplication().

401 {
402  int slen = strlen(str);
403  char *p;
404 
405  p = pg_server_to_client(str, slen);
406  if (p != str) /* actual conversion has been done? */
407  {
408  (void) pq_putmessage(msgtype, p, strlen(p) + 1);
409  pfree(p);
410  return;
411  }
412  (void) pq_putmessage(msgtype, str, slen + 1);
413 }
char * pg_server_to_client(const char *s, int len)
Definition: mbutils.c:634
void pfree(void *pointer)
Definition: mcxt.c:992
#define pq_putmessage(msgtype, s, len)
Definition: libpq.h:43
void pq_send_ascii_string ( StringInfo  buf,
const char *  str 
)

Definition at line 218 of file pqformat.c.

References appendStringInfoChar(), appendStringInfoCharMacro, and IS_HIGHBIT_SET.

Referenced by err_sendstring().

219 {
220  while (*str)
221  {
222  char ch = *str++;
223 
224  if (IS_HIGHBIT_SET(ch))
225  ch = '?';
226  appendStringInfoCharMacro(buf, ch);
227  }
228  appendStringInfoChar(buf, '\0');
229 }
#define appendStringInfoCharMacro(str, ch)
Definition: stringinfo.h:135
#define IS_HIGHBIT_SET(ch)
Definition: c.h:968
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:201
void pq_sendbytes ( StringInfo  buf,
const char *  data,
int  datalen 
)
void pq_sendcountedtext ( StringInfo  buf,
const char *  str,
int  slen,
bool  countincludesself 
)

Definition at line 131 of file pqformat.c.

References appendBinaryStringInfo(), pfree(), pg_server_to_client(), and pq_sendint().

Referenced by printsimple(), printtup(), printtup_20(), and SendFunctionResult().

133 {
134  int extra = countincludesself ? 4 : 0;
135  char *p;
136 
137  p = pg_server_to_client(str, slen);
138  if (p != str) /* actual conversion has been done? */
139  {
140  slen = strlen(p);
141  pq_sendint(buf, slen + extra, 4);
142  appendBinaryStringInfo(buf, p, slen);
143  pfree(p);
144  }
145  else
146  {
147  pq_sendint(buf, slen + extra, 4);
148  appendBinaryStringInfo(buf, str, slen);
149  }
150 }
char * pg_server_to_client(const char *s, int len)
Definition: mbutils.c:634
void pfree(void *pointer)
Definition: mcxt.c:992
void pq_sendint(StringInfo buf, int i, int b)
Definition: pqformat.c:236
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240
void pq_sendfloat4 ( StringInfo  buf,
float4  f 
)

Definition at line 298 of file pqformat.c.

References appendBinaryStringInfo(), i, and swap.

Referenced by float4send().

299 {
300  union
301  {
302  float4 f;
303  uint32 i;
304  } swap;
305 
306  swap.f = f;
307  swap.i = htonl(swap.i);
308 
309  appendBinaryStringInfo(buf, (char *) &swap.i, 4);
310 }
#define swap(a, b)
Definition: qsort.c:94
unsigned int uint32
Definition: c.h:265
float float4
Definition: c.h:376
int i
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240
void pq_sendfloat8 ( StringInfo  buf,
float8  f 
)

Definition at line 324 of file pqformat.c.

References i, pq_sendint64(), and swap.

Referenced by box_send(), circle_send(), complex_send(), float8send(), interval_send(), line_send(), lseg_send(), path_send(), point_send(), poly_send(), time_send(), timestamp_send(), timestamptz_send(), and timetz_send().

325 {
326  union
327  {
328  float8 f;
329  int64 i;
330  } swap;
331 
332  swap.f = f;
333  pq_sendint64(buf, swap.i);
334 }
#define swap(a, b)
Definition: qsort.c:94
double float8
Definition: c.h:377
int i
void pq_sendint64(StringInfo buf, int64 i)
Definition: pqformat.c:271
void pq_sendint ( StringInfo  buf,
int  i,
int  b 
)

Definition at line 236 of file pqformat.c.

References appendBinaryStringInfo(), elog, and ERROR.

Referenced by abstimesend(), array_send(), cidsend(), date_send(), exec_describe_statement_message(), hstore_send(), int2send(), int4send(), interval_send(), jsonb_send(), logicalrep_write_attrs(), logicalrep_write_begin(), logicalrep_write_delete(), logicalrep_write_insert(), logicalrep_write_rel(), logicalrep_write_tuple(), logicalrep_write_typ(), logicalrep_write_update(), NotifyMyFrontEnd(), numeric_avg_serialize(), numeric_send(), numeric_serialize(), oidsend(), ParallelWorkerMain(), path_send(), perform_base_backup(), poly_send(), PostgresMain(), pq_sendcountedtext(), printsimple(), printsimple_startup(), printtup(), printtup_20(), printtup_internal_20(), range_send(), ReceiveCopyBegin(), record_send(), reltimesend(), send_int8_string(), sendAuthRequest(), SendBackupHeader(), SendCopyBegin(), SendFunctionResult(), SendRowDescriptionMessage(), SendTimeLineHistory(), SendXlogRecPtrResult(), StartLogicalReplication(), StartReplication(), tidsend(), timetz_send(), tintervalsend(), tsquerysend(), tsvectorsend(), txid_snapshot_send(), varbit_send(), xidsend(), and XLogWalRcvSendHSFeedback().

237 {
238  unsigned char n8;
239  uint16 n16;
240  uint32 n32;
241 
242  switch (b)
243  {
244  case 1:
245  n8 = (unsigned char) i;
246  appendBinaryStringInfo(buf, (char *) &n8, 1);
247  break;
248  case 2:
249  n16 = htons((uint16) i);
250  appendBinaryStringInfo(buf, (char *) &n16, 2);
251  break;
252  case 4:
253  n32 = htonl((uint32) i);
254  appendBinaryStringInfo(buf, (char *) &n32, 4);
255  break;
256  default:
257  elog(ERROR, "unsupported integer size %d", b);
258  break;
259  }
260 }
unsigned short uint16
Definition: c.h:264
#define ERROR
Definition: elog.h:43
unsigned int uint32
Definition: c.h:265
int i
#define elog
Definition: elog.h:219
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240
void pq_sendint64 ( StringInfo  buf,
int64  i 
)

Definition at line 271 of file pqformat.c.

References appendBinaryStringInfo().

Referenced by cash_send(), int8_avg_serialize(), int8send(), interval_send(), logicalrep_write_begin(), logicalrep_write_commit(), logicalrep_write_origin(), numeric_avg_serialize(), numeric_poly_serialize(), numeric_serialize(), pg_lsn_send(), pq_sendfloat8(), send_feedback(), time_send(), timestamp_send(), timestamptz_send(), timetz_send(), txid_snapshot_send(), WalSndKeepalive(), WalSndPrepareWrite(), WalSndWriteData(), XLogSendPhysical(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().

272 {
273  uint32 n32;
274 
275  /* High order half first, since we're doing MSB-first */
276  n32 = (uint32) (i >> 32);
277  n32 = htonl(n32);
278  appendBinaryStringInfo(buf, (char *) &n32, 4);
279 
280  /* Now the low order half */
281  n32 = (uint32) i;
282  n32 = htonl(n32);
283  appendBinaryStringInfo(buf, (char *) &n32, 4);
284 }
unsigned int uint32
Definition: c.h:265
int i
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240
void pq_sendstring ( StringInfo  buf,
const char *  str 
)

Definition at line 186 of file pqformat.c.

References appendBinaryStringInfo(), pfree(), and pg_server_to_client().

Referenced by err_sendstring(), logicalrep_write_attrs(), logicalrep_write_namespace(), logicalrep_write_origin(), logicalrep_write_rel(), logicalrep_write_typ(), NotifyMyFrontEnd(), printsimple_startup(), ReportGUCOption(), SendBackupHeader(), SendRowDescriptionMessage(), SendTimeLineHistory(), SendXlogRecPtrResult(), and tsquerysend().

187 {
188  int slen = strlen(str);
189  char *p;
190 
191  p = pg_server_to_client(str, slen);
192  if (p != str) /* actual conversion has been done? */
193  {
194  slen = strlen(p);
195  appendBinaryStringInfo(buf, p, slen + 1);
196  pfree(p);
197  }
198  else
199  appendBinaryStringInfo(buf, str, slen + 1);
200 }
char * pg_server_to_client(const char *s, int len)
Definition: mbutils.c:634
void pfree(void *pointer)
Definition: mcxt.c:992
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240
void pq_sendtext ( StringInfo  buf,
const char *  str,
int  slen 
)

Definition at line 163 of file pqformat.c.

References appendBinaryStringInfo(), pfree(), and pg_server_to_client().

Referenced by cstring_send(), enum_send(), hstore_send(), json_send(), jsonb_send(), namesend(), textsend(), tsvectorsend(), unknownsend(), and xml_send().

164 {
165  char *p;
166 
167  p = pg_server_to_client(str, slen);
168  if (p != str) /* actual conversion has been done? */
169  {
170  slen = strlen(p);
171  appendBinaryStringInfo(buf, p, slen);
172  pfree(p);
173  }
174  else
175  appendBinaryStringInfo(buf, str, slen);
176 }
char * pg_server_to_client(const char *s, int len)
Definition: mbutils.c:634
void pfree(void *pointer)
Definition: mcxt.c:992
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:240