Thread: SnapshotNow == (Snapshot) NULL, seems bad

SnapshotNow == (Snapshot) NULL, seems bad

From
Tom Lane
Date:
With the current definitions of the "special" snapshot values:

#define SnapshotNow                  ((Snapshot) 0x0)
#define SnapshotSelf                 ((Snapshot) 0x1)
#define SnapshotAny                  ((Snapshot) 0x2)
#define SnapshotToast                ((Snapshot) 0x3)

it is not possible to distinguish SnapshotNow from (Snapshot) NULL,
and in particular there is no unique representation defined for an
"invalid" snapshot.  This has not caused problems to date, but it
seems inevitable that it will rise up and bite us someday.  Does
anyone object to revising these values to be 0x1-0x4 respectively,
and adding "InvalidSnapshot" #defined to 0?

This change would force a backend-wide recompile, and possibly force
recompiling some external C functions, but not have any wider effect
than that AFAICS.

I have an ulterior motive here, which is that in connection with
the discussions about changing SetQuerySnapshot behavior, I am looking
at some internal API changes for which it would be convenient to have
an InvalidSnapshot value ...
        regards, tom lane