Commit 9a946298 authored by Robert Haas's avatar Robert Haas

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 2bd9e412.

Reported by Álvaro Herrera.
parent 5ede3a31
...@@ -105,9 +105,6 @@ char *Unix_socket_group; ...@@ -105,9 +105,6 @@ char *Unix_socket_group;
/* Where the Unix socket files are (list of palloc'd strings) */ /* Where the Unix socket files are (list of palloc'd strings) */
static List *sock_paths = NIL; static List *sock_paths = NIL;
PQcommMethods *PqCommMethods;
/* /*
* Buffers for low-level I/O. * Buffers for low-level I/O.
* *
...@@ -154,8 +151,6 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath); ...@@ -154,8 +151,6 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
static int Setup_AF_UNIX(char *sock_path); static int Setup_AF_UNIX(char *sock_path);
#endif /* HAVE_UNIX_SOCKETS */ #endif /* HAVE_UNIX_SOCKETS */
PQcommMethods PQcommSocketMethods;
static PQcommMethods PqCommSocketMethods = { static PQcommMethods PqCommSocketMethods = {
socket_comm_reset, socket_comm_reset,
socket_flush, socket_flush,
...@@ -167,6 +162,9 @@ static PQcommMethods PqCommSocketMethods = { ...@@ -167,6 +162,9 @@ static PQcommMethods PqCommSocketMethods = {
socket_endcopyout socket_endcopyout
}; };
PQcommMethods *PqCommMethods = &PqCommSocketMethods;
/* -------------------------------- /* --------------------------------
* pq_init - initialize libpq at backend startup * pq_init - initialize libpq at backend startup
...@@ -175,7 +173,6 @@ static PQcommMethods PqCommSocketMethods = { ...@@ -175,7 +173,6 @@ static PQcommMethods PqCommSocketMethods = {
void void
pq_init(void) pq_init(void)
{ {
PqCommMethods = &PqCommSocketMethods;
PqSendBufferSize = PQ_SEND_BUFFER_SIZE; PqSendBufferSize = PQ_SEND_BUFFER_SIZE;
PqSendBuffer = MemoryContextAlloc(TopMemoryContext, PqSendBufferSize); PqSendBuffer = MemoryContextAlloc(TopMemoryContext, PqSendBufferSize);
PqSendPointer = PqSendStart = PqRecvPointer = PqRecvLength = 0; PqSendPointer = PqSendStart = PqRecvPointer = PqRecvLength = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment