aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-12-04 19:47:06 -0500
committerRobert Haas <rhaas@postgresql.org>2014-12-04 19:49:43 -0500
commit9a946298338e4783fcc98e0896712fdf2b2bfd56 (patch)
tree20bdcae224685ce8a8d5842350f9e90150dd5373
parent5ede3a31171d83b94a773d997fe05b563f8ebb3d (diff)
downloadpostgresql-9a946298338e4783fcc98e0896712fdf2b2bfd56.tar.gz
postgresql-9a946298338e4783fcc98e0896712fdf2b2bfd56.zip
Don't dump core if pq_comm_reset() is called before pq_init().
This can happen if an error occurs in a standalone backend. This bug was introduced by commit 2bd9e412f92bc6a68f3e8bcb18e04955cc35001d. Reported by Álvaro Herrera.
-rw-r--r--src/backend/libpq/pqcomm.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 74161970ab5..a4abf3ab832 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -105,9 +105,6 @@ char *Unix_socket_group;
/* Where the Unix socket files are (list of palloc'd strings) */
static List *sock_paths = NIL;
-PQcommMethods *PqCommMethods;
-
-
/*
* Buffers for low-level I/O.
*
@@ -154,8 +151,6 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
static int Setup_AF_UNIX(char *sock_path);
#endif /* HAVE_UNIX_SOCKETS */
-PQcommMethods PQcommSocketMethods;
-
static PQcommMethods PqCommSocketMethods = {
socket_comm_reset,
socket_flush,
@@ -167,6 +162,9 @@ static PQcommMethods PqCommSocketMethods = {
socket_endcopyout
};
+PQcommMethods *PqCommMethods = &PqCommSocketMethods;
+
+
/* --------------------------------
* pq_init - initialize libpq at backend startup
@@ -175,7 +173,6 @@ static PQcommMethods PqCommSocketMethods = {
void
pq_init(void)
{
- PqCommMethods = &PqCommSocketMethods;
PqSendBufferSize = PQ_SEND_BUFFER_SIZE;
PqSendBuffer = MemoryContextAlloc(TopMemoryContext, PqSendBufferSize);
PqSendPointer = PqSendStart = PqRecvPointer = PqRecvLength = 0;