Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3a20b0e7
Commit
3a20b0e7
authored
Mar 28, 2015
by
Heikki Linnakangas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add index-only scan support to inet GiST opclass.
Andreas Karlsson
parent
16bbb96a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
1 deletion
+57
-1
src/backend/utils/adt/network_gist.c
src/backend/utils/adt/network_gist.c
+27
-0
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+1
-1
src/include/catalog/pg_amproc.h
src/include/catalog/pg_amproc.h
+1
-0
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+2
-0
src/include/utils/inet.h
src/include/utils/inet.h
+1
-0
src/test/regress/expected/inet.out
src/test/regress/expected/inet.out
+19
-0
src/test/regress/sql/inet.sql
src/test/regress/sql/inet.sql
+6
-0
No files found.
src/backend/utils/adt/network_gist.c
View file @
3a20b0e7
...
...
@@ -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
*
...
...
src/include/catalog/catversion.h
View file @
3a20b0e7
...
...
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 2015032
6
1
#define CATALOG_VERSION_NO 2015032
8
1
#endif
src/include/catalog/pg_amproc.h
View file @
3a20b0e7
...
...
@@ -411,6 +411,7 @@ DATA(insert ( 3550 869 869 4 3556 ));
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
));
...
...
src/include/catalog/pg_proc.h
View file @
3a20b0e7
...
...
@@ -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_
));
...
...
src/include/utils/inet.h
View file @
3a20b0e7
...
...
@@ -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
);
...
...
src/test/regress/expected/inet.out
View file @
3a20b0e7
...
...
@@ -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
...
...
src/test/regress/sql/inet.sql
View file @
3a20b0e7
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment