@@ -2063,12 +2063,8 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
20632063 TransactionId xid = GetCurrentTransactionId ();
20642064 HeapTuple heaptup ;
20652065 Buffer buffer ;
2066- Page page = NULL ;
20672066 Buffer vmbuffer = InvalidBuffer ;
2068- bool starting_with_empty_page ;
20692067 bool all_visible_cleared = false;
2070- bool all_frozen_set = false;
2071- uint8 vmstatus = 0 ;
20722068
20732069 /* Cheap, simplistic check that the tuple matches the rel's rowtype. */
20742070 Assert (HeapTupleHeaderGetNatts (tup -> t_data ) <=
@@ -2085,36 +2081,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
20852081 /*
20862082 * Find buffer to insert this tuple into. If the page is all visible,
20872083 * this will also pin the requisite visibility map page.
2088- *
2089- * Also pin visibility map page if COPY FREEZE inserts tuples into an
2090- * empty page. See all_frozen_set below.
20912084 */
20922085 buffer = RelationGetBufferForTuple (relation , heaptup -> t_len ,
20932086 InvalidBuffer , options , bistate ,
20942087 & vmbuffer , NULL );
20952088
2096-
2097- /*
2098- * If we're inserting frozen entry into an empty page, set visibility map
2099- * bits and PageAllVisible() hint.
2100- *
2101- * If we're inserting frozen entry into already all_frozen page, preserve
2102- * this state.
2103- */
2104- if (options & HEAP_INSERT_FROZEN )
2105- {
2106- page = BufferGetPage (buffer );
2107-
2108- starting_with_empty_page = PageGetMaxOffsetNumber (page ) == 0 ;
2109-
2110- if (visibilitymap_pin_ok (BufferGetBlockNumber (buffer ), vmbuffer ))
2111- vmstatus = visibilitymap_get_status (relation ,
2112- BufferGetBlockNumber (buffer ), & vmbuffer );
2113-
2114- if ((starting_with_empty_page || vmstatus & VISIBILITYMAP_ALL_FROZEN ))
2115- all_frozen_set = true;
2116- }
2117-
21182089 /*
21192090 * We're about to do the actual insert -- but check for conflict first, to
21202091 * avoid possibly having to roll back work we've just done.
@@ -2138,28 +2109,14 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
21382109 RelationPutHeapTuple (relation , buffer , heaptup ,
21392110 (options & HEAP_INSERT_SPECULATIVE ) != 0 );
21402111
2141- /*
2142- * If the page is all visible, need to clear that, unless we're only going
2143- * to add further frozen rows to it.
2144- *
2145- * If we're only adding already frozen rows to a page that was empty or
2146- * marked as all visible, mark it as all-visible.
2147- */
2148- if (PageIsAllVisible (BufferGetPage (buffer )) && !(options & HEAP_INSERT_FROZEN ))
2112+ if (PageIsAllVisible (BufferGetPage (buffer )))
21492113 {
21502114 all_visible_cleared = true;
21512115 PageClearAllVisible (BufferGetPage (buffer ));
21522116 visibilitymap_clear (relation ,
21532117 ItemPointerGetBlockNumber (& (heaptup -> t_self )),
21542118 vmbuffer , VISIBILITYMAP_VALID_BITS );
21552119 }
2156- else if (all_frozen_set )
2157- {
2158- /* We only ever set all_frozen_set after reading the page. */
2159- Assert (page );
2160-
2161- PageSetAllVisible (page );
2162- }
21632120
21642121 /*
21652122 * XXX Should we set PageSetPrunable on this page ?
@@ -2207,8 +2164,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
22072164 xlrec .flags = 0 ;
22082165 if (all_visible_cleared )
22092166 xlrec .flags |= XLH_INSERT_ALL_VISIBLE_CLEARED ;
2210- if (all_frozen_set )
2211- xlrec .flags = XLH_INSERT_ALL_FROZEN_SET ;
22122167 if (options & HEAP_INSERT_SPECULATIVE )
22132168 xlrec .flags |= XLH_INSERT_IS_SPECULATIVE ;
22142169 Assert (ItemPointerGetBlockNumber (& heaptup -> t_self ) == BufferGetBlockNumber (buffer ));
@@ -2257,29 +2212,6 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
22572212
22582213 END_CRIT_SECTION ();
22592214
2260- /*
2261- * If we've frozen everything on the page, update the visibilitymap. We're
2262- * already holding pin on the vmbuffer.
2263- *
2264- * No need to update the visibilitymap if it had all_frozen bit set before
2265- * this insertion.
2266- */
2267- if (all_frozen_set && ((vmstatus & VISIBILITYMAP_ALL_FROZEN ) == 0 ))
2268- {
2269- Assert (PageIsAllVisible (page ));
2270- Assert (visibilitymap_pin_ok (BufferGetBlockNumber (buffer ), vmbuffer ));
2271-
2272- /*
2273- * It's fine to use InvalidTransactionId here - this is only used when
2274- * HEAP_INSERT_FROZEN is specified, which intentionally violates
2275- * visibility rules.
2276- */
2277- visibilitymap_set (relation , BufferGetBlockNumber (buffer ), buffer ,
2278- InvalidXLogRecPtr , vmbuffer ,
2279- InvalidTransactionId ,
2280- VISIBILITYMAP_ALL_VISIBLE | VISIBILITYMAP_ALL_FROZEN );
2281- }
2282-
22832215 UnlockReleaseBuffer (buffer );
22842216 if (vmbuffer != InvalidBuffer )
22852217 ReleaseBuffer (vmbuffer );
@@ -8946,10 +8878,6 @@ heap_xlog_insert(XLogReaderState *record)
89468878 ItemPointerSetBlockNumber (& target_tid , blkno );
89478879 ItemPointerSetOffsetNumber (& target_tid , xlrec -> offnum );
89488880
8949- /* check that the mutually exclusive flags are not both set */
8950- Assert (!((xlrec -> flags & XLH_INSERT_ALL_VISIBLE_CLEARED ) &&
8951- (xlrec -> flags & XLH_INSERT_ALL_FROZEN_SET )));
8952-
89538881 /*
89548882 * The visibility map may need to be fixed even if the heap page is
89558883 * already up-to-date.
0 commit comments