From 22053fb3cbc95dcfadfabd76f5f937c1f5aa3e5a Mon Sep 17 00:00:00 2001 From: David Christensen Date: Thu, 4 Jun 2026 20:19:42 +0000 Subject: [PATCH] pg19: build cleanly against PostgreSQL 19beta1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PG19 dropped a number of transitive header includes and reshaped a few APIs. Add explicit includes wherever the build broke and shim the renamed APIs in pg_extension_base/pg_compat.h. Header reorg (PG19 dropped these from common transitive paths): - utils/tuplestore.h (was pulled in via nodes/execnodes.h) - access/htup_details.h (was pulled in via executor/tuptable.h) - utils/hsearch.h (HASHCTL/hash_create/hash_search) - catalog/pg_type_d.h (TEXTOID, INTERVALOID, etc.) - utils/wait_event.h (WAIT_EVENT_CLIENT_READ) - utils/timestamp.h (Datum<-->TimestampTz, IntervalPGetDatum) - storage/lock.h (LockAcquire, LockAcquireResult) - storage/fd.h (AllocateFile, FreeFile) API changes wrapped behind #if PG_VERSION_NUM >= 190000: - LWLockNewTrancheId() now requires a name argument; the separate LWLockRegisterTranche() helper is gone. - ShmemInitHash() collapsed init_size/max_size into a single nelems. - SIG_IGN -> PG_SIG_IGN (pqsigfunc-typed sentinel). - pg_plan_query() gained a trailing ExplainState* (pass NULL). - CopyFormatOptions.binary / .csv_mode were replaced by an enum .format field — wrapped behind CopyOptsIsBinary/CopyOptsIsCsvMode macros in pg_compat.h so callers keep the older names. - CopyHeaderChoice enum was removed; header_line is a plain int with COPY_HEADER_TRUE/FALSE/MATCH constants. Reintroduced the typedef locally so our exported API signature stays stable. - numeric_int4_opt_error() renamed to numeric_int4_safe() and switched from a bool* error flag to an ErrorSaveContext* (soft-error API). Wrapped via an inline shim that preserves the older bool* signature. pgduck_server is a frontend program; the unused #include "nodes/nodes.h" in numutils.h started failing because PG19 changed nodes.h to use Datum in extern declarations. Removed the vestigial include. Builds clean against PG19 locally for: pg_extension_base, pg_map, pg_lake_engine, pg_lake_copy, pg_lake. pg_lake_iceberg/pg_lake_table were not exercised locally because the avro library was not built; they're expected to need similar include fixes already applied here. Signed-off-by: David Christensen --- .../include/pg_extension_base/pg_compat.h | 49 +++++++++++++++++++ .../include/pg_extension_base/spi_helpers.h | 2 + pg_extension_base/src/attached_worker.c | 2 + pg_extension_base/src/base_worker_launcher.c | 34 ++++++++++++- pg_extension_base/src/library_preloader.c | 1 + .../src/pg_extension_updater.c | 1 + pg_lake_benchmark/src/tpcds.c | 1 + pg_lake_benchmark/src/tpch.c | 1 + pg_lake_copy/src/test/types.c | 2 + .../include/pg_lake/csv/csv_options.h | 9 ++++ .../include/pg_lake/pgduck/serialize.h | 1 + pg_lake_engine/src/cleanup/deletion_queue.c | 2 + .../src/cleanup/in_progress_files.c | 3 ++ pg_lake_engine/src/csv/csv_writer.c | 22 +++++---- .../src/data_file/data_file_stats.c | 1 + pg_lake_engine/src/json/json_reader.c | 1 + pg_lake_engine/src/parquet/field.c | 1 + pg_lake_engine/src/parsetree/const.c | 1 + pg_lake_engine/src/parsetree/expression.c | 1 + pg_lake_engine/src/pgduck/client.c | 1 + pg_lake_engine/src/pgduck/map.c | 2 + pg_lake_engine/src/pgduck/parse_struct.c | 1 + pg_lake_engine/src/pgduck/read_data.c | 1 + pg_lake_engine/src/pgduck/rewrite_query.c | 3 ++ .../src/pgduck/shippable_spatial_functions.c | 1 + pg_lake_engine/src/pgduck/type.c | 1 + pg_lake_engine/src/pgduck/write_data.c | 1 + pg_lake_engine/src/query/execute.c | 6 ++- pg_lake_engine/src/utils/compare_utils.c | 1 + pg_lake_engine/src/utils/operator_utils.c | 1 + pg_lake_engine/src/utils/plan_cache.c | 1 + .../src/iceberg/api/table_metadata.c | 1 + pg_lake_iceberg/src/iceberg/catalog.c | 1 + .../src/iceberg/iceberg_type_binary_serde.c | 4 ++ .../src/iceberg/iceberg_type_json_serde.c | 1 + .../src/iceberg/metadata_operations.c | 1 + .../operations/find_referenced_files.c | 1 + pg_lake_iceberg/src/iceberg/read_manifest.c | 3 ++ .../object_store_catalog.c | 2 + .../src/rest_catalog/rest_catalog.c | 1 + pg_lake_iceberg/src/test/test_http_client.c | 1 + .../src/test/test_iceberg_binary_serde.c | 2 + .../src/test/test_iceberg_field_ids.c | 1 + .../src/test/test_iceberg_manifest.c | 2 + pg_lake_iceberg/src/utils/truncate_utils.c | 1 + .../include/pg_lake/fdw/data_files_catalog.h | 2 + pg_lake_table/src/ddl/alter_table.c | 1 + pg_lake_table/src/ddl/create_table.c | 1 + pg_lake_table/src/describe/describe.c | 1 + .../src/duckdb/transform_query_to_duckdb.c | 1 + pg_lake_table/src/fdw/data_file_pruning.c | 3 ++ pg_lake_table/src/fdw/data_files_catalog.c | 2 + .../src/fdw/data_files_catalog_batch.c | 4 ++ pg_lake_table/src/fdw/deparse.c | 4 ++ pg_lake_table/src/fdw/deparse_ruleutils.c | 1 + pg_lake_table/src/fdw/partition_transform.c | 2 + .../fdw/partitioning/partition_spec_catalog.c | 2 + .../partitioning/partitioned_dest_receiver.c | 1 + pg_lake_table/src/fdw/pg_lake_table.c | 2 + pg_lake_table/src/fdw/position_delete_dest.c | 2 + .../field_id_mapping_catalog.c | 1 + pg_lake_table/src/fdw/update_tracking.c | 6 ++- pg_lake_table/src/fdw/writable_table.c | 3 ++ pg_lake_table/src/planner/insert_select.c | 1 + pg_lake_table/src/planner/query_pushdown.c | 20 ++++++-- .../src/planner/restriction_collector.c | 1 + pg_lake_table/src/recovery/recover.c | 1 + pg_lake_table/src/test/hide_lake_objects.c | 2 + pg_lake_table/src/test/test_partition_tuple.c | 3 ++ .../track_iceberg_metadata_changes.c | 1 + pg_map/src/map.c | 1 + pgduck_server/Makefile | 6 ++- pgduck_server/include/utils/numutils.h | 2 - pgduck_server/src/duckdb/type_conversion.c | 1 + pgduck_server/tests/ctests/Makefile | 6 ++- 75 files changed, 239 insertions(+), 22 deletions(-) diff --git a/pg_extension_base/include/pg_extension_base/pg_compat.h b/pg_extension_base/include/pg_extension_base/pg_compat.h index 75791c554..04f3a17f9 100644 --- a/pg_extension_base/include/pg_extension_base/pg_compat.h +++ b/pg_extension_base/include/pg_extension_base/pg_compat.h @@ -18,6 +18,55 @@ #pragma once #include "postgres.h" +#include "catalog/pg_type_d.h" +#include "commands/copy.h" +#include "nodes/miscnodes.h" +#include "utils/numeric.h" + +#if PG_VERSION_NUM >= 190000 + +/* + * PG19 reshaped CopyFormatOptions: the bool fields ".binary" and ".csv_mode" + * were replaced by a single CopyFormat enum field ".format". Provide + * accessor macros so callers keep the older names. + */ +#define CopyOptsIsBinary(opts) ((opts).format == COPY_FORMAT_BINARY) +#define CopyOptsIsCsvMode(opts) ((opts).format == COPY_FORMAT_CSV) + +/* + * PG19 renamed numeric_int4_opt_error -> numeric_int4_safe and switched the + * out-of-band error signal from a bool* to an ErrorSaveContext* (the standard + * "soft error" API). Wrap with the older name + bool* signature. + */ +static inline int32 +numeric_int4_opt_error(Numeric num, bool *have_error) +{ + ErrorSaveContext escontext = {T_ErrorSaveContext}; + int32 result = numeric_int4_safe(num, (Node *) &escontext); + + *have_error = escontext.error_occurred; + return result; +} + +/* + * Likewise for the binary numeric arithmetic helpers, which were also + * renamed from foo_opt_error(Numeric, Numeric, bool *) to + * foo_safe(Numeric, Numeric, Node *escontext) in PG19. Our callers always + * pass NULL for the error argument, so just forward to the new name. + */ +#define numeric_add_opt_error(num1, num2, _ignored) numeric_add_safe(num1, num2, NULL) +#define numeric_sub_opt_error(num1, num2, _ignored) numeric_sub_safe(num1, num2, NULL) +#define numeric_mul_opt_error(num1, num2, _ignored) numeric_mul_safe(num1, num2, NULL) +#define numeric_div_opt_error(num1, num2, _ignored) numeric_div_safe(num1, num2, NULL) +#define numeric_mod_opt_error(num1, num2, _ignored) numeric_mod_safe(num1, num2, NULL) + +#else + +#define CopyOptsIsBinary(opts) ((opts).binary) +#define CopyOptsIsCsvMode(opts) ((opts).csv_mode) + +#endif + #if PG_VERSION_NUM < 170000 #define foreach_ptr(type, var, lst) foreach_internal(type, *, var, lst, lfirst) diff --git a/pg_extension_base/include/pg_extension_base/spi_helpers.h b/pg_extension_base/include/pg_extension_base/spi_helpers.h index d8a15b875..7359b9b08 100644 --- a/pg_extension_base/include/pg_extension_base/spi_helpers.h +++ b/pg_extension_base/include/pg_extension_base/spi_helpers.h @@ -18,6 +18,7 @@ #ifndef SPI_UTILITIES_H #define SPI_UTILITIES_H +#include "catalog/pg_type_d.h" #include "miscadmin.h" #include "executor/spi.h" @@ -25,6 +26,7 @@ #include "utils/guc.h" #include "utils/jsonb.h" #include "utils/pg_lsn.h" +#include "utils/timestamp.h" /* SPI macros for setting parameters */ #define DATUMIZE_TEXTOID(Value) CStringGetTextDatum(Value) diff --git a/pg_extension_base/src/attached_worker.c b/pg_extension_base/src/attached_worker.c index f580a8e32..f6fa7a9f4 100644 --- a/pg_extension_base/src/attached_worker.c +++ b/pg_extension_base/src/attached_worker.c @@ -29,6 +29,7 @@ #include "miscadmin.h" #include "pgstat.h" +#include "access/htup_details.h" #include "access/xact.h" #include "catalog/pg_authid.h" #include "commands/dbcommands.h" @@ -61,6 +62,7 @@ #include "utils/syscache.h" #include "utils/timeout.h" #include "utils/typcache.h" +#include "utils/tuplestore.h" #define QUEUE_SIZE ((Size) 65536) #define ATTACHED_WORKER_MAGIC 0x52004040 diff --git a/pg_extension_base/src/base_worker_launcher.c b/pg_extension_base/src/base_worker_launcher.c index 393cac5c6..6eee40f2f 100644 --- a/pg_extension_base/src/base_worker_launcher.c +++ b/pg_extension_base/src/base_worker_launcher.c @@ -58,6 +58,9 @@ * should still exist, or whether to clean up their shared memory records. */ #include "postgres.h" +#include "utils/hsearch.h" +#include "access/htup_details.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "miscadmin.h" @@ -94,6 +97,10 @@ #include "utils/memutils.h" #include "utils/snapmgr.h" #include "utils/syscache.h" +#include "utils/tuplestore.h" +#if PG_VERSION_NUM >= 190000 +#include "utils/wait_event.h" +#endif #include "tcop/utility.h" #include "pg_extension_base/base_workers.h" @@ -508,11 +515,20 @@ BaseWorkerSharedMemoryInit(void) if (!alreadyInitialized) { - BaseWorkerControl->trancheId = LWLockNewTrancheId(); BaseWorkerControl->lockTrancheName = "pg_extension_base server starter locks"; +#if PG_VERSION_NUM >= 190000 + /* + * PG19 folded the name into LWLockNewTrancheId and removed + * LWLockRegisterTranche entirely. + */ + BaseWorkerControl->trancheId = + LWLockNewTrancheId(BaseWorkerControl->lockTrancheName); +#else + BaseWorkerControl->trancheId = LWLockNewTrancheId(); LWLockRegisterTranche(BaseWorkerControl->trancheId, BaseWorkerControl->lockTrancheName); +#endif LWLockInitialize(&BaseWorkerControl->lock, BaseWorkerControl->trancheId); @@ -527,7 +543,11 @@ BaseWorkerSharedMemoryInit(void) int hashFlags = (HASH_ELEM | HASH_FUNCTION); DatabaseStarterHash = ShmemInitHash("pg_extension_base database starter hash", +#if PG_VERSION_NUM >= 190000 + 2 * max_worker_processes, +#else max_worker_processes, 2 * max_worker_processes, +#endif &hashInfo, hashFlags); memset(&hashInfo, 0, sizeof(hashInfo)); @@ -537,7 +557,11 @@ BaseWorkerSharedMemoryInit(void) hashFlags = (HASH_ELEM | HASH_FUNCTION); BaseWorkerHash = ShmemInitHash("pg_extension_base base worker hash", +#if PG_VERSION_NUM >= 190000 + 2 * max_worker_processes, +#else max_worker_processes, 2 * max_worker_processes, +#endif &hashInfo, hashFlags); LWLockRelease(AddinShmemInitLock); @@ -650,7 +674,11 @@ PgExtensionServerStarterMain(Datum arg) /* set up signal handlers */ pqsignal(SIGHUP, HandleSighup); pqsignal(SIGTERM, HandleSigterm); +#if PG_VERSION_NUM >= 190000 + pqsignal(SIGINT, PG_SIG_IGN); +#else pqsignal(SIGINT, SIG_IGN); +#endif before_shmem_exit(PgBaseExtensionServerStarterSharedMemoryExit, 0); @@ -1012,7 +1040,11 @@ PgExtensionBaseDatabaseStarterMain(Datum databaseIdDatum) /* Establish signal handlers before unblocking signals. */ pqsignal(SIGHUP, HandleSighup); +#if PG_VERSION_NUM >= 190000 + pqsignal(SIGINT, PG_SIG_IGN); +#else pqsignal(SIGINT, SIG_IGN); +#endif pqsignal(SIGTERM, HandleSigterm); /* Set our exit handler before any calls to proc_exit */ diff --git a/pg_extension_base/src/library_preloader.c b/pg_extension_base/src/library_preloader.c index fec185f62..9ab2c9651 100644 --- a/pg_extension_base/src/library_preloader.c +++ b/pg_extension_base/src/library_preloader.c @@ -36,6 +36,7 @@ #include "utils/builtins.h" #include "utils/conffiles.h" #include "utils/guc.h" +#include "utils/tuplestore.h" /* PreloadLibrary represents a library to preload */ typedef struct PreloadLibrary diff --git a/pg_extension_updater/src/pg_extension_updater.c b/pg_extension_updater/src/pg_extension_updater.c index 758590ea4..6e0eb2b32 100644 --- a/pg_extension_updater/src/pg_extension_updater.c +++ b/pg_extension_updater/src/pg_extension_updater.c @@ -22,6 +22,7 @@ *------------------------------------------------------------------------- */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "miscadmin.h" diff --git a/pg_lake_benchmark/src/tpcds.c b/pg_lake_benchmark/src/tpcds.c index f88ab28d5..8abf2e2d9 100644 --- a/pg_lake_benchmark/src/tpcds.c +++ b/pg_lake_benchmark/src/tpcds.c @@ -19,6 +19,7 @@ #include "fmgr.h" #include "funcapi.h" #include "utils/builtins.h" +#include "utils/tuplestore.h" #include "pg_lake/benchmark.h" #include "pg_lake/copy/copy_format.h" diff --git a/pg_lake_benchmark/src/tpch.c b/pg_lake_benchmark/src/tpch.c index b21ef35b1..338cdaa6c 100644 --- a/pg_lake_benchmark/src/tpch.c +++ b/pg_lake_benchmark/src/tpch.c @@ -19,6 +19,7 @@ #include "fmgr.h" #include "funcapi.h" #include "utils/builtins.h" +#include "utils/tuplestore.h" #include "pg_lake/benchmark.h" #include "pg_lake/copy/copy_format.h" diff --git a/pg_lake_copy/src/test/types.c b/pg_lake_copy/src/test/types.c index 00ee41b6c..51b535404 100644 --- a/pg_lake_copy/src/test/types.c +++ b/pg_lake_copy/src/test/types.c @@ -20,12 +20,14 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "pg_lake/pgduck/type.h" #include "pg_lake/pgduck/parse_struct.h" #include "utils/builtins.h" +#include "utils/tuplestore.h" PG_FUNCTION_INFO_V1(duckdb_type_by_name); diff --git a/pg_lake_engine/include/pg_lake/csv/csv_options.h b/pg_lake_engine/include/pg_lake/csv/csv_options.h index d26afe1bb..dd16f2e48 100644 --- a/pg_lake_engine/include/pg_lake/csv/csv_options.h +++ b/pg_lake_engine/include/pg_lake/csv/csv_options.h @@ -20,6 +20,15 @@ #include "commands/copy.h" #include "nodes/pg_list.h" +#if PG_VERSION_NUM >= 190000 +/* + * PG19 dropped the CopyHeaderChoice enum and stores the header choice as a + * plain int holding COPY_HEADER_FALSE / COPY_HEADER_TRUE / COPY_HEADER_MATCH. + * Reintroduce the typedef here so we keep a stable signature. + */ +typedef int CopyHeaderChoice; +#endif + extern PGDLLEXPORT List *InternalCSVOptions(bool includeHeader); extern PGDLLEXPORT List *NormalizedExternalCSVOptions(List *inputOptions); extern PGDLLEXPORT CopyHeaderChoice GetCopyHeaderChoice(DefElem *def, bool is_from); diff --git a/pg_lake_engine/include/pg_lake/pgduck/serialize.h b/pg_lake_engine/include/pg_lake/pgduck/serialize.h index d76f4b0be..7c7cf7ae8 100644 --- a/pg_lake_engine/include/pg_lake/pgduck/serialize.h +++ b/pg_lake_engine/include/pg_lake/pgduck/serialize.h @@ -18,6 +18,7 @@ #pragma once #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "pg_lake/parquet/field.h" diff --git a/pg_lake_engine/src/cleanup/deletion_queue.c b/pg_lake_engine/src/cleanup/deletion_queue.c index a6d00640d..efbc258cd 100644 --- a/pg_lake_engine/src/cleanup/deletion_queue.c +++ b/pg_lake_engine/src/cleanup/deletion_queue.c @@ -19,6 +19,7 @@ * Functions for cleaning up orphaned files. */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include "miscadmin.h" @@ -30,6 +31,7 @@ #include "pg_lake/util/string_utils.h" #include "datatype/timestamp.h" #include "storage/procarray.h" +#include "utils/tuplestore.h" #define DELETION_QUEUE_TABLE "lake_engine.deletion_queue" diff --git a/pg_lake_engine/src/cleanup/in_progress_files.c b/pg_lake_engine/src/cleanup/in_progress_files.c index 67b55644f..9d858ffce 100644 --- a/pg_lake_engine/src/cleanup/in_progress_files.c +++ b/pg_lake_engine/src/cleanup/in_progress_files.c @@ -24,6 +24,7 @@ * via VACUUM. */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include "miscadmin.h" @@ -42,11 +43,13 @@ #include "pg_lake/util/plan_cache.h" #include "pg_lake/util/string_utils.h" #include "datatype/timestamp.h" +#include "storage/lock.h" #include "storage/procarray.h" #include "utils/fmgroids.h" #include "utils/memutils.h" #include "utils/lsyscache.h" #include "utils/snapmgr.h" +#include "utils/tuplestore.h" #define OPERATION_ID_SEQUENCE "operationid_seq" diff --git a/pg_lake_engine/src/csv/csv_writer.c b/pg_lake_engine/src/csv/csv_writer.c index 3b91870fe..4974f9d26 100644 --- a/pg_lake_engine/src/csv/csv_writer.c +++ b/pg_lake_engine/src/csv/csv_writer.c @@ -42,7 +42,9 @@ #include "mb/pg_wchar.h" #include "nodes/execnodes.h" #include "nodes/makefuncs.h" +#include "pg_extension_base/pg_compat.h" #include "port/pg_bswap.h" +#include "storage/fd.h" #include "utils/builtins.h" #include "utils/lsyscache.h" #include "utils/memutils.h" @@ -198,7 +200,7 @@ CopySendEndOfRow(CopyToState cstate) switch (cstate->copy_dest) { case COPY_FILE: - if (!cstate->opts.binary) + if (!CopyOptsIsBinary(cstate->opts)) { /* Default line termination depends on platform */ #ifndef WIN32 @@ -264,7 +266,7 @@ CopySendInt16(CopyToState cstate, int16 val) static void EndCopy(CopyToState cstate) { - if (cstate->opts.binary) + if (CopyOptsIsBinary(cstate->opts)) { /* Generate trailer for a binary copy */ CopySendInt16(cstate, -1); @@ -461,7 +463,7 @@ StartCopyTo(CopyToState cstate, TupleDesc tupDesc) bool isvarlena; Form_pg_attribute attr = TupleDescAttr(tupDesc, attnum - 1); - if (cstate->opts.binary) + if (CopyOptsIsBinary(cstate->opts)) getTypeBinaryOutputInfo(attr->atttypid, &out_func_oid, &isvarlena); @@ -482,7 +484,7 @@ StartCopyTo(CopyToState cstate, TupleDesc tupDesc) "COPY TO", ALLOCSET_DEFAULT_SIZES); - if (cstate->opts.binary) + if (CopyOptsIsBinary(cstate->opts)) { /* Generate header for a binary copy */ int32 tmp; @@ -523,7 +525,7 @@ StartCopyTo(CopyToState cstate, TupleDesc tupDesc) colname = NameStr(TupleDescAttr(tupDesc, attnum - 1)->attname); - if (cstate->opts.csv_mode) + if (CopyOptsIsCsvMode(cstate->opts)) CopyAttributeOutCSV(cstate, colname, false, list_length(cstate->attnumlist) == 1); else @@ -731,7 +733,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot) MemoryContextReset(cstate->rowcontext); oldcontext = MemoryContextSwitchTo(cstate->rowcontext); - if (cstate->opts.binary) + if (CopyOptsIsBinary(cstate->opts)) { /* Binary per-tuple header */ CopySendInt16(cstate, list_length(cstate->attnumlist)); @@ -746,7 +748,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot) Datum value = slot->tts_values[attnum - 1]; bool isnull = slot->tts_isnull[attnum - 1]; - if (!cstate->opts.binary) + if (!CopyOptsIsBinary(cstate->opts)) { if (need_delim) CopySendChar(cstate, cstate->opts.delim[0]); @@ -755,14 +757,14 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot) if (isnull) { - if (!cstate->opts.binary) + if (!CopyOptsIsBinary(cstate->opts)) CopySendString(cstate, cstate->opts.null_print_client); else CopySendInt32(cstate, -1); } else { - if (!cstate->opts.binary) + if (!CopyOptsIsBinary(cstate->opts)) { /* * Lookup the underlying tuple's attribute so we can pass in @@ -802,7 +804,7 @@ CopyOneRowTo(CopyToState cstate, TupleTableSlot *slot) } - if (cstate->opts.csv_mode) + if (CopyOptsIsCsvMode(cstate->opts)) CopyAttributeOutCSV(cstate, string, cstate->opts.force_quote_flags[attnum - 1], list_length(cstate->attnumlist) == 1); diff --git a/pg_lake_engine/src/data_file/data_file_stats.c b/pg_lake_engine/src/data_file/data_file_stats.c index 09992d697..acd296432 100644 --- a/pg_lake_engine/src/data_file/data_file_stats.c +++ b/pg_lake_engine/src/data_file/data_file_stats.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "executor/executor.h" #include "pg_lake/data_file/data_files.h" diff --git a/pg_lake_engine/src/json/json_reader.c b/pg_lake_engine/src/json/json_reader.c index ff54c125f..37623c93f 100644 --- a/pg_lake_engine/src/json/json_reader.c +++ b/pg_lake_engine/src/json/json_reader.c @@ -18,6 +18,7 @@ #include "postgres.h" #include "common/fe_memutils.h" +#include "pg_extension_base/pg_compat.h" #include "pg_lake/json/json_reader.h" #include "utils/builtins.h" #include "utils/jsonb.h" diff --git a/pg_lake_engine/src/parquet/field.c b/pg_lake_engine/src/parquet/field.c index 8acdfb45f..b8f8e3299 100644 --- a/pg_lake_engine/src/parquet/field.c +++ b/pg_lake_engine/src/parquet/field.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "common/int.h" diff --git a/pg_lake_engine/src/parsetree/const.c b/pg_lake_engine/src/parsetree/const.c index 46276f348..861c34331 100644 --- a/pg_lake_engine/src/parsetree/const.c +++ b/pg_lake_engine/src/parsetree/const.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "pg_lake/parsetree/const.h" diff --git a/pg_lake_engine/src/parsetree/expression.c b/pg_lake_engine/src/parsetree/expression.c index c22279cb8..9ca195440 100644 --- a/pg_lake_engine/src/parsetree/expression.c +++ b/pg_lake_engine/src/parsetree/expression.c @@ -24,6 +24,7 @@ #include "pg_lake/parsetree/const.h" #include "pg_lake/parsetree/expression.h" #include "datatype/timestamp.h" +#include "utils/timestamp.h" #include "nodes/makefuncs.h" #include "nodes/nodeFuncs.h" #include "nodes/parsenodes.h" diff --git a/pg_lake_engine/src/pgduck/client.c b/pg_lake_engine/src/pgduck/client.c index e64e6c327..12023e76b 100644 --- a/pg_lake_engine/src/pgduck/client.c +++ b/pg_lake_engine/src/pgduck/client.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "utils/hsearch.h" #include "miscadmin.h" #include "libpq-fe.h" diff --git a/pg_lake_engine/src/pgduck/map.c b/pg_lake_engine/src/pgduck/map.c index 7a28fd0ed..b92c2a973 100644 --- a/pg_lake_engine/src/pgduck/map.c +++ b/pg_lake_engine/src/pgduck/map.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "access/htup_details.h" +#include "catalog/pg_type_d.h" #include "miscadmin.h" #include "libpq-fe.h" diff --git a/pg_lake_engine/src/pgduck/parse_struct.c b/pg_lake_engine/src/pgduck/parse_struct.c index 4c6a47306..3f47e9eeb 100644 --- a/pg_lake_engine/src/pgduck/parse_struct.c +++ b/pg_lake_engine/src/pgduck/parse_struct.c @@ -23,6 +23,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "miscadmin.h" #include "libpq-fe.h" diff --git a/pg_lake_engine/src/pgduck/read_data.c b/pg_lake_engine/src/pgduck/read_data.c index c0c4d7926..aecf5662d 100644 --- a/pg_lake_engine/src/pgduck/read_data.c +++ b/pg_lake_engine/src/pgduck/read_data.c @@ -19,6 +19,7 @@ * Functions for generating query for reading data from pgduck server. */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include diff --git a/pg_lake_engine/src/pgduck/rewrite_query.c b/pg_lake_engine/src/pgduck/rewrite_query.c index e37fff63d..5be822e80 100644 --- a/pg_lake_engine/src/pgduck/rewrite_query.c +++ b/pg_lake_engine/src/pgduck/rewrite_query.c @@ -16,6 +16,9 @@ */ #include "postgres.h" +#include "access/htup_details.h" +#include "catalog/pg_type_d.h" +#include "utils/hsearch.h" #include #include diff --git a/pg_lake_engine/src/pgduck/shippable_spatial_functions.c b/pg_lake_engine/src/pgduck/shippable_spatial_functions.c index 49a1e1c59..26d2c3da0 100644 --- a/pg_lake_engine/src/pgduck/shippable_spatial_functions.c +++ b/pg_lake_engine/src/pgduck/shippable_spatial_functions.c @@ -20,6 +20,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "nodes/nodeFuncs.h" #include "optimizer/optimizer.h" diff --git a/pg_lake_engine/src/pgduck/type.c b/pg_lake_engine/src/pgduck/type.c index eb40c5e38..6330b76b5 100644 --- a/pg_lake_engine/src/pgduck/type.c +++ b/pg_lake_engine/src/pgduck/type.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "miscadmin.h" #include "libpq-fe.h" diff --git a/pg_lake_engine/src/pgduck/write_data.c b/pg_lake_engine/src/pgduck/write_data.c index 2fb0d0798..120453fb9 100644 --- a/pg_lake_engine/src/pgduck/write_data.c +++ b/pg_lake_engine/src/pgduck/write_data.c @@ -19,6 +19,7 @@ * Functions for generating query for writing data via pgduck server. */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "access/tupdesc.h" #include "commands/defrem.h" diff --git a/pg_lake_engine/src/query/execute.c b/pg_lake_engine/src/query/execute.c index f4a6aa78e..3bd3730ee 100644 --- a/pg_lake_engine/src/query/execute.c +++ b/pg_lake_engine/src/query/execute.c @@ -75,7 +75,11 @@ uint64 ExecuteQueryToDestReceiver(Query *query, const char *queryString, ParamListInfo params, DestReceiver *dest) { - PlannedStmt *plan = pg_plan_query(query, queryString, CURSOR_OPT_PARALLEL_OK, params); + PlannedStmt *plan = pg_plan_query(query, queryString, CURSOR_OPT_PARALLEL_OK, params +#if PG_VERSION_NUM >= 190000 + ,NULL +#endif + ); return ExecutePlanToDestReceiver(plan, queryString, params, dest); } diff --git a/pg_lake_engine/src/utils/compare_utils.c b/pg_lake_engine/src/utils/compare_utils.c index 6c2b161f3..278e974b5 100644 --- a/pg_lake_engine/src/utils/compare_utils.c +++ b/pg_lake_engine/src/utils/compare_utils.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "catalog/pg_collation.h" #include "fmgr.h" #include "utils/builtins.h" diff --git a/pg_lake_engine/src/utils/operator_utils.c b/pg_lake_engine/src/utils/operator_utils.c index baa41aa93..a919dc961 100644 --- a/pg_lake_engine/src/utils/operator_utils.c +++ b/pg_lake_engine/src/utils/operator_utils.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "catalog/pg_operator.h" #include "pg_lake/util/operator_utils.h" diff --git a/pg_lake_engine/src/utils/plan_cache.c b/pg_lake_engine/src/utils/plan_cache.c index 166988dd0..efb9bfa7b 100644 --- a/pg_lake_engine/src/utils/plan_cache.c +++ b/pg_lake_engine/src/utils/plan_cache.c @@ -26,6 +26,7 @@ * consider the cache size and eviction policy. */ #include "postgres.h" +#include "utils/hsearch.h" #include "fmgr.h" #include "miscadmin.h" diff --git a/pg_lake_iceberg/src/iceberg/api/table_metadata.c b/pg_lake_iceberg/src/iceberg/api/table_metadata.c index 611b3781e..40766f9ac 100644 --- a/pg_lake_iceberg/src/iceberg/api/table_metadata.c +++ b/pg_lake_iceberg/src/iceberg/api/table_metadata.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "storage/fd.h" #include "fmgr.h" #include "funcapi.h" #include "libpq-fe.h" diff --git a/pg_lake_iceberg/src/iceberg/catalog.c b/pg_lake_iceberg/src/iceberg/catalog.c index 7e4cd64f9..e07994dc7 100644 --- a/pg_lake_iceberg/src/iceberg/catalog.c +++ b/pg_lake_iceberg/src/iceberg/catalog.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "miscadmin.h" #include "pg_lake/extensions/pg_lake_iceberg.h" diff --git a/pg_lake_iceberg/src/iceberg/iceberg_type_binary_serde.c b/pg_lake_iceberg/src/iceberg/iceberg_type_binary_serde.c index 67828a27e..463b4ec20 100644 --- a/pg_lake_iceberg/src/iceberg/iceberg_type_binary_serde.c +++ b/pg_lake_iceberg/src/iceberg/iceberg_type_binary_serde.c @@ -16,6 +16,10 @@ */ #include "postgres.h" + +#include + +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "libpq-fe.h" diff --git a/pg_lake_iceberg/src/iceberg/iceberg_type_json_serde.c b/pg_lake_iceberg/src/iceberg/iceberg_type_json_serde.c index 5f0bbf0cd..b37a5aa67 100644 --- a/pg_lake_iceberg/src/iceberg/iceberg_type_json_serde.c +++ b/pg_lake_iceberg/src/iceberg/iceberg_type_json_serde.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "libpq-fe.h" diff --git a/pg_lake_iceberg/src/iceberg/metadata_operations.c b/pg_lake_iceberg/src/iceberg/metadata_operations.c index 0938f5fe2..6aff58a6a 100644 --- a/pg_lake_iceberg/src/iceberg/metadata_operations.c +++ b/pg_lake_iceberg/src/iceberg/metadata_operations.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "utils/hsearch.h" #include "fmgr.h" #include "access/xact.h" #include "common/hashfn.h" diff --git a/pg_lake_iceberg/src/iceberg/operations/find_referenced_files.c b/pg_lake_iceberg/src/iceberg/operations/find_referenced_files.c index f42e8fdb7..3aadec87a 100644 --- a/pg_lake_iceberg/src/iceberg/operations/find_referenced_files.c +++ b/pg_lake_iceberg/src/iceberg/operations/find_referenced_files.c @@ -23,6 +23,7 @@ * referenced in the latest metadata.json file. */ #include "postgres.h" +#include "utils/hsearch.h" #include "miscadmin.h" #include "fmgr.h" #include "funcapi.h" diff --git a/pg_lake_iceberg/src/iceberg/read_manifest.c b/pg_lake_iceberg/src/iceberg/read_manifest.c index 3086eb3f9..6dc8d2a0c 100644 --- a/pg_lake_iceberg/src/iceberg/read_manifest.c +++ b/pg_lake_iceberg/src/iceberg/read_manifest.c @@ -16,11 +16,14 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "libpq-fe.h" #include "miscadmin.h" +#include "storage/fd.h" #include "utils/builtins.h" #include "utils/snapmgr.h" #include "utils/wait_event.h" diff --git a/pg_lake_iceberg/src/object_store_catalog/object_store_catalog.c b/pg_lake_iceberg/src/object_store_catalog/object_store_catalog.c index 642674277..94808b9c2 100644 --- a/pg_lake_iceberg/src/object_store_catalog/object_store_catalog.c +++ b/pg_lake_iceberg/src/object_store_catalog/object_store_catalog.c @@ -1,4 +1,5 @@ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include "miscadmin.h" @@ -7,6 +8,7 @@ #include "utils/inval.h" #include "utils/snapmgr.h" #include "utils/lsyscache.h" +#include "utils/tuplestore.h" #include "pg_lake/json/json_utils.h" #include "pg_lake/iceberg/catalog.h" diff --git a/pg_lake_iceberg/src/rest_catalog/rest_catalog.c b/pg_lake_iceberg/src/rest_catalog/rest_catalog.c index 8cf2b2ae3..cbbbdb5bd 100644 --- a/pg_lake_iceberg/src/rest_catalog/rest_catalog.c +++ b/pg_lake_iceberg/src/rest_catalog/rest_catalog.c @@ -18,6 +18,7 @@ #include #include "postgres.h" +#include "pg_extension_base/pg_compat.h" #include "miscadmin.h" #include "common/base64.h" diff --git a/pg_lake_iceberg/src/test/test_http_client.c b/pg_lake_iceberg/src/test/test_http_client.c index 185a77acd..539b2a2b4 100644 --- a/pg_lake_iceberg/src/test/test_http_client.c +++ b/pg_lake_iceberg/src/test/test_http_client.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "fmgr.h" #include "funcapi.h" #include "utils/array.h" diff --git a/pg_lake_iceberg/src/test/test_iceberg_binary_serde.c b/pg_lake_iceberg/src/test/test_iceberg_binary_serde.c index 685aee4a2..92d0a3fbb 100644 --- a/pg_lake_iceberg/src/test/test_iceberg_binary_serde.c +++ b/pg_lake_iceberg/src/test/test_iceberg_binary_serde.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" @@ -28,6 +29,7 @@ #include "utils/builtins.h" #include "utils/json.h" +#include "utils/tuplestore.h" static ColumnBound * FindColumnBoundByColumnId(ColumnBound * bounds, int numBounds, int columnId); diff --git a/pg_lake_iceberg/src/test/test_iceberg_field_ids.c b/pg_lake_iceberg/src/test/test_iceberg_field_ids.c index 1431697a3..f5689cc7a 100644 --- a/pg_lake_iceberg/src/test/test_iceberg_field_ids.c +++ b/pg_lake_iceberg/src/test/test_iceberg_field_ids.c @@ -24,6 +24,7 @@ #include "pg_lake/parquet/leaf_field.h" #include "utils/builtins.h" +#include "utils/tuplestore.h" PG_FUNCTION_INFO_V1(pg_lake_get_leaf_field_ids); diff --git a/pg_lake_iceberg/src/test/test_iceberg_manifest.c b/pg_lake_iceberg/src/test/test_iceberg_manifest.c index 62f4d6921..c0ee48f8a 100644 --- a/pg_lake_iceberg/src/test/test_iceberg_manifest.c +++ b/pg_lake_iceberg/src/test/test_iceberg_manifest.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "libpq-fe.h" @@ -28,6 +29,7 @@ #include "pg_lake/iceberg/partitioning/partition.h" #include "utils/builtins.h" +#include "utils/tuplestore.h" static const char *FetchCurrentSnapshotManifestListPathFromTableMetadataUri(const char *tableMetadataPath); static List *FetchDataFilePathsFromTableMetadataUri(const char *tableMetadataPath, bool isDelete); diff --git a/pg_lake_iceberg/src/utils/truncate_utils.c b/pg_lake_iceberg/src/utils/truncate_utils.c index e136e4cab..73a333b5e 100644 --- a/pg_lake_iceberg/src/utils/truncate_utils.c +++ b/pg_lake_iceberg/src/utils/truncate_utils.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "pg_extension_base/pg_compat.h" #include "mb/pg_wchar.h" #include "utils/builtins.h" #include "utils/fmgrprotos.h" diff --git a/pg_lake_table/include/pg_lake/fdw/data_files_catalog.h b/pg_lake_table/include/pg_lake/fdw/data_files_catalog.h index 65e5a9c25..5db9e2d4a 100644 --- a/pg_lake_table/include/pg_lake/fdw/data_files_catalog.h +++ b/pg_lake_table/include/pg_lake/fdw/data_files_catalog.h @@ -22,7 +22,9 @@ #include "pg_lake/util/s3_reader_utils.h" #include "nodes/pg_list.h" +#if PG_VERSION_NUM < 190000 #include "utils/dynahash.h" +#endif #define DATA_FILES_TABLE_QUALIFIED \ PG_LAKE_TABLE_SCHEMA "." PG_LAKE_TABLE_FILES_TABLE_NAME diff --git a/pg_lake_table/src/ddl/alter_table.c b/pg_lake_table/src/ddl/alter_table.c index 1f3d08754..956f247be 100644 --- a/pg_lake_table/src/ddl/alter_table.c +++ b/pg_lake_table/src/ddl/alter_table.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "miscadmin.h" #include "access/heapam.h" diff --git a/pg_lake_table/src/ddl/create_table.c b/pg_lake_table/src/ddl/create_table.c index 510cd7d40..9f758554b 100644 --- a/pg_lake_table/src/ddl/create_table.c +++ b/pg_lake_table/src/ddl/create_table.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "miscadmin.h" #include "access/table.h" diff --git a/pg_lake_table/src/describe/describe.c b/pg_lake_table/src/describe/describe.c index 5a32d431f..8d4c78773 100644 --- a/pg_lake_table/src/describe/describe.c +++ b/pg_lake_table/src/describe/describe.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "libpq-fe.h" #include "commands/defrem.h" diff --git a/pg_lake_table/src/duckdb/transform_query_to_duckdb.c b/pg_lake_table/src/duckdb/transform_query_to_duckdb.c index f0fb4dfbd..f30b5d5d6 100644 --- a/pg_lake_table/src/duckdb/transform_query_to_duckdb.c +++ b/pg_lake_table/src/duckdb/transform_query_to_duckdb.c @@ -28,6 +28,7 @@ #include "access/relation.h" #include "access/xact.h" #include "utils/builtins.h" +#include "utils/timestamp.h" #include "catalog/pg_class_d.h" #include "catalog/pg_type_d.h" #include "pg_lake/iceberg/api/table_schema.h" diff --git a/pg_lake_table/src/fdw/data_file_pruning.c b/pg_lake_table/src/fdw/data_file_pruning.c index b2beca68a..b4cde17bc 100644 --- a/pg_lake_table/src/fdw/data_file_pruning.c +++ b/pg_lake_table/src/fdw/data_file_pruning.c @@ -21,6 +21,9 @@ * execution and statistics of the data files. */ #include "postgres.h" +#include "utils/hsearch.h" +#include "access/htup_details.h" +#include "catalog/pg_type_d.h" #include "catalog/pg_am_d.h" #include "catalog/pg_index.h" diff --git a/pg_lake_table/src/fdw/data_files_catalog.c b/pg_lake_table/src/fdw/data_files_catalog.c index 5890683b1..82d343813 100644 --- a/pg_lake_table/src/fdw/data_files_catalog.c +++ b/pg_lake_table/src/fdw/data_files_catalog.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "miscadmin.h" diff --git a/pg_lake_table/src/fdw/data_files_catalog_batch.c b/pg_lake_table/src/fdw/data_files_catalog_batch.c index 750684a93..21d275529 100644 --- a/pg_lake_table/src/fdw/data_files_catalog_batch.c +++ b/pg_lake_table/src/fdw/data_files_catalog_batch.c @@ -25,6 +25,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "pg_extension_base/extension_ids.h" #include "pg_extension_base/spi_helpers.h" @@ -42,7 +44,9 @@ #include "executor/spi.h" #include "utils/builtins.h" +#if PG_VERSION_NUM < 190000 #include "utils/dynahash.h" +#endif /* path -> int64 file id, built from RETURNING output of ExecInsertDataFiles */ typedef struct FileIdHashEntry diff --git a/pg_lake_table/src/fdw/deparse.c b/pg_lake_table/src/fdw/deparse.c index 48c36da49..a26d3b5e1 100644 --- a/pg_lake_table/src/fdw/deparse.c +++ b/pg_lake_table/src/fdw/deparse.c @@ -1222,7 +1222,11 @@ is_foreign_pathkey(PlannerInfo *root, static char * deparse_type_name(Oid type_oid, int32 typemod) { +#if PG_VERSION_NUM >= 190000 + uint16 flags = FORMAT_TYPE_TYPEMOD_GIVEN; +#else bits16 flags = FORMAT_TYPE_TYPEMOD_GIVEN; +#endif if (!is_builtin(type_oid)) flags |= FORMAT_TYPE_FORCE_QUALIFY; diff --git a/pg_lake_table/src/fdw/deparse_ruleutils.c b/pg_lake_table/src/fdw/deparse_ruleutils.c index 9e3c565fe..6b7b4c3c0 100644 --- a/pg_lake_table/src/fdw/deparse_ruleutils.c +++ b/pg_lake_table/src/fdw/deparse_ruleutils.c @@ -25,6 +25,7 @@ *------------------------------------------------------------------------- */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "parser/parse_func.h" #include "parser/parsetree.h" diff --git a/pg_lake_table/src/fdw/partition_transform.c b/pg_lake_table/src/fdw/partition_transform.c index 077bf0655..6d385faae 100644 --- a/pg_lake_table/src/fdw/partition_transform.c +++ b/pg_lake_table/src/fdw/partition_transform.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "utils/builtins.h" #include "utils/date.h" #include "utils/lsyscache.h" diff --git a/pg_lake_table/src/fdw/partitioning/partition_spec_catalog.c b/pg_lake_table/src/fdw/partitioning/partition_spec_catalog.c index 05680c271..e3769a545 100644 --- a/pg_lake_table/src/fdw/partitioning/partition_spec_catalog.c +++ b/pg_lake_table/src/fdw/partitioning/partition_spec_catalog.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "pg_lake/extensions/pg_lake_table.h" diff --git a/pg_lake_table/src/fdw/partitioning/partitioned_dest_receiver.c b/pg_lake_table/src/fdw/partitioning/partitioned_dest_receiver.c index 8f34c30cc..45cb5a4ab 100644 --- a/pg_lake_table/src/fdw/partitioning/partitioned_dest_receiver.c +++ b/pg_lake_table/src/fdw/partitioning/partitioned_dest_receiver.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "utils/hsearch.h" #include "access/tupdesc.h" #include "commands/copy.h" diff --git a/pg_lake_table/src/fdw/pg_lake_table.c b/pg_lake_table/src/fdw/pg_lake_table.c index d41078945..70e0cf702 100644 --- a/pg_lake_table/src/fdw/pg_lake_table.c +++ b/pg_lake_table/src/fdw/pg_lake_table.c @@ -25,6 +25,8 @@ *------------------------------------------------------------------------- */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include diff --git a/pg_lake_table/src/fdw/position_delete_dest.c b/pg_lake_table/src/fdw/position_delete_dest.c index 21b3fb564..66e204691 100644 --- a/pg_lake_table/src/fdw/position_delete_dest.c +++ b/pg_lake_table/src/fdw/position_delete_dest.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "access/htup_details.h" +#include "utils/hsearch.h" #include "access/tupdesc.h" #include "commands/copy.h" diff --git a/pg_lake_table/src/fdw/schema_operations/field_id_mapping_catalog.c b/pg_lake_table/src/fdw/schema_operations/field_id_mapping_catalog.c index 53dabb678..ce3d0ffe7 100644 --- a/pg_lake_table/src/fdw/schema_operations/field_id_mapping_catalog.c +++ b/pg_lake_table/src/fdw/schema_operations/field_id_mapping_catalog.c @@ -22,6 +22,7 @@ * from/to catalog lake_table.field_id_mappings. */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "miscadmin.h" #include "access/relation.h" diff --git a/pg_lake_table/src/fdw/update_tracking.c b/pg_lake_table/src/fdw/update_tracking.c index b206cd1f3..b46fe1b41 100644 --- a/pg_lake_table/src/fdw/update_tracking.c +++ b/pg_lake_table/src/fdw/update_tracking.c @@ -219,7 +219,11 @@ CreateUpdateTrackingTable(RangeVar *updateTableName) indexColumn->name = "rowid"; createPrimaryKey->indexParams = list_make1(indexColumn); - DefineIndex(updateTableAddress.objectId, + DefineIndex( +#if PG_VERSION_NUM >= 190000 + /* pstate */ NULL, +#endif + updateTableAddress.objectId, createPrimaryKey, /* indexRelationId */ InvalidOid, /* parentIndexId */ InvalidOid, diff --git a/pg_lake_table/src/fdw/writable_table.c b/pg_lake_table/src/fdw/writable_table.c index dcab98fed..1d8522e56 100644 --- a/pg_lake_table/src/fdw/writable_table.c +++ b/pg_lake_table/src/fdw/writable_table.c @@ -16,6 +16,9 @@ */ #include "postgres.h" +#include "storage/lock.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "fmgr.h" #include "funcapi.h" #include "miscadmin.h" diff --git a/pg_lake_table/src/planner/insert_select.c b/pg_lake_table/src/planner/insert_select.c index 0ba1bee5a..a00d19d9d 100644 --- a/pg_lake_table/src/planner/insert_select.c +++ b/pg_lake_table/src/planner/insert_select.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "catalog/pg_type_d.h" #include "access/table.h" #include "pg_lake/extensions/postgis.h" diff --git a/pg_lake_table/src/planner/query_pushdown.c b/pg_lake_table/src/planner/query_pushdown.c index 18c9fbe18..ffdd4d710 100644 --- a/pg_lake_table/src/planner/query_pushdown.c +++ b/pg_lake_table/src/planner/query_pushdown.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include "miscadmin.h" @@ -95,7 +97,11 @@ typedef struct IsShippableContext static PlannedStmt *LakeTablePlanner(Query *parse, const char *queryString, - int cursorOptions, ParamListInfo boundParams); + int cursorOptions, ParamListInfo boundParams +#if PG_VERSION_NUM >= 190000 + ,ExplainState *es +#endif +); static bool AdjustParseTreeForPgLake(Node *node, void *context); static bool ProcessNotShippableExpressionWalker(Node *node, IsShippableContext * context); static bool AddMissingRTEAliasaes(Node *node, void *context); @@ -253,7 +259,11 @@ AppendPermInfos(PlannedStmt *pushdownPlan, PlannedStmt *localPlan) */ static PlannedStmt * LakeTablePlanner(Query *parse, const char *queryString, - int cursorOptions, ParamListInfo boundParams) + int cursorOptions, ParamListInfo boundParams +#if PG_VERSION_NUM >= 190000 + ,ExplainState *es +#endif +) { Query *originalQuery = NULL; bool hasLakeTable = false; @@ -293,7 +303,11 @@ LakeTablePlanner(Query *parse, const char *queryString, PG_TRY(); { - plan = PreviousPlannerHook(parse, queryString, cursorOptions, boundParams); + plan = PreviousPlannerHook(parse, queryString, cursorOptions, boundParams +#if PG_VERSION_NUM >= 190000 + ,es +#endif + ); if (EnableFullQueryPushdown && hasLakeTable && (cursorOptions & CURSOR_OPT_SCROLL) == 0) diff --git a/pg_lake_table/src/planner/restriction_collector.c b/pg_lake_table/src/planner/restriction_collector.c index 31087de91..385c964d3 100644 --- a/pg_lake_table/src/planner/restriction_collector.c +++ b/pg_lake_table/src/planner/restriction_collector.c @@ -24,6 +24,7 @@ * that Postgres planner knows about. */ #include "postgres.h" +#include "utils/hsearch.h" #include "funcapi.h" #include "miscadmin.h" diff --git a/pg_lake_table/src/recovery/recover.c b/pg_lake_table/src/recovery/recover.c index 53b3f22ab..e1f5bb038 100644 --- a/pg_lake_table/src/recovery/recover.c +++ b/pg_lake_table/src/recovery/recover.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "access/htup_details.h" #include "miscadmin.h" #include "fmgr.h" diff --git a/pg_lake_table/src/test/hide_lake_objects.c b/pg_lake_table/src/test/hide_lake_objects.c index d53835729..a4e70fe39 100644 --- a/pg_lake_table/src/test/hide_lake_objects.c +++ b/pg_lake_table/src/test/hide_lake_objects.c @@ -16,6 +16,8 @@ */ #include "postgres.h" +#include "utils/hsearch.h" +#include "access/htup_details.h" #include "miscadmin.h" #include "access/genam.h" diff --git a/pg_lake_table/src/test/test_partition_tuple.c b/pg_lake_table/src/test/test_partition_tuple.c index acd2644a8..2bef4fcc5 100644 --- a/pg_lake_table/src/test/test_partition_tuple.c +++ b/pg_lake_table/src/test/test_partition_tuple.c @@ -16,11 +16,14 @@ */ #include "postgres.h" +#include "access/htup_details.h" +#include "catalog/pg_type_d.h" #include "funcapi.h" #include "access/relation.h" #include "utils/builtins.h" #include "utils/lsyscache.h" #include "utils/rel.h" +#include "utils/tuplestore.h" #include "pg_lake/partitioning/partition_spec_catalog.h" #include "pg_lake/fdw/partition_transform.h" diff --git a/pg_lake_table/src/transaction/track_iceberg_metadata_changes.c b/pg_lake_table/src/transaction/track_iceberg_metadata_changes.c index 2c3e0655f..96104738f 100644 --- a/pg_lake_table/src/transaction/track_iceberg_metadata_changes.c +++ b/pg_lake_table/src/transaction/track_iceberg_metadata_changes.c @@ -16,6 +16,7 @@ */ #include "postgres.h" +#include "utils/hsearch.h" #include "access/xact.h" #include "common/int.h" #include "utils/memutils.h" diff --git a/pg_map/src/map.c b/pg_map/src/map.c index 15bf0daa3..fd0318e50 100644 --- a/pg_map/src/map.c +++ b/pg_map/src/map.c @@ -53,6 +53,7 @@ #include "utils/regproc.h" #include "utils/syscache.h" #include "utils/typcache.h" +#include "utils/tuplestore.h" /* Check PgSQL version */ diff --git a/pgduck_server/Makefile b/pgduck_server/Makefile index 5f6c956aa..3dd88b740 100644 --- a/pgduck_server/Makefile +++ b/pgduck_server/Makefile @@ -12,9 +12,11 @@ PGXS := $(shell $(PG_CONFIG) --pgxs) PG_LAKE_DELTA_SUPPORT ?= 0 -# compile with C11 option to use modern C +# compile with C11 option to use modern C; use GNU dialect so that +# typeof / static_assert resolve when including PG19's c.h, which +# uses both unconditionally # use duckdb.h from the duckdb submodule -PG_CPPFLAGS = -std=c11 -I$(PG_INCLUDEDIR) -Iinclude -DPG_LAKE_DELTA_SUPPORT=$(PG_LAKE_DELTA_SUPPORT) +PG_CPPFLAGS = -std=gnu11 -I$(PG_INCLUDEDIR) -Iinclude -DPG_LAKE_DELTA_SUPPORT=$(PG_LAKE_DELTA_SUPPORT) # Add dependencies SHLIB_LINK_INTERNAL = $(libpq) diff --git a/pgduck_server/include/utils/numutils.h b/pgduck_server/include/utils/numutils.h index daabe4dd8..eb349908c 100644 --- a/pgduck_server/include/utils/numutils.h +++ b/pgduck_server/include/utils/numutils.h @@ -25,8 +25,6 @@ #include "c.h" -#include "nodes/nodes.h" - extern int pg_itoa(int16 i, char *a); extern int pg_ulltoa_n(uint64 value, char *a); extern int pg_ultoa_n(uint32 value, char *a); diff --git a/pgduck_server/src/duckdb/type_conversion.c b/pgduck_server/src/duckdb/type_conversion.c index 6424abc43..4b7171288 100644 --- a/pgduck_server/src/duckdb/type_conversion.c +++ b/pgduck_server/src/duckdb/type_conversion.c @@ -22,6 +22,7 @@ * * Copyright (c) 2025 Snowflake Computing, Inc. All rights reserved. */ +#include "catalog/pg_type_d.h" #include "c.h" #include "postgres_fe.h" diff --git a/pgduck_server/tests/ctests/Makefile b/pgduck_server/tests/ctests/Makefile index 630245b61..2f1519908 100644 --- a/pgduck_server/tests/ctests/Makefile +++ b/pgduck_server/tests/ctests/Makefile @@ -12,8 +12,10 @@ PG_INCLUDEDIR = $(shell $(PG_CONFIG) --includedir) # PGXS: Locates PostgreSQL extension building infrastructure using 'pg_config'. PGXS := $(shell $(PG_CONFIG) --pgxs) -# compile with C11 option to use modern C -PG_CPPFLAGS = -std=c11 -I$(PG_INCLUDEDIR) -g +# compile with C11 option to use modern C; use GNU dialect so that +# typeof / static_assert resolve when including PG19's c.h, which +# uses both unconditionally +PG_CPPFLAGS = -std=gnu11 -I$(PG_INCLUDEDIR) -g PG_LDFLAGS = -L$(PG_LIBDIR) -lpq -lpgcommon -lduckdb -Wl,-rpath,$(PG_LIBDIR)