index 14dd62b77195fe21b27d73a429f2a8040964edb9..cd2b8b19a770397ef8d2d8b2576ab4303aa498f8 100644 (file)
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
*
index 3d50f704021e8222f1779d7a1476fa965ce931a5..f3f148a8c52acaa448f414ad2f4ec3f950b32ca5 100644 (file)
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201503261
+#define CATALOG_VERSION_NO 201503281
#endif
index 612a9d242e327b08a95b87ddef24b5bd34d3f07f..037684c3f2ba560d0d11bf253ba5821570b8f359 100644 (file)
DATA(insert ( 3550 869 869 5 3557 ));
DATA(insert ( 3550 869 869 6 3558 ));
DATA(insert ( 3550 869 869 7 3559 ));
+DATA(insert ( 3550 869 869 9 3573 ));
/* sp-gist */
DATA(insert ( 3474 3831 3831 1 3469 ));
index 77b77176a334c17e02fddc40cdb0cc6bb996eefe..a96d3695dfc86545ba15b2d54e72ea233ed78f91 100644 (file)
@@ -2240,6 +2240,8 @@ DATA(insert OID = 3555 ( inet_gist_compress PGNSP PGUID 12 1 0 0 0 f f f f t f
DESCR("GiST support");
DATA(insert OID = 3556 ( inet_gist_decompress PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2281 "2281" _null_ _null_ _null_ _null_ inet_gist_decompress _null_ _null_ _null_ ));
DESCR("GiST support");
+DATA(insert OID = 3573 ( inet_gist_fetch PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2281 "2281" _null_ _null_ _null_ _null_ inet_gist_fetch _null_ _null_ _null_ ));
+DESCR("GiST support");
DATA(insert OID = 3557 ( inet_gist_penalty PGNSP PGUID 12 1 0 0 0 f f f f t f i 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ inet_gist_penalty _null_ _null_ _null_ ));
DESCR("GiST support");
DATA(insert OID = 3558 ( inet_gist_picksplit PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ inet_gist_picksplit _null_ _null_ _null_ ));
index 66946886c72d5e101c2b1937ff94fbdde066a447..2d2bae4cbe6efe1abd12b4ef06b4d5940b27ab2b 100644 (file)
@@ -123,6 +123,7 @@ extern int bitncommon(const unsigned char *l, const unsigned char *r, int n);
/*
* GiST support functions in network_gist.c
*/
+extern Datum inet_gist_fetch(PG_FUNCTION_ARGS);
extern Datum inet_gist_consistent(PG_FUNCTION_ARGS);
extern Datum inet_gist_union(PG_FUNCTION_ARGS);
extern Datum inet_gist_compress(PG_FUNCTION_ARGS);
index d58bf017b693170ac7dfd0dfe704f22b304db86e..d25e5e42a79cad98f5a7d277cafa416710fbd67d 100644 (file)
@@ -390,6 +390,25 @@ SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i;
10:23::8000/113 | 10:23::ffff
(16 rows)
+-- test index-only scans
+EXPLAIN (COSTS OFF)
+SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i;
+ QUERY PLAN
+---------------------------------------------------
+ Sort
+ Sort Key: i
+ -> Index Only Scan using inet_idx2 on inet_tbl
+ Index Cond: (i << '192.168.1.0/24'::inet)
+(4 rows)
+
+SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i;
+ i
+------------------
+ 192.168.1.0/25
+ 192.168.1.255/25
+ 192.168.1.226
+(3 rows)
+
SET enable_seqscan TO on;
DROP INDEX inet_idx2;
-- simple tests of inet boolean and arithmetic operators
index c9792b71201f3991b71d03a957f707dc4e069715..2034d3e86f643765b178180ce29ddac777b9fbf1 100644 (file)
@@ -84,6 +84,12 @@ SELECT * FROM inet_tbl WHERE i = '192.168.1.0/24'::cidr ORDER BY i;
SELECT * FROM inet_tbl WHERE i >= '192.168.1.0/24'::cidr ORDER BY i;
SELECT * FROM inet_tbl WHERE i > '192.168.1.0/24'::cidr ORDER BY i;
SELECT * FROM inet_tbl WHERE i <> '192.168.1.0/24'::cidr ORDER BY i;
+
+-- test index-only scans
+EXPLAIN (COSTS OFF)
+SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i;
+SELECT i FROM inet_tbl WHERE i << '192.168.1.0/24'::cidr ORDER BY i;
+
SET enable_seqscan TO on;
DROP INDEX inet_idx2;