1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-08 00:47:37 +03:00

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.
This commit is contained in:
Tom Lane
2006-06-11 15:49:28 +00:00
parent 807bfa581c
commit bf64a37909
2 changed files with 24 additions and 6 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.86 2006/04/04 19:35:35 tgl Exp $
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.87 2006/06/11 15:49:28 tgl Exp $
*
* NOTES
* This cruft is the server side of PQfn.
@@ -26,6 +26,7 @@
#include "miscadmin.h"
#include "mb/pg_wchar.h"
#include "tcop/fastpath.h"
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
@@ -299,14 +300,25 @@ HandleFunctionRequest(StringInfo msgBuf)
errmsg("current transaction is aborted, "
"commands ignored until end of transaction block")));
/*
* Now that we know we are in a valid transaction, set snapshot in
* case needed by function itself or one of the datatype I/O routines.
*/
ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
/*
* Begin parsing the buffer contents.
*/
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
(void) pq_getmsgstring(msgBuf); /* dummy string */
(void) pq_getmsgstring(msgBuf); /* dummy string */
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
if (log_statement == LOGSTMT_ALL)
ereport(LOG,
(errmsg("fastpath function call: function OID %u",
fid)));
/*
* There used to be a lame attempt at caching lookup info here. Now we
* just do the lookups on every call.