Re: pgsql: Add the "snapshot too old" feature - Mailing list pgsql-committers

From Tom Lane
Subject Re: pgsql: Add the "snapshot too old" feature
Date
Msg-id 17585.1460300802@sss.pgh.pa.us
Whole thread Raw
In response to pgsql: Add the "snapshot too old" feature  (Kevin Grittner <kgrittn@postgresql.org>)
List pgsql-committers
Kevin Grittner <kgrittn@postgresql.org> writes:
> Add the "snapshot too old" feature

I am fairly certain that this:

    typedef struct OldSnapshotControlData *OldSnapshotControl;

    static volatile OldSnapshotControl oldSnapshotControl;

does not do what you intended.  That causes the pointer variable
to be marked volatile, not what it points to.  You need to write

    static volatile OldSnapshotControlData *oldSnapshotControl;

to cause oldSnapshotControl to be understood as a pointer to
something volatile.

I think you could lose the OldSnapshotControl typedef altogether;
it's practically unused, it's confusingly similar to the name of
the pointer variable, and if anyplace did use it (eg to declare
a local-variable copy of oldSnapshotControl) it would be wrong
because of the same misplacement of the volatile property as here.

It's possible that you could instead fix this by putting the volatile
marker inside the typedef, but I'm not enough of a C language lawyer
to be sure that that works in the way you need; and since we don't
rely on such a thing anyplace else, I would be hesitant to start here.

            regards, tom lane


pgsql-committers by date:

Previous
From: Alvaro Herrera
Date:
Subject: pgsql: Fix possible NULL dereference in ExecAlterObjectDependsStmt
Next
From: Tom Lane
Date:
Subject: pgsql: Improve contrib/bloom regression test using code coverage info.