From 059897bf907022e416db9af21f5bb1c8fbd824d1 Mon Sep 17 00:00:00 2001 From: Xnoe Date: Tue, 10 Jan 2023 22:59:03 +0000 Subject: [PATCH] Changed error level to NOTICE and return NULL when an error is encountered --- rdns--1.0.sql | 4 ++-- rdns.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/rdns--1.0.sql b/rdns--1.0.sql index 6a01ea6..9662825 100644 --- a/rdns--1.0.sql +++ b/rdns--1.0.sql @@ -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; diff --git a/rdns.c b/rdns.c index 5ffacfe..f762f7e 100644 --- a/rdns.c +++ b/rdns.c @@ -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;