22 #define DatumGetSegP(X) ((SEG *) DatumGetPointer(X))
23 #define PG_GETARG_SEG_P(n) DatumGetSegP(PG_GETARG_DATUM(n))
96 static int restore(
char *result,
float val,
int n);
112 seg_yyerror(result, fcinfo->context,
"bogus input");
126 p = result = (
char *)
palloc(40);
140 if (seg->
l_ext !=
'-')
147 if (seg->
u_ext !=
'-')
236 numranges = entryvec->
n;
238 *sizep =
sizeof(
SEG);
240 for (
i = 1;
i < numranges;
i++)
284 *result = tmp1 - tmp2;
288 fprintf(stderr,
"\t%g\n", *result);
334 fprintf(stderr,
"picksplit\n");
338 maxoff = entryvec->
n - 1;
345 for (
i = 1;
i <= maxoff;
i++)
351 sort_items[
i - 1].
data = seg;
357 firstright = maxoff / 2;
370 memcpy(seg_l, sort_items[0].
data,
sizeof(
SEG));
371 *left++ = sort_items[0].
index;
373 for (
i = 1;
i < firstright;
i++)
380 *left++ = sort_items[
i].
index;
388 memcpy(seg_r, sort_items[firstright].
data,
sizeof(
SEG));
389 *right++ = sort_items[firstright].
index;
391 for (
i = firstright + 1;
i < maxoff;
i++)
398 *right++ = sort_items[
i].
index;
422 fprintf(stderr,
"same: %s\n", (*result ?
"TRUE" :
"FALSE"));
436 #ifdef GIST_QUERY_DEBUG
437 fprintf(stderr,
"leaf_consistent, %d\n", strategy);
480 #ifdef GIST_QUERY_DEBUG
481 fprintf(stderr,
"internal_consistent, %d\n", strategy);
530 *sizep =
sizeof(
SEG);
577 ((
b->upper >=
a->upper) && (
b->lower <=
a->upper)));
634 if (
a->upper >
b->upper)
648 if (
a->lower <
b->lower)
674 if (
a->upper <
b->upper)
688 if (
a->lower >
b->lower)
707 if (
a == (
SEG *) NULL ||
a->upper <=
a->lower)
710 *
size = fabsf(
a->upper -
a->lower);
734 if (
a->lower <
b->lower)
736 if (
a->lower >
b->lower)
746 if (
a->l_ext !=
b->l_ext)
765 if (
a->l_sigd <
b->l_sigd)
767 if (
a->l_sigd >
b->l_sigd)
775 if (
a->l_ext !=
b->l_ext)
782 elog(
ERROR,
"bogus lower boundary types %d %d",
783 (
int)
a->l_ext, (
int)
b->l_ext);
791 if (
a->upper <
b->upper)
793 if (
a->upper >
b->upper)
803 if (
a->u_ext !=
b->u_ext)
823 if (
a->u_sigd <
b->u_sigd)
825 if (
a->u_sigd >
b->u_sigd)
833 if (
a->u_ext !=
b->u_ext)
840 elog(
ERROR,
"bogus upper boundary types %d %d",
841 (
int)
a->u_ext, (
int)
b->u_ext);
917 '0',
'0',
'0',
'0',
'0',
918 '0',
'0',
'0',
'0',
'0',
919 '0',
'0',
'0',
'0',
'0',
920 '0',
'0',
'0',
'0',
'0',
921 '0',
'0',
'0',
'0',
'\0'
946 p = strchr(result,
'e');
950 return strlen(result);
966 for (p = result +
sign,
i = 10, dp = 0; *p !=
'e'; p++,
i++)
980 if (dp - 10 + exp >= n)
987 exp = dp - 10 + exp - n;
994 for (
i = 23;
i > dp;
i--)
1011 strcpy(result, &
buf[9]);
1014 strcpy(result, &
buf[10]);
1019 for (
i = 23;
i > dp;
i--)
1026 strcpy(result, &
buf[9]);
1029 strcpy(result, &
buf[10]);
1040 strcpy(result, &
buf[dp - 2]);
1043 strcpy(result, &
buf[dp - 1]);
1052 return strlen(result);
1073 for (
c = *p; (
c ==
'0' ||
c ==
'+' ||
c ==
'-') &&
c != 0;
c = *(++p));
1076 for (
c = *p; (
c ==
'0' ||
c ==
'.') &&
c != 0;
c = *(++p))
1083 for (
c = *p, n = 0;
c != 0;
c = *(++p))
1085 if (!((
c >=
'0' &&
c <=
'9') || (
c ==
'.')))
#define DirectFunctionCall2(func, arg1, arg2)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_DATUM(n)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_UINT16(n)
#define PG_RETURN_INT32(x)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_FLOAT4(x)
#define PG_RETURN_BOOL(x)
#define qsort(a, b, c, d)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static int32 DatumGetInt32(Datum X)
static int cmp(const chr *x, const chr *y, size_t len)
Datum seg_le(PG_FUNCTION_ARGS)
Datum gseg_decompress(PG_FUNCTION_ARGS)
Datum seg_gt(PG_FUNCTION_ARGS)
static Datum gseg_leaf_consistent(Datum key, Datum query, StrategyNumber strategy)
Datum gseg_penalty(PG_FUNCTION_ARGS)
Datum gseg_union(PG_FUNCTION_ARGS)
Datum gseg_consistent(PG_FUNCTION_ARGS)
Datum seg_center(PG_FUNCTION_ARGS)
Datum seg_over_right(PG_FUNCTION_ARGS)
Datum seg_contained(PG_FUNCTION_ARGS)
Datum seg_overlap(PG_FUNCTION_ARGS)
Datum seg_right(PG_FUNCTION_ARGS)
#define PG_GETARG_SEG_P(n)
Datum gseg_same(PG_FUNCTION_ARGS)
static int gseg_picksplit_item_cmp(const void *a, const void *b)
Datum seg_lt(PG_FUNCTION_ARGS)
Datum seg_size(PG_FUNCTION_ARGS)
Datum seg_union(PG_FUNCTION_ARGS)
int significant_digits(const char *s)
Datum seg_upper(PG_FUNCTION_ARGS)
static Datum gseg_internal_consistent(Datum key, Datum query, StrategyNumber strategy)
Datum seg_ge(PG_FUNCTION_ARGS)
Datum seg_lower(PG_FUNCTION_ARGS)
Datum gseg_picksplit(PG_FUNCTION_ARGS)
Datum seg_in(PG_FUNCTION_ARGS)
Datum seg_cmp(PG_FUNCTION_ARGS)
static int restore(char *result, float val, int n)
Datum seg_inter(PG_FUNCTION_ARGS)
Datum seg_left(PG_FUNCTION_ARGS)
static void rt_seg_size(SEG *a, float *size)
Datum seg_out(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(seg_in)
static Datum gseg_binary_union(Datum r1, Datum r2, int *sizep)
Datum seg_over_left(PG_FUNCTION_ARGS)
Datum gseg_compress(PG_FUNCTION_ARGS)
Datum seg_contains(PG_FUNCTION_ARGS)
Datum seg_same(PG_FUNCTION_ARGS)
Datum seg_different(PG_FUNCTION_ARGS)
int seg_yyparse(SEG *result, struct Node *escontext)
void seg_yyerror(SEG *result, struct Node *escontext, const char *message)
void seg_scanner_init(const char *str)
void seg_scanner_finish(void)
static pg_noinline void Size size
#define RTOldContainsStrategyNumber
#define RTOverlapStrategyNumber
#define RTLeftStrategyNumber
#define RTOverRightStrategyNumber
#define RTRightStrategyNumber
#define RTSameStrategyNumber
#define RTContainsStrategyNumber
#define RTOverLeftStrategyNumber
#define RTOldContainedByStrategyNumber
#define RTContainedByStrategyNumber
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]