From: | Ewald Geschwinde <webmaster(at)geschwinde(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | index a datatype |
Date: | 2002-05-22 13:53:07 |
Message-ID: | 3CEBA2C3.3060408@geschwinde.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I have looked at the cube datataype in the contrib but I''m not sure
that I'm on the right way
I have found these functions:
-- support routines for indexing
CREATE FUNCTION cube_union(cube, cube) RETURNS cube
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION cube_inter(cube, cube) RETURNS cube
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION cube_size(cube) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
and there are the same functions written in c in the file
/* cube_union */
NDBOX *
cube_union(NDBOX * box_a, NDBOX * box_b)
{
int i;
NDBOX *result;
NDBOX *a = swap_corners(box_a);
NDBOX *b = swap_corners(box_b);
if (a->dim >= b->dim)
{
result = palloc(a->size);
result->size = a->size;
result->dim = a->dim;
}
else
{
result = palloc(b->size);
result->size = b->size;
result->dim = b->dim;
}
/* swap the box pointers if needed */
if (a->dim < b->dim)
{
NDBOX *tmp = b;
b = a;
a = tmp;
}
/*
* use the potentially smaller of the two boxes (b) to fill in the
* result, padding absent dimensions with zeroes
*/
for (i = 0; i < b->dim; i++)
{
result->x[i] = b->x[i];
result->x[i + a->dim] = b->x[i + b->dim];
}
for (i = b->dim; i < a->dim; i++)
{
result->x[i] = 0;
result->x[i + a->dim] = 0;
}
/* compute the union */
for (i = 0; i < a->dim; i++)
result->x[i] = min(a->x[i], result->x[i]);
for (i = a->dim; i < a->dim * 2; i++)
result->x[i] = max(a->x[i], result->x[i]);
pfree(a);
pfree(b);
return (result);
}
Now my question is:
Is it easy to write an indexed datatype without touching the, let's say
internal code, of postgresql
Are there some problems when writing indexed datatypes?
Any information and suggestaions welcome
Ewald
From | Date | Subject | |
---|---|---|---|
Next Message | Lee Kindness | 2002-05-22 13:57:25 | Re: Redhat 7.3 time manipulation bug |
Previous Message | D'Arcy J.M. Cain | 2002-05-22 13:51:24 | Edge case problem with pg_dump |