Avoid including explain.h in explain_format.h and explain_dr.h
authorRobert Haas <[email protected]>
Fri, 28 Feb 2025 18:17:29 +0000 (13:17 -0500)
committerRobert Haas <[email protected]>
Fri, 28 Feb 2025 18:17:29 +0000 (13:17 -0500)
As per a suggestion from Tom Lane, we do this by declaring "struct
ExplainState" here and refer to that rather than "ExplainState".

Also per Tom, CreateExplainSerializeDestReceiver was still defined
in explain.h in addition to explain_dr.h. Remove leftover prototype.

Reviewed-by: Tom Lane <[email protected]>
Discussion: http://postgr.es/m/CA+TgmoYtaad3i21V0jqua-fbr+CR0ix6uBvEX8_s6BG96abd=g@mail.gmail.com

src/backend/commands/explain_dr.c
src/backend/tcop/dest.c
src/include/commands/explain.h
src/include/commands/explain_dr.h
src/include/commands/explain_format.h

index a0a37ea70f49e6cd1305e9fd76e22781c49d7432..fb42bee6e723698f135fb824d1dd53c4510152a0 100644 (file)
@@ -13,6 +13,7 @@
  */
 #include "postgres.h"
 
+#include "commands/explain.h"
 #include "commands/explain_dr.h"
 #include "libpq/pqformat.h"
 #include "libpq/protocol.h"
index b44f907228054ae5376ed92395854cfe016323be..b620766c938882afdd84651a431abaeae249cdfb 100644 (file)
@@ -33,7 +33,7 @@
 #include "access/xact.h"
 #include "commands/copy.h"
 #include "commands/createas.h"
-#include "commands/explain.h"
+#include "commands/explain_dr.h"
 #include "commands/matview.h"
 #include "executor/functions.h"
 #include "executor/tqueue.h"
index 8dd87c47eec5c5fa2d0b7411a42e2dcfc27b4e71..64547bd9b9caaec4fc46a44182830933a069b17a 100644 (file)
@@ -120,6 +120,4 @@ extern void ExplainPrintJITSummary(ExplainState *es, QueryDesc *queryDesc);
 extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
 extern void ExplainQueryParameters(ExplainState *es, ParamListInfo params, int maxlen);
 
-extern DestReceiver *CreateExplainSerializeDestReceiver(ExplainState *es);
-
 #endif                         /* EXPLAIN_H */
index 8f86239b41e8629e3a5b60ffe2c20e849da16783..55da63d66bdf6fa35a1acbf6a7cafd44b728cbd8 100644 (file)
 #ifndef EXPLAIN_DR_H
 #define EXPLAIN_DR_H
 
-#include "commands/explain.h"
 #include "executor/instrument.h"
+#include "tcop/dest.h"
+
+struct ExplainState;           /* avoid including explain.h here */
 
 /* Instrumentation data for EXPLAIN's SERIALIZE option */
 typedef struct SerializeMetrics
@@ -24,7 +26,7 @@ typedef struct SerializeMetrics
    BufferUsage bufferUsage;    /* buffers accessed during serialization */
 } SerializeMetrics;
 
-extern DestReceiver *CreateExplainSerializeDestReceiver(ExplainState *es);
+extern DestReceiver *CreateExplainSerializeDestReceiver(struct ExplainState *es);
 extern SerializeMetrics GetSerializationMetrics(DestReceiver *dest);
 
 #endif
index 0460f0fd2af02cc524b24a490a00a68ba3f4547a..05045bf8cb4af3150c77ecdb9e35af84914e8f68 100644 (file)
 #ifndef EXPLAIN_FORMAT_H
 #define EXPLAIN_FORMAT_H
 
-#include "commands/explain.h"
+#include "nodes/pg_list.h"
+
+struct ExplainState;           /* avoid including explain.h here */
 
 extern void ExplainPropertyList(const char *qlabel, List *data,
-                               ExplainState *es);
+                               struct ExplainState *es);
 extern void ExplainPropertyListNested(const char *qlabel, List *data,
-                                     ExplainState *es);
+                                     struct ExplainState *es);
 extern void ExplainPropertyText(const char *qlabel, const char *value,
-                               ExplainState *es);
+                               struct ExplainState *es);
 extern void ExplainPropertyInteger(const char *qlabel, const char *unit,
-                                  int64 value, ExplainState *es);
+                                  int64 value, struct ExplainState *es);
 extern void ExplainPropertyUInteger(const char *qlabel, const char *unit,
-                                   uint64 value, ExplainState *es);
+                                   uint64 value, struct ExplainState *es);
 extern void ExplainPropertyFloat(const char *qlabel, const char *unit,
-                                double value, int ndigits, ExplainState *es);
+                                double value, int ndigits,
+                                struct ExplainState *es);
 extern void ExplainPropertyBool(const char *qlabel, bool value,
-                               ExplainState *es);
+                               struct ExplainState *es);
 
 extern void ExplainOpenGroup(const char *objtype, const char *labelname,
-                            bool labeled, ExplainState *es);
+                            bool labeled, struct ExplainState *es);
 extern void ExplainCloseGroup(const char *objtype, const char *labelname,
-                             bool labeled, ExplainState *es);
+                             bool labeled, struct ExplainState *es);
 
 extern void ExplainOpenSetAsideGroup(const char *objtype, const char *labelname,
-                                    bool labeled, int depth, ExplainState *es);
-extern void ExplainSaveGroup(ExplainState *es, int depth, int *state_save);
-extern void ExplainRestoreGroup(ExplainState *es, int depth, int *state_save);
+                                    bool labeled, int depth,
+                                    struct ExplainState *es);
+extern void ExplainSaveGroup(struct ExplainState *es, int depth,
+                            int *state_save);
+extern void ExplainRestoreGroup(struct ExplainState *es, int depth,
+                               int *state_save);
 
 extern void ExplainDummyGroup(const char *objtype, const char *labelname,
-                             ExplainState *es);
+                             struct ExplainState *es);
 
-extern void ExplainBeginOutput(ExplainState *es);
-extern void ExplainEndOutput(ExplainState *es);
-extern void ExplainSeparatePlans(ExplainState *es);
+extern void ExplainBeginOutput(struct ExplainState *es);
+extern void ExplainEndOutput(struct ExplainState *es);
+extern void ExplainSeparatePlans(struct ExplainState *es);
 
-extern void ExplainIndentText(ExplainState *es);
+extern void ExplainIndentText(struct ExplainState *es);
 
 #endif