Ignore close statement/portal request if they do not exist.
authorTatsuo Ishii <ishii@postgresql.org>
Fri, 30 Oct 2015 06:08:42 +0000 (15:08 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Fri, 30 Oct 2015 06:12:36 +0000 (15:12 +0900)
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

index c1b081d30806a9f41fb892cbd28f59489e03edc1..40ae2d6bae4fa0a5492acdbbe680bba699b89eb2 100644 (file)
@@ -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
@@ -1456,21 +1456,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
        {
@@ -1478,6 +1473,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;