changeset 766:de9603f25df4 pg-next-699

switch to libpq 18.1
author Alain Mazy <am@orthanc.team>
date Fri, 28 Nov 2025 11:24:39 +0100
parents 0d7376c70f56
children 3327126233a6
files Framework/PostgreSQL/PostgreSQLIncludes.h Framework/PostgreSQL/PostgreSQLOids.h Resources/CMake/PostgreSQLConfiguration.cmake
diffstat 3 files changed, 77 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/PostgreSQL/PostgreSQLIncludes.h	Fri Nov 28 09:02:03 2025 +0100
+++ b/Framework/PostgreSQL/PostgreSQLIncludes.h	Fri Nov 28 11:24:39 2025 +0100
@@ -44,12 +44,19 @@
 #  error PG_VERSION_NUM is not defined
 #endif
 
-#if PG_VERSION_NUM >= 110000
-#  include <catalog/pg_type_d.h>
+
+
+#if PG_VERSION_NUM < 180000
+#  if PG_VERSION_NUM >= 110000
+#    include <catalog/pg_type_d.h>
+#  else
+#    include <postgres.h>
+#    undef LOG  // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
+#    include <catalog/pg_type.h>
+#  endif
 #else
-#  include <postgres.h>
-#  undef LOG  // This one comes from <postgres.h>, and conflicts with <Core/Logging.h>
-#  include <catalog/pg_type.h>
+// from libpq 18, we avoid using server headers to simplify the "configure steps"
+#  include "PostgreSQLOids.h"
 #endif
 
 #include <libpq-fe.h>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Framework/PostgreSQL/PostgreSQLOids.h	Fri Nov 28 11:24:39 2025 +0100
@@ -0,0 +1,47 @@
+/**
+ * Orthanc - A Lightweight, RESTful DICOM Store
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2023 Osimis S.A., Belgium
+ * Copyright (C) 2024-2025 Orthanc Team SRL, Belgium
+ * Copyright (C) 2021-2025 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+#if PG_VERSION_NUM < 180000
+#  error This file shall not be included if you are linking against libpq < 18
+#endif
+// Object ID type in PostgreSQL
+typedef unsigned int Oid;
+
+// Core built-in type OIDs.  
+// All these OIDs are guaranteed not to change.
+// By defining them here, we avoid including server only headers
+#define BOOLOID        16
+#define BYTEAOID       17
+#define CHAROID        18
+#define NAMEOID        19
+#define INT8OID        20
+#define INT2OID        21
+#define INT4OID        23
+#define TEXTOID        25
+#define OIDOID         26
+#define VARCHAROID     1043
+#define TIMESTAMPOID   1114
+#define TIMESTAMPTZOID 1184
+#define VOIDOID        2278
\ No newline at end of file
--- a/Resources/CMake/PostgreSQLConfiguration.cmake	Fri Nov 28 09:02:03 2025 +0100
+++ b/Resources/CMake/PostgreSQLConfiguration.cmake	Fri Nov 28 11:24:39 2025 +0100
@@ -48,13 +48,13 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_LIBPQ)
   add_definitions(-DORTHANC_POSTGRESQL_STATIC=1)
 
-  SET(LIBPQ_MAJOR 13)
-  SET(LIBPQ_MINOR 23)
+  SET(LIBPQ_MAJOR 18)
+  SET(LIBPQ_MINOR 1)
   SET(LIBPQ_VERSION ${LIBPQ_MAJOR}.${LIBPQ_MINOR})
 
   SET(LIBPQ_SOURCES_DIR ${CMAKE_BINARY_DIR}/postgresql-${LIBPQ_VERSION})
   DownloadPackage(
-    "86f7b1ace0dc43e993f29a6739a264d8"
+    "523b5e7f7f64d331004fd93d37109aa0"
     "https://orthanc.uclouvain.be/downloads/third-party-downloads/postgresql-${LIBPQ_VERSION}.tar.gz"
     "${LIBPQ_SOURCES_DIR}")
 
@@ -185,6 +185,8 @@
     set(PG_INT64_TYPE "long int")
   endif()
   
+  check_type_size("long long" SIZEOF_LONG_LONG)
+
   if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
     set(ALIGNOF_DOUBLE 8)
     set(ALIGNOF_INT 4)
@@ -311,19 +313,12 @@
   set(USE_OPENSSL 1)
   set(USE_OPENSSL_RANDOM 1)
   
-  PrepareCMakeConfigurationFile(
-    ${LIBPQ_SOURCES_DIR}/src/include/pg_config_ext.h.in
-    ${AUTOGENERATED_DIR}/pg_config_ext.h.in)
-  
+ 
   PrepareCMakeConfigurationFile(
     ${LIBPQ_SOURCES_DIR}/src/include/pg_config.h.in
     ${AUTOGENERATED_DIR}/pg_config.h.in)
   
   configure_file(
-    ${AUTOGENERATED_DIR}/pg_config_ext.h.in
-    ${AUTOGENERATED_DIR}/pg_config_ext.h)
-
-  configure_file(
     ${AUTOGENERATED_DIR}/pg_config.h.in
     ${AUTOGENERATED_DIR}/pg_config.h)
 
@@ -357,41 +352,49 @@
   set(LIBPQ_SOURCES
     # Don't use files from the "src/backend/" folder
     ${LIBPQ_SOURCES_DIR}/src/common/base64.c
+    ${LIBPQ_SOURCES_DIR}/src/common/cryptohash_openssl.c
     ${LIBPQ_SOURCES_DIR}/src/common/encnames.c
+    ${LIBPQ_SOURCES_DIR}/src/common/fe_memutils.c
     ${LIBPQ_SOURCES_DIR}/src/common/ip.c
     ${LIBPQ_SOURCES_DIR}/src/common/link-canary.c
+    ${LIBPQ_SOURCES_DIR}/src/common/jsonapi.c
     ${LIBPQ_SOURCES_DIR}/src/common/md5.c
+    ${LIBPQ_SOURCES_DIR}/src/common/md5_common.c
+    ${LIBPQ_SOURCES_DIR}/src/common/pg_prng.c
+    ${LIBPQ_SOURCES_DIR}/src/common/psprintf.c
     ${LIBPQ_SOURCES_DIR}/src/common/saslprep.c
     ${LIBPQ_SOURCES_DIR}/src/common/scram-common.c
-    ${LIBPQ_SOURCES_DIR}/src/common/sha2_openssl.c
+    ${LIBPQ_SOURCES_DIR}/src/common/hmac_openssl.c
     ${LIBPQ_SOURCES_DIR}/src/common/string.c
+    ${LIBPQ_SOURCES_DIR}/src/common/stringinfo.c
     ${LIBPQ_SOURCES_DIR}/src/common/unicode_norm.c
     ${LIBPQ_SOURCES_DIR}/src/common/wchar.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth-oauth.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth-scram.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-auth.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-cancel.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-connect.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-exec.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-lobj.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-misc.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-print.c
-    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-protocol2.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-protocol3.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure-common.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure-openssl.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-secure.c
+    ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/fe-trace.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/libpq-events.c
     ${LIBPQ_SOURCES_DIR}/src/interfaces/libpq/pqexpbuffer.c
     ${LIBPQ_SOURCES_DIR}/src/port/chklocale.c
     ${LIBPQ_SOURCES_DIR}/src/port/explicit_bzero.c
-    ${LIBPQ_SOURCES_DIR}/src/port/getaddrinfo.c
     ${LIBPQ_SOURCES_DIR}/src/port/inet_net_ntop.c
     ${LIBPQ_SOURCES_DIR}/src/port/noblock.c
     ${LIBPQ_SOURCES_DIR}/src/port/pg_strong_random.c
+    ${LIBPQ_SOURCES_DIR}/src/port/pg_bitutils.c
     ${LIBPQ_SOURCES_DIR}/src/port/pgstrcasecmp.c
     ${LIBPQ_SOURCES_DIR}/src/port/pqsignal.c
     ${LIBPQ_SOURCES_DIR}/src/port/snprintf.c
     ${LIBPQ_SOURCES_DIR}/src/port/strerror.c
-    ${LIBPQ_SOURCES_DIR}/src/port/thread.c
     )
 
   if (NOT HAVE_STRLCPY)