@@ -253,7 +253,7 @@ ptrackMapInit(void)
253
253
}
254
254
else
255
255
{
256
- strncat (ptrack_map -> magic , PTRACK_MAGIC , 3 );
256
+ memcpy (ptrack_map -> magic , PTRACK_MAGIC , PTRACK_MAGIC_SIZE );
257
257
ptrack_map -> version_num = PTRACK_VERSION_NUM ;
258
258
}
259
259
@@ -639,9 +639,13 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
639
639
{
640
640
size_t hash ;
641
641
XLogRecPtr new_lsn ;
642
- XLogRecPtr old_lsn ;
643
- XLogRecPtr old_init_lsn ;
644
642
PtBlockId bid ;
643
+ /*
644
+ * We use pg_atomic_uint64 here only for alignment purposes, because
645
+ * pg_atomic_uint64 is forcely aligned on 8 bytes during the MSVC build.
646
+ */
647
+ pg_atomic_uint64 old_lsn ;
648
+ pg_atomic_uint64 old_init_lsn ;
645
649
646
650
if (ptrack_map_size != 0 && (ptrack_map != NULL ) &&
647
651
smgr_rnode .backend == InvalidBackendId ) /* do not track temporary
@@ -657,24 +661,24 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
657
661
else
658
662
new_lsn = GetXLogInsertRecPtr ();
659
663
660
- old_lsn = pg_atomic_read_u64 (& ptrack_map -> entries [hash ]);
664
+ old_lsn . value = pg_atomic_read_u64 (& ptrack_map -> entries [hash ]);
661
665
662
666
/* Atomically assign new init LSN value */
663
- old_init_lsn = pg_atomic_read_u64 (& ptrack_map -> init_lsn );
667
+ old_init_lsn . value = pg_atomic_read_u64 (& ptrack_map -> init_lsn );
664
668
665
- if (old_init_lsn == InvalidXLogRecPtr )
669
+ if (old_init_lsn . value == InvalidXLogRecPtr )
666
670
{
667
- elog (DEBUG1 , "ptrack_mark_block: init_lsn " UINT64_FORMAT " <- " UINT64_FORMAT , old_init_lsn , new_lsn );
671
+ elog (DEBUG1 , "ptrack_mark_block: init_lsn " UINT64_FORMAT " <- " UINT64_FORMAT , old_init_lsn . value , new_lsn );
668
672
669
- while (old_init_lsn < new_lsn &&
670
- !pg_atomic_compare_exchange_u64 (& ptrack_map -> init_lsn , & old_init_lsn , new_lsn ));
673
+ while (old_init_lsn . value < new_lsn &&
674
+ !pg_atomic_compare_exchange_u64 (& ptrack_map -> init_lsn , ( uint64 * ) & old_init_lsn . value , new_lsn ));
671
675
}
672
676
673
- elog (DEBUG3 , "ptrack_mark_block: map[%zu]=" UINT64_FORMAT " <- " UINT64_FORMAT , hash , old_lsn , new_lsn );
677
+ elog (DEBUG3 , "ptrack_mark_block: map[%zu]=" UINT64_FORMAT " <- " UINT64_FORMAT , hash , old_lsn . value , new_lsn );
674
678
675
679
/* Atomically assign new LSN value */
676
- while (old_lsn < new_lsn &&
677
- !pg_atomic_compare_exchange_u64 (& ptrack_map -> entries [hash ], & old_lsn , new_lsn ));
680
+ while (old_lsn . value < new_lsn &&
681
+ !pg_atomic_compare_exchange_u64 (& ptrack_map -> entries [hash ], ( uint64 * ) & old_lsn . value , new_lsn ));
678
682
elog (DEBUG3 , "ptrack_mark_block: map[%zu]=" UINT64_FORMAT , hash , pg_atomic_read_u64 (& ptrack_map -> entries [hash ]));
679
683
}
680
684
}
0 commit comments