99 */
1010#include "pg_squeeze.h"
1111
12- #if PG_VERSION_NUM >= 130000
1312#include "access/heaptoast.h"
14- #endif
1513#include "access/multixact.h"
1614#include "access/sysattr.h"
17- #if PG_VERSION_NUM >= 130000
1815#include "access/toast_internals.h"
1916#include "access/xlogutils.h"
20- #endif
2117#if PG_VERSION_NUM >= 150000
2218#include "access/xloginsert.h"
2319#endif
@@ -139,9 +135,6 @@ static bool perform_final_merge(Oid relid_src, Oid *indexes_src, int nindexes,
139135static void swap_relation_files (Oid r1 , Oid r2 );
140136static void swap_toast_names (Oid relid1 , Oid toastrelid1 , Oid relid2 ,
141137 Oid toastrelid2 );
142- #if PG_VERSION_NUM < 130000
143- static Oid get_toast_index (Oid toastrelid );
144- #endif
145138
146139/*
147140 * The maximum time to hold AccessExclusiveLock during the final
@@ -1032,19 +1025,13 @@ setup_decoding(Oid relid, TupleDesc tup_desc, Snapshot *snap_hist)
10321025 ctx = CreateDecodingContext (InvalidXLogRecPtr ,
10331026 NIL ,
10341027 false,
1035- #if PG_VERSION_NUM >= 130000
10361028 XL_ROUTINE (.page_read = read_local_xlog_page ,
10371029 .segment_open = wal_segment_open ,
10381030 .segment_close = wal_segment_close ),
1039- #else
1040- logical_read_local_xlog_page ,
1041- #endif
10421031 NULL , NULL , NULL );
10431032
1044- #if PG_VERSION_NUM >= 130000
10451033 /* decode_concurrent_changes() handles the older versions. */
10461034 XLogBeginRead (ctx -> reader , MyReplicationSlot -> data .restart_lsn );
1047- #endif
10481035
10491036 XLByteToSeg (restart_lsn , squeeze_current_segment , wal_segment_size );
10501037
@@ -2589,8 +2576,7 @@ create_transient_table(CatalogState *cat_state, TupleDesc tup_desc,
25892576 * will eventually be dropped.
25902577 */
25912578#if (PG_VERSION_NUM >= 140000 ) || \
2592- (PG_VERSION_NUM < 140000 && PG_VERSION_NUM > 130004 ) || \
2593- (PG_VERSION_NUM < 130000 && PG_VERSION_NUM > 120008 )
2579+ (PG_VERSION_NUM < 140000 && PG_VERSION_NUM > 130004 )
25942580 NewHeapCreateToastTable (result , reloptions , AccessExclusiveLock ,
25952581 InvalidOid );
25962582#else
@@ -3312,13 +3298,10 @@ swap_toast_names(Oid relid1, Oid toastrelid1, Oid relid2, Oid toastrelid2)
33123298 RenameRelationInternal (toastrelid2 , name , true, false);
33133299
33143300 snprintf (name , NAMEDATALEN , "pg_toast_%u_index_" , relid1 );
3315- #if PG_VERSION_NUM < 130000
3316- /* NoLock as RenameRelationInternal() did not release its lock. */
3317- toastidxid = get_toast_index (toastrelid2 );
3318- #else
3301+
33193302 /* TOAST relation is locked, but not its indexes. */
33203303 toastidxid = toast_get_valid_index (toastrelid2 , AccessExclusiveLock );
3321- #endif
3304+
33223305 /*
33233306 * Pass is_index=false so that even the index is locked in
33243307 * AccessExclusiveLock mode. ShareUpdateExclusiveLock mode (allowing
@@ -3334,43 +3317,15 @@ swap_toast_names(Oid relid1, Oid toastrelid1, Oid relid2, Oid toastrelid2)
33343317 /* Now set the desired names on the TOAST stuff of relid1. */
33353318 snprintf (name , NAMEDATALEN , "pg_toast_%u" , relid1 );
33363319 RenameRelationInternal (toastrelid1 , name , true, false);
3337- #if PG_VERSION_NUM < 130000
3338- /* NoLock as RenameRelationInternal() did not release its lock. */
3339- toastidxid = get_toast_index (toastrelid1 );
3340- #else
3320+
33413321 /* TOAST relation is locked, but not its indexes. */
33423322 toastidxid = toast_get_valid_index (toastrelid1 , AccessExclusiveLock );
3343- #endif
3323+
33443324 snprintf (name , NAMEDATALEN , "pg_toast_%u_index" , relid1 );
33453325 RenameRelationInternal (toastidxid , name , true, false);
33463326 CommandCounterIncrement ();
33473327}
33483328
3349- #if PG_VERSION_NUM < 130000
3350- /*
3351- * The function is called after RenameRelationInternal() which does not
3352- * release the lock it acquired.
3353- */
3354- static Oid
3355- get_toast_index (Oid toastrelid )
3356- {
3357- Relation toastrel ;
3358- List * toastidxs ;
3359- Oid result ;
3360-
3361- toastrel = table_open (toastrelid , NoLock );
3362- toastidxs = RelationGetIndexList (toastrel );
3363-
3364- if (toastidxs == NIL || list_length (toastidxs ) != 1 )
3365- elog (ERROR , "Unexpected number of TOAST indexes" );
3366-
3367- result = linitial_oid (toastidxs );
3368- table_close (toastrel , NoLock );
3369-
3370- return result ;
3371- }
3372- #endif
3373-
33743329/*
33753330 * Retrieve the "fillfactor" storage option in a convenient way, so we don't
33763331 * have to parse pg_class(reloptions) value at SQL level.
0 commit comments