PostgreSQL Source Code  git master
encode.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "mb/pg_wchar.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
Include dependency graph for encode.c:

Go to the source code of this file.

Data Structures

struct  pg_encoding
 

Macros

#define VAL(CH)   ((CH) - '0')
 
#define DIG(VAL)   ((VAL) + '0')
 

Functions

static const struct pg_encodingpg_find_encoding (const char *name)
 
Datum binary_encode (PG_FUNCTION_ARGS)
 
Datum binary_decode (PG_FUNCTION_ARGS)
 
uint64 hex_encode (const char *src, size_t len, char *dst)
 
static char get_hex (const char *cp)
 
uint64 hex_decode (const char *src, size_t len, char *dst)
 
static uint64 hex_enc_len (const char *src, size_t srclen)
 
static uint64 hex_dec_len (const char *src, size_t srclen)
 
static uint64 pg_base64_encode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64_decode (const char *src, size_t len, char *dst)
 
static uint64 pg_base64_enc_len (const char *src, size_t srclen)
 
static uint64 pg_base64_dec_len (const char *src, size_t srclen)
 
static uint64 esc_encode (const char *src, size_t srclen, char *dst)
 
static uint64 esc_decode (const char *src, size_t srclen, char *dst)
 
static uint64 esc_enc_len (const char *src, size_t srclen)
 
static uint64 esc_dec_len (const char *src, size_t srclen)
 

Variables

static const char hextbl [] = "0123456789abcdef"
 
static const int8 hexlookup [128]
 
static const char _base64 []
 
static const int8 b64lookup [128]
 
struct {
   const char *   name
 
   struct pg_encoding   enc
 
enclist []
 

Macro Definition Documentation

◆ DIG

#define DIG (   VAL)    ((VAL) + '0')

Definition at line 402 of file encode.c.

Referenced by esc_encode().

◆ VAL

#define VAL (   CH)    ((CH) - '0')

Definition at line 401 of file encode.c.

Referenced by esc_decode().

Function Documentation

◆ binary_decode()

Datum binary_decode ( PG_FUNCTION_ARGS  )

Definition at line 95 of file encode.c.

References pg_encoding::decode, pg_encoding::decode_len, elog, enc, ereport, errcode(), errmsg(), ERROR, FATAL, MaxAllocSize, name, palloc(), pg_find_encoding(), PG_GETARG_DATUM, PG_GETARG_TEXT_PP, PG_RETURN_BYTEA_P, SET_VARSIZE, TextDatumGetCString, VARDATA, VARDATA_ANY, VARHDRSZ, and VARSIZE_ANY_EXHDR.

96 {
97  text *data = PG_GETARG_TEXT_PP(0);
99  bytea *result;
100  char *namebuf;
101  char *dataptr;
102  size_t datalen;
103  uint64 resultlen;
104  uint64 res;
105  const struct pg_encoding *enc;
106 
107  namebuf = TextDatumGetCString(name);
108 
109  enc = pg_find_encoding(namebuf);
110  if (enc == NULL)
111  ereport(ERROR,
112  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
113  errmsg("unrecognized encoding: \"%s\"", namebuf)));
114 
115  dataptr = VARDATA_ANY(data);
116  datalen = VARSIZE_ANY_EXHDR(data);
117 
118  resultlen = enc->decode_len(dataptr, datalen);
119 
120  /*
121  * resultlen possibly overflows uint32, therefore on 32-bit machines it's
122  * unsafe to rely on palloc's internal check.
123  */
124  if (resultlen > MaxAllocSize - VARHDRSZ)
125  ereport(ERROR,
126  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
127  errmsg("result of decoding conversion is too large")));
128 
129  result = palloc(VARHDRSZ + resultlen);
130 
131  res = enc->decode(dataptr, datalen, VARDATA(result));
132 
133  /* Make this FATAL 'cause we've trodden on memory ... */
134  if (res > resultlen)
135  elog(FATAL, "overflow - decode estimate too small");
136 
137  SET_VARSIZE(result, VARHDRSZ + res);
138 
139  PG_RETURN_BYTEA_P(result);
140 }
uint64(* decode)(const char *data, size_t dlen, char *res)
Definition: encode.c:37
#define VARDATA_ANY(PTR)
Definition: postgres.h:348
#define VARDATA(PTR)
Definition: postgres.h:302
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define VARHDRSZ
Definition: c.h:623
int errcode(int sqlerrcode)
Definition: elog.c:691
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define ERROR
Definition: elog.h:43
struct pg_encoding enc
Definition: encode.c:562
#define FATAL
Definition: elog.h:52
uint64(* decode_len)(const char *data, size_t dlen)
Definition: encode.c:35
static const struct pg_encoding * pg_find_encoding(const char *name)
Definition: encode.c:593
#define MaxAllocSize
Definition: memutils.h:40
#define TextDatumGetCString(d)
Definition: builtins.h:87
uintptr_t Datum
Definition: postgres.h:367
#define ereport(elevel,...)
Definition: elog.h:155
const char * name
Definition: encode.c:561
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:341
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:902
#define elog(elevel,...)
Definition: elog.h:228
Definition: c.h:617
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329

◆ binary_encode()

Datum binary_encode ( PG_FUNCTION_ARGS  )

Definition at line 47 of file encode.c.

References elog, enc, pg_encoding::encode, pg_encoding::encode_len, ereport, errcode(), errmsg(), ERROR, FATAL, MaxAllocSize, name, palloc(), pg_find_encoding(), PG_GETARG_BYTEA_PP, PG_GETARG_DATUM, PG_RETURN_TEXT_P, SET_VARSIZE, TextDatumGetCString, VARDATA, VARDATA_ANY, VARHDRSZ, and VARSIZE_ANY_EXHDR.

48 {
49  bytea *data = PG_GETARG_BYTEA_PP(0);
51  text *result;
52  char *namebuf;
53  char *dataptr;
54  size_t datalen;
55  uint64 resultlen;
56  uint64 res;
57  const struct pg_encoding *enc;
58 
59  namebuf = TextDatumGetCString(name);
60 
61  enc = pg_find_encoding(namebuf);
62  if (enc == NULL)
63  ereport(ERROR,
64  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
65  errmsg("unrecognized encoding: \"%s\"", namebuf)));
66 
67  dataptr = VARDATA_ANY(data);
68  datalen = VARSIZE_ANY_EXHDR(data);
69 
70  resultlen = enc->encode_len(dataptr, datalen);
71 
72  /*
73  * resultlen possibly overflows uint32, therefore on 32-bit machines it's
74  * unsafe to rely on palloc's internal check.
75  */
76  if (resultlen > MaxAllocSize - VARHDRSZ)
77  ereport(ERROR,
78  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
79  errmsg("result of encoding conversion is too large")));
80 
81  result = palloc(VARHDRSZ + resultlen);
82 
83  res = enc->encode(dataptr, datalen, VARDATA(result));
84 
85  /* Make this FATAL 'cause we've trodden on memory ... */
86  if (res > resultlen)
87  elog(FATAL, "overflow - encode estimate too small");
88 
89  SET_VARSIZE(result, VARHDRSZ + res);
90 
91  PG_RETURN_TEXT_P(result);
92 }
#define VARDATA_ANY(PTR)
Definition: postgres.h:348
#define VARDATA(PTR)
Definition: postgres.h:302
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define VARHDRSZ
Definition: c.h:623
int errcode(int sqlerrcode)
Definition: elog.c:691
uint64(* encode_len)(const char *data, size_t dlen)
Definition: encode.c:34
#define ERROR
Definition: elog.h:43
struct pg_encoding enc
Definition: encode.c:562
#define FATAL
Definition: elog.h:52
static const struct pg_encoding * pg_find_encoding(const char *name)
Definition: encode.c:593
#define MaxAllocSize
Definition: memutils.h:40
#define TextDatumGetCString(d)
Definition: builtins.h:87
uintptr_t Datum
Definition: postgres.h:367
#define ereport(elevel,...)
Definition: elog.h:155
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
uint64(* encode)(const char *data, size_t dlen, char *res)
Definition: encode.c:36
#define PG_GETARG_BYTEA_PP(n)
Definition: fmgr.h:308
const char * name
Definition: encode.c:561
#define VARSIZE_ANY_EXHDR(PTR)
Definition: postgres.h:341
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:902
#define elog(elevel,...)
Definition: elog.h:228
Definition: c.h:617
#define SET_VARSIZE(PTR, len)
Definition: postgres.h:329

◆ esc_dec_len()

static uint64 esc_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 513 of file encode.c.

References ereport, errcode(), errmsg(), and ERROR.

514 {
515  const char *end = src + srclen;
516  uint64 len = 0;
517 
518  while (src < end)
519  {
520  if (src[0] != '\\')
521  src++;
522  else if (src + 3 < end &&
523  (src[1] >= '0' && src[1] <= '3') &&
524  (src[2] >= '0' && src[2] <= '7') &&
525  (src[3] >= '0' && src[3] <= '7'))
526  {
527  /*
528  * backslash + valid octal
529  */
530  src += 4;
531  }
532  else if (src + 1 < end &&
533  (src[1] == '\\'))
534  {
535  /*
536  * two backslashes = backslash
537  */
538  src += 2;
539  }
540  else
541  {
542  /*
543  * one backslash, not followed by ### valid octal
544  */
545  ereport(ERROR,
546  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
547  errmsg("invalid input syntax for type %s", "bytea")));
548  }
549 
550  len++;
551  }
552  return len;
553 }
int errcode(int sqlerrcode)
Definition: elog.c:691
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg(const char *fmt,...)
Definition: elog.c:902

◆ esc_decode()

static uint64 esc_decode ( const char *  src,
size_t  srclen,
char *  dst 
)
static

Definition at line 444 of file encode.c.

References ereport, errcode(), errmsg(), ERROR, VAL, and val.

445 {
446  const char *end = src + srclen;
447  char *rp = dst;
448  uint64 len = 0;
449 
450  while (src < end)
451  {
452  if (src[0] != '\\')
453  *rp++ = *src++;
454  else if (src + 3 < end &&
455  (src[1] >= '0' && src[1] <= '3') &&
456  (src[2] >= '0' && src[2] <= '7') &&
457  (src[3] >= '0' && src[3] <= '7'))
458  {
459  int val;
460 
461  val = VAL(src[1]);
462  val <<= 3;
463  val += VAL(src[2]);
464  val <<= 3;
465  *rp++ = val + VAL(src[3]);
466  src += 4;
467  }
468  else if (src + 1 < end &&
469  (src[1] == '\\'))
470  {
471  *rp++ = '\\';
472  src += 2;
473  }
474  else
475  {
476  /*
477  * One backslash, not followed by ### valid octal. Should never
478  * get here, since esc_dec_len does same check.
479  */
480  ereport(ERROR,
481  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
482  errmsg("invalid input syntax for type %s", "bytea")));
483  }
484 
485  len++;
486  }
487 
488  return len;
489 }
int errcode(int sqlerrcode)
Definition: elog.c:691
#define ERROR
Definition: elog.h:43
#define VAL(CH)
Definition: encode.c:401
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg(const char *fmt,...)
Definition: elog.c:902
long val
Definition: informix.c:664

◆ esc_enc_len()

static uint64 esc_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 492 of file encode.c.

References IS_HIGHBIT_SET.

493 {
494  const char *end = src + srclen;
495  uint64 len = 0;
496 
497  while (src < end)
498  {
499  if (*src == '\0' || IS_HIGHBIT_SET(*src))
500  len += 4;
501  else if (*src == '\\')
502  len += 2;
503  else
504  len++;
505 
506  src++;
507  }
508 
509  return len;
510 }
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1152

◆ esc_encode()

static uint64 esc_encode ( const char *  src,
size_t  srclen,
char *  dst 
)
static

Definition at line 405 of file encode.c.

References DIG, and IS_HIGHBIT_SET.

406 {
407  const char *end = src + srclen;
408  char *rp = dst;
409  uint64 len = 0;
410 
411  while (src < end)
412  {
413  unsigned char c = (unsigned char) *src;
414 
415  if (c == '\0' || IS_HIGHBIT_SET(c))
416  {
417  rp[0] = '\\';
418  rp[1] = DIG(c >> 6);
419  rp[2] = DIG((c >> 3) & 7);
420  rp[3] = DIG(c & 7);
421  rp += 4;
422  len += 4;
423  }
424  else if (c == '\\')
425  {
426  rp[0] = '\\';
427  rp[1] = '\\';
428  rp += 2;
429  len += 2;
430  }
431  else
432  {
433  *rp++ = c;
434  len++;
435  }
436 
437  src++;
438  }
439 
440  return len;
441 }
#define IS_HIGHBIT_SET(ch)
Definition: c.h:1152
char * c
#define DIG(VAL)
Definition: encode.c:402

◆ get_hex()

static char get_hex ( const char *  cp)
inlinestatic

Definition at line 175 of file encode.c.

References ereport, errcode(), errmsg(), ERROR, hexlookup, and pg_mblen().

Referenced by hex_decode().

176 {
177  unsigned char c = (unsigned char) *cp;
178  int res = -1;
179 
180  if (c < 127)
181  res = hexlookup[c];
182 
183  if (res < 0)
184  ereport(ERROR,
185  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
186  errmsg("invalid hexadecimal digit: \"%.*s\"",
187  pg_mblen(cp), cp)));
188 
189  return (char) res;
190 }
int errcode(int sqlerrcode)
Definition: elog.c:691
static const int8 hexlookup[128]
Definition: encode.c:149
#define ERROR
Definition: elog.h:43
char * c
#define ereport(elevel,...)
Definition: elog.h:155
int pg_mblen(const char *mbstr)
Definition: mbutils.c:907
int errmsg(const char *fmt,...)
Definition: elog.c:902

◆ hex_dec_len()

static uint64 hex_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 233 of file encode.c.

234 {
235  return (uint64) srclen >> 1;
236 }

◆ hex_decode()

uint64 hex_decode ( const char *  src,
size_t  len,
char *  dst 
)

Definition at line 193 of file encode.c.

References ereport, errcode(), errmsg(), ERROR, and get_hex().

Referenced by byteain().

194 {
195  const char *s,
196  *srcend;
197  char v1,
198  v2,
199  *p;
200 
201  srcend = src + len;
202  s = src;
203  p = dst;
204  while (s < srcend)
205  {
206  if (*s == ' ' || *s == '\n' || *s == '\t' || *s == '\r')
207  {
208  s++;
209  continue;
210  }
211  v1 = get_hex(s) << 4;
212  s++;
213  if (s >= srcend)
214  ereport(ERROR,
215  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
216  errmsg("invalid hexadecimal data: odd number of digits")));
217 
218  v2 = get_hex(s);
219  s++;
220  *p++ = v1 | v2;
221  }
222 
223  return p - dst;
224 }
int errcode(int sqlerrcode)
Definition: elog.c:691
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:155
static char get_hex(const char *cp)
Definition: encode.c:175
int errmsg(const char *fmt,...)
Definition: elog.c:902

◆ hex_enc_len()

static uint64 hex_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 227 of file encode.c.

228 {
229  return (uint64) srclen << 1;
230 }

◆ hex_encode()

uint64 hex_encode ( const char *  src,
size_t  len,
char *  dst 
)

Definition at line 161 of file encode.c.

References hextbl.

Referenced by AddFileToBackupManifest(), byteaout(), and SendBackupManifest().

162 {
163  const char *end = src + len;
164 
165  while (src < end)
166  {
167  *dst++ = hextbl[(*src >> 4) & 0xF];
168  *dst++ = hextbl[*src & 0xF];
169  src++;
170  }
171  return (uint64) len * 2;
172 }
static const char hextbl[]
Definition: encode.c:147

◆ pg_base64_dec_len()

static uint64 pg_base64_dec_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 382 of file encode.c.

383 {
384  return ((uint64) srclen * 3) >> 2;
385 }

◆ pg_base64_decode()

static uint64 pg_base64_decode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 304 of file encode.c.

References b64lookup, buf, ereport, errcode(), errhint(), errmsg(), ERROR, and pg_mblen().

305 {
306  const char *srcend = src + len,
307  *s = src;
308  char *p = dst;
309  char c;
310  int b = 0;
311  uint32 buf = 0;
312  int pos = 0,
313  end = 0;
314 
315  while (s < srcend)
316  {
317  c = *s++;
318 
319  if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
320  continue;
321 
322  if (c == '=')
323  {
324  /* end sequence */
325  if (!end)
326  {
327  if (pos == 2)
328  end = 1;
329  else if (pos == 3)
330  end = 2;
331  else
332  ereport(ERROR,
333  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
334  errmsg("unexpected \"=\" while decoding base64 sequence")));
335  }
336  b = 0;
337  }
338  else
339  {
340  b = -1;
341  if (c > 0 && c < 127)
342  b = b64lookup[(unsigned char) c];
343  if (b < 0)
344  ereport(ERROR,
345  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
346  errmsg("invalid symbol \"%.*s\" found while decoding base64 sequence",
347  pg_mblen(s - 1), s - 1)));
348  }
349  /* add it to buffer */
350  buf = (buf << 6) + b;
351  pos++;
352  if (pos == 4)
353  {
354  *p++ = (buf >> 16) & 255;
355  if (end == 0 || end > 1)
356  *p++ = (buf >> 8) & 255;
357  if (end == 0 || end > 2)
358  *p++ = buf & 255;
359  buf = 0;
360  pos = 0;
361  }
362  }
363 
364  if (pos != 0)
365  ereport(ERROR,
366  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
367  errmsg("invalid base64 end sequence"),
368  errhint("Input data is missing padding, is truncated, or is otherwise corrupted.")));
369 
370  return p - dst;
371 }
int errhint(const char *fmt,...)
Definition: elog.c:1149
int errcode(int sqlerrcode)
Definition: elog.c:691
#define ERROR
Definition: elog.h:43
char * c
static char * buf
Definition: pg_test_fsync.c:68
unsigned int uint32
Definition: c.h:429
#define ereport(elevel,...)
Definition: elog.h:155
int pg_mblen(const char *mbstr)
Definition: mbutils.c:907
int errmsg(const char *fmt,...)
Definition: elog.c:902
static const int8 b64lookup[128]
Definition: encode.c:245

◆ pg_base64_enc_len()

static uint64 pg_base64_enc_len ( const char *  src,
size_t  srclen 
)
static

Definition at line 375 of file encode.c.

376 {
377  /* 3 bytes will be converted to 4, linefeed after 76 chars */
378  return ((uint64) srclen + 2) * 4 / 3 + (uint64) srclen / (76 * 3 / 4);
379 }

◆ pg_base64_encode()

static uint64 pg_base64_encode ( const char *  src,
size_t  len,
char *  dst 
)
static

Definition at line 257 of file encode.c.

References _base64, and buf.

258 {
259  char *p,
260  *lend = dst + 76;
261  const char *s,
262  *end = src + len;
263  int pos = 2;
264  uint32 buf = 0;
265 
266  s = src;
267  p = dst;
268 
269  while (s < end)
270  {
271  buf |= (unsigned char) *s << (pos << 3);
272  pos--;
273  s++;
274 
275  /* write it out */
276  if (pos < 0)
277  {
278  *p++ = _base64[(buf >> 18) & 0x3f];
279  *p++ = _base64[(buf >> 12) & 0x3f];
280  *p++ = _base64[(buf >> 6) & 0x3f];
281  *p++ = _base64[buf & 0x3f];
282 
283  pos = 2;
284  buf = 0;
285  }
286  if (p >= lend)
287  {
288  *p++ = '\n';
289  lend = p + 76;
290  }
291  }
292  if (pos != 2)
293  {
294  *p++ = _base64[(buf >> 18) & 0x3f];
295  *p++ = _base64[(buf >> 12) & 0x3f];
296  *p++ = (pos == 0) ? _base64[(buf >> 6) & 0x3f] : '=';
297  *p++ = '=';
298  }
299 
300  return p - dst;
301 }
static const char _base64[]
Definition: encode.c:242
static char * buf
Definition: pg_test_fsync.c:68
unsigned int uint32
Definition: c.h:429

◆ pg_find_encoding()

static const struct pg_encoding * pg_find_encoding ( const char *  name)
static

Definition at line 593 of file encode.c.

References enclist, i, and pg_strcasecmp().

Referenced by binary_decode(), and binary_encode().

594 {
595  int i;
596 
597  for (i = 0; enclist[i].name; i++)
598  if (pg_strcasecmp(enclist[i].name, name) == 0)
599  return &enclist[i].enc;
600 
601  return NULL;
602 }
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
static const struct @26 enclist[]
const char * name
Definition: encode.c:561
int i

Variable Documentation

◆ _base64

const char _base64[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Definition at line 242 of file encode.c.

Referenced by pg_base64_encode().

◆ b64lookup

const int8 b64lookup[128]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
}

Definition at line 245 of file encode.c.

Referenced by pg_base64_decode().

◆ enc

◆ enclist

const { ... } enclist[]
Initial value:
=
{
{
"hex",
{
}
},
{
"base64",
{
}
},
{
"escape",
{
}
},
{
NULL,
{
NULL, NULL, NULL, NULL
}
}
}
static uint64 esc_dec_len(const char *src, size_t srclen)
Definition: encode.c:513
static uint64 esc_encode(const char *src, size_t srclen, char *dst)
Definition: encode.c:405
static uint64 pg_base64_enc_len(const char *src, size_t srclen)
Definition: encode.c:375
static uint64 pg_base64_encode(const char *src, size_t len, char *dst)
Definition: encode.c:257
static uint64 hex_dec_len(const char *src, size_t srclen)
Definition: encode.c:233
uint64 hex_encode(const char *src, size_t len, char *dst)
Definition: encode.c:161
uint64 hex_decode(const char *src, size_t len, char *dst)
Definition: encode.c:193
static uint64 pg_base64_decode(const char *src, size_t len, char *dst)
Definition: encode.c:304
static uint64 esc_enc_len(const char *src, size_t srclen)
Definition: encode.c:492
static uint64 hex_enc_len(const char *src, size_t srclen)
Definition: encode.c:227
static uint64 esc_decode(const char *src, size_t srclen, char *dst)
Definition: encode.c:444
static uint64 pg_base64_dec_len(const char *src, size_t srclen)
Definition: encode.c:382

Referenced by pg_find_encoding().

◆ hexlookup

const int8 hexlookup[128]
static
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
}

Definition at line 149 of file encode.c.

Referenced by get_hex().

◆ hextbl

const char hextbl[] = "0123456789abcdef"
static

Definition at line 147 of file encode.c.

Referenced by hex_encode().

◆ name

const char* name

Definition at line 561 of file encode.c.

Referenced by _copyAExpr(), _copyAlterDomainStmt(), _copyAlterTableCmd(), _copyCreateOpClassItem(), _copyDeallocateStmt(), _copyExecuteStmt(), _copyFunctionParameter(), _copyIndexElem(), _copyNamedArgExpr(), _copyPartitionCmd(), _copyPartitionElem(), _copyPrepareStmt(), _copyReindexStmt(), _copyReplicaIdentityStmt(), _copyResTarget(), _copyTriggerTransition(), _copyVariableSetStmt(), _copyVariableShowStmt(), _copyWindowClause(), _copyWindowDef(), _copyXmlExpr(), _equalAExpr(), _equalAlterDomainStmt(), _equalAlterTableCmd(), _equalCreateOpClassItem(), _equalDeallocateStmt(), _equalExecuteStmt(), _equalFunctionParameter(), _equalIndexElem(), _equalNamedArgExpr(), _equalPartitionCmd(), _equalPartitionElem(), _equalPrepareStmt(), _equalReindexStmt(), _equalReplicaIdentityStmt(), _equalResTarget(), _equalTriggerTransition(), _equalVariableSetStmt(), _equalVariableShowStmt(), _equalWindowClause(), _equalWindowDef(), _equalXmlExpr(), _outAExpr(), _outIndexElem(), _outNamedArgExpr(), _outPartitionElem(), _outResTarget(), _outTriggerTransition(), _outWindowClause(), _outWindowDef(), _outXmlExpr(), _readNamedArgExpr(), _readWindowClause(), _readXmlExpr(), aclparse(), aes_cbc_decrypt(), AllocSetContextCreateInternal(), AllocSetStats(), AlterObjectNamespace_internal(), AlterSystemSetConfigFile(), AlterTableGetRelOptionsLockLevel(), appendReloptionsArray(), assignVariables(), AuxiliaryPidGetProc(), binary_decode(), binary_encode(), BuildOnConflictExcludedTargetlist(), check_encoding_conversion_args(), checkInsertTargets(), choose_dsm_implementation(), ChooseExtendedStatisticNameAddition(), ChooseForeignKeyConstraintNameAddition(), ChooseIndexNameAddition(), compareVariableNames(), convert_sourcefiles_in(), convertRegProcReference(), CopyGetAttnums(), CreateTrigger(), cursor_to_xml(), cursor_to_xmlschema(), deallocate_one(), define_custom_variable(), DescribeQuery(), do_pset(), does_not_exist_skipping(), dsm_impl_mmap(), dsm_impl_op(), dsm_impl_pin_segment(), dsm_impl_sysv(), dsm_impl_unpin_segment(), dump_block(), dupEvents(), eats(), ecpg_register_prepared_stmt(), ECPGdescribe(), enum_in(), enum_recv(), ExecParallelHashJoinSetUpBatches(), expandNSItemAttrs(), FigureColname(), FigureIndexColname(), find_option(), findTargetlistEntrySQL92(), GenerationFree(), GenerationRealloc(), GenerationStats(), get_collation_version_for_oid(), get_object_address_unqualified(), get_prompt(), get_reloptions(), get_type(), GetMemoryChunkContext(), getopt_long(), initialize_reloptions(), initialize_worker_spi(), InitializeClientEncoding(), InitializeLWLocks(), leftmostvalue_name(), listAvailableScripts(), llvm_resolve_symbol(), lookupVariable(), main(), makeA_Expr(), makeDefElem(), makeDefElemExtended(), makeFuncCall(), makeObjectName(), MemoryContextCreate(), MemoryContextStatsPrint(), MergeAttributes(), mkdirs(), namecheck(), NameListToString(), parseQuery(), parseVariable(), pg_any_to_server(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_digest(), pg_drop_replication_slot(), pg_fe_getauthname(), pg_get_functiondef(), pg_get_object_address(), pg_hmac(), pg_import_system_collations(), pg_logging_init(), pg_logical_slot_get_changes_guts(), pg_open_tzfile(), pg_replication_origin_advance(), pg_replication_origin_create(), pg_replication_origin_drop(), pg_replication_origin_oid(), pg_replication_origin_progress(), pg_replication_origin_session_setup(), pg_stat_get_slru(), pg_unicode_to_server(), pgstat_reset_slru_counter(), pgtls_verify_peer_name_matches_certificate_guts(), PLy_traceback(), PostmasterMain(), pp_require_safe(), pq_verify_peer_name_matches_certificate_name(), process_postgres_switches(), process_startup_options(), ProcessGUCArray(), publicationListToArray(), PutMemoryContextsStatsTupleStore(), px_resolve_alias(), repairDependencyLoop(), report_invalid_encoding(), report_multiple_error_messages(), report_untranslatable_char(), ResourceOwnerCreate(), ri_ReportViolation(), run_permutation(), scan_available_timezones(), schema_to_xml(), schema_to_xml_and_xmlschema(), schema_to_xmlschema(), sendCommand(), seq_search_ascii(), set_config_by_name(), set_ps_display(), SetMessageEncoding(), show_item(), SlabStats(), strlist_to_textarray(), sts_parallel_scan_next(), sts_puttuple(), tarOpen(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), TSTemplateIsVisible(), TypeCreate(), TypeShellMake(), tzloadbody(), tzparse(), and xml_is_document().