27#include "utils/fmgrprotos.h"
95#define PG_STR_GET_BYTEA(str_) \
96 DatumGetByteaPP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
126 errmsg(
"negative substring length not allowed")));
174 errmsg(
"negative substring length not allowed")));
178 errmsg(
"integer out of range")));
192#define VAL(CH) ((CH) - '0')
193#define DIG(VAL) ((VAL) + '0')
205 Node *escontext = fcinfo->context;
233 else if ((tp[1] >=
'0' && tp[1] <=
'3') &&
234 (tp[2] >=
'0' && tp[2] <=
'7') &&
235 (tp[3] >=
'0' && tp[3] <=
'7'))
243 *
rp++ = v +
VAL(tp[3]);
247 else if (tp[1] ==
'\\')
259 errmsg(
"invalid input syntax for type %s",
"bytea")));
303 else if ((
unsigned char) *
vp < 0x20 || (
unsigned char) *
vp > 0x7e)
328 else if ((
unsigned char) *
vp < 0x20 || (
unsigned char) *
vp > 0x7e)
347 elog(
ERROR,
"unrecognized \"bytea_output\" setting: %d",
365 nbytes =
buf->len -
buf->cursor;
417 elog(
ERROR,
"bytea_string_agg_transfn called in non-aggregate context");
619 for (p = 0; p <=
px; p++)
652 errmsg(
"index %d out of valid range, 0..%d",
692 if (
byte & (1 <<
bitNo))
719 errmsg(
"index %d out of valid range, 0..%d",
768 errmsg(
"new bit must be 0 or 1")));
972 if ((
cmp == 0) && (len1 != len2))
973 cmp = (len1 < len2) ? -1 : 1;
995 result = ((
cmp > 0) || ((
cmp == 0) && (len1 > len2)) ?
arg1 :
arg2);
1014 result = ((
cmp < 0) || ((
cmp == 0) && (len1 < len2)) ?
arg1 :
arg2);
1040 if ((result == 0) && (len1 != len2))
1041 result = (len1 < len2) ? -1 : 1;
1070 pres = (
char *) &res;
1161 if (memtupcount < 100)
1182 elog(
LOG,
"bytea_abbrev: abbrev_distinct after %d: %f "
1183 "(key_distinct: %f, norm_abbrev_card: %f, prop_card: %f)",
1197 if (memtupcount > 10000)
1198 bss->prop_card *= 0.65;
1207 elog(
LOG,
"bytea_abbrev: aborted abbreviation at %d "
1208 "(abbrev_distinct: %f, key_distinct: %f, prop_card: %f)",
1232 bss->abbreviate =
true;
1233 bss->prop_card = 0.20;
1258 if (
len >
sizeof(result))
1261 errmsg(
"smallint out of range"));
1265 for (
int i = 0;
i <
len;
i++)
1283 if (
len >
sizeof(result))
1286 errmsg(
"integer out of range"));
1290 for (
int i = 0;
i <
len;
i++)
1308 if (
len >
sizeof(result))
1311 errmsg(
"bigint out of range"));
1315 for (
int i = 0;
i <
len;
i++)
1356 errmsg(
"invalid input length for type %s",
"uuid"),
Datum byteacat(PG_FUNCTION_ARGS)
Datum uuid_bytea(PG_FUNCTION_ARGS)
Datum byteaoverlay(PG_FUNCTION_ARGS)
Datum byteaeq(PG_FUNCTION_ARGS)
Datum byteagt(PG_FUNCTION_ARGS)
Datum bytea_int2(PG_FUNCTION_ARGS)
Datum bytea_string_agg_finalfn(PG_FUNCTION_ARGS)
Datum int2_bytea(PG_FUNCTION_ARGS)
Datum byteapos(PG_FUNCTION_ARGS)
static bytea * bytea_overlay(bytea *t1, bytea *t2, int sp, int sl)
Datum byteane(PG_FUNCTION_ARGS)
Datum byteage(PG_FUNCTION_ARGS)
Datum byteacmp(PG_FUNCTION_ARGS)
Datum byteaGetBit(PG_FUNCTION_ARGS)
Datum bytea_bit_count(PG_FUNCTION_ARGS)
Datum byteaSetBit(PG_FUNCTION_ARGS)
Datum byteaSetByte(PG_FUNCTION_ARGS)
static int byteafastcmp(Datum x, Datum y, SortSupport ssup)
Datum bytea_substr_no_len(PG_FUNCTION_ARGS)
Datum byteale(PG_FUNCTION_ARGS)
#define PG_STR_GET_BYTEA(str_)
Datum int8_bytea(PG_FUNCTION_ARGS)
Datum bytea_int4(PG_FUNCTION_ARGS)
Datum bytearecv(PG_FUNCTION_ARGS)
Datum bytea_smaller(PG_FUNCTION_ARGS)
Datum bytea_sortsupport(PG_FUNCTION_ARGS)
static bytea * bytea_substring(Datum str, int S, int L, bool length_not_specified)
static Datum bytea_abbrev_convert(Datum original, SortSupport ssup)
static bool bytea_abbrev_abort(int memtupcount, SortSupport ssup)
static bytea * bytea_catenate(bytea *t1, bytea *t2)
Datum bytea_uuid(PG_FUNCTION_ARGS)
Datum bytea_reverse(PG_FUNCTION_ARGS)
Datum byteaoverlay_no_len(PG_FUNCTION_ARGS)
Datum bytea_int8(PG_FUNCTION_ARGS)
Datum bytea_larger(PG_FUNCTION_ARGS)
Datum byteaoctetlen(PG_FUNCTION_ARGS)
Datum byteaout(PG_FUNCTION_ARGS)
Datum byteain(PG_FUNCTION_ARGS)
Datum bytea_string_agg_transfn(PG_FUNCTION_ARGS)
Datum byteaGetByte(PG_FUNCTION_ARGS)
Datum int4_bytea(PG_FUNCTION_ARGS)
Datum bytea_substr(PG_FUNCTION_ARGS)
Datum bytealt(PG_FUNCTION_ARGS)
Datum byteasend(PG_FUNCTION_ARGS)
#define Assert(condition)
Size toast_raw_datum_size(Datum value)
int errcode(int sqlerrcode)
#define ereturn(context, dummy_value,...)
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
uint64 hex_decode_safe(const char *src, size_t len, char *dst, Node *escontext)
uint64 hex_encode(const char *src, size_t len, char *dst)
struct SortSupportData * SortSupport
#define palloc_object(type)
#define PG_FREE_IF_COPY(ptr, n)
#define DatumGetByteaPSlice(X, m, n)
#define PG_GETARG_BYTEA_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define DatumGetByteaPP(X)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_RETURN_INT64(x)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_INT16(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_POINTER(x)
#define PG_GETARG_BYTEA_P_COPY(n)
#define PG_RETURN_BOOL(x)
void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
static Datum hash_uint32(uint32 k)
static Datum hash_any(const unsigned char *k, int keylen)
void initHyperLogLog(hyperLogLogState *cState, uint8 bwidth)
double estimateHyperLogLog(hyperLogLogState *cState)
void addHyperLogLog(hyperLogLogState *cState, uint32 hash)
Datum int8send(PG_FUNCTION_ARGS)
Datum int2send(PG_FUNCTION_ARGS)
Datum int4send(PG_FUNCTION_ARGS)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
void pfree(void *pointer)
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint64 pg_popcount(const char *buf, int bytes)
#define DatumBigEndianToNative(x)
#define PG_CACHE_LINE_SIZE
static char buf[DEFAULT_XLOG_SEG_SIZE]
static uint32 DatumGetUInt32(Datum X)
static uint64 DatumGetUInt64(Datum X)
static Datum PointerGetDatum(const void *X)
static int cmp(const chr *x, const chr *y, size_t len)
static unsigned hash(unsigned *uv, int n)
struct StringInfoData * StringInfo
StringInfo makeStringInfo(void)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
hyperLogLogState full_card
hyperLogLogState abbr_card
int(* comparator)(Datum x, Datum y, SortSupport ssup)
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
int(* abbrev_full_comparator)(Datum x, Datum y, SortSupport ssup)
bool(* abbrev_abort)(int memtupcount, SortSupport ssup)
int ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
Datum uuid_send(PG_FUNCTION_ARGS)
#define PG_RETURN_UUID_P(X)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)