Ensure that a cursor has an immutable snapshot throughout its lifespan.
Alvaro Herrera <alvherre@alvh.no-ip.org>
Ensure that a cursor has an immutable snapshot throughout its lifespan. The old coding was using a regular snapshot, referenced elsewhere, that was subject to having its command counter updated. Fix by creating a private copy of the snapshot exclusively for the cursor. Backpatch to 8.4, which is when the bug was introduced during the snapshot management rewrite.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/commands/portalcmds.c | modified | +11 −2 |
| src/backend/executor/spi.c | modified | +2 −5 |
| src/backend/utils/time/snapmgr.c | modified | +2 −3 |
| src/include/utils/snapmgr.h | modified | +2 −1 |
| src/test/regress/expected/portals.out | modified | +15 −0 |
| src/test/regress/sql/portals.sql | modified | +12 −0 |