Re: Problem with server/utils/snapmgr.h

Lists: pgsql-hackers
From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Problem with server/utils/snapmgr.h
Date: 2008-04-21 20:40:02
Message-ID: 607ierndr1.fsf_-_@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

There's a new #include file that it turns out we need for Slony-I to
reference, namely include/server/utils/snapmgr.h

I tried adding an autoconf rule to Slony-I to check for its existence
(goal then is to do a suitable #define so that we can #ifdef the
#include, so that we #include this only with versions of PostgreSQL
that have the file).

If I use:
AC_CHECK_HEADER(utils/snapmgr.h, HAVE_SNAPMGR=1)

this turns out to fail. Apparently autoconf wants to compile the
#include file to validate that it's an OK #include file.

GCC barfs on it, thus:

cbbrowne(at)dba2:~/Slony-I/CMD/slony1-HEAD> gcc -I/opt/OXRS/dbs/pgsql84-beta/include/server /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/block.h:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'BlockNumber'
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/block.h:55: error: expected specifier-qualifier-list before 'uint16'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/off.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemid.h:46: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ItemOffset'
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemid.h:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ItemLength'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/off.h:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'OffsetNumber'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:40: error: expected specifier-qualifier-list before 'OffsetNumber'
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:143: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ItemPointerEquals'
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:144: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'ItemPointerCompare'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/storage/relfilenode.h:44: error: expected specifier-qualifier-list before 'Oid'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:106: error: expected specifier-qualifier-list before 'TransactionId'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:118: error: expected specifier-qualifier-list before 'int32'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:142: error: expected specifier-qualifier-list before 'uint16'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:442: error: expected specifier-qualifier-list before 'uint32'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:498: error: expected specifier-qualifier-list before 'uint32'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:623: error: expected specifier-qualifier-list before 'uint16'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:671: error: expected specifier-qualifier-list before 'BlockNumber'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:684: error: expected specifier-qualifier-list before 'BlockNumber'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:694: error: expected specifier-qualifier-list before 'TransactionId'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:714: error: expected specifier-qualifier-list before 'BlockNumber'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:722: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'HeapTupleHeaderGetCmin'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:723: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'HeapTupleHeaderGetCmax'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:725: error: expected declaration specifiers or '...' before 'CommandId'
/opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:726: error: expected declaration specifiers or '...' before 'bool'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:30: error: expected declaration specifiers or '...' before '*' token
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:31: error: 'bool' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:35: error: expected specifier-qualifier-list before 'SnapshotSatisfiesFunc'
In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SnapshotData'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SnapshotData'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SnapshotData'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SnapshotData'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:69: error: 'HeapTupleSatisfiesMVCC' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:71: error: 'HeapTupleSatisfiesNow' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:73: error: 'HeapTupleSatisfiesSelf' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:75: error: 'HeapTupleSatisfiesAny' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:77: error: 'HeapTupleSatisfiesToast' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:79: error: 'HeapTupleSatisfiesDirty' declared as function returning a function
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:83: error: expected declaration specifiers or '...' before 'CommandId'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:85: error: expected declaration specifiers or '...' before 'TransactionId'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:88: error: expected declaration specifiers or '...' before 'uint16'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:88: error: expected declaration specifiers or '...' before 'TransactionId'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Snapshot'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:21: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Snapshot'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Snapshot'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TransactionXmin'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'RecentXmin'
/opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'RecentGlobalXmin'

Is there something in here that needs cleaning?

Note: I pulled CVS HEAD earlier today, so this is the state of the
code just a little while ago.
--
"cbbrowne","@","linuxfinances.info"
http://linuxfinances.info/info/advocacy.html
Humpty Dumpty sat on the wall,
Humpty Dumpty had a great fall!
All the king's horses,
And all the king's men,
Had scrambled eggs for breakfast again!


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-21 22:31:00
Message-ID: 20080421223100.GD16040@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Chris Browne wrote:

> If I use:
> AC_CHECK_HEADER(utils/snapmgr.h, HAVE_SNAPMGR=1)
>
> this turns out to fail. Apparently autoconf wants to compile the
> #include file to validate that it's an OK #include file.
>
> GCC barfs on it, thus:
>
> cbbrowne(at)dba2:~/Slony-I/CMD/slony1-HEAD> gcc -I/opt/OXRS/dbs/pgsql84-beta/include/server /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h
> In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:17,
> from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:

Hmm. It works for me if I forcefully include postgres.h:

gcc -I/pgsql/install/00head/include/server -include postgres.h /pgsql/install/00head/include/server/utils/snapmgr.h

Our header file rule says that a header must include any header it needs
to compile, but never include postgres.h, which must be the first
include in all the .c files.

So I'm not sure the fix for this.

What does Slony-I need snapmgr.h for, anyway? This code is in a state
of a flux right now -- there are pending patches which are likely to
change the horizon a bit. Perhaps it does not make sense for Slony to
adjust to a state that's expected to be short-lived.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-22 00:16:39
Message-ID: 8561.1208823399@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Chris Browne <cbbrowne(at)acm(dot)org> writes:
> I tried adding an autoconf rule to Slony-I to check for its existence
> (goal then is to do a suitable #define so that we can #ifdef the
> #include, so that we #include this only with versions of PostgreSQL
> that have the file).

The customary way of handling Postgres version differences at
compilation time has been something like

#include "catalog/catversion.h"
#if CATALOG_VERSION_NO >= 200804201
... new code ...
#else
... old code ...
#endif

Seems to me that would do just fine and you don't need autoconf help.

I concur with Alvaro's comment that you're probably wasting your time
to do anything touching snapmgr.h right now, but if you must ...

regards, tom lane


From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-22 15:01:38
Message-ID: 60tzhulyr1.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

alvherre(at)commandprompt(dot)com (Alvaro Herrera) writes:

> Chris Browne wrote:
>
>> If I use:
>> AC_CHECK_HEADER(utils/snapmgr.h, HAVE_SNAPMGR=1)
>>
>> this turns out to fail. Apparently autoconf wants to compile the
>> #include file to validate that it's an OK #include file.
>>
>> GCC barfs on it, thus:
>>
>> cbbrowne(at)dba2:~/Slony-I/CMD/slony1-HEAD> gcc -I/opt/OXRS/dbs/pgsql84-beta/include/server /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h
>> In file included from /opt/OXRS/dbs/pgsql84-beta/include/server/storage/itemptr.h:17,
>> from /opt/OXRS/dbs/pgsql84-beta/include/server/access/htup.h:17,
>> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapshot.h:16,
>> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/tqual.h:18,
>> from /opt/OXRS/dbs/pgsql84-beta/include/server/utils/snapmgr.h:16:
>
>
> Hmm. It works for me if I forcefully include postgres.h:
>
> gcc -I/pgsql/install/00head/include/server -include postgres.h /pgsql/install/00head/include/server/utils/snapmgr.h
>
> Our header file rule says that a header must include any header it needs
> to compile, but never include postgres.h, which must be the first
> include in all the .c files.
>
> So I'm not sure the fix for this.
>
> What does Slony-I need snapmgr.h for, anyway? This code is in a state
> of a flux right now -- there are pending patches which are likely to
> change the horizon a bit. Perhaps it does not make sense for Slony to
> adjust to a state that's expected to be short-lived.

Well, one of the Sun guys observed this...
http://www.slony.info/bugzilla/show_bug.cgi?id=46

And I was trying to build against CVS HEAD (for both projects ;-)) and
observed it:

cbbrowne(at)dba2:CMD/slony1-HEAD/src/backend> make
gcc -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I../.. -fpic -I/opt/OXRS/dbs/pgsql84-beta/include/ -I/opt/OXRS/dbs/pgsql84-beta/include/server/ -c -o slony1_funcs.o slony1_funcs.c
slony1_funcs.c: In function '_Slony_I_createEvent':
slony1_funcs.c:142: error: 'SerializableSnapshot' undeclared (first use in this function)
slony1_funcs.c:142: error: (Each undeclared identifier is reported only once
slony1_funcs.c:142: error: for each function it appears in.)

The definition for SerializableSnapshot has moved from
server/utils/tqual.h to server/utils/snapmgr.h

I agree that the code seems in flux; it seems quite likely that there
will be further changes between now and release of 8.4. That being
said, it's useful to observe these problems *early*, and have
workarounds, so that we can validate that Slony-I is generally
compatible with 8.4 throughout its development cycle.

As a workaround, for now, I'll see if Tom's counsel on this works out
well; I expect so.

The point of the exercise wasn't so much to ask "How do I work around
this?" as it was to point out that there's *something* up with the
header file, in that the autoconf AC_CHECK_HEADER function barfs on
it.

*THAT* (the fact that AC_CHECK_HEADER breaks) appears to be a bad
thing, irrespective of any Slony-I issues.
--
let name="cbbrowne" and tld="linuxdatabases.info" in name ^ "@" ^ tld;;
http://linuxdatabases.info/info/x.html
Signs of a Klingon Programmer - 1. "Defensive programming? Never!
Klingon programs are always on the offense. Yes, offensive programming
is what we do best."


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Chris Browne <cbbrowne(at)acm(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-22 15:45:02
Message-ID: 20080422154502.GA6912@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Chris Browne wrote:

> And I was trying to build against CVS HEAD (for both projects ;-)) and
> observed it:
>
> cbbrowne(at)dba2:CMD/slony1-HEAD/src/backend> make
> gcc -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I../.. -fpic -I/opt/OXRS/dbs/pgsql84-beta/include/ -I/opt/OXRS/dbs/pgsql84-beta/include/server/ -c -o slony1_funcs.o slony1_funcs.c
> slony1_funcs.c: In function '_Slony_I_createEvent':
> slony1_funcs.c:142: error: 'SerializableSnapshot' undeclared (first use in this function)
> slony1_funcs.c:142: error: (Each undeclared identifier is reported only once
> slony1_funcs.c:142: error: for each function it appears in.)
>
> The definition for SerializableSnapshot has moved from
> server/utils/tqual.h to server/utils/snapmgr.h

Well, considering that my next patch proposes removing
SerializableSnapshot altogether, I think Slony will need some
rejiggering.

What do you need SerializableSnapshot for? Perhaps this is reason
enough not to remove it (but I doubt it.) Please point me to an online
copy of slony1_funcs.c.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: "Marko Kreen" <markokr(at)gmail(dot)com>
To: "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>
Cc: "Chris Browne" <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-22 20:39:42
Message-ID: e51f66da0804221339o3f15775fkdb5a9a320bfa1af1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 4/22/08, Alvaro Herrera <alvherre(at)commandprompt(dot)com> wrote:
> Chris Browne wrote:
>
> > And I was trying to build against CVS HEAD (for both projects ;-)) and
> > observed it:
> >
> > cbbrowne(at)dba2:CMD/slony1-HEAD/src/backend> make
> > gcc -g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -I../.. -fpic -I/opt/OXRS/dbs/pgsql84-beta/include/ -I/opt/OXRS/dbs/pgsql84-beta/include/server/ -c -o slony1_funcs.o slony1_funcs.c
> > slony1_funcs.c: In function '_Slony_I_createEvent':
> > slony1_funcs.c:142: error: 'SerializableSnapshot' undeclared (first use in this function)
> > slony1_funcs.c:142: error: (Each undeclared identifier is reported only once
> > slony1_funcs.c:142: error: for each function it appears in.)
> >
> > The definition for SerializableSnapshot has moved from
> > server/utils/tqual.h to server/utils/snapmgr.h
>
>
> Well, considering that my next patch proposes removing
> SerializableSnapshot altogether, I think Slony will need some
> rejiggering.
>
> What do you need SerializableSnapshot for? Perhaps this is reason
> enough not to remove it (but I doubt it.) Please point me to an online
> copy of slony1_funcs.c.

You probably simply need to use ActiveSnapshot there.

Same thing came up when txid landed in core - it had inherited
SerializableSnapshot from xxid code.

If you really need exact same sematics, you need to simply
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE. But if the whole
transaction is not SERIALIZABLE already, its unlikely you need it.

--
marko


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: Chris Browne <cbbrowne(at)acm(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem with server/utils/snapmgr.h
Date: 2008-04-22 20:47:17
Message-ID: 20080422204717.GI6912@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Marko Kreen escribió:

> You probably simply need to use ActiveSnapshot there.

Heh, ActiveSnapshot as a symbol is also gone in the new code ;-) I
changed txid.c to use GetActiveSnapshot() instead.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.