diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-01 00:52:04 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-01 00:52:04 +0000 |
| commit | 573a71a5da70d6e2503c8f53e3b4f26b3b6d738d (patch) | |
| tree | 070f677b0043631518f83ce84ff201bf8fda700f /src/include/utils | |
| parent | 4c9aa572fa2ee60e8ac557b866eccc7310df0a09 (diff) | |
Nested transactions. There is still much left to do, especially on the
performance front, but with feature freeze upon us I think it's time to
drive a stake in the ground and say that this will be in 7.5.
Alvaro Herrera, with some help from Tom Lane.
Diffstat (limited to 'src/include/utils')
| -rw-r--r-- | src/include/utils/catcache.h | 10 | ||||
| -rw-r--r-- | src/include/utils/guc.h | 6 | ||||
| -rw-r--r-- | src/include/utils/guc_tables.h | 52 | ||||
| -rw-r--r-- | src/include/utils/inval.h | 12 | ||||
| -rw-r--r-- | src/include/utils/memutils.h | 3 | ||||
| -rw-r--r-- | src/include/utils/portal.h | 5 | ||||
| -rw-r--r-- | src/include/utils/rel.h | 5 | ||||
| -rw-r--r-- | src/include/utils/relcache.h | 6 |
8 files changed, 71 insertions, 28 deletions
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 9c8d3053fec..3ce54b99a25 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.48 2003/11/29 22:41:15 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/catcache.h,v 1.49 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -101,6 +101,9 @@ typedef struct catctup * and negative entries is identical. */ int refcount; /* number of active references */ + int *prev_refcount; /* refcounts for upper subtransactions */ + int numpushes; /* number of used refcounts in the array */ + int numalloc; /* allocated size of array */ bool dead; /* dead but not yet removed? */ bool negative; /* negative cache entry? */ uint32 hash_value; /* hash value for this tuple's keys */ @@ -139,6 +142,9 @@ typedef struct catclist */ Dlelem cache_elem; /* list member of per-catcache list */ int refcount; /* number of active references */ + int *prev_refcount; /* refcounts for upper subtransactions */ + int numpushes; /* number of used refcounts in the array */ + int numalloc; /* allocated size of array */ bool dead; /* dead but not yet removed? */ bool ordered; /* members listed in index order? */ short nkeys; /* number of lookup keys specified */ @@ -163,6 +169,8 @@ extern DLLIMPORT MemoryContext CacheMemoryContext; extern void CreateCacheMemoryContext(void); extern void AtEOXact_CatCache(bool isCommit); +extern void AtSubStart_CatCache(void); +extern void AtEOSubXact_CatCache(bool isCommit); extern CatCache *InitCatCache(int id, const char *relname, const char *indname, int reloidattr, diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index b91682af88f..0a510cd6653 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -7,7 +7,7 @@ * Copyright (c) 2000-2003, PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. * - * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.47 2004/05/28 05:13:32 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.48 2004/07/01 00:51:44 tgl Exp $ *-------------------------------------------------------------------- */ #ifndef GUC_H @@ -175,14 +175,14 @@ extern void DefineCustomStringVariable( GucStringAssignHook assign_hook, GucShowHook show_hook); -extern void EmittWarningsOnPlaceholders(const char* className); +extern void EmitWarningsOnPlaceholders(const char* className); extern const char *GetConfigOption(const char *name); extern const char *GetConfigOptionResetString(const char *name); extern void ProcessConfigFile(GucContext context); extern void InitializeGUCOptions(void); extern void ResetAllOptions(void); -extern void AtEOXact_GUC(bool isCommit); +extern void AtEOXact_GUC(bool isCommit, bool isSubXact); extern void BeginReportingGUCOptions(void); extern void ParseLongOption(const char *string, char **name, char **value); extern bool set_config_option(const char *name, const char *value, diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index 62d2d571b29..d522f6d5e94 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -7,12 +7,31 @@ * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.11 2004/05/26 15:07:41 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.12 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ -#ifndef GUC_TABLES -#define GUC_TABLES 1 +#ifndef GUC_TABLES_H +#define GUC_TABLES_H 1 + +/* + * GUC supports these types of variables: + */ +enum config_type +{ + PGC_BOOL, + PGC_INT, + PGC_REAL, + PGC_STRING +}; + +union config_var_value +{ + bool boolval; + int intval; + double realval; + char *stringval; +}; /* * Groupings to help organize all the run-time options for display @@ -56,15 +75,19 @@ enum config_group }; /* - * GUC supports these types of variables: + * Stack entry for saving the state of a variable prior to the current + * transaction */ -enum config_type +typedef struct guc_stack { - PGC_BOOL, - PGC_INT, - PGC_REAL, - PGC_STRING -}; + struct guc_stack *prev; /* previous stack item, if any */ + int nest_level; /* nesting depth of cur transaction */ + int status; /* previous status bits, see below */ + GucSource tentative_source; /* source of the tentative_value */ + GucSource source; /* source of the actual value */ + union config_var_value tentative_val; /* previous tentative val */ + union config_var_value value; /* previous actual value */ +} GucStack; /* * Generic fields applicable to all types of variables @@ -86,9 +109,9 @@ struct config_generic enum config_type vartype; /* type of variable (set only at startup) */ int status; /* status bits, see below */ GucSource reset_source; /* source of the reset_value */ - GucSource session_source; /* source of the session_value */ GucSource tentative_source; /* source of the tentative_value */ GucSource source; /* source of the current actual value */ + GucStack *stack; /* stacked outside-of-transaction states */ }; /* bit values in flags field */ @@ -104,6 +127,7 @@ struct config_generic /* bit values in status field */ #define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */ #define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */ +#define GUC_HAVE_STACK 0x0004 /* we have stacked prior value(s) */ /* GUC records for specific variable types */ @@ -118,7 +142,6 @@ struct config_bool GucBoolAssignHook assign_hook; GucShowHook show_hook; /* variable fields, initialized at runtime: */ - bool session_val; bool tentative_val; }; @@ -134,7 +157,6 @@ struct config_int GucIntAssignHook assign_hook; GucShowHook show_hook; /* variable fields, initialized at runtime: */ - int session_val; int tentative_val; }; @@ -150,7 +172,6 @@ struct config_real GucRealAssignHook assign_hook; GucShowHook show_hook; /* variable fields, initialized at runtime: */ - double session_val; double tentative_val; }; @@ -165,7 +186,6 @@ struct config_string GucShowHook show_hook; /* variable fields, initialized at runtime: */ char *reset_val; - char *session_val; char *tentative_val; }; @@ -180,4 +200,4 @@ extern struct config_generic **get_guc_variables(void); extern void build_guc_variables(void); -#endif +#endif /* GUC_TABLES_H */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index a2bad9cd06c..add5ca83c71 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.31 2004/05/06 16:10:57 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/inval.h,v 1.32 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -22,9 +22,15 @@ typedef void (*CacheCallbackFunction) (Datum arg, Oid relid); extern void AcceptInvalidationMessages(void); -extern void AtEOXactInvalidationMessages(bool isCommit); +extern void AtStart_Inval(void); -extern void CommandEndInvalidationMessages(bool isCommit); +extern void AtSubStart_Inval(void); + +extern void AtEOXact_Inval(bool isCommit); + +extern void AtSubEOXact_Inval(bool isCommit); + +extern void CommandEndInvalidationMessages(void); extern void CacheInvalidateHeapTuple(Relation relation, HeapTuple tuple); diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index 7865859c062..d2d7d4a9093 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -10,7 +10,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/memutils.h,v 1.55 2004/06/05 19:48:09 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/memutils.h,v 1.56 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -73,6 +73,7 @@ extern DLLIMPORT MemoryContext PostmasterContext; extern DLLIMPORT MemoryContext CacheMemoryContext; extern DLLIMPORT MemoryContext MessageContext; extern DLLIMPORT MemoryContext TopTransactionContext; +extern DLLIMPORT MemoryContext CurTransactionContext; /* These two are transient links to contexts owned by other objects: */ extern DLLIMPORT MemoryContext QueryContext; diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 2819295e837..3437dc448a3 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -39,7 +39,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.48 2003/11/29 22:41:16 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.49 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -167,6 +167,9 @@ extern void EnablePortalManager(void); extern void AtCommit_Portals(void); extern void AtAbort_Portals(void); extern void AtCleanup_Portals(void); +extern void AtSubCommit_Portals(TransactionId parentXid); +extern void AtSubAbort_Portals(void); +extern void AtSubCleanup_Portals(void); extern Portal CreatePortal(const char *name, bool allowDup, bool dupSilent); extern Portal CreateNewPortal(void); extern void PortalDrop(Portal portal, bool isError); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index e5008e56ea5..b7f85eda68e 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.74 2004/05/08 19:09:25 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.75 2004/07/01 00:51:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -110,6 +110,9 @@ typedef struct RelationData BlockNumber rd_targblock; /* current insertion target block, or * InvalidBlockNumber */ int rd_refcnt; /* reference count */ + int *rd_prevrefcnt; /* reference count stack */ + int rd_numalloc; /* stack allocated size */ + int rd_numpushed; /* stack used size */ bool rd_isnew; /* rel was created in current xact */ /* diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index da82f4f6137..47f46190df7 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.40 2004/06/18 06:14:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.41 2004/07/01 00:51:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -65,7 +65,9 @@ extern void RelationCacheInvalidateEntry(Oid relationId, RelFileNode *rnode); extern void RelationCacheInvalidate(void); -extern void AtEOXact_RelationCache(bool commit); +extern void AtEOXact_RelationCache(bool isCommit); +extern void AtSubStart_RelationCache(void); +extern void AtEOSubXact_RelationCache(bool isCommit); /* * Routines to help manage rebuilding of relcache init file |
