aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-02-03 10:01:30 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-02-03 10:01:30 +0000
commit9de778b24b7d4040a385486348904db1bf69f677 (patch)
tree575b906bda0ed9b86a52480cefdff773eadb3a42 /src/backend/access/heap
parent808969d0e7ac2d2fdbd915c6a6ac9ec68b6f63f9 (diff)
downloadpostgresql-9de778b24b7d4040a385486348904db1bf69f677.tar.gz
postgresql-9de778b24b7d4040a385486348904db1bf69f677.zip
Move the responsibility of writing a "unlogged WAL operation" record from
heap_sync() to the callers, because heap_sync() is sometimes called even if the operation itself is WAL-logged. This eliminates the bogus unlogged records from CLUSTER that Simon Riggs reported, patch by Fujii Masao.
Diffstat (limited to 'src/backend/access/heap')
-rw-r--r--src/backend/access/heap/heapam.c8
-rw-r--r--src/backend/access/heap/rewriteheap.c11
2 files changed, 11 insertions, 8 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 45912825a12..0d9ad2af045 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.284 2010/01/29 17:10:05 sriggs Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.285 2010/02/03 10:01:29 heikki Exp $
*
*
* INTERFACE ROUTINES
@@ -5074,16 +5074,10 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
void
heap_sync(Relation rel)
{
- char reason[NAMEDATALEN + 30];
-
/* temp tables never need fsync */
if (rel->rd_istemp)
return;
- snprintf(reason, sizeof(reason), "heap inserts on \"%s\"",
- RelationGetRelationName(rel));
- XLogReportUnloggedStatement(reason);
-
/* main heap */
FlushRelationBuffers(rel);
/* FlushRelationBuffers will have opened rd_smgr */
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index 9f9e3e8007e..65522f46c14 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -96,7 +96,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.19 2010/01/02 16:57:35 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/rewriteheap.c,v 1.20 2010/02/03 10:01:29 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -278,6 +278,15 @@ end_heap_rewrite(RewriteState state)
(char *) state->rs_buffer, true);
}
+ /* Write an XLOG UNLOGGED record if WAL-logging was skipped */
+ if (!state->rs_use_wal && !state->rs_new_rel->rd_istemp)
+ {
+ char reason[NAMEDATALEN + 30];
+ snprintf(reason, sizeof(reason), "heap rewrite on \"%s\"",
+ RelationGetRelationName(state->rs_new_rel));
+ XLogReportUnloggedStatement(reason);
+ }
+
/*
* If the rel isn't temp, must fsync before commit. We use heap_sync to
* ensure that the toast table gets fsync'd too.