Re: postgres source code function "internal_ping" may be not right in some conditions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lin <jluwln(at)163(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres source code function "internal_ping" may be not right in some conditions
Date: 2017-03-24 14:02:43
Message-ID: 17209.1490364163@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

lin <jluwln(at)163(dot)com> writes:
> all. I have test the function "internal_ping", and find in some conditions, the return result is not right.

> if conn->status == CONNECTION_BAD , and the "conn->last_sqlstate" is "28000", the return value is PQPING_OK, it is not right.

I don't think so. 28000 is ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION,
which is a not-unlikely case here since often a caller wouldn't have
bothered to provide a valid userid. However, if the server returned that,
then it must be up; otherwise it could not have looked into pg_authid
to find out that the supplied userid wasn't valid.

IOW, the point of the ping functionality is to test whether the server
is up, not whether you have valid login credentials.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Farber 2017-03-24 15:06:39 Combining INSERT with DELETE RETURNING
Previous Message Greg Sabino Mullane 2017-03-24 13:18:40 Re: Run statements before pg_dump in same transaction?