Correctly handle an empty error message from PQescapeIdentifier

This commit is contained in:
Daniele Varrazzo 2014-06-05 13:41:45 +02:00 committed by mrmilosz
parent 54e5349f53
commit 92109e4bba

View File

@ -1030,7 +1030,8 @@ _escape_identifier(PGconn *pgconn, const char *str, size_t length)
rv = PQescapeIdentifier(pgconn, str, length);
if (!rv) {
char *msg;
if (!(msg = PQerrorMessage(pgconn))) {
msg = PQerrorMessage(pgconn);
if (!msg || !msg[0]) {
msg = "no message provided";
}
PyErr_Format(InterfaceError, "failed to escape identifier: %s", msg);