Changed error level to NOTICE and return NULL when an error is encountered

This commit is contained in:
Xnoe 2023-01-10 22:59:03 +00:00
parent 1cec318025
commit 059897bf90
Signed by: xnoe
GPG Key ID: 45AC398F44F0DAFE
2 changed files with 6 additions and 4 deletions

View File

@ -1,9 +1,9 @@
CREATE FUNCTION rdns_lookup(text)
RETURNS text
AS '$libdir/rdns'
IMMUTABLE AS '$libdir/rdns'
LANGUAGE C STRICT;
CREATE FUNCTION circular_rdns_lookup(text)
RETURNS text
AS '$libdir/rdns'
IMMUTABLE AS '$libdir/rdns'
LANGUAGE C STRICT;

6
rdns.c
View File

@ -61,14 +61,16 @@ Datum circular_rdns_lookup(PG_FUNCTION_ARGS) {
if (r == EAI_NONAME)
PG_RETURN_NULL();
if (r) {
ereport(ERROR, (errcode(ERRCODE_SYSTEM_ERROR), errmsg("getnameinfo failed! %s", gai_strerror(r))));
ereport(NOTICE, (errcode(ERRCODE_SYSTEM_ERROR), errmsg("getnameinfo failed for IP `%s`, %s", ip, gai_strerror(r))));
PG_RETURN_NULL();
}
hint.ai_family = AF_INET;
r = getaddrinfo(host, 0, &hint, &results);
if (r) {
ereport(ERROR, (errcode(ERRCODE_SYSTEM_ERROR), errmsg("getaddrinfo failed! %s", gai_strerror(r))));
ereport(NOTICE, (errcode(ERRCODE_SYSTEM_ERROR), errmsg("getaddrinfo failed for host `%s`, %s", host, gai_strerror(r))));
PG_RETURN_NULL();
}
c = results;