diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/analyze.c | 16 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 10 | ||||
-rw-r--r-- | src/backend/commands/vacuum.c | 16 |
3 files changed, 39 insertions, 3 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 5c20b05447e..4c06a28621a 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.46 2002/09/04 20:31:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.47 2002/09/23 20:43:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -21,6 +21,7 @@ #include "catalog/catalog.h" #include "catalog/catname.h" #include "catalog/indexing.h" +#include "catalog/namespace.h" #include "catalog/pg_operator.h" #include "catalog/pg_statistic.h" #include "catalog/pg_type.h" @@ -216,6 +217,19 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } /* + * Silently ignore tables that are temp tables of other backends --- + * trying to analyze these is rather pointless, since their + * contents are probably not up-to-date on disk. (We don't throw a + * warning here; it would just lead to chatter during a database-wide + * ANALYZE.) + */ + if (isOtherTempNamespace(RelationGetNamespace(onerel))) + { + relation_close(onerel, AccessShareLock); + return; + } + + /* * We can ANALYZE any table except pg_statistic. See update_attstats */ if (IsSystemNamespace(RelationGetNamespace(onerel)) && diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7b2bab71c34..0934a274c7a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.43 2002/09/22 19:42:50 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.44 2002/09/23 20:43:40 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -367,6 +367,7 @@ TruncateRelation(const RangeVar *relation) RelationGetRelationName(rel)); } + /* Permissions checks */ if (!allowSystemTableMods && IsSystemRelation(rel)) elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table", RelationGetRelationName(rel)); @@ -375,6 +376,13 @@ TruncateRelation(const RangeVar *relation) aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(rel)); /* + * Don't allow truncate on temp tables of other backends ... their + * local buffer manager is not going to cope. + */ + if (isOtherTempNamespace(RelationGetNamespace(rel))) + elog(ERROR, "TRUNCATE cannot be used on temp tables of other processes"); + + /* * Don't allow truncate on tables which are referenced by foreign keys */ fkeyRel = heap_openr(ConstraintRelationName, AccessShareLock); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 42172ac07b4..04c13be4e07 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.239 2002/09/23 00:42:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.240 2002/09/23 20:43:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -776,6 +776,20 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) } /* + * Silently ignore tables that are temp tables of other backends --- + * trying to vacuum these will lead to great unhappiness, since their + * contents are probably not up-to-date on disk. (We don't throw a + * warning here; it would just lead to chatter during a database-wide + * VACUUM.) + */ + if (isOtherTempNamespace(RelationGetNamespace(onerel))) + { + relation_close(onerel, lmode); + CommitTransactionCommand(true); + return; + } + + /* * Get a session-level lock too. This will protect our access to the * relation across multiple transactions, so that we can vacuum the * relation's TOAST table (if any) secure in the knowledge that no one |