1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Add index-only scan support to inet GiST opclass.

Andreas Karlsson
This commit is contained in:
Heikki Linnakangas
2015-03-28 15:11:53 +02:00
parent 16bbb96a2b
commit 3a20b0e7b6
7 changed files with 57 additions and 1 deletions

View File

@ -587,6 +587,33 @@ inet_gist_decompress(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(entry);
}
/*
* The GiST fetch function
*
* Reconstruct the original inet datum from a GistInetKey.
*/
Datum
inet_gist_fetch(PG_FUNCTION_ARGS)
{
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
GistInetKey *key = DatumGetInetKeyP(entry->key);
GISTENTRY *retval;
inet *dst;
dst = (inet *) palloc0(sizeof(inet));
ip_family(dst) = gk_ip_family(key);
ip_bits(dst) = gk_ip_minbits(key);
memcpy(ip_addr(dst), gk_ip_addr(key), ip_addrsize(dst));
SET_INET_VARSIZE(dst);
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, InetPGetDatum(dst), entry->rel, entry->page,
entry->offset, FALSE);
PG_RETURN_POINTER(retval);
}
/*
* The GiST page split penalty function
*