Compare commits

..

No commits in common. "ecc78c959020ae078d1c228073108a401b25f5e4" and "ab90f301b5051227d1a582c5f39d1a4aee6a754f" have entirely different histories.

13 changed files with 56 additions and 374 deletions

View File

@ -1,35 +0,0 @@
env:
DEBIAN_FRONTEND: noninteractive
LANG: C
task:
name: Linux (Debian/Ubuntu)
matrix:
- container:
image: ubuntu:20.04
env:
matrix:
- PGVERSION: 14
- PGVERSION: 13
- PGVERSION: 12
- PGVERSION: 11
- PGVERSION: 10
- PGVERSION: 9.6
- PGVERSION: 9.5
- PGVERSION: 9.4
- PGVERSION: 9.3
setup_script:
- apt-get update
- apt-get -y install curl gnupg lsb-release
- curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
- echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
- apt-get update
- apt-get -y install gcc liburiparser-dev make pkg-config postgresql-$PGVERSION postgresql-server-dev-$PGVERSION
- pg_createcluster --start $PGVERSION test -p 55435 -- -A trust
build_script:
- PATH=/usr/lib/postgresql/$PGVERSION/bin:$PATH
- make all
- make install
test_script:
- PATH=/usr/lib/postgresql/$PGVERSION/bin:$PATH
- PGPORT=55435 make installcheck PGUSER=postgres

14
.travis.yml Normal file
View File

@ -0,0 +1,14 @@
language: c
before_install:
- wget https://gist.github.com/petere/5893799/raw/apt.postgresql.org.sh
- wget https://gist.github.com/petere/6023944/raw/pg-travis-test.sh
- sudo sh ./apt.postgresql.org.sh
install:
- sudo apt-get install -qq liburiparser-dev
env:
- PGVERSION=9.1
- PGVERSION=9.2
- PGVERSION=9.3
- PGVERSION=9.4
script:
- bash ./pg-travis-test.sh

View File

@ -1,19 +0,0 @@
© 2015 Peter Eisentraut <peter@eisentraut.org>
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written
agreement is hereby granted, provided that the above copyright notice
and this paragraph and the following two paragraphs appear in all
copies.
IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
IS" BASIS, AND THE AUTHORS HAVE NO OBLIGATIONS TO PROVIDE MAINTENANCE,
SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

5
debian/changelog vendored
View File

@ -1,5 +0,0 @@
pguri (1.20151224-1) bullseye; urgency=medium
* Add Debian packaging
-- jordi fita mas <jordi@tandem.blog> Tue, 24 Jan 2023 13:07:39 +0000

34
debian/control vendored
View File

@ -1,34 +0,0 @@
Source: pguri
Section: database
Priority: optional
Maintainer: jordi fita mas <jordi@tandem.blog>
Build-Depends:
debhelper-compat (= 13),
postgresql-all (>= 217~),
liburiparser-dev
Standards-Version: 4.6.0
Vcs-Browser: https://github.com/petere/pguri
Vcs-Git: https://github.com/petere/pguri.git
Homepage: https://github.com/petere/pguri
Rules-Requires-Root: no
Package: postgresql-13-pguri
Architecture: all
Depends:
${shlibs:Depends},
${misc:Depends},
postgresql-13
description: uri type for PostgreSQL
This is an extension for PostgreSQL that provides a uri data type. Advantages
over using plain text for storing URIs include:
.
* URI syntax checking,
* functions for extracting URI components, and
* human-friendly sorting.
.
The actual URI parsing is provided by the uriparser library, which supports
URI syntax as per RFC 3986.
.
Note that this might not be the right data type to use if you want to store
user-provided URI data, such as HTTP referrers, since they might contain
arbitrary junk.

34
debian/control.in vendored
View File

@ -1,34 +0,0 @@
Source: pguri
Section: database
Priority: optional
Maintainer: jordi fita mas <jordi@tandem.blog>
Build-Depends:
debhelper-compat (= 13),
postgresql-all (>= 217~),
liburiparser-dev
Standards-Version: 4.6.0
Vcs-Browser: https://github.com/petere/pguri
Vcs-Git: https://github.com/petere/pguri.git
Homepage: https://github.com/petere/pguri
Rules-Requires-Root: no
Package: postgresql-PGVERSION-pguri
Architecture: all
Depends:
${shlibs:Depends},
${misc:Depends},
postgresql-PGVERSION
description: uri type for PostgreSQL
This is an extension for PostgreSQL that provides a uri data type. Advantages
over using plain text for storing URIs include:
.
* URI syntax checking,
* functions for extracting URI components, and
* human-friendly sorting.
.
The actual URI parsing is provided by the uriparser library, which supports
URI syntax as per RFC 3986.
.
Note that this might not be the right data type to use if you want to store
user-provided URI data, such as HTTP referrers, since they might contain
arbitrary junk.

29
debian/copyright vendored
View File

@ -1,29 +0,0 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/petere/pguri
Upstream-Name: pguri
Upstream-Contact: peter@eisentraut.org
Files: *
Copyright: 2015 Peter Eisentraut
License:
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement is
hereby granted, provided that the above copyright notice and this paragraph and
the following two paragraphs appear in all copies.
.
IN NO EVENT SHALL THE AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS HAVE
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.
THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE
AUTHORS HAVE NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
ENHANCEMENTS, OR MODIFICATIONS.
Files: debian/*
Copyright: 2023 jordi fita mas
License:
This debian package is distributed under the same license as the source
package.

1
debian/pgversions vendored
View File

@ -1 +0,0 @@
13+

6
debian/rules vendored
View File

@ -1,6 +0,0 @@
#!/usr/bin/make -f
include /usr/share/postgresql-common/pgxs_debian_control.mk
%:
dh $@ --with pgxs_loop

View File

@ -1 +0,0 @@
3.0 (quilt)

View File

@ -4,14 +4,10 @@ CREATE TABLE test (a serial, b uri);
INSERT INTO test (b)
VALUES ('http://www.postgresql.org/'),
('http://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS'),
('http://www.postgresql.org:591/'),
('http://www.postgresql.org:80/'),
('https://duckduckgo.com/?q=postgresql&ia=about'),
('ftp://ftp.gnu.org/gnu/bison'),
('mailto:foo@example.com'),
('ssh://username@review.openstack.org:29418/openstack/nova.git'),
('ssh://foobar@review.openstack.org:29418/openstack/nova.git'),
('ssh://review.openstack.org:29418/openstack/nova.git'),
('http://admin:password@192.168.0.1'),
('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'),
('http://[1080::8:800:200C:417A]/foo'),
@ -30,26 +26,22 @@ SELECT * FROM test;
----+-----------------------------------------------------------------------------------------
1 | http://www.postgresql.org/
2 | http://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
3 | http://www.postgresql.org:591/
4 | http://www.postgresql.org:80/
5 | https://duckduckgo.com/?q=postgresql&ia=about
6 | ftp://ftp.gnu.org/gnu/bison
7 | mailto:foo@example.com
8 | ssh://username@review.openstack.org:29418/openstack/nova.git
9 | ssh://foobar@review.openstack.org:29418/openstack/nova.git
10 | ssh://review.openstack.org:29418/openstack/nova.git
11 | http://admin:password@192.168.0.1
12 | http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
13 | http://[1080::8:800:200C:417A]/foo
14 | http://host:
15 |
16 | /
17 | foobar
18 | /foobar
19 | HTTP://www.EXAMPLE.com/
20 | http://www.ex%41mple.com/
21 | eXAMPLE://a/./b/../b/%63/%7bfoo%7d
(21 rows)
3 | https://duckduckgo.com/?q=postgresql&ia=about
4 | ftp://ftp.gnu.org/gnu/bison
5 | mailto:foo@example.com
6 | ssh://username@review.openstack.org:29418/openstack/nova.git
7 | http://admin:password@192.168.0.1
8 | http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
9 | http://[1080::8:800:200C:417A]/foo
10 | http://host:
11 |
12 | /
13 | foobar
14 | /foobar
15 | HTTP://www.EXAMPLE.com/
16 | http://www.ex%41mple.com/
17 | eXAMPLE://a/./b/../b/%63/%7bfoo%7d
(17 rows)
-- error cases
SELECT uri 'http://host:port/';
@ -94,30 +86,6 @@ uri_path_array | {docs,devel,static,xfunc-sql.html}
uri_query | _null_
uri_fragment | XFUNC-SQL-FUNCTION-ARGUMENTS
-[ RECORD 3 ]--+----------------------------------------------------------------------------------------
uri | http://www.postgresql.org:591/
uri_normalize | http://www.postgresql.org:591/
uri_scheme | http
uri_userinfo | _null_
uri_host | www.postgresql.org
uri_host_inet | _null_
uri_port | 591
uri_path | /
uri_path_array | {""}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 4 ]--+----------------------------------------------------------------------------------------
uri | http://www.postgresql.org:80/
uri_normalize | http://www.postgresql.org:80/
uri_scheme | http
uri_userinfo | _null_
uri_host | www.postgresql.org
uri_host_inet | _null_
uri_port | 80
uri_path | /
uri_path_array | {""}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 5 ]--+----------------------------------------------------------------------------------------
uri | https://duckduckgo.com/?q=postgresql&ia=about
uri_normalize | https://duckduckgo.com/?q=postgresql&ia=about
uri_scheme | https
@ -129,7 +97,7 @@ uri_path | /
uri_path_array | {""}
uri_query | q=postgresql&ia=about
uri_fragment | _null_
-[ RECORD 6 ]--+----------------------------------------------------------------------------------------
-[ RECORD 4 ]--+----------------------------------------------------------------------------------------
uri | ftp://ftp.gnu.org/gnu/bison
uri_normalize | ftp://ftp.gnu.org/gnu/bison
uri_scheme | ftp
@ -141,7 +109,7 @@ uri_path | /gnu/bison
uri_path_array | {gnu,bison}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 7 ]--+----------------------------------------------------------------------------------------
-[ RECORD 5 ]--+----------------------------------------------------------------------------------------
uri | mailto:foo@example.com
uri_normalize | mailto:foo@example.com
uri_scheme | mailto
@ -153,7 +121,7 @@ uri_path | foo@example.com
uri_path_array | {foo@example.com}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 8 ]--+----------------------------------------------------------------------------------------
-[ RECORD 6 ]--+----------------------------------------------------------------------------------------
uri | ssh://username@review.openstack.org:29418/openstack/nova.git
uri_normalize | ssh://username@review.openstack.org:29418/openstack/nova.git
uri_scheme | ssh
@ -165,31 +133,7 @@ uri_path | /openstack/nova.git
uri_path_array | {openstack,nova.git}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 9 ]--+----------------------------------------------------------------------------------------
uri | ssh://foobar@review.openstack.org:29418/openstack/nova.git
uri_normalize | ssh://foobar@review.openstack.org:29418/openstack/nova.git
uri_scheme | ssh
uri_userinfo | foobar
uri_host | review.openstack.org
uri_host_inet | _null_
uri_port | 29418
uri_path | /openstack/nova.git
uri_path_array | {openstack,nova.git}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 10 ]-+----------------------------------------------------------------------------------------
uri | ssh://review.openstack.org:29418/openstack/nova.git
uri_normalize | ssh://review.openstack.org:29418/openstack/nova.git
uri_scheme | ssh
uri_userinfo | _null_
uri_host | review.openstack.org
uri_host_inet | _null_
uri_port | 29418
uri_path | /openstack/nova.git
uri_path_array | {openstack,nova.git}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 11 ]-+----------------------------------------------------------------------------------------
-[ RECORD 7 ]--+----------------------------------------------------------------------------------------
uri | http://admin:password@192.168.0.1
uri_normalize | http://admin:password@192.168.0.1
uri_scheme | http
@ -201,7 +145,7 @@ uri_path |
uri_path_array | {}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 12 ]-+----------------------------------------------------------------------------------------
-[ RECORD 8 ]--+----------------------------------------------------------------------------------------
uri | http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
uri_normalize | http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:80/index.html
uri_scheme | http
@ -213,7 +157,7 @@ uri_path | /index.html
uri_path_array | {index.html}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 13 ]-+----------------------------------------------------------------------------------------
-[ RECORD 9 ]--+----------------------------------------------------------------------------------------
uri | http://[1080::8:800:200C:417A]/foo
uri_normalize | http://[1080:0000:0000:0000:0008:0800:200c:417a]/foo
uri_scheme | http
@ -225,7 +169,7 @@ uri_path | /foo
uri_path_array | {foo}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 14 ]-+----------------------------------------------------------------------------------------
-[ RECORD 10 ]-+----------------------------------------------------------------------------------------
uri | http://host:
uri_normalize | http://host:
uri_scheme | http
@ -237,7 +181,7 @@ uri_path |
uri_path_array | {}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 15 ]-+----------------------------------------------------------------------------------------
-[ RECORD 11 ]-+----------------------------------------------------------------------------------------
uri |
uri_normalize |
uri_scheme | _null_
@ -249,7 +193,7 @@ uri_path |
uri_path_array | {}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 16 ]-+----------------------------------------------------------------------------------------
-[ RECORD 12 ]-+----------------------------------------------------------------------------------------
uri | /
uri_normalize | /
uri_scheme | _null_
@ -261,7 +205,7 @@ uri_path | /
uri_path_array | {}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 17 ]-+----------------------------------------------------------------------------------------
-[ RECORD 13 ]-+----------------------------------------------------------------------------------------
uri | foobar
uri_normalize | foobar
uri_scheme | _null_
@ -273,7 +217,7 @@ uri_path | foobar
uri_path_array | {foobar}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 18 ]-+----------------------------------------------------------------------------------------
-[ RECORD 14 ]-+----------------------------------------------------------------------------------------
uri | /foobar
uri_normalize | /foobar
uri_scheme | _null_
@ -285,7 +229,7 @@ uri_path | /foobar
uri_path_array | {foobar}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 19 ]-+----------------------------------------------------------------------------------------
-[ RECORD 15 ]-+----------------------------------------------------------------------------------------
uri | HTTP://www.EXAMPLE.com/
uri_normalize | http://www.example.com/
uri_scheme | HTTP
@ -297,7 +241,7 @@ uri_path | /
uri_path_array | {""}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 20 ]-+----------------------------------------------------------------------------------------
-[ RECORD 16 ]-+----------------------------------------------------------------------------------------
uri | http://www.ex%41mple.com/
uri_normalize | http://www.example.com/
uri_scheme | http
@ -309,7 +253,7 @@ uri_path | /
uri_path_array | {""}
uri_query | _null_
uri_fragment | _null_
-[ RECORD 21 ]-+----------------------------------------------------------------------------------------
-[ RECORD 17 ]-+----------------------------------------------------------------------------------------
uri | eXAMPLE://a/./b/../b/%63/%7bfoo%7d
uri_normalize | example://a/b/c/%7Bfoo%7D
uri_scheme | eXAMPLE
@ -330,24 +274,20 @@ SELECT DISTINCT b FROM test ORDER BY b;
/
/foobar
foobar
HTTP://www.EXAMPLE.com/
eXAMPLE://a/./b/../b/%63/%7bfoo%7d
ftp://ftp.gnu.org/gnu/bison
http://admin:password@192.168.0.1
http://[1080::8:800:200C:417A]/foo
http://admin:password@192.168.0.1
http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
http://host:
http://www.ex%41mple.com/
HTTP://www.EXAMPLE.com/
http://www.postgresql.org/
http://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS
http://www.postgresql.org:80/
http://www.postgresql.org:591/
https://duckduckgo.com/?q=postgresql&ia=about
mailto:foo@example.com
ssh://review.openstack.org:29418/openstack/nova.git
ssh://foobar@review.openstack.org:29418/openstack/nova.git
ssh://username@review.openstack.org:29418/openstack/nova.git
(21 rows)
(17 rows)
CREATE TABLE test2 (x text, y uri);
INSERT INTO test2 VALUES ('foo', 'http://www.postgresql.org/');

View File

@ -7,14 +7,10 @@ CREATE TABLE test (a serial, b uri);
INSERT INTO test (b)
VALUES ('http://www.postgresql.org/'),
('http://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS'),
('http://www.postgresql.org:591/'),
('http://www.postgresql.org:80/'),
('https://duckduckgo.com/?q=postgresql&ia=about'),
('ftp://ftp.gnu.org/gnu/bison'),
('mailto:foo@example.com'),
('ssh://username@review.openstack.org:29418/openstack/nova.git'),
('ssh://foobar@review.openstack.org:29418/openstack/nova.git'),
('ssh://review.openstack.org:29418/openstack/nova.git'),
('http://admin:password@192.168.0.1'),
('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'),
('http://[1080::8:800:200C:417A]/foo'),

120
uri.c
View File

@ -42,7 +42,6 @@ parse_uri(const char *s, UriUriA *urip)
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for type uri at or near \"%s\"",
state.errorPos)));
break;
default:
elog(ERROR, "liburiparser error code %d", state.errorCode);
}
@ -171,16 +170,6 @@ uri_host_inet(PG_FUNCTION_ARGS)
}
}
static int
_uri_port_num(UriUriA *urip)
{
if (!urip->portText.first || !urip->portText.afterLast
|| urip->portText.afterLast == urip->portText.first)
return -1;
return strtol(pnstrdup(urip->portText.first, urip->portText.afterLast - urip->portText.first),
NULL, 10);
}
PG_FUNCTION_INFO_V1(uri_port);
Datum
uri_port(PG_FUNCTION_ARGS)
@ -188,14 +177,15 @@ uri_port(PG_FUNCTION_ARGS)
Datum arg = PG_GETARG_DATUM(0);
char *s = TextDatumGetCString(arg);
UriUriA uri;
int num;
const char *p;
parse_uri(s, &uri);
num = _uri_port_num(&uri);
uriFreeUriMembersA(&uri);
if (num < 0)
if (!uri.portText.first || !uri.portText.afterLast
|| uri.portText.afterLast == uri.portText.first)
PG_RETURN_NULL();
PG_RETURN_INT32(num);
p = pnstrdup(uri.portText.first, uri.portText.afterLast - uri.portText.first);
uriFreeUriMembersA(&uri);
PG_RETURN_INT32(strtol(p, NULL, 10));
}
PG_FUNCTION_INFO_V1(uri_query);
@ -334,56 +324,6 @@ uri_normalize(PG_FUNCTION_ARGS)
PG_RETURN_URI_P((uritype *) cstring_to_text(ret));
}
static int
strcasecmp_ascii(const char *s1, const char *s2)
{
for (;;)
{
unsigned char ch1 = (unsigned char) *s1++;
unsigned char ch2 = (unsigned char) *s2++;
if (ch1 != ch2)
{
if (ch1 >= 'A' && ch1 <= 'Z')
ch1 += 'a' - 'A';
if (ch2 >= 'A' && ch2 <= 'Z')
ch2 += 'a' - 'A';
if (ch1 != ch2)
return (int) ch1 - (int) ch2;
}
if (ch1 == 0)
break;
}
return 0;
}
static int
strncasecmp_ascii(const char *s1, const char *s2, size_t n)
{
while (n-- > 0)
{
unsigned char ch1 = (unsigned char) *s1++;
unsigned char ch2 = (unsigned char) *s2++;
if (ch1 != ch2)
{
if (ch1 >= 'A' && ch1 <= 'Z')
ch1 += 'a' - 'A';
if (ch2 >= 'A' && ch2 <= 'Z')
ch2 += 'a' - 'A';
if (ch1 != ch2)
return (int) ch1 - (int) ch2;
}
if (ch1 == 0)
break;
}
return 0;
}
static int
cmp_text_range(UriTextRangeA a, UriTextRangeA b)
{
@ -398,7 +338,7 @@ cmp_text_range(UriTextRangeA a, UriTextRangeA b)
return 1;
else
{
int x = strncasecmp_ascii(a.first, b.first,
int x = strncmp(a.first, b.first,
Min(a.afterLast - a.first, b.afterLast - b.first));
if (x == 0)
return (a.afterLast - a.first) - (b.afterLast - b.first);
@ -406,44 +346,6 @@ cmp_text_range(UriTextRangeA a, UriTextRangeA b)
}
}
static int
cmp_hosts(UriUriA *uap, UriUriA *ubp)
{
if (!uap->hostText.first)
{
if (!ubp->hostText.first)
return 0;
else
return -1;
}
else if (uap->hostData.ip4)
{
if (!ubp->hostText.first)
return 1;
else if (ubp->hostData.ip4)
return memcmp(uap->hostData.ip4->data,
ubp->hostData.ip4->data,
sizeof(uap->hostData.ip4->data));
else
return -1;
}
else if (uap->hostData.ip6)
{
if (!ubp->hostText.first)
return 1;
else if (ubp->hostData.ip4)
return 1;
else if (ubp->hostData.ip6)
return memcmp(uap->hostData.ip6->data,
ubp->hostData.ip6->data,
sizeof(uap->hostData.ip6->data));
else
return -1;
}
else
return cmp_text_range(uap->hostText, ubp->hostText);
}
static int
_uri_cmp(Datum a, Datum b)
{
@ -459,13 +361,7 @@ _uri_cmp(Datum a, Datum b)
if (res == 0)
res = cmp_text_range(ua.scheme, ub.scheme);
if (res == 0)
res = cmp_hosts(&ua, &ub);
if (res == 0)
res = _uri_port_num(&ua) - _uri_port_num(&ub);
if (res == 0)
res = cmp_text_range(ua.userInfo, ub.userInfo);
if (res == 0)
res = strcasecmp_ascii(sa, sb);
res = cmp_text_range(ua.hostText, ub.hostText);
if (res == 0)
res = strcmp(sa, sb);
uriFreeUriMembersA(&ua);