mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
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.
This commit is contained in:
16
src/backend/utils/cache/relcache.c
vendored
16
src/backend/utils/cache/relcache.c
vendored
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user