1/*-------------------------------------------------------------------------
4 * Definitions for formatting and parsing frontend/backend messages
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
9 * src/include/libpq/pqformat.h
11 *-------------------------------------------------------------------------
34 * Append a [u]int8 to a StringInfo buffer, which already has enough space
37 * The use of pg_restrict allows the compiler to optimize the code based on
38 * the assumption that buf, buf->len, buf->data and *buf->data don't
39 * overlap. Without the annotation buf->len etc cannot be kept in a register
40 * over subsequent pq_writeintN calls.
42 * The use of StringInfoData * rather than StringInfo is due to MSVC being
43 * overly picky and demanding a * before a restrict.
51 memcpy((
char *pg_restrict) (
buf->data +
buf->len), &ni,
sizeof(
uint8));
56 * Append a [u]int16 to a StringInfo buffer, which already has enough space
65 memcpy((
char *pg_restrict) (
buf->data +
buf->len), &ni,
sizeof(
uint16));
70 * Append a [u]int32 to a StringInfo buffer, which already has enough space
79 memcpy((
char *pg_restrict) (
buf->data +
buf->len), &ni,
sizeof(
uint32));
84 * Append a [u]int64 to a StringInfo buffer, which already has enough space
93 memcpy((
char *pg_restrict) (
buf->data +
buf->len), &ni,
sizeof(
uint64));
98 * Append a null-terminated text string (with conversion) to a buffer with
101 * NB: The pre-allocated space needs to be sufficient for the string after
102 * converting to client encoding.
104 * NB: passed text string must be null-terminated, and so is the data
105 * sent to the frontend.
110 int slen = strlen(
str);
114 if (p !=
str)
/* actual conversion has been done? */
119 memcpy(((
char *pg_restrict)
buf->data +
buf->len), p, slen + 1);
120 buf->len += slen + 1;
126/* append a binary [u]int8 to a StringInfo buffer */
134/* append a binary [u]int16 to a StringInfo buffer */
142/* append a binary [u]int32 to a StringInfo buffer */
150/* append a binary [u]int64 to a StringInfo buffer */
158/* append a binary byte to a StringInfo buffer */
166 * Append a binary integer to a StringInfo buffer
168 * This function is deprecated; prefer use of the functions above.
185 elog(
ERROR,
"unsupported integer size %d",
b);
209#endif /* PQFORMAT_H */
Assert(PointerIsAligned(start, uint64))
char * pg_server_to_client(const char *s, int len)
void pfree(void *pointer)
void enlargeStringInfo(StringInfo str, int needed)