Skip to content

Commit fd01983

Browse files
committed
Remove dead code and fix comments in fast-path function handling.
HandleFunctionRequest() is no longer responsible for reading the protocol message from the client, since commit 2b3a8b2. Fix the outdated comments. HandleFunctionRequest() now always returns 0, because the code that used to return EOF was moved in 2b3a8b2. 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
1 parent 5c21ad0 commit fd01983

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

src/backend/tcop/fastpath.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -249,24 +249,15 @@ fetch_fp_info(Oid func_id, struct fp_info * fip)
249249
* This corresponds to the libpq protocol symbol "F".
250250
*
251251
* INPUT:
252-
* In protocol version 3, postgres.c has already read the message body
253-
* and will pass it in msgBuf.
254-
* In old protocol, the passed msgBuf is empty and we must read the
255-
* message here.
256-
*
257-
* RETURNS:
258-
* 0 if successful completion, EOF if frontend connection lost.
259-
*
260-
* Note: All ordinary errors result in ereport(ERROR,...). However,
261-
* if we lose the frontend connection there is no one to ereport to,
262-
* and no use in proceeding...
252+
* postgres.c has already read the message body and will pass it in
253+
* msgBuf.
263254
*
264255
* Note: palloc()s done here and in the called function do not need to be
265256
* cleaned up explicitly. We are called from PostgresMain() in the
266257
* MessageContext memory context, which will be automatically reset when
267258
* control returns to PostgresMain.
268259
*/
269-
int
260+
void
270261
HandleFunctionRequest(StringInfo msgBuf)
271262
{
272263
Oid fid;
@@ -281,9 +272,8 @@ HandleFunctionRequest(StringInfo msgBuf)
281272
char msec_str[32];
282273

283274
/*
284-
* Now that we've eaten the input message, check to see if we actually
285-
* want to do the function call or not. It's now safe to ereport(); we
286-
* won't lose sync with the frontend.
275+
* We only accept COMMIT/ABORT if we are in an aborted transaction, and
276+
* COMMIT/ABORT cannot be executed through the fastpath interface.
287277
*/
288278
if (IsAbortedTransactionBlockState())
289279
ereport(ERROR,
@@ -406,8 +396,6 @@ HandleFunctionRequest(StringInfo msgBuf)
406396
msec_str, fip->fname, fid)));
407397
break;
408398
}
409-
410-
return 0;
411399
}
412400

413401
/*

src/backend/tcop/postgres.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,19 +4164,7 @@ PostgresMain(int argc, char *argv[],
41644164
/* switch back to message context */
41654165
MemoryContextSwitchTo(MessageContext);
41664166

4167-
if (HandleFunctionRequest(&input_message) == EOF)
4168-
{
4169-
/* lost frontend connection during F message input */
4170-
4171-
/*
4172-
* Reset whereToSendOutput to prevent ereport from
4173-
* attempting to send any more messages to client.
4174-
*/
4175-
if (whereToSendOutput == DestRemote)
4176-
whereToSendOutput = DestNone;
4177-
4178-
proc_exit(0);
4179-
}
4167+
HandleFunctionRequest(&input_message);
41804168

41814169
/* commit the function-invocation transaction */
41824170
finish_xact_command();

src/include/tcop/fastpath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
#include "lib/stringinfo.h"
1717

1818
extern int GetOldFunctionMessage(StringInfo buf);
19-
extern int HandleFunctionRequest(StringInfo msgBuf);
19+
extern void HandleFunctionRequest(StringInfo msgBuf);
2020

2121
#endif /* FASTPATH_H */

0 commit comments

Comments
 (0)