1
1
/******************************************************************************
2
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.36 2008/05/29 18:46:40 tgl Exp $
2
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.37 2009/06/11 14:48:50 momjian Exp $
4
4
This file contains routines that can be bound to a Postgres backend and
5
5
called by the backend in the process of processing queries. The calling
135
135
** For internal use only
137
int32 cube_cmp_v0(NDBOX * a, NDBOX * b);
138
bool cube_contains_v0(NDBOX * a, NDBOX * b);
139
bool cube_overlap_v0(NDBOX * a, NDBOX * b);
140
NDBOX *cube_union_v0(NDBOX * a, NDBOX * b);
141
void rt_cube_size(NDBOX * a, double *sz);
142
NDBOX *g_cube_binary_union(NDBOX * r1, NDBOX * r2, int *sizep);
143
bool g_cube_leaf_consistent(NDBOX * key, NDBOX * query, StrategyNumber strategy);
144
bool g_cube_internal_consistent(NDBOX * key, NDBOX * query, StrategyNumber strategy);
137
int32 cube_cmp_v0(NDBOX *a, NDBOX *b);
138
bool cube_contains_v0(NDBOX *a, NDBOX *b);
139
bool cube_overlap_v0(NDBOX *a, NDBOX *b);
140
NDBOX *cube_union_v0(NDBOX *a, NDBOX *b);
141
void rt_cube_size(NDBOX *a, double *sz);
142
NDBOX *g_cube_binary_union(NDBOX *r1, NDBOX *r2, int *sizep);
143
bool g_cube_leaf_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy);
144
bool g_cube_internal_consistent(NDBOX *key, NDBOX *query, StrategyNumber strategy);
147
147
** Auxiliary funxtions
201
201
dur = ARRPTR(ur);
202
202
dll = ARRPTR(ll);
204
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
204
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim;
205
205
result = (NDBOX *) palloc0(size);
206
206
SET_VARSIZE(result, size);
207
207
result->dim = dim;
238
238
dur = ARRPTR(ur);
240
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
240
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim;
241
241
result = (NDBOX *) palloc0(size);
242
242
SET_VARSIZE(result, size);
243
243
result->dim = dim;
270
270
dx = (int4 *) ARR_DATA_PTR(idx);
272
272
dim = ARRNELEMS(idx);
273
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2 * dim;
273
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2 * dim;
274
274
result = (NDBOX *) palloc0(size);
275
275
SET_VARSIZE(result, size);
276
276
result->dim = dim;
359
359
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
360
360
NDBOX *query = PG_GETARG_NDBOX(1);
361
361
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
362
363
/* Oid subtype = PG_GETARG_OID(3); */
363
364
bool *recheck = (bool *) PG_GETARG_POINTER(4);
906
907
/* make up a metric in which one box will be 'lower' than the other
907
908
-- this can be useful for sorting and to determine uniqueness */
909
cube_cmp_v0(NDBOX * a, NDBOX * b)
910
cube_cmp_v0(NDBOX *a, NDBOX *b)
1375
1376
if (a->dim > dim)
1377
size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
1378
size = offsetof(NDBOX, x[0]) +sizeof(double) * dim * 2;
1378
1379
result = (NDBOX *) palloc0(size);
1379
1380
SET_VARSIZE(result, size);
1380
1381
result->dim = dim;
1418
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
1419
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2;
1419
1420
result = (NDBOX *) palloc0(size);
1420
1421
SET_VARSIZE(result, size);
1421
1422
result->dim = 1;
1436
size = offsetof(NDBOX, x[0]) + sizeof(double) * 2;
1437
size = offsetof(NDBOX, x[0]) +sizeof(double) * 2;
1437
1438
result = (NDBOX *) palloc0(size);
1438
1439
SET_VARSIZE(result, size);
1439
1440
result->dim = 1;
1457
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
1458
size = offsetof(NDBOX, x[0]) +sizeof(double) * (c->dim + 1) *2;
1458
1459
result = (NDBOX *) palloc0(size);
1459
1460
SET_VARSIZE(result, size);
1460
1461
result->dim = c->dim + 1;
1484
size = offsetof(NDBOX, x[0]) + sizeof(double) * (c->dim + 1) *2;
1485
size = offsetof(NDBOX, x[0]) +sizeof(double) * (c->dim + 1) *2;
1485
1486
result = (NDBOX *) palloc0(size);
1486
1487
SET_VARSIZE(result, size);
1487
1488
result->dim = c->dim + 1;