Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7a9fa3

Browse files
committed
Add support for EUI-64 MAC addresses as macaddr8
This adds in support for EUI-64 MAC addresses by adding a new data typecalled 'macaddr8' (using our usual convention of indicating the numberof bytes stored).This was largely a copy-and-paste from the macaddr data type, withappropriate adjustments for having 8 bytes instead of 6 and addingsupport for converting a provided EUI-48 (6 byte format) to the EUI-64format. Conversion from EUI-48 to EUI-64 inserts FFFE as the 4th and5th bytes but does not perform the IPv6 modified EUI-64 action offlipping the 7th bit, but we add a function to perform that specificaction for the user as it may be commonly done by users who wish tocalculate their IPv6 address based on their network prefix and 48-bitMAC address.Author: Haribabu Kommi, with a good bit of rework of macaddr8_in by me.Reviewed by: Vitaly Burovoy, Kuntal GhoshDiscussion:https://postgr.es/m/CAJrrPGcUi8ZH+KkK+=TctNQ+EfkeCEHtMU_yo1mvX8hsk_ghNQ@mail.gmail.com
1 parent42bdaeb commitc7a9fa3

37 files changed

+1826
-20
lines changed

‎contrib/btree_gin/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ MODULE_big = btree_gin
44
OBJS = btree_gin.o$(WIN32RES)
55

66
EXTENSION = btree_gin
7-
DATA = btree_gin--1.0.sql btree_gin--unpackaged--1.0.sql
7+
DATA = btree_gin--1.0.sql btree_gin--1.0--1.1.sql btree_gin--unpackaged--1.0.sql
88
PGFILEDESC = "btree_gin - B-tree equivalent GIN operator classes"
99

1010
REGRESS = install_btree_gin int2 int4 int8 float4 float8 money oid\
1111
timestamp timestamptz time timetz date interval\
12-
macaddr inet cidr text varchar char bytea bit varbit\
12+
macaddrmacaddr8inet cidr text varchar char bytea bit varbit\
1313
numeric
1414

1515
ifdefUSE_PGXS
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* contrib/btree_gin/btree_gin--1.0--1.1.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use"ALTER EXTENSION btree_gin UPDATE TO '1.1'" to load this file. \quit
5+
6+
-- macaddr8 datatype support new in 10.0.
7+
CREATEFUNCTIONgin_extract_value_macaddr8(macaddr8, internal)
8+
RETURNS internal
9+
AS'MODULE_PATHNAME'
10+
LANGUAGE C STRICT IMMUTABLE;
11+
12+
CREATEFUNCTIONgin_compare_prefix_macaddr8(macaddr8, macaddr8, int2, internal)
13+
RETURNS int4
14+
AS'MODULE_PATHNAME'
15+
LANGUAGE C STRICT IMMUTABLE;
16+
17+
CREATEFUNCTIONgin_extract_query_macaddr8(macaddr8, internal, int2, internal, internal)
18+
RETURNS internal
19+
AS'MODULE_PATHNAME'
20+
LANGUAGE C STRICT IMMUTABLE;
21+
22+
CREATEOPERATOR CLASSmacaddr8_ops
23+
DEFAULT FOR TYPE macaddr8 USING gin
24+
AS
25+
OPERATOR1<,
26+
OPERATOR2<=,
27+
OPERATOR3=,
28+
OPERATOR4>=,
29+
OPERATOR5>,
30+
FUNCTION1 macaddr8_cmp(macaddr8, macaddr8),
31+
FUNCTION2 gin_extract_value_macaddr8(macaddr8, internal),
32+
FUNCTION3 gin_extract_query_macaddr8(macaddr8, internal, int2, internal, internal),
33+
FUNCTION4 gin_btree_consistent(internal, int2, anyelement, int4, internal, internal),
34+
FUNCTION5 gin_compare_prefix_macaddr8(macaddr8, macaddr8, int2, internal),
35+
STORAGE macaddr8;

‎contrib/btree_gin/btree_gin.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ leftmostvalue_macaddr(void)
322322

323323
GIN_SUPPORT(macaddr, false,leftmostvalue_macaddr,macaddr_cmp)
324324

325+
staticDatum
326+
leftmostvalue_macaddr8(void)
327+
{
328+
macaddr8*v=palloc0(sizeof(macaddr8));
329+
330+
returnMacaddr8PGetDatum(v);
331+
}
332+
333+
GIN_SUPPORT(macaddr8, false,leftmostvalue_macaddr8,macaddr8_cmp)
334+
325335
staticDatum
326336
leftmostvalue_inet(void)
327337
{

‎contrib/btree_gin/btree_gin.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# btree_gin extension
22
comment = 'support for indexing common datatypes in GIN'
3-
default_version = '1.0'
3+
default_version = '1.1'
44
module_pathname = '$libdir/btree_gin'
55
relocatable = true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
set enable_seqscan=off;
2+
CREATE TABLE test_macaddr8 (
3+
i macaddr8
4+
);
5+
INSERT INTO test_macaddr8 VALUES
6+
( '22:00:5c:03:55:08:01:02' ),
7+
( '22:00:5c:04:55:08:01:02' ),
8+
( '22:00:5c:05:55:08:01:02' ),
9+
( '22:00:5c:08:55:08:01:02' ),
10+
( '22:00:5c:09:55:08:01:02' ),
11+
( '22:00:5c:10:55:08:01:02' )
12+
;
13+
CREATE INDEX idx_macaddr8 ON test_macaddr8 USING gin (i);
14+
SELECT * FROM test_macaddr8 WHERE i<'22:00:5c:08:55:08:01:02'::macaddr8 ORDER BY i;
15+
i
16+
-------------------------
17+
22:00:5c:03:55:08:01:02
18+
22:00:5c:04:55:08:01:02
19+
22:00:5c:05:55:08:01:02
20+
(3 rows)
21+
22+
SELECT * FROM test_macaddr8 WHERE i<='22:00:5c:08:55:08:01:02'::macaddr8 ORDER BY i;
23+
i
24+
-------------------------
25+
22:00:5c:03:55:08:01:02
26+
22:00:5c:04:55:08:01:02
27+
22:00:5c:05:55:08:01:02
28+
22:00:5c:08:55:08:01:02
29+
(4 rows)
30+
31+
SELECT * FROM test_macaddr8 WHERE i='22:00:5c:08:55:08:01:02'::macaddr8 ORDER BY i;
32+
i
33+
-------------------------
34+
22:00:5c:08:55:08:01:02
35+
(1 row)
36+
37+
SELECT * FROM test_macaddr8 WHERE i>='22:00:5c:08:55:08:01:02'::macaddr8 ORDER BY i;
38+
i
39+
-------------------------
40+
22:00:5c:08:55:08:01:02
41+
22:00:5c:09:55:08:01:02
42+
22:00:5c:10:55:08:01:02
43+
(3 rows)
44+
45+
SELECT * FROM test_macaddr8 WHERE i>'22:00:5c:08:55:08:01:02'::macaddr8 ORDER BY i;
46+
i
47+
-------------------------
48+
22:00:5c:09:55:08:01:02
49+
22:00:5c:10:55:08:01:02
50+
(2 rows)
51+

‎contrib/btree_gin/sql/macaddr8.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set enable_seqscan=off;
2+
3+
CREATETABLEtest_macaddr8 (
4+
i macaddr8
5+
);
6+
7+
INSERT INTO test_macaddr8VALUES
8+
('22:00:5c:03:55:08:01:02' ),
9+
('22:00:5c:04:55:08:01:02' ),
10+
('22:00:5c:05:55:08:01:02' ),
11+
('22:00:5c:08:55:08:01:02' ),
12+
('22:00:5c:09:55:08:01:02' ),
13+
('22:00:5c:10:55:08:01:02' )
14+
;
15+
16+
CREATEINDEXidx_macaddr8ON test_macaddr8 USING gin (i);
17+
18+
SELECT*FROM test_macaddr8WHERE i<'22:00:5c:08:55:08:01:02'::macaddr8ORDER BY i;
19+
SELECT*FROM test_macaddr8WHERE i<='22:00:5c:08:55:08:01:02'::macaddr8ORDER BY i;
20+
SELECT*FROM test_macaddr8WHERE i='22:00:5c:08:55:08:01:02'::macaddr8ORDER BY i;
21+
SELECT*FROM test_macaddr8WHERE i>='22:00:5c:08:55:08:01:02'::macaddr8ORDER BY i;
22+
SELECT*FROM test_macaddr8WHERE i>'22:00:5c:08:55:08:01:02'::macaddr8ORDER BY i;

‎contrib/btree_gist/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ MODULE_big = btree_gist
55
OBJS = btree_gist.o btree_utils_num.o btree_utils_var.o btree_int2.o\
66
btree_int4.o btree_int8.o btree_float4.o btree_float8.o btree_cash.o\
77
btree_oid.o btree_ts.o btree_time.o btree_date.o btree_interval.o\
8-
btree_macaddr.obtree_inet.obtree_text.obtree_bytea.obtree_bit.o\
9-
btree_numeric.o btree_uuid.o$(WIN32RES)
8+
btree_macaddr.obtree_macaddr8.obtree_inet.obtree_text.obtree_bytea.o\
9+
btree_bit.obtree_numeric.o btree_uuid.o$(WIN32RES)
1010

1111
EXTENSION = btree_gist
1212
DATA = btree_gist--unpackaged--1.0.sql btree_gist--1.0--1.1.sql\
13-
btree_gist--1.1--1.2.sql btree_gist--1.2.sql btree_gist--1.2--1.3.sql
13+
btree_gist--1.1--1.2.sql btree_gist--1.2.sql btree_gist--1.2--1.3.sql\
14+
btree_gist--1.3--1.4.sql
1415
PGFILEDESC = "btree_gist - B-tree equivalent GiST operator classes"
1516

1617
REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz\
17-
time timetz date interval macaddr inet cidr text varchar char bytea\
18-
bit varbit numeric uuid not_equal
18+
time timetz date interval macaddrmacaddr8inet cidr text varchar char\
19+
byteabit varbit numeric uuid not_equal
1920

2021
SHLIB_LINK +=$(filter -lm,$(LIBS))
2122

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* contrib/btree_gist/btree_gist--1.3--1.4.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use"ALTER EXTENSION btree_gist UPDATE TO '1.4'" to load this file. \quit
5+
6+
-- Add support for indexing macaddr8 columns
7+
8+
-- define the GiST support methods
9+
CREATEFUNCTIONgbt_macad8_consistent(internal,macaddr8,int2,oid,internal)
10+
RETURNS bool
11+
AS'MODULE_PATHNAME'
12+
LANGUAGE C IMMUTABLE STRICT;
13+
14+
CREATEFUNCTIONgbt_macad8_compress(internal)
15+
RETURNS internal
16+
AS'MODULE_PATHNAME'
17+
LANGUAGE C IMMUTABLE STRICT;
18+
19+
CREATEFUNCTIONgbt_macad8_fetch(internal)
20+
RETURNS internal
21+
AS'MODULE_PATHNAME'
22+
LANGUAGE C IMMUTABLE STRICT;
23+
24+
CREATEFUNCTIONgbt_macad8_penalty(internal,internal,internal)
25+
RETURNS internal
26+
AS'MODULE_PATHNAME'
27+
LANGUAGE C IMMUTABLE STRICT;
28+
29+
CREATEFUNCTIONgbt_macad8_picksplit(internal, internal)
30+
RETURNS internal
31+
AS'MODULE_PATHNAME'
32+
LANGUAGE C IMMUTABLE STRICT;
33+
34+
CREATEFUNCTIONgbt_macad8_union(internal, internal)
35+
RETURNS gbtreekey16
36+
AS'MODULE_PATHNAME'
37+
LANGUAGE C IMMUTABLE STRICT;
38+
39+
CREATEFUNCTIONgbt_macad8_same(gbtreekey16, gbtreekey16, internal)
40+
RETURNS internal
41+
AS'MODULE_PATHNAME'
42+
LANGUAGE C IMMUTABLE STRICT;
43+
44+
-- Create the operator class
45+
CREATEOPERATOR CLASSgist_macaddr8_ops
46+
DEFAULT FOR TYPE macaddr8 USING gist
47+
AS
48+
OPERATOR1< ,
49+
OPERATOR2<= ,
50+
OPERATOR3= ,
51+
OPERATOR4>= ,
52+
OPERATOR5> ,
53+
FUNCTION1gbt_macad8_consistent (internal, macaddr8, int2,oid, internal),
54+
FUNCTION2gbt_macad8_union (internal, internal),
55+
FUNCTION3gbt_macad8_compress (internal),
56+
FUNCTION4gbt_decompress (internal),
57+
FUNCTION5gbt_macad8_penalty (internal, internal, internal),
58+
FUNCTION6gbt_macad8_picksplit (internal, internal),
59+
FUNCTION7gbt_macad8_same (gbtreekey16, gbtreekey16, internal),
60+
STORAGEgbtreekey16;
61+
62+
ALTEROPERATOR FAMILY gist_macaddr8_ops USING gist ADD
63+
OPERATOR6<> (macaddr8, macaddr8) ,
64+
FUNCTION9 (macaddr8, macaddr8) gbt_macad8_fetch (internal);

‎contrib/btree_gist/btree_gist.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# btree_gist extension
22
comment = 'support for indexing common datatypes in GiST'
3-
default_version = '1.3'
3+
default_version = '1.4'
44
module_pathname = '$libdir/btree_gist'
55
relocatable = true

‎contrib/btree_gist/btree_gist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum gbtree_type
2727
gbt_t_date,
2828
gbt_t_intv,
2929
gbt_t_macad,
30+
gbt_t_macad8,
3031
gbt_t_text,
3132
gbt_t_bpchar,
3233
gbt_t_bytea,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp