Content-Length: 824185 | pFad | http://github.com/tonybelloni/postgres/commit/b8cc8f94730610c0189aa82dfec4ae6ce9b13e34

5B Support BSD and e2fsprogs UUID libraries alongside OSSP UUID library. · tonybelloni/postgres@b8cc8f9 · GitHub
Skip to content

Commit b8cc8f9

Browse files
committed
Support BSD and e2fsprogs UUID libraries alongside OSSP UUID library.
Allow the contrib/uuid-ossp extension to be built atop any one of these three popular UUID libraries. (The extension's name is now arguably a misnomer, but we'll keep it the same so as not to cause unnecessary compatibility issues for users.) We would not normally consider a change like this post-beta1, but the issue has been forced by our upgrade to autoconf 2.69, whose more rigorous header checks are causing OSSP's header files to be rejected on some platforms. It's been foreseen for some time that we'd have to move away from depending on OSSP UUID due to lack of upstream maintenance, so this is a down payment on that problem. While at it, add some simple regression tests, in hopes of catching any major incompatibilities between the three implementations. Matteo Beccati, with some further hacking by me
1 parent 616afee commit b8cc8f9

12 files changed

+923
-177
lines changed

configure

+296-78
Large diffs are not rendered by default.

configure.in

+69-12
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,38 @@ PGAC_ARG_BOOL(with, libedit-preferred, no,
694694

695695

696696
#
697-
# OSSP UUID library
697+
# UUID library
698698
#
699-
PGAC_ARG_BOOL(with, ossp-uuid, no, [build contrib/uuid-ossp, requires OSSP UUID library])
700-
AC_SUBST(with_ossp_uuid)
699+
# There are at least three UUID libraries in common use: the FreeBSD/NetBSD
700+
# library, the e2fsprogs libuuid (now part of util-linux-ng), and the OSSP
701+
# UUID library. More than one of these might be present on a given platform,
702+
# so we make the user say which one she wants.
703+
#
704+
PGAC_ARG_REQ(with, uuid, [LIB], [build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)])
705+
if test x"$with_uuid" = x"" ; then
706+
with_uuid=no
707+
fi
708+
PGAC_ARG_BOOL(with, ossp-uuid, no, [obsolete spelling of --with-uuid=ossp])
709+
if test "$with_ossp_uuid" = yes ; then
710+
with_uuid=ossp
711+
fi
712+
713+
if test "$with_uuid" = bsd ; then
714+
AC_DEFINE([HAVE_UUID_BSD], 1, [Define to 1 if you have BSD UUID support.])
715+
UUID_EXTRA_OBJS="md5.o sha1.o"
716+
elif test "$with_uuid" = e2fs ; then
717+
AC_DEFINE([HAVE_UUID_E2FS], 1, [Define to 1 if you have E2FS UUID support.])
718+
UUID_EXTRA_OBJS="md5.o sha1.o"
719+
elif test "$with_uuid" = ossp ; then
720+
AC_DEFINE([HAVE_UUID_OSSP], 1, [Define to 1 if you have OSSP UUID support.])
721+
UUID_EXTRA_OBJS=""
722+
elif test "$with_uuid" = no ; then
723+
UUID_EXTRA_OBJS=""
724+
else
725+
AC_MSG_ERROR([--with-uuid must specify one of bsd, e2fs, or ossp])
726+
fi
727+
AC_SUBST(with_uuid)
728+
AC_SUBST(UUID_EXTRA_OBJS)
701729

702730

703731
#
@@ -948,14 +976,26 @@ if test "$with_selinux" = yes; then
948976
fi
949977

950978
# for contrib/uuid-ossp
951-
if test "$with_ossp_uuid" = yes ; then
979+
if test "$with_uuid" = bsd ; then
980+
# On BSD, the UUID functions are in libc
981+
AC_CHECK_FUNC(uuid_to_string,
982+
[UUID_LIBS=""],
983+
[AC_MSG_ERROR([BSD UUID functions are not present])])
984+
elif test "$with_uuid" = e2fs ; then
985+
# On OS X, the UUID functions are in libc
986+
AC_CHECK_FUNC(uuid_generate,
987+
[UUID_LIBS=""],
988+
[AC_CHECK_LIB(uuid, uuid_generate,
989+
[UUID_LIBS="-luuid"],
990+
[AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])])
991+
elif test "$with_uuid" = ossp ; then
952992
AC_CHECK_LIB(ossp-uuid, uuid_export,
953-
[OSSP_UUID_LIBS="-lossp-uuid"],
993+
[UUID_LIBS="-lossp-uuid"],
954994
[AC_CHECK_LIB(uuid, uuid_export,
955-
[OSSP_UUID_LIBS="-luuid"],
956-
[AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP-UUID])])])
995+
[UUID_LIBS="-luuid"],
996+
[AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP UUID])])])
957997
fi
958-
AC_SUBST(OSSP_UUID_LIBS)
998+
AC_SUBST(UUID_LIBS)
959999

9601000

9611001
##
@@ -1075,10 +1115,27 @@ if test "$with_bonjour" = yes ; then
10751115
fi
10761116

10771117
# for contrib/uuid-ossp
1078-
if test "$with_ossp_uuid" = yes ; then
1079-
AC_CHECK_HEADERS(ossp/uuid.h, [], [
1080-
AC_CHECK_HEADERS(uuid.h, [],
1081-
[AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP-UUID])])])
1118+
if test "$with_uuid" = bsd ; then
1119+
AC_CHECK_HEADERS(uuid.h,
1120+
[AC_EGREP_HEADER([uuid_to_string], uuid.h, [],
1121+
[AC_MSG_ERROR([header file <uuid.h> does not match BSD UUID library])])],
1122+
[AC_MSG_ERROR([header file <uuid.h> is required for BSD UUID])])
1123+
elif test "$with_uuid" = e2fs ; then
1124+
AC_CHECK_HEADERS(uuid/uuid.h,
1125+
[AC_EGREP_HEADER([uuid_generate], uuid/uuid.h, [],
1126+
[AC_MSG_ERROR([header file <uuid/uuid.h> does not match E2FS UUID library])])],
1127+
[AC_CHECK_HEADERS(uuid.h,
1128+
[AC_EGREP_HEADER([uuid_generate], uuid.h, [],
1129+
[AC_MSG_ERROR([header file <uuid.h> does not match E2FS UUID library])])],
1130+
[AC_MSG_ERROR([header file <uuid/uuid.h> or <uuid.h> is required for E2FS UUID])])])
1131+
elif test "$with_uuid" = ossp ; then
1132+
AC_CHECK_HEADERS(ossp/uuid.h,
1133+
[AC_EGREP_HEADER([uuid_export], ossp/uuid.h, [],
1134+
[AC_MSG_ERROR([header file <ossp/uuid.h> does not match OSSP UUID library])])],
1135+
[AC_CHECK_HEADERS(uuid.h,
1136+
[AC_EGREP_HEADER([uuid_export], uuid.h, [],
1137+
[AC_MSG_ERROR([header file <uuid.h> does not match OSSP UUID library])])],
1138+
[AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP UUID])])])
10821139
fi
10831140

10841141
if test "$PORTNAME" = "win32" ; then

contrib/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ else
6464
ALWAYS_SUBDIRS += sslinfo
6565
endif
6666

67-
ifeq ($(with_ossp_uuid),yes)
67+
ifneq ($(with_uuid),no)
6868
SUBDIRS += uuid-ossp
6969
else
7070
ALWAYS_SUBDIRS += uuid-ossp

contrib/uuid-ossp/.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/md5.c
2+
/sha1.c
3+
# Generated subdirectories
4+
/log/
5+
/results/
6+
/tmp_check/

contrib/uuid-ossp/Makefile

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# contrib/uuid-ossp/Makefile
22

33
MODULE_big = uuid-ossp
4-
OBJS = uuid-ossp.o
4+
OBJS = uuid-ossp.o $(UUID_EXTRA_OBJS)
55

66
EXTENSION = uuid-ossp
77
DATA = uuid-ossp--1.0.sql uuid-ossp--unpackaged--1.0.sql
88

9-
SHLIB_LINK += $(OSSP_UUID_LIBS)
9+
REGRESS = uuid_ossp
10+
11+
SHLIB_LINK += $(UUID_LIBS)
12+
13+
# We copy some needed files verbatim from pgcrypto
14+
pgcrypto_src = $(top_srcdir)/contrib/pgcrypto
15+
16+
PG_CPPFLAGS = -I$(pgcrypto_src)
17+
18+
EXTRA_CLEAN = md5.c sha1.c
1019

1120
ifdef USE_PGXS
1221
PG_CONFIG = pg_config
@@ -18,3 +27,6 @@ top_builddir = ../..
1827
include $(top_builddir)/src/Makefile.global
1928
include $(top_srcdir)/contrib/contrib-global.mk
2029
endif
30+
31+
md5.c sha1.c: % : $(pgcrypto_src)/%
32+
rm -f $@ && $(LN_S) $< .
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
CREATE EXTENSION "uuid-ossp";
2+
SELECT uuid_nil();
3+
uuid_nil
4+
--------------------------------------
5+
00000000-0000-0000-0000-000000000000
6+
(1 row)
7+
8+
SELECT uuid_ns_dns();
9+
uuid_ns_dns
10+
--------------------------------------
11+
6ba7b810-9dad-11d1-80b4-00c04fd430c8
12+
(1 row)
13+
14+
SELECT uuid_ns_url();
15+
uuid_ns_url
16+
--------------------------------------
17+
6ba7b811-9dad-11d1-80b4-00c04fd430c8
18+
(1 row)
19+
20+
SELECT uuid_ns_oid();
21+
uuid_ns_oid
22+
--------------------------------------
23+
6ba7b812-9dad-11d1-80b4-00c04fd430c8
24+
(1 row)
25+
26+
SELECT uuid_ns_x500();
27+
uuid_ns_x500
28+
--------------------------------------
29+
6ba7b814-9dad-11d1-80b4-00c04fd430c8
30+
(1 row)
31+
32+
SELECT uuid_generate_v1() < uuid_generate_v1();
33+
?column?
34+
----------
35+
t
36+
(1 row)
37+
38+
SELECT uuid_generate_v1() < uuid_generate_v1mc();
39+
?column?
40+
----------
41+
t
42+
(1 row)
43+
44+
SELECT substr(uuid_generate_v1()::text, 25) = substr(uuid_generate_v1()::text, 25);
45+
?column?
46+
----------
47+
t
48+
(1 row)
49+
50+
SELECT substr(uuid_generate_v1()::text, 25) <> substr(uuid_generate_v1mc()::text, 25);
51+
?column?
52+
----------
53+
t
54+
(1 row)
55+
56+
SELECT substr(uuid_generate_v1mc()::text, 25) <> substr(uuid_generate_v1mc()::text, 25);
57+
?column?
58+
----------
59+
t
60+
(1 row)
61+
62+
SELECT ('x' || substr(uuid_generate_v1mc()::text, 25, 2))::bit(8) & '00000011';
63+
?column?
64+
----------
65+
00000011
66+
(1 row)
67+
68+
SELECT uuid_generate_v3(uuid_ns_dns(), 'www.widgets.com');
69+
uuid_generate_v3
70+
--------------------------------------
71+
3d813cbb-47fb-32ba-91df-831e1593ac29
72+
(1 row)
73+
74+
SELECT uuid_generate_v5(uuid_ns_dns(), 'www.widgets.com');
75+
uuid_generate_v5
76+
--------------------------------------
77+
21f7f8de-8051-5b89-8680-0195ef798b6a
78+
(1 row)
79+
80+
SELECT uuid_generate_v4()::text ~ '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$';
81+
?column?
82+
----------
83+
t
84+
(1 row)
85+
86+
SELECT uuid_generate_v4() <> uuid_generate_v4();
87+
?column?
88+
----------
89+
t
90+
(1 row)
91+

contrib/uuid-ossp/sql/uuid_ossp.sql

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CREATE EXTENSION "uuid-ossp";
2+
3+
SELECT uuid_nil();
4+
SELECT uuid_ns_dns();
5+
SELECT uuid_ns_url();
6+
SELECT uuid_ns_oid();
7+
SELECT uuid_ns_x500();
8+
9+
SELECT uuid_generate_v1() < uuid_generate_v1();
10+
SELECT uuid_generate_v1() < uuid_generate_v1mc();
11+
12+
SELECT substr(uuid_generate_v1()::text, 25) = substr(uuid_generate_v1()::text, 25);
13+
SELECT substr(uuid_generate_v1()::text, 25) <> substr(uuid_generate_v1mc()::text, 25);
14+
SELECT substr(uuid_generate_v1mc()::text, 25) <> substr(uuid_generate_v1mc()::text, 25);
15+
16+
SELECT ('x' || substr(uuid_generate_v1mc()::text, 25, 2))::bit(8) & '00000011';
17+
18+
SELECT uuid_generate_v3(uuid_ns_dns(), 'www.widgets.com');
19+
SELECT uuid_generate_v5(uuid_ns_dns(), 'www.widgets.com');
20+
21+
SELECT uuid_generate_v4()::text ~ '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$';
22+
SELECT uuid_generate_v4() <> uuid_generate_v4();

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tonybelloni/postgres/commit/b8cc8f94730610c0189aa82dfec4ae6ce9b13e34

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy