]> granicus.if.org Git - postgresql/commitdiff
Remove dead code and fix comments in fast-path function handling.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 6 Apr 2017 06:09:39 +0000 (09:09 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 6 Apr 2017 06:11:22 +0000 (09:11 +0300)
HandleFunctionRequest() is no longer responsible for reading the protocol
message from the client, since commit 2b3a8b20c2. Fix the outdated
comments.

HandleFunctionRequest() now always returns 0, because the code that used
to return EOF was moved in 2b3a8b20c2. Therefore, the caller no longer
needs to check the return value.

Reported by Andres Freund. Backpatch to all supported versions, even though
this doesn't have any user-visible effect, to make backporting future
patches in this area easier.

Discussion: https://www.postgresql.org/message-id/20170405010525.rt5azbya5fkbhvrx@alap3.anarazel.de

src/backend/tcop/fastpath.c
src/backend/tcop/postgres.c
src/include/tcop/fastpath.h

index 6614a12f1dd3a9d8182b4b54943c35aa58587b32..3dd6633bfb931db0c7597b353ddf68358441c6c0 100644 (file)
@@ -249,24 +249,15 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
  * This corresponds to the libpq protocol symbol "F".
  *
  * INPUT:
- *             In protocol version 3, postgres.c has already read the message body
- *             and will pass it in msgBuf.
- *             In old protocol, the passed msgBuf is empty and we must read the
- *             message here.
- *
- * RETURNS:
- *             0 if successful completion, EOF if frontend connection lost.
- *
- * Note: All ordinary errors result in ereport(ERROR,...).  However,
- * if we lose the frontend connection there is no one to ereport to,
- * and no use in proceeding...
+ *             postgres.c has already read the message body and will pass it in
+ *             msgBuf.
  *
  * Note: palloc()s done here and in the called function do not need to be
  * cleaned up explicitly.  We are called from PostgresMain() in the
  * MessageContext memory context, which will be automatically reset when
  * control returns to PostgresMain.
  */
-int
+void
 HandleFunctionRequest(StringInfo msgBuf)
 {
        Oid                     fid;
@@ -281,9 +272,8 @@ HandleFunctionRequest(StringInfo msgBuf)
        char            msec_str[32];
 
        /*
-        * Now that we've eaten the input message, check to see if we actually
-        * want to do the function call or not.  It's now safe to ereport(); we
-        * won't lose sync with the frontend.
+        * We only accept COMMIT/ABORT if we are in an aborted transaction, and
+        * COMMIT/ABORT cannot be executed through the fastpath interface.
         */
        if (IsAbortedTransactionBlockState())
                ereport(ERROR,
@@ -406,8 +396,6 @@ HandleFunctionRequest(StringInfo msgBuf)
                                                        msec_str, fip->fname, fid)));
                        break;
        }
-
-       return 0;
 }
 
 /*
index fa17316cd8df6acc0750f3634b810f34efa27faf..8b9c3d4feb9ba2356d94fa8a1fd126713884a0bc 100644 (file)
@@ -4189,19 +4189,7 @@ PostgresMain(int argc, char *argv[],
                                /* switch back to message context */
                                MemoryContextSwitchTo(MessageContext);
 
-                               if (HandleFunctionRequest(&input_message) == EOF)
-                               {
-                                       /* lost frontend connection during F message input */
-
-                                       /*
-                                        * Reset whereToSendOutput to prevent ereport from
-                                        * attempting to send any more messages to client.
-                                        */
-                                       if (whereToSendOutput == DestRemote)
-                                               whereToSendOutput = DestNone;
-
-                                       proc_exit(0);
-                               }
+                               HandleFunctionRequest(&input_message);
 
                                /* commit the function-invocation transaction */
                                finish_xact_command();
index c03a35fc0aea02e1855dd6fb91fdf2a9cc9d773d..22ebd52940ee834a9830f2739ab90e1b74a4984d 100644 (file)
@@ -16,6 +16,6 @@
 #include "lib/stringinfo.h"
 
 extern int GetOldFunctionMessage(StringInfo buf);
-extern int     HandleFunctionRequest(StringInfo msgBuf);
+extern void HandleFunctionRequest(StringInfo msgBuf);
 
 #endif   /* FASTPATH_H */