unlogged_operation_by_vacuum_full_20100202.patch
text/x-patch
Filename: unlogged_operation_by_vacuum_full_20100202.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/access/heap/heapam.c | 0 | 0 |
| src/backend/access/heap/rewriteheap.c | 10 | 0 |
| src/backend/commands/cluster.c | 1 | 0 |
| src/backend/commands/copy.c | 6 | 0 |
| src/backend/commands/tablecmds.c | 6 | 0 |
| src/backend/executor/execMain.c | 6 | 0 |
| src/include/access/rewriteheap.h | 1 | 0 |
*** a/src/backend/access/heap/heapam.c
--- b/src/backend/access/heap/heapam.c
***************
*** 5074,5089 **** 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 */
--- 5074,5083 ----
*** a/src/backend/access/heap/rewriteheap.c
--- b/src/backend/access/heap/rewriteheap.c
***************
*** 246,252 **** begin_heap_rewrite(Relation new_heap, TransactionId oldest_xmin,
* state and any other resources are freed.
*/
void
! end_heap_rewrite(RewriteState state)
{
HASH_SEQ_STATUS seq_status;
UnresolvedTup unresolved;
--- 246,252 ----
* state and any other resources are freed.
*/
void
! end_heap_rewrite(RewriteState state, bool use_wal)
{
HASH_SEQ_STATUS seq_status;
UnresolvedTup unresolved;
***************
*** 278,283 **** end_heap_rewrite(RewriteState state)
--- 278,292 ----
(char *) state->rs_buffer, true);
}
+ /* Write an XLOG UNLOGGED record if WAL-logging was skipped */
+ if (!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.
*** a/src/backend/commands/cluster.c
--- b/src/backend/commands/cluster.c
***************
*** 998,1004 **** copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex,
heap_endscan(heapScan);
/* Write out any remaining tuples, and fsync if needed */
! end_heap_rewrite(rwstate);
pfree(values);
pfree(isnull);
--- 998,1004 ----
heap_endscan(heapScan);
/* Write out any remaining tuples, and fsync if needed */
! end_heap_rewrite(rwstate, use_wal);
pfree(values);
pfree(isnull);
*** a/src/backend/commands/copy.c
--- b/src/backend/commands/copy.c
***************
*** 2225,2231 **** CopyFrom(CopyState cstate)
--- 2225,2237 ----
* indexes since those use WAL anyway)
*/
if (hi_options & HEAP_INSERT_SKIP_WAL)
+ {
+ char reason[NAMEDATALEN + 30];
+ snprintf(reason, sizeof(reason), "COPY FROM on \"%s\"",
+ RelationGetRelationName(cstate->rel));
+ XLogReportUnloggedStatement(reason);
heap_sync(cstate->rel);
+ }
}
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 3297,3303 **** ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
--- 3297,3309 ----
/* If we skipped writing WAL, then we need to sync the heap. */
if (hi_options & HEAP_INSERT_SKIP_WAL)
+ {
+ char reason[NAMEDATALEN + 30];
+ snprintf(reason, sizeof(reason), "table rewrite on \"%s\"",
+ RelationGetRelationName(newrel));
+ XLogReportUnloggedStatement(reason);
heap_sync(newrel);
+ }
heap_close(newrel, NoLock);
}
*** a/src/backend/executor/execMain.c
--- b/src/backend/executor/execMain.c
***************
*** 2240,2246 **** CloseIntoRel(QueryDesc *queryDesc)
--- 2240,2252 ----
/* If we skipped using WAL, must heap_sync before commit */
if (myState->hi_options & HEAP_INSERT_SKIP_WAL)
+ {
+ char reason[NAMEDATALEN + 30];
+ snprintf(reason, sizeof(reason), "SELECT INTO on \"%s\"",
+ RelationGetRelationName(myState->rel));
+ XLogReportUnloggedStatement(reason);
heap_sync(myState->rel);
+ }
/* close rel, but keep lock until commit */
heap_close(myState->rel, NoLock);
*** a/src/include/access/rewriteheap.h
--- b/src/include/access/rewriteheap.h
***************
*** 22,28 **** typedef struct RewriteStateData *RewriteState;
extern RewriteState begin_heap_rewrite(Relation NewHeap,
TransactionId OldestXmin, TransactionId FreezeXid,
bool use_wal);
! extern void end_heap_rewrite(RewriteState state);
extern void rewrite_heap_tuple(RewriteState state, HeapTuple oldTuple,
HeapTuple newTuple);
extern void rewrite_heap_dead_tuple(RewriteState state, HeapTuple oldTuple);
--- 22,28 ----
extern RewriteState begin_heap_rewrite(Relation NewHeap,
TransactionId OldestXmin, TransactionId FreezeXid,
bool use_wal);
! extern void end_heap_rewrite(RewriteState state, bool use_wal);
extern void rewrite_heap_tuple(RewriteState state, HeapTuple oldTuple,
HeapTuple newTuple);
extern void rewrite_heap_dead_tuple(RewriteState state, HeapTuple oldTuple);