> On Dec 19, 2025, at 19:51, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
>> +/*
>> + * Generic union representing all kind of possible snapshots. Some have
>> + * type-specific structs.
>> + */
>> +typedef union SnapshotData
>> +{
>> + SnapshotType snapshot_type; /* type of snapshot */
>> +
>> + MVCCSnapshotData mvcc;
>> + DirtySnapshotData dirty;
>> + HistoricMVCCSnapshotData historic_mvcc;
>> + NonVacuumableSnapshotData nonvacuumable;
>> } SnapshotData;
>> ```
>> > And my big concern is here. This union definition looks unusual,
>> snapshot_type shares the same space with real snapshot bodies, so
>> that once snapshot is assigned to the union, that type info is lost,
>> there would be no way to decide what exact snapshot is stored in
>> SnapshotData.
>
> Each of the structs, MVCCSnapshotData, DirtySnapshotData, etc., contain 'snapshot_type' as the first field, so it's
alwaysavailable.
Oh, I didn’t notice each of the structs contain “snapshot_type”, in that case, maybe we can just define SnapshotData as
astructure with a single field “snapshot_type”, in the same way as “Node”.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/