From e56a601e067894002c8bbc19cef5c4ef584ba8ad Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 16 Sep 2025 08:59:12 +0200 Subject: [PATCH] Move pg_int64 back to postgres_ext.h Fix for commit 3c86223c998. That commit moved the typedef of pg_int64 from postgres_ext.h to libpq-fe.h, because the only remaining place where it might be used is libpq users, and since the type is obsolete, the intent was to limit its scope. The problem is that if someone builds an extension against an older (pre-PG18) server version and a new (PG18) libpq, they might get two typedefs, depending on include file order. This is not allowed under C99, so they might get warnings or errors, depending on the compiler and options. The underlying types might also be different (e.g., long int vs. long long int), which would also lead to errors. This scenario is plausible when using the standard Debian packaging, which provides only the newest libpq but per-major-version server packages. The fix is to undo that part of commit 3c86223c998. That way, the typedef is in the same header file across versions. At least, this is the safest fix doable before PostgreSQL 18 releases. Reviewed-by: Thomas Munro Discussion: https://www.postgresql.org/message-id/25144219-5142-4589-89f8-4e76948b32db%40eisentraut.org --- src/include/postgres_ext.h | 5 +++++ src/interfaces/libpq/libpq-fe.h | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h index bf45c50dcf3..6a8f25a9907 100644 --- a/src/include/postgres_ext.h +++ b/src/include/postgres_ext.h @@ -24,6 +24,8 @@ #ifndef POSTGRES_EXT_H #define POSTGRES_EXT_H +#include + /* * Object ID is a fundamental type in Postgres. */ @@ -42,6 +44,9 @@ typedef unsigned int Oid; /* the above needs */ +/* deprecated name for int64_t, formerly used in client API declarations */ +typedef int64_t pg_int64; + /* * Identifiers of error message fields. Kept here to keep common * between frontend and backend, and also to export them to libpq diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index af8004f952a..0852584edae 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -234,9 +234,6 @@ typedef struct pgNotify struct pgNotify *next; /* list link */ } PGnotify; -/* deprecated name for int64_t */ -typedef int64_t pg_int64; - /* pg_usec_time_t is like time_t, but with microsecond resolution */ typedef int64_t pg_usec_time_t; -- 2.39.5