diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-31 22:12:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-03-31 22:12:48 +0000 |
commit | 948d6ec90fd35d6e1a59d0b1af8d6efd8442f0ad (patch) | |
tree | c9184787540c4daa3ae880ea8969d77140a40a5b /src/backend/utils/cache/relcache.c | |
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/backend/utils/cache/relcache.c')
-rw-r--r-- | src/backend/utils/cache/relcache.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index c39759ee1c9..ae6fcea7e67 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.285 2009/03/31 17:59:56 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.286 2009/03/31 22:12:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -829,7 +829,11 @@ RelationBuildDesc(Oid targetRelId, Relation oldrelation) relation->rd_isnailed = false; relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; - relation->rd_istemp = isTempOrToastNamespace(relation->rd_rel->relnamespace); + relation->rd_istemp = relation->rd_rel->relistemp; + if (relation->rd_istemp) + relation->rd_islocaltemp = isTempOrToastNamespace(relation->rd_rel->relnamespace); + else + relation->rd_islocaltemp = false; /* * initialize the tuple descriptor (relation->rd_att). @@ -1375,6 +1379,7 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; relation->rd_istemp = false; + relation->rd_islocaltemp = false; /* * initialize relation tuple form @@ -2355,8 +2360,9 @@ RelationBuildLocalRelation(const char *relname, /* must flag that we have rels created in this transaction */ need_eoxact_work = true; - /* is it a temporary relation? */ + /* it is temporary if and only if it is in my temp-table namespace */ rel->rd_istemp = isTempOrToastNamespace(relnamespace); + rel->rd_islocaltemp = rel->rd_istemp; /* * create a new tuple descriptor from the one passed in. We do this @@ -2403,9 +2409,7 @@ RelationBuildLocalRelation(const char *relname, * as the logical ID (OID). */ rel->rd_rel->relisshared = shared_relation; - - /* it is temporary if and only if it is in my temp-table namespace */ - rel->rd_rel->relistemp = isTempOrToastNamespace(relnamespace); + rel->rd_rel->relistemp = rel->rd_istemp; RelationGetRelid(rel) = relid; |