diff options
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 837c5321aa1..bf83a9b5697 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -3591,7 +3591,9 @@ keep_going: /* We will come back to here until there is * Anything else probably means it's not Postgres on the other * end at all. */ - if (!(beresp == 'R' || beresp == 'v' || beresp == 'E')) + if (beresp != PqMsg_AuthenticationRequest && + beresp != PqMsg_ErrorResponse && + beresp != PqMsg_NegotiateProtocolVersion) { libpq_append_conn_error(conn, "expected authentication request from server, but received %c", beresp); @@ -3618,19 +3620,22 @@ keep_going: /* We will come back to here until there is * version 14, the server also used the old protocol for * errors that happened before processing the startup packet.) */ - if (beresp == 'R' && (msgLength < 8 || msgLength > 2000)) + if (beresp == PqMsg_AuthenticationRequest && + (msgLength < 8 || msgLength > 2000)) { libpq_append_conn_error(conn, "received invalid authentication request"); goto error_return; } - if (beresp == 'v' && (msgLength < 8 || msgLength > 2000)) + if (beresp == PqMsg_NegotiateProtocolVersion && + (msgLength < 8 || msgLength > 2000)) { libpq_append_conn_error(conn, "received invalid protocol negotiation message"); goto error_return; } #define MAX_ERRLEN 30000 - if (beresp == 'E' && (msgLength < 8 || msgLength > MAX_ERRLEN)) + if (beresp == PqMsg_ErrorResponse && + (msgLength < 8 || msgLength > MAX_ERRLEN)) { /* Handle error from a pre-3.0 server */ conn->inCursor = conn->inStart + 1; /* reread data */ @@ -3693,7 +3698,7 @@ keep_going: /* We will come back to here until there is } /* Handle errors. */ - if (beresp == 'E') + if (beresp == PqMsg_ErrorResponse) { if (pqGetErrorNotice3(conn, true)) { @@ -3770,7 +3775,7 @@ keep_going: /* We will come back to here until there is goto error_return; } - else if (beresp == 'v') + else if (beresp == PqMsg_NegotiateProtocolVersion) { if (pqGetNegotiateProtocolVersion3(conn)) { @@ -4540,7 +4545,7 @@ sendTerminateConn(PGconn *conn) * Try to send "close connection" message to backend. Ignore any * error. */ - pqPutMsgStart('X', conn); + pqPutMsgStart(PqMsg_Terminate, conn); pqPutMsgEnd(conn); (void) pqFlush(conn); } |