I ran `make headerscheck` after these patches and it reported a few
problems:

/pgsql/source/master/src/tools/pginclude/headerscheck /pgsql/source/master 
/pgsql/build/master
In file included from /tmp/headerscheck.xdG40Y/test.c:2:
/pgsql/source/master/src/include/commands/copyapi.h:76:44: error: unknown type 
name ‘CopyFromState’; did you mean ‘CopyToState’?
   76 |         void            (*CopyFromInFunc) (CopyFromState cstate, Oid 
atttypid,
      |                                            ^~~~~~~~~~~~~
      |                                            CopyToState
/pgsql/source/master/src/include/commands/copyapi.h:87:43: error: unknown type 
name ‘CopyFromState’; did you mean ‘CopyToState’?
   87 |         void            (*CopyFromStart) (CopyFromState cstate, 
TupleDesc tupDesc);
      |                                           ^~~~~~~~~~~~~
      |                                           CopyToState
/pgsql/source/master/src/include/commands/copyapi.h:98:44: error: unknown type 
name ‘CopyFromState’; did you mean ‘CopyToState’?
   98 |         bool            (*CopyFromOneRow) (CopyFromState cstate, 
ExprContext *econtext,
      |                                            ^~~~~~~~~~~~~
      |                                            CopyToState
/pgsql/source/master/src/include/commands/copyapi.h:102:41: error: unknown type 
name ‘CopyFromState’; did you mean ‘CopyToState’?
  102 |         void            (*CopyFromEnd) (CopyFromState cstate);
      |                                         ^~~~~~~~~~~~~
      |                                         CopyToState
/pgsql/source/master/src/include/commands/copyapi.h:103:1: warning: no 
semicolon at end of struct or union
  103 | } CopyFromRoutine;
      | ^

I think the fix should be the attached.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"In Europe they call me Niklaus Wirth; in the US they call me Nickel's worth.
 That's because in Europe they call me by name, and in the US by value!"
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 9e2896f32ae..bac31315fcb 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -21,7 +21,6 @@
 #include "access/table.h"
 #include "catalog/pg_authid.h"
 #include "catalog/pg_foreign_table.h"
-#include "commands/copy.h"
 #include "commands/copyfrom_internal.h"
 #include "commands/defrem.h"
 #include "commands/explain.h"
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c
index 5416583e94d..f80bdd5ed4e 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -62,7 +62,6 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-#include "commands/copy.h"
 #include "commands/copyfrom_internal.h"
 #include "commands/progress.h"
 #include "executor/executor.h"
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index 73b9ca44577..345ba48c3f9 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -19,7 +19,6 @@
 #include <sys/stat.h>
 
 #include "access/tableam.h"
-#include "commands/copy.h"
 #include "commands/copyapi.h"
 #include "commands/progress.h"
 #include "executor/execdesc.h"
diff --git a/src/include/commands/copyapi.h b/src/include/commands/copyapi.h
index ff269def9dc..4c3413841ae 100644
--- a/src/include/commands/copyapi.h
+++ b/src/include/commands/copyapi.h
@@ -14,12 +14,10 @@
 #ifndef COPYAPI_H
 #define COPYAPI_H
 
+#include "commands/copy.h"
 #include "executor/tuptable.h"
 #include "nodes/execnodes.h"
 
-/* This is private in commands/copyto.c */
-typedef struct CopyToStateData *CopyToState;
-
 /*
  * API structure for a COPY TO format implementation.   Note this must be
  * allocated in a server-lifetime manner, typically as a static const struct.
diff --git a/src/include/commands/copyfrom_internal.h b/src/include/commands/copyfrom_internal.h
index 55fe24d7284..1ca058c6add 100644
--- a/src/include/commands/copyfrom_internal.h
+++ b/src/include/commands/copyfrom_internal.h
@@ -14,7 +14,6 @@
 #ifndef COPYFROM_INTERNAL_H
 #define COPYFROM_INTERNAL_H
 
-#include "commands/copy.h"
 #include "commands/copyapi.h"
 #include "commands/trigger.h"
 #include "nodes/miscnodes.h"

Reply via email to