diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/cluster.c | 14 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 19 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 913ba1681c5..56d040590ba 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.193 2010/01/15 09:19:01 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.194 2010/01/20 19:43:40 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -821,6 +821,18 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex, */ use_wal = XLogIsNeeded() && !NewHeap->rd_istemp; + /* + * Write an XLOG UNLOGGED record if WAL-logging was skipped because + * WAL archiving is not enabled. + */ + if (!use_wal && !NewHeap->rd_istemp) + { + char reason[NAMEDATALEN + 20]; + snprintf(reason, sizeof(reason), "CLUSTER on \"%s\"", + RelationGetRelationName(NewHeap)); + XLogReportUnloggedStatement(reason); + } + /* use_wal off requires rd_targblock be initially invalid */ Assert(NewHeap->rd_targblock == InvalidBlockNumber); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 43d8c0c56bf..0c5ccdcb45e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.316 2010/01/17 22:56:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.317 2010/01/20 19:43:40 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -7015,6 +7015,19 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace) heap_close(pg_class, RowExclusiveLock); + /* + * Write an XLOG UNLOGGED record if WAL-logging was skipped because + * WAL archiving is not enabled. + */ + if (!XLogIsNeeded() && !rel->rd_istemp) + { + char reason[NAMEDATALEN + 40]; + snprintf(reason, sizeof(reason), "ALTER TABLE SET TABLESPACE on \"%s\"", + RelationGetRelationName(rel)); + + XLogReportUnloggedStatement(reason); + } + relation_close(rel, NoLock); /* Make sure the reltablespace change is visible */ @@ -7043,6 +7056,10 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst, /* * We need to log the copied data in WAL iff WAL archiving/streaming is * enabled AND it's not a temp rel. + * + * Note: If you change the conditions here, update the conditions in + * ATExecSetTableSpace() for when an XLOG UNLOGGED record is written + * to match. */ use_wal = XLogIsNeeded() && !istemp; |