From bf64a37909cd25e2e14c47de922a51d205795d17 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 11 Jun 2006 15:49:28 +0000 Subject: Fix Assert failure when a fastpath function call is attempted inside an already-aborted transaction block. GetSnapshotData throws an Assert if not in a valid transaction; hence we mustn't attempt to set a snapshot for the function until after checking for aborted transaction. This is harmless AFAICT if Asserts aren't enabled (GetSnapshotData will compute a bogus snapshot, but it doesn't matter since HandleFunctionRequest will throw an error shortly anywy). Hence, not a major bug. Along the way, add some ability to log fastpath calls when statement logging is turned on. This could probably stand to be improved further, but not logging anything is clearly undesirable. Backpatched as far as 8.0; bug doesn't exist before that. --- src/backend/tcop/postgres.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 2135c92fd80..a43478088f9 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.486 2006/04/25 00:25:18 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.487 2006/06/11 15:49:28 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -3344,12 +3344,18 @@ PostgresMain(int argc, char *argv[], const char *username) /* start an xact for this function invocation */ initialize_command(); + /* + * Note: we may at this point be inside an aborted + * transaction. We can't throw error for that until + * we've finished reading the function-call message, so + * HandleFunctionRequest() must check for it after doing so. + * Be careful not to do anything that assumes we're inside a + * valid transaction here. + */ + /* switch back to message context */ MemoryContextSwitchTo(MessageContext); - /* set snapshot in case function needs one */ - ActiveSnapshot = CopySnapshot(GetTransactionSnapshot()); - if (HandleFunctionRequest(&input_message) == EOF) { /* lost frontend connection during F message input */ -- cgit v1.2.3