Skip site navigation (1) Skip section navigation (2)

Re: gist access methods parameter types

From: Marios Vodas <mvodas(at)gmail(dot)com>
To: Dimitri Fontaine <dfontaine(at)hi-media(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: gist access methods parameter types
Date: 2010-09-27 15:52:07
Message-ID: AANLkTi=TYUrWad9wO_mj9WeRZeYEYOgwc45-ZLYhbf_Y@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Please can you answer the question of whether entry->key in compress should
be of delta3d sql type (composite type) and if not of what it should be
since the type I index is different from the type stored in tree?
Taking into consideration the types I described before this is my code for
compress.

Datum delta3d_compress(PG_FUNCTION_ARGS) {
    GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
    GISTENTRY *retval;

    HeapTupleHeader in;
    HeapTupleHeader i;
    HeapTupleHeader e;
    bool isnull;

    if (entry->leafkey) {
        in = DatumGetHeapTupleHeader(entry->key);

        if (in != NULL) {
            i = DatumGetHeapTupleHeader(GetAttributeByName(in, "i",
&isnull));
            e = DatumGetHeapTupleHeader(GetAttributeByName(in, "e",
&isnull));

            delta3d *compressed_data = (delta3d *) palloc(sizeof (delta3d));
            compressed_data->xi = DatumGetFloat8(GetAttributeByName(i, "x",
&isnull));
            compressed_data->yi = DatumGetFloat8(GetAttributeByName(i, "y",
&isnull));
            compressed_data->ti = DatumGetTimestamp(GetAttributeByName(i,
"t", &isnull));
            compressed_data->xe = DatumGetFloat8(GetAttributeByName(e, "x",
&isnull));
            compressed_data->ye = DatumGetFloat8(GetAttributeByName(e, "y",
&isnull));
            compressed_data->te = DatumGetTimestamp(GetAttributeByName(e,
"t", &isnull));
            compressed_data->trajectory =
DatumGetInt32(GetAttributeByName(in, "trajectory", &isnull));

            retval = palloc(sizeof (GISTENTRY));
            gistentryinit(*retval, PointerGetDatum(compressed_data),
entry->rel, entry->page, entry->offset, FALSE);
        } else {
            retval = palloc(sizeof (GISTENTRY));
            gistentryinit(*retval, (Datum) 0, entry->rel, entry->page,
entry->offset, FALSE);
        }
    } else {
        retval = entry; *//does this have to change? I thing it is going to
be of C type delta3d_mbb, am I right?*
    }

    PG_RETURN_POINTER(retval);
}

In response to

pgsql-hackers by date

Next:From: Guillaume Du PasquierDate: 2010-09-27 15:53:35
Subject: client socket TIME_WAIT state after PQfinish
Previous:From: Alvaro HerreraDate: 2010-09-27 15:35:24
Subject: Re: A small update for postgresql.conf.sample

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group