From 7640f9312321ceba2af61f7017da7e64f0f7b667 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 31 May 2019 11:45:33 -0400 Subject: [PATCH] Fix assorted header files that failed to compile standalone. We have a longstanding project convention that all .h files should be includable with no prerequisites other than postgres.h. This is tested/relied-on by cpluspluscheck. However, cpluspluscheck has not historically been applied to most headers outside the src/include tree, with the predictable consequence that some of them don't work. Fix that, usually by adding missing #include dependencies. The change in printf_hack.h might require some explanation: without it, my C++ compiler whines that the function is unused. There's not so many call sites that "inline" is going to cost much, and besides all the callers are in test code that we really don't care about the size of. There's no actual bugs being fixed here, so I see no need to back-patch. Discussion: https://postgr.es/m/b517ec3918d645eb950505eac8dd434e@gaz-is.ru --- src/bin/pg_waldump/rmgrdesc.h | 1 + src/bin/psql/crosstabview.h | 2 ++ src/interfaces/ecpg/ecpglib/ecpglib_extern.h | 1 + src/interfaces/ecpg/test/printf_hack.h | 2 +- src/interfaces/libpq/fe-gssapi-common.h | 5 +++++ src/pl/plperl/plperl_helpers.h | 3 +++ src/pl/plpython/plpy_elog.h | 2 ++ src/pl/plpython/plpy_resultobject.h | 2 ++ src/pl/plpython/plpy_spi.h | 2 ++ src/pl/plpython/plpy_subxactobject.h | 2 ++ src/pl/plpython/plpy_typeio.h | 2 ++ src/pl/plpython/plpy_util.h | 2 ++ src/pl/plpython/plpython.h | 3 ++- 13 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_waldump/rmgrdesc.h b/src/bin/pg_waldump/rmgrdesc.h index d5f6923e5ce..42f8483b482 100644 --- a/src/bin/pg_waldump/rmgrdesc.h +++ b/src/bin/pg_waldump/rmgrdesc.h @@ -8,6 +8,7 @@ #ifndef RMGRDESC_H #define RMGRDESC_H +#include "access/xlogreader.h" #include "lib/stringinfo.h" typedef struct RmgrDescData diff --git a/src/bin/psql/crosstabview.h b/src/bin/psql/crosstabview.h index 535ee986928..bb02032bbd5 100644 --- a/src/bin/psql/crosstabview.h +++ b/src/bin/psql/crosstabview.h @@ -9,6 +9,8 @@ #ifndef CROSSTABVIEW_H #define CROSSTABVIEW_H +#include "libpq-fe.h" + /* * Limit the number of output columns generated in memory by the crosstabview * algorithm. A new output column is added for each distinct value found in the diff --git a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h index f9336a0c23d..6cb7ab1a192 100644 --- a/src/interfaces/ecpg/ecpglib/ecpglib_extern.h +++ b/src/interfaces/ecpg/ecpglib/ecpglib_extern.h @@ -8,6 +8,7 @@ #include "sqlda-native.h" #include "sqlda-compat.h" #include "ecpg_config.h" +#include "ecpgtype.h" #ifndef CHAR_BIT #include diff --git a/src/interfaces/ecpg/test/printf_hack.h b/src/interfaces/ecpg/test/printf_hack.h index ef584c0d548..1c061d5e87e 100644 --- a/src/interfaces/ecpg/test/printf_hack.h +++ b/src/interfaces/ecpg/test/printf_hack.h @@ -2,7 +2,7 @@ * print_double(x) has the same effect as printf("%g", x), but is intended * to produce the same formatting across all platforms. */ -static void +static inline void print_double(double x) { #ifdef WIN32 diff --git a/src/interfaces/libpq/fe-gssapi-common.h b/src/interfaces/libpq/fe-gssapi-common.h index deb010e4066..ebe24f7ca01 100644 --- a/src/interfaces/libpq/fe-gssapi-common.h +++ b/src/interfaces/libpq/fe-gssapi-common.h @@ -16,8 +16,13 @@ #include "libpq-fe.h" #include "libpq-int.h" +#ifdef ENABLE_GSS + void pg_GSS_error(const char *mprefix, PGconn *conn, OM_uint32 maj_stat, OM_uint32 min_stat); bool pg_GSS_have_ccache(gss_cred_id_t *cred_out); int pg_GSS_load_servicename(PGconn *conn); + +#endif + #endif /* FE_GSSAPI_COMMON_H */ diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h index 65b85a27aed..1e318b6dc83 100644 --- a/src/pl/plperl/plperl_helpers.h +++ b/src/pl/plperl/plperl_helpers.h @@ -3,6 +3,9 @@ #include "mb/pg_wchar.h" +#include "plperl.h" + + /* * convert from utf8 to database encoding * diff --git a/src/pl/plpython/plpy_elog.h b/src/pl/plpython/plpy_elog.h index 967df784652..e02ef4ffe9f 100644 --- a/src/pl/plpython/plpy_elog.h +++ b/src/pl/plpython/plpy_elog.h @@ -5,6 +5,8 @@ #ifndef PLPY_ELOG_H #define PLPY_ELOG_H +#include "plpython.h" + /* global exception classes */ extern PyObject *PLy_exc_error; extern PyObject *PLy_exc_fatal; diff --git a/src/pl/plpython/plpy_resultobject.h b/src/pl/plpython/plpy_resultobject.h index bbaca0dd00f..978c4cc176c 100644 --- a/src/pl/plpython/plpy_resultobject.h +++ b/src/pl/plpython/plpy_resultobject.h @@ -7,6 +7,8 @@ #include "access/tupdesc.h" +#include "plpython.h" + typedef struct PLyResultObject { diff --git a/src/pl/plpython/plpy_spi.h b/src/pl/plpython/plpy_spi.h index 5a0eef78dcd..ec7b6893597 100644 --- a/src/pl/plpython/plpy_spi.h +++ b/src/pl/plpython/plpy_spi.h @@ -7,6 +7,8 @@ #include "utils/resowner.h" +#include "plpython.h" + extern PyObject *PLy_spi_prepare(PyObject *self, PyObject *args); extern PyObject *PLy_spi_execute(PyObject *self, PyObject *args); extern PyObject *PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit); diff --git a/src/pl/plpython/plpy_subxactobject.h b/src/pl/plpython/plpy_subxactobject.h index 92a9e635f3a..1ee85c0cdf3 100644 --- a/src/pl/plpython/plpy_subxactobject.h +++ b/src/pl/plpython/plpy_subxactobject.h @@ -8,6 +8,8 @@ #include "nodes/pg_list.h" #include "utils/resowner.h" +#include "plpython.h" + /* a list of nested explicit subtransactions */ extern List *explicit_subtransactions; diff --git a/src/pl/plpython/plpy_typeio.h b/src/pl/plpython/plpy_typeio.h index 64c72fa4785..3412a9817bf 100644 --- a/src/pl/plpython/plpy_typeio.h +++ b/src/pl/plpython/plpy_typeio.h @@ -9,6 +9,8 @@ #include "fmgr.h" #include "utils/typcache.h" +#include "plpython.h" + struct PLyProcedure; /* avoid requiring plpy_procedure.h here */ diff --git a/src/pl/plpython/plpy_util.h b/src/pl/plpython/plpy_util.h index f990bb08908..c9ba7edc0ec 100644 --- a/src/pl/plpython/plpy_util.h +++ b/src/pl/plpython/plpy_util.h @@ -6,6 +6,8 @@ #ifndef PLPY_UTIL_H #define PLPY_UTIL_H +#include "plpython.h" + extern PyObject *PLyUnicode_Bytes(PyObject *unicode); extern char *PLyUnicode_AsString(PyObject *unicode); diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h index 1a9463a1e31..3a1f0d56d7c 100644 --- a/src/pl/plpython/plpython.h +++ b/src/pl/plpython/plpython.h @@ -14,7 +14,8 @@ /* * Include order should be: postgres.h, other postgres headers, plpython.h, - * other plpython headers + * other plpython headers. (In practice, other plpython headers will also + * include this file, so that they can compile standalone.) */ #ifndef POSTGRES_H #error postgres.h must be included before plpython.h -- 2.39.5