problem with realizing gist index

Started by Sergej Galkinabout 16 years ago2 messages
#1Sergej Galkin
sergej.galkin@gmail.com

Hello all,
I'm creating gist index for testing purpuses :)

I created index element structure:

typedef struct moving_object
{
double x_high;
double y_high;
double x_low;
double y_low;
time_t mov_time;
double x_plus;
double y_plus;
double x_minus;
double y_minus;
} moving_object;

And defined macros that return pointer to this structure:

#define DatumGetMovP(x) ((moving_object*)DatumGetPointer(x))

but index interface function gives me error: Incompatible type in assignment
Error line I style - bold

Datum gist_mov_union(PG_FUNCTION_ARGS)
{
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
int *sizep = (int *) PG_GETARG_POINTER(1);
int num_obj;
moving_object *pageunion, curr;

num_obj = entryvec->n;

pageunion = (moving_object*) palloc(sizeof(moving_object));
// THIS IS THE ERROR LINE
* curr = DatumGetMovP(entryvec->vector[0].key);*
make_now(curr);
memcpy((void *) pageunion, (void *) curr, sizeof(moving_object));

for(int i = 1; i < num_obj; i++)
{
curr = DatumGetMovP(entryvec->vector[i].key);
make_now(curr);
if (pageunion->x_high > curr->x_high)
pageunion->x_high = curr->x_high;
if (pageunion->y_high < curr->y_high)
pageunion->y_high = curr->y_high;
if (pageunion->x_low < curr->x_low)
pageunion->x_low = curr->x_low;
if (pageunion->y_low > curr->y_low)
pageunion->y_low = curr->y_low;
}

*sizep = sizeof(moving_object);
PG_RETURN_POINTER(pageunion);
}*
*

Can anybody know what the problem ? I imagine that my defined function
returns not pointer, but stucture (??) ?

Best regards,
Sergej Galkin

#2Nicolas Barbier
nicolas.barbier@gmail.com
In reply to: Sergej Galkin (#1)
Re: problem with realizing gist index

2009/12/31 Sergej Galkin <sergej.galkin@gmail.com>:

typedef struct moving_object
{
    double x_high;
    double y_high;
    double x_low;
    double y_low;
    time_t mov_time;
    double x_plus;
    double y_plus;
    double x_minus;
    double y_minus;
} moving_object;

[..]

#define DatumGetMovP(x) ((moving_object*)DatumGetPointer(x))

[..]

but index interface function gives me error: Incompatible type in assignment

[..]

    moving_object *pageunion, curr;

Note that curr is not defined as a pointer.

        // THIS IS THE ERROR LINE
    curr = DatumGetMovP(entryvec->vector[0].key);

But here you want to assign a pointer to it.

Nicolas