diff options
| author | Tom Lane | 2009-03-31 22:12:48 +0000 |
|---|---|---|
| committer | Tom Lane | 2009-03-31 22:12:48 +0000 |
| commit | 948d6ec90fd35d6e1a59d0b1af8d6efd8442f0ad (patch) | |
| tree | c9184787540c4daa3ae880ea8969d77140a40a5b /src/include | |
| parent | 84a059abf75019f56eba51f33f90b018df8c1116 (diff) | |
Modify the relcache to record the temp status of both local and nonlocal
temp relations; this is no more expensive than before, now that we have
pg_class.relistemp. Insert tests into bufmgr.c to prevent attempting
to fetch pages from nonlocal temp relations. This provides a low-level
defense against bugs-of-omission allowing temp pages to be loaded into shared
buffers, as in the contrib/pgstattuple problem reported by Stuart Bishop.
While at it, tweak a bunch of places to use new relcache tests (instead of
expensive probes into pg_namespace) to detect local or nonlocal temp tables.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/utils/rel.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index a3aaf69e2f1..8c849e3ad62 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.112 2009/02/09 20:57:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.113 2009/03/31 22:12:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -126,7 +126,8 @@ typedef struct RelationData BlockNumber rd_targblock; /* current insertion target block, or * InvalidBlockNumber */ int rd_refcnt; /* reference count */ - bool rd_istemp; /* rel uses the local buffer mgr */ + bool rd_istemp; /* rel is a temporary relation */ + bool rd_islocaltemp; /* rel is a temp rel of this session */ bool rd_isnailed; /* rel is nailed in cache */ bool rd_isvalid; /* relcache entry is valid */ char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 = @@ -355,9 +356,18 @@ typedef struct StdRdOptions * Beware of multiple eval of argument */ #define RELATION_IS_LOCAL(relation) \ - ((relation)->rd_istemp || \ + ((relation)->rd_islocaltemp || \ (relation)->rd_createSubid != InvalidSubTransactionId) +/* + * RELATION_IS_OTHER_TEMP + * Test for a temporary relation that belongs to some other session. + * + * Beware of multiple eval of argument + */ +#define RELATION_IS_OTHER_TEMP(relation) \ + ((relation)->rd_istemp && !(relation)->rd_islocaltemp) + /* routines in utils/cache/relcache.c */ extern void RelationIncrementReferenceCount(Relation rel); extern void RelationDecrementReferenceCount(Relation rel); |
