minor improvement in snapbuild: use existing interface and remove fake code

ocean_li_996 <ocean_li_996@163.com>

From: ocean_li_996 <ocean_li_996@163.com>
To: pgsql-hackers@lists.postgresql.org
Cc: "mohen.lhy@alibaba-inc.com" <mohen.lhy@alibaba-inc.com>
Date: 2025-11-17T17:18:12Z
Lists: pgsql-hackers

Attachments

Hi hackers,
While reviewing the snapbuild implementation, I noticed several small changes that could improve code clarity, correctness, and reuse. 
I have prepared a patch with these modifications (attached):


1. Removed the Assert in SnapBuildGetOrBuildSnapshot(). When called from logicalmsg_decode(), this Assert may not hold, which looks like a bug.


2. In SnapBuildProcessChange(), now reuse SnapBuildGetOrBuildSnapshot() to obtain the snapshot.


3. Removed handling of SNAPBUILD_START and SNAPBUILD_BUILDING_SNAPSHOT states in SnapBuildCommitTxn(). When entering this function,
builder->state is always SNAPBUILD_FULL_SNAPSHOT or SNAPBUILD_CONSISTENT.




Looking forward to your comments.

Best regards,

Haiyang Li