27#include "utils/fmgrprotos.h"
94#define PG_STR_GET_BYTEA(str_) \
95 DatumGetByteaPP(DirectFunctionCall1(byteain, CStringGetDatum(str_)))
125 errmsg(
"negative substring length not allowed")));
173 errmsg(
"negative substring length not allowed")));
177 errmsg(
"integer out of range")));
191#define VAL(CH) ((CH) - '0')
192#define DIG(VAL) ((VAL) + '0')
204 Node *escontext = fcinfo->context;
232 else if ((tp[1] >=
'0' && tp[1] <=
'3') &&
233 (tp[2] >=
'0' && tp[2] <=
'7') &&
234 (tp[3] >=
'0' && tp[3] <=
'7'))
242 *
rp++ = v +
VAL(tp[3]);
246 else if (tp[1] ==
'\\')
258 errmsg(
"invalid input syntax for type %s",
"bytea")));
302 else if ((
unsigned char) *
vp < 0x20 || (
unsigned char) *
vp > 0x7e)
327 else if ((
unsigned char) *
vp < 0x20 || (
unsigned char) *
vp > 0x7e)
346 elog(
ERROR,
"unrecognized \"bytea_output\" setting: %d",
364 nbytes =
buf->len -
buf->cursor;
416 elog(
ERROR,
"bytea_string_agg_transfn called in non-aggregate context");
618 for (p = 0; p <=
px; p++)
651 errmsg(
"index %d out of valid range, 0..%d",
691 if (
byte & (1 <<
bitNo))
718 errmsg(
"index %d out of valid range, 0..%d",
767 errmsg(
"new bit must be 0 or 1")));
971 if ((
cmp == 0) && (len1 != len2))
972 cmp = (len1 < len2) ? -1 : 1;
994 result = ((
cmp > 0) || ((
cmp == 0) && (len1 > len2)) ?
arg1 :
arg2);
1013 result = ((
cmp < 0) || ((
cmp == 0) && (len1 < len2)) ?
arg1 :
arg2);
1039 if ((result == 0) && (len1 != len2))
1040 result = (len1 < len2) ? -1 : 1;
1069 pres = (
char *) &res;
1160 if (memtupcount < 100)
1181 elog(
LOG,
"bytea_abbrev: abbrev_distinct after %d: %f "
1182 "(key_distinct: %f, norm_abbrev_card: %f, prop_card: %f)",
1196 if (memtupcount > 10000)
1197 bss->prop_card *= 0.65;
1206 elog(
LOG,
"bytea_abbrev: aborted abbreviation at %d "
1207 "(abbrev_distinct: %f, key_distinct: %f, prop_card: %f)",
1231 bss->abbreviate =
true;
1232 bss->prop_card = 0.20;
1257 if (
len >
sizeof(result))
1260 errmsg(
"smallint out of range"));
1264 for (
int i = 0;
i <
len;
i++)
1282 if (
len >
sizeof(result))
1285 errmsg(
"integer out of range"));
1289 for (
int i = 0;
i <
len;
i++)
1307 if (
len >
sizeof(result))
1310 errmsg(
"bigint out of range"));
1314 for (
int i = 0;
i <
len;
i++)
Datum byteacat(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_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 errmsg_internal(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#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)
#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 SortSupportData * SortSupport
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)
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)