21 #define DatumGetSegP(X) ((SEG *) DatumGetPointer(X)) 22 #define PG_GETARG_SEG_P(n) DatumGetSegP(PG_GETARG_DATUM(n)) 125 p = result = (
char *)
palloc(40);
139 if (seg->
l_ext !=
'-')
146 if (seg->
u_ext !=
'-')
235 numranges = entryvec->
n;
237 *sizep =
sizeof(
SEG);
239 for (i = 1; i < numranges; i++)
283 *result = tmp1 - tmp2;
287 fprintf(stderr,
"\t%g\n", *result);
333 fprintf(stderr,
"picksplit\n");
337 maxoff = entryvec->
n - 1;
344 for (i = 1; i <= maxoff; i++)
349 sort_items[i - 1].
index =
i;
350 sort_items[i - 1].
data = seg;
356 firstright = maxoff / 2;
369 memcpy(seg_l, sort_items[0].data,
sizeof(
SEG));
370 *left++ = sort_items[0].
index;
372 for (i = 1; i < firstright; i++)
379 *left++ = sort_items[
i].
index;
387 memcpy(seg_r, sort_items[firstright].data,
sizeof(
SEG));
388 *right++ = sort_items[firstright].
index;
390 for (i = firstright + 1; i < maxoff; i++)
397 *right++ = sort_items[
i].
index;
421 fprintf(stderr,
"same: %s\n", (*result ?
"TRUE" :
"FALSE"));
435 #ifdef GIST_QUERY_DEBUG 436 fprintf(stderr,
"leaf_consistent, %d\n", strategy);
479 #ifdef GIST_QUERY_DEBUG 480 fprintf(stderr,
"internal_consistent, %d\n", strategy);
529 *sizep =
sizeof(
SEG);
781 elog(
ERROR,
"bogus lower boundary types %d %d",
839 elog(
ERROR,
"bogus upper boundary types %d %d",
916 '0',
'0',
'0',
'0',
'0',
917 '0',
'0',
'0',
'0',
'0',
918 '0',
'0',
'0',
'0',
'0',
919 '0',
'0',
'0',
'0',
'0',
920 '0',
'0',
'0',
'0',
'\0' 935 sign = (val < 0 ? 1 : 0);
938 sprintf(result,
"%.*e", n - 1, val);
941 p = strchr(result,
'e');
945 return strlen(result);
961 for (p = result + sign, i = 10, dp = 0; *p !=
'e'; p++, i++)
975 if (dp - 10 + exp >= n)
982 exp = dp - 10 + exp - n;
989 for (i = 23; i > dp; i--)
999 sprintf(&buf[11 + n],
"e%d", exp + n - 1);
1001 sprintf(&buf[11],
"e%d", exp + n - 1);
1006 strcpy(result, &buf[9]);
1009 strcpy(result, &buf[10]);
1014 for (i = 23; i > dp; i--)
1015 buf[i] = buf[i - 1];
1021 strcpy(result, &buf[9]);
1024 strcpy(result, &buf[10]);
1035 strcpy(result, &buf[dp - 2]);
1038 strcpy(result, &buf[dp - 1]);
1047 return strlen(result);
1068 for (c = *p; (c ==
'0' || c ==
'+' || c ==
'-') && c != 0; c = *(++p));
1071 for (c = *p; (c ==
'0' || c ==
'.') && c != 0; c = *(++p))
1078 for (c = *p, n = 0; c != 0; c = *(++p))
1080 if (!((c >=
'0' && c <=
'9') || (c ==
'.')))
#define PG_RETURN_POINTER(x)
static Datum gseg_leaf_consistent(Datum key, Datum query, StrategyNumber strategy)
Datum gseg_same(PG_FUNCTION_ARGS)
#define PG_RETURN_FLOAT4(x)
Datum seg_same(PG_FUNCTION_ARGS)
static int gseg_picksplit_item_cmp(const void *a, const void *b)
static void rt_seg_size(SEG *a, float *size)
#define RTOldContainsStrategyNumber
#define RTOldContainedByStrategyNumber
#define RTLeftStrategyNumber
Datum seg_lower(PG_FUNCTION_ARGS)
Datum seg_contains(PG_FUNCTION_ARGS)
#define PointerGetDatum(X)
#define PG_GETARG_DATUM(n)
Datum seg_out(PG_FUNCTION_ARGS)
#define PG_RETURN_INT32(x)
Datum gseg_union(PG_FUNCTION_ARGS)
#define RTContainedByStrategyNumber
#define PG_GETARG_POINTER(n)
void seg_scanner_finish(void)
Datum seg_left(PG_FUNCTION_ARGS)
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
Datum seg_right(PG_FUNCTION_ARGS)
Datum seg_size(PG_FUNCTION_ARGS)
int seg_yyparse(SEG *result)
static Datum gseg_binary_union(Datum r1, Datum r2, int *sizep)
Datum seg_in(PG_FUNCTION_ARGS)
Datum seg_contained(PG_FUNCTION_ARGS)
Datum seg_over_left(PG_FUNCTION_ARGS)
int significant_digits(const char *s)
Datum seg_center(PG_FUNCTION_ARGS)
Datum gseg_compress(PG_FUNCTION_ARGS)
#define RTSameStrategyNumber
#define PG_GETARG_SEG_P(n)
Datum gseg_penalty(PG_FUNCTION_ARGS)
#define RTOverRightStrategyNumber
Datum seg_overlap(PG_FUNCTION_ARGS)
Datum seg_ge(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(seg_in)
void seg_scanner_init(const char *str)
#define RTOverLeftStrategyNumber
#define PG_RETURN_BOOL(x)
Datum seg_gt(PG_FUNCTION_ARGS)
#define PG_RETURN_DATUM(x)
Datum seg_union(PG_FUNCTION_ARGS)
Datum seg_lt(PG_FUNCTION_ARGS)
#define RTRightStrategyNumber
#define PG_RETURN_CSTRING(x)
#define RTContainsStrategyNumber
static int restore(char *s, float val, int n)
Datum seg_upper(PG_FUNCTION_ARGS)
Datum gseg_decompress(PG_FUNCTION_ARGS)
static Datum gseg_internal_consistent(Datum key, Datum query, StrategyNumber strategy)
#define PG_GETARG_UINT16(n)
void seg_yyerror(SEG *result, const char *message) pg_attribute_noreturn()
Datum seg_inter(PG_FUNCTION_ARGS)
Datum seg_cmp(PG_FUNCTION_ARGS)
Datum seg_over_right(PG_FUNCTION_ARGS)
Datum gseg_consistent(PG_FUNCTION_ARGS)
#define PG_GETARG_CSTRING(n)
#define RTOverlapStrategyNumber
#define qsort(a, b, c, d)
Datum seg_different(PG_FUNCTION_ARGS)
Datum seg_le(PG_FUNCTION_ARGS)
#define DirectFunctionCall2(func, arg1, arg2)
static int cmp(const chr *x, const chr *y, size_t len)
Datum gseg_picksplit(PG_FUNCTION_ARGS)