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
6761a030
Commit
6761a030
authored
Oct 03, 2008
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regression test for macaddr type. Enhance documentation about accepted
input formats.
parent
0e4896d5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
174 additions
and
13 deletions
+174
-13
doc/src/sgml/datatype.sgml
doc/src/sgml/datatype.sgml
+26
-10
src/test/regress/expected/macaddr.out
src/test/regress/expected/macaddr.out
+106
-0
src/test/regress/parallel_schedule
src/test/regress/parallel_schedule
+2
-2
src/test/regress/serial_schedule
src/test/regress/serial_schedule
+2
-1
src/test/regress/sql/macaddr.sql
src/test/regress/sql/macaddr.sql
+38
-0
No files found.
doc/src/sgml/datatype.sgml
View file @
6761a030
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.22
8 2008/09/11 15:27:30 tgl
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.22
9 2008/10/03 15:37:18 petere
Exp $ -->
<chapter id="datatype">
<chapter id="datatype">
<title id="datatype-title">Data Types</title>
<title id="datatype-title">Data Types</title>
...
@@ -3187,23 +3187,39 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
...
@@ -3187,23 +3187,39 @@ SELECT person.name, holidays.num_weeks FROM person, holidays
</indexterm>
</indexterm>
<para>
<para>
The <type>macaddr</> type stores MAC addresses,
i.e., Ethernet
The <type>macaddr</> type stores MAC addresses,
known for example
card hardware addresses (although MAC addresses are used for
from Ethernet card hardware addresses (although MAC addresses are
other purposes as well). Input is accepted in various customary
used for other purposes as well). Input is accepted in the
fo
rmats, including
fo
llowing formats:
<simplelist>
<simplelist>
<member><literal>'08:00:2b:01:02:03'</></member>
<member><literal>'08-00-2b-01-02-03'</></member>
<member><literal>'08002b:010203'</></member>
<member><literal>'08002b:010203'</></member>
<member><literal>'08002b-010203'</></member>
<member><literal>'08002b-010203'</></member>
<member><literal>'0800.2b01.0203'</></member>
<member><literal>'0800.2b01.0203'</></member>
<member><literal>'08-00-2b-01-02-03'</></member>
<member><literal>'08002b010203'</></member>
<member><literal>'08:00:2b:01:02:03'</></member>
</simplelist>
</simplelist>
which would all specify the same
These examples would all specify the same address. Upper and
address. Upper and
lower case is accepted for the digits
lower case is accepted for the digits
<literal>a</> through <literal>f</>. Output is always in the
<literal>a</> through <literal>f</>. Output is always in the
last of the forms shown.
first of the forms shown.
</para>
<para>
IEEE Std 802-2001 specifies the second shown form (with hyphens)
as the canonical form for MAC addresses, and specifies the first
form (with colons) as the bit-reversed notation, so that
08-00-2b-01-02-03 = 01:00:4D:08:04:0C. This convention is widely
ignored nowadays, and it is only relevant for obsolete network
protocols (such as Token Ring). PostgreSQL makes no provisions
for bit reversal, and all accepted formats use the canonical LSB
order.
</para>
<para>
The remaining four input formats are not part of any standard.
</para>
</para>
</sect2>
</sect2>
...
...
src/test/regress/expected/macaddr.out
0 → 100644
View file @
6761a030
--
-- macaddr
--
CREATE TABLE macaddr_data (a int, b macaddr);
INSERT INTO macaddr_data VALUES (1, '08:00:2b:01:02:03');
INSERT INTO macaddr_data VALUES (2, '08-00-2b-01-02-03');
INSERT INTO macaddr_data VALUES (3, '08002b:010203');
INSERT INTO macaddr_data VALUES (4, '08002b-010203');
INSERT INTO macaddr_data VALUES (5, '0800.2b01.0203');
INSERT INTO macaddr_data VALUES (6, '08002b010203');
INSERT INTO macaddr_data VALUES (7, '0800:2b01:0203'); -- invalid
ERROR: invalid input syntax for type macaddr: "0800:2b01:0203"
LINE 1: INSERT INTO macaddr_data VALUES (7, '0800:2b01:0203');
^
INSERT INTO macaddr_data VALUES (8, 'not even close'); -- invalid
ERROR: invalid input syntax for type macaddr: "not even close"
LINE 1: INSERT INTO macaddr_data VALUES (8, 'not even close');
^
INSERT INTO macaddr_data VALUES (10, '08:00:2b:01:02:04');
INSERT INTO macaddr_data VALUES (11, '08:00:2b:01:02:02');
INSERT INTO macaddr_data VALUES (12, '08:00:2a:01:02:03');
INSERT INTO macaddr_data VALUES (13, '08:00:2c:01:02:03');
INSERT INTO macaddr_data VALUES (14, '08:00:2a:01:02:04');
SELECT * FROM macaddr_data;
a | b
----+-------------------
1 | 08:00:2b:01:02:03
2 | 08:00:2b:01:02:03
3 | 08:00:2b:01:02:03
4 | 08:00:2b:01:02:03
5 | 08:00:2b:01:02:03
6 | 08:00:2b:01:02:03
10 | 08:00:2b:01:02:04
11 | 08:00:2b:01:02:02
12 | 08:00:2a:01:02:03
13 | 08:00:2c:01:02:03
14 | 08:00:2a:01:02:04
(11 rows)
CREATE INDEX macaddr_data_btree ON macaddr_data USING btree (b);
CREATE INDEX macaddr_data_hash ON macaddr_data USING hash (b);
SELECT a, b, trunc(b) FROM macaddr_data ORDER BY 2, 1;
a | b | trunc
----+-------------------+-------------------
12 | 08:00:2a:01:02:03 | 08:00:2a:00:00:00
14 | 08:00:2a:01:02:04 | 08:00:2a:00:00:00
11 | 08:00:2b:01:02:02 | 08:00:2b:00:00:00
1 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
2 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
3 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
4 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
5 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
6 | 08:00:2b:01:02:03 | 08:00:2b:00:00:00
10 | 08:00:2b:01:02:04 | 08:00:2b:00:00:00
13 | 08:00:2c:01:02:03 | 08:00:2c:00:00:00
(11 rows)
SELECT b < '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1; -- true
?column?
----------
t
(1 row)
SELECT b > '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1; -- false
?column?
----------
f
(1 row)
SELECT b > '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1; -- false
?column?
----------
f
(1 row)
SELECT b <= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1; -- true
?column?
----------
t
(1 row)
SELECT b >= '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1; -- false
?column?
----------
f
(1 row)
SELECT b = '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1; -- true
?column?
----------
t
(1 row)
SELECT b <> '08:00:2b:01:02:04' FROM macaddr_data WHERE a = 1; -- true
?column?
----------
t
(1 row)
SELECT b <> '08:00:2b:01:02:03' FROM macaddr_data WHERE a = 1; -- false
?column?
----------
f
(1 row)
DROP TABLE macaddr_data;
src/test/regress/parallel_schedule
View file @
6761a030
# ----------
# ----------
# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.4
7 2008/04/10 22:25:26 tgl
Exp $
# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.4
8 2008/10/03 15:37:18 petere
Exp $
#
#
# By convention, we put no more than twenty tests in any one parallel group;
# By convention, we put no more than twenty tests in any one parallel group;
# this limits the number of connections needed to run the tests.
# this limits the number of connections needed to run the tests.
...
@@ -18,7 +18,7 @@ test: numerology
...
@@ -18,7 +18,7 @@ test: numerology
# ----------
# ----------
# The second group of parallel tests
# The second group of parallel tests
# ----------
# ----------
test: point lseg box path polygon circle date time timetz timestamp timestamptz interval abstime reltime tinterval inet tstypes comments
test: point lseg box path polygon circle date time timetz timestamp timestamptz interval abstime reltime tinterval inet
macaddr
tstypes comments
# ----------
# ----------
# Another group of parallel tests
# Another group of parallel tests
...
...
src/test/regress/serial_schedule
View file @
6761a030
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.4
4 2008/04/10 22:25:26 tgl
Exp $
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.4
5 2008/10/03 15:37:18 petere
Exp $
# This should probably be in an order similar to parallel_schedule.
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: boolean
test: char
test: char
...
@@ -35,6 +35,7 @@ test: abstime
...
@@ -35,6 +35,7 @@ test: abstime
test: reltime
test: reltime
test: tinterval
test: tinterval
test: inet
test: inet
test: macaddr
test: tstypes
test: tstypes
test: comments
test: comments
test: geometry
test: geometry
...
...
src/test/regress/sql/macaddr.sql
0 → 100644
View file @
6761a030
--
-- macaddr
--
CREATE
TABLE
macaddr_data
(
a
int
,
b
macaddr
);
INSERT
INTO
macaddr_data
VALUES
(
1
,
'08:00:2b:01:02:03'
);
INSERT
INTO
macaddr_data
VALUES
(
2
,
'08-00-2b-01-02-03'
);
INSERT
INTO
macaddr_data
VALUES
(
3
,
'08002b:010203'
);
INSERT
INTO
macaddr_data
VALUES
(
4
,
'08002b-010203'
);
INSERT
INTO
macaddr_data
VALUES
(
5
,
'0800.2b01.0203'
);
INSERT
INTO
macaddr_data
VALUES
(
6
,
'08002b010203'
);
INSERT
INTO
macaddr_data
VALUES
(
7
,
'0800:2b01:0203'
);
-- invalid
INSERT
INTO
macaddr_data
VALUES
(
8
,
'not even close'
);
-- invalid
INSERT
INTO
macaddr_data
VALUES
(
10
,
'08:00:2b:01:02:04'
);
INSERT
INTO
macaddr_data
VALUES
(
11
,
'08:00:2b:01:02:02'
);
INSERT
INTO
macaddr_data
VALUES
(
12
,
'08:00:2a:01:02:03'
);
INSERT
INTO
macaddr_data
VALUES
(
13
,
'08:00:2c:01:02:03'
);
INSERT
INTO
macaddr_data
VALUES
(
14
,
'08:00:2a:01:02:04'
);
SELECT
*
FROM
macaddr_data
;
CREATE
INDEX
macaddr_data_btree
ON
macaddr_data
USING
btree
(
b
);
CREATE
INDEX
macaddr_data_hash
ON
macaddr_data
USING
hash
(
b
);
SELECT
a
,
b
,
trunc
(
b
)
FROM
macaddr_data
ORDER
BY
2
,
1
;
SELECT
b
<
'08:00:2b:01:02:04'
FROM
macaddr_data
WHERE
a
=
1
;
-- true
SELECT
b
>
'08:00:2b:01:02:04'
FROM
macaddr_data
WHERE
a
=
1
;
-- false
SELECT
b
>
'08:00:2b:01:02:03'
FROM
macaddr_data
WHERE
a
=
1
;
-- false
SELECT
b
<=
'08:00:2b:01:02:04'
FROM
macaddr_data
WHERE
a
=
1
;
-- true
SELECT
b
>=
'08:00:2b:01:02:04'
FROM
macaddr_data
WHERE
a
=
1
;
-- false
SELECT
b
=
'08:00:2b:01:02:03'
FROM
macaddr_data
WHERE
a
=
1
;
-- true
SELECT
b
<>
'08:00:2b:01:02:04'
FROM
macaddr_data
WHERE
a
=
1
;
-- true
SELECT
b
<>
'08:00:2b:01:02:03'
FROM
macaddr_data
WHERE
a
=
1
;
-- false
DROP
TABLE
macaddr_data
;
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