mirror of
https://github.com/postgres/postgres.git
synced 2025-09-06 13:46:51 +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:
@@ -22,7 +22,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.167 2009/03/05 17:30:29 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/prep/prepunion.c,v 1.168 2009/03/31 22:12:48 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1258,21 +1258,23 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti)
|
||||
Index childRTindex;
|
||||
AppendRelInfo *appinfo;
|
||||
|
||||
/* Open rel, acquire the appropriate lock type */
|
||||
if (childOID != parentOID)
|
||||
newrelation = heap_open(childOID, lockmode);
|
||||
else
|
||||
newrelation = oldrelation;
|
||||
|
||||
/*
|
||||
* It is possible that the parent table has children that are temp
|
||||
* tables of other backends. We cannot safely access such tables
|
||||
* (because of buffering issues), and the best thing to do seems to be
|
||||
* to silently ignore them.
|
||||
*/
|
||||
if (childOID != parentOID &&
|
||||
isOtherTempNamespace(get_rel_namespace(childOID)))
|
||||
if (childOID != parentOID && RELATION_IS_OTHER_TEMP(newrelation))
|
||||
{
|
||||
heap_close(newrelation, lockmode);
|
||||
continue;
|
||||
|
||||
/* Open rel, acquire the appropriate lock type */
|
||||
if (childOID != parentOID)
|
||||
newrelation = heap_open(childOID, lockmode);
|
||||
else
|
||||
newrelation = oldrelation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build an RTE for the child, and attach to query's rangetable list.
|
||||
|
Reference in New Issue
Block a user