Hi,
This is in reference to BUG #5705 and corresponding todo item: Fix
/contrib/btree_gist's implementation of inet indexing
Issue: SELECT '1.255.255.200/8'::inet < '1.0.0.0'::inet didn't worked
with index.
I am not able to repro this issue.
Steps:
SELECT '1.255.255.200/8'::inet < '1.0.0.0'::inet;
?column?
----------
t
(1 row)
CREATE TABLE inet_test (a inet);
INSERT INTO inet_test VALUES ('1.255.255.200/8');
SELECT * FROM inet_test WHERE a < '1.0.0.0'::inet;
a
-----------------
1.255.255.200/8
(1 row)
EXPLAIN ANALYZE SELECT * FROM inet_test WHERE a < '1.0.0.0'::inet;
QUERY PLAN
----------------------------------------------------------------------------------------------------
Seq Scan on inet_test (cost=0.00..1.01 rows=1 width=32) (actual
time=0.032..0.033 rows=1 loops=1)
Filter: (a < '1.0.0.0'::inet)
Planning Time: 0.040 ms
Execution Time: 0.049 ms
(4 rows)
UPDATE pg_opclass SET opcdefault=true WHERE opcname = 'inet_ops';
CREATE INDEX inet_test_idx ON inet_test USING gist (a);
SET enable_seqscan = false;
SELECT * FROM inet_test WHERE a < '1.0.0.0'::inet;
a
-----------------
1.255.255.200/8
## This was expected to return 0 rows as in bug report
EXPLAIN analyze SELECT * FROM inet_test WHERE a < '1.0.0.0'::inet;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------
-----
Index Only Scan using inet_test_idx on inet_test (cost=0.12..8.14
rows=1 width=32) (actual time=0.024..0.025 rows=1 loop
s=1)
Index Cond: (a < '1.0.0.0'::inet)
Heap Fetches: 1
Planning Time: 0.056 ms
Execution Time: 0.044 ms
(5 rows)
Gist index works fine as opposed to issue reported in the bug. Bug
should be marked as resolved and todo item can be removed.
--
Regards,
Ankit Kumar Pandey