input formats.
-
+
Data Types
- The macaddr> type stores MAC addresses, i.e., Ethernet
- card hardware addresses (although MAC addresses are used for
- other purposes as well). Input is accepted in various customary
- formats, including
+ The macaddr> type stores MAC addresses, known for example
+ from Ethernet card hardware addresses (although MAC addresses are
+ used for other purposes as well). Input is accepted in the
+ following formats:
+ '08:00:2b:01:02:03'>
+ '08-00-2b-01-02-03'>
'08002b:010203'>
'08002b-010203'>
'0800.2b01.0203'>
- '08-00-2b-01-02-03'>
- '08:00:2b:01:02:03'>
+ '08002b010203'>
- which would all specify the same
- address. Upper and lower case is accepted for the digits
+ These examples would all specify the same address. Upper and
+ lower case is accepted for the digits
a> through f>. Output is always in the
- last of the forms shown.
+ first of the forms shown.
+
+
+ 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.
+
+
+ The remaining four input formats are not part of any standard.
--- /dev/null
+--
+-- 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;
# ----------
-# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.47 2008/04/10 22:25:26 tgl Exp $
+# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.48 2008/10/03 15:37:18 petere Exp $
#
# 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.
# ----------
# 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
-# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.44 2008/04/10 22:25:26 tgl Exp $
+# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.45 2008/10/03 15:37:18 petere Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
test: reltime
test: tinterval
test: inet
+test: macaddr
test: tstypes
test: comments
test: geometry
--- /dev/null
+--
+-- 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;