Such messages are not entirely valid (sqlstate is documented to be
always present), however we receive them after a SHOW HELP in the
PgBouncer admin database.
The SHOW HELP actually does generate a sqlstate `00000` but the message
is somehow parsed incorrectly by the libpq, which goes on to report an
error:
message contents do not agree with length in message type "N"
See #303. PgBouncer issue reported upstream in
https://github.com/pgbouncer/pgbouncer/issues/718
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Raise `DataError` dumping arrays of mixed types (:ticket:`#301`).
+- Fix handling of incorrect server results, with blank sqlstate (:ticket:`#303`).
Current release
def get_base_exception(sqlstate: str) -> Type[Error]:
return (
_base_exc_map.get(sqlstate[:2])
- or _base_exc_map.get(sqlstate[0])
+ or _base_exc_map.get(sqlstate[:1])
or DatabaseError
)
exc = pickle.loads(pickle.dumps(excinfo.value))
assert exc.pgresult is None
assert exc.diag.sqlstate == "42P01"
+
+
+def test_blank_sqlstate(conn):
+ assert e.get_base_exception("") is e.DatabaseError