summaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/catcache.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-10-06 18:23:48 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-10-06 18:23:48 +0000
commitd2cc024be10c85eca94688af863b21b54eacd690 (patch)
tree953f49c98bdce9d01e89ee74132359156bb5a6b6 /src/backend/utils/cache/catcache.c
parent4d3760f6745b45f70b1699399f14041e56b71b4a (diff)
Fix SysCacheGetAttr() to handle the case where the specified syscache has not
been initialized yet. This can happen because there are code paths that call SysCacheGetAttr() on a tuple originally fetched from a different syscache (hopefully on the same catalog) than the one specified in the call. It doesn't seem useful or robust to try to prevent that from happening, so just improve the function to cope instead. Per bug#2678 from Jeff Trout. The specific example shown by Jeff is new in 8.1, but to be on the safe side I'm backpatching 8.0 as well. We could patch 7.x similarly but I think that's probably overkill, given the lack of evidence of old bugs of this ilk.
Diffstat (limited to 'src/backend/utils/cache/catcache.c')
-rw-r--r--src/backend/utils/cache/catcache.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 68995f98388..0cd30ed8526 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.118 2004/12/31 22:01:25 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.118.4.1 2006/10/06 18:23:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -972,7 +972,7 @@ CatalogCacheInitializeCache(CatCache *cache)
cache->cc_skey[i].sk_strategy = BTEqualStrategyNumber;
cache->cc_skey[i].sk_subtype = InvalidOid;
- CACHE4_elog(DEBUG2, "CatalogCacheInit %s %d %p",
+ CACHE4_elog(DEBUG2, "CatalogCacheInitializeCache %s %d %p",
cache->cc_relname,
i,
cache);
@@ -987,18 +987,20 @@ CatalogCacheInitializeCache(CatCache *cache)
/*
* InitCatCachePhase2 -- external interface for CatalogCacheInitializeCache
*
- * The only reason to call this routine is to ensure that the relcache
- * has created entries for all the catalogs and indexes referenced by
- * catcaches. Therefore, open the index too. An exception is the indexes
- * on pg_am, which we don't use (cf. IndexScanOK).
+ * One reason to call this routine is to ensure that the relcache has
+ * created entries for all the catalogs and indexes referenced by catcaches.
+ * Therefore, provide an option to open the index as well as fixing the
+ * cache itself. An exception is the indexes on pg_am, which we don't use
+ * (cf. IndexScanOK).
*/
void
-InitCatCachePhase2(CatCache *cache)
+InitCatCachePhase2(CatCache *cache, bool touch_index)
{
if (cache->cc_tupdesc == NULL)
CatalogCacheInitializeCache(cache);
- if (cache->id != AMOID &&
+ if (touch_index &&
+ cache->id != AMOID &&
cache->id != AMNAME)
{
Relation idesc;