From 948d6ec90fd35d6e1a59d0b1af8d6efd8442f0ad Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 31 Mar 2009 22:12:48 +0000 Subject: 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. --- src/backend/commands/cluster.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/cluster.c') diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 6f578440da8..18f316dd517 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.182 2009/02/02 19:31:38 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.183 2009/03/31 22:12:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -117,7 +117,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel) * Reject clustering a remote temp table ... their local buffer * manager is not going to cope. */ - if (isOtherTempNamespace(RelationGetNamespace(rel))) + if (RELATION_IS_OTHER_TEMP(rel)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot cluster temporary tables of other sessions"))); @@ -302,7 +302,7 @@ cluster_rel(RelToCluster *rvtc, bool recheck, bool verbose) * check_index_is_clusterable which is redundant, but we leave it for * extra safety. */ - if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) + if (RELATION_IS_OTHER_TEMP(OldHeap)) { relation_close(OldHeap, AccessExclusiveLock); return; @@ -465,7 +465,7 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck) * Don't allow cluster on temp tables of other backends ... their local * buffer manager is not going to cope. */ - if (isOtherTempNamespace(RelationGetNamespace(OldHeap))) + if (RELATION_IS_OTHER_TEMP(OldHeap)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot cluster temporary tables of other sessions"))); -- cgit v1.2.3