Re: dblink question please

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: dblink question please
Дата
Msg-id 3E4B1CB7.90309@joeconway.com
обсуждение исходный текст
Ответ на dblink question please  ("Frankie Lam" <frankie@ucr.com.hk>)
Список pgsql-sql
Frankie Lam wrote:
> Does anyone know if there's a simple way that let dblink function calls in a
> plpgsql function wouldn't raise exception, in case there's sth wrong.
> (e.g. cannot connect to the remote host ......)

Not without hacking dblink.c.

At quick glance it looks like it might be reasonably safe to use
dblink_connect with the lines:

8<---------------------------------
if (PQstatus(persistent_conn) == CONNECTION_BAD)
{   msg = pstrdup(PQerrorMessage(persistent_conn));   PQfinish(persistent_conn);   persistent_conn = NULL;
elog(ERROR,"dblink_connect: connection error: %s", msg);
 
}
8<---------------------------------

changed to something like (untested)

8<---------------------------------
if (PQstatus(persistent_conn) == CONNECTION_BAD)
{   msg = pstrdup(PQerrorMessage(persistent_conn));   PQfinish(persistent_conn);   persistent_conn = NULL;
elog(NOTICE,"dblink_connect: connection error: %s", msg);   result_text = DatumGetTextP(DirectFunctionCall1(textin,
                            CStringGetDatum("ERROR")));   PG_RETURN_TEXT_P(result_text);
 
}
8<---------------------------------

It would be more complex if you want to not use the persistent connection.

HTH,

Joe




В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Possible bug in Postgres? Followup to "How do you select from a table until a condition is met?"
Следующее
От: "Frankie Lam"
Дата:
Сообщение: Re: dblink question please