Skip to content

Commit 36825f3

Browse files
committed
Can't completely get rid of #ifndef FRONTEND in palloc.h :-(
pg_controldata includes postgres.h not postgres_fe.h, so utils/palloc.h must be able to compile in a "#define FRONTEND" context. It appears that Solaris Studio is smart enough to persuade us to define PG_USE_INLINE, but not smart enough to not make a copy of unreferenced static functions; which leads to an unsatisfied reference to CurrentMemoryContext. So we need an #ifndef FRONTEND around that declaration. Per buildfarm.
1 parent e4c1a49 commit 36825f3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/include/utils/palloc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,14 @@ extern void pfree(void *pointer);
7171
* MemoryContextSwitchTo can't be a macro in standard C compilers.
7272
* But we can make it an inline function if the compiler supports it.
7373
* See STATIC_IF_INLINE in c.h.
74+
*
75+
* Although this header file is nominally backend-only, certain frontend
76+
* programs like pg_controldata include it via postgres.h. For some compilers
77+
* it's necessary to hide the inline definition of MemoryContextSwitchTo in
78+
* this scenario; hence the #ifndef FRONTEND.
7479
*/
7580

81+
#ifndef FRONTEND
7682
#ifndef PG_USE_INLINE
7783
extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
7884
#endif /* !PG_USE_INLINE */
@@ -86,6 +92,7 @@ MemoryContextSwitchTo(MemoryContext context)
8692
return old;
8793
}
8894
#endif /* PG_USE_INLINE || MCXT_INCLUDE_DEFINITIONS */
95+
#endif /* FRONTEND */
8996

9097
/*
9198
* These are like standard strdup() except the copied string is

0 commit comments

Comments
 (0)