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