From 2ce2046a433ef5430a794fd77ebeef15a383d987 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 30 Oct 2015 15:08:42 +0900 Subject: [PATCH] Ignore close statement/portal request if they do not exist. In this case just returns a close complete message to client. This is a back port of commit: 1a37e1c35bd8b6f10f524693bbcb7b51f73b4bf0 which should have been back ported earlier. --- pool_proto_modules.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pool_proto_modules.c b/pool_proto_modules.c index 113aa3a86..2d13de0c0 100644 --- a/pool_proto_modules.c +++ b/pool_proto_modules.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2014 PgPool Global Development Group + * Copyright (c) 2003-2015 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -1166,21 +1166,16 @@ POOL_STATUS Close(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, msg = pool_get_sent_message('Q', contents+1); if (!msg) msg = pool_get_sent_message('P', contents+1); + if (!msg) - { - pool_error("Close: cannot get parse message"); - return POOL_END; - } + pool_debug("Close: cannot get parse message"); } /* Portal */ else if (*contents == 'P') { msg = pool_get_sent_message('B', contents+1); if (!msg) - { - pool_error("Close: cannot get bind message"); - return POOL_END; - } + pool_debug("Close: cannot get bind message"); } else { @@ -1188,6 +1183,23 @@ POOL_STATUS Close(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, return POOL_END; } + /* + * As per the postgresql, calling close on non existing portals is not + * an error. So on the same footings we will ignore all such calls and + * return the close complete message to clients with out going to backend + */ + if (!msg) + { + int len = htonl(sizeof(len)); + pool_set_command_success(); + pool_unset_query_in_progress(); + + pool_write(frontend, "3", 1); + pool_write_and_flush(frontend, &len, sizeof(len)); + + return POOL_CONTINUE; + } + session_context->uncompleted_message = msg; query_context = msg->query_context; -- 2.39.5