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/optimizer/prep/prepunion.c | |
parent | 84a059abf75019f56eba51f33f90b018df8c1116 (diff) | |
download | postgresql-948d6ec90fd35d6e1a59d0b1af8d6efd8442f0ad.tar.gz postgresql-948d6ec90fd35d6e1a59d0b1af8d6efd8442f0ad.zip |
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/optimizer/prep/prepunion.c')
-rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 43aa515ae5e..06f920561a2 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -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. |