Fix pg_stat_ssl.clientdn

Return null if there is no client certificate.  This is how it has
always been documented, but in reality it returned an empty string.

Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Discussion: https://www.postgresql.org/message-id/flat/398754d8-6bb5-c5cf-e7b8-22e5f0983caf@2ndquadrant.com/
This commit is contained in:
Peter Eisentraut 2019-01-28 14:36:48 +01:00
parent 18059543e7
commit e77cfa54d7
2 changed files with 5 additions and 2 deletions

View File

@ -652,7 +652,10 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
values[20] = CStringGetTextDatum(beentry->st_sslstatus->ssl_cipher);
values[21] = Int32GetDatum(beentry->st_sslstatus->ssl_bits);
values[22] = BoolGetDatum(beentry->st_sslstatus->ssl_compression);
values[23] = CStringGetTextDatum(beentry->st_sslstatus->ssl_clientdn);
if (beentry->st_sslstatus->ssl_clientdn[0])
values[23] = CStringGetTextDatum(beentry->st_sslstatus->ssl_clientdn);
else
nulls[23] = true;
}
else
{

View File

@ -316,7 +316,7 @@ command_like([
'-c', "SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid()"
],
qr{^pid,ssl,version,cipher,bits,compression,clientdn\n
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,$}mx,
^\d+,t,TLSv[\d.]+,[\w-]+,\d+,f,_null_$}mx,
'pg_stat_ssl view without client certificate');
### Server-side tests.