PostgreSQL Source Code git master
pqformat.h File Reference
#include "lib/stringinfo.h"
#include "mb/pg_wchar.h"
#include "port/pg_bswap.h"
Include dependency graph for pqformat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pq_beginmessage (StringInfo buf, char msgtype)
 
void pq_beginmessage_reuse (StringInfo buf, char msgtype)
 
void pq_endmessage (StringInfo buf)
 
void pq_endmessage_reuse (StringInfo buf)
 
void pq_sendbytes (StringInfo buf, const void *data, int datalen)
 
void pq_sendcountedtext (StringInfo buf, const char *str, int slen)
 
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_sendfloat4 (StringInfo buf, float4 f)
 
void pq_sendfloat8 (StringInfo buf, float8 f)
 
static void pq_writeint8 (StringInfoData *pg_restrict buf, uint8 i)
 
static void pq_writeint16 (StringInfoData *pg_restrict buf, uint16 i)
 
static void pq_writeint32 (StringInfoData *pg_restrict buf, uint32 i)
 
static void pq_writeint64 (StringInfoData *pg_restrict buf, uint64 i)
 
static void pq_writestring (StringInfoData *pg_restrict buf, const char *pg_restrict str)
 
static void pq_sendint8 (StringInfo buf, uint8 i)
 
static void pq_sendint16 (StringInfo buf, uint16 i)
 
static void pq_sendint32 (StringInfo buf, uint32 i)
 
static void pq_sendint64 (StringInfo buf, uint64 i)
 
static void pq_sendbyte (StringInfo buf, uint8 byt)
 
static void pq_sendint (StringInfo buf, uint32 i, int b)
 
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

◆ pq_beginmessage()

void pq_beginmessage ( StringInfo  buf,
char  msgtype 
)

Definition at line 88 of file pqformat.c.

89{
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}
static char * buf
Definition: pg_test_fsync.c:72
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97

References buf, and initStringInfo().

Referenced by bbsink_copystream_archive_contents(), bbsink_copystream_begin_archive(), bbsink_copystream_begin_manifest(), bbsink_copystream_end_archive(), NotifyMyFrontEnd(), pgstat_progress_parallel_incr_param(), PostgresMain(), printsimple(), printsimple_startup(), ReadyForQuery(), ReceiveCopyBegin(), ReportGUCOption(), send_message_to_frontend(), sendAuthRequest(), SendCopyBegin(), SendCopyOutResponse(), SendFunctionResult(), SendNegotiateProtocolVersion(), SendTimeLineHistory(), StartLogicalReplication(), StartReplication(), and UploadManifest().

◆ pq_beginmessage_reuse()

void pq_beginmessage_reuse ( StringInfo  buf,
char  msgtype 
)

Definition at line 109 of file pqformat.c.

110{
112
113 /*
114 * We stash the message type into the buffer's cursor field, expecting
115 * that the pq_sendXXX routines won't touch it. We could alternatively
116 * make it the first byte of the buffer contents, but this seems easier.
117 */
118 buf->cursor = msgtype;
119}
void resetStringInfo(StringInfo str)
Definition: stringinfo.c:126

References buf, and resetStringInfo().

Referenced by exec_describe_statement_message(), printtup(), SendRowDescriptionMessage(), and serializeAnalyzeReceive().

◆ pq_begintypsend()

void pq_begintypsend ( StringInfo  buf)

◆ pq_copymsgbytes()

void pq_copymsgbytes ( StringInfo  msg,
char *  buf,
int  datalen 
)

Definition at line 528 of file pqformat.c.

529{
530 if (datalen < 0 || datalen > (msg->len - msg->cursor))
532 (errcode(ERRCODE_PROTOCOL_VIOLATION),
533 errmsg("insufficient data left in message")));
534 memcpy(buf, &msg->data[msg->cursor], datalen);
535 msg->cursor += datalen;
536}
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149

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

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

◆ pq_endmessage()

void pq_endmessage ( StringInfo  buf)

◆ pq_endmessage_reuse()

void pq_endmessage_reuse ( StringInfo  buf)

Definition at line 314 of file pqformat.c.

315{
316 /* msgtype was saved in cursor field */
317 (void) pq_putmessage(buf->cursor, buf->data, buf->len);
318}

References buf, and pq_putmessage.

Referenced by exec_describe_statement_message(), printtup(), SendRowDescriptionMessage(), and UploadManifest().

◆ pq_endtypsend()

bytea * pq_endtypsend ( StringInfo  buf)

◆ pq_getmsgbyte()

◆ pq_getmsgbytes()

const char * pq_getmsgbytes ( StringInfo  msg,
int  datalen 
)

Definition at line 508 of file pqformat.c.

509{
510 const char *result;
511
512 if (datalen < 0 || datalen > (msg->len - msg->cursor))
514 (errcode(ERRCODE_PROTOCOL_VIOLATION),
515 errmsg("insufficient data left in message")));
516 result = &msg->data[msg->cursor];
517 msg->cursor += datalen;
518 return result;
519}

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

Referenced by array_agg_array_deserialize(), array_agg_deserialize(), CheckSASLAuth(), exec_bind_message(), multirange_recv(), parse_fcall_arguments(), range_recv(), string_agg_deserialize(), uuid_recv(), and xml_recv().

◆ pq_getmsgend()

◆ pq_getmsgfloat4()

float4 pq_getmsgfloat4 ( StringInfo  msg)

Definition at line 469 of file pqformat.c.

470{
471 union
472 {
473 float4 f;
474 uint32 i;
475 } swap;
476
477 swap.i = pq_getmsgint(msg, 4);
478 return swap.f;
479}
uint32_t uint32
Definition: c.h:488
float float4
Definition: c.h:586
int i
Definition: isn.c:72
unsigned int pq_getmsgint(StringInfo msg, int b)
Definition: pqformat.c:415

References i, and pq_getmsgint().

Referenced by float4recv().

◆ pq_getmsgfloat8()

float8 pq_getmsgfloat8 ( StringInfo  msg)

Definition at line 488 of file pqformat.c.

489{
490 union
491 {
492 float8 f;
493 int64 i;
494 } swap;
495
496 swap.i = pq_getmsgint64(msg);
497 return swap.f;
498}
int64_t int64
Definition: c.h:485
double float8
Definition: c.h:587
int64 pq_getmsgint64(StringInfo msg)
Definition: pqformat.c:453

References i, and pq_getmsgint64().

Referenced by box_recv(), circle_recv(), complex_recv(), cube_recv(), float8recv(), line_recv(), lseg_recv(), path_recv(), point_recv(), and poly_recv().

◆ pq_getmsgint()

unsigned int pq_getmsgint ( StringInfo  msg,
int  b 
)

Definition at line 415 of file pqformat.c.

416{
417 unsigned int result;
418 unsigned char n8;
419 uint16 n16;
420 uint32 n32;
421
422 switch (b)
423 {
424 case 1:
425 pq_copymsgbytes(msg, (char *) &n8, 1);
426 result = n8;
427 break;
428 case 2:
429 pq_copymsgbytes(msg, (char *) &n16, 2);
430 result = pg_ntoh16(n16);
431 break;
432 case 4:
433 pq_copymsgbytes(msg, (char *) &n32, 4);
434 result = pg_ntoh32(n32);
435 break;
436 default:
437 elog(ERROR, "unsupported integer size %d", b);
438 result = 0; /* keep compiler quiet */
439 break;
440 }
441 return result;
442}
uint16_t uint16
Definition: c.h:487
#define elog(elevel,...)
Definition: elog.h:225
int b
Definition: isn.c:69
#define pg_ntoh32(x)
Definition: pg_bswap.h:125
#define pg_ntoh16(x)
Definition: pg_bswap.h:124
void pq_copymsgbytes(StringInfo msg, char *buf, int datalen)
Definition: pqformat.c:528

References b, elog, ERROR, pg_ntoh16, pg_ntoh32, and pq_copymsgbytes().

Referenced by array_agg_array_deserialize(), array_agg_deserialize(), array_recv(), bit_recv(), CheckSASLAuth(), cidrecv(), cube_recv(), date_recv(), exec_bind_message(), handle_streamed_transaction(), HandleFunctionRequest(), HandleParallelMessage(), hstore_recv(), int2recv(), int4recv(), interval_avg_deserialize(), interval_recv(), jsonb_recv(), jsonpath_recv(), logicalrep_read_attrs(), logicalrep_read_begin(), logicalrep_read_begin_prepare(), logicalrep_read_commit_prepared(), logicalrep_read_delete(), logicalrep_read_insert(), logicalrep_read_prepare_common(), logicalrep_read_rel(), logicalrep_read_rollback_prepared(), logicalrep_read_stream_abort(), logicalrep_read_stream_commit(), logicalrep_read_stream_start(), logicalrep_read_truncate(), logicalrep_read_tuple(), logicalrep_read_typ(), logicalrep_read_update(), lquery_recv(), ltree_recv(), ltxtq_recv(), multirange_recv(), numeric_avg_deserialize(), numeric_deserialize(), numeric_recv(), numericvar_deserialize(), oidrecv(), parse_fcall_arguments(), path_recv(), pg_snapshot_recv(), poly_recv(), PostgresMain(), pq_getmsgfloat4(), ProcessStandbyHSFeedbackMessage(), range_recv(), ReadArrayBinary(), record_recv(), string_agg_deserialize(), tidrecv(), timetz_recv(), tsqueryrecv(), tsvectorrecv(), varbit_recv(), and xidrecv().

◆ pq_getmsgint64()

◆ pq_getmsgrawstring()

const char * pq_getmsgrawstring ( StringInfo  msg)

Definition at line 608 of file pqformat.c.

609{
610 char *str;
611 int slen;
612
613 str = &msg->data[msg->cursor];
614
615 /*
616 * It's safe to use strlen() here because a StringInfo is guaranteed to
617 * have a trailing null byte. But check we found a null inside the
618 * message.
619 */
620 slen = strlen(str);
621 if (msg->cursor + slen >= msg->len)
623 (errcode(ERRCODE_PROTOCOL_VIOLATION),
624 errmsg("invalid string in message")));
625 msg->cursor += slen + 1;
626
627 return str;
628}
const char * str

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

Referenced by CheckSASLAuth(), HandleParallelMessage(), and pq_parse_errornotice().

◆ pq_getmsgstring()

const char * pq_getmsgstring ( StringInfo  msg)

Definition at line 579 of file pqformat.c.

580{
581 char *str;
582 int slen;
583
584 str = &msg->data[msg->cursor];
585
586 /*
587 * It's safe to use strlen() here because a StringInfo is guaranteed to
588 * have a trailing null byte. But check we found a null inside the
589 * message.
590 */
591 slen = strlen(str);
592 if (msg->cursor + slen >= msg->len)
594 (errcode(ERRCODE_PROTOCOL_VIOLATION),
595 errmsg("invalid string in message")));
596 msg->cursor += slen + 1;
597
598 return pg_client_to_server(str, slen);
599}
char * pg_client_to_server(const char *s, int len)
Definition: mbutils.c:660

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

Referenced by CopyGetData(), exec_bind_message(), HandleUploadManifestPacket(), logicalrep_read_attrs(), logicalrep_read_begin_prepare(), logicalrep_read_commit_prepared(), logicalrep_read_namespace(), logicalrep_read_origin(), logicalrep_read_prepare_common(), logicalrep_read_rel(), logicalrep_read_rollback_prepared(), logicalrep_read_typ(), PostgresMain(), tsqueryrecv(), and tsvectorrecv().

◆ pq_getmsgtext()

char * pq_getmsgtext ( StringInfo  msg,
int  rawbytes,
int *  nbytes 
)

Definition at line 546 of file pqformat.c.

547{
548 char *str;
549 char *p;
550
551 if (rawbytes < 0 || rawbytes > (msg->len - msg->cursor))
553 (errcode(ERRCODE_PROTOCOL_VIOLATION),
554 errmsg("insufficient data left in message")));
555 str = &msg->data[msg->cursor];
556 msg->cursor += rawbytes;
557
558 p = pg_client_to_server(str, rawbytes);
559 if (p != str) /* actual conversion has been done? */
560 *nbytes = strlen(p);
561 else
562 {
563 p = (char *) palloc(rawbytes + 1);
564 memcpy(p, str, rawbytes);
565 p[rawbytes] = '\0';
566 *nbytes = rawbytes;
567 }
568 return p;
569}
void * palloc(Size size)
Definition: mcxt.c:1317

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

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

◆ pq_putemptymessage()

void pq_putemptymessage ( char  msgtype)

◆ pq_puttextmessage()

void pq_puttextmessage ( char  msgtype,
const char *  str 
)

Definition at line 367 of file pqformat.c.

368{
369 int slen = strlen(str);
370 char *p;
371
372 p = pg_server_to_client(str, slen);
373 if (p != str) /* actual conversion has been done? */
374 {
375 (void) pq_putmessage(msgtype, p, strlen(p) + 1);
376 pfree(p);
377 return;
378 }
379 (void) pq_putmessage(msgtype, str, slen + 1);
380}
char * pg_server_to_client(const char *s, int len)
Definition: mbutils.c:738

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

Referenced by bbsink_copystream_begin_backup(), and SendXlogRecPtrResult().

◆ pq_send_ascii_string()

void pq_send_ascii_string ( StringInfo  buf,
const char *  str 
)

Definition at line 227 of file pqformat.c.

228{
229 while (*str)
230 {
231 char ch = *str++;
232
233 if (IS_HIGHBIT_SET(ch))
234 ch = '?';
236 }
238}
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1112
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:242

References appendStringInfoChar(), appendStringInfoCharMacro, buf, IS_HIGHBIT_SET, and str.

Referenced by err_sendstring().

◆ pq_sendbyte()

◆ pq_sendbytes()

void pq_sendbytes ( StringInfo  buf,
const void *  data,
int  datalen 
)

Definition at line 126 of file pqformat.c.

127{
128 /* use variant that maintains a trailing null-byte, out of caution */
130}
const void * data
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:281

References appendBinaryStringInfo(), buf, and data.

Referenced by array_agg_array_serialize(), array_agg_serialize(), array_send(), logicalrep_write_message(), logicalrep_write_tuple(), multirange_send(), printtup(), range_send(), record_send(), sendAuthRequest(), SendFunctionResult(), SendTimeLineHistory(), serializeAnalyzeReceive(), string_agg_serialize(), uuid_send(), and varbit_send().

◆ pq_sendcountedtext()

void pq_sendcountedtext ( StringInfo  buf,
const char *  str,
int  slen 
)

Definition at line 142 of file pqformat.c.

143{
144 char *p;
145
146 p = pg_server_to_client(str, slen);
147 if (p != str) /* actual conversion has been done? */
148 {
149 slen = strlen(p);
150 pq_sendint32(buf, slen);
152 pfree(p);
153 }
154 else
155 {
156 pq_sendint32(buf, slen);
158 }
159}
static void pq_sendint32(StringInfo buf, uint32 i)
Definition: pqformat.h:144
void appendBinaryStringInfoNT(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:307

References appendBinaryStringInfoNT(), buf, pfree(), pg_server_to_client(), pq_sendint32(), and str.

Referenced by logicalrep_write_tuple(), printsimple(), printtup(), SendFunctionResult(), and serializeAnalyzeReceive().

◆ pq_sendfloat4()

void pq_sendfloat4 ( StringInfo  buf,
float4  f 
)

Definition at line 252 of file pqformat.c.

253{
254 union
255 {
256 float4 f;
257 uint32 i;
258 } swap;
259
260 swap.f = f;
261 pq_sendint32(buf, swap.i);
262}

References buf, i, and pq_sendint32().

Referenced by float4send().

◆ pq_sendfloat8()

void pq_sendfloat8 ( StringInfo  buf,
float8  f 
)

Definition at line 276 of file pqformat.c.

277{
278 union
279 {
280 float8 f;
281 int64 i;
282 } swap;
283
284 swap.f = f;
285 pq_sendint64(buf, swap.i);
286}
static void pq_sendint64(StringInfo buf, uint64 i)
Definition: pqformat.h:152

References buf, i, and pq_sendint64().

Referenced by box_send(), circle_send(), complex_send(), cube_send(), float8send(), line_send(), lseg_send(), path_send(), point_send(), and poly_send().

◆ pq_sendint()

static void pq_sendint ( StringInfo  buf,
uint32  i,
int  b 
)
inlinestatic

Definition at line 171 of file pqformat.h.

172{
173 switch (b)
174 {
175 case 1:
177 break;
178 case 2:
180 break;
181 case 4:
183 break;
184 default:
185 elog(ERROR, "unsupported integer size %d", b);
186 break;
187 }
188}
uint8_t uint8
Definition: c.h:486
static void pq_sendint16(StringInfo buf, uint16 i)
Definition: pqformat.h:136

References b, buf, elog, ERROR, i, pq_sendint16(), pq_sendint32(), and pq_sendint8().

Referenced by logicalrep_write_tuple(), and string_agg_serialize().

◆ pq_sendint16()

◆ pq_sendint32()

static void pq_sendint32 ( StringInfo  buf,
uint32  i 
)
inlinestatic

Definition at line 144 of file pqformat.h.

145{
146 enlargeStringInfo(buf, sizeof(uint32));
148}
static void pq_writeint32(StringInfoData *pg_restrict buf, uint32 i)
Definition: pqformat.h:74

References buf, enlargeStringInfo(), i, and pq_writeint32().

Referenced by array_agg_array_serialize(), array_agg_serialize(), array_send(), cidsend(), cube_send(), date_send(), exec_describe_statement_message(), hstore_send(), int4send(), interval_avg_serialize(), interval_send(), logicalrep_write_attrs(), logicalrep_write_begin(), logicalrep_write_begin_prepare(), logicalrep_write_commit_prepared(), logicalrep_write_delete(), logicalrep_write_insert(), logicalrep_write_message(), logicalrep_write_prepare_common(), logicalrep_write_rel(), logicalrep_write_rollback_prepared(), logicalrep_write_stream_abort(), logicalrep_write_stream_commit(), logicalrep_write_stream_start(), logicalrep_write_truncate(), logicalrep_write_typ(), logicalrep_write_update(), multirange_send(), NotifyMyFrontEnd(), numeric_avg_serialize(), numeric_serialize(), numericvar_serialize(), oidsend(), path_send(), pg_snapshot_send(), pgstat_progress_parallel_incr_param(), poly_send(), PostgresMain(), pq_sendcountedtext(), pq_sendfloat4(), pq_sendint(), printsimple(), printsimple_startup(), printtup(), range_send(), record_send(), sendAuthRequest(), SendFunctionResult(), SendNegotiateProtocolVersion(), SendTimeLineHistory(), serializeAnalyzeReceive(), tidsend(), timetz_send(), tsquerysend(), tsvectorsend(), varbit_send(), xidsend(), and XLogWalRcvSendHSFeedback().

◆ pq_sendint64()

◆ pq_sendint8()

static void pq_sendint8 ( StringInfo  buf,
uint8  i 
)
inlinestatic

Definition at line 128 of file pqformat.h.

129{
130 enlargeStringInfo(buf, sizeof(uint8));
132}
static void pq_writeint8(StringInfoData *pg_restrict buf, uint8 i)
Definition: pqformat.h:46

References buf, enlargeStringInfo(), i, and pq_writeint8().

Referenced by jsonb_send(), jsonpath_send(), logicalrep_write_message(), logicalrep_write_truncate(), lquery_send(), ltree_send(), ltxtq_send(), pq_sendbyte(), pq_sendint(), and tsquerysend().

◆ pq_sendstring()

◆ pq_sendtext()

void pq_sendtext ( StringInfo  buf,
const char *  str,
int  slen 
)

Definition at line 172 of file pqformat.c.

173{
174 char *p;
175
176 p = pg_server_to_client(str, slen);
177 if (p != str) /* actual conversion has been done? */
178 {
179 slen = strlen(p);
180 appendBinaryStringInfo(buf, p, slen);
181 pfree(p);
182 }
183 else
185}

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

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

◆ pq_writeint16()

static void pq_writeint16 ( StringInfoData *pg_restrict  buf,
uint16  i 
)
inlinestatic

Definition at line 60 of file pqformat.h.

61{
62 uint16 ni = pg_hton16(i);
63
64 Assert(buf->len + (int) sizeof(uint16) <= buf->maxlen);
65 memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint16));
66 buf->len += sizeof(uint16);
67}
#define pg_hton16(x)
Definition: pg_bswap.h:120

References Assert, buf, i, and pg_hton16.

Referenced by pq_sendint16(), and SendRowDescriptionMessage().

◆ pq_writeint32()

static void pq_writeint32 ( StringInfoData *pg_restrict  buf,
uint32  i 
)
inlinestatic

Definition at line 74 of file pqformat.h.

75{
76 uint32 ni = pg_hton32(i);
77
78 Assert(buf->len + (int) sizeof(uint32) <= buf->maxlen);
79 memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint32));
80 buf->len += sizeof(uint32);
81}
#define pg_hton32(x)
Definition: pg_bswap.h:121

References Assert, buf, i, and pg_hton32.

Referenced by pq_sendint32(), and SendRowDescriptionMessage().

◆ pq_writeint64()

static void pq_writeint64 ( StringInfoData *pg_restrict  buf,
uint64  i 
)
inlinestatic

Definition at line 88 of file pqformat.h.

89{
90 uint64 ni = pg_hton64(i);
91
92 Assert(buf->len + (int) sizeof(uint64) <= buf->maxlen);
93 memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint64));
94 buf->len += sizeof(uint64);
95}
#define pg_hton64(x)
Definition: pg_bswap.h:122

References Assert, buf, i, and pg_hton64.

Referenced by pq_sendint64().

◆ pq_writeint8()

static void pq_writeint8 ( StringInfoData *pg_restrict  buf,
uint8  i 
)
inlinestatic

Definition at line 46 of file pqformat.h.

47{
48 uint8 ni = i;
49
50 Assert(buf->len + (int) sizeof(uint8) <= buf->maxlen);
51 memcpy((char *pg_restrict) (buf->data + buf->len), &ni, sizeof(uint8));
52 buf->len += sizeof(uint8);
53}

References Assert, buf, and i.

Referenced by pq_sendint8().

◆ pq_writestring()

static void pq_writestring ( StringInfoData *pg_restrict  buf,
const char *pg_restrict  str 
)
inlinestatic

Definition at line 108 of file pqformat.h.

109{
110 int slen = strlen(str);
111 char *p;
112
113 p = pg_server_to_client(str, slen);
114 if (p != str) /* actual conversion has been done? */
115 slen = strlen(p);
116
117 Assert(buf->len + slen + 1 <= buf->maxlen);
118
119 memcpy(((char *pg_restrict) buf->data + buf->len), p, slen + 1);
120 buf->len += slen + 1;
121
122 if (p != str)
123 pfree(p);
124}

References Assert, buf, pfree(), pg_server_to_client(), and str.

Referenced by SendRowDescriptionMessage().