summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Wegener <sven.wegener@stealer.net>2014-11-03 10:02:35 +0100
committerSven Wegener <sven.wegener@stealer.net>2016-08-03 14:20:07 +0200
commit04949d2265c425ba357a6ebd882244da9301f0b9 (patch)
tree584eb08f93feba029c2260b4e222cccd4819d525
parent0a4d67b16cd6a0d435169e66a1b4911007cb6aef (diff)
Use a complete new snaphot for COPYcopy-snapshot-fix
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
-rw-r--r--src/backend/commands/copy.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index f45b3304ae9..c3f728cddd5 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1364,6 +1364,13 @@ BeginCopy(bool is_from,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("table \"%s\" does not have OIDs",
RelationGetRelationName(cstate->rel))));
+
+ /*
+ * Use a new snapshot to ensure this query sees
+ * results of any previously executed queries.
+ */
+ if (!is_from)
+ PushActiveSnapshot(GetTransactionSnapshot());
}
else
{
@@ -1481,11 +1488,10 @@ BeginCopy(bool is_from,
}
/*
- * Use a snapshot with an updated command ID to ensure this query sees
+ * Use a new snapshot to ensure this query sees
* results of any previously executed queries.
*/
- PushCopiedSnapshot(GetActiveSnapshot());
- UpdateActiveSnapshotCommandId();
+ PushActiveSnapshot(GetTransactionSnapshot());
/* Create dest receiver for COPY OUT */
dest = CreateDestReceiver(DestCopyOut);
@@ -1838,9 +1844,11 @@ EndCopyTo(CopyState cstate)
ExecutorFinish(cstate->queryDesc);
ExecutorEnd(cstate->queryDesc);
FreeQueryDesc(cstate->queryDesc);
- PopActiveSnapshot();
}
+ /* Discard snapshot */
+ PopActiveSnapshot();
+
/* Clean up storage */
EndCopy(cstate);
}