Re: pgsql: Add the "snapshot too old" feature

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Grittner <kgrittn(at)postgresql(dot)org>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Add the "snapshot too old" feature
Date: 2016-04-10 15:06:42
Message-ID: 17585.1460300802@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Kevin Grittner <kgrittn(at)postgresql(dot)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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-04-10 17:12:35 pgsql: Improve contrib/bloom regression test using code coverage info.
Previous Message Alvaro Herrera 2016-04-10 14:06:03 pgsql: Fix possible NULL dereference in ExecAlterObjectDependsStmt

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2016-04-10 15:19:18 Re: pgbench - allow backslash-continuations in custom scripts
Previous Message Andrew Dunstan 2016-04-10 14:58:28 Re: VS 2015 support in src/tools/msvc