From 0b63396fa9cc8fad854b1b4cee11f7ea6a3a2879 Mon Sep 17 00:00:00 2001 From: yaozichen2025 Date: Thu, 9 Jul 2026 17:02:06 +0800 Subject: [PATCH 1/2] Fix build failure with GCC 14+ (C23 bool keyword and -Wint-conversion) GCC 14 and 15 default to -std=gnu23, where 'bool' is a keyword. This causes two compile errors in IvorySQL-specific code: 1. src/interfaces/libpq/libpq-fe.h defines 'typedef unsigned char bool'. The existing guard '#if !(defined(true) && defined(false))' is not sufficient under C23, because true/false may not be defined as macros even though bool is a built-in keyword. Add a check for __STDC_VERSION__ >= 202311L (and __cplusplus) to skip the typedef, mirroring the pattern used in src/include/c.h. 2. contrib/ivorysql_ora/.../ora_xml_functions.c: ivy_xmlisvalid() returns Datum but the !USE_LIBXML fallback did 'return NULL'. With GCC 14's -Wint-conversion promoted to error, this fails. Replace with 'return 0' to match the upstream PostgreSQL xml.c pattern. Fixes #1351. --- contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c | 2 +- src/interfaces/libpq/libpq-fe.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c b/contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c index 3c1549d0f64..23e8ac4f51b 100644 --- a/contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c +++ b/contrib/ivorysql_ora/src/xml_functions/ora_xml_functions.c @@ -2466,6 +2466,6 @@ Datum ivy_xmlisvalid(PG_FUNCTION_ARGS) } #else NO_XML_SUPPORT(); - return NULL; + return 0; #endif } diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 24f60f14acb..9852375e589 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -74,8 +74,12 @@ extern "C" /* * Assume bool has been defined if true and false are defined. * This avoids duplicate-typedef errors if this file is included after c.h. + * + * Starting with C23, bool, true and false are keywords, so we must not + * provide our own typedef. C++ has bool as a keyword as well. */ -#if !(defined(true) && defined(false)) +#if !defined(__cplusplus) && !(defined(true) && defined(false)) && \ + !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) typedef unsigned char bool; #endif From 733f1645d5a0d313b6c2327e860b215fe17c225c Mon Sep 17 00:00:00 2001 From: yaozichen2025 Date: Tue, 14 Jul 2026 12:01:03 +0800 Subject: [PATCH 2/2] Use standard bool type in libpq header Replace the custom bool typedef with , as requested in the review of PR #1385. Assisted-by: OpenAI:gpt-5 --- src/interfaces/libpq/libpq-fe.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 9852375e589..4880302b659 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -20,6 +20,7 @@ extern "C" { #endif +#include #include #include @@ -71,18 +72,6 @@ extern "C" #define PG_COPYRES_EVENTS 0x04 #define PG_COPYRES_NOTICEHOOKS 0x08 -/* - * Assume bool has been defined if true and false are defined. - * This avoids duplicate-typedef errors if this file is included after c.h. - * - * Starting with C23, bool, true and false are keywords, so we must not - * provide our own typedef. C++ has bool as a keyword as well. - */ -#if !defined(__cplusplus) && !(defined(true) && defined(false)) && \ - !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) -typedef unsigned char bool; -#endif - /* Application-visible enum types */ /*