68 errhint(
"Valid encodings are \"%s\", \"%s\", \"%s\", \"%s\", and \"%s\".",
69 "base32hex",
"base64",
"base64url",
"escape",
"hex")));
83 errmsg(
"result of encoding conversion is too large")));
91 elog(
FATAL,
"overflow - encode estimate too small");
118 errhint(
"Valid encodings are \"%s\", \"%s\", \"%s\", \"%s\", and \"%s\".",
119 "base32hex",
"base64",
"base64url",
"escape",
"hex")));
133 errmsg(
"result of decoding conversion is too large")));
141 elog(
FATAL,
"overflow - decode estimate too small");
157"000102030405060708090a0b0c0d0e0f"
158"101112131415161718191a1b1c1d1e1f"
159"202122232425262728292a2b2c2d2e2f"
160"303132333435363738393a3b3c3d3e3f"
161"404142434445464748494a4b4c4d4e4f"
162"505152535455565758595a5b5c5d5e5f"
163"606162636465666768696a6b6c6d6e6f"
164"707172737475767778797a7b7c7d7e7f"
165"808182838485868788898a8b8c8d8e8f"
166"909192939495969798999a9b9c9d9e9f"
167"a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
168"b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
169"c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
170"d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
171"e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
172"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
175 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
176 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
177 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
178 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
179 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
180 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
181 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
182 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
188 const char *end = src +
len;
192 unsigned char usrc = *((
const unsigned char *) src);
253 unsigned char c = (
unsigned char) *
cp;
284 if (*s ==
' ' || *s ==
'\n' || *s ==
'\t' || *s ==
'\r')
292 errmsg(
"invalid hexadecimal digit: \"%.*s\"",
298 errmsg(
"invalid hexadecimal data: odd number of digits")));
302 errmsg(
"invalid hexadecimal digit: \"%.*s\"",
305 *p++ = (v1 << 4) |
v2;
407"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
410"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
413 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
416 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
417 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
418 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
419 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
420 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
446 buf |= (
unsigned char) *s << (pos << 3);
525 if (
c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'\r')
551 errmsg(
"unexpected \"=\" while decoding %s sequence",
url ?
"base64url" :
"base64")));
559 if (
c > 0 &&
c < 127)
566 errmsg(
"invalid symbol \"%.*s\" found while decoding %s sequence",
568 url ?
"base64url" :
"base64")));
576 *p++ = (
buf >> 16) & 255;
577 if (end == 0 || end > 1)
578 *p++ = (
buf >> 8) & 255;
579 if (end == 0 || end > 2)
589 *p++ = (
buf >> 16) & 0xFF;
594 *p++ = (
buf >> 16) & 0xFF;
595 *p++ = (
buf >> 8) & 0xFF;
602 errmsg(
"invalid %s end sequence",
url ?
"base64url" :
"base64"),
603 errhint(
"Input data is missing padding, is truncated, or is otherwise corrupted.")));
641 return (
srclen + 2) / 3 * 4;
674#define VAL(CH) ((CH) - '0')
675#define DIG(VAL) ((VAL) + '0')
680 const char *end = src +
srclen;
686 unsigned char c = (
unsigned char) *src;
692 rp[2] =
DIG((
c >> 3) & 7);
719 const char *end = src +
srclen;
727 else if (src + 3 < end &&
728 (src[1] >=
'0' && src[1] <=
'3') &&
729 (src[2] >=
'0' && src[2] <=
'7') &&
730 (src[3] >=
'0' && src[3] <=
'7'))
741 else if (src + 1 < end &&
755 errmsg(
"invalid input syntax for type %s",
"bytea")));
767 const char *end = src +
srclen;
774 else if (*src ==
'\\')
788 const char *end = src +
srclen;
795 else if (src + 3 < end &&
796 (src[1] >=
'0' && src[1] <=
'3') &&
797 (src[2] >=
'0' && src[2] <=
'7') &&
798 (src[3] >=
'0' && src[3] <=
'7'))
805 else if (src + 1 < end &&
820 errmsg(
"invalid input syntax for type %s",
"bytea")));
835 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
836 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
837 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
838 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
839 -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
840 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1,
841 -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
842 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1,
862 const unsigned char *
data = (
const unsigned char *) src;
913 if (
c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'\r')
926 if (pos != 2 && pos != 4 && pos != 5 && pos != 7)
929 errmsg(
"unexpected \"=\" while decoding base32hex sequence")));
940 errmsg(
"invalid symbol \"%.*s\" found while decoding base32hex sequence",
945 if ((
unsigned char)
c < 128)
950 errmsg(
"invalid symbol \"%.*s\" found while decoding base32hex sequence",
#define TextDatumGetCString(d)
#define IS_HIGHBIT_SET(ch)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
int errcode(int sqlerrcode)
#define ereturn(context, dummy_value,...)
int errhint(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
static uint64 pg_base64_decode(const char *src, size_t len, char *dst)
static uint64 pg_base64_decode_internal(const char *src, size_t len, char *dst, bool url)
static bool get_hex(const char *cp, char *out)
static uint64 hex_dec_len(const char *src, size_t srclen)
static const struct pg_encoding * pg_find_encoding(const char *name)
static uint64 pg_base64_encode(const char *src, size_t len, char *dst)
static const struct @25 enclist[]
static uint64 esc_encode(const char *src, size_t srclen, char *dst)
static uint64 hex_enc_len(const char *src, size_t srclen)
Datum binary_decode(PG_FUNCTION_ARGS)
static const char hextbl[512]
static uint64 pg_base64url_enc_len(const char *src, size_t srclen)
static uint64 pg_base64url_decode(const char *src, size_t len, char *dst)
static const char _base64url[]
uint64 hex_decode_safe(const char *src, size_t len, char *dst, Node *escontext)
static uint64 hex_decode_safe_scalar(const char *src, size_t len, char *dst, Node *escontext)
static uint64 hex_encode_scalar(const char *src, size_t len, char *dst)
static uint64 base32hex_decode(const char *src, size_t srclen, char *dst)
uint64 hex_encode(const char *src, size_t len, char *dst)
static uint64 esc_enc_len(const char *src, size_t srclen)
static uint64 pg_base64url_encode(const char *src, size_t len, char *dst)
static uint64 pg_base64url_dec_len(const char *src, size_t srclen)
static uint64 pg_base64_enc_len(const char *src, size_t srclen)
static uint64 pg_base64_encode_internal(const char *src, size_t len, char *dst, bool url)
static const char _base64[]
static const int8 b32hexlookup[128]
static uint64 esc_decode(const char *src, size_t srclen, char *dst)
static const char base32hex_table[]
static uint64 base32hex_enc_len(const char *src, size_t srclen)
static uint64 esc_dec_len(const char *src, size_t srclen)
Datum binary_encode(PG_FUNCTION_ARGS)
static uint64 base32hex_encode(const char *src, size_t srclen, char *dst)
uint64 hex_decode(const char *src, size_t len, char *dst)
static const int8 b64lookup[128]
static const int8 hexlookup[128]
static uint64 base32hex_dec_len(const char *src, size_t srclen)
static uint64 pg_base64_dec_len(const char *src, size_t srclen)
#define PG_GETARG_BYTEA_PP(n)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_TEXT_P(x)
int pg_mblen_range(const char *mbstr, const char *end)
static char buf[DEFAULT_XLOG_SEG_SIZE]
int pg_strcasecmp(const char *s1, const char *s2)
static Vector8 vector8_broadcast(const uint8 c)
static void vector8_load(Vector8 *v, const uint8 *s)
static Vector8 vector8_or(const Vector8 v1, const Vector8 v2)
uint64(* encode_len)(const char *data, size_t dlen)
uint64(* decode_len)(const char *data, size_t dlen)
uint64(* decode)(const char *data, size_t dlen, char *res)
uint64(* encode)(const char *data, size_t dlen, char *res)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)