]> granicus.if.org Git - postgresql/commitdiff
Move the extern declaration for ExceptionalCondition into c.h.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 15 Feb 2018 00:43:33 +0000 (19:43 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 15 Feb 2018 00:43:33 +0000 (19:43 -0500)
This is the logical conclusion of our decision to support Assert()
in both frontend and backend code: it should be possible to use that
after including just c.h.  But as things were arranged before, if
you wanted to use Assert() in code that might be compiled for either
environment, you had to include postgres.h for the backend case.
Let's simplify that.

Per buildfarm, some of whose members started throwing warnings after
commit 0c62356cc added an Assert in src/port/snprintf.c.

It's possible that some other src/port files that use the stanza

#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif

could now be simplified to just say '#include "c.h"'.  I have not
tested for that, though, and it'd be unlikely to apply for more
than a small number of them.

src/include/c.h
src/include/postgres.h

index 9b7fe87f32b65274d129f5b9930afaae35e54438..c38ef8aed3e9778573d5adcd8ae2a9ed2c52f9e6 100644 (file)
  *             8)              random stuff
  *             9)              system-specific hacks
  *
- * NOTE: since this file is included by both frontend and backend modules, it's
- * almost certainly wrong to put an "extern" declaration here.  typedefs and
- * macros are the kind of thing that might go here.
+ * NOTE: since this file is included by both frontend and backend modules,
+ * it's usually wrong to put an "extern" declaration here, unless it's
+ * ifdef'd so that it's seen in only one case or the other.
+ * typedefs and macros are the kind of thing that might go here.
  *
  *----------------------------------------------------------------
  */
@@ -747,6 +748,18 @@ typedef NameData *Name;
 
 #endif                                                 /* USE_ASSERT_CHECKING && !FRONTEND */
 
+/*
+ * ExceptionalCondition is compiled into the backend whether or not
+ * USE_ASSERT_CHECKING is defined, so as to support use of extensions
+ * that are built with that #define with a backend that isn't.  Hence,
+ * we should declare it as long as !FRONTEND.
+ */
+#ifndef FRONTEND
+extern void ExceptionalCondition(const char *conditionName,
+                                        const char *errorType,
+                                        const char *fileName, int lineNumber) pg_attribute_noreturn();
+#endif
+
 /*
  * Macros to support compile-time assertion checks.
  *
index 3dc62801aa3d85510c712aa008b595d09d9ae0d5..bbcb50e41fc0edf54cfec59d9d5394d684e6ebc1 100644 (file)
@@ -25,7 +25,6 @@
  *       -------       ------------------------------------------------
  *             1)              variable-length datatypes (TOAST support)
  *             2)              Datum type + support macros
- *             3)              exception handling backend support
  *
  *      NOTES
  *
@@ -766,19 +765,4 @@ extern Datum Float8GetDatum(float8 X);
 #define Float4GetDatumFast(X) PointerGetDatum(&(X))
 #endif
 
-
-/* ----------------------------------------------------------------
- *                             Section 3:      exception handling backend support
- * ----------------------------------------------------------------
- */
-
-/*
- * Backend only infrastructure for the assertion-related macros in c.h.
- *
- * ExceptionalCondition must be present even when assertions are not enabled.
- */
-extern void ExceptionalCondition(const char *conditionName,
-                                        const char *errorType,
-                                        const char *fileName, int lineNumber) pg_attribute_noreturn();
-
 #endif                                                 /* POSTGRES_H */