Datum should be defined outside postgres.h - Mailing list pgsql-hackers

From Zdenek Kotala
Subject Datum should be defined outside postgres.h
Date
Msg-id 47209F67.5080106@sun.com
Whole thread Raw
Responses Re: Datum should be defined outside postgres.h
Re: Datum should be defined outside postgres.h
List pgsql-hackers
I'm trying to solve one TODO item mentioned in 
src/backend/utils/mmgr/mcxt.c.

----
/* * MemoryContextSwitchTo *              Returns the current context; installs the given context. * * This is inlined
whenusing GCC. * * TODO: investigate supporting inlining for some non-GCC compilers. */
 
----

Everything works fine with Sun Studio instead of zic and ecpg 
compilation. The problem there is that palloc.h defines 
CurrentMemoryContext which is declared in mcxt.c. And palloc.h is 
included by postgres.h.

Unfortunately zic and ecpg break the rule which is mentioned on many 
places and they include postgres.h. Linker is looking for 
CurrentMemoryContext because inlined function requires it. This problem 
disappears when -xO3 is enabled and SS optimizes a code. But it cannot 
be use in general.

I fixed it for zic, but problem with ecpg is that it includes 
nodes/primnodes.h and it requires Datum type definition which is defined 
in postgres.h. :(

By my opinion Datum should be defined in separate file and all headers 
which use this type should include it. (this is problem on many places 
with another types). Another question is why ecpg needs it?

    Any comments how to fix ecpg?
        Zdenek


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: text search and "filenames"
Next
From: Alvaro Herrera
Date:
Subject: text search parser, "uri"