diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index d0b368530e..6ca814224f 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -714,6 +714,9 @@ errcode_for_socket_access(void) case EPIPE: #ifdef ECONNRESET case ECONNRESET: +#endif +#ifdef ECONNABORTED + case ECONNABORTED: #endif edata->sqlerrcode = ERRCODE_CONNECTION_FAILURE; break; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index ff840b7730..657310f22c 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -683,6 +683,11 @@ retry3: #ifdef ECONNRESET if (SOCK_ERRNO == ECONNRESET) goto definitelyFailed; +#endif + /* We might get ECONNABORTED here if using TCP and backend died */ +#ifdef ECONNABORTED + if (SOCK_ERRNO == ECONNABORTED) + goto definitelyFailed; #endif /* pqsecure_read set the error message for us */ return -1; @@ -773,6 +778,11 @@ retry4: #ifdef ECONNRESET if (SOCK_ERRNO == ECONNRESET) goto definitelyFailed; +#endif + /* We might get ECONNABORTED here if using TCP and backend died */ +#ifdef ECONNABORTED + if (SOCK_ERRNO == ECONNABORTED) + goto definitelyFailed; #endif /* pqsecure_read set the error message for us */ return -1; diff --git a/src/interfaces/libpq/win32.h b/src/interfaces/libpq/win32.h index c42d7abfe3..40cff28f3a 100644 --- a/src/interfaces/libpq/win32.h +++ b/src/interfaces/libpq/win32.h @@ -22,6 +22,9 @@ #ifndef ECONNRESET #define ECONNRESET WSAECONNRESET #endif +#ifndef ECONNABORTED +#define ECONNABORTED WSAECONNABORTED +#endif #ifndef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #endif