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

Reply via email to