Re: BUG #5246: Misleading/inconsistent SQLSTATE behavior

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Travers <chris(at)metatrontech(dot)com>
Cc: Chris Travers <chris(dot)travers(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5246: Misleading/inconsistent SQLSTATE behavior
Date: 2009-12-17 01:31:27
Message-ID: 20245.1261013487@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Chris Travers <chris(at)metatrontech(dot)com> writes:
> 2) As of 8.1, tshark shows that the server does send the SQLSTATE to
> the client regarding why the login fails (for example 3D000 in the
> case of bad db name). Libpq as far as I can tell (from reading the
> code) doesn't do anything with this code. Certainly there seems to be
> no exposure of the SQLSTATE to anything as it relates to a failed
> connection attempt. I could be missing something because I am not
> extremely familiar with the libpq codebase, but it seems that the
> value is just discarded.

Yeah. The problem is that the only infrastructure libpq has for returning
individual error message fields (like the SQLSTATE) is associated with a
PGresult, and there's no PGresult for a connection failure. I see no
easy way to fix that without incompatible changes in libpq's API.

This is related to the fact that errors detected internally in libpq
generally lack SQLSTATEs. Part of the reason that fixing that has been
so low-priority is that in many cases there's no existing API whereby
they could be returned anyhow. It's been on the TODO list since 7.4,
but nobody has cared to tackle it.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Craig Ringer 2009-12-17 02:03:53 Re: pgstat wait timeout (by Robert Schnabel)
Previous Message Chris Travers 2009-12-17 01:14:59 Re: BUG #5246: Misleading/inconsistent SQLSTATE behavior