@@ -124,7 +124,7 @@ initscan(HeapScanDesc scan, ScanKey key, bool is_rescan)
124124 *
125125 * During a rescan, don't make a new strategy object if we don't have to.
126126 */
127- if (!scan -> rs_rd -> rd_istemp &&
127+ if (!RelationUsesLocalBuffers ( scan -> rs_rd ) &&
128128 scan -> rs_nblocks > NBuffers / 4 )
129129 {
130130 allow_strat = scan -> rs_allow_strat ;
@@ -905,7 +905,7 @@ relation_open(Oid relationId, LOCKMODE lockmode)
905905 elog (ERROR , "could not open relation with OID %u" , relationId );
906906
907907 /* Make note that we've accessed a temporary relation */
908- if (r -> rd_istemp )
908+ if (RelationUsesLocalBuffers ( r ) )
909909 MyXactAccessedTempRel = true;
910910
911911 pgstat_initstats (r );
@@ -951,7 +951,7 @@ try_relation_open(Oid relationId, LOCKMODE lockmode)
951951 elog (ERROR , "could not open relation with OID %u" , relationId );
952952
953953 /* Make note that we've accessed a temporary relation */
954- if (r -> rd_istemp )
954+ if (RelationUsesLocalBuffers ( r ) )
955955 MyXactAccessedTempRel = true;
956956
957957 pgstat_initstats (r );
@@ -1917,7 +1917,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid,
19171917 MarkBufferDirty (buffer );
19181918
19191919 /* XLOG stuff */
1920- if (!(options & HEAP_INSERT_SKIP_WAL ) && ! relation -> rd_istemp )
1920+ if (!(options & HEAP_INSERT_SKIP_WAL ) && RelationNeedsWAL ( relation ) )
19211921 {
19221922 xl_heap_insert xlrec ;
19231923 xl_heap_header xlhdr ;
@@ -2227,7 +2227,7 @@ heap_delete(Relation relation, ItemPointer tid,
22272227 MarkBufferDirty (buffer );
22282228
22292229 /* XLOG stuff */
2230- if (! relation -> rd_istemp )
2230+ if (RelationNeedsWAL ( relation ) )
22312231 {
22322232 xl_heap_delete xlrec ;
22332233 XLogRecPtr recptr ;
@@ -2780,7 +2780,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
27802780 MarkBufferDirty (buffer );
27812781
27822782 /* XLOG stuff */
2783- if (! relation -> rd_istemp )
2783+ if (RelationNeedsWAL ( relation ) )
27842784 {
27852785 XLogRecPtr recptr = log_heap_update (relation , buffer , oldtup .t_self ,
27862786 newbuf , heaptup ,
@@ -3403,7 +3403,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple, Buffer *buffer,
34033403 * (Also, in a PITR log-shipping or 2PC environment, we have to have XLOG
34043404 * entries for everything anyway.)
34053405 */
3406- if (! relation -> rd_istemp )
3406+ if (RelationNeedsWAL ( relation ) )
34073407 {
34083408 xl_heap_lock xlrec ;
34093409 XLogRecPtr recptr ;
@@ -3505,7 +3505,7 @@ heap_inplace_update(Relation relation, HeapTuple tuple)
35053505 MarkBufferDirty (buffer );
35063506
35073507 /* XLOG stuff */
3508- if (! relation -> rd_istemp )
3508+ if (RelationNeedsWAL ( relation ) )
35093509 {
35103510 xl_heap_inplace xlrec ;
35113511 XLogRecPtr recptr ;
@@ -3867,8 +3867,8 @@ log_heap_clean(Relation reln, Buffer buffer,
38673867 XLogRecPtr recptr ;
38683868 XLogRecData rdata [4 ];
38693869
3870- /* Caller should not call me on a temp relation */
3871- Assert (! reln -> rd_istemp );
3870+ /* Caller should not call me on a non-WAL-logged relation */
3871+ Assert (RelationNeedsWAL ( reln ) );
38723872
38733873 xlrec .node = reln -> rd_node ;
38743874 xlrec .block = BufferGetBlockNumber (buffer );
@@ -3950,8 +3950,8 @@ log_heap_freeze(Relation reln, Buffer buffer,
39503950 XLogRecPtr recptr ;
39513951 XLogRecData rdata [2 ];
39523952
3953- /* Caller should not call me on a temp relation */
3954- Assert (! reln -> rd_istemp );
3953+ /* Caller should not call me on a non-WAL-logged relation */
3954+ Assert (RelationNeedsWAL ( reln ) );
39553955 /* nor when there are no tuples to freeze */
39563956 Assert (offcnt > 0 );
39573957
@@ -3996,8 +3996,8 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
39963996 XLogRecData rdata [4 ];
39973997 Page page = BufferGetPage (newbuf );
39983998
3999- /* Caller should not call me on a temp relation */
4000- Assert (! reln -> rd_istemp );
3999+ /* Caller should not call me on a non-WAL-logged relation */
4000+ Assert (RelationNeedsWAL ( reln ) );
40014001
40024002 if (HeapTupleIsHeapOnly (newtup ))
40034003 info = XLOG_HEAP_HOT_UPDATE ;
@@ -4997,7 +4997,7 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
49974997 * heap_sync - sync a heap, for use when no WAL has been written
49984998 *
49994999 * This forces the heap contents (including TOAST heap if any) down to disk.
5000- * If we skipped using WAL, and it's not a temp relation , we must force the
5000+ * If we skipped using WAL, and WAL is otherwise needed , we must force the
50015001 * relation down to disk before it's safe to commit the transaction. This
50025002 * requires writing out any dirty buffers and then doing a forced fsync.
50035003 *
@@ -5010,8 +5010,8 @@ heap2_desc(StringInfo buf, uint8 xl_info, char *rec)
50105010void
50115011heap_sync (Relation rel )
50125012{
5013- /* temp tables never need fsync */
5014- if (rel -> rd_istemp )
5013+ /* non-WAL-logged tables never need fsync */
5014+ if (! RelationNeedsWAL ( rel ) )
50155015 return ;
50165016
50175017 /* main heap */
0 commit comments