Reset conn->errorReported when PQrequestCancel sets errorMessage.
authorTom Lane <[email protected]>
Sun, 20 Feb 2022 20:02:41 +0000 (15:02 -0500)
committerTom Lane <[email protected]>
Sun, 20 Feb 2022 20:02:41 +0000 (15:02 -0500)
Oversight in commit 618c16707.  This is mainly neatnik-ism, since
if PQrequestCancel is used per its API contract, we should perform
pqClearConnErrorState before reaching any place that would consult
errorReported.  But still, it seems like a bad idea to potentially
leave errorReported pointing past errorMessage.len.

src/interfaces/libpq/fe-connect.c

index 2a3d68b4d146d04c86950c02803df668bbace51d..1c5a2b43e99a82e327bdfa6f5715cc9150b2cb97 100644 (file)
@@ -4687,6 +4687,7 @@ PQrequestCancel(PGconn *conn)
                "PQrequestCancel() -- connection is not open\n",
                conn->errorMessage.maxlen);
        conn->errorMessage.len = strlen(conn->errorMessage.data);
+       conn->errorReported = 0;
 
        return false;
    }
@@ -4706,7 +4707,10 @@ PQrequestCancel(PGconn *conn)
    }
 
    if (!r)
+   {
        conn->errorMessage.len = strlen(conn->errorMessage.data);
+       conn->errorReported = 0;
+   }
 
    return r;
 }