|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.2 2007/09/21 21:25:42 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/access/heap/pruneheap.c,v 1.3 2007/10/24 13:05:57 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -146,17 +146,29 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, |
146 | 146 | intnredirected=0; |
147 | 147 | intndead=0; |
148 | 148 | intnunused=0; |
| 149 | +boolpage_was_full= false; |
| 150 | +TransactionIdsave_prune_xid; |
149 | 151 |
|
150 | 152 | START_CRIT_SECTION(); |
151 | 153 |
|
152 | 154 | /* |
153 | | - * Mark the page as clear of prunable tuples. If we find a tuple which |
154 | | - * may soon become prunable, we shall set the hint again. Also clear |
155 | | - * the "page is full" flag, since there's no point in repeating the |
156 | | - * prune/defrag process until something else happens to the page. |
| 155 | + * Save the current pd_prune_xid and mark the page as clear of prunable |
| 156 | + * tuples. If we find a tuple which may soon become prunable, we shall set |
| 157 | + * the hint again. |
157 | 158 | */ |
| 159 | +save_prune_xid= ((PageHeader)page)->pd_prune_xid; |
158 | 160 | PageClearPrunable(page); |
159 | | -PageClearFull(page); |
| 161 | + |
| 162 | +/* |
| 163 | + * Also clear the "page is full" flag if it is set, since there's no point |
| 164 | + * in repeating the prune/defrag process until something else happens to |
| 165 | + * the page. |
| 166 | + */ |
| 167 | +if (PageIsFull(page)) |
| 168 | +{ |
| 169 | +PageClearFull(page); |
| 170 | +page_was_full= true; |
| 171 | +} |
160 | 172 |
|
161 | 173 | /* Scan the page */ |
162 | 174 | maxoff=PageGetMaxOffsetNumber(page); |
@@ -209,10 +221,13 @@ heap_page_prune(Relation relation, Buffer buffer, TransactionId OldestXmin, |
209 | 221 | else |
210 | 222 | { |
211 | 223 | /* |
212 | | - * If we didn't prune anything, we have nonetheless updated the |
213 | | - * pd_prune_xid field; treat this as a non-WAL-logged hint. |
| 224 | + * If we didn't prune anything, but have updated either the |
| 225 | + * pd_prune_xid field or the "page is full" flag, mark the buffer |
| 226 | + * dirty. This is treated as a non-WAL-logged hint. |
214 | 227 | */ |
215 | | -SetBufferCommitInfoNeedsSave(buffer); |
| 228 | +if (((PageHeader)page)->pd_prune_xid!=save_prune_xid|| |
| 229 | +page_was_full) |
| 230 | +SetBufferCommitInfoNeedsSave(buffer); |
216 | 231 | } |
217 | 232 |
|
218 | 233 | END_CRIT_SECTION(); |
|