Separate snapshot management code from tuple visibility code, create a
snapmgmt.c file for the former. The header files have also been reorganized in three parts: the most basic snapshot definitions are now in a new file snapshot.h, and the also new snapmgmt.h keeps the definitions for snapmgmt.c. tqual.h has been reduced to the bare minimum. This patch is just a first step towards managing live snapshots within a transaction; there is no functionality change. Per my proposal to pgsql-patches on 20080318191940.GB27458@alvh.no-ip.org and subsequent discussion.
This commit is contained in:
parent
2d7705e85e
commit
d43b085d57
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.251 2008/03/08 21:57:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.252 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -56,6 +56,7 @@
|
||||
#include "utils/inval.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.101 2008/01/01 19:45:46 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.102 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
* index_open - open an index relation by relation OID
|
||||
@ -67,6 +67,7 @@
|
||||
#include "access/transam.h"
|
||||
#include "pgstat.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.106 2008/01/01 19:45:46 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtpage.c,v 1.107 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Postgres btree pages look like ordinary relation pages. The opaque
|
||||
@ -28,6 +28,7 @@
|
||||
#include "storage/freespace.h"
|
||||
#include "storage/lmgr.h"
|
||||
#include "utils/inval.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.20 2008/01/01 19:45:48 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.21 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -31,7 +31,7 @@
|
||||
#include "access/slru.h"
|
||||
#include "access/subtrans.h"
|
||||
#include "access/transam.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.74 2008/03/11 20:20:35 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.75 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains the high level access-method interface to the
|
||||
@ -22,7 +22,7 @@
|
||||
#include "access/clog.h"
|
||||
#include "access/subtrans.h"
|
||||
#include "access/transam.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.260 2008/03/17 19:44:41 petere Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.261 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -45,6 +45,7 @@
|
||||
#include "utils/inval.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/xml.h"
|
||||
#include "pg_trace.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.73 2008/02/20 17:44:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.74 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -38,6 +38,7 @@
|
||||
#include "storage/fd.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
#define OIDCHARS 10 /* max chars printed by %u */
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.328 2008/03/25 22:42:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.329 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -60,6 +60,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
static void AddNewRelationTuple(Relation pg_class_desc,
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.293 2008/03/25 22:42:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.294 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -55,6 +55,7 @@
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tuplesort.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/* state info for validate_index bulkdelete callback */
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.169 2008/01/30 19:46:48 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.170 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -41,6 +41,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.296 2008/03/08 01:16:26 adunstan Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.297 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -40,6 +40,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.169 2008/01/01 19:45:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.170 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -31,6 +31,7 @@
|
||||
#include "utils/guc.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/tuplesort.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/* Hook for plugins to get control in ExplainOneQuery() */
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.171 2008/02/07 17:09:51 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.172 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -47,6 +47,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.70 2008/03/20 20:05:56 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.71 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -28,6 +28,7 @@
|
||||
#include "executor/executor.h"
|
||||
#include "tcop/pquery.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Copyright (c) 2002-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.82 2008/03/25 22:42:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.83 2008/03/26 16:20:46 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -32,6 +32,7 @@
|
||||
#include "tcop/utility.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.244 2008/03/25 22:42:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.245 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -65,6 +65,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.227 2008/01/02 23:34:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.228 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -38,6 +38,7 @@
|
||||
#include "utils/inval.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.368 2008/03/19 14:18:21 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.369 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,6 +48,7 @@
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/pg_rusage.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "pgstat.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.125 2008/01/03 21:23:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.126 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -25,7 +25,7 @@
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.122 2008/03/25 22:42:43 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.123 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -28,6 +28,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/datum.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "utils/typcache.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.22 2008/01/01 19:45:49 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.23 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -40,6 +40,7 @@
|
||||
#include "executor/nodeBitmapHeapscan.h"
|
||||
#include "pgstat.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
static TupleTableSlot *BitmapHeapNext(BitmapHeapScanState *node);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.189 2008/03/20 20:05:56 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.190 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -20,6 +20,7 @@
|
||||
#include "executor/spi_priv.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/typcache.h"
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.141 2008/03/15 20:46:31 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.142 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -33,6 +33,7 @@
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/relcache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
#include "catalog/catalog.h"
|
||||
#include "miscadmin.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.41 2008/03/11 20:20:35 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.42 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -37,7 +37,7 @@
|
||||
#include "access/twophase.h"
|
||||
#include "miscadmin.h"
|
||||
#include "storage/procarray.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/* Our shared memory area */
|
||||
|
@ -24,7 +24,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.128 2008/03/01 19:26:22 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.129 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -42,6 +42,7 @@
|
||||
#include "storage/large_object.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/resowner.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.97 2008/01/01 19:45:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.98 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This cruft is the server side of PQfn.
|
||||
@ -30,6 +30,7 @@
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.545 2008/03/12 23:58:27 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.546 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -66,6 +66,7 @@
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/ps_status.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
|
||||
#include "pgstat.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.120 2008/01/01 19:45:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.121 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -23,6 +23,7 @@
|
||||
#include "tcop/tcopprot.h"
|
||||
#include "tcop/utility.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.104 2008/02/18 23:00:32 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.105 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@ -41,6 +41,7 @@
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
/* ----------
|
||||
|
@ -14,7 +14,7 @@
|
||||
* Author: Jan Wieck, Afilias USA INC.
|
||||
* 64-bit txids: Marko Kreen, Skype Technologies
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.4 2008/01/01 19:45:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/txid.c,v 1.5 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -26,6 +26,7 @@
|
||||
#include "funcapi.h"
|
||||
#include "libpq/pqformat.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
#ifndef INT64_IS_BUSTED
|
||||
|
3
src/backend/utils/cache/plancache.c
vendored
3
src/backend/utils/cache/plancache.c
vendored
@ -33,7 +33,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.15 2008/01/01 19:45:53 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.16 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -51,6 +51,7 @@
|
||||
#include "utils/inval.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/resowner.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Makefile for utils/time
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $PostgreSQL: pgsql/src/backend/utils/time/Makefile,v 1.13 2008/02/19 10:30:09 petere Exp $
|
||||
# $PostgreSQL: pgsql/src/backend/utils/time/Makefile,v 1.14 2008/03/26 16:20:47 alvherre Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@ -12,6 +12,6 @@ subdir = src/backend/utils/time
|
||||
top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
OBJS = combocid.o tqual.o
|
||||
OBJS = combocid.o tqual.o snapmgmt.o
|
||||
|
||||
include $(top_srcdir)/src/backend/common.mk
|
||||
|
172
src/backend/utils/time/snapmgmt.c
Normal file
172
src/backend/utils/time/snapmgmt.c
Normal file
@ -0,0 +1,172 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
* snapmgmt.c
|
||||
* PostgreSQL snapshot management code.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgmt.c,v 1.1 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/xact.h"
|
||||
#include "access/transam.h"
|
||||
#include "storage/procarray.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/*
|
||||
* These SnapshotData structs are static to simplify memory allocation
|
||||
* (see the hack in GetSnapshotData to avoid repeated malloc/free).
|
||||
*/
|
||||
static SnapshotData SerializableSnapshotData = {HeapTupleSatisfiesMVCC};
|
||||
static SnapshotData LatestSnapshotData = {HeapTupleSatisfiesMVCC};
|
||||
|
||||
/* Externally visible pointers to valid snapshots: */
|
||||
Snapshot SerializableSnapshot = NULL;
|
||||
Snapshot LatestSnapshot = NULL;
|
||||
|
||||
/*
|
||||
* This pointer is not maintained by this module, but it's convenient
|
||||
* to declare it here anyway. Callers typically assign a copy of
|
||||
* GetTransactionSnapshot's result to ActiveSnapshot.
|
||||
*/
|
||||
Snapshot ActiveSnapshot = NULL;
|
||||
|
||||
/*
|
||||
* These are updated by GetSnapshotData. We initialize them this way
|
||||
* for the convenience of TransactionIdIsInProgress: even in bootstrap
|
||||
* mode, we don't want it to say that BootstrapTransactionId is in progress.
|
||||
*/
|
||||
TransactionId TransactionXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentGlobalXmin = FirstNormalTransactionId;
|
||||
|
||||
|
||||
/*
|
||||
* GetTransactionSnapshot
|
||||
* Get the appropriate snapshot for a new query in a transaction.
|
||||
*
|
||||
* The SerializableSnapshot is the first one taken in a transaction.
|
||||
* In serializable mode we just use that one throughout the transaction.
|
||||
* In read-committed mode, we take a new snapshot each time we are called.
|
||||
*
|
||||
* Note that the return value points at static storage that will be modified
|
||||
* by future calls and by CommandCounterIncrement(). Callers should copy
|
||||
* the result with CopySnapshot() if it is to be used very long.
|
||||
*/
|
||||
Snapshot
|
||||
GetTransactionSnapshot(void)
|
||||
{
|
||||
/* First call in transaction? */
|
||||
if (SerializableSnapshot == NULL)
|
||||
{
|
||||
SerializableSnapshot = GetSnapshotData(&SerializableSnapshotData, true);
|
||||
return SerializableSnapshot;
|
||||
}
|
||||
|
||||
if (IsXactIsoLevelSerializable)
|
||||
return SerializableSnapshot;
|
||||
|
||||
LatestSnapshot = GetSnapshotData(&LatestSnapshotData, false);
|
||||
|
||||
return LatestSnapshot;
|
||||
}
|
||||
|
||||
/*
|
||||
* GetLatestSnapshot
|
||||
* Get a snapshot that is up-to-date as of the current instant,
|
||||
* even if we are executing in SERIALIZABLE mode.
|
||||
*/
|
||||
Snapshot
|
||||
GetLatestSnapshot(void)
|
||||
{
|
||||
/* Should not be first call in transaction */
|
||||
if (SerializableSnapshot == NULL)
|
||||
elog(ERROR, "no snapshot has been set");
|
||||
|
||||
LatestSnapshot = GetSnapshotData(&LatestSnapshotData, false);
|
||||
|
||||
return LatestSnapshot;
|
||||
}
|
||||
|
||||
/*
|
||||
* CopySnapshot
|
||||
* Copy the given snapshot.
|
||||
*
|
||||
* The copy is palloc'd in the current memory context.
|
||||
*/
|
||||
Snapshot
|
||||
CopySnapshot(Snapshot snapshot)
|
||||
{
|
||||
Snapshot newsnap;
|
||||
Size subxipoff;
|
||||
Size size;
|
||||
|
||||
/* We allocate any XID arrays needed in the same palloc block. */
|
||||
size = subxipoff = sizeof(SnapshotData) +
|
||||
snapshot->xcnt * sizeof(TransactionId);
|
||||
if (snapshot->subxcnt > 0)
|
||||
size += snapshot->subxcnt * sizeof(TransactionId);
|
||||
|
||||
newsnap = (Snapshot) palloc(size);
|
||||
memcpy(newsnap, snapshot, sizeof(SnapshotData));
|
||||
|
||||
/* setup XID array */
|
||||
if (snapshot->xcnt > 0)
|
||||
{
|
||||
newsnap->xip = (TransactionId *) (newsnap + 1);
|
||||
memcpy(newsnap->xip, snapshot->xip,
|
||||
snapshot->xcnt * sizeof(TransactionId));
|
||||
}
|
||||
else
|
||||
newsnap->xip = NULL;
|
||||
|
||||
/* setup subXID array */
|
||||
if (snapshot->subxcnt > 0)
|
||||
{
|
||||
newsnap->subxip = (TransactionId *) ((char *) newsnap + subxipoff);
|
||||
memcpy(newsnap->subxip, snapshot->subxip,
|
||||
snapshot->subxcnt * sizeof(TransactionId));
|
||||
}
|
||||
else
|
||||
newsnap->subxip = NULL;
|
||||
|
||||
return newsnap;
|
||||
}
|
||||
|
||||
/*
|
||||
* FreeSnapshot
|
||||
* Free a snapshot previously copied with CopySnapshot.
|
||||
*
|
||||
* This is currently identical to pfree, but is provided for cleanliness.
|
||||
*
|
||||
* Do *not* apply this to the results of GetTransactionSnapshot or
|
||||
* GetLatestSnapshot, since those are just static structs.
|
||||
*/
|
||||
void
|
||||
FreeSnapshot(Snapshot snapshot)
|
||||
{
|
||||
pfree(snapshot);
|
||||
}
|
||||
|
||||
/*
|
||||
* FreeXactSnapshot
|
||||
* Free snapshot(s) at end of transaction.
|
||||
*/
|
||||
void
|
||||
FreeXactSnapshot(void)
|
||||
{
|
||||
/*
|
||||
* We do not free the xip arrays for the static snapshot structs; they
|
||||
* will be reused soon. So this is now just a state change to prevent
|
||||
* outside callers from accessing the snapshots.
|
||||
*/
|
||||
SerializableSnapshot = NULL;
|
||||
LatestSnapshot = NULL;
|
||||
ActiveSnapshot = NULL; /* just for cleanliness */
|
||||
}
|
@ -31,7 +31,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.109 2008/01/01 19:45:55 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/time/tqual.c,v 1.110 2008/03/26 16:20:47 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,33 +53,6 @@ SnapshotData SnapshotSelfData = {HeapTupleSatisfiesSelf};
|
||||
SnapshotData SnapshotAnyData = {HeapTupleSatisfiesAny};
|
||||
SnapshotData SnapshotToastData = {HeapTupleSatisfiesToast};
|
||||
|
||||
/*
|
||||
* These SnapshotData structs are static to simplify memory allocation
|
||||
* (see the hack in GetSnapshotData to avoid repeated malloc/free).
|
||||
*/
|
||||
static SnapshotData SerializableSnapshotData = {HeapTupleSatisfiesMVCC};
|
||||
static SnapshotData LatestSnapshotData = {HeapTupleSatisfiesMVCC};
|
||||
|
||||
/* Externally visible pointers to valid snapshots: */
|
||||
Snapshot SerializableSnapshot = NULL;
|
||||
Snapshot LatestSnapshot = NULL;
|
||||
|
||||
/*
|
||||
* This pointer is not maintained by this module, but it's convenient
|
||||
* to declare it here anyway. Callers typically assign a copy of
|
||||
* GetTransactionSnapshot's result to ActiveSnapshot.
|
||||
*/
|
||||
Snapshot ActiveSnapshot = NULL;
|
||||
|
||||
/*
|
||||
* These are updated by GetSnapshotData. We initialize them this way
|
||||
* for the convenience of TransactionIdIsInProgress: even in bootstrap
|
||||
* mode, we don't want it to say that BootstrapTransactionId is in progress.
|
||||
*/
|
||||
TransactionId TransactionXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentGlobalXmin = FirstNormalTransactionId;
|
||||
|
||||
/* local functions */
|
||||
static bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot);
|
||||
|
||||
@ -1235,130 +1208,6 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GetTransactionSnapshot
|
||||
* Get the appropriate snapshot for a new query in a transaction.
|
||||
*
|
||||
* The SerializableSnapshot is the first one taken in a transaction.
|
||||
* In serializable mode we just use that one throughout the transaction.
|
||||
* In read-committed mode, we take a new snapshot each time we are called.
|
||||
*
|
||||
* Note that the return value points at static storage that will be modified
|
||||
* by future calls and by CommandCounterIncrement(). Callers should copy
|
||||
* the result with CopySnapshot() if it is to be used very long.
|
||||
*/
|
||||
Snapshot
|
||||
GetTransactionSnapshot(void)
|
||||
{
|
||||
/* First call in transaction? */
|
||||
if (SerializableSnapshot == NULL)
|
||||
{
|
||||
SerializableSnapshot = GetSnapshotData(&SerializableSnapshotData, true);
|
||||
return SerializableSnapshot;
|
||||
}
|
||||
|
||||
if (IsXactIsoLevelSerializable)
|
||||
return SerializableSnapshot;
|
||||
|
||||
LatestSnapshot = GetSnapshotData(&LatestSnapshotData, false);
|
||||
|
||||
return LatestSnapshot;
|
||||
}
|
||||
|
||||
/*
|
||||
* GetLatestSnapshot
|
||||
* Get a snapshot that is up-to-date as of the current instant,
|
||||
* even if we are executing in SERIALIZABLE mode.
|
||||
*/
|
||||
Snapshot
|
||||
GetLatestSnapshot(void)
|
||||
{
|
||||
/* Should not be first call in transaction */
|
||||
if (SerializableSnapshot == NULL)
|
||||
elog(ERROR, "no snapshot has been set");
|
||||
|
||||
LatestSnapshot = GetSnapshotData(&LatestSnapshotData, false);
|
||||
|
||||
return LatestSnapshot;
|
||||
}
|
||||
|
||||
/*
|
||||
* CopySnapshot
|
||||
* Copy the given snapshot.
|
||||
*
|
||||
* The copy is palloc'd in the current memory context.
|
||||
*/
|
||||
Snapshot
|
||||
CopySnapshot(Snapshot snapshot)
|
||||
{
|
||||
Snapshot newsnap;
|
||||
Size subxipoff;
|
||||
Size size;
|
||||
|
||||
/* We allocate any XID arrays needed in the same palloc block. */
|
||||
size = subxipoff = sizeof(SnapshotData) +
|
||||
snapshot->xcnt * sizeof(TransactionId);
|
||||
if (snapshot->subxcnt > 0)
|
||||
size += snapshot->subxcnt * sizeof(TransactionId);
|
||||
|
||||
newsnap = (Snapshot) palloc(size);
|
||||
memcpy(newsnap, snapshot, sizeof(SnapshotData));
|
||||
|
||||
/* setup XID array */
|
||||
if (snapshot->xcnt > 0)
|
||||
{
|
||||
newsnap->xip = (TransactionId *) (newsnap + 1);
|
||||
memcpy(newsnap->xip, snapshot->xip,
|
||||
snapshot->xcnt * sizeof(TransactionId));
|
||||
}
|
||||
else
|
||||
newsnap->xip = NULL;
|
||||
|
||||
/* setup subXID array */
|
||||
if (snapshot->subxcnt > 0)
|
||||
{
|
||||
newsnap->subxip = (TransactionId *) ((char *) newsnap + subxipoff);
|
||||
memcpy(newsnap->subxip, snapshot->subxip,
|
||||
snapshot->subxcnt * sizeof(TransactionId));
|
||||
}
|
||||
else
|
||||
newsnap->subxip = NULL;
|
||||
|
||||
return newsnap;
|
||||
}
|
||||
|
||||
/*
|
||||
* FreeSnapshot
|
||||
* Free a snapshot previously copied with CopySnapshot.
|
||||
*
|
||||
* This is currently identical to pfree, but is provided for cleanliness.
|
||||
*
|
||||
* Do *not* apply this to the results of GetTransactionSnapshot or
|
||||
* GetLatestSnapshot, since those are just static structs.
|
||||
*/
|
||||
void
|
||||
FreeSnapshot(Snapshot snapshot)
|
||||
{
|
||||
pfree(snapshot);
|
||||
}
|
||||
|
||||
/*
|
||||
* FreeXactSnapshot
|
||||
* Free snapshot(s) at end of transaction.
|
||||
*/
|
||||
void
|
||||
FreeXactSnapshot(void)
|
||||
{
|
||||
/*
|
||||
* We do not free the xip arrays for the static snapshot structs; they
|
||||
* will be reused soon. So this is now just a state change to prevent
|
||||
* outside callers from accessing the snapshots.
|
||||
*/
|
||||
SerializableSnapshot = NULL;
|
||||
LatestSnapshot = NULL;
|
||||
ActiveSnapshot = NULL; /* just for cleanliness */
|
||||
}
|
||||
|
||||
/*
|
||||
* XidInMVCCSnapshot
|
||||
* Is the given XID still-in-progress according to the snapshot?
|
||||
|
@ -7,16 +7,17 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.60 2008/01/14 01:39:09 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.61 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RELSCAN_H
|
||||
#define RELSCAN_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "access/skey.h"
|
||||
#include "storage/bufpage.h"
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
typedef struct HeapScanDescData
|
||||
|
@ -8,14 +8,14 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/storage/large_object.h,v 1.39 2008/01/01 19:45:59 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/storage/large_object.h,v 1.40 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef LARGE_OBJECT_H
|
||||
#define LARGE_OBJECT_H
|
||||
|
||||
#include "utils/tqual.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
/*----------
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.20 2008/01/09 21:52:36 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.21 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -15,6 +15,7 @@
|
||||
#define PROCARRAY_H
|
||||
|
||||
#include "storage/lock.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
extern Size ProcArrayShmemSize(void);
|
||||
@ -25,6 +26,8 @@ extern void ProcArrayRemove(PGPROC *proc, TransactionId latestXid);
|
||||
extern void ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid);
|
||||
extern void ProcArrayClearTransaction(PGPROC *proc);
|
||||
|
||||
extern Snapshot GetSnapshotData(Snapshot snapshot, bool serializable);
|
||||
|
||||
extern bool TransactionIdIsInProgress(TransactionId xid);
|
||||
extern bool TransactionIdIsActive(TransactionId xid);
|
||||
extern TransactionId GetOldestXmin(bool allDbs, bool ignoreVacuum);
|
||||
|
33
src/include/utils/snapmgmt.h
Normal file
33
src/include/utils/snapmgmt.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* snapmgmt.h
|
||||
* POSTGRES snapshot management definitions
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/snapmgmt.h,v 1.1 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SNAPMGMT_H
|
||||
#define SNAPMGMT_H
|
||||
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
extern PGDLLIMPORT Snapshot SerializableSnapshot;
|
||||
extern PGDLLIMPORT Snapshot LatestSnapshot;
|
||||
extern PGDLLIMPORT Snapshot ActiveSnapshot;
|
||||
|
||||
extern TransactionId TransactionXmin;
|
||||
extern TransactionId RecentXmin;
|
||||
extern TransactionId RecentGlobalXmin;
|
||||
|
||||
extern Snapshot GetTransactionSnapshot(void);
|
||||
extern Snapshot GetLatestSnapshot(void);
|
||||
extern Snapshot CopySnapshot(Snapshot snapshot);
|
||||
extern void FreeSnapshot(Snapshot snapshot);
|
||||
extern void FreeXactSnapshot(void);
|
||||
|
||||
#endif /* SNAPMGMT_H */
|
62
src/include/utils/snapshot.h
Normal file
62
src/include/utils/snapshot.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* snapshot.h
|
||||
* POSTGRES snapshot definition
|
||||
*
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/snapshot.h,v 1.1 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SNAPSHOT_H
|
||||
#define SNAPSHOT_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "storage/buf.h"
|
||||
|
||||
|
||||
typedef struct SnapshotData *Snapshot;
|
||||
|
||||
#define InvalidSnapshot ((Snapshot) NULL)
|
||||
|
||||
/*
|
||||
* We use SnapshotData structures to represent both "regular" (MVCC)
|
||||
* snapshots and "special" snapshots that have non-MVCC semantics.
|
||||
* The specific semantics of a snapshot are encoded by the "satisfies"
|
||||
* function.
|
||||
*/
|
||||
typedef bool (*SnapshotSatisfiesFunc) (HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
|
||||
typedef struct SnapshotData
|
||||
{
|
||||
SnapshotSatisfiesFunc satisfies; /* tuple test function */
|
||||
|
||||
/*
|
||||
* The remaining fields are used only for MVCC snapshots, and are normally
|
||||
* just zeroes in special snapshots. (But xmin and xmax are used
|
||||
* specially by HeapTupleSatisfiesDirty.)
|
||||
*
|
||||
* An MVCC snapshot can never see the effects of XIDs >= xmax. It can see
|
||||
* the effects of all older XIDs except those listed in the snapshot. xmin
|
||||
* is stored as an optimization to avoid needing to search the XID arrays
|
||||
* for most tuples.
|
||||
*/
|
||||
TransactionId xmin; /* all XID < xmin are visible to me */
|
||||
TransactionId xmax; /* all XID >= xmax are invisible to me */
|
||||
uint32 xcnt; /* # of xact ids in xip[] */
|
||||
TransactionId *xip; /* array of xact IDs in progress */
|
||||
/* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
|
||||
int32 subxcnt; /* # of xact ids in subxip[], -1 if overflow */
|
||||
TransactionId *subxip; /* array of subxact IDs in progress */
|
||||
|
||||
/*
|
||||
* note: all ids in subxip[] are >= xmin, but we don't bother filtering
|
||||
* out any that are >= xmax
|
||||
*/
|
||||
CommandId curcid; /* in my xact, CID < curcid are visible */
|
||||
} SnapshotData;
|
||||
|
||||
#endif /* SNAPSHOT_H */
|
@ -8,59 +8,16 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.71 2008/01/01 19:45:59 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/tqual.h,v 1.72 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef TQUAL_H
|
||||
#define TQUAL_H
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "storage/buf.h"
|
||||
#include "utils/snapshot.h"
|
||||
|
||||
|
||||
/*
|
||||
* We use SnapshotData structures to represent both "regular" (MVCC)
|
||||
* snapshots and "special" snapshots that have non-MVCC semantics.
|
||||
* The specific semantics of a snapshot are encoded by the "satisfies"
|
||||
* function.
|
||||
*/
|
||||
typedef struct SnapshotData *Snapshot;
|
||||
|
||||
typedef bool (*SnapshotSatisfiesFunc) (HeapTupleHeader tuple,
|
||||
Snapshot snapshot, Buffer buffer);
|
||||
|
||||
typedef struct SnapshotData
|
||||
{
|
||||
SnapshotSatisfiesFunc satisfies; /* tuple test function */
|
||||
|
||||
/*
|
||||
* The remaining fields are used only for MVCC snapshots, and are normally
|
||||
* just zeroes in special snapshots. (But xmin and xmax are used
|
||||
* specially by HeapTupleSatisfiesDirty.)
|
||||
*
|
||||
* An MVCC snapshot can never see the effects of XIDs >= xmax. It can see
|
||||
* the effects of all older XIDs except those listed in the snapshot. xmin
|
||||
* is stored as an optimization to avoid needing to search the XID arrays
|
||||
* for most tuples.
|
||||
*/
|
||||
TransactionId xmin; /* all XID < xmin are visible to me */
|
||||
TransactionId xmax; /* all XID >= xmax are invisible to me */
|
||||
uint32 xcnt; /* # of xact ids in xip[] */
|
||||
TransactionId *xip; /* array of xact IDs in progress */
|
||||
/* note: all ids in xip[] satisfy xmin <= xip[i] < xmax */
|
||||
int32 subxcnt; /* # of xact ids in subxip[], -1 if overflow */
|
||||
TransactionId *subxip; /* array of subxact IDs in progress */
|
||||
|
||||
/*
|
||||
* note: all ids in subxip[] are >= xmin, but we don't bother filtering
|
||||
* out any that are >= xmax
|
||||
*/
|
||||
CommandId curcid; /* in my xact, CID < curcid are visible */
|
||||
} SnapshotData;
|
||||
|
||||
#define InvalidSnapshot ((Snapshot) NULL)
|
||||
|
||||
/* Static variables representing various special snapshot semantics */
|
||||
extern PGDLLIMPORT SnapshotData SnapshotNowData;
|
||||
extern PGDLLIMPORT SnapshotData SnapshotSelfData;
|
||||
@ -84,15 +41,6 @@ extern PGDLLIMPORT SnapshotData SnapshotToastData;
|
||||
#define IsMVCCSnapshot(snapshot) \
|
||||
((snapshot)->satisfies == HeapTupleSatisfiesMVCC)
|
||||
|
||||
|
||||
extern PGDLLIMPORT Snapshot SerializableSnapshot;
|
||||
extern PGDLLIMPORT Snapshot LatestSnapshot;
|
||||
extern PGDLLIMPORT Snapshot ActiveSnapshot;
|
||||
|
||||
extern TransactionId TransactionXmin;
|
||||
extern TransactionId RecentXmin;
|
||||
extern TransactionId RecentGlobalXmin;
|
||||
|
||||
/*
|
||||
* HeapTupleSatisfiesVisibility
|
||||
* True iff heap tuple satisfies a time qual.
|
||||
@ -149,13 +97,4 @@ extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTupleHeader tuple,
|
||||
extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
|
||||
uint16 infomask, TransactionId xid);
|
||||
|
||||
extern Snapshot GetTransactionSnapshot(void);
|
||||
extern Snapshot GetLatestSnapshot(void);
|
||||
extern Snapshot CopySnapshot(Snapshot snapshot);
|
||||
extern void FreeSnapshot(Snapshot snapshot);
|
||||
extern void FreeXactSnapshot(void);
|
||||
|
||||
/* in procarray.c; declared here to avoid including tqual.h in procarray.h: */
|
||||
extern Snapshot GetSnapshotData(Snapshot snapshot, bool serializable);
|
||||
|
||||
#endif /* TQUAL_H */
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.204 2008/03/25 22:42:45 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.205 2008/03/26 16:20:48 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -32,6 +32,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/snapmgmt.h"
|
||||
#include "utils/typcache.h"
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user