Fix compilation on older PostgreSQL versions
This commit is contained in:
parent
2dd3f82fb9
commit
83b652dc7e
|
@ -1,4 +1,5 @@
|
||||||
\pset null _null_
|
\pset null _null_
|
||||||
|
SET client_min_messages = warning;
|
||||||
CREATE TABLE test (a serial, b uri);
|
CREATE TABLE test (a serial, b uri);
|
||||||
INSERT INTO test (b)
|
INSERT INTO test (b)
|
||||||
VALUES ('http://www.postgresql.org/'),
|
VALUES ('http://www.postgresql.org/'),
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
\pset null _null_
|
\pset null _null_
|
||||||
|
|
||||||
|
SET client_min_messages = warning;
|
||||||
|
|
||||||
CREATE TABLE test (a serial, b uri);
|
CREATE TABLE test (a serial, b uri);
|
||||||
|
|
||||||
INSERT INTO test (b)
|
INSERT INTO test (b)
|
||||||
|
|
16
uri.c
16
uri.c
|
@ -143,14 +143,16 @@ uri_host_inet(PG_FUNCTION_ARGS)
|
||||||
if (uri.hostData.ip4)
|
if (uri.hostData.ip4)
|
||||||
{
|
{
|
||||||
unsigned char *data = uri.hostData.ip4;
|
unsigned char *data = uri.hostData.ip4;
|
||||||
char *tmp = psprintf("%u.%u.%u.%u", data[0], data[1], data[2], data[3]);
|
char *tmp = palloc(16);
|
||||||
|
snprintf(tmp, 16, "%u.%u.%u.%u", data[0], data[1], data[2], data[3]);
|
||||||
uriFreeUriMembersA(&uri);
|
uriFreeUriMembersA(&uri);
|
||||||
PG_RETURN_INET_P(DirectFunctionCall1(inet_in, CStringGetDatum(tmp)));
|
PG_RETURN_INET_P(DirectFunctionCall1(inet_in, CStringGetDatum(tmp)));
|
||||||
}
|
}
|
||||||
else if (uri.hostData.ip6)
|
else if (uri.hostData.ip6)
|
||||||
{
|
{
|
||||||
unsigned char *data = uri.hostData.ip6;
|
unsigned char *data = uri.hostData.ip6;
|
||||||
char *tmp = psprintf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
char *tmp = palloc(40);
|
||||||
|
snprintf(tmp, 40, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
||||||
data[0], data[1], data[2], data[3],
|
data[0], data[1], data[2], data[3],
|
||||||
data[4], data[5], data[6], data[7],
|
data[4], data[5], data[6], data[7],
|
||||||
data[8], data[9], data[10], data[11],
|
data[8], data[9], data[10], data[11],
|
||||||
|
@ -226,7 +228,7 @@ uri_path(PG_FUNCTION_ARGS)
|
||||||
Datum arg = PG_GETARG_DATUM(0);
|
Datum arg = PG_GETARG_DATUM(0);
|
||||||
char *s = TextDatumGetCString(arg);
|
char *s = TextDatumGetCString(arg);
|
||||||
UriUriA uri;
|
UriUriA uri;
|
||||||
ArrayBuildState *astate = initArrayResult(TEXTOID, CurrentMemoryContext);
|
ArrayBuildState *astate = NULL;
|
||||||
UriPathSegmentA *pa;
|
UriPathSegmentA *pa;
|
||||||
|
|
||||||
parse_uri(s, &uri);
|
parse_uri(s, &uri);
|
||||||
|
@ -241,11 +243,9 @@ uri_path(PG_FUNCTION_ARGS)
|
||||||
}
|
}
|
||||||
uriFreeUriMembersA(&uri);
|
uriFreeUriMembersA(&uri);
|
||||||
|
|
||||||
if (astate)
|
PG_RETURN_ARRAYTYPE_P(astate
|
||||||
PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate,
|
? makeArrayResult(astate, CurrentMemoryContext)
|
||||||
CurrentMemoryContext));
|
: construct_empty_array(TEXTOID));
|
||||||
else
|
|
||||||
PG_RETURN_NULL();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in New Issue