@@ -1394,9 +1394,6 @@ static StripeMetadata *
13941394UpdateStripeMetadataRow (uint64 storageId , uint64 stripeId , uint64 fileOffset ,
13951395 uint64 dataLength , uint64 rowCount , uint64 chunkCount )
13961396{
1397- SnapshotData dirtySnapshot ;
1398- InitDirtySnapshot (dirtySnapshot );
1399-
14001397 ScanKeyData scanKey [2 ];
14011398 ScanKeyInit (& scanKey [0 ], Anum_columnar_stripe_storageid ,
14021399 BTEqualStrategyNumber , F_INT8EQ , Int64GetDatum (storageId ));
@@ -1405,23 +1402,16 @@ UpdateStripeMetadataRow(uint64 storageId, uint64 stripeId, uint64 fileOffset,
14051402
14061403 Oid columnarStripesOid = ColumnarStripeRelationId ();
14071404
1408- #if PG_VERSION_NUM >= 180000
1409-
1410- /* CatalogTupleUpdate performs a normal heap UPDATE → RowExclusiveLock */
1411- const LOCKMODE openLockMode = RowExclusiveLock ;
1412- #else
1413-
1414- /* In‑place update never changed tuple length → AccessShareLock was enough */
1415- const LOCKMODE openLockMode = AccessShareLock ;
1416- #endif
1417-
1418- Relation columnarStripes = table_open (columnarStripesOid , openLockMode );
1405+ Relation columnarStripes = table_open (columnarStripesOid , AccessShareLock );
14191406 TupleDesc tupleDescriptor = RelationGetDescr (columnarStripes );
14201407
14211408 Oid indexId = ColumnarStripePKeyIndexRelationId ();
14221409 bool indexOk = OidIsValid (indexId );
1423- SysScanDesc scanDescriptor = systable_beginscan (columnarStripes , indexId , indexOk ,
1424- & dirtySnapshot , 2 , scanKey );
1410+
1411+ void * state ;
1412+ HeapTuple tuple ;
1413+ systable_inplace_update_begin (columnarStripes , indexId , indexOk , NULL ,
1414+ 2 , scanKey , & tuple , & state );
14251415
14261416 static bool loggedSlowMetadataAccessWarning = false;
14271417 if (!indexOk && !loggedSlowMetadataAccessWarning )
@@ -1430,15 +1420,19 @@ UpdateStripeMetadataRow(uint64 storageId, uint64 stripeId, uint64 fileOffset,
14301420 loggedSlowMetadataAccessWarning = true;
14311421 }
14321422
1433- HeapTuple oldTuple = systable_getnext (scanDescriptor );
1434- if (!HeapTupleIsValid (oldTuple ))
1423+ if (!HeapTupleIsValid (tuple ))
14351424 {
14361425 ereport (ERROR , (errmsg ("attempted to modify an unexpected stripe, "
14371426 "columnar storage with id=" UINT64_FORMAT
14381427 " does not have stripe with id=" UINT64_FORMAT ,
14391428 storageId , stripeId )));
14401429 }
14411430
1431+ /*
1432+ * systable_inplace_update_finish already doesn't allow changing size of the original
1433+ * tuple, so we don't allow setting any Datum's to NULL values.
1434+ */
1435+
14421436 Datum * newValues = (Datum * ) palloc (tupleDescriptor -> natts * sizeof (Datum ));
14431437 bool * newNulls = (bool * ) palloc0 (tupleDescriptor -> natts * sizeof (bool ));
14441438 bool * update = (bool * ) palloc0 (tupleDescriptor -> natts * sizeof (bool ));
@@ -1453,43 +1447,21 @@ UpdateStripeMetadataRow(uint64 storageId, uint64 stripeId, uint64 fileOffset,
14531447 newValues [Anum_columnar_stripe_row_count - 1 ] = UInt64GetDatum (rowCount );
14541448 newValues [Anum_columnar_stripe_chunk_count - 1 ] = Int32GetDatum (chunkCount );
14551449
1456- HeapTuple modifiedTuple = heap_modify_tuple (oldTuple ,
1457- tupleDescriptor ,
1458- newValues ,
1459- newNulls ,
1460- update );
1450+ tuple = heap_modify_tuple (tuple ,
1451+ tupleDescriptor ,
1452+ newValues ,
1453+ newNulls ,
1454+ update );
14611455
1462- #if PG_VERSION_NUM < PG_VERSION_18
1456+ systable_inplace_update_finish ( state , tuple );
14631457
1464- /*
1465- * heap_inplace_update already doesn't allow changing size of the original
1466- * tuple, so we don't allow setting any Datum's to NULL values.
1467- */
1468- heap_inplace_update (columnarStripes , modifiedTuple );
1469-
1470- /*
1471- * Existing tuple now contains modifications, because we used
1472- * heap_inplace_update().
1473- */
1474- HeapTuple newTuple = oldTuple ;
1475- #else
1476-
1477- /* Regular catalog UPDATE keeps indexes in sync */
1478- CatalogTupleUpdate (columnarStripes , & oldTuple -> t_self , modifiedTuple );
1479- HeapTuple newTuple = modifiedTuple ;
1480- #endif
1458+ StripeMetadata * modifiedStripeMetadata = BuildStripeMetadata (columnarStripes ,
1459+ tuple );
14811460
14821461 CommandCounterIncrement ();
14831462
1484- /*
1485- * Must not pass modifiedTuple, because BuildStripeMetadata expects a real
1486- * heap tuple with MVCC fields.
1487- */
1488- StripeMetadata * modifiedStripeMetadata =
1489- BuildStripeMetadata (columnarStripes , newTuple );
1490-
1491- systable_endscan (scanDescriptor );
1492- table_close (columnarStripes , openLockMode );
1463+ heap_freetuple (tuple );
1464+ table_close (columnarStripes , AccessShareLock );
14931465
14941466 pfree (newValues );
14951467 pfree (newNulls );
0 commit comments