From b27de223da1f64a23cf7934b78757b5fa073fbc4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 1 Dec 2008 17:06:41 +0000 Subject: Ensure that the contents of a holdable cursor don't depend on out-of-line toasted values, since those could get dropped once the cursor's transaction is over. Per bug #4553 from Andrew Gierth. Back-patch as far as 8.1. The bug actually exists back to 7.4 when holdable cursors were introduced, but this patch won't work before 8.1 without significant adjustments. Given the lack of field complaints, it doesn't seem worth the work (and risk of introducing new bugs) to try to make a patch for the older branches. --- src/backend/commands/portalcmds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/backend/commands/portalcmds.c') diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 39b73c7a609..f02ecec3f8f 100644 --- a/src/backend/commands/portalcmds.c +++ b/src/backend/commands/portalcmds.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.44.2.1 2007/02/06 22:49:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.44.2.2 2008/12/01 17:06:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,6 +25,7 @@ #include "commands/portalcmds.h" #include "executor/executor.h" +#include "executor/tstoreReceiver.h" #include "optimizer/planner.h" #include "rewrite/rewriteHandler.h" #include "tcop/pquery.h" @@ -368,8 +369,12 @@ PersistHoldablePortal(Portal portal) */ ExecutorRewind(queryDesc); - /* Change the destination to output to the tuplestore */ + /* + * Change the destination to output to the tuplestore. Note we + * tell the tuplestore receiver to detoast all data passed through it. + */ queryDesc->dest = CreateDestReceiver(DestTuplestore, portal); + SetTuplestoreDestReceiverDeToast(queryDesc->dest, true); /* Fetch the result set into the tuplestore */ ExecutorRun(queryDesc, ForwardScanDirection, 0L); -- cgit v1.2.3