From 87f456741b8a05c0f1f79cd476958bea87137e04 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 29 Aug 2026 09:45:26 +0800 Subject: [PATCH 01/13] Add meson build support for Cloudberry backend and core extensions The PG16 merge brought in 266 meson.build files verbatim from upstream, with no Cloudberry awareness at all: no GP options, no GP source files, no GP catalogs, and several upstream targets that Cloudberry does not build. This wires up enough of it to configure, build, install and initdb a working single-node Cloudberry with meson. Build options and configuration: - 24 GP options in meson_options.txt, defaults matching configure.ac - GP_VERSION / GP_MAJORVERSION / GP_VERSION_NUM computed via getversion, without writing a VERSION file into the source tree - ~20 GP config macros (USE_ORCA, USE_INTERNAL_FTS, FAULT_INJECTOR, ...) - libcurl, libbz2 and libuv detection Backend: - 21 new meson.build files for cdb, fts, task, crypto, the AO/AOCS/bitmap access methods, resgroup and the other GP utils subdirectories - GP sources added to 21 existing meson.build files - 40+ GP catalog headers and 5 .dat files registered; gp_version_at_initdb.dat generated from its template next to a build-dir copy of its header, since genbki.pl derives each .dat path from its .h path - system_views_gp.sql generated, plus cdb_schema.sql and the GP catalog SQL - libpq frontend sources compiled into the backend for QD<->QE communication - libpqwalreceiver built as a normal backend object, not a separate module Divergences from upstream that meson was still assuming: - geqo is not built by Cloudberry (not in optimizer/Makefile SUBDIRS) - gen_node_support.pl is unused; NodeTag is hand-maintained in nodes.h and copyfuncs.funcs.c / copyfuncs.switch.c are committed to the repository - ecpg is not built (commented out of src/interfaces/Makefile SUBDIRS) - man pages cannot be built; stylesheet-man.xsl is absent from the tree - libpq needs an explicit -DFRONTEND, as its sources include c.h rather than postgres_fe.h so the same files can also be compiled into the backend Extensions: - contrib/interconnect, required as a preload library by initdb - the eight always-on gpcontrib extensions array_userfuncs.c included ../../catalog/pg_type_d.h, which only resolves in an in-place build; corrected to the normal include path. ORCA, gpfdist, pxf, gpMgmt, the flag-gated gpcontrib extensions and the test suites are not wired up yet. Assisted-by: Claude Code --- contrib/interconnect/meson.build | 62 +++++++++ contrib/meson.build | 1 + doc/src/sgml/meson.build | 5 +- gpcontrib/gp_distribution_policy/meson.build | 31 +++++ gpcontrib/gp_exttable_fdw/meson.build | 38 +++++ gpcontrib/gp_internal_tools/meson.build | 46 ++++++ gpcontrib/gp_legacy_string_agg/meson.build | 31 +++++ gpcontrib/gp_relsizes_stats/meson.build | 31 +++++ gpcontrib/gp_sparse_vector/meson.build | 35 +++++ gpcontrib/gp_toolkit/meson.build | 46 ++++++ gpcontrib/meson.build | 28 ++++ gpcontrib/pg_hint_plan/meson.build | 38 +++++ meson.build | 131 +++++++++++++++++- meson_options.txt | 78 +++++++++++ src/backend/access/aocs/meson.build | 22 +++ src/backend/access/appendonly/meson.build | 32 +++++ src/backend/access/bitmap/meson.build | 25 ++++ src/backend/access/common/meson.build | 2 + src/backend/access/external/meson.build | 24 ++++ src/backend/access/meson.build | 4 + src/backend/access/rmgrdesc/meson.build | 3 + src/backend/access/transam/meson.build | 4 + src/backend/catalog/meson.build | 52 +++++++ src/backend/cdb/dispatcher/meson.build | 27 ++++ src/backend/cdb/endpoint/meson.build | 21 +++ src/backend/cdb/meson.build | 64 +++++++++ src/backend/cdb/motion/meson.build | 24 ++++ src/backend/commands/meson.build | 13 ++ src/backend/crypto/meson.build | 21 +++ src/backend/executor/meson.build | 17 +++ src/backend/fts/meson.build | 21 +++ src/backend/libpq/meson.build | 33 +++++ src/backend/meson.build | 5 +- src/backend/nodes/meson.build | 3 +- src/backend/optimizer/meson.build | 1 - src/backend/optimizer/plan/meson.build | 10 ++ src/backend/optimizer/util/meson.build | 2 + src/backend/parser/meson.build | 1 + src/backend/postmaster/meson.build | 3 + src/backend/replication/meson.build | 4 + src/backend/storage/file/meson.build | 3 + src/backend/task/meson.build | 23 +++ src/backend/tcop/meson.build | 1 + src/backend/utils/activity/meson.build | 1 + src/backend/utils/adt/array_userfuncs.c | 2 +- src/backend/utils/adt/meson.build | 7 + src/backend/utils/datumstream/meson.build | 20 +++ src/backend/utils/error/meson.build | 1 + src/backend/utils/etcd_lib/meson.build | 19 +++ src/backend/utils/fmgr/meson.build | 1 + src/backend/utils/gdd/meson.build | 21 +++ src/backend/utils/gp/meson.build | 19 +++ src/backend/utils/hyperloglog/meson.build | 19 +++ src/backend/utils/meson.build | 13 ++ src/backend/utils/misc/fstream/meson.build | 20 +++ src/backend/utils/misc/meson.build | 12 ++ src/backend/utils/mmgr/meson.build | 6 + src/backend/utils/resgroup/meson.build | 48 +++++++ .../utils/resource_manager/meson.build | 20 +++ src/backend/utils/resscheduler/meson.build | 20 +++ src/backend/utils/time/meson.build | 1 + .../utils/workfile_manager/meson.build | 19 +++ src/bin/pg_dump/meson.build | 1 + src/bin/pg_upgrade/meson.build | 14 ++ src/common/meson.build | 9 ++ src/fe_utils/meson.build | 1 + src/include/catalog/meson.build | 77 +++++++++- src/include/nodes/meson.build | 68 +-------- src/interfaces/libpq/meson.build | 7 +- src/interfaces/meson.build | 5 +- 70 files changed, 1440 insertions(+), 77 deletions(-) create mode 100644 contrib/interconnect/meson.build create mode 100644 gpcontrib/gp_distribution_policy/meson.build create mode 100644 gpcontrib/gp_exttable_fdw/meson.build create mode 100644 gpcontrib/gp_internal_tools/meson.build create mode 100644 gpcontrib/gp_legacy_string_agg/meson.build create mode 100644 gpcontrib/gp_relsizes_stats/meson.build create mode 100644 gpcontrib/gp_sparse_vector/meson.build create mode 100644 gpcontrib/gp_toolkit/meson.build create mode 100644 gpcontrib/meson.build create mode 100644 gpcontrib/pg_hint_plan/meson.build create mode 100644 src/backend/access/aocs/meson.build create mode 100644 src/backend/access/appendonly/meson.build create mode 100644 src/backend/access/bitmap/meson.build create mode 100644 src/backend/access/external/meson.build create mode 100644 src/backend/cdb/dispatcher/meson.build create mode 100644 src/backend/cdb/endpoint/meson.build create mode 100644 src/backend/cdb/meson.build create mode 100644 src/backend/cdb/motion/meson.build create mode 100644 src/backend/crypto/meson.build create mode 100644 src/backend/fts/meson.build create mode 100644 src/backend/task/meson.build create mode 100644 src/backend/utils/datumstream/meson.build create mode 100644 src/backend/utils/etcd_lib/meson.build create mode 100644 src/backend/utils/gdd/meson.build create mode 100644 src/backend/utils/gp/meson.build create mode 100644 src/backend/utils/hyperloglog/meson.build create mode 100644 src/backend/utils/misc/fstream/meson.build create mode 100644 src/backend/utils/resgroup/meson.build create mode 100644 src/backend/utils/resource_manager/meson.build create mode 100644 src/backend/utils/resscheduler/meson.build create mode 100644 src/backend/utils/workfile_manager/meson.build diff --git a/contrib/interconnect/meson.build b/contrib/interconnect/meson.build new file mode 100644 index 00000000000..0b3fed36d9a --- /dev/null +++ b/contrib/interconnect/meson.build @@ -0,0 +1,62 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +interconnect_sources = files( + 'ic_common.c', + 'ic_modules.c', + 'tcp/ic_tcp.c', + 'udp/ic_udpifc.c', +) + +# Proxy mode is gated on --enable-ic-proxy and requires libuv. +# Mirrors: ifeq ($(enable_ic_proxy), yes) in this directory's Makefile. +interconnect_mod_args = contrib_mod_args +if get_option('ic_proxy').enabled() + interconnect_sources += files( + 'proxy/ic_proxy_addr.c', + 'proxy/ic_proxy_backend.c', + 'proxy/ic_proxy_client.c', + 'proxy/ic_proxy_iobuf.c', + 'proxy/ic_proxy_key.c', + 'proxy/ic_proxy_main.c', + 'proxy/ic_proxy_packet.c', + 'proxy/ic_proxy_peer.c', + 'proxy/ic_proxy_pkt_cache.c', + 'proxy/ic_proxy_router.c', + ) + interconnect_mod_args += { + 'dependencies': contrib_mod_args['dependencies'] + [libuv], + } +endif + +if host_system == 'windows' + interconnect_sources += rc_lib_gen.process(win32ver_rc, extra_args: [ + '--NAME', 'interconnect', + '--FILEDESC', 'interconnect - inter connection module',]) +endif + +interconnect = shared_module('interconnect', + interconnect_sources, + include_directories: include_directories('.'), + kwargs: interconnect_mod_args, +) +contrib_targets += interconnect + +install_data( + 'interconnect--1.0.sql', + 'interconnect.control', + kwargs: contrib_data_args, +) diff --git a/contrib/meson.build b/contrib/meson.build index bd4a57c43c0..255e6094413 100644 --- a/contrib/meson.build +++ b/contrib/meson.build @@ -54,6 +54,7 @@ subdir('pg_walinspect') subdir('postgres_fdw') subdir('seg') subdir('sepgsql') +subdir('interconnect') subdir('spi') subdir('sslinfo') # start-scripts doesn't contain build products diff --git a/doc/src/sgml/meson.build b/doc/src/sgml/meson.build index 4fcce2f6546..e2d210d94bc 100644 --- a/doc/src/sgml/meson.build +++ b/doc/src/sgml/meson.build @@ -200,7 +200,10 @@ endif # # Man pages # -if docs_dep.found() +# Cloudberry does not ship stylesheet-man.xsl, so man pages cannot be built. +# (doc/src/sgml/Makefile:85 still references it, so `make man` is equally +# broken in the autoconf build -- guard here rather than silently failing.) +if docs_dep.found() and fs.exists(meson.current_source_dir() / 'stylesheet-man.xsl') # FIXME: implement / consider sqlmansectnum logic man = custom_target('man', input: ['stylesheet-man.xsl', postgres_full_xml], diff --git a/gpcontrib/gp_distribution_policy/meson.build b/gpcontrib/gp_distribution_policy/meson.build new file mode 100644 index 00000000000..ac90fb9e896 --- /dev/null +++ b/gpcontrib/gp_distribution_policy/meson.build @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_distribution_policy_sources = files( + 'gp_distribution_policy.c', +) + +gp_distribution_policy = shared_module('gp_distribution_policy', + gp_distribution_policy_sources, + kwargs: contrib_mod_args, +) +contrib_targets += gp_distribution_policy + +install_data( + 'gp_distribution_policy--1.0.sql', + 'gp_distribution_policy.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_exttable_fdw/meson.build b/gpcontrib/gp_exttable_fdw/meson.build new file mode 100644 index 00000000000..c7549b9aa6b --- /dev/null +++ b/gpcontrib/gp_exttable_fdw/meson.build @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_exttable_fdw_sources = files( + 'extaccess.c', + 'gp_exttable_fdw.c', + 'option.c', +) + +# SHLIB_LINK_INTERNAL = $(libpq) +gp_exttable_fdw_args = contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [libpq], +} + +gp_exttable_fdw = shared_module('gp_exttable_fdw', + gp_exttable_fdw_sources, + kwargs: gp_exttable_fdw_args, +) +contrib_targets += gp_exttable_fdw + +install_data( + 'gp_exttable_fdw--1.0.sql', + 'gp_exttable_fdw.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_internal_tools/meson.build b/gpcontrib/gp_internal_tools/meson.build new file mode 100644 index 00000000000..ebc06becb19 --- /dev/null +++ b/gpcontrib/gp_internal_tools/meson.build @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_ao_co_diagnostics = shared_module('gp_ao_co_diagnostics', + files('gp_ao_co_diagnostics.c'), + kwargs: contrib_mod_args, +) +contrib_targets += gp_ao_co_diagnostics + +gp_workfile_mgr = shared_module('gp_workfile_mgr', + files('gp_workfile_mgr.c'), + kwargs: contrib_mod_args, +) +contrib_targets += gp_workfile_mgr + +gp_session_state_memory_stats = shared_module('gp_session_state_memory_stats', + files('gp_session_state_memory_stats.c'), + kwargs: contrib_mod_args, +) +contrib_targets += gp_session_state_memory_stats + +gp_instrument_shmem = shared_module('gp_instrument_shmem', + files('gp_instrument_shmem.c'), + kwargs: contrib_mod_args, +) +contrib_targets += gp_instrument_shmem + +install_data( + 'gp_internal_tools--1.0.0.sql', + 'gp_internal_tools.control', + 'uninstall_gp_session_state.sql', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_legacy_string_agg/meson.build b/gpcontrib/gp_legacy_string_agg/meson.build new file mode 100644 index 00000000000..52571531d3c --- /dev/null +++ b/gpcontrib/gp_legacy_string_agg/meson.build @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_legacy_string_agg_sources = files( + 'gp_legacy_string_agg.c', +) + +gp_legacy_string_agg = shared_module('gp_legacy_string_agg', + gp_legacy_string_agg_sources, + kwargs: contrib_mod_args, +) +contrib_targets += gp_legacy_string_agg + +install_data( + 'gp_legacy_string_agg--1.0.0.sql', + 'gp_legacy_string_agg.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_relsizes_stats/meson.build b/gpcontrib/gp_relsizes_stats/meson.build new file mode 100644 index 00000000000..350f6c378b5 --- /dev/null +++ b/gpcontrib/gp_relsizes_stats/meson.build @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_relsizes_stats_sources = files( + 'src/gp_relsizes_stats.c', +) + +gp_relsizes_stats = shared_module('gp_relsizes_stats', + gp_relsizes_stats_sources, + kwargs: contrib_mod_args, +) +contrib_targets += gp_relsizes_stats + +install_data( + 'sql/gp_relsizes_stats--1.0.sql', + 'gp_relsizes_stats.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_sparse_vector/meson.build b/gpcontrib/gp_sparse_vector/meson.build new file mode 100644 index 00000000000..e7f7f680be2 --- /dev/null +++ b/gpcontrib/gp_sparse_vector/meson.build @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_svec_sources = files( + 'SparseData.c', + 'gp_sfv.c', + 'operators.c', + 'sparse_vector.c', +) + +gp_svec = shared_module('gp_svec', + gp_svec_sources, + kwargs: contrib_mod_args, +) +contrib_targets += gp_svec + +install_data( + 'gp_sparse_vector--1.0.1.sql', + 'gp_sparse_vector--1.0.0--1.0.1.sql', + 'gp_sparse_vector.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_toolkit/meson.build b/gpcontrib/gp_toolkit/meson.build new file mode 100644 index 00000000000..02a6bd16d6d --- /dev/null +++ b/gpcontrib/gp_toolkit/meson.build @@ -0,0 +1,46 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_toolkit_sources = files( + 'gp_partition_maint.c', +) + +# resource group support is Linux-only; elsewhere the dummy is used. +# Mirrors: ifeq ($(shell uname -s), Linux) in this directory's Makefile. +if host_machine.system() == 'linux' + gp_toolkit_sources += files('resgroup.c') +else + gp_toolkit_sources += files('resgroup-dummy.c') +endif + +gp_toolkit = shared_module('gp_toolkit', + gp_toolkit_sources, + kwargs: contrib_mod_args, +) +contrib_targets += gp_toolkit + +install_data( + 'gp_toolkit--1.1--1.2.sql', + 'gp_toolkit--1.0--1.1.sql', + 'gp_toolkit--1.0.sql', + 'gp_toolkit--1.2--1.3.sql', + 'gp_toolkit--1.3.sql', + 'gp_toolkit--1.3--1.4.sql', + 'gp_toolkit--1.4--1.5.sql', + 'gp_toolkit--1.5--1.6.sql', + 'gp_toolkit.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/meson.build b/gpcontrib/meson.build new file mode 100644 index 00000000000..6a3874485bf --- /dev/null +++ b/gpcontrib/meson.build @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# Extensions built unconditionally, matching the base recurse_targets list in +# gpcontrib/Makefile. The flag-gated ones (gpcloud, gpmapreduce, orafce, +# diskquota, zstd, gp_stats_collector, pxf_fdw and the debug set) are not +# wired up yet. +subdir('gp_distribution_policy') +subdir('gp_exttable_fdw') +subdir('gp_internal_tools') +subdir('gp_legacy_string_agg') +subdir('gp_relsizes_stats') +subdir('gp_sparse_vector') +subdir('gp_toolkit') +subdir('pg_hint_plan') diff --git a/gpcontrib/pg_hint_plan/meson.build b/gpcontrib/pg_hint_plan/meson.build new file mode 100644 index 00000000000..182d70cf8e6 --- /dev/null +++ b/gpcontrib/pg_hint_plan/meson.build @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# PG_CPPFLAGS += -I$(top_srcdir)/src/pl/plpgsql/src/ +pg_hint_plan = shared_module('pg_hint_plan', + files('pg_hint_plan.c'), + include_directories: include_directories('../../src/pl/plpgsql/src'), + kwargs: contrib_mod_args, +) +contrib_targets += pg_hint_plan + +install_data( + 'pg_hint_plan--1.3.0.sql', + 'pg_hint_plan--1.3.0--1.3.1.sql', + 'pg_hint_plan--1.3.1--1.3.2.sql', + 'pg_hint_plan--1.3.2--1.3.3.sql', + 'pg_hint_plan--1.3.3--1.3.4.sql', + 'pg_hint_plan--1.3.5--1.3.6.sql', + 'pg_hint_plan--1.3.4--1.3.5.sql', + 'pg_hint_plan--1.3.6--1.3.7.sql', + 'pg_hint_plan--1.3.7--1.3.8.sql', + 'pg_hint_plan--1.3.8--1.3.9.sql', + 'pg_hint_plan.control', + kwargs: contrib_data_args, +) diff --git a/meson.build b/meson.build index 929d6c27be6..49e8189f018 100644 --- a/meson.build +++ b/meson.build @@ -2934,6 +2934,120 @@ generated_sources_ac = {} # within. That makes it easy to add the necessary dependencies for the # subsequent build steps. + +############################################################### +# Apache Cloudberry configuration +############################################################### + +# Version. +# +# configure.ac runs `bash ./getversion` and then writes the result into a +# VERSION file *in the source tree*. meson must never write into srcdir, so we +# compute the value here and keep it in memory instead. getversion pushd's to +# its own directory, so it is safe to invoke from any working directory. +bash = find_program('bash', native: true) + +gp_version_long = run_command('bash', meson.current_source_dir() / 'getversion', + check: true).stdout().strip() +gp_version_short = run_command('bash', meson.current_source_dir() / 'getversion', + '--short', check: true).stdout().strip() + +# GP_MAJORVERSION is the leading run of digits, matching configure.ac's +# expr "$GP_VERSION" : '\([0-9][0-9]*\)' +gp_majorversion = gp_version_short.split('.')[0] + +# GP_VERSION_NUM packs major/minor/patch as %d%02d%02d, matching configure.ac. +# Strip the '+dev.N.gHASH' and '-devel' suffixes first. +gp_version_parts = gp_version_short.split('+')[0].split('-')[0].split('.') +gp_version_num = gp_version_parts[0].to_int() * 10000 +if gp_version_parts.length() > 1 + gp_version_num += gp_version_parts[1].to_int() * 100 +endif +if gp_version_parts.length() > 2 + gp_version_num += gp_version_parts[2].to_int() +endif + +cdata.set_quoted('GP_VERSION', gp_version_long) +cdata.set_quoted('GP_MAJORVERSION', gp_majorversion) +cdata.set('GP_VERSION_NUM', gp_version_num) + +# ORCA optimizer +orcaopt = get_option('orca') +if orcaopt.enabled() + cdata.set('USE_ORCA', 1) + # GPOS_DEBUG is ABI-affecting: it is tested by ~475 files under + # src/backend/gporca and changes class layouts. It must be a single value + # shared by the whole build, exactly as configure.ac ties it to cassert. + if get_option('cassert') + cdata.set('GPOS_DEBUG', 1) + endif +endif +if host_machine.system() == 'darwin' + cdata.set('GPOS_Darwin', 1) +endif + +# Fault tolerance service: internal unless an external FTS is requested. +if not get_option('external_fts') + cdata.set('USE_INTERNAL_FTS', 1) +endif + +# Simple boolean-driven defines. +cdata.set('FAULT_INJECTOR', get_option('faultinjector') ? 1 : false) +cdata.set('SERVERLESS', get_option('serverless') ? 1 : false) +cdata.set('USE_CATALOG_EXT', get_option('catalog_ext') ? 1 : false) +cdata.set('ENABLE_IC_UDP2', get_option('ic_udp2') ? 1 : false) +cdata.set('ENABLE_PRELOAD_IC_MODULE', get_option('preload_ic_module') ? 1 : false) +cdata.set('OPENSSL_ALLOW_REDIRECT', get_option('openssl_redirect') ? 1 : false) +cdata.set('USE_SHARED_POSTGRES_BACKEND', get_option('shared_postgres_backend') ? 1 : false) +cdata.set('USE_LINK_POSTGRES_WITH_SHARED', get_option('link_postgres_with_shared') ? 1 : false) + +# Feature-driven defines. +# interconnect proxy mode requires libuv (configure.ac: AC_CHECK_LIB(uv, ...)) +icproxyopt = get_option('ic_proxy') +if icproxyopt.enabled() + libuv = dependency('libuv', required: icproxyopt) + cdata.set('ENABLE_IC_PROXY', libuv.found() ? 1 : false) + cdata.set('HAVE_LIBUV', libuv.found() ? 1 : false) +else + libuv = not_found_dep + cdata.set('ENABLE_IC_PROXY', false) +endif +cdata.set('USE_PAX_STORAGE', get_option('pax').enabled() ? 1 : false) +cdata.set('USE_GPCLOUD', get_option('gpcloud').enabled() ? 1 : false) +cdata.set('USE_MAPREDUCE', get_option('mapreduce').enabled() ? 1 : false) +# libcurl: used by external tables (url_curl.c), PXF and gpcloud. +# configure.ac: AC_CHECK_CURL([7.19.0]) then LIBS += $CURL_LIBS +libcurlopt = get_option('libcurl') +if not libcurlopt.disabled() + libcurl = dependency('libcurl', version: '>= 7.19.0', required: libcurlopt) + cdata.set('USE_CURL', libcurl.found() ? 1 : false) +else + libcurl = not_found_dep + cdata.set('USE_CURL', false) +endif + +# bzip2: configure.ac does AC_CHECK_LIB(bz2, BZ2_bzDecompress) into global LIBS +libbz2opt = get_option('libbz2') +if not libbz2opt.disabled() + libbz2 = cc.find_library('bz2', has_headers: ['bzlib.h'], required: libbz2opt) + cdata.set('HAVE_LIBBZ2', libbz2.found() ? 1 : false) +else + libbz2 = not_found_dep + cdata.set('HAVE_LIBBZ2', false) +endif +cdata.set('USE_MDBLOCALES', get_option('mdblocales').enabled() ? 1 : false) + +# --enable-link-postgres-with-shared requires --enable-shared-postgres-backend +if get_option('link_postgres_with_shared') and not get_option('shared_postgres_backend') + error('link_postgres_with_shared requires shared_postgres_backend') +endif + +# PAX requires the shared backend +if get_option('pax').enabled() and not get_option('shared_postgres_backend') + error('pax requires shared_postgres_backend') +endif + + subdir('src/include') subdir('config') @@ -2959,7 +3073,7 @@ frontend_common_code = declare_dependency( compile_args: ['-DFRONTEND'], include_directories: [postgres_inc], sources: generated_headers, - dependencies: [os_deps, zlib, zstd], + dependencies: [os_deps, zlib, zstd, ssl], ) backend_common_code = declare_dependency( @@ -2981,7 +3095,7 @@ frontend_stlib_code = declare_dependency( include_directories: [postgres_inc], link_with: [common_static, pgport_static], sources: generated_headers, - dependencies: [os_deps, libintl], + dependencies: [os_deps, libintl, ssl], ) # all shared libraries not part of the backend should depend on this @@ -3021,10 +3135,12 @@ frontend_code = declare_dependency( include_directories: [postgres_inc], link_with: [fe_utils, common_static, pgport_static], sources: generated_headers, - dependencies: [os_deps, libintl], + dependencies: [os_deps, libintl, ssl], ) backend_both_deps += [ + libcurl, + libbz2, thread_dep, bsd_auth, gssapi, @@ -3043,9 +3159,13 @@ backend_both_deps += [ backend_mod_deps = backend_both_deps + os_deps +# Cloudberry's backend uses libpq directly for QD<->QE communication: 21 +# directories under src/backend add -I$(libpq_srcdir) in their Makefiles +# (upstream needs it only for libpqwalreceiver). Since meson compiles the +# backend as one target, the include path is added globally here. backend_code = declare_dependency( compile_args: ['-DBUILDING_DLL'], - include_directories: [postgres_inc], + include_directories: [postgres_inc, libpq_inc], link_args: ldflags_be, link_with: [], sources: generated_headers + generated_backend_headers, @@ -3067,9 +3187,10 @@ test_install_libs = [] subdir('src') subdir('contrib') +subdir('gpcontrib') subdir('src/test') -subdir('src/interfaces/ecpg/test') +# ecpg is not built by Cloudberry; see src/interfaces/meson.build subdir('doc/src/sgml') diff --git a/meson_options.txt b/meson_options.txt index d2f95cfec36..c05b74f7a30 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -209,3 +209,81 @@ option('ZSTD', type: 'string', value: 'zstd', option('ZIC', type: 'string', value: 'zic', description: 'Path to zic binary, when cross-compiling') + +# +-----------------------------------------------------------------------+ +# | Apache Cloudberry options | +# +-----------------------------------------------------------------------+ +# Defaults mirror configure.ac exactly; changing one here silently breaks +# equivalence with the autoconf build. + +option('orca', type: 'feature', value: 'enabled', + description: 'ORCA query optimizer (requires xerces-c)') + +option('gpfdist', type: 'feature', value: 'enabled', + description: 'gpfdist external table server (requires apr, libevent)') + +option('pxf', type: 'feature', value: 'enabled', + description: 'PXF foreign data wrapper (requires libcurl)') + +option('gpcloud', type: 'feature', value: 'disabled', + description: 'S3 external table protocol (requires libcurl, libxml2)') + +option('mapreduce', type: 'feature', value: 'disabled', + description: 'gpmapreduce (requires libyaml, perl)') + +option('orafce', type: 'feature', value: 'disabled', + description: 'Oracle compatibility extension') + +option('ic_proxy', type: 'feature', value: 'disabled', + description: 'interconnect proxy mode (requires libuv)') + +option('pax', type: 'feature', value: 'disabled', + description: 'PAX storage engine (requires protobuf >= 3.5, zstd >= 1.4)') + +option('diskquota', type: 'feature', value: 'disabled', + description: 'diskquota extension') + +option('gp_stats_collector', type: 'feature', value: 'disabled', + description: 'stats collector extension (requires protobuf)') + +option('libbz2', type: 'feature', value: 'enabled', + description: 'bzip2 support') + +option('libcurl', type: 'feature', value: 'enabled', + description: 'libcurl support (required by pxf and gpcloud)') + +option('libseccomp', type: 'feature', value: 'disabled', + description: 'libseccomp support') + +option('mdblocales', type: 'feature', value: 'disabled', + description: 'mdblocales support') + +option('debug_extensions', type: 'boolean', value: true, + description: 'build debug-only extensions in gpcontrib') + +option('faultinjector', type: 'boolean', value: true, + description: 'fault injection support for testing') + +option('catalog_ext', type: 'boolean', value: false, + description: 'catalog extension support (requires protobuf)') + +option('serverless', type: 'boolean', value: false, + description: 'serverless mode') + +option('external_fts', type: 'boolean', value: false, + description: 'use external fault tolerance service instead of the internal one') + +option('ic_udp2', type: 'boolean', value: false, + description: 'UDP interconnect v2') + +option('preload_ic_module', type: 'boolean', value: true, + description: 'preload the interconnect module') + +option('openssl_redirect', type: 'boolean', value: false, + description: 'allow OpenSSL redirect') + +option('shared_postgres_backend', type: 'boolean', value: true, + description: 'build the backend as libpostgres.so shared between postmaster and postgres') + +option('link_postgres_with_shared', type: 'boolean', value: false, + description: 'link the postgres binary against libpostgres.so') diff --git a/src/backend/access/aocs/meson.build b/src/backend/access/aocs/meson.build new file mode 100644 index 00000000000..e0960a7f566 --- /dev/null +++ b/src/backend/access/aocs/meson.build @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'aocs_compaction.c', + 'aocsam.c', + 'aocsam_handler.c', + 'aocssegfiles.c', +) diff --git a/src/backend/access/appendonly/meson.build b/src/backend/access/appendonly/meson.build new file mode 100644 index 00000000000..e033a5b5070 --- /dev/null +++ b/src/backend/access/appendonly/meson.build @@ -0,0 +1,32 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'aomd.c', + 'aomd_filehandler.c', + 'aosegfiles.c', + 'appendonly_blkdir_udf.c', + 'appendonly_compaction.c', + 'appendonly_visimap.c', + 'appendonly_visimap_entry.c', + 'appendonly_visimap_store.c', + 'appendonly_visimap_udf.c', + 'appendonlyam.c', + 'appendonlyam_handler.c', + 'appendonlyblockdirectory.c', + 'appendonlytid.c', + 'appendonlywriter.c', +) diff --git a/src/backend/access/bitmap/meson.build b/src/backend/access/bitmap/meson.build new file mode 100644 index 00000000000..0f5d94fbfe3 --- /dev/null +++ b/src/backend/access/bitmap/meson.build @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'bitmap.c', + 'bitmapattutil.c', + 'bitmapinsert.c', + 'bitmappages.c', + 'bitmapsearch.c', + 'bitmaputil.c', + 'bitmapxlog.c', +) diff --git a/src/backend/access/common/meson.build b/src/backend/access/common/meson.build index f5ac17b4987..f7f9805b824 100644 --- a/src/backend/access/common/meson.build +++ b/src/backend/access/common/meson.build @@ -17,4 +17,6 @@ backend_sources += files( 'toast_internals.c', 'tupconvert.c', 'tupdesc.c', + 'memtuple.c', + 'reloptions_gp.c', ) diff --git a/src/backend/access/external/meson.build b/src/backend/access/external/meson.build new file mode 100644 index 00000000000..0df2f68bdf7 --- /dev/null +++ b/src/backend/access/external/meson.build @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'external.c', + 'url.c', + 'url_curl.c', + 'url_custom.c', + 'url_execute.c', + 'url_file.c', +) diff --git a/src/backend/access/meson.build b/src/backend/access/meson.build index aa99c4d1622..7b326150d66 100644 --- a/src/backend/access/meson.build +++ b/src/backend/access/meson.build @@ -13,3 +13,7 @@ subdir('spgist') subdir('table') subdir('tablesample') subdir('transam') +subdir('external') +subdir('bitmap') +subdir('appendonly') +subdir('aocs') diff --git a/src/backend/access/rmgrdesc/meson.build b/src/backend/access/rmgrdesc/meson.build index f76e87e2d7d..bdb9f0fc714 100644 --- a/src/backend/access/rmgrdesc/meson.build +++ b/src/backend/access/rmgrdesc/meson.build @@ -24,6 +24,9 @@ rmgr_desc_sources = files( 'tblspcdesc.c', 'xactdesc.c', 'xlogdesc.c', + 'appendonlydesc.c', + 'bitmapdesc.c', + 'distributedlogdesc.c', ) backend_sources += rmgr_desc_sources diff --git a/src/backend/access/transam/meson.build b/src/backend/access/transam/meson.build index 8920c1bfce2..4c663298ffd 100644 --- a/src/backend/access/transam/meson.build +++ b/src/backend/access/transam/meson.build @@ -24,6 +24,10 @@ backend_sources += files( 'xlogrecovery.c', 'xlogstats.c', 'xlogutils.c', + 'distributedlog.c', + 'gp_distributed_log.c', + 'gp_transaction_log.c', + 'xlogfuncs_gp.c', ) # used by frontend programs to build a frontend xlogreader diff --git a/src/backend/catalog/meson.build b/src/backend/catalog/meson.build index 793575e1e8e..9f1dd881ac1 100644 --- a/src/backend/catalog/meson.build +++ b/src/backend/catalog/meson.build @@ -34,6 +34,28 @@ backend_sources += files( 'pg_type.c', 'storage.c', 'toasting.c', + 'aoblkdir.c', + 'aocatalog.c', + 'aoseg.c', + 'aovisimap.c', + 'gp_fastsequence.c', + 'gp_matview_aux.c', + 'gp_partition_template.c', + 'gp_segment_config.c', + 'oid_dispatch.c', + 'pg_appendonly.c', + 'pg_attribute_encoding.c', + 'pg_compression.c', + 'pg_directory_table.c', + 'pg_extprotocol.c', + 'pg_proc_callback.c', + 'pg_task.c', + 'pg_task_run_history.c', + 'storage_database.c', + 'storage_directory_table.c', + 'storage_tablespace.c', + 'storage_tablespace_twophase.c', + 'storage_tablespace_xact.c', ) @@ -43,5 +65,35 @@ install_data( 'sql_features.txt', 'system_functions.sql', 'system_views.sql', + 'system_views_gp_summary.sql', install_dir: dir_data, ) + +# cdb_schema.sql is installed into a subdirectory of $datadir +install_data( + 'cdb_schema.sql', + install_dir: dir_data / 'cdb_init.d', +) + +# external_fts.sql is only installed when the internal FTS is not in use +# (ifeq ($(USE_INTERNAL_FTS_FOUND), false) in this directory's Makefile) +if get_option('external_fts') + install_data('external_fts.sql', install_dir: dir_data) +endif + +# system_views_gp.sql wraps each listed pg_* view in an MPP-aware gp_* view. +# Reproduces the shell pipeline in this directory's Makefile ($(GP_SYSVIEW_SQL)). +system_views_gp_sql = custom_target('system_views_gp.sql', + input: 'system_views_gp.in', + output: 'system_views_gp.sql', + command: [bash, '-c', +'''set -eu +in="$1"; out="$2" +echo "-- MPP-aware system views of the PG system views. Auto-generated from a list of system views specified in system_views_gp.in. Do not edit this file directly." > "$out" +grep -v '#' "$in" | sed 's/pg_//g' | sed "s/.*/CREATE OR REPLACE VIEW gp_& AS SELECT gp_execution_segment() as gp_segment_id, * FROM gp_dist_random('pg_&') UNION ALL SELECT -1 as gp_segment_id, * from pg_&;/g" >> "$out" +''', + 'system_views_gp', '@INPUT@', '@OUTPUT@'], + install: true, + install_dir: dir_data, + build_by_default: true, +) diff --git a/src/backend/cdb/dispatcher/meson.build b/src/backend/cdb/dispatcher/meson.build new file mode 100644 index 00000000000..fa6995c90cf --- /dev/null +++ b/src/backend/cdb/dispatcher/meson.build @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'cdbconn.c', + 'cdbdisp.c', + 'cdbdisp_async.c', + 'cdbdisp_dtx.c', + 'cdbdisp_query.c', + 'cdbdispatchresult.c', + 'cdbgang.c', + 'cdbgang_async.c', + 'cdbpq.c', +) diff --git a/src/backend/cdb/endpoint/meson.build b/src/backend/cdb/endpoint/meson.build new file mode 100644 index 00000000000..a1e27acd503 --- /dev/null +++ b/src/backend/cdb/endpoint/meson.build @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'cdbendpoint.c', + 'cdbendpointretrieve.c', + 'cdbendpointutils.c', +) diff --git a/src/backend/cdb/meson.build b/src/backend/cdb/meson.build new file mode 100644 index 00000000000..43682158dad --- /dev/null +++ b/src/backend/cdb/meson.build @@ -0,0 +1,64 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'cdbappendonlystorageformat.c', + 'cdbappendonlystorageread.c', + 'cdbappendonlystoragewrite.c', + 'cdbappendonlyxlog.c', + 'cdbbufferedappend.c', + 'cdbbufferedread.c', + 'cdbcat.c', + 'cdbcopy.c', + 'cdbdistributedsnapshot.c', + 'cdbdistributedxacts.c', + 'cdbdistributedxid.c', + 'cdbdtxcontextinfo.c', + 'cdbdtxrecovery.c', + 'cdbfts.c', + 'cdbgroup.c', + 'cdbgroupingpaths.c', + 'cdbhash.c', + 'cdblegacyhash.c', + 'cdbllize.c', + 'cdblocaldistribxact.c', + 'cdbmutate.c', + 'cdboidsync.c', + 'cdbpath.c', + 'cdbpathlocus.c', + 'cdbpathtoplan.c', + 'cdbpgdatabase.c', + 'cdbplan.c', + 'cdbpullup.c', + 'cdbrelsize.c', + 'cdbsetop.c', + 'cdbsreh.c', + 'cdbsrlz.c', + 'cdbsubplan.c', + 'cdbsubselect.c', + 'cdbtargeteddispatch.c', + 'cdbthreadlog.c', + 'cdbtimer.c', + 'cdbtm.c', + 'cdbtmutils.c', + 'cdbutil.c', + 'cdbvarblock.c', + 'cdbvars.c', +) + +subdir('dispatcher') +subdir('endpoint') +subdir('motion') diff --git a/src/backend/cdb/motion/meson.build b/src/backend/cdb/motion/meson.build new file mode 100644 index 00000000000..36c86f986e4 --- /dev/null +++ b/src/backend/cdb/motion/meson.build @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'cdbmotion.c', + 'htupfifo.c', + 'ic_proxy_bgworker.c', + 'tupchunklist.c', + 'tupleremap.c', + 'tupser.c', +) diff --git a/src/backend/commands/meson.build b/src/backend/commands/meson.build index 42cced9ebe9..9f5af564b1b 100644 --- a/src/backend/commands/meson.build +++ b/src/backend/commands/meson.build @@ -50,4 +50,17 @@ backend_sources += files( 'vacuumparallel.c', 'variable.c', 'view.c', + 'analyzefuncs.c', + 'analyzeutils.c', + 'dirtablecmds.c', + 'extprotocolcmds.c', + 'exttablecmds.c', + 'pg_profile.c', + 'queue.c', + 'resgroupcmds.c', + 'storagecmds.c', + 'tablecmds_gp.c', + 'tag.c', + 'taskcmds.c', + 'vacuum_ao.c', ) diff --git a/src/backend/crypto/meson.build b/src/backend/crypto/meson.build new file mode 100644 index 00000000000..82ddd000023 --- /dev/null +++ b/src/backend/crypto/meson.build @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'bufenc.c', + 'kmgr.c', + 'sm4_ofb.c', +) diff --git a/src/backend/executor/meson.build b/src/backend/executor/meson.build index 65f9457c9b1..4db9f6fb090 100644 --- a/src/backend/executor/meson.build +++ b/src/backend/executor/meson.build @@ -66,4 +66,21 @@ backend_sources += files( 'spi.c', 'tqueue.c', 'tstoreReceiver.c', + 'execDynamicIndexes.c', + 'nodeAssertOp.c', + 'nodeDynamicBitmapHeapscan.c', + 'nodeDynamicBitmapIndexscan.c', + 'nodeDynamicForeignscan.c', + 'nodeDynamicIndexOnlyscan.c', + 'nodeDynamicIndexscan.c', + 'nodeDynamicSeqscan.c', + 'nodeMotion.c', + 'nodePartitionSelector.c', + 'nodeRuntimeFilter.c', + 'nodeSequence.c', + 'nodeShareInputScan.c', + 'nodeSplitMerge.c', + 'nodeSplitUpdate.c', + 'nodeTableFunction.c', + 'nodeTupleSplit.c', ) diff --git a/src/backend/fts/meson.build b/src/backend/fts/meson.build new file mode 100644 index 00000000000..a657b56ad8b --- /dev/null +++ b/src/backend/fts/meson.build @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'fts.c', + 'ftsmessagehandler.c', + 'ftsprobe.c', +) diff --git a/src/backend/libpq/meson.build b/src/backend/libpq/meson.build index 74a226c2bdd..1da75de79d2 100644 --- a/src/backend/libpq/meson.build +++ b/src/backend/libpq/meson.build @@ -27,6 +27,39 @@ if gssapi.found() ) endif +# Cloudberry compiles libpq's frontend sources into the backend as well, to get +# an internal libpq for QD<->QE communication. The Makefile symlinks them into +# this directory ("# Cloudberry objects follow"); meson references them in place. +# They must NOT be built with -DFRONTEND -- these files switch on that macro, +# and the backend copy needs the backend side (see fe-protocol3.c's header +# comment and src/interfaces/libpq/meson.build). +backend_sources += files( + '../../interfaces/libpq/fe-auth-scram.c', + '../../interfaces/libpq/fe-auth.c', + '../../interfaces/libpq/fe-connect.c', + '../../interfaces/libpq/fe-exec.c', + '../../interfaces/libpq/fe-misc.c', + '../../interfaces/libpq/fe-protocol3.c', + '../../interfaces/libpq/fe-secure.c', + '../../interfaces/libpq/fe-trace.c', + '../../interfaces/libpq/libpq-events.c', + '../../interfaces/libpq/pqexpbuffer.c', +) + +if ssl.found() + backend_sources += files( + '../../interfaces/libpq/fe-secure-common.c', + '../../interfaces/libpq/fe-secure-openssl.c', + ) +endif + +if gssapi.found() + backend_sources += files( + '../../interfaces/libpq/fe-gssapi-common.c', + '../../interfaces/libpq/fe-secure-gssapi.c', + ) +endif + install_data( 'pg_hba.conf.sample', 'pg_ident.conf.sample', diff --git a/src/backend/meson.build b/src/backend/meson.build index 88a35e96763..0a751a0bae8 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -33,6 +33,10 @@ subdir('storage') subdir('tcop') subdir('tsearch') subdir('utils') +subdir('task') +subdir('crypto') +subdir('fts') +subdir('cdb') subdir('po', if_found: libintl) @@ -207,7 +211,6 @@ pg_test_mod_args = pg_mod_args + { # enter these after we defined the server build. subdir('jit/llvm') -subdir('replication/libpqwalreceiver') subdir('replication/pgoutput') subdir('snowball') subdir('utils/mb/conversion_procs') diff --git a/src/backend/nodes/meson.build b/src/backend/nodes/meson.build index 31467a12d3b..43d5669d965 100644 --- a/src/backend/nodes/meson.build +++ b/src/backend/nodes/meson.build @@ -13,6 +13,8 @@ backend_sources += files( 'read.c', 'tidbitmap.c', 'value.c', + 'outfast.c', + 'readfast.c', ) # these include .c files generated in ../../include/nodes, seems nicer to not @@ -20,7 +22,6 @@ backend_sources += files( nodefunc_sources = files( 'copyfuncs.c', 'equalfuncs.c', - 'queryjumblefuncs.c', 'outfuncs.c', 'readfuncs.c', ) diff --git a/src/backend/optimizer/meson.build b/src/backend/optimizer/meson.build index d340ffb68a1..33daea175da 100644 --- a/src/backend/optimizer/meson.build +++ b/src/backend/optimizer/meson.build @@ -1,6 +1,5 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group -subdir('geqo') subdir('path') subdir('plan') subdir('prep') diff --git a/src/backend/optimizer/plan/meson.build b/src/backend/optimizer/plan/meson.build index ddcad0543a5..9bbdbed500d 100644 --- a/src/backend/optimizer/plan/meson.build +++ b/src/backend/optimizer/plan/meson.build @@ -9,4 +9,14 @@ backend_sources += files( 'planner.c', 'setrefs.c', 'subselect.c', + 'aqumv.c', + 'joinpartprune.c', + 'planshare.c', + 'transform.c', ) + +# orca.c is the entry point into the ORCA optimizer; built only with ORCA. +# Mirrors: ifeq ($(enable_orca),yes) / OBJS += orca.o +if get_option('orca').enabled() + backend_sources += files('orca.c') +endif diff --git a/src/backend/optimizer/util/meson.build b/src/backend/optimizer/util/meson.build index cc776e1090c..ecab748102e 100644 --- a/src/backend/optimizer/util/meson.build +++ b/src/backend/optimizer/util/meson.build @@ -15,4 +15,6 @@ backend_sources += files( 'restrictinfo.c', 'tlist.c', 'var.c', + 'predtest_valueset.c', + 'walkers.c', ) diff --git a/src/backend/parser/meson.build b/src/backend/parser/meson.build index 94517a7f7de..06028246bee 100644 --- a/src/backend/parser/meson.build +++ b/src/backend/parser/meson.build @@ -19,6 +19,7 @@ backend_sources += files( 'parse_type.c', 'parse_utilcmd.c', 'scansup.c', + 'parse_partition_gp.c', ) # Build a small utility static lib for the parser. The generation of the diff --git a/src/backend/postmaster/meson.build b/src/backend/postmaster/meson.build index cda921fd10b..ed6c0c2e075 100644 --- a/src/backend/postmaster/meson.build +++ b/src/backend/postmaster/meson.build @@ -13,4 +13,7 @@ backend_sources += files( 'startup.c', 'syslogger.c', 'walwriter.c', + 'autostats.c', + 'backoff.c', + 'loginmonitor.c', ) diff --git a/src/backend/replication/meson.build b/src/backend/replication/meson.build index c158a75147b..f99d024da22 100644 --- a/src/backend/replication/meson.build +++ b/src/backend/replication/meson.build @@ -7,6 +7,10 @@ backend_sources += files( 'walreceiver.c', 'walreceiverfuncs.c', 'walsender.c', + 'gp_replication.c', + # In PostgreSQL this is a separate shared library; Cloudberry links it as a + # normal backend object (src/backend/replication/Makefile:34). + 'libpqwalreceiver/libpqwalreceiver.c', ) # see ../parser/meson.build diff --git a/src/backend/storage/file/meson.build b/src/backend/storage/file/meson.build index e7fe850ccbe..57a5856373c 100644 --- a/src/backend/storage/file/meson.build +++ b/src/backend/storage/file/meson.build @@ -7,4 +7,7 @@ backend_sources += files( 'fileset.c', 'reinit.c', 'sharedfileset.c', + 'execute_pipe.c', + 'gp_compress.c', + 'ufile.c', ) diff --git a/src/backend/task/meson.build b/src/backend/task/meson.build new file mode 100644 index 00000000000..b3157e03bc0 --- /dev/null +++ b/src/backend/task/meson.build @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'entry.c', + 'job_metadata.c', + 'misc.c', + 'pg_cron.c', + 'task_states.c', +) diff --git a/src/backend/tcop/meson.build b/src/backend/tcop/meson.build index 55c49809fe8..3676f74bb08 100644 --- a/src/backend/tcop/meson.build +++ b/src/backend/tcop/meson.build @@ -7,4 +7,5 @@ backend_sources += files( 'postgres.c', 'pquery.c', 'utility.c', + 'idle_resource_cleaner.c', ) diff --git a/src/backend/utils/activity/meson.build b/src/backend/utils/activity/meson.build index 518ee3f798e..d6290576998 100644 --- a/src/backend/utils/activity/meson.build +++ b/src/backend/utils/activity/meson.build @@ -18,4 +18,5 @@ backend_sources += files( 'pgstat_wal.c', 'pgstat_xact.c', 'wait_event.c', + 'pgstat_resqueue.c', ) diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index ce4096fdd36..bc6ec65049f 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -23,7 +23,7 @@ #include "utils/datum.h" #include "utils/lsyscache.h" #include "utils/typcache.h" -#include "../../catalog/pg_type_d.h" +#include "catalog/pg_type_d.h" /* * SerialIOData diff --git a/src/backend/utils/adt/meson.build b/src/backend/utils/adt/meson.build index 8515cd93650..ae5e8859a2d 100644 --- a/src/backend/utils/adt/meson.build +++ b/src/backend/utils/adt/meson.build @@ -106,6 +106,13 @@ backend_sources += files( 'xid.c', 'xid8funcs.c', 'xml.c', + 'complex_type.c', + 'gp_dump_oids.c', + 'gp_optimizer_functions.c', + 'interpolate.c', + 'matrix.c', + 'mdb.c', + 'pivot.c', ) diff --git a/src/backend/utils/datumstream/meson.build b/src/backend/utils/datumstream/meson.build new file mode 100644 index 00000000000..cd8922ebd97 --- /dev/null +++ b/src/backend/utils/datumstream/meson.build @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'datumstream.c', + 'datumstreamblock.c', +) diff --git a/src/backend/utils/error/meson.build b/src/backend/utils/error/meson.build index 86b70751594..1411ee8ebc0 100644 --- a/src/backend/utils/error/meson.build +++ b/src/backend/utils/error/meson.build @@ -5,4 +5,5 @@ backend_sources += files( 'csvlog.c', 'elog.c', 'jsonlog.c', + 'debugutils.c', ) diff --git a/src/backend/utils/etcd_lib/meson.build b/src/backend/utils/etcd_lib/meson.build new file mode 100644 index 00000000000..33e2f75532a --- /dev/null +++ b/src/backend/utils/etcd_lib/meson.build @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'etcd.c', +) diff --git a/src/backend/utils/fmgr/meson.build b/src/backend/utils/fmgr/meson.build index a00e1685665..5c4b1c000ce 100644 --- a/src/backend/utils/fmgr/meson.build +++ b/src/backend/utils/fmgr/meson.build @@ -4,6 +4,7 @@ backend_sources += files( 'dfmgr.c', 'fmgr.c', 'funcapi.c', + 'deprecated.c', ) # fmgrtab.c diff --git a/src/backend/utils/gdd/meson.build b/src/backend/utils/gdd/meson.build new file mode 100644 index 00000000000..3d94cf6a178 --- /dev/null +++ b/src/backend/utils/gdd/meson.build @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'gddbackend.c', + 'gdddetector.c', + 'gddfuncs.c', +) diff --git a/src/backend/utils/gp/meson.build b/src/backend/utils/gp/meson.build new file mode 100644 index 00000000000..d1685d5bda9 --- /dev/null +++ b/src/backend/utils/gp/meson.build @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'segadmin.c', +) diff --git a/src/backend/utils/hyperloglog/meson.build b/src/backend/utils/hyperloglog/meson.build new file mode 100644 index 00000000000..3e0a7adb938 --- /dev/null +++ b/src/backend/utils/hyperloglog/meson.build @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'gp_hyperloglog.c', +) diff --git a/src/backend/utils/meson.build b/src/backend/utils/meson.build index 6239d6cddff..ff255421d80 100644 --- a/src/backend/utils/meson.build +++ b/src/backend/utils/meson.build @@ -1,5 +1,9 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group +backend_sources += files( + 'session_state.c', +) + install_data('errcodes.txt', install_dir: dir_data, ) @@ -17,3 +21,12 @@ subdir('mmgr') subdir('resowner') subdir('sort') subdir('time') +subdir('datumstream') +subdir('etcd_lib') +subdir('gdd') +subdir('resgroup') +subdir('resscheduler') +subdir('gp') +subdir('workfile_manager') +subdir('resource_manager') +subdir('hyperloglog') diff --git a/src/backend/utils/misc/fstream/meson.build b/src/backend/utils/misc/fstream/meson.build new file mode 100644 index 00000000000..fdcf85e2185 --- /dev/null +++ b/src/backend/utils/misc/fstream/meson.build @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'fstream.c', + 'gfile.c', +) diff --git a/src/backend/utils/misc/meson.build b/src/backend/utils/misc/meson.build index f719c97c051..585c671d0d5 100644 --- a/src/backend/utils/misc/meson.build +++ b/src/backend/utils/misc/meson.build @@ -16,6 +16,16 @@ backend_sources += files( 'superuser.c', 'timeout.c', 'tzparser.c', + 'backend_cancel.c', + 'bitmap_compression.c', + 'bitstream.c', + 'faultinjector.c', + 'faultinjector_warnings.c', + 'gpexpand.c', + 'guc_gp.c', + 'queryjumble.c', + 'string_utils.c', + 'uriparser.c', ) guc_scan = custom_target('guc_scan', @@ -35,3 +45,5 @@ backend_link_with += static_library('guc-file', install_data('postgresql.conf.sample', install_dir: dir_data, ) + +subdir('fstream') diff --git a/src/backend/utils/mmgr/meson.build b/src/backend/utils/mmgr/meson.build index e6ebe145eab..bb70a3b37e0 100644 --- a/src/backend/utils/mmgr/meson.build +++ b/src/backend/utils/mmgr/meson.build @@ -10,4 +10,10 @@ backend_sources += files( 'memdebug.c', 'portalmem.c', 'slab.c', + 'event_version.c', + 'idle_tracker.c', + 'memprot.c', + 'redzone_handler.c', + 'runaway_cleaner.c', + 'vmem_tracker.c', ) diff --git a/src/backend/utils/resgroup/meson.build b/src/backend/utils/resgroup/meson.build new file mode 100644 index 00000000000..dc1937202d8 --- /dev/null +++ b/src/backend/utils/resgroup/meson.build @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'resgroup.c', + 'resgroup_helper.c', +) + +# cgroup support is Linux-only; other platforms get the dummy implementation. +# Mirrors the ifeq ($(PORTNAME),linux) split in this directory's Makefile. +if host_machine.system() == 'linux' + backend_sources += files( + 'cgroup.c', + 'cgroup-ops-linux-v1.c', + 'cgroup-ops-linux-v2.c', + 'cgroup_io_limit.c', + ) + + io_limit_scanner = custom_target('io_limit_scanner', + input: 'io_limit_scanner.l', + output: 'io_limit_scanner.c', + command: flex_cmd, + ) + generated_sources += io_limit_scanner + backend_sources += io_limit_scanner + + io_limit_gram = custom_target('io_limit_gram', + input: 'io_limit_gram.y', + kwargs: bison_kw, + ) + generated_sources += io_limit_gram.to_list() + backend_sources += io_limit_gram +else + backend_sources += files('cgroup-ops-dummy.c') +endif diff --git a/src/backend/utils/resource_manager/meson.build b/src/backend/utils/resource_manager/meson.build new file mode 100644 index 00000000000..ba1c97ebe43 --- /dev/null +++ b/src/backend/utils/resource_manager/meson.build @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'memquota.c', + 'resource_manager.c', +) diff --git a/src/backend/utils/resscheduler/meson.build b/src/backend/utils/resscheduler/meson.build new file mode 100644 index 00000000000..772c81f5aa8 --- /dev/null +++ b/src/backend/utils/resscheduler/meson.build @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'resqueue.c', + 'resscheduler.c', +) diff --git a/src/backend/utils/time/meson.build b/src/backend/utils/time/meson.build index 36166b20bfa..75da0af6c01 100644 --- a/src/backend/utils/time/meson.build +++ b/src/backend/utils/time/meson.build @@ -3,4 +3,5 @@ backend_sources += files( 'combocid.c', 'snapmgr.c', + 'sharedsnapshot.c', ) diff --git a/src/backend/utils/workfile_manager/meson.build b/src/backend/utils/workfile_manager/meson.build new file mode 100644 index 00000000000..4d99c8d19b2 --- /dev/null +++ b/src/backend/utils/workfile_manager/meson.build @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +backend_sources += files( + 'workfile_mgr.c', +) diff --git a/src/bin/pg_dump/meson.build b/src/bin/pg_dump/meson.build index 9d59a106f36..79cdfd86192 100644 --- a/src/bin/pg_dump/meson.build +++ b/src/bin/pg_dump/meson.build @@ -15,6 +15,7 @@ pg_dump_common_sources = files( 'pg_backup_null.c', 'pg_backup_tar.c', 'pg_backup_utils.c', + 'dumputils_gp.c', ) pg_dump_common = static_library('libpgdump_common', diff --git a/src/bin/pg_upgrade/meson.build b/src/bin/pg_upgrade/meson.build index 12a97f84e29..f1b8ea1c73e 100644 --- a/src/bin/pg_upgrade/meson.build +++ b/src/bin/pg_upgrade/meson.build @@ -16,8 +16,19 @@ pg_upgrade_sources = files( 'tablespace.c', 'util.c', 'version.c', + # Cloudberry additions (OBJS += greenplum/... in this directory's Makefile) + 'greenplum/aotable.c', + 'greenplum/check_gp.c', + 'greenplum/controldata_gp.c', + 'greenplum/option_gp.c', + 'greenplum/reporting.c', + 'greenplum/util.c', + 'greenplum/version_gp.c', ) +# The Makefile symlinks this in from the backend; meson can reference it directly. +pg_upgrade_sources += files('../../backend/access/appendonly/aomd_filehandler.c') + if host_system == 'windows' pg_upgrade_sources += rc_bin_gen.process(win32ver_rc, extra_args: [ '--NAME', 'pg_upgrade', @@ -28,6 +39,9 @@ pg_upgrade = executable('pg_upgrade', pg_upgrade_sources, c_pch: pch_postgres_fe_h, dependencies: [frontend_code, libpq], + # greenplum/*.c include "pg_upgrade.h" from the parent directory + # (Makefile: override CPPFLAGS := -I$(srcdir) ...) + include_directories: include_directories('.'), kwargs: default_bin_args, ) bin_targets += pg_upgrade diff --git a/src/common/meson.build b/src/common/meson.build index 3e06ca11117..35daa726ca3 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -37,12 +37,14 @@ common_sources = files( if ssl.found() common_sources += files( + 'cipher_openssl.c', 'cryptohash_openssl.c', 'hmac_openssl.c', 'protocol_openssl.c', ) else common_sources += files( + 'cipher.c', 'cryptohash.c', 'hmac.c', 'md5.c', @@ -51,6 +53,13 @@ else ) endif +# Cloudberry additions built unconditionally (see OBJS_COMMON in ../common/Makefile) +common_sources += files( + 'etcdutils.c', + 'kmgr_utils.c', + 'sm3.c', +) + common_kwlist = custom_target('kwlist', input: files('../include/parser/kwlist.h'), output: 'kwlist_d.h', diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build index ea96e862adb..0bc04d40fa4 100644 --- a/src/fe_utils/meson.build +++ b/src/fe_utils/meson.build @@ -13,6 +13,7 @@ fe_utils_sources = files( 'recovery_gen.c', 'simple_list.c', 'string_utils.c', + 'log.c', ) psqlscan = custom_target('psqlscan', diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build index c3fd05d0279..f8aaf2d863e 100644 --- a/src/include/catalog/meson.build +++ b/src/include/catalog/meson.build @@ -65,8 +65,49 @@ catalog_headers = [ 'pg_publication_rel.h', 'pg_subscription.h', 'pg_subscription_rel.h', + + # Apache Cloudberry catalogs + 'pg_resqueue.h', + 'pg_resqueuecapability.h', + 'pg_resourcetype.h', + 'pg_resgroup.h', + 'pg_resgroupcapability.h', + 'gp_configuration_history.h', + 'gp_id.h', + 'gp_distribution_policy.h', + 'gp_version_at_initdb.h', + 'gp_warehouse.h', + 'pg_appendonly.h', + 'gp_fastsequence.h', + 'pg_extprotocol.h', + 'pg_attribute_encoding.h', + 'pg_auth_time_constraint.h', + 'pg_compression.h', + 'pg_proc_callback.h', + 'pg_type_encoding.h', + 'pg_stat_last_operation.h', + 'pg_stat_last_shoperation.h', + 'pg_foreign_table_seg.h', + 'gp_partition_template.h', + 'pg_task.h', + 'pg_task_run_history.h', + 'pg_profile.h', + 'pg_password_history.h', + 'pg_directory_table.h', + 'gp_storage_server.h', + 'gp_storage_user_mapping.h', + 'pg_tag.h', + 'pg_tag_description.h', + 'gp_matview_aux.h', + 'gp_matview_tables.h', ] +# gp_segment_configuration is only a catalog when the internal FTS is used. +# Mirrors: ifeq ($(USE_INTERNAL_FTS_FOUND), true) in ../../backend/catalog/Makefile +if not get_option('external_fts') + catalog_headers += ['gp_segment_configuration.h'] +endif + bki_data = [ 'pg_aggregate.dat', 'pg_am.dat', @@ -92,9 +133,30 @@ bki_data = [ 'pg_ts_parser.dat', 'pg_ts_template.dat', 'pg_type.dat', + + # Apache Cloudberry catalog data + 'pg_profile.dat', + 'pg_compression.dat', + 'pg_resgroup.dat', + 'pg_resgroupcapability.dat', ] bki_data_f = files(bki_data) +# gp_version_at_initdb.dat is generated from a template (autoconf does this via +# AC_CONFIG_FILES). genbki.pl derives each .dat path from its .h path, so the +# generated .dat and its header must sit in the same directory -- copy the +# header into the build dir next to the generated .dat. +gp_version_at_initdb_dat = configure_file( + input: 'gp_version_at_initdb.dat.in', + output: 'gp_version_at_initdb.dat', + configuration: {'GP_VERSION_LONG': gp_version_long}, +) +gp_version_at_initdb_h = configure_file( + input: 'gp_version_at_initdb.h', + output: 'gp_version_at_initdb.h', + copy: true, +) + input = [] output_files = ['postgres.bki', 'system_constraints.sql', 'schemapg.h', 'system_fk_info.h'] @@ -102,16 +164,27 @@ output_install = [dir_data, dir_data, dir_include_server / 'catalog', dir_includ foreach h : catalog_headers fname = h.split('.h')[0] + '_d.h' - input += files(h) + if h == 'gp_version_at_initdb.h' + input += gp_version_at_initdb_h + else + input += files(h) + endif output_files += fname output_install += dir_include_server / 'catalog' endforeach +# Extra BKI sources that are not catalogs themselves (no _d.h output). +# Mirrors POSTGRES_BKI_SRCS += ... in ../../backend/catalog/Makefile +input += files('gp_indexing.h') +if not get_option('external_fts') + input += files('gp_segment_configuration_indexing.h') +endif + generated_catalog_headers = custom_target('generated_catalog_headers', output: output_files, install_dir: output_install, input: input, - depend_files: bki_data_f + catalog_pm, + depend_files: bki_data_f + catalog_pm + [gp_version_at_initdb_dat], build_by_default: true, install: true, command: [ diff --git a/src/include/nodes/meson.build b/src/include/nodes/meson.build index 626dc696d51..a4732317034 100644 --- a/src/include/nodes/meson.build +++ b/src/include/nodes/meson.build @@ -1,65 +1,7 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group -node_support_input_i = [ - 'nodes/nodes.h', - 'nodes/primnodes.h', - 'nodes/parsenodes.h', - 'nodes/pathnodes.h', - 'nodes/plannodes.h', - 'nodes/execnodes.h', - 'access/amapi.h', - 'access/sdir.h', - 'access/tableam.h', - 'access/tsmapi.h', - 'commands/event_trigger.h', - 'commands/trigger.h', - 'executor/tuptable.h', - 'foreign/fdwapi.h', - 'nodes/bitmapset.h', - 'nodes/extensible.h', - 'nodes/lockoptions.h', - 'nodes/miscnodes.h', - 'nodes/replnodes.h', - 'nodes/supportnodes.h', - 'nodes/value.h', - 'utils/rel.h', -] - -node_support_input = [] -foreach i : node_support_input_i - node_support_input += meson.source_root() / 'src' / 'include' / i -endforeach - -node_support_output = [ - 'nodetags.h', - 'outfuncs.funcs.c', 'outfuncs.switch.c', - 'readfuncs.funcs.c', 'readfuncs.switch.c', - 'copyfuncs.funcs.c', 'copyfuncs.switch.c', - 'equalfuncs.funcs.c', 'equalfuncs.switch.c', - 'queryjumblefuncs.funcs.c', 'queryjumblefuncs.switch.c', -] -node_support_install = [ - dir_include_server / 'nodes', - false, false, - false, false, - false, false, - false, false, - false, false, -] - -generated_nodes = custom_target('nodetags.h', - input: node_support_input, - output: node_support_output, - depend_files: catalog_pm, - command: [ - perl, files('../../backend/nodes/gen_node_support.pl'), - '-o', '@OUTDIR@', - '@INPUT@'], - install: true, - install_dir: node_support_install, -) -generated_headers += generated_nodes[0] - -# autoconf generates the file there, ensure we get a conflict -generated_sources_ac += {'src/backend/nodes': node_support_output + ['node-support-stamp']} -generated_sources_ac += {'src/include/nodes': ['header-stamp']} +# Cloudberry does not use gen_node_support.pl: the NodeTag enum is maintained by +# hand in nodes.h, copyfuncs.funcs.c / copyfuncs.switch.c are committed to the +# repository and #included by copyfuncs.c, and outfuncs/readfuncs/equalfuncs are +# plain hand-written sources. src/backend/nodes/Makefile likewise never invokes +# the generator, so there is nothing to generate here. diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build index 8a2872c0eea..9ab53e73794 100644 --- a/src/interfaces/libpq/meson.build +++ b/src/interfaces/libpq/meson.build @@ -42,7 +42,12 @@ export_file = custom_target('libpq.exports', # port needs to be in include path due to pthread-win32.h libpq_inc = include_directories('.', '../../port') -libpq_c_args = ['-DSO_MAJOR_VERSION=5'] +# Cloudberry's libpq sources include "c.h" rather than "postgres_fe.h" because +# the same files are also compiled into the backend (see src/backend/libpq/ +# Makefile) and switch on the FRONTEND macro. postgres_fe.h is what normally +# defines FRONTEND, so the frontend build must define it explicitly. +# Mirrors: override CPPFLAGS := -DFRONTEND ... in this directory's Makefile. +libpq_c_args = ['-DSO_MAJOR_VERSION=5', '-DFRONTEND'] # Not using both_libraries() here as # 1) resource files should only be in the shared library diff --git a/src/interfaces/meson.build b/src/interfaces/meson.build index 75278bf801f..95ae006b783 100644 --- a/src/interfaces/meson.build +++ b/src/interfaces/meson.build @@ -1,4 +1,7 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group # NB: libpq is entered directly from the toplevel meson file -subdir('ecpg') +# Cloudberry does not build ecpg -- src/interfaces/Makefile has it commented +# out of SUBDIRS (only libpq is built). Keep the variable defined so the +# top-level meson.build can still reference it. +ecpg_targets = [] From d82bf27886f78b9b6ec8fcba663a3e5b3d1bce11 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 29 Aug 2026 10:10:12 +0800 Subject: [PATCH 02/13] meson: build ORCA ORCA is 945 C++ translation units spread over 34 near-identical leaf Makefiles that only emit objfiles.txt. In meson the whole tree collapses to two files, built as static libraries and linked whole into the backend: - C++ is enabled before the LLVM block, gated on the orca option, because upstream only enables it for the JIT - xerces-c is probed with a library check plus a header check honouring extra_include_dirs / extra_lib_dirs, and scoped to the ORCA targets rather than leaked into the global LIBS the way configure does - cpp_std=c++14 as an option, where configure appends -std=c++14 to CXX - the strict -Werror -Wextra -Wpedantic triple is kept on Linux and dropped on darwin, matching gporca.mk - postgres gets link_language: 'cpp', since src/backend/Makefile links it with $(CXX) and meson would otherwise pick the C driver libpq_binddomain() used ldir without declaring it. That code only compiles under ENABLE_NLS, which Cloudberry does not build, so it had never been reached; the declaration is restored from upstream anyway. Verified: 3048 targets build, initdb succeeds, gp_opt_version() reports "GPOPT version: 4.0.0, Xerces version: 3.3.0", and a query planned by ORCA returns the expected rows. Assisted-by: Claude Code --- meson.build | 48 +- src/backend/gpopt/meson.build | 60 ++ src/backend/gporca/meson.build | 968 +++++++++++++++++++++++++++++++++ src/backend/meson.build | 12 + src/interfaces/libpq/fe-misc.c | 2 + 5 files changed, 1087 insertions(+), 3 deletions(-) create mode 100644 src/backend/gpopt/meson.build create mode 100644 src/backend/gporca/meson.build diff --git a/meson.build b/meson.build index 49e8189f018..d1acde5a132 100644 --- a/meson.build +++ b/meson.build @@ -788,6 +788,48 @@ endif +############################################################### +# Language: C++ (ORCA, and the LLVM JIT below) +############################################################### + +# Cloudberry's ORCA optimizer is C++, so the C++ compiler has to be available +# whenever ORCA is built. Upstream only enables C++ for the LLVM JIT, which is +# why this has to happen before the LLVM block. add_languages() is idempotent, +# so LLVM's own call below still works. +orcaopt = get_option('orca') +have_cpp = add_languages('cpp', required: orcaopt, native: false) + +# Xerces-C, ORCA's only external dependency. +# +# configure.ac only does AC_CHECK_LIB(xerces-c, strnicmp) -- a C-mode link +# probe with no include path, no version floor and no check for the Cloudberry +# patch that cmake/FindXerces.cmake says is required. Probe properly here, and +# scope the dependency to the ORCA targets instead of leaking -lxerces-c into +# the global LIBS the way configure does. +xerces = not_found_dep +if not orcaopt.disabled() + if not have_cpp + if orcaopt.enabled() + error('ORCA requires a C++ compiler') + endif + else + cpp = meson.get_compiler('cpp') + # Honour --with-libraries / --with-includes equivalents so xerces can live + # outside the default search path (as it does in the CI image). + xerces_probe_args = [] + foreach d : get_option('extra_include_dirs') + xerces_probe_args += '-I' + d + endforeach + xerces_lib = cpp.find_library('xerces-c', dirs: postgres_lib_d, required: orcaopt) + if xerces_lib.found() and cpp.has_header('xercesc/sax2/DefaultHandler.hpp', + dependencies: xerces_lib, args: xerces_probe_args) + xerces = xerces_lib + elif orcaopt.enabled() + error('ORCA requires xerces-c (library and headers)') + endif + endif +endif + ############################################################### # Library: LLVM ############################################################### @@ -2971,9 +3013,9 @@ cdata.set_quoted('GP_VERSION', gp_version_long) cdata.set_quoted('GP_MAJORVERSION', gp_majorversion) cdata.set('GP_VERSION_NUM', gp_version_num) -# ORCA optimizer -orcaopt = get_option('orca') -if orcaopt.enabled() +# ORCA optimizer (orcaopt / xerces are resolved near the top of this file, +# because enabling C++ has to happen before any C++ target is defined) +if xerces.found() cdata.set('USE_ORCA', 1) # GPOS_DEBUG is ABI-affecting: it is tested by ~475 files under # src/backend/gporca and changes class layouts. It must be a single value diff --git a/src/backend/gpopt/meson.build b/src/backend/gpopt/meson.build new file mode 100644 index 00000000000..84009dcc228 --- /dev/null +++ b/src/backend/gpopt/meson.build @@ -0,0 +1,60 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# +# The translator layer between the GPDB planner and ORCA. Its sources include +# backend headers inside extern "C", including generated ones (fmgroids.h, +# catalog/pg_*), so the generated headers must be an explicit dependency. + +gpopt_sources = files( + 'CGPOptimizer.cpp', + 'config/CConfigParamMapping.cpp', + 'gpdbwrappers.cpp', + 'relcache/CMDProviderRelcache.cpp', + 'translate/CCTEListEntry.cpp', + 'translate/CContextDXLToPlStmt.cpp', + 'translate/CContextQueryToDXL.cpp', + 'translate/CDXLTranslateContext.cpp', + 'translate/CDXLTranslateContextBaseTable.cpp', + 'translate/CMappingColIdVar.cpp', + 'translate/CMappingColIdVarPlStmt.cpp', + 'translate/CMappingElementColIdParamId.cpp', + 'translate/CMappingVarColId.cpp', + 'translate/CPartPruneStepsBuilder.cpp', + 'translate/CQueryMutators.cpp', + 'translate/CTranslatorDXLToPlStmt.cpp', + 'translate/CTranslatorDXLToScalar.cpp', + 'translate/CTranslatorQueryToDXL.cpp', + 'translate/CTranslatorRelcacheToDXL.cpp', + 'translate/CTranslatorScalarToDXL.cpp', + 'translate/CTranslatorUtils.cpp', + 'utils/CConstExprEvaluatorProxy.cpp', + 'utils/CMemoryPoolPalloc.cpp', + 'utils/CMemoryPoolPallocManager.cpp', + 'utils/COptTasks.cpp', + 'utils/RelationWrapper.cpp', + 'utils/funcs.cpp', +) + +gpopt = static_library('gpopt', + gpopt_sources, + include_directories: [orca_inc, postgres_inc], + dependencies: [backend_code, xerces], + cpp_args: ['-fno-omit-frame-pointer'], + override_options: ['cpp_std=c++14'], + kwargs: internal_lib_args, +) +backend_link_with += gpopt diff --git a/src/backend/gporca/meson.build b/src/backend/gporca/meson.build new file mode 100644 index 00000000000..5d628d1e4e6 --- /dev/null +++ b/src/backend/gporca/meson.build @@ -0,0 +1,968 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# +# ORCA is built as one static library and linked whole into the backend. The +# Makefiles keep 34 near-identical leaf files that only emit objfiles.txt; in +# meson the whole tree collapses to this single file. + +orca_inc = include_directories( + 'libgpos/include', + 'libgpopt/include', + 'libnaucrates/include', + 'libgpdbcost/include', +) + +# gporca.mk: do not omit the frame pointer (used for backtraces even in +# release builds). Linux tolerates the strict triple; Apple clang emits many +# more diagnostics under it, so it is dropped there -- same split as the .mk. +orca_cpp_args = ['-fno-omit-frame-pointer'] +if host_machine.system() != 'darwin' + orca_cpp_args += ['-Werror', '-Wextra', '-Wpedantic'] +endif + +orca_sources = files( + 'libgpdbcost/src/CCostModelGPDB.cpp', + 'libgpdbcost/src/CCostModelParamsGPDB.cpp', + 'libgpdbcost/src/ICostModel.cpp', + 'libgpopt/src/base/CAutoOptCtxt.cpp', + 'libgpopt/src/base/CCTEInfo.cpp', + 'libgpopt/src/base/CCTEMap.cpp', + 'libgpopt/src/base/CCTEReq.cpp', + 'libgpopt/src/base/CCastUtils.cpp', + 'libgpopt/src/base/CColConstraintsArrayMapper.cpp', + 'libgpopt/src/base/CColConstraintsHashMapper.cpp', + 'libgpopt/src/base/CColRef.cpp', + 'libgpopt/src/base/CColRefComputed.cpp', + 'libgpopt/src/base/CColRefSet.cpp', + 'libgpopt/src/base/CColRefSetIter.cpp', + 'libgpopt/src/base/CColRefTable.cpp', + 'libgpopt/src/base/CColumnFactory.cpp', + 'libgpopt/src/base/CConstraint.cpp', + 'libgpopt/src/base/CConstraintConjunction.cpp', + 'libgpopt/src/base/CConstraintDisjunction.cpp', + 'libgpopt/src/base/CConstraintInterval.cpp', + 'libgpopt/src/base/CConstraintNegation.cpp', + 'libgpopt/src/base/CCostContext.cpp', + 'libgpopt/src/base/CDatumSortedSet.cpp', + 'libgpopt/src/base/CDefaultComparator.cpp', + 'libgpopt/src/base/CDistributionSpecHashed.cpp', + 'libgpopt/src/base/CDistributionSpecHashedNoOp.cpp', + 'libgpopt/src/base/CDistributionSpecNonSingleton.cpp', + 'libgpopt/src/base/CDistributionSpecRandom.cpp', + 'libgpopt/src/base/CDistributionSpecReplicated.cpp', + 'libgpopt/src/base/CDistributionSpecRouted.cpp', + 'libgpopt/src/base/CDistributionSpecSingleton.cpp', + 'libgpopt/src/base/CDistributionSpecStrictHashed.cpp', + 'libgpopt/src/base/CDistributionSpecStrictRandom.cpp', + 'libgpopt/src/base/CDistributionSpecStrictSingleton.cpp', + 'libgpopt/src/base/CDistributionSpecUniversal.cpp', + 'libgpopt/src/base/CDistributionSpecWorkerRandom.cpp', + 'libgpopt/src/base/CDrvdProp.cpp', + 'libgpopt/src/base/CDrvdPropCtxt.cpp', + 'libgpopt/src/base/CDrvdPropCtxtPlan.cpp', + 'libgpopt/src/base/CDrvdPropPlan.cpp', + 'libgpopt/src/base/CDrvdPropRelational.cpp', + 'libgpopt/src/base/CDrvdPropScalar.cpp', + 'libgpopt/src/base/CEnfdDistribution.cpp', + 'libgpopt/src/base/CEnfdOrder.cpp', + 'libgpopt/src/base/CEnfdPartitionPropagation.cpp', + 'libgpopt/src/base/CEnfdProp.cpp', + 'libgpopt/src/base/CEnfdRewindability.cpp', + 'libgpopt/src/base/CFunctionProp.cpp', + 'libgpopt/src/base/CFunctionalDependency.cpp', + 'libgpopt/src/base/CIOUtils.cpp', + 'libgpopt/src/base/CKeyCollection.cpp', + 'libgpopt/src/base/COptCtxt.cpp', + 'libgpopt/src/base/COptimizationContext.cpp', + 'libgpopt/src/base/COrderSpec.cpp', + 'libgpopt/src/base/CPartInfo.cpp', + 'libgpopt/src/base/CPartKeys.cpp', + 'libgpopt/src/base/CPartitionPropagationSpec.cpp', + 'libgpopt/src/base/CPrintPrefix.cpp', + 'libgpopt/src/base/CPropConstraint.cpp', + 'libgpopt/src/base/CQueryContext.cpp', + 'libgpopt/src/base/CRange.cpp', + 'libgpopt/src/base/CReqdProp.cpp', + 'libgpopt/src/base/CReqdPropPlan.cpp', + 'libgpopt/src/base/CReqdPropRelational.cpp', + 'libgpopt/src/base/CRewindabilitySpec.cpp', + 'libgpopt/src/base/CUtils.cpp', + 'libgpopt/src/base/CWindowFrame.cpp', + 'libgpopt/src/base/CWindowOids.cpp', + 'libgpopt/src/base/IColConstraintsMapper.cpp', + 'libgpopt/src/engine/CEngine.cpp', + 'libgpopt/src/engine/CEnumeratorConfig.cpp', + 'libgpopt/src/engine/CPartialPlan.cpp', + 'libgpopt/src/engine/CStatisticsConfig.cpp', + 'libgpopt/src/eval/CConstExprEvaluatorDXL.cpp', + 'libgpopt/src/eval/CConstExprEvaluatorDefault.cpp', + 'libgpopt/src/exception.cpp', + 'libgpopt/src/hints/CHintUtils.cpp', + 'libgpopt/src/hints/CJoinHint.cpp', + 'libgpopt/src/hints/CJoinTypeHint.cpp', + 'libgpopt/src/hints/CPlanHint.cpp', + 'libgpopt/src/hints/CRowHint.cpp', + 'libgpopt/src/hints/CScanHint.cpp', + 'libgpopt/src/init.cpp', + 'libgpopt/src/mdcache/CMDAccessor.cpp', + 'libgpopt/src/mdcache/CMDAccessorUtils.cpp', + 'libgpopt/src/mdcache/CMDCache.cpp', + 'libgpopt/src/mdcache/CMDKey.cpp', + 'libgpopt/src/metadata/CColumnDescriptor.cpp', + 'libgpopt/src/metadata/CIndexDescriptor.cpp', + 'libgpopt/src/metadata/CName.cpp', + 'libgpopt/src/metadata/CTableDescriptor.cpp', + 'libgpopt/src/minidump/CDXLMinidump.cpp', + 'libgpopt/src/minidump/CMetadataAccessorFactory.cpp', + 'libgpopt/src/minidump/CMiniDumperDXL.cpp', + 'libgpopt/src/minidump/CMinidumperUtils.cpp', + 'libgpopt/src/minidump/CSerializableMDAccessor.cpp', + 'libgpopt/src/minidump/CSerializableOptimizerConfig.cpp', + 'libgpopt/src/minidump/CSerializablePlan.cpp', + 'libgpopt/src/minidump/CSerializableQuery.cpp', + 'libgpopt/src/minidump/CSerializableStackTrace.cpp', + 'libgpopt/src/operators/CDedupSupersetPreprocessor.cpp', + 'libgpopt/src/operators/CExpression.cpp', + 'libgpopt/src/operators/CExpressionFactorizer.cpp', + 'libgpopt/src/operators/CExpressionHandle.cpp', + 'libgpopt/src/operators/CExpressionPreprocessor.cpp', + 'libgpopt/src/operators/CExpressionUtils.cpp', + 'libgpopt/src/operators/CHashedDistributions.cpp', + 'libgpopt/src/operators/CJoinOrderHintsPreprocessor.cpp', + 'libgpopt/src/operators/CLeftJoinPruningPreprocessor.cpp', + 'libgpopt/src/operators/CLogical.cpp', + 'libgpopt/src/operators/CLogicalApply.cpp', + 'libgpopt/src/operators/CLogicalAssert.cpp', + 'libgpopt/src/operators/CLogicalBitmapTableGet.cpp', + 'libgpopt/src/operators/CLogicalCTEAnchor.cpp', + 'libgpopt/src/operators/CLogicalCTEConsumer.cpp', + 'libgpopt/src/operators/CLogicalCTEProducer.cpp', + 'libgpopt/src/operators/CLogicalConstTableGet.cpp', + 'libgpopt/src/operators/CLogicalDML.cpp', + 'libgpopt/src/operators/CLogicalDelete.cpp', + 'libgpopt/src/operators/CLogicalDifference.cpp', + 'libgpopt/src/operators/CLogicalDifferenceAll.cpp', + 'libgpopt/src/operators/CLogicalDynamicBitmapTableGet.cpp', + 'libgpopt/src/operators/CLogicalDynamicForeignGet.cpp', + 'libgpopt/src/operators/CLogicalDynamicGet.cpp', + 'libgpopt/src/operators/CLogicalDynamicGetBase.cpp', + 'libgpopt/src/operators/CLogicalDynamicIndexGet.cpp', + 'libgpopt/src/operators/CLogicalForeignGet.cpp', + 'libgpopt/src/operators/CLogicalFullOuterJoin.cpp', + 'libgpopt/src/operators/CLogicalGbAgg.cpp', + 'libgpopt/src/operators/CLogicalGbAggDeduplicate.cpp', + 'libgpopt/src/operators/CLogicalGet.cpp', + 'libgpopt/src/operators/CLogicalIndexApply.cpp', + 'libgpopt/src/operators/CLogicalIndexGet.cpp', + 'libgpopt/src/operators/CLogicalInnerApply.cpp', + 'libgpopt/src/operators/CLogicalInnerCorrelatedApply.cpp', + 'libgpopt/src/operators/CLogicalInnerJoin.cpp', + 'libgpopt/src/operators/CLogicalInsert.cpp', + 'libgpopt/src/operators/CLogicalIntersect.cpp', + 'libgpopt/src/operators/CLogicalIntersectAll.cpp', + 'libgpopt/src/operators/CLogicalJoin.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiApply.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiApplyNotIn.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiCorrelatedApply.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiCorrelatedApplyNotIn.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiJoin.cpp', + 'libgpopt/src/operators/CLogicalLeftAntiSemiJoinNotIn.cpp', + 'libgpopt/src/operators/CLogicalLeftOuterApply.cpp', + 'libgpopt/src/operators/CLogicalLeftOuterCorrelatedApply.cpp', + 'libgpopt/src/operators/CLogicalLeftOuterJoin.cpp', + 'libgpopt/src/operators/CLogicalLeftSemiApply.cpp', + 'libgpopt/src/operators/CLogicalLeftSemiApplyIn.cpp', + 'libgpopt/src/operators/CLogicalLeftSemiCorrelatedApply.cpp', + 'libgpopt/src/operators/CLogicalLeftSemiCorrelatedApplyIn.cpp', + 'libgpopt/src/operators/CLogicalLeftSemiJoin.cpp', + 'libgpopt/src/operators/CLogicalLimit.cpp', + 'libgpopt/src/operators/CLogicalMaxOneRow.cpp', + 'libgpopt/src/operators/CLogicalNAryJoin.cpp', + 'libgpopt/src/operators/CLogicalProject.cpp', + 'libgpopt/src/operators/CLogicalRightOuterJoin.cpp', + 'libgpopt/src/operators/CLogicalSelect.cpp', + 'libgpopt/src/operators/CLogicalSequence.cpp', + 'libgpopt/src/operators/CLogicalSequenceProject.cpp', + 'libgpopt/src/operators/CLogicalSetOp.cpp', + 'libgpopt/src/operators/CLogicalSplit.cpp', + 'libgpopt/src/operators/CLogicalTVF.cpp', + 'libgpopt/src/operators/CLogicalUnary.cpp', + 'libgpopt/src/operators/CLogicalUnion.cpp', + 'libgpopt/src/operators/CLogicalUnionAll.cpp', + 'libgpopt/src/operators/CLogicalUpdate.cpp', + 'libgpopt/src/operators/CNormalizer.cpp', + 'libgpopt/src/operators/COperator.cpp', + 'libgpopt/src/operators/COrderedAggPreprocessor.cpp', + 'libgpopt/src/operators/CPattern.cpp', + 'libgpopt/src/operators/CPhysical.cpp', + 'libgpopt/src/operators/CPhysicalAgg.cpp', + 'libgpopt/src/operators/CPhysicalAssert.cpp', + 'libgpopt/src/operators/CPhysicalBitmapTableScan.cpp', + 'libgpopt/src/operators/CPhysicalCTEConsumer.cpp', + 'libgpopt/src/operators/CPhysicalCTEProducer.cpp', + 'libgpopt/src/operators/CPhysicalComputeScalar.cpp', + 'libgpopt/src/operators/CPhysicalConstTableGet.cpp', + 'libgpopt/src/operators/CPhysicalDML.cpp', + 'libgpopt/src/operators/CPhysicalDynamicBitmapTableScan.cpp', + 'libgpopt/src/operators/CPhysicalDynamicForeignScan.cpp', + 'libgpopt/src/operators/CPhysicalDynamicIndexOnlyScan.cpp', + 'libgpopt/src/operators/CPhysicalDynamicIndexScan.cpp', + 'libgpopt/src/operators/CPhysicalDynamicScan.cpp', + 'libgpopt/src/operators/CPhysicalDynamicTableScan.cpp', + 'libgpopt/src/operators/CPhysicalFilter.cpp', + 'libgpopt/src/operators/CPhysicalForeignScan.cpp', + 'libgpopt/src/operators/CPhysicalFullHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalFullMergeJoin.cpp', + 'libgpopt/src/operators/CPhysicalHashAgg.cpp', + 'libgpopt/src/operators/CPhysicalHashAggDeduplicate.cpp', + 'libgpopt/src/operators/CPhysicalHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalHashSequenceProject.cpp', + 'libgpopt/src/operators/CPhysicalIndexOnlyScan.cpp', + 'libgpopt/src/operators/CPhysicalIndexScan.cpp', + 'libgpopt/src/operators/CPhysicalInnerHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalInnerIndexNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalInnerNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftAntiSemiHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftAntiSemiHashJoinNotIn.cpp', + 'libgpopt/src/operators/CPhysicalLeftAntiSemiNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftOuterHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftOuterIndexNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftOuterNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftSemiHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalLeftSemiNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalLimit.cpp', + 'libgpopt/src/operators/CPhysicalMotion.cpp', + 'libgpopt/src/operators/CPhysicalMotionBroadcast.cpp', + 'libgpopt/src/operators/CPhysicalMotionGather.cpp', + 'libgpopt/src/operators/CPhysicalMotionHashDistribute.cpp', + 'libgpopt/src/operators/CPhysicalMotionRandom.cpp', + 'libgpopt/src/operators/CPhysicalMotionRoutedDistribute.cpp', + 'libgpopt/src/operators/CPhysicalNLJoin.cpp', + 'libgpopt/src/operators/CPhysicalParallelTableScan.cpp', + 'libgpopt/src/operators/CPhysicalParallelUnionAll.cpp', + 'libgpopt/src/operators/CPhysicalPartitionSelector.cpp', + 'libgpopt/src/operators/CPhysicalRightOuterHashJoin.cpp', + 'libgpopt/src/operators/CPhysicalScalarAgg.cpp', + 'libgpopt/src/operators/CPhysicalScan.cpp', + 'libgpopt/src/operators/CPhysicalSequence.cpp', + 'libgpopt/src/operators/CPhysicalSequenceProject.cpp', + 'libgpopt/src/operators/CPhysicalSerialUnionAll.cpp', + 'libgpopt/src/operators/CPhysicalSort.cpp', + 'libgpopt/src/operators/CPhysicalSplit.cpp', + 'libgpopt/src/operators/CPhysicalSpool.cpp', + 'libgpopt/src/operators/CPhysicalStreamAgg.cpp', + 'libgpopt/src/operators/CPhysicalStreamAggDeduplicate.cpp', + 'libgpopt/src/operators/CPhysicalTVF.cpp', + 'libgpopt/src/operators/CPhysicalTableScan.cpp', + 'libgpopt/src/operators/CPhysicalUnionAll.cpp', + 'libgpopt/src/operators/CPhysicalUnionAllFactory.cpp', + 'libgpopt/src/operators/CPredicateUtils.cpp', + 'libgpopt/src/operators/CScalar.cpp', + 'libgpopt/src/operators/CScalarAggFunc.cpp', + 'libgpopt/src/operators/CScalarArray.cpp', + 'libgpopt/src/operators/CScalarArrayCmp.cpp', + 'libgpopt/src/operators/CScalarArrayCoerceExpr.cpp', + 'libgpopt/src/operators/CScalarArrayRef.cpp', + 'libgpopt/src/operators/CScalarArrayRefIndexList.cpp', + 'libgpopt/src/operators/CScalarAssertConstraint.cpp', + 'libgpopt/src/operators/CScalarAssertConstraintList.cpp', + 'libgpopt/src/operators/CScalarBitmapBoolOp.cpp', + 'libgpopt/src/operators/CScalarBitmapIndexProbe.cpp', + 'libgpopt/src/operators/CScalarBoolOp.cpp', + 'libgpopt/src/operators/CScalarBooleanTest.cpp', + 'libgpopt/src/operators/CScalarCaseTest.cpp', + 'libgpopt/src/operators/CScalarCast.cpp', + 'libgpopt/src/operators/CScalarCmp.cpp', + 'libgpopt/src/operators/CScalarCoalesce.cpp', + 'libgpopt/src/operators/CScalarCoerceBase.cpp', + 'libgpopt/src/operators/CScalarCoerceToDomain.cpp', + 'libgpopt/src/operators/CScalarCoerceViaIO.cpp', + 'libgpopt/src/operators/CScalarConst.cpp', + 'libgpopt/src/operators/CScalarDMLAction.cpp', + 'libgpopt/src/operators/CScalarFieldSelect.cpp', + 'libgpopt/src/operators/CScalarFunc.cpp', + 'libgpopt/src/operators/CScalarIdent.cpp', + 'libgpopt/src/operators/CScalarIf.cpp', + 'libgpopt/src/operators/CScalarIsDistinctFrom.cpp', + 'libgpopt/src/operators/CScalarMinMax.cpp', + 'libgpopt/src/operators/CScalarNAryJoinPredList.cpp', + 'libgpopt/src/operators/CScalarNullIf.cpp', + 'libgpopt/src/operators/CScalarNullTest.cpp', + 'libgpopt/src/operators/CScalarOp.cpp', + 'libgpopt/src/operators/CScalarParam.cpp', + 'libgpopt/src/operators/CScalarProjectElement.cpp', + 'libgpopt/src/operators/CScalarProjectList.cpp', + 'libgpopt/src/operators/CScalarSortGroupClause.cpp', + 'libgpopt/src/operators/CScalarSubquery.cpp', + 'libgpopt/src/operators/CScalarSubqueryAll.cpp', + 'libgpopt/src/operators/CScalarSubqueryAny.cpp', + 'libgpopt/src/operators/CScalarSubqueryExistential.cpp', + 'libgpopt/src/operators/CScalarSubqueryQuantified.cpp', + 'libgpopt/src/operators/CScalarSwitch.cpp', + 'libgpopt/src/operators/CScalarSwitchCase.cpp', + 'libgpopt/src/operators/CScalarValuesList.cpp', + 'libgpopt/src/operators/CScalarWindowFunc.cpp', + 'libgpopt/src/operators/CStrictHashedDistributions.cpp', + 'libgpopt/src/optimizer/COptimizer.cpp', + 'libgpopt/src/optimizer/COptimizerConfig.cpp', + 'libgpopt/src/search/CBinding.cpp', + 'libgpopt/src/search/CGroup.cpp', + 'libgpopt/src/search/CGroupExpression.cpp', + 'libgpopt/src/search/CGroupProxy.cpp', + 'libgpopt/src/search/CJob.cpp', + 'libgpopt/src/search/CJobFactory.cpp', + 'libgpopt/src/search/CJobGroup.cpp', + 'libgpopt/src/search/CJobGroupExploration.cpp', + 'libgpopt/src/search/CJobGroupExpression.cpp', + 'libgpopt/src/search/CJobGroupExpressionExploration.cpp', + 'libgpopt/src/search/CJobGroupExpressionImplementation.cpp', + 'libgpopt/src/search/CJobGroupExpressionOptimization.cpp', + 'libgpopt/src/search/CJobGroupImplementation.cpp', + 'libgpopt/src/search/CJobGroupOptimization.cpp', + 'libgpopt/src/search/CJobQueue.cpp', + 'libgpopt/src/search/CJobTest.cpp', + 'libgpopt/src/search/CJobTransformation.cpp', + 'libgpopt/src/search/CMemo.cpp', + 'libgpopt/src/search/CScheduler.cpp', + 'libgpopt/src/search/CSchedulerContext.cpp', + 'libgpopt/src/search/CSearchStage.cpp', + 'libgpopt/src/translate/CTranslatorDXLToExpr.cpp', + 'libgpopt/src/translate/CTranslatorDXLToExprUtils.cpp', + 'libgpopt/src/translate/CTranslatorExprToDXL.cpp', + 'libgpopt/src/translate/CTranslatorExprToDXLUtils.cpp', + 'libgpopt/src/xforms/CDecorrelator.cpp', + 'libgpopt/src/xforms/CJoinOrder.cpp', + 'libgpopt/src/xforms/CJoinOrderDP.cpp', + 'libgpopt/src/xforms/CJoinOrderDPv2.cpp', + 'libgpopt/src/xforms/CJoinOrderGreedy.cpp', + 'libgpopt/src/xforms/CJoinOrderMinCard.cpp', + 'libgpopt/src/xforms/CSubqueryHandler.cpp', + 'libgpopt/src/xforms/CXform.cpp', + 'libgpopt/src/xforms/CXformCTEAnchor2Sequence.cpp', + 'libgpopt/src/xforms/CXformCTEAnchor2TrivialSelect.cpp', + 'libgpopt/src/xforms/CXformCollapseGbAgg.cpp', + 'libgpopt/src/xforms/CXformCollapseProject.cpp', + 'libgpopt/src/xforms/CXformDelete2DML.cpp', + 'libgpopt/src/xforms/CXformDifference2LeftAntiSemiJoin.cpp', + 'libgpopt/src/xforms/CXformDifferenceAll2LeftAntiSemiJoin.cpp', + 'libgpopt/src/xforms/CXformDynamicForeignGet2DynamicForeignScan.cpp', + 'libgpopt/src/xforms/CXformDynamicGet2DynamicTableScan.cpp', + 'libgpopt/src/xforms/CXformDynamicIndexGet2DynamicIndexScan.cpp', + 'libgpopt/src/xforms/CXformDynamicIndexOnlyGet2DynamicIndexOnlyScan.cpp', + 'libgpopt/src/xforms/CXformEagerAgg.cpp', + 'libgpopt/src/xforms/CXformExpandDynamicGetWithForeignPartitions.cpp', + 'libgpopt/src/xforms/CXformExpandFullOuterJoin.cpp', + 'libgpopt/src/xforms/CXformExpandNAryJoin.cpp', + 'libgpopt/src/xforms/CXformExpandNAryJoinDP.cpp', + 'libgpopt/src/xforms/CXformExpandNAryJoinDPv2.cpp', + 'libgpopt/src/xforms/CXformExpandNAryJoinGreedy.cpp', + 'libgpopt/src/xforms/CXformExpandNAryJoinMinCard.cpp', + 'libgpopt/src/xforms/CXformExploration.cpp', + 'libgpopt/src/xforms/CXformFactory.cpp', + 'libgpopt/src/xforms/CXformForeignGet2ForeignScan.cpp', + 'libgpopt/src/xforms/CXformFullJoinCommutativity.cpp', + 'libgpopt/src/xforms/CXformFullOuterJoin2HashJoin.cpp', + 'libgpopt/src/xforms/CXformGbAgg2Apply.cpp', + 'libgpopt/src/xforms/CXformGbAgg2HashAgg.cpp', + 'libgpopt/src/xforms/CXformGbAgg2ScalarAgg.cpp', + 'libgpopt/src/xforms/CXformGbAgg2StreamAgg.cpp', + 'libgpopt/src/xforms/CXformGbAggDedup2HashAggDedup.cpp', + 'libgpopt/src/xforms/CXformGbAggDedup2StreamAggDedup.cpp', + 'libgpopt/src/xforms/CXformGbAggWithMDQA2Join.cpp', + 'libgpopt/src/xforms/CXformGet2ParallelTableScan.cpp', + 'libgpopt/src/xforms/CXformGet2TableScan.cpp', + 'libgpopt/src/xforms/CXformImplementAssert.cpp', + 'libgpopt/src/xforms/CXformImplementBitmapTableGet.cpp', + 'libgpopt/src/xforms/CXformImplementCTEConsumer.cpp', + 'libgpopt/src/xforms/CXformImplementCTEProducer.cpp', + 'libgpopt/src/xforms/CXformImplementConstTableGet.cpp', + 'libgpopt/src/xforms/CXformImplementDML.cpp', + 'libgpopt/src/xforms/CXformImplementDynamicBitmapTableGet.cpp', + 'libgpopt/src/xforms/CXformImplementFullOuterMergeJoin.cpp', + 'libgpopt/src/xforms/CXformImplementHashSequenceProject.cpp', + 'libgpopt/src/xforms/CXformImplementInnerJoin.cpp', + 'libgpopt/src/xforms/CXformImplementLimit.cpp', + 'libgpopt/src/xforms/CXformImplementSequence.cpp', + 'libgpopt/src/xforms/CXformImplementSequenceProject.cpp', + 'libgpopt/src/xforms/CXformImplementSplit.cpp', + 'libgpopt/src/xforms/CXformImplementTVF.cpp', + 'libgpopt/src/xforms/CXformImplementTVFNoArgs.cpp', + 'libgpopt/src/xforms/CXformImplementUnionAll.cpp', + 'libgpopt/src/xforms/CXformImplementation.cpp', + 'libgpopt/src/xforms/CXformIndexGet2IndexScan.cpp', + 'libgpopt/src/xforms/CXformIndexOnlyGet2IndexOnlyScan.cpp', + 'libgpopt/src/xforms/CXformInlineCTEConsumer.cpp', + 'libgpopt/src/xforms/CXformInlineCTEConsumerUnderSelect.cpp', + 'libgpopt/src/xforms/CXformInnerApply2InnerJoin.cpp', + 'libgpopt/src/xforms/CXformInnerApply2InnerJoinNoCorrelations.cpp', + 'libgpopt/src/xforms/CXformInnerApplyWithOuterKey2InnerJoin.cpp', + 'libgpopt/src/xforms/CXformInnerJoinCommutativity.cpp', + 'libgpopt/src/xforms/CXformInsert2DML.cpp', + 'libgpopt/src/xforms/CXformIntersect2Join.cpp', + 'libgpopt/src/xforms/CXformIntersectAll2LeftSemiJoin.cpp', + 'libgpopt/src/xforms/CXformJoin2IndexApply.cpp', + 'libgpopt/src/xforms/CXformJoin2IndexApplyGeneric.cpp', + 'libgpopt/src/xforms/CXformJoinAssociativity.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiApply2LeftAntiSemiJoin.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiApply2LeftAntiSemiJoinNoCorrelations.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiApplyNotIn2LeftAntiSemiJoinNotIn.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiApplyNotIn2LeftAntiSemiJoinNotInNoCorrelations.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiJoin2CrossProduct.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiJoin2HashJoin.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiJoin2NLJoin.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiJoinNotIn2HashJoinNotIn.cpp', + 'libgpopt/src/xforms/CXformLeftAntiSemiJoinNotIn2NLJoinNotIn.cpp', + 'libgpopt/src/xforms/CXformLeftJoin2RightJoin.cpp', + 'libgpopt/src/xforms/CXformLeftOuter2InnerUnionAllLeftAntiSemiJoin.cpp', + 'libgpopt/src/xforms/CXformLeftOuterApply2LeftOuterJoin.cpp', + 'libgpopt/src/xforms/CXformLeftOuterApply2LeftOuterJoinNoCorrelations.cpp', + 'libgpopt/src/xforms/CXformLeftOuterJoin2HashJoin.cpp', + 'libgpopt/src/xforms/CXformLeftOuterJoin2NLJoin.cpp', + 'libgpopt/src/xforms/CXformLeftSemiApply2LeftSemiJoin.cpp', + 'libgpopt/src/xforms/CXformLeftSemiApply2LeftSemiJoinNoCorrelations.cpp', + 'libgpopt/src/xforms/CXformLeftSemiApplyWithExternalCorrs2InnerJoin.cpp', + 'libgpopt/src/xforms/CXformLeftSemiJoin2CrossProduct.cpp', + 'libgpopt/src/xforms/CXformLeftSemiJoin2HashJoin.cpp', + 'libgpopt/src/xforms/CXformLeftSemiJoin2InnerJoin.cpp', + 'libgpopt/src/xforms/CXformLeftSemiJoin2InnerJoinUnderGb.cpp', + 'libgpopt/src/xforms/CXformLeftSemiJoin2NLJoin.cpp', + 'libgpopt/src/xforms/CXformLimit2IndexGet.cpp', + 'libgpopt/src/xforms/CXformMaxOneRow2Assert.cpp', + 'libgpopt/src/xforms/CXformMinMax2IndexGet.cpp', + 'libgpopt/src/xforms/CXformProject2Apply.cpp', + 'libgpopt/src/xforms/CXformProject2ComputeScalar.cpp', + 'libgpopt/src/xforms/CXformPushDownLeftOuterJoin.cpp', + 'libgpopt/src/xforms/CXformPushGbBelowJoin.cpp', + 'libgpopt/src/xforms/CXformPushGbDedupBelowJoin.cpp', + 'libgpopt/src/xforms/CXformPushGbWithHavingBelowJoin.cpp', + 'libgpopt/src/xforms/CXformPushJoinBelowUnionAll.cpp', + 'libgpopt/src/xforms/CXformPushPartialAggBelowJoin.cpp', + 'libgpopt/src/xforms/CXformRemoveSubqDistinct.cpp', + 'libgpopt/src/xforms/CXformResult.cpp', + 'libgpopt/src/xforms/CXformRightOuterJoin2HashJoin.cpp', + 'libgpopt/src/xforms/CXformSelect2Apply.cpp', + 'libgpopt/src/xforms/CXformSelect2BitmapBoolOp.cpp', + 'libgpopt/src/xforms/CXformSelect2DynamicIndexGet.cpp', + 'libgpopt/src/xforms/CXformSelect2DynamicIndexOnlyGet.cpp', + 'libgpopt/src/xforms/CXformSelect2Filter.cpp', + 'libgpopt/src/xforms/CXformSelect2IndexGet.cpp', + 'libgpopt/src/xforms/CXformSelect2IndexOnlyGet.cpp', + 'libgpopt/src/xforms/CXformSequenceProject2Apply.cpp', + 'libgpopt/src/xforms/CXformSimplifyGbAgg.cpp', + 'libgpopt/src/xforms/CXformSimplifyLeftOuterJoin.cpp', + 'libgpopt/src/xforms/CXformSimplifySubquery.cpp', + 'libgpopt/src/xforms/CXformSplitDQA.cpp', + 'libgpopt/src/xforms/CXformSplitGbAgg.cpp', + 'libgpopt/src/xforms/CXformSplitGbAggDedup.cpp', + 'libgpopt/src/xforms/CXformSplitLimit.cpp', + 'libgpopt/src/xforms/CXformSplitWindowFunc.cpp', + 'libgpopt/src/xforms/CXformSubqJoin2Apply.cpp', + 'libgpopt/src/xforms/CXformSubqueryUnnest.cpp', + 'libgpopt/src/xforms/CXformUnion2UnionAll.cpp', + 'libgpopt/src/xforms/CXformUnnestTVF.cpp', + 'libgpopt/src/xforms/CXformUpdate2DML.cpp', + 'libgpopt/src/xforms/CXformUtils.cpp', + 'libgpopt/src/xforms/CxformSelect2DynamicBitmapBoolOp.cpp', + 'libgpos/src/_api.cpp', + 'libgpos/src/common/CAutoTimer.cpp', + 'libgpos/src/common/CBitSet.cpp', + 'libgpos/src/common/CBitSetIter.cpp', + 'libgpos/src/common/CBitVector.cpp', + 'libgpos/src/common/CDebugCounter.cpp', + 'libgpos/src/common/CHeapObject.cpp', + 'libgpos/src/common/CMainArgs.cpp', + 'libgpos/src/common/CRandom.cpp', + 'libgpos/src/common/CStackDescriptor.cpp', + 'libgpos/src/common/CStackObject.cpp', + 'libgpos/src/common/CTimerUser.cpp', + 'libgpos/src/common/CWallClock.cpp', + 'libgpos/src/common/clibwrapper.cpp', + 'libgpos/src/common/syslibwrapper.cpp', + 'libgpos/src/error/CAutoExceptionStack.cpp', + 'libgpos/src/error/CAutoTrace.cpp', + 'libgpos/src/error/CErrorContext.cpp', + 'libgpos/src/error/CErrorHandlerStandard.cpp', + 'libgpos/src/error/CException.cpp', + 'libgpos/src/error/CLogger.cpp', + 'libgpos/src/error/CLoggerStream.cpp', + 'libgpos/src/error/CLoggerSyslog.cpp', + 'libgpos/src/error/CMessage.cpp', + 'libgpos/src/error/CMessageRepository.cpp', + 'libgpos/src/error/CMessageTable.cpp', + 'libgpos/src/error/CMiniDumper.cpp', + 'libgpos/src/error/CSerializable.cpp', + 'libgpos/src/error/ILogger.cpp', + 'libgpos/src/io/CFileDescriptor.cpp', + 'libgpos/src/io/CFileReader.cpp', + 'libgpos/src/io/CFileWriter.cpp', + 'libgpos/src/io/COstream.cpp', + 'libgpos/src/io/COstreamBasic.cpp', + 'libgpos/src/io/COstreamStdString.cpp', + 'libgpos/src/io/COstreamString.cpp', + 'libgpos/src/io/ioutils.cpp', + 'libgpos/src/memory/CAutoMemoryPool.cpp', + 'libgpos/src/memory/CCacheFactory.cpp', + 'libgpos/src/memory/CMemoryPool.cpp', + 'libgpos/src/memory/CMemoryPoolManager.cpp', + 'libgpos/src/memory/CMemoryPoolTracker.cpp', + 'libgpos/src/memory/CMemoryVisitorPrint.cpp', + 'libgpos/src/string/CStringStatic.cpp', + 'libgpos/src/string/CWString.cpp', + 'libgpos/src/string/CWStringBase.cpp', + 'libgpos/src/string/CWStringConst.cpp', + 'libgpos/src/string/CWStringDynamic.cpp', + 'libgpos/src/string/CWStringStatic.cpp', + 'libgpos/src/task/CAutoSuspendAbort.cpp', + 'libgpos/src/task/CAutoTaskProxy.cpp', + 'libgpos/src/task/CAutoTraceFlag.cpp', + 'libgpos/src/task/CTask.cpp', + 'libgpos/src/task/CTaskContext.cpp', + 'libgpos/src/task/CTaskLocalStorage.cpp', + 'libgpos/src/task/CTaskSchedulerFifo.cpp', + 'libgpos/src/task/CWorker.cpp', + 'libgpos/src/task/CWorkerPoolManager.cpp', + 'libgpos/src/task/ITask.cpp', + 'libgpos/src/task/IWorker.cpp', + 'libgpos/src/utils.cpp', + 'libnaucrates/src/CCostModelConfigSerializer.cpp', + 'libnaucrates/src/CDXLUtils.cpp', + 'libnaucrates/src/CIdGenerator.cpp', + 'libnaucrates/src/base/CDatumBoolGPDB.cpp', + 'libnaucrates/src/base/CDatumGenericGPDB.cpp', + 'libnaucrates/src/base/CDatumInt2GPDB.cpp', + 'libnaucrates/src/base/CDatumInt4GPDB.cpp', + 'libnaucrates/src/base/CDatumInt8GPDB.cpp', + 'libnaucrates/src/base/CDatumOidGPDB.cpp', + 'libnaucrates/src/base/CQueryToDXLResult.cpp', + 'libnaucrates/src/base/IDatum.cpp', + 'libnaucrates/src/exception.cpp', + 'libnaucrates/src/init.cpp', + 'libnaucrates/src/md/CDXLBucket.cpp', + 'libnaucrates/src/md/CDXLColStats.cpp', + 'libnaucrates/src/md/CDXLExtStats.cpp', + 'libnaucrates/src/md/CDXLExtStatsInfo.cpp', + 'libnaucrates/src/md/CDXLRelStats.cpp', + 'libnaucrates/src/md/CDXLStatsDerivedColumn.cpp', + 'libnaucrates/src/md/CDXLStatsDerivedRelation.cpp', + 'libnaucrates/src/md/CMDAggregateGPDB.cpp', + 'libnaucrates/src/md/CMDArrayCoerceCastGPDB.cpp', + 'libnaucrates/src/md/CMDCastGPDB.cpp', + 'libnaucrates/src/md/CMDCheckConstraintGPDB.cpp', + 'libnaucrates/src/md/CMDColumn.cpp', + 'libnaucrates/src/md/CMDExtStatsInfo.cpp', + 'libnaucrates/src/md/CMDFunctionGPDB.cpp', + 'libnaucrates/src/md/CMDIdCast.cpp', + 'libnaucrates/src/md/CMDIdColStats.cpp', + 'libnaucrates/src/md/CMDIdGPDB.cpp', + 'libnaucrates/src/md/CMDIdGPDBCtas.cpp', + 'libnaucrates/src/md/CMDIdRelStats.cpp', + 'libnaucrates/src/md/CMDIdScCmp.cpp', + 'libnaucrates/src/md/CMDIndexGPDB.cpp', + 'libnaucrates/src/md/CMDIndexInfo.cpp', + 'libnaucrates/src/md/CMDName.cpp', + 'libnaucrates/src/md/CMDProviderGeneric.cpp', + 'libnaucrates/src/md/CMDProviderMemory.cpp', + 'libnaucrates/src/md/CMDRelationCtasGPDB.cpp', + 'libnaucrates/src/md/CMDRelationGPDB.cpp', + 'libnaucrates/src/md/CMDRequest.cpp', + 'libnaucrates/src/md/CMDScCmpGPDB.cpp', + 'libnaucrates/src/md/CMDScalarOpGPDB.cpp', + 'libnaucrates/src/md/CMDTypeBoolGPDB.cpp', + 'libnaucrates/src/md/CMDTypeGenericGPDB.cpp', + 'libnaucrates/src/md/CMDTypeInt2GPDB.cpp', + 'libnaucrates/src/md/CMDTypeInt4GPDB.cpp', + 'libnaucrates/src/md/CMDTypeInt8GPDB.cpp', + 'libnaucrates/src/md/CMDTypeOidGPDB.cpp', + 'libnaucrates/src/md/CSystemId.cpp', + 'libnaucrates/src/md/IMDCacheObject.cpp', + 'libnaucrates/src/md/IMDIndex.cpp', + 'libnaucrates/src/md/IMDProvider.cpp', + 'libnaucrates/src/md/IMDRelation.cpp', + 'libnaucrates/src/md/IMDType.cpp', + 'libnaucrates/src/operators/CDXLColDescr.cpp', + 'libnaucrates/src/operators/CDXLColRef.cpp', + 'libnaucrates/src/operators/CDXLCtasStorageOptions.cpp', + 'libnaucrates/src/operators/CDXLDatum.cpp', + 'libnaucrates/src/operators/CDXLDatumBool.cpp', + 'libnaucrates/src/operators/CDXLDatumGeneric.cpp', + 'libnaucrates/src/operators/CDXLDatumInt2.cpp', + 'libnaucrates/src/operators/CDXLDatumInt4.cpp', + 'libnaucrates/src/operators/CDXLDatumInt8.cpp', + 'libnaucrates/src/operators/CDXLDatumOid.cpp', + 'libnaucrates/src/operators/CDXLDatumStatsDoubleMappable.cpp', + 'libnaucrates/src/operators/CDXLDatumStatsLintMappable.cpp', + 'libnaucrates/src/operators/CDXLDirectDispatchInfo.cpp', + 'libnaucrates/src/operators/CDXLIndexDescr.cpp', + 'libnaucrates/src/operators/CDXLLogical.cpp', + 'libnaucrates/src/operators/CDXLLogicalCTAS.cpp', + 'libnaucrates/src/operators/CDXLLogicalCTEAnchor.cpp', + 'libnaucrates/src/operators/CDXLLogicalCTEConsumer.cpp', + 'libnaucrates/src/operators/CDXLLogicalCTEProducer.cpp', + 'libnaucrates/src/operators/CDXLLogicalConstTable.cpp', + 'libnaucrates/src/operators/CDXLLogicalDelete.cpp', + 'libnaucrates/src/operators/CDXLLogicalForeignGet.cpp', + 'libnaucrates/src/operators/CDXLLogicalGet.cpp', + 'libnaucrates/src/operators/CDXLLogicalGroupBy.cpp', + 'libnaucrates/src/operators/CDXLLogicalInsert.cpp', + 'libnaucrates/src/operators/CDXLLogicalJoin.cpp', + 'libnaucrates/src/operators/CDXLLogicalLimit.cpp', + 'libnaucrates/src/operators/CDXLLogicalProject.cpp', + 'libnaucrates/src/operators/CDXLLogicalSelect.cpp', + 'libnaucrates/src/operators/CDXLLogicalSetOp.cpp', + 'libnaucrates/src/operators/CDXLLogicalTVF.cpp', + 'libnaucrates/src/operators/CDXLLogicalUpdate.cpp', + 'libnaucrates/src/operators/CDXLLogicalWindow.cpp', + 'libnaucrates/src/operators/CDXLNode.cpp', + 'libnaucrates/src/operators/CDXLOperator.cpp', + 'libnaucrates/src/operators/CDXLOperatorCost.cpp', + 'libnaucrates/src/operators/CDXLOperatorFactory.cpp', + 'libnaucrates/src/operators/CDXLPhysical.cpp', + 'libnaucrates/src/operators/CDXLPhysicalAbstractBitmapScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalAgg.cpp', + 'libnaucrates/src/operators/CDXLPhysicalAppend.cpp', + 'libnaucrates/src/operators/CDXLPhysicalAssert.cpp', + 'libnaucrates/src/operators/CDXLPhysicalBitmapTableScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalBroadcastMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalCTAS.cpp', + 'libnaucrates/src/operators/CDXLPhysicalCTEConsumer.cpp', + 'libnaucrates/src/operators/CDXLPhysicalCTEProducer.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDML.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDynamicBitmapTableScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDynamicForeignScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDynamicIndexOnlyScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDynamicIndexScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalDynamicTableScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalForeignScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalGatherMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalHashJoin.cpp', + 'libnaucrates/src/operators/CDXLPhysicalIndexOnlyScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalIndexScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalJoin.cpp', + 'libnaucrates/src/operators/CDXLPhysicalLimit.cpp', + 'libnaucrates/src/operators/CDXLPhysicalMaterialize.cpp', + 'libnaucrates/src/operators/CDXLPhysicalMergeJoin.cpp', + 'libnaucrates/src/operators/CDXLPhysicalMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalNLJoin.cpp', + 'libnaucrates/src/operators/CDXLPhysicalParallelTableScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalPartitionSelector.cpp', + 'libnaucrates/src/operators/CDXLPhysicalProperties.cpp', + 'libnaucrates/src/operators/CDXLPhysicalRandomMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalRedistributeMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalResult.cpp', + 'libnaucrates/src/operators/CDXLPhysicalRoutedDistributeMotion.cpp', + 'libnaucrates/src/operators/CDXLPhysicalSequence.cpp', + 'libnaucrates/src/operators/CDXLPhysicalSort.cpp', + 'libnaucrates/src/operators/CDXLPhysicalSplit.cpp', + 'libnaucrates/src/operators/CDXLPhysicalTVF.cpp', + 'libnaucrates/src/operators/CDXLPhysicalTableScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalValuesScan.cpp', + 'libnaucrates/src/operators/CDXLPhysicalWindow.cpp', + 'libnaucrates/src/operators/CDXLProperties.cpp', + 'libnaucrates/src/operators/CDXLScalar.cpp', + 'libnaucrates/src/operators/CDXLScalarAggref.cpp', + 'libnaucrates/src/operators/CDXLScalarArray.cpp', + 'libnaucrates/src/operators/CDXLScalarArrayCoerceExpr.cpp', + 'libnaucrates/src/operators/CDXLScalarArrayComp.cpp', + 'libnaucrates/src/operators/CDXLScalarArrayRef.cpp', + 'libnaucrates/src/operators/CDXLScalarArrayRefIndexList.cpp', + 'libnaucrates/src/operators/CDXLScalarAssertConstraint.cpp', + 'libnaucrates/src/operators/CDXLScalarAssertConstraintList.cpp', + 'libnaucrates/src/operators/CDXLScalarBitmapBoolOp.cpp', + 'libnaucrates/src/operators/CDXLScalarBitmapIndexProbe.cpp', + 'libnaucrates/src/operators/CDXLScalarBoolExpr.cpp', + 'libnaucrates/src/operators/CDXLScalarBooleanTest.cpp', + 'libnaucrates/src/operators/CDXLScalarCaseTest.cpp', + 'libnaucrates/src/operators/CDXLScalarCast.cpp', + 'libnaucrates/src/operators/CDXLScalarCoalesce.cpp', + 'libnaucrates/src/operators/CDXLScalarCoerceBase.cpp', + 'libnaucrates/src/operators/CDXLScalarCoerceToDomain.cpp', + 'libnaucrates/src/operators/CDXLScalarCoerceViaIO.cpp', + 'libnaucrates/src/operators/CDXLScalarComp.cpp', + 'libnaucrates/src/operators/CDXLScalarConstValue.cpp', + 'libnaucrates/src/operators/CDXLScalarDMLAction.cpp', + 'libnaucrates/src/operators/CDXLScalarDistinctComp.cpp', + 'libnaucrates/src/operators/CDXLScalarFieldSelect.cpp', + 'libnaucrates/src/operators/CDXLScalarFilter.cpp', + 'libnaucrates/src/operators/CDXLScalarFuncExpr.cpp', + 'libnaucrates/src/operators/CDXLScalarHashCondList.cpp', + 'libnaucrates/src/operators/CDXLScalarHashExpr.cpp', + 'libnaucrates/src/operators/CDXLScalarHashExprList.cpp', + 'libnaucrates/src/operators/CDXLScalarIdent.cpp', + 'libnaucrates/src/operators/CDXLScalarIfStmt.cpp', + 'libnaucrates/src/operators/CDXLScalarIndexCondList.cpp', + 'libnaucrates/src/operators/CDXLScalarJoinFilter.cpp', + 'libnaucrates/src/operators/CDXLScalarLimitCount.cpp', + 'libnaucrates/src/operators/CDXLScalarLimitOffset.cpp', + 'libnaucrates/src/operators/CDXLScalarMergeCondList.cpp', + 'libnaucrates/src/operators/CDXLScalarMinMax.cpp', + 'libnaucrates/src/operators/CDXLScalarNullIf.cpp', + 'libnaucrates/src/operators/CDXLScalarNullTest.cpp', + 'libnaucrates/src/operators/CDXLScalarOneTimeFilter.cpp', + 'libnaucrates/src/operators/CDXLScalarOpExpr.cpp', + 'libnaucrates/src/operators/CDXLScalarOpList.cpp', + 'libnaucrates/src/operators/CDXLScalarParam.cpp', + 'libnaucrates/src/operators/CDXLScalarProjElem.cpp', + 'libnaucrates/src/operators/CDXLScalarProjList.cpp', + 'libnaucrates/src/operators/CDXLScalarRecheckCondFilter.cpp', + 'libnaucrates/src/operators/CDXLScalarSortCol.cpp', + 'libnaucrates/src/operators/CDXLScalarSortColList.cpp', + 'libnaucrates/src/operators/CDXLScalarSubPlan.cpp', + 'libnaucrates/src/operators/CDXLScalarSubquery.cpp', + 'libnaucrates/src/operators/CDXLScalarSubqueryAll.cpp', + 'libnaucrates/src/operators/CDXLScalarSubqueryAny.cpp', + 'libnaucrates/src/operators/CDXLScalarSubqueryExists.cpp', + 'libnaucrates/src/operators/CDXLScalarSubqueryNotExists.cpp', + 'libnaucrates/src/operators/CDXLScalarSubqueryQuantified.cpp', + 'libnaucrates/src/operators/CDXLScalarSwitch.cpp', + 'libnaucrates/src/operators/CDXLScalarSwitchCase.cpp', + 'libnaucrates/src/operators/CDXLScalarValuesList.cpp', + 'libnaucrates/src/operators/CDXLScalarWindowFrameEdge.cpp', + 'libnaucrates/src/operators/CDXLScalarWindowRef.cpp', + 'libnaucrates/src/operators/CDXLSpoolInfo.cpp', + 'libnaucrates/src/operators/CDXLTableDescr.cpp', + 'libnaucrates/src/operators/CDXLWindowFrame.cpp', + 'libnaucrates/src/operators/CDXLWindowKey.cpp', + 'libnaucrates/src/operators/CDXLWindowSpec.cpp', + 'libnaucrates/src/parser/CParseHandlerAgg.cpp', + 'libnaucrates/src/parser/CParseHandlerAppend.cpp', + 'libnaucrates/src/parser/CParseHandlerArray.cpp', + 'libnaucrates/src/parser/CParseHandlerAssert.cpp', + 'libnaucrates/src/parser/CParseHandlerBase.cpp', + 'libnaucrates/src/parser/CParseHandlerBroadcastMotion.cpp', + 'libnaucrates/src/parser/CParseHandlerCTEConfig.cpp', + 'libnaucrates/src/parser/CParseHandlerCTEList.cpp', + 'libnaucrates/src/parser/CParseHandlerColDescr.cpp', + 'libnaucrates/src/parser/CParseHandlerColStats.cpp', + 'libnaucrates/src/parser/CParseHandlerColStatsBucket.cpp', + 'libnaucrates/src/parser/CParseHandlerCondList.cpp', + 'libnaucrates/src/parser/CParseHandlerCost.cpp', + 'libnaucrates/src/parser/CParseHandlerCostModel.cpp', + 'libnaucrates/src/parser/CParseHandlerCostParam.cpp', + 'libnaucrates/src/parser/CParseHandlerCostParams.cpp', + 'libnaucrates/src/parser/CParseHandlerCtasStorageOptions.cpp', + 'libnaucrates/src/parser/CParseHandlerDXL.cpp', + 'libnaucrates/src/parser/CParseHandlerDirectDispatchInfo.cpp', + 'libnaucrates/src/parser/CParseHandlerDistinctComp.cpp', + 'libnaucrates/src/parser/CParseHandlerDummy.cpp', + 'libnaucrates/src/parser/CParseHandlerDynamicForeignScan.cpp', + 'libnaucrates/src/parser/CParseHandlerDynamicIndexOnlyScan.cpp', + 'libnaucrates/src/parser/CParseHandlerDynamicIndexScan.cpp', + 'libnaucrates/src/parser/CParseHandlerDynamicTableScan.cpp', + 'libnaucrates/src/parser/CParseHandlerEnumeratorConfig.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStats.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStatsDependencies.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStatsDependency.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStatsInfo.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStatsNDistinct.cpp', + 'libnaucrates/src/parser/CParseHandlerExtStatsNDistinctList.cpp', + 'libnaucrates/src/parser/CParseHandlerFactory.cpp', + 'libnaucrates/src/parser/CParseHandlerFilter.cpp', + 'libnaucrates/src/parser/CParseHandlerForeignScan.cpp', + 'libnaucrates/src/parser/CParseHandlerGatherMotion.cpp', + 'libnaucrates/src/parser/CParseHandlerGroupingColList.cpp', + 'libnaucrates/src/parser/CParseHandlerHashExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerHashExprList.cpp', + 'libnaucrates/src/parser/CParseHandlerHashJoin.cpp', + 'libnaucrates/src/parser/CParseHandlerHint.cpp', + 'libnaucrates/src/parser/CParseHandlerIndexCondList.cpp', + 'libnaucrates/src/parser/CParseHandlerIndexDescr.cpp', + 'libnaucrates/src/parser/CParseHandlerIndexOnlyScan.cpp', + 'libnaucrates/src/parser/CParseHandlerIndexScan.cpp', + 'libnaucrates/src/parser/CParseHandlerLimit.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalCTAS.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalCTEAnchor.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalCTEConsumer.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalCTEProducer.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalConstTable.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalDelete.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalForeignGet.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalGet.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalGroupBy.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalInsert.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalJoin.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalLimit.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalOp.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalProject.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalSelect.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalSetOp.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalTVF.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalUpdate.cpp', + 'libnaucrates/src/parser/CParseHandlerLogicalWindow.cpp', + 'libnaucrates/src/parser/CParseHandlerMDArrayCoerceCast.cpp', + 'libnaucrates/src/parser/CParseHandlerMDCast.cpp', + 'libnaucrates/src/parser/CParseHandlerMDGPDBAgg.cpp', + 'libnaucrates/src/parser/CParseHandlerMDGPDBCheckConstraint.cpp', + 'libnaucrates/src/parser/CParseHandlerMDGPDBFunc.cpp', + 'libnaucrates/src/parser/CParseHandlerMDGPDBScalarOp.cpp', + 'libnaucrates/src/parser/CParseHandlerMDIndex.cpp', + 'libnaucrates/src/parser/CParseHandlerMDIndexInfoList.cpp', + 'libnaucrates/src/parser/CParseHandlerMDRelation.cpp', + 'libnaucrates/src/parser/CParseHandlerMDRelationCtas.cpp', + 'libnaucrates/src/parser/CParseHandlerMDRequest.cpp', + 'libnaucrates/src/parser/CParseHandlerMDScCmp.cpp', + 'libnaucrates/src/parser/CParseHandlerMDType.cpp', + 'libnaucrates/src/parser/CParseHandlerManager.cpp', + 'libnaucrates/src/parser/CParseHandlerMaterialize.cpp', + 'libnaucrates/src/parser/CParseHandlerMergeJoin.cpp', + 'libnaucrates/src/parser/CParseHandlerMetadata.cpp', + 'libnaucrates/src/parser/CParseHandlerMetadataColumn.cpp', + 'libnaucrates/src/parser/CParseHandlerMetadataColumns.cpp', + 'libnaucrates/src/parser/CParseHandlerMetadataIdList.cpp', + 'libnaucrates/src/parser/CParseHandlerMetadataObject.cpp', + 'libnaucrates/src/parser/CParseHandlerNLJIndexParam.cpp', + 'libnaucrates/src/parser/CParseHandlerNLJIndexParamList.cpp', + 'libnaucrates/src/parser/CParseHandlerNLJoin.cpp', + 'libnaucrates/src/parser/CParseHandlerOp.cpp', + 'libnaucrates/src/parser/CParseHandlerOptimizerConfig.cpp', + 'libnaucrates/src/parser/CParseHandlerPartitionSelector.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalAbstractBitmapScan.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalBitmapTableScan.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalCTAS.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalCTEConsumer.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalCTEProducer.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalDML.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalDynamicBitmapTableScan.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalOp.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalSplit.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalTVF.cpp', + 'libnaucrates/src/parser/CParseHandlerPhysicalWindow.cpp', + 'libnaucrates/src/parser/CParseHandlerPlan.cpp', + 'libnaucrates/src/parser/CParseHandlerPlanHint.cpp', + 'libnaucrates/src/parser/CParseHandlerProjElem.cpp', + 'libnaucrates/src/parser/CParseHandlerProjList.cpp', + 'libnaucrates/src/parser/CParseHandlerProperties.cpp', + 'libnaucrates/src/parser/CParseHandlerQuery.cpp', + 'libnaucrates/src/parser/CParseHandlerQueryOutput.cpp', + 'libnaucrates/src/parser/CParseHandlerRandomMotion.cpp', + 'libnaucrates/src/parser/CParseHandlerRedistributeMotion.cpp', + 'libnaucrates/src/parser/CParseHandlerRelStats.cpp', + 'libnaucrates/src/parser/CParseHandlerRelationExtendedStats.cpp', + 'libnaucrates/src/parser/CParseHandlerResult.cpp', + 'libnaucrates/src/parser/CParseHandlerRoutedMotion.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarAggref.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarArrayCoerceExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarArrayComp.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarArrayRef.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarArrayRefIndexList.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarAssertConstraintList.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarBitmapBoolOp.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarBitmapIndexProbe.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarBoolExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarBooleanTest.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarCaseTest.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarCast.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarCoalesce.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarCoerceToDomain.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarCoerceViaIO.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarComp.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarConstValue.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarDMLAction.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarFieldSelect.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarFuncExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarIdent.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarIfStmt.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarLimitCount.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarLimitOffset.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarMinMax.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarNullIf.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarNullTest.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarOp.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarOpExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarOpList.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarParam.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSortGroupClause.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubPlan.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubPlanParam.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubPlanParamList.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubPlanTestExpr.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubquery.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubqueryExists.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSubqueryQuantified.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSwitch.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarSwitchCase.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarValuesList.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarWindowFrameEdge.cpp', + 'libnaucrates/src/parser/CParseHandlerScalarWindowRef.cpp', + 'libnaucrates/src/parser/CParseHandlerSearchStage.cpp', + 'libnaucrates/src/parser/CParseHandlerSearchStrategy.cpp', + 'libnaucrates/src/parser/CParseHandlerSequence.cpp', + 'libnaucrates/src/parser/CParseHandlerSort.cpp', + 'libnaucrates/src/parser/CParseHandlerSortCol.cpp', + 'libnaucrates/src/parser/CParseHandlerSortColList.cpp', + 'libnaucrates/src/parser/CParseHandlerStackTrace.cpp', + 'libnaucrates/src/parser/CParseHandlerStatistics.cpp', + 'libnaucrates/src/parser/CParseHandlerStatisticsConfig.cpp', + 'libnaucrates/src/parser/CParseHandlerStatsBound.cpp', + 'libnaucrates/src/parser/CParseHandlerStatsDerivedColumn.cpp', + 'libnaucrates/src/parser/CParseHandlerStatsDerivedRelation.cpp', + 'libnaucrates/src/parser/CParseHandlerTableDescr.cpp', + 'libnaucrates/src/parser/CParseHandlerTableScan.cpp', + 'libnaucrates/src/parser/CParseHandlerTraceFlags.cpp', + 'libnaucrates/src/parser/CParseHandlerUtils.cpp', + 'libnaucrates/src/parser/CParseHandlerValuesScan.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowFrame.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowKey.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowKeyList.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowOids.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowSpec.cpp', + 'libnaucrates/src/parser/CParseHandlerWindowSpecList.cpp', + 'libnaucrates/src/parser/CParseHandlerXform.cpp', + 'libnaucrates/src/statistics/CBucket.cpp', + 'libnaucrates/src/statistics/CExtendedStatsProcessor.cpp', + 'libnaucrates/src/statistics/CFilterStatsProcessor.cpp', + 'libnaucrates/src/statistics/CGroupByStatsProcessor.cpp', + 'libnaucrates/src/statistics/CHistogram.cpp', + 'libnaucrates/src/statistics/CInnerJoinStatsProcessor.cpp', + 'libnaucrates/src/statistics/CJoinStatsProcessor.cpp', + 'libnaucrates/src/statistics/CLeftAntiSemiJoinStatsProcessor.cpp', + 'libnaucrates/src/statistics/CLeftOuterJoinStatsProcessor.cpp', + 'libnaucrates/src/statistics/CLeftSemiJoinStatsProcessor.cpp', + 'libnaucrates/src/statistics/CLimitStatsProcessor.cpp', + 'libnaucrates/src/statistics/CPoint.cpp', + 'libnaucrates/src/statistics/CProjectStatsProcessor.cpp', + 'libnaucrates/src/statistics/CScaleFactorUtils.cpp', + 'libnaucrates/src/statistics/CStatistics.cpp', + 'libnaucrates/src/statistics/CStatisticsUtils.cpp', + 'libnaucrates/src/statistics/CStatsPredArrayCmp.cpp', + 'libnaucrates/src/statistics/CStatsPredConj.cpp', + 'libnaucrates/src/statistics/CStatsPredDisj.cpp', + 'libnaucrates/src/statistics/CStatsPredLike.cpp', + 'libnaucrates/src/statistics/CStatsPredPoint.cpp', + 'libnaucrates/src/statistics/CStatsPredUnsupported.cpp', + 'libnaucrates/src/statistics/CStatsPredUtils.cpp', + 'libnaucrates/src/statistics/CUnionAllStatsProcessor.cpp', + 'libnaucrates/src/statistics/CUpperBoundNDVs.cpp', + 'libnaucrates/src/traceflags.cpp', + 'libnaucrates/src/xml/CDXLMemoryManager.cpp', + 'libnaucrates/src/xml/CDXLSections.cpp', + 'libnaucrates/src/xml/CXMLSerializer.cpp', + 'libnaucrates/src/xml/dxltokens.cpp', +) + +gporca = static_library('gporca', + orca_sources, + include_directories: [orca_inc, postgres_inc], + dependencies: [backend_code, xerces], + cpp_args: orca_cpp_args, + # configure.ac pins C++14 by appending -std=c++14 to CXX itself + # (config/ax_cxx_compile_stdcxx.m4); meson expresses it as an option. + override_options: ['cpp_std=c++14'], + kwargs: internal_lib_args, +) +backend_link_with += gporca diff --git a/src/backend/meson.build b/src/backend/meson.build index 0a751a0bae8..72963af7415 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -38,6 +38,12 @@ subdir('crypto') subdir('fts') subdir('cdb') +# ifeq ($(enable_orca),yes) / SUBDIRS += gporca gpopt +if xerces.found() + subdir('gporca') + subdir('gpopt') +endif + subdir('po', if_found: libintl) @@ -144,12 +150,18 @@ if host_system == 'windows' '--FILEDESC', 'PostgreSQL Server',]) endif +# src/backend/Makefile links postgres with $(CXX) because ORCA is C++. +# meson picks the linker from the target's own sources, which are all C, so +# the C++ linker has to be requested explicitly when ORCA is linked in. +postgres_link_language = xerces.found() ? 'cpp' : 'c' + postgres = executable('postgres', backend_input, sources: post_export_backend_sources, objects: backend_objs, link_args: backend_link_args, link_with: backend_link_with, + link_language: postgres_link_language, link_depends: backend_link_depends, export_dynamic: true, implib: true, diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index a6c46421c28..608bf5c5430 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -1343,6 +1343,8 @@ libpq_binddomain(void) #endif /* No relocatable lookup here because the binary could be anywhere */ + const char *ldir; + ldir = getenv("PGLOCALEDIR"); if (!ldir) ldir = LOCALEDIR; From 1e715ac833e2f1b457bf77b55bb9911235da563d Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 29 Aug 2026 10:26:55 +0800 Subject: [PATCH 03/13] meson: build gpfdist, pxf_fdw and the remaining gated gpcontrib extensions - gpfdist, with apr located through apr-1-config rather than pkg-config. configure uses the config tool (--with-apr-config) for a reason: the system apr-1.pc on macOS points at an include directory that does not exist. Adds an apr_config option mirroring --with-apr-config. libevent is required, libyaml optional and gating -DGPFXDIST, and gfile.c keeps its per-file -DFRONTEND. - pxf_fdw, with libcurl as a dependency instead of a hardcoded -lcurl - the debug-extension set (gp_debug_numsegments, gp_inject_fault, gp_replica_check including its python script, reject_partition_fullscan), zstd (MODULE_big name differs from the directory name) and orafce src/Makefile.global.in's Cloudberry @variables@ are now filled in. They are defined by configure via AC_SUBST and consumed by recursive make -- for example gpcontrib/Makefile reads enable_gpcloud / enable_pxf / with_diskquota / enable_debug_extensions, and src/bin/gpfdist/Makefile reads have_yaml / EVENT_LIBS / apr_*. The meson build does not use them itself, but Makefile.global is installed as part of PGXS, so out-of-tree extensions built with USE_PGXS=1 still read them; leaving them empty would silently change their behaviour. meson setup no longer warns about missing substitutions. Assisted-by: Claude Code --- gpcontrib/gp_debug_numsegments/meson.build | 29 ++++++ gpcontrib/gp_inject_fault/meson.build | 33 +++++++ gpcontrib/gp_replica_check/meson.build | 30 ++++++ gpcontrib/meson.build | 23 +++++ gpcontrib/orafce/meson.build | 92 +++++++++++++++++++ gpcontrib/pxf_fdw/meson.build | 41 +++++++++ .../reject_partition_fullscan/meson.build | 29 ++++++ gpcontrib/zstd/meson.build | 29 ++++++ meson.build | 34 +++++++ meson_options.txt | 3 + src/bin/gpfdist/meson.build | 57 ++++++++++++ src/bin/meson.build | 5 + src/makefiles/meson.build | 66 +++++++++++++ 13 files changed, 471 insertions(+) create mode 100644 gpcontrib/gp_debug_numsegments/meson.build create mode 100644 gpcontrib/gp_inject_fault/meson.build create mode 100644 gpcontrib/gp_replica_check/meson.build create mode 100644 gpcontrib/orafce/meson.build create mode 100644 gpcontrib/pxf_fdw/meson.build create mode 100644 gpcontrib/reject_partition_fullscan/meson.build create mode 100644 gpcontrib/zstd/meson.build create mode 100644 src/bin/gpfdist/meson.build diff --git a/gpcontrib/gp_debug_numsegments/meson.build b/gpcontrib/gp_debug_numsegments/meson.build new file mode 100644 index 00000000000..92448c1705c --- /dev/null +++ b/gpcontrib/gp_debug_numsegments/meson.build @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_debug_numsegments = shared_module('gp_debug_numsegments', + files( + 'gp_debug_numsegments.c', + ), + kwargs: contrib_mod_args, +) +contrib_targets += gp_debug_numsegments + +install_data( + 'gp_debug_numsegments--1.0.sql', + 'gp_debug_numsegments.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_inject_fault/meson.build b/gpcontrib/gp_inject_fault/meson.build new file mode 100644 index 00000000000..ea6f01cfd43 --- /dev/null +++ b/gpcontrib/gp_inject_fault/meson.build @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_inject_fault_args = contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [libpq], +} + +gp_inject_fault = shared_module('gp_inject_fault', + files( + 'gp_inject_fault.c', + ), + kwargs: gp_inject_fault_args, +) +contrib_targets += gp_inject_fault + +install_data( + 'gp_inject_fault--1.0.sql', + 'gp_inject_fault.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_replica_check/meson.build b/gpcontrib/gp_replica_check/meson.build new file mode 100644 index 00000000000..2cba82c19fe --- /dev/null +++ b/gpcontrib/gp_replica_check/meson.build @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gp_replica_check = shared_module('gp_replica_check', + files('gp_replica_check.c'), + kwargs: contrib_mod_args, +) +contrib_targets += gp_replica_check + +install_data( + 'gp_replica_check--0.0.1.sql', + 'gp_replica_check.control', + kwargs: contrib_data_args, +) + +# SCRIPTS = gp_replica_check.py +install_data('gp_replica_check.py', install_dir: dir_bin) diff --git a/gpcontrib/meson.build b/gpcontrib/meson.build index 6a3874485bf..62417af2893 100644 --- a/gpcontrib/meson.build +++ b/gpcontrib/meson.build @@ -26,3 +26,26 @@ subdir('gp_relsizes_stats') subdir('gp_sparse_vector') subdir('gp_toolkit') subdir('pg_hint_plan') + +# --enable-pxf (default yes); requires libcurl +if get_option('pxf').enabled() + subdir('pxf_fdw') +endif + +# --enable-debug-extensions (default yes) +if get_option('debug_extensions') + subdir('gp_debug_numsegments') + subdir('gp_inject_fault') + subdir('gp_replica_check') + subdir('reject_partition_fullscan') +endif + +# --with-zstd +if zstd.found() + subdir('zstd') +endif + +# --enable-orafce +if get_option('orafce').enabled() + subdir('orafce') +endif diff --git a/gpcontrib/orafce/meson.build b/gpcontrib/orafce/meson.build new file mode 100644 index 00000000000..c400c73b349 --- /dev/null +++ b/gpcontrib/orafce/meson.build @@ -0,0 +1,92 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +orafce = shared_module('orafce', + files( + 'aggregate.c', + 'alert.c', + 'assert.c', + 'charlen.c', + 'charpad.c', + 'convert.c', + 'datefce.c', + 'dbms_sql.c', + 'file.c', + 'magic.c', + 'math.c', + 'nvarchar2.c', + 'orafce.c', + 'others.c', + 'parse_keyword.c', + 'pipe.c', + 'plunit.c', + 'plvdate.c', + 'plvlex.c', + 'plvstr.c', + 'plvsubst.c', + 'putline.c', + 'random.c', + 'regexp.c', + 'replace_empty_string.c', + 'shmmc.c', + 'sqlparse.c', + 'utility.c', + 'varchar2.c', + ), + kwargs: contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [libintl], + }, +) +contrib_targets += orafce + +install_data( + 'orafce--4.9.sql', + 'orafce--3.2--3.3.sql', + 'orafce--3.3--3.4.sql', + 'orafce--3.4--3.5.sql', + 'orafce--3.5--3.6.sql', + 'orafce--3.6--3.7.sql', + 'orafce--3.7--3.8.sql', + 'orafce--3.8--3.9.sql', + 'orafce--3.9--3.10.sql', + 'orafce--3.10--3.11.sql', + 'orafce--3.11--3.12.sql', + 'orafce--3.12--3.13.sql', + 'orafce--3.13--3.14.sql', + 'orafce--3.14--3.15.sql', + 'orafce--3.15--3.16.sql', + 'orafce--3.16--3.17.sql', + 'orafce--3.17--3.18.sql', + 'orafce--3.18--3.19.sql', + 'orafce--3.19--3.20.sql', + 'orafce--3.20--3.21.sql', + 'orafce--3.21--3.22.sql', + 'orafce--3.22--3.23.sql', + 'orafce--3.23--3.24.sql', + 'orafce--3.24--3.25.sql', + 'orafce--3.25--4.0.sql', + 'orafce--4.0--4.1.sql', + 'orafce--4.1--4.2.sql', + 'orafce--4.2--4.3.sql', + 'orafce--4.3--4.4.sql', + 'orafce--4.4--4.5.sql', + 'orafce--4.5--4.6.sql', + 'orafce--4.6--4.7.sql', + 'orafce--4.7--4.8.sql', + 'orafce--4.8--4.9.sql', + 'orafce.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/pxf_fdw/meson.build b/gpcontrib/pxf_fdw/meson.build new file mode 100644 index 00000000000..e887834e26a --- /dev/null +++ b/gpcontrib/pxf_fdw/meson.build @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# SHLIB_LINK += -lcurl (hardcoded in the Makefile; use the dependency instead) +pxf_fdw_args = contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [libcurl], +} + +pxf_fdw = shared_module('pxf_fdw', + files( + 'libchurl.c', + 'pxf_bridge.c', + 'pxf_deparse.c', + 'pxf_fdw.c', + 'pxf_filter.c', + 'pxf_fragment.c', + 'pxf_header.c', + 'pxf_option.c', + ), + kwargs: pxf_fdw_args, +) +contrib_targets += pxf_fdw + +install_data( + 'pxf_fdw--1.0.sql', + 'pxf_fdw.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/reject_partition_fullscan/meson.build b/gpcontrib/reject_partition_fullscan/meson.build new file mode 100644 index 00000000000..c7ebc518ed8 --- /dev/null +++ b/gpcontrib/reject_partition_fullscan/meson.build @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +reject_partition_fullscan = shared_module('reject_partition_fullscan', + files( + 'reject_partition_fullscan.c', + ), + kwargs: contrib_mod_args, +) +contrib_targets += reject_partition_fullscan + +install_data( + 'reject_partition_fullscan--1.0.sql', + 'reject_partition_fullscan.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/zstd/meson.build b/gpcontrib/zstd/meson.build new file mode 100644 index 00000000000..f2c444b3d5e --- /dev/null +++ b/gpcontrib/zstd/meson.build @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# MODULE_big = gp_zstd_compression (note: differs from the directory name) +gp_zstd_compression = shared_module('gp_zstd_compression', + files('zstd_compression.c'), + kwargs: contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [zstd], + }, +) +contrib_targets += gp_zstd_compression + +# Plain SQL, not an EXTENSION +install_data( + kwargs: contrib_data_args, +) diff --git a/meson.build b/meson.build index d1acde5a132..66e08b16840 100644 --- a/meson.build +++ b/meson.build @@ -3068,6 +3068,40 @@ else cdata.set('USE_CURL', false) endif +# gpfdist dependencies: apr-1 and libevent are required, libyaml is optional +# and only gates the transform support (-DGPFXDIST). +# configure.ac: PKG_CHECK_MODULES([EVENT], [libevent >= 2.0.0]) and +# AC_SEARCH_LIBS(yaml_parser_initialize, [yaml]) +gpfdistopt = get_option('gpfdist') +apr = not_found_dep +apr_link_ld_libs = '' +libevent = not_found_dep +if not gpfdistopt.disabled() + # configure.ac locates apr through apr-1-config (--with-apr-config), not + # pkg-config -- on some platforms the system apr-1.pc points at an include + # directory that does not exist. Follow the same route, falling back to + # pkg-config only if the config tool is unavailable. + apr_config = find_program(get_option('apr_config'), required: false, native: true) + if apr_config.found() + apr_inc_args = run_command(apr_config, '--includes', check: true).stdout().split() + apr_link_ld_libs = run_command(apr_config, '--link-ld', check: true).stdout().strip() + apr = declare_dependency( + compile_args: apr_inc_args, + link_args: apr_link_ld_libs.split(), + ) + else + apr = dependency('apr-1', required: gpfdistopt) + endif + libevent = dependency('libevent', version: '>= 2.0.0', required: gpfdistopt) +endif + +# libyaml is optional for gpfdist but required for gpmapreduce. +mapreduceopt = get_option('mapreduce') +libyaml = not_found_dep +if not gpfdistopt.disabled() or mapreduceopt.enabled() + libyaml = dependency('yaml-0.1', required: mapreduceopt.enabled()) +endif + # bzip2: configure.ac does AC_CHECK_LIB(bz2, BZ2_bzDecompress) into global LIBS libbz2opt = get_option('libbz2') if not libbz2opt.disabled() diff --git a/meson_options.txt b/meson_options.txt index c05b74f7a30..cbfa9da6438 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -287,3 +287,6 @@ option('shared_postgres_backend', type: 'boolean', value: true, option('link_postgres_with_shared', type: 'boolean', value: false, description: 'link the postgres binary against libpostgres.so') + +option('apr_config', type: 'string', value: 'apr-1-config', + description: 'path to the apr-1-config utility (--with-apr-config)') diff --git a/src/bin/gpfdist/meson.build b/src/bin/gpfdist/meson.build new file mode 100644 index 00000000000..335e33a9681 --- /dev/null +++ b/src/bin/gpfdist/meson.build @@ -0,0 +1,57 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# fstream.c and gfile.c are shared with the backend. The Makefile symlinks them +# into this directory; meson can just reference them where they live. Note the +# asymmetry the Makefile encodes: only gfile.c is built with -DFRONTEND. +gpfdist_sources = files( + 'gpfdist.c', + 'gpfdist_helper.c', + '../../backend/utils/misc/fstream/fstream.c', +) + +gpfdist_c_args = [] +gpfdist_deps = [apr, libevent, libbz2, zlib] + +# ifeq ($(have_yaml),yes): transform support, plus -DGPFXDIST for the whole +# translation unit set (except win32). +if libyaml.found() + gpfdist_sources += files('transform.c') + gpfdist_deps += libyaml + if host_system != 'windows' + gpfdist_c_args += '-DGPFXDIST' + endif +endif + +# gfile.o: CPPFLAGS := $(CPPFLAGS) -DFRONTEND +gpfdist_gfile = static_library('gpfdist_gfile', + files('../../backend/utils/misc/fstream/gfile.c'), + c_args: gpfdist_c_args + ['-DFRONTEND'], + include_directories: [postgres_inc, include_directories('.')], + # gfile.c pulls in gpfxdist.h, which needs apr when transform support is on + dependencies: [frontend_stlib_code, zlib, libbz2] + gpfdist_deps, + kwargs: internal_lib_args, +) + +gpfdist = executable('gpfdist', + gpfdist_sources, + c_args: gpfdist_c_args, + include_directories: [postgres_inc, include_directories('.')], + link_with: gpfdist_gfile, + dependencies: [frontend_code] + gpfdist_deps, + kwargs: default_bin_args, +) +bin_targets += gpfdist diff --git a/src/bin/meson.build b/src/bin/meson.build index 67cb50630c5..2457de559ee 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -20,3 +20,8 @@ subdir('pgbench') subdir('pgevent') subdir('psql') subdir('scripts') + +# Cloudberry additions +if get_option('gpfdist').enabled() + subdir('gpfdist') +endif diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build index 13045cbd6e4..96db86b73e8 100644 --- a/src/makefiles/meson.build +++ b/src/makefiles/meson.build @@ -260,3 +260,69 @@ endforeach foreach d, v : pgxs_deps pgxs_cdata.set('with_@0@'.format(d), v.found() ? 'yes' : 'no') endforeach + +############################################################### +# Apache Cloudberry: PGXS variables +############################################################### +# +# src/Makefile.global.in carries ~38 Cloudberry @variables@ that configure +# fills in via AC_SUBST. They are consumed by recursive make (gpcontrib/Makefile +# reads enable_gpcloud / enable_pxf / with_diskquota / enable_debug_extensions, +# src/bin/gpfdist/Makefile reads have_yaml / EVENT_LIBS / apr_*, and so on). +# +# The meson build does not use them itself -- it uses meson options instead -- +# but Makefile.global is installed as part of PGXS, so out-of-tree extensions +# built with `make USE_PGXS=1` still read them. Leaving them empty would +# silently change behaviour for those extensions, so fill them in here. + +pgxs_cdata.set('GP_MAJORVERSION', gp_majorversion) +pgxs_cdata.set('GP_VERSION_SHORT', gp_version_short) +pgxs_cdata.set('PG_PACKAGE_VERSION', pg_version) +pgxs_cdata.set('BLD_ARCH', '') + +foreach k, v : { + 'enable_orca': xerces.found(), + 'enable_gpfdist': get_option('gpfdist').enabled(), + 'enable_pxf': get_option('pxf').enabled(), + 'enable_gpcloud': get_option('gpcloud').enabled(), + 'enable_mapreduce': get_option('mapreduce').enabled(), + 'enable_orafce': get_option('orafce').enabled(), + 'enable_ic_proxy': get_option('ic_proxy').enabled(), + 'enable_pax': get_option('pax').enabled(), + 'enable_ic_udp2': get_option('ic_udp2'), + 'enable_catalog_ext': get_option('catalog_ext'), + 'enable_serverless': get_option('serverless'), + 'enable_debug_extensions': get_option('debug_extensions'), + 'enable_shared_postgres_backend': get_option('shared_postgres_backend'), + 'enable_link_postgres_with_shared': get_option('link_postgres_with_shared'), + 'with_diskquota': get_option('diskquota').enabled(), + 'with_gp_stats_collector': get_option('gp_stats_collector').enabled(), + 'with_libbz2': libbz2.found(), + 'have_yaml': libyaml.found(), + # legacy upstream toggles that are always on in a modern build + 'enable_largefile': true, + 'enable_shared': true, + 'enable_strong_random': true, + # dropped in the meson build: the autoconf path downloads Python packages + # at build time, which has no honest meson equivalent + 'with_pythonsrc_ext': false, +} + pgxs_cdata.set(k, v ? 'yes' : 'no') +endforeach + +pgxs_cdata.set('YAML_LIBS', libyaml.found() ? '-lyaml' : '') +pgxs_cdata.set('EVENT_LIBS', libevent.found() ? '-levent' : '') +pgxs_cdata.set('ZSTD_CFLAGS', '') +pgxs_cdata.set('ZSTD_LIBS', zstd.found() ? '-lzstd' : '') + +# apr is discovered through pkg-config here, where configure shells out to +# apr-1-config; expose the same variables so PGXS consumers keep working. +pgxs_cdata.set('APR_1_CONFIG', '') +pgxs_cdata.set('with_apr_config', '') +pgxs_cdata.set('apr_includes', '') +pgxs_cdata.set('apr_cppflags', '') +pgxs_cdata.set('apr_cflags', '') +pgxs_cdata.set('apr_link_ld_libs', apr_link_ld_libs) + +pgxs_cdata.set('libexecdir', dir_prefix / get_option('libexecdir')) +pgxs_cdata.set('sbindir', dir_prefix / get_option('sbindir')) From e8da4b61c88184df995c9f2eef7373c945dd5cc5 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 29 Aug 2026 10:34:29 +0800 Subject: [PATCH 04/13] ci: add a meson build workflow with an install smoke test Builds Cloudberry with meson in the same rocky9 build container the autoconf workflows use, installs it, and runs a smoke test. This does not replace build-cloudberry.yml: until the two paths are proven equivalent the autoconf build stays authoritative, and this exists to keep the meson files from rotting and to surface divergence early. The workflow header maps each flag of the reference configure line in coverity.yml onto its meson option, and records which ones are not reachable from meson yet (gpcloud, pax, mapreduce, diskquota, gp_stats_collector) and that --with-pythonsrc-ext was dropped deliberately. The smoke test lives in devops/build/automation/cloudberry/scripts so it can be run by hand against any install prefix. It checks the installed binaries and GP extensions, that the generated catalog data is present, that initdb succeeds, and then in single-user mode that the GP catalogs exist, that the gp_* views generated from system_views_gp.in were created, that gp_opt_version() reports a working ORCA, and that an append-only table actually stores and returns rows. Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 179 ++++++++++++++++++ .../cloudberry/scripts/meson-smoke-test.sh | 119 ++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 .github/workflows/build-meson-cloudberry.yml create mode 100755 devops/build/automation/cloudberry/scripts/meson-smoke-test.sh diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml new file mode 100644 index 00000000000..b73848379dd --- /dev/null +++ b/.github/workflows/build-meson-cloudberry.yml @@ -0,0 +1,179 @@ +# -------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# -------------------------------------------------------------------- +# +# Apache Cloudberry Meson Build +# +# PostgreSQL 16 introduced meson as a second build system alongside +# autoconf/make. This workflow builds Cloudberry with meson and runs a smoke +# test, so that the meson path keeps working while it is brought up to parity +# with the autoconf path. +# +# This does NOT replace the autoconf build. Until the two are proven +# equivalent, `build-cloudberry.yml` remains the authoritative build; this +# workflow exists to stop the meson files from rotting and to surface +# divergence early. +# +# Option mapping, against the reference configure line in coverity.yml: +# +# --disable-external-fts -> -Dexternal_fts=false +# --enable-orca -> -Dorca=enabled +# --enable-pxf -> -Dpxf=enabled +# --enable-orafce -> -Dorafce=enabled +# --enable-ic-proxy -> -Dic_proxy=enabled +# --enable-tap-tests -> -Dtap_tests=enabled +# --with-gssapi -> -Dgssapi=enabled +# --with-ldap -> -Dldap=enabled +# --with-libxml -> -Dlibxml=enabled +# --with-lz4 -> -Dlz4=enabled +# --with-zstd -> -Dzstd=enabled +# --with-pam -> -Dpam=enabled +# --with-perl -> -Dplperl=enabled +# --with-python -> -Dplpython=enabled +# --with-ssl=openssl -> -Dssl=openssl +# --with-uuid=e2fs -> -Duuid=e2fs +# --with-pgport=5432 -> -Dpgport=5432 +# --with-includes=... -> -Dextra_include_dirs=... +# --with-libraries=... -> -Dextra_lib_dirs=... +# +# Not yet reachable from meson, and therefore not enabled here: +# --enable-gpcloud, --enable-pax, --enable-mapreduce, +# --with-diskquota, --with-gp-stats-collector +# +# Deliberately dropped: --with-pythonsrc-ext downloads psutil / PyYAML / +# PyGreSQL from PyPI during `make install`, which has no honest meson +# equivalent. Those are external runtime dependencies for the meson build. +# -------------------------------------------------------------------- +name: Apache Cloudberry Meson Build + +on: + push: + branches: [ main, pg16-ci ] + pull_request: + branches: [ main, pg16-ci ] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + meson-build: + name: Meson build and smoke test + runs-on: ubuntu-22.04 + + container: + image: apache/incubator-cloudberry:cbdb-build-rocky9-latest + options: >- + --user root + -h cdw + + env: + BUILD_DIR: build-meson + INSTALL_PREFIX: /usr/local/cloudberry-db + + steps: + - name: Checkout Apache Cloudberry + uses: actions/checkout@v7 + with: + fetch-depth: 0 + submodules: true + + - name: Environment Initialization + run: | + if ! su - gpadmin -c "/tmp/init_system.sh"; then + echo "::error::Container initialization failed" + exit 1 + fi + + - name: Install meson and ninja + run: | + set -euox pipefail + # The build image ships autoconf/make but not meson. + python3 -m pip install --disable-pip-version-check 'meson>=0.54' ninja + meson --version + ninja --version + + - name: Prepare install prefix + run: | + set -euox pipefail + # Mirrors build-cloudberry.yml: xerces is staged into the install + # prefix so the built binaries can find it at runtime. + mkdir -p "${INSTALL_PREFIX}/lib" + cp /usr/local/xerces-c/lib/libxerces-c.so \ + /usr/local/xerces-c/lib/libxerces-c-3.3.so \ + "${INSTALL_PREFIX}/lib" + chown -R gpadmin:gpadmin "${INSTALL_PREFIX}" + chown -R gpadmin:gpadmin "${GITHUB_WORKSPACE}" + + - name: meson setup + run: | + set -euox pipefail + # Run the build as gpadmin, like the autoconf workflows do. + # No single quotes inside, so the whole command can be double quoted + # and the environment variables expand in this shell. + su gpadmin -c "cd ${GITHUB_WORKSPACE} && meson setup ${BUILD_DIR} . \ + --prefix=${INSTALL_PREFIX} \ + --buildtype=release \ + -Dexternal_fts=false \ + -Dorca=enabled \ + -Dpxf=enabled \ + -Dorafce=enabled \ + -Dic_proxy=enabled \ + -Dgpfdist=enabled \ + -Dtap_tests=enabled \ + -Dgssapi=enabled \ + -Dldap=enabled \ + -Dlibxml=enabled \ + -Dlz4=enabled \ + -Dzstd=enabled \ + -Dpam=enabled \ + -Dplperl=enabled \ + -Dplpython=enabled \ + -Dssl=openssl \ + -Duuid=e2fs \ + -Dpgport=5432 \ + -Dextra_include_dirs=/usr/local/xerces-c/include \ + -Dextra_lib_dirs=${INSTALL_PREFIX}/lib" + + - name: ninja build + run: | + set -euox pipefail + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C ${BUILD_DIR} -j$(nproc)" + + - name: ninja install + run: | + set -euox pipefail + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C ${BUILD_DIR} install" + + - name: Verify install and run smoke test + run: | + set -euox pipefail + su gpadmin -c "${GITHUB_WORKSPACE}/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh ${INSTALL_PREFIX}" + + - name: Upload meson logs on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: meson-logs + path: | + ${{ env.BUILD_DIR }}/meson-logs/ + retention-days: 7 + if-no-files-found: ignore diff --git a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh new file mode 100755 index 00000000000..2b221122eea --- /dev/null +++ b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash +# -------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# -------------------------------------------------------------------- +# +# Smoke test for a meson-built Apache Cloudberry installation. +# +# Checks that the install is complete, that initdb succeeds (which exercises +# catalog generation end to end), and that the MPP-specific pieces are really +# there rather than merely linked. +# +# Usage: meson-smoke-test.sh +# -------------------------------------------------------------------- +set -euo pipefail + +PREFIX="${1:?usage: $0 }" +export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH:-}" + +fail() { echo "::error::$*" >&2; exit 1; } + +# -------------------------------------------------------------------- +# 1. Installed artifacts +# -------------------------------------------------------------------- +echo "== checking installed binaries ==" +for b in postgres initdb pg_ctl psql pg_dump pg_upgrade gpfdist; do + [ -x "${PREFIX}/bin/${b}" ] || fail "missing bin/${b}" + echo " ok bin/${b}" +done + +echo "== checking GP extensions ==" +for e in interconnect gp_exttable_fdw gp_toolkit gp_distribution_policy pxf_fdw; do + [ -f "${PREFIX}/share/postgresql/extension/${e}.control" ] || fail "missing extension ${e}" + echo " ok ${e}" +done + +echo "== checking generated catalog data ==" +for f in system_views_gp.sql cdb_init.d/cdb_schema.sql postgres.bki; do + [ -f "${PREFIX}/share/postgresql/${f}" ] || fail "missing share/postgresql/${f}" + echo " ok ${f}" +done + +"${PREFIX}/bin/postgres" --version + +# -------------------------------------------------------------------- +# 2. initdb +# -------------------------------------------------------------------- +WORKDIR="$(mktemp -d)" +trap 'rm -rf "${WORKDIR}"' EXIT +DATADIR="${WORKDIR}/pgdata" + +echo "== running initdb ==" +"${PREFIX}/bin/initdb" -D "${DATADIR}" --no-locale --encoding=UTF8 >"${WORKDIR}/initdb.log" 2>&1 || { + tail -30 "${WORKDIR}/initdb.log" >&2 + fail "initdb failed" +} +echo " ok initdb" + +# -------------------------------------------------------------------- +# 3. Runtime checks, in single-user mode +# -------------------------------------------------------------------- +# A full postmaster needs an MPP identity (-b dbid) and a segment +# configuration; single-user mode is enough to prove the catalogs, the +# optimizer and the storage layer are functional. +run_sql() { + printf '%s\n' "$1" | "${PREFIX}/bin/postgres" --single -D "${DATADIR}" \ + -c gp_role=utility -c optimizer=on postgres 2>&1 +} + +echo "== checking GP catalogs ==" +run_sql "select count(*) as n from pg_class where relname in ('gp_segment_configuration', 'gp_distribution_policy', 'pg_resgroup', 'pg_appendonly');" \ + >"${WORKDIR}/catalogs.out" +grep -q 'n = "4"' "${WORKDIR}/catalogs.out" || { + cat "${WORKDIR}/catalogs.out" >&2 + fail "expected 4 GP catalogs" +} +echo " ok 4/4 GP catalogs present" + +echo "== checking the gp_* views generated from system_views_gp.in ==" +run_sql "select count(*) as n from pg_views where viewname like 'gp\\_%';" >"${WORKDIR}/views.out" +grep -qE 'n = "[1-9][0-9]*"' "${WORKDIR}/views.out" || { + cat "${WORKDIR}/views.out" >&2 + fail "no gp_* views were created" +} +echo " ok $(sed -n 's/.*n = "\([0-9]*\)".*/\1/p' "${WORKDIR}/views.out" | head -1) gp_* views" + +echo "== checking ORCA ==" +run_sql "select gp_opt_version();" >"${WORKDIR}/orca.out" +grep -q "GPOPT version" "${WORKDIR}/orca.out" || { + cat "${WORKDIR}/orca.out" >&2 + fail "ORCA is not available" +} +echo " ok $(sed -n 's/.*gp_opt_version = "\([^"]*\)".*/\1/p' "${WORKDIR}/orca.out" | head -1)" + +echo "== checking append-only storage ==" +run_sql "create table t_ao(a int) with (appendonly=true);" >/dev/null +run_sql "insert into t_ao select generate_series(1,100);" >/dev/null +run_sql "select count(*) as n from t_ao;" >"${WORKDIR}/ao.out" +grep -q 'n = "100"' "${WORKDIR}/ao.out" || { + cat "${WORKDIR}/ao.out" >&2 + fail "append-only table did not return 100 rows" +} +echo " ok append-only table returned 100 rows" + +echo +echo "Smoke test passed." From c81d756df8e4d4ddfaec9afb174d3862f192cf99 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sat, 29 Aug 2026 10:42:47 +0800 Subject: [PATCH 05/13] meson: install the gpMgmt management utilities Four levels of recursive make that exist almost entirely to copy files collapse into per-directory install_data calls. The 0755 / 0644 split is inconsistent in the autoconf build (base.py is installed as a script while its siblings are data, and so on), so it is reproduced file by file rather than with a blanket install_subdir. - 32 utilities into bindir, 11 into sbindir, gppylib and its eight subpackages into libdir/python/gppylib, the gpcheckcat / gpconfig / gpssh module directories and bin/lib into bindir - the two C programs: stream into bindir/lib with the backward-compatible bindir/stream/stream symlink, and ifaddrs into libexecdir, which is where gp_bash_functions.sh looks for it - the six gpdemo scripts, which live in gpAux/gpdemo but are installed from gpMgmt/bin - gp_bash_version.sh generated from its template; configure.ac does this with an inline sed because the placeholder is ##version## rather than @VERSION@, and writes the result into the source tree putversion rewrites $Revision$ in ~48 files *after* installing them, which meson cannot do. subst_version.py performs the same substitution on the way into the build directory instead, so the installed file is already correct. It is applied to exactly the files the Makefiles apply putversion to; the two that are left untouched here are untouched by the autoconf build as well. Not ported: --with-pythonsrc-ext (dropped by decision - it downloads psutil, PyYAML and PyGreSQL from PyPI during install), and the behave test targets. Assisted-by: Claude Code --- gpMgmt/bin/gpcheckcat_modules/meson.build | 28 ++++++++ gpMgmt/bin/gpconfig_modules/meson.build | 27 +++++++ gpMgmt/bin/gppylib/commands/meson.build | 24 +++++++ gpMgmt/bin/gppylib/data/meson.build | 15 ++++ gpMgmt/bin/gppylib/db/meson.build | 22 ++++++ gpMgmt/bin/gppylib/gpMgmttest/meson.build | 15 ++++ gpMgmt/bin/gppylib/meson.build | 56 +++++++++++++++ gpMgmt/bin/gppylib/operations/meson.build | 39 ++++++++++ gpMgmt/bin/gppylib/programs/meson.build | 35 +++++++++ gpMgmt/bin/gppylib/system/meson.build | 31 ++++++++ gpMgmt/bin/gppylib/util/meson.build | 15 ++++ gpMgmt/bin/gpssh_modules/meson.build | 22 ++++++ gpMgmt/bin/ifaddrs/meson.build | 22 ++++++ gpMgmt/bin/lib/meson.build | 43 +++++++++++ gpMgmt/bin/lib/pexpect/meson.build | 22 ++++++ gpMgmt/bin/meson.build | 88 +++++++++++++++++++++++ gpMgmt/bin/stream/meson.build | 26 +++++++ gpMgmt/bin/subst_version.py | 40 +++++++++++ gpMgmt/doc/gpconfigs/meson.build | 31 ++++++++ gpMgmt/doc/meson.build | 17 +++++ gpMgmt/meson.build | 25 +++++++ gpMgmt/sbin/meson.build | 38 ++++++++++ meson.build | 1 + 23 files changed, 682 insertions(+) create mode 100644 gpMgmt/bin/gpcheckcat_modules/meson.build create mode 100644 gpMgmt/bin/gpconfig_modules/meson.build create mode 100644 gpMgmt/bin/gppylib/commands/meson.build create mode 100644 gpMgmt/bin/gppylib/data/meson.build create mode 100644 gpMgmt/bin/gppylib/db/meson.build create mode 100644 gpMgmt/bin/gppylib/gpMgmttest/meson.build create mode 100644 gpMgmt/bin/gppylib/meson.build create mode 100644 gpMgmt/bin/gppylib/operations/meson.build create mode 100644 gpMgmt/bin/gppylib/programs/meson.build create mode 100644 gpMgmt/bin/gppylib/system/meson.build create mode 100644 gpMgmt/bin/gppylib/util/meson.build create mode 100644 gpMgmt/bin/gpssh_modules/meson.build create mode 100644 gpMgmt/bin/ifaddrs/meson.build create mode 100644 gpMgmt/bin/lib/meson.build create mode 100644 gpMgmt/bin/lib/pexpect/meson.build create mode 100644 gpMgmt/bin/meson.build create mode 100644 gpMgmt/bin/stream/meson.build create mode 100755 gpMgmt/bin/subst_version.py create mode 100644 gpMgmt/doc/gpconfigs/meson.build create mode 100644 gpMgmt/doc/meson.build create mode 100644 gpMgmt/meson.build create mode 100644 gpMgmt/sbin/meson.build diff --git a/gpMgmt/bin/gpcheckcat_modules/meson.build b/gpMgmt/bin/gpcheckcat_modules/meson.build new file mode 100644 index 00000000000..f9520e6acf7 --- /dev/null +++ b/gpMgmt/bin/gpcheckcat_modules/meson.build @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'foreign_key_check.py', + 'leaked_schema_dropper.py', + 'orphan_toast_table_issues.py', + 'orphaned_toast_tables_check.py', + 'repair.py', + 'repair_missing_extraneous.py', + 'unique_index_violation_check.py', + install_dir: dir_bin / 'gpcheckcat_modules', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/gpconfig_modules/meson.build b/gpMgmt/bin/gpconfig_modules/meson.build new file mode 100644 index 00000000000..e74ab50af5b --- /dev/null +++ b/gpMgmt/bin/gpconfig_modules/meson.build @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'compare_segment_guc.py', + 'database_segment_guc.py', + 'file_segment_guc.py', + 'guc_collection.py', + 'parse_guc_metadata.py', + 'segment_guc.py', + install_dir: dir_bin / 'gpconfig_modules', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/gppylib/commands/meson.build b/gpMgmt/bin/gppylib/commands/meson.build new file mode 100644 index 00000000000..fbacd2cb87d --- /dev/null +++ b/gpMgmt/bin/gppylib/commands/meson.build @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'dca.py', + 'gp.py', + 'pg.py', + 'unix.py', + install_dir: gppylib_dir / 'commands', +) diff --git a/gpMgmt/bin/gppylib/data/meson.build b/gpMgmt/bin/gppylib/data/meson.build new file mode 100644 index 00000000000..37d57148321 --- /dev/null +++ b/gpMgmt/bin/gppylib/data/meson.build @@ -0,0 +1,15 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. diff --git a/gpMgmt/bin/gppylib/db/meson.build b/gpMgmt/bin/gppylib/db/meson.build new file mode 100644 index 00000000000..d9038a9aaab --- /dev/null +++ b/gpMgmt/bin/gppylib/db/meson.build @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'catalog.py', + 'dbconn.py', + install_dir: gppylib_dir / 'db', +) diff --git a/gpMgmt/bin/gppylib/gpMgmttest/meson.build b/gpMgmt/bin/gppylib/gpMgmttest/meson.build new file mode 100644 index 00000000000..37d57148321 --- /dev/null +++ b/gpMgmt/bin/gppylib/gpMgmttest/meson.build @@ -0,0 +1,15 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. diff --git a/gpMgmt/bin/gppylib/meson.build b/gpMgmt/bin/gppylib/meson.build new file mode 100644 index 00000000000..ed9499c0208 --- /dev/null +++ b/gpMgmt/bin/gppylib/meson.build @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +gppylib_dir = get_option('libdir') / 'python' / 'gppylib' + +foreach s : ['commands', 'data', 'db', 'gpMgmttest', 'operations', 'programs', 'system', 'util'] + subdir(s) +endforeach + +install_data( + 'gparray.py', + 'gpunit', + 'unit2', + install_dir: gppylib_dir, + install_mode: 'rwxr-xr-x', +) + +install_data( + '__init__.py', + 'datetimeutils.py', + 'gp_era.py', + 'gpcatalog.py', + 'gplog.py', + 'gpparseopts.py', + 'gpresgroup.py', + 'gpsubprocess.py', + 'gpversion.py', + 'heapchecksum.py', + 'logfilter.py', + 'parseutils.py', + 'pgconf.py', + 'recoveryinfo.py', + 'userinput.py', + 'utils.py', + install_dir: gppylib_dir, +) + +# putversion is applied to mainUtils.py specifically +install_data( + configure_file(input: 'mainUtils.py', output: 'mainUtils.py', + command: [python, gpmgmt_subst_version, '@INPUT@', '@OUTPUT@', gp_version_long]), + install_dir: gppylib_dir, +) diff --git a/gpMgmt/bin/gppylib/operations/meson.build b/gpMgmt/bin/gppylib/operations/meson.build new file mode 100644 index 00000000000..2874a7a6e67 --- /dev/null +++ b/gpMgmt/bin/gppylib/operations/meson.build @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + 'initstandby.py', + 'test_utils_helper.py', + install_dir: gppylib_dir / 'operations', + install_mode: 'rwxr-xr-x', +) + +install_data( + '__init__.py', + 'buildMirrorSegments.py', + 'deletesystem.py', + 'detect_unreachable_hosts.py', + 'package.py', + 'rebalanceSegments.py', + 'reload.py', + 'segment_reconfigurer.py', + 'segment_tablespace_locations.py', + 'startSegments.py', + 'unix.py', + 'update_pg_hba_on_segments.py', + 'utils.py', + install_dir: gppylib_dir / 'operations', +) diff --git a/gpMgmt/bin/gppylib/programs/meson.build b/gpMgmt/bin/gppylib/programs/meson.build new file mode 100644 index 00000000000..0da6d208d5d --- /dev/null +++ b/gpMgmt/bin/gppylib/programs/meson.build @@ -0,0 +1,35 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'programIoUtils.py', + install_dir: gppylib_dir / 'programs', +) + +# putversion is applied to these specific files by this directory's Makefile +foreach f : [ + 'clsAddMirrors.py', + 'clsRecoverSegment.py', + 'clsRecoverSegment_triples.py', + 'clsSystemState.py', +] + install_data( + configure_file(input: f, output: f, + command: [python, gpmgmt_subst_version, '@INPUT@', '@OUTPUT@', gp_version_long]), + install_dir: gppylib_dir / 'programs', + ) +endforeach diff --git a/gpMgmt/bin/gppylib/system/meson.build b/gpMgmt/bin/gppylib/system/meson.build new file mode 100644 index 00000000000..ab7ed9bb8b8 --- /dev/null +++ b/gpMgmt/bin/gppylib/system/meson.build @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'configurationImplGpdb.py', + 'configurationInterface.py', + 'environment.py', + 'faultProberImplGpdb.py', + 'faultProberInterface.py', + 'fileSystemImplOs.py', + 'fileSystemImplTest.py', + 'fileSystemInterface.py', + 'info.py', + 'osImplNative.py', + 'osInterface.py', + install_dir: gppylib_dir / 'system', +) diff --git a/gpMgmt/bin/gppylib/util/meson.build b/gpMgmt/bin/gppylib/util/meson.build new file mode 100644 index 00000000000..37d57148321 --- /dev/null +++ b/gpMgmt/bin/gppylib/util/meson.build @@ -0,0 +1,15 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. diff --git a/gpMgmt/bin/gpssh_modules/meson.build b/gpMgmt/bin/gpssh_modules/meson.build new file mode 100644 index 00000000000..8aa178200ea --- /dev/null +++ b/gpMgmt/bin/gpssh_modules/meson.build @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'gppxssh_wrapper.py', + install_dir: dir_bin / 'gpssh_modules', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/ifaddrs/meson.build b/gpMgmt/bin/ifaddrs/meson.build new file mode 100644 index 00000000000..e4aa339e035 --- /dev/null +++ b/gpMgmt/bin/ifaddrs/meson.build @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# The only thing Cloudberry installs into libexecdir. gp_bash_functions.sh +# calls "$GPHOME"/libexec/ifaddrs, so the location matters. +ifaddrs_bin = executable('ifaddrs', + files('main.c'), + kwargs: default_bin_args + {'install_dir': get_option('libexecdir')}, +) diff --git a/gpMgmt/bin/lib/meson.build b/gpMgmt/bin/lib/meson.build new file mode 100644 index 00000000000..4f52cf367af --- /dev/null +++ b/gpMgmt/bin/lib/meson.build @@ -0,0 +1,43 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +subdir('pexpect') + +install_data( + '__init__.py', + 'gp_bash_functions.sh', + 'gpconfigurenewsegment', + 'gpcreateseg.sh', + 'gppinggpfdist.py', + 'gpstate.py', + 'multidd', + install_dir: dir_bin / 'lib', + install_mode: 'rwxr-xr-x', +) + +# gp_bash_version.sh is generated from a template. configure.ac does this with +# an inline sed because the placeholder is ##version## rather than @VERSION@, +# and writes the result into the source tree; do it properly here. +install_data( + configure_file( + input: 'gp_bash_version.sh.in', + output: 'gp_bash_version.sh', + command: [sed, 's,##.*##,' + gp_version_long + ',', '@INPUT@'], + capture: true, + ), + install_dir: dir_bin / 'lib', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/lib/pexpect/meson.build b/gpMgmt/bin/lib/pexpect/meson.build new file mode 100644 index 00000000000..d9fb828708e --- /dev/null +++ b/gpMgmt/bin/lib/pexpect/meson.build @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + '__init__.py', + 'pxssh.py', + install_dir: dir_bin / 'lib' / 'pexpect', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/meson.build b/gpMgmt/bin/meson.build new file mode 100644 index 00000000000..f3d26d229c0 --- /dev/null +++ b/gpMgmt/bin/meson.build @@ -0,0 +1,88 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +subdir('stream') +subdir('ifaddrs') +subdir('gpcheckcat_modules') +subdir('gpconfig_modules') +subdir('gpssh_modules') +subdir('gppylib') +subdir('lib') + +# Top-level management utilities. putversion rewrites these after install in +# the autoconf build; meson substitutes on the way into the build directory. +foreach f : [ + 'analyzedb', + 'gpactivatestandby', + 'gpaddmirrors', + 'gpcheckcat', + 'gpcheckperf', + 'gpcheckresgroupimpl', + 'gpcheckresgroupv2impl', + 'gpconfig', + 'gpdeletesystem', + 'gpdemo', + 'gpdirtableload', + 'gpexpand', + 'gpinitstandby', + 'gpinitsystem', + 'gpload', + 'gpload.py', + 'gplogfilter', + 'gpmemreport', + 'gpmemwatcher', + 'gpmovemirrors', + 'gppkg', + 'gprecoverseg', + 'gpreload', + 'gpsd', + 'gpshrink', + 'gpssh', + 'gpssh-exkeys', + 'gpstart', + 'gpstate', + 'gpstop', + 'gpsync', + 'minirepro', +] + install_data( + configure_file(input: f, output: f, + command: [python, gpmgmt_subst_version, '@INPUT@', '@OUTPUT@', gp_version_long]), + install_dir: dir_bin, + install_mode: 'rwxr-xr-x', + ) +endforeach + +install_data('gpload.bat', install_dir: dir_bin) + +# GPDEMO_LIBS: the demo-cluster scripts live in gpAux/gpdemo but are installed +# from here (bin/Makefile), into $bindir/lib/gpdemo. +install_data( + '../../gpAux/gpdemo/README', + '../../gpAux/gpdemo/demo_cluster.sh', + '../../gpAux/gpdemo/generate_certs.sh', + '../../gpAux/gpdemo/gpdemo-defaults.sh', + '../../gpAux/gpdemo/lalshell', + '../../gpAux/gpdemo/probe_config.sh', + install_dir: dir_bin / 'lib' / 'gpdemo', + install_mode: 'rwxr-xr-x', +) + +# if [ ! -L $(bindir)/lib/gpcheckcat ]; then ln -s ../gpcheckcat gpcheckcat +install_symlink('gpcheckcat', + install_dir: dir_bin / 'lib', + pointing_to: '..' / 'gpcheckcat', +) diff --git a/gpMgmt/bin/stream/meson.build b/gpMgmt/bin/stream/meson.build new file mode 100644 index 00000000000..f5794642e22 --- /dev/null +++ b/gpMgmt/bin/stream/meson.build @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +stream_bin = executable('stream', + files('stream.c'), + kwargs: default_bin_args + {'install_dir': dir_bin / 'lib'}, +) + +# Symlink kept for backward compatibility: $bindir/stream/stream -> ../lib/stream +install_symlink('stream', + install_dir: dir_bin / 'stream', + pointing_to: '..' / 'lib' / 'stream', +) diff --git a/gpMgmt/bin/subst_version.py b/gpMgmt/bin/subst_version.py new file mode 100755 index 00000000000..72cd15b3430 --- /dev/null +++ b/gpMgmt/bin/subst_version.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +"""Substitute the Cloudberry version into a management utility. + +The autoconf build does this with ./putversion, which rewrites files *after* +they have been installed. meson never modifies installed files, so the +substitution happens on the way into the build directory instead and the +result is what gets installed. + +putversion replaces a literal $Revision...$ placeholder with the contents of +the VERSION file, with '-' turned into ' '. + +Usage: subst_version.py +""" +import re +import sys + +src, dst, version = sys.argv[1], sys.argv[2], sys.argv[3] + +with open(src, encoding='utf-8', errors='surrogateescape') as fh: + text = fh.read() + +text = re.sub(r'\$Revision.*?\$', version.replace('-', ' '), text) + +with open(dst, 'w', encoding='utf-8', errors='surrogateescape') as fh: + fh.write(text) diff --git a/gpMgmt/doc/gpconfigs/meson.build b/gpMgmt/doc/gpconfigs/meson.build new file mode 100644 index 00000000000..34f8aa18d88 --- /dev/null +++ b/gpMgmt/doc/gpconfigs/meson.build @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +install_data( + 'gpinitsystem_config', + 'gpinitsystem_singlenode', + 'gpinitsystem_test', + 'hostfile_exkeys', + 'hostfile_gpchecknet_ic1', + 'hostfile_gpchecknet_ic2', + 'hostfile_gpcheckperf', + 'hostfile_gpexpand', + 'hostfile_gpinitsystem', + 'hostfile_gpssh_allhosts', + 'hostfile_gpssh_segonly', + 'hostlist_singlenode', + install_dir: dir_prefix / 'docs' / 'cli_help' / 'gpconfigs', +) diff --git a/gpMgmt/doc/meson.build b/gpMgmt/doc/meson.build new file mode 100644 index 00000000000..61c17f8b006 --- /dev/null +++ b/gpMgmt/doc/meson.build @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +subdir('gpconfigs') diff --git a/gpMgmt/meson.build b/gpMgmt/meson.build new file mode 100644 index 00000000000..d741705b5b5 --- /dev/null +++ b/gpMgmt/meson.build @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# The management utilities are almost entirely file installs; the autoconf +# build spends four levels of recursive make on them. Two small C programs +# (stream, ifaddrs) are the only things compiled here. + +gpmgmt_subst_version = files('bin/subst_version.py') + +subdir('sbin') +subdir('bin') +subdir('doc') diff --git a/gpMgmt/sbin/meson.build b/gpMgmt/sbin/meson.build new file mode 100644 index 00000000000..0f603ed02f6 --- /dev/null +++ b/gpMgmt/sbin/meson.build @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# putversion rewrites these after install in the autoconf build; meson +# substitutes on the way into the build directory instead. +foreach f : [ + 'gpcleansegmentdir.py', + 'gpconfig_helper.py', + 'gpgetstatususingtransition.py', + 'gpoperation.py', + 'gpsegrecovery.py', + 'gpsegsetuprecovery.py', + 'gpsegstart.py', + 'gpsegstop.py', + 'packcore', + 'recovery_base.py', + 'seg_update_pg_hba.py', +] + install_data( + configure_file(input: f, output: f, + command: [python, gpmgmt_subst_version, '@INPUT@', '@OUTPUT@', gp_version_long]), + install_dir: get_option('sbindir'), + install_mode: 'rwxr-xr-x', + ) +endforeach diff --git a/meson.build b/meson.build index 66e08b16840..e0c0f42a1bc 100644 --- a/meson.build +++ b/meson.build @@ -3264,6 +3264,7 @@ subdir('src') subdir('contrib') subdir('gpcontrib') +subdir('gpMgmt') subdir('src/test') # ecpg is not built by Cloudberry; see src/interfaces/meson.build From b1cd26064f3f3fe0dcfb95759245c5f455573f7d Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sun, 30 Aug 2026 10:03:56 +0800 Subject: [PATCH 06/13] meson: build the remaining Cloudberry components Everything left that the autoconf build produces and meson did not: the frontend binaries under src/bin (gpfts, gpnetbench, pg_alterckey), and the gpcontrib components that need more than a PGXS-shaped extension -- gpmapreduce, gp_stats_collector, gpcloud with gpcheckcloud, and diskquota. Three needed something other than a straight translation. gpmapreduce's generated scanner and parser hardcode their own output names with %output= and %option outfile=, which override the -o meson passes, so bison and flex run with the build directory as their working directory. gp_stats_collector generates C++ from protobuf, so protoc runs from the extension root: its -I has to be a textual prefix of every input path, and the sources import "protos/xxx.proto". diskquota is a cmake project in tree. Rather than shell out to cmake from meson -- two build systems, two configurations, one of them invisible to ninja -- its sources are listed directly, which is what the rest of this port does with everything else. libpostgres.so comes with them, and with the symbol map the Makefiles generate: the shared backend must not re-export libpq's symbols, or an extension linked against libpq gets the backend's copies. gen_symbol_map.py derives the list from src/interfaces/libpq/exports.txt, as the Makefile does, and emits a version script on Linux and an -unexported_symbols_list on darwin. Assisted-by: Claude Code --- gpcontrib/diskquota/meson.build | 69 +++++++++++++++++++ gpcontrib/gp_stats_collector/meson.build | 64 +++++++++++++++++ .../gp_stats_collector/protos/meson.build | 38 ++++++++++ .../gpcloud/bin/gpcheckcloud/meson.build | 30 ++++++++ gpcontrib/gpcloud/meson.build | 68 ++++++++++++++++++ gpcontrib/gpmapreduce/meson.build | 59 ++++++++++++++++ gpcontrib/meson.build | 20 ++++++ meson.build | 19 ++++- src/backend/gen_symbol_map.py | 59 ++++++++++++++++ src/backend/main/meson.build | 5 +- src/backend/meson.build | 64 ++++++++++++++++- src/bin/gpfts/meson.build | 47 +++++++++++++ src/bin/gpnetbench/meson.build | 24 +++++++ src/bin/meson.build | 3 + src/bin/pg_alterckey/meson.build | 29 ++++++++ 15 files changed, 595 insertions(+), 3 deletions(-) create mode 100644 gpcontrib/diskquota/meson.build create mode 100644 gpcontrib/gp_stats_collector/meson.build create mode 100644 gpcontrib/gp_stats_collector/protos/meson.build create mode 100644 gpcontrib/gpcloud/bin/gpcheckcloud/meson.build create mode 100644 gpcontrib/gpcloud/meson.build create mode 100644 gpcontrib/gpmapreduce/meson.build create mode 100755 src/backend/gen_symbol_map.py create mode 100644 src/bin/gpfts/meson.build create mode 100644 src/bin/gpnetbench/meson.build create mode 100644 src/bin/pg_alterckey/meson.build diff --git a/gpcontrib/diskquota/meson.build b/gpcontrib/diskquota/meson.build new file mode 100644 index 00000000000..86c76e7df54 --- /dev/null +++ b/gpcontrib/diskquota/meson.build @@ -0,0 +1,69 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# diskquota ships a standalone CMake project whose Makefile is a thin shim. +# Almost all of that CMake exists to discover PostgreSQL's paths and flags via +# pg_config (cmake/Gpdb.cmake), which meson already knows, so the extension is +# built natively here instead of shelling out to cmake. Only 7 source files. + +diskquota_version = run_command('cat', files('VERSION'), check: true).stdout().strip() +diskquota_version_parts = diskquota_version.split('.') +diskquota_major = diskquota_version_parts[0] +diskquota_minor = diskquota_version_parts[1] +diskquota_patch = diskquota_version_parts[2] + +# CMakeLists.txt: 1.0 keeps the bare name, everything else is suffixed. +if diskquota_major + '.' + diskquota_minor == '1.0' + diskquota_binary_name = 'diskquota' +else + diskquota_binary_name = 'diskquota-' + diskquota_major + '.' + diskquota_minor +endif + +diskquota_c_args = [ + '-DDISKQUOTA_VERSION="' + diskquota_version + '"', + '-DDISKQUOTA_MAJOR_VERSION=' + diskquota_major, + '-DDISKQUOTA_MINOR_VERSION=' + diskquota_minor, + '-DDISKQUOTA_PATCH_VERSION=' + diskquota_patch, + '-DDISKQUOTA_BINARY_NAME="' + diskquota_binary_name + '"', +] + +diskquota = shared_module(diskquota_binary_name, + files( + 'src/diskquota.c', + 'src/diskquota_utility.c', + 'src/enforcement.c', + 'src/gp_activetable.c', + 'src/monitored_db.c', + 'src/quotamodel.c', + 'src/relation_cache.c', + ), + override_options: ['c_std=c99'], + kwargs: contrib_mod_args + { + 'c_args': contrib_mod_args.get('c_args', []) + diskquota_c_args, + 'dependencies': contrib_mod_args['dependencies'] + [libpq], + }, +) +contrib_targets += diskquota + +# install(FILES ${diskquota_DDL} DESTINATION "share/postgresql/extension/") +install_data( + 'control/ddl/diskquota.control', + 'control/ddl/diskquota--2.2.sql', + 'control/ddl/diskquota--2.3.sql', + 'control/ddl/diskquota--2.2--2.3.sql', + 'control/ddl/diskquota--2.3--2.2.sql', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_stats_collector/meson.build b/gpcontrib/gp_stats_collector/meson.build new file mode 100644 index 00000000000..70a4afdac17 --- /dev/null +++ b/gpcontrib/gp_stats_collector/meson.build @@ -0,0 +1,64 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# protoc's proto_path must be the extension root (the .proto files import each +# other as "protos/xxx.proto"), so pass both roots down to protos/meson.build. +gpsc_root_src = meson.current_source_dir() +gpsc_root_build = meson.current_build_dir() + +subdir('protos') + +# PG_CXXFLAGS += -Werror -Wall -Wno-unused-but-set-variable -std=c++17 +# -Isrc/protos -Isrc -Iinclude -DGPBUILD +gpsc_cpp_args = [ + '-Wall', + '-Wno-unused-but-set-variable', + '-DGPBUILD', +] + +gp_stats_collector = shared_module('gp_stats_collector', + files( + 'src/gp_stats_collector.c', + 'src/stat_statements_parser/pg_stat_statements_parser.c', + 'src/Config.cpp', + 'src/EventSender.cpp', + 'src/GpscStat.cpp', + 'src/PgUtils.cpp', + 'src/ProcStats.cpp', + 'src/ProtoUtils.cpp', + 'src/UDSConnector.cpp', + 'src/hook_wrappers.cpp', + 'src/log/LogOps.cpp', + 'src/log/LogSchema.cpp', + 'src/memory/gpdbwrappers.cpp', + ), + gpsc_proto_sources, + include_directories: include_directories('.', 'src', 'protos'), + override_options: ['cpp_std=c++17'], + kwargs: contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + [protobuf], + 'cpp_args': contrib_mod_args.get('cpp_args', []) + gpsc_cpp_args, + }, +) +contrib_targets += gp_stats_collector + +install_data( + 'gp_stats_collector--1.0.sql', + 'gp_stats_collector--1.0--1.1.sql', + 'gp_stats_collector--1.1.sql', + 'gp_stats_collector.control', + kwargs: contrib_data_args, +) diff --git a/gpcontrib/gp_stats_collector/protos/meson.build b/gpcontrib/gp_stats_collector/protos/meson.build new file mode 100644 index 00000000000..d1ea81f25e7 --- /dev/null +++ b/gpcontrib/gp_stats_collector/protos/meson.build @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# The .proto files import each other as "protos/xxx.proto", so protoc's +# proto_path has to be the extension root, not this directory -- matching the +# Makefile's `protoc -I . --cpp_out=src protos/*.proto`. With --cpp_out set to +# the parent build directory, the generated files land back in this directory, +# which is where the outputs are declared. +# +# The Makefile then renames .pb.cc to .pb.cpp so its own pattern rules match; +# meson infers the language from the extension, so no rename is needed. +gpsc_proto_sources = [] + +foreach base : ['gpsc_plan', 'gpsc_metrics', 'gpsc_set_service'] + gpsc_proto_sources += custom_target(base + '_pb', + input: base + '.proto', + output: [base + '.pb.cc', base + '.pb.h'], + # protoc requires -I to be an exact textual prefix of the file argument, + # so both are absolute. + command: [protoc, + '-I', gpsc_root_src, + '--cpp_out=' + gpsc_root_build, + gpsc_root_src / 'protos' / (base + '.proto')], + ) +endforeach diff --git a/gpcontrib/gpcloud/bin/gpcheckcloud/meson.build b/gpcontrib/gpcloud/bin/gpcheckcloud/meson.build new file mode 100644 index 00000000000..0f8e49f177d --- /dev/null +++ b/gpcontrib/gpcloud/bin/gpcheckcloud/meson.build @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# Same sources as the module, rebuilt standalone with the S3_STANDALONE +# defines. The Makefile does this with a hand-rolled cross-directory pattern +# rule (%.o: ../../src/%.cpp); meson just lists the paths. +gpcheckcloud = executable('gpcheckcloud', + files('gpcheckcloud.cpp'), + gpcloud_common_sources, + gpcloud_lib_sources, + cpp_args: ['-DS3_STANDALONE', '-DS3_STANDALONE_CHECKCLOUD'], + include_directories: gpcloud_inc, + override_options: ['cpp_std=c++11'], + dependencies: [frontend_code] + gpcloud_deps, + kwargs: default_bin_args, +) +bin_targets += gpcheckcloud diff --git a/gpcontrib/gpcloud/meson.build b/gpcontrib/gpcloud/meson.build new file mode 100644 index 00000000000..61cc2ab298f --- /dev/null +++ b/gpcontrib/gpcloud/meson.build @@ -0,0 +1,68 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# include/makefile.inc hardcodes +# COMMON_LINK_OPTIONS = -lstdc++ -lxml2 -pthread -lcrypto -lcurl -lz +# COMMON_CPP_FLAGS = -std=c++11 -fPIC -I/usr/include/libxml2 +# -I/usr/local/opt/openssl/include +# The literal paths only work on some machines; use real dependencies instead. +gpcloud_common_sources = files( + 'src/compress_writer.cpp', + 'src/decompress_reader.cpp', + 'src/gpreader.cpp', + 'src/gpwriter.cpp', + 'src/s3bucket_reader.cpp', + 'src/s3common_reader.cpp', + 'src/s3common_writer.cpp', + 'src/s3conf.cpp', + 'src/s3http_headers.cpp', + 'src/s3interface.cpp', + 'src/s3key_reader.cpp', + 'src/s3key_writer.cpp', + 'src/s3log.cpp', + 'src/s3restful_service.cpp', + 'src/s3url.cpp', + 'src/s3utils.cpp', +) + +gpcloud_lib_sources = files( + 'lib/http_parser.cpp', + 'lib/ini.cpp', +) + +gpcloud_inc = include_directories('include', 'lib') +gpcloud_deps = [libcurl, libxml, ssl, zlib, thread_dep] + +gpcloud = shared_module('gpcloud', + files('src/gpcloud.cpp'), + gpcloud_common_sources, + gpcloud_lib_sources, + include_directories: gpcloud_inc, + override_options: ['cpp_std=c++11'], + kwargs: contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + gpcloud_deps, + }, +) +contrib_targets += gpcloud + +# The Makefile overrides contrib-global.mk's install target purely to add this +# symlink: ln -sf gpcloud.so $(pkglibdir)/gps3ext.so +install_symlink('gps3ext' + dlsuffix, + install_dir: dir_lib_pkg, + pointing_to: 'gpcloud' + dlsuffix, +) + +subdir('bin/gpcheckcloud') diff --git a/gpcontrib/gpmapreduce/meson.build b/gpcontrib/gpmapreduce/meson.build new file mode 100644 index 00000000000..d7bcbc19412 --- /dev/null +++ b/gpcontrib/gpmapreduce/meson.build @@ -0,0 +1,59 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# The Makefile generates the scanner and parser into the *source* directory; +# meson's generators put them in the build directory, which is what we want. +# FLEXFLAGS = -i (case-insensitive) is passed through to flex as an extra flag. +# yaml_parse.y and yaml_scan.l hardcode their own output names: +# yaml_parse.y:1 %output="yaml_parse.c" +# yaml_scan.l:1 %option outfile="yaml_scan.c" +# Those directives override -o, so both tools write into the *current +# directory* -- which is why the Makefile does `cd $(SRCDIR)` and passes no -o. +# Run them with the build directory as cwd so the hardcoded names land there. +gpmapreduce_srcdir = meson.current_source_dir() / 'src' + +gpmapreduce_yaml_parse = custom_target('yaml_parse', + input: 'src/yaml_parse.y', + output: ['yaml_parse.c', 'yaml_parse.h'], + command: [bash, '-c', 'cd "$1" && exec "$0" -Wno-deprecated -d "$2"', + bison, meson.current_build_dir(), gpmapreduce_srcdir / 'yaml_parse.y'], +) + +gpmapreduce_yaml_scan = custom_target('yaml_scan', + input: 'src/yaml_scan.l', + output: 'yaml_scan.c', + # FLEXFLAGS = -i in the Makefile: case-insensitive scanner. + command: [bash, '-c', 'cd "$1" && exec "$0" -i "$2"', + flex, meson.current_build_dir(), gpmapreduce_srcdir / 'yaml_scan.l'], +) + +# $(MAPREDOBJS): override CPPFLAGS += -DFRONTEND +gpmapreduce = executable('gpmapreduce', + files('src/main.c', 'src/mapred.c', 'src/parse.c'), + gpmapreduce_yaml_parse, + gpmapreduce_yaml_scan, + c_args: ['-DFRONTEND'], + # '.' picks up this directory in the *build* tree too, where bison puts + # yaml_parse.h -- the generated scanner includes it. + include_directories: include_directories('.', 'src', 'include'), + dependencies: [frontend_code, libpq, libyaml], + kwargs: default_bin_args, +) +bin_targets += gpmapreduce + +# NAME = regress / OBJS = mapred_test.o builds a regress.so used only by this +# directory's installcheck target. It is never installed, so it is deferred +# along with the rest of the test infrastructure. diff --git a/gpcontrib/meson.build b/gpcontrib/meson.build index 62417af2893..a6991376944 100644 --- a/gpcontrib/meson.build +++ b/gpcontrib/meson.build @@ -49,3 +49,23 @@ endif if get_option('orafce').enabled() subdir('orafce') endif + +# --enable-mapreduce; requires libyaml and perl +if get_option('mapreduce').enabled() + subdir('gpmapreduce') +endif + +# --with-gp-stats-collector; requires protobuf and protoc +if get_option('gp_stats_collector').enabled() + subdir('gp_stats_collector') +endif + +# --enable-gpcloud; requires libcurl, libxml2, openssl +if get_option('gpcloud').enabled() + subdir('gpcloud') +endif + +# --with-diskquota +if get_option('diskquota').enabled() + subdir('diskquota') +endif diff --git a/meson.build b/meson.build index e0c0f42a1bc..aee78b5689c 100644 --- a/meson.build +++ b/meson.build @@ -796,8 +796,14 @@ endif # whenever ORCA is built. Upstream only enables C++ for the LLVM JIT, which is # why this has to happen before the LLVM block. add_languages() is idempotent, # so LLVM's own call below still works. +# ORCA is the biggest C++ consumer, but gp_stats_collector, gpcloud and PAX +# are C++ too, so any of them being enabled requires the compiler. orcaopt = get_option('orca') -have_cpp = add_languages('cpp', required: orcaopt, native: false) +cpp_needed = not orcaopt.disabled() \ + or get_option('gp_stats_collector').enabled() \ + or get_option('gpcloud').enabled() \ + or get_option('pax').enabled() +have_cpp = add_languages('cpp', required: cpp_needed, native: false) # Xerces-C, ORCA's only external dependency. # @@ -3102,6 +3108,17 @@ if not gpfdistopt.disabled() or mapreduceopt.enabled() libyaml = dependency('yaml-0.1', required: mapreduceopt.enabled()) endif +# protobuf: required by gp_stats_collector (>= 3.0.0) and by PAX (>= 3.5.0). +# configure.ac uses PKG_CHECK_MODULES([PROTOBUF], ...) plus the protoc binary. +gpscopt = get_option('gp_stats_collector') +protobuf = not_found_dep +protoc = disabler() +if gpscopt.enabled() or get_option('pax').enabled() + protobuf_min = get_option('pax').enabled() ? '>= 3.5.0' : '>= 3.0.0' + protobuf = dependency('protobuf', version: protobuf_min, required: true) + protoc = find_program('protoc', required: true, native: true) +endif + # bzip2: configure.ac does AC_CHECK_LIB(bz2, BZ2_bzDecompress) into global LIBS libbz2opt = get_option('libbz2') if not libbz2opt.disabled() diff --git a/src/backend/gen_symbol_map.py b/src/backend/gen_symbol_map.py new file mode 100755 index 00000000000..e2cb483e025 --- /dev/null +++ b/src/backend/gen_symbol_map.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +"""Generate the linker symbol map that keeps libpq symbols private in postgres. + +Cloudberry compiles frontend symbols into the postgres binary, because the +backend connects to other segments, while extensions dynamically link +libpq.so. Some symbols are unsafe to export from both -- for example +functions that allocate with palloc/pfree in the backend but malloc/free in +the frontend. These are kept private in the postgres binary. + +Equivalent to the awk/grep pipelines behind SYMBOL_MAP_FILE in +src/backend/Makefile. + +Usage: gen_symbol_map.py +""" +import re +import sys + +platform, exports, output = sys.argv[1], sys.argv[2], sys.argv[3] + +# SAFELY_EXPORTED_SYMBOLS_PATTERN in src/backend/Makefile +safe = re.compile(r'(pqsignal|pg_*)') + +symbols = [] +with open(exports, encoding='utf-8') as fh: + for line in fh: + # awk '/^[^#]/': skip comments and blank lines + if not line.strip() or line.startswith('#'): + continue + name = line.split()[0] + if safe.search(name): + continue + symbols.append(name) + +with open(output, 'w', encoding='utf-8') as fh: + if platform == 'darwin': + # -unexported_symbols_list wants mangled names, one per line + for name in symbols: + fh.write('_%s\n' % name) + else: + # --version-script: everything global except these + fh.write('{ global: *; \n local:\n') + for name in symbols: + fh.write('%s;\n' % name) + fh.write('};\n') diff --git a/src/backend/main/meson.build b/src/backend/main/meson.build index 461a8c4b67f..c5891c2db05 100644 --- a/src/backend/main/meson.build +++ b/src/backend/main/meson.build @@ -1,4 +1,7 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group main_file = files('main.c') -backend_sources += main_file + +# main.c is deliberately NOT added to backend_sources. src/backend/Makefile +# filters main/main.o out of libpostgres.so and links it into the postgres +# executable instead, so it is added directly to that target. diff --git a/src/backend/meson.build b/src/backend/meson.build index 72963af7415..b0a02e1ecbf 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -50,6 +50,33 @@ subdir('po', if_found: libintl) backend_link_args = [] backend_link_depends = [] +# Cloudberry compiles frontend symbols into the postgres binary (the backend +# connects to other segments), while extensions dynamically link libpq.so. +# Some symbols are unsafe to export from both -- e.g. functions that use +# palloc/pfree in the backend and malloc/free in the frontend. The linker is +# told to keep them private in postgres, matching SYMBOL_MAPPING_FLAGS in +# src/backend/Makefile. +gen_symbol_map = files('gen_symbol_map.py') +libpq_exports_txt = meson.source_root() / 'src/interfaces/libpq/exports.txt' + +if host_system == 'darwin' + symbol_map = custom_target('hide_symbols.list', + output: 'hide_symbols.list', + command: [python, gen_symbol_map, 'darwin', libpq_exports_txt, '@OUTPUT@'], + ) + backend_link_args += '-Wl,-unexported_symbols_list,@0@'.format(symbol_map.full_path()) + backend_link_depends += symbol_map +elif host_system == 'linux' + symbol_map = custom_target('postgres_symbols.map', + output: 'postgres_symbols.map', + command: [python, gen_symbol_map, 'linux', libpq_exports_txt, '@OUTPUT@'], + ) + backend_link_args += '-Wl,--version-script=@0@'.format(symbol_map.full_path()) + backend_link_depends += symbol_map +else + symbol_map = [] +endif + # On windows when compiling with msvc we need to make postgres export all its # symbols so that extension libraries can use them. For that we need to scan @@ -157,7 +184,9 @@ postgres_link_language = xerces.found() ? 'cpp' : 'c' postgres = executable('postgres', backend_input, - sources: post_export_backend_sources, + # main.c is not part of backend_sources: src/backend/Makefile filters + # main/main.o out of libpostgres.so and links it into this binary instead. + sources: post_export_backend_sources + main_file, objects: backend_objs, link_args: backend_link_args, link_with: backend_link_with, @@ -171,6 +200,39 @@ postgres = executable('postgres', backend_targets += postgres +# --enable-shared-postgres-backend (default yes): in addition to the fully +# linked postgres binary, expose the backend as a shared library. PAX links +# against it. main.c is excluded (see src/backend/main/meson.build). +# +# --enable-link-postgres-with-shared (default no) would make postgres link +# against this library instead of the objects directly; that variant is not +# implemented yet. +if get_option('shared_postgres_backend') + # main.c provides progname and other globals but is excluded from this + # library (it is linked into the postgres executable), so the library has + # undefined symbols that are resolved at load time. + # + # The Makefile only needs an explicit flag on darwin, because it never asks + # the linker to reject undefined symbols in the first place. meson does: + # b_lundef defaults to true, which passes -Wl,--no-undefined on Linux and + # -Wl,-undefined,error on darwin. Turning it off for this target covers both + # platforms -- on darwin meson then emits -Wl,-undefined,dynamic_lookup, + # which is exactly what LIBPOSTGRES_SO_LDFLAGS sets by hand. + libpostgres_so = shared_library('postgres', + objects: backend_objs, + link_whole: backend_link_with, + link_args: backend_link_args, + link_language: postgres_link_language, + link_depends: backend_link_depends, + dependencies: backend_build_deps, + name_prefix: 'lib', + override_options: ['b_lundef=false'], + install: true, + install_dir: dir_lib, + ) + backend_targets += libpostgres_so +endif + pg_mod_c_args = cflags_mod pg_mod_cpp_args = cxxflags_mod pg_mod_link_args = ldflags_sl + ldflags_mod diff --git a/src/bin/gpfts/meson.build b/src/bin/gpfts/meson.build new file mode 100644 index 00000000000..f3497005b40 --- /dev/null +++ b/src/bin/gpfts/meson.build @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# etcd.c is shared with the backend. The Makefile symlinks it into this +# directory; meson references it where it lives. +bin_targets += executable('gpfts', + files( + 'fts.c', + 'fts_etcd.c', + 'ftsprobe.c', + '../../backend/utils/etcd_lib/etcd.c', + ), + include_directories: include_directories('.'), + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, +) + +# Failover helper scripts, installed under $bindir/failover +install_data( + 'failover/docker_master_check_back.sh', + 'failover/docker_segment_check_back.sh', + 'failover/docker_standby_check_back.sh', + 'failover/master_check_back.sh', + 'failover/segment_all_down.sh', + 'failover/segment_check_back.sh', + 'failover/standby_check_back.sh', + install_dir: dir_bin / 'failover', + install_mode: 'rwxr-xr-x', +) + +install_data( + 'config/cbdb_etcd_default.conf', + install_dir: dir_bin / 'config', +) diff --git a/src/bin/gpnetbench/meson.build b/src/bin/gpnetbench/meson.build new file mode 100644 index 00000000000..35af011498b --- /dev/null +++ b/src/bin/gpnetbench/meson.build @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# Two separate binaries, both installed into $bindir/lib rather than $bindir. +foreach prog : ['gpnetbenchServer', 'gpnetbenchClient'] + bin_targets += executable(prog, + files(prog + '.c'), + dependencies: [frontend_code], + kwargs: default_bin_args + {'install_dir': dir_bin / 'lib'}, + ) +endforeach diff --git a/src/bin/meson.build b/src/bin/meson.build index 2457de559ee..2c0ddf47412 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -25,3 +25,6 @@ subdir('scripts') if get_option('gpfdist').enabled() subdir('gpfdist') endif +subdir('gpfts') +subdir('gpnetbench') +subdir('pg_alterckey') diff --git a/src/bin/pg_alterckey/meson.build b/src/bin/pg_alterckey/meson.build new file mode 100644 index 00000000000..84208d584c7 --- /dev/null +++ b/src/bin/pg_alterckey/meson.build @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +pg_alterckey_sources = files('pg_alterckey.c') + +if host_system == 'windows' + pg_alterckey_sources += rc_bin_gen.process(win32ver_rc, extra_args: [ + '--NAME', 'pg_alterckey', + '--FILEDESC', 'pg_alterckey - alter the cluster key',]) +endif + +bin_targets += executable('pg_alterckey', + pg_alterckey_sources, + dependencies: [frontend_code], + kwargs: default_bin_args, +) From 985ff90c6b34e20356f14c356a45a172ccc427d6 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Sun, 30 Aug 2026 17:59:25 +0800 Subject: [PATCH 07/13] meson: build PAX, and enable the remaining components in CI PAX ships a standalone CMake project driven from its Makefile. The meson source list mirrors the groups in src/cpp/cmake/pax.cmake for the default configuration (USE_PAX_CATALOG=ON, USE_MANIFEST_API=OFF, VEC_BUILD off), which is 93 files. Note the mixed extensions: one source is .cpp where the rest are .cc, and missing it produced a module that built cleanly but failed to load with an undefined pax::tools::OrcDumpReader::Dump(). Two pieces of code generation: - protoc, declared in a nested storage/proto/meson.build so the generated headers land in a storage/proto directory inside the build tree, which is how the sources include them. CMake instead writes them back into the source tree. - the extension SQL, which cmake/pax.cmake produces by compiling tools/gen_sql.c and redirecting its stdout into pax-cdbinit--1.0.sql in the source tree; meson captures the output instead. yyjson is not needed: it is only linked when USE_MANIFEST_API is on and USE_PAX_CATALOG is off, which is the opposite of the defaults. tabulate is needed unconditionally (used by a UDF), so PAX requires that submodule. pg_waldump also needs PAX when it is enabled: rmgrdesc.c includes "paxc_desc.h" under USE_PAX_STORAGE, and the Makefile symlinks paxc_desc.[ch] in from contrib/pax_storage. Verified end to end: the pax access method is registered, and a table created with USING pax stores and returns rows. CI now enables gpcloud, mapreduce, diskquota and pax as well, and the smoke test checks the additional binaries and the generated PAX SQL. gp_stats_collector remains off there for the reason recorded in the workflow. Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 16 +- contrib/meson.build | 4 + contrib/pax_storage/meson.build | 165 ++++++++++++++++++ .../src/cpp/storage/proto/meson.build | 36 ++++ .../cloudberry/scripts/meson-smoke-test.sh | 8 +- src/bin/pg_waldump/meson.build | 13 ++ 6 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 contrib/pax_storage/meson.build create mode 100644 contrib/pax_storage/src/cpp/storage/proto/meson.build diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml index b73848379dd..7fb15ecf626 100644 --- a/.github/workflows/build-meson-cloudberry.yml +++ b/.github/workflows/build-meson-cloudberry.yml @@ -35,6 +35,10 @@ # --enable-pxf -> -Dpxf=enabled # --enable-orafce -> -Dorafce=enabled # --enable-ic-proxy -> -Dic_proxy=enabled +# --enable-gpcloud -> -Dgpcloud=enabled +# --enable-mapreduce -> -Dmapreduce=enabled +# --enable-pax -> -Dpax=enabled +# --with-diskquota -> -Ddiskquota=enabled # --enable-tap-tests -> -Dtap_tests=enabled # --with-gssapi -> -Dgssapi=enabled # --with-ldap -> -Dldap=enabled @@ -50,9 +54,11 @@ # --with-includes=... -> -Dextra_include_dirs=... # --with-libraries=... -> -Dextra_lib_dirs=... # -# Not yet reachable from meson, and therefore not enabled here: -# --enable-gpcloud, --enable-pax, --enable-mapreduce, -# --with-diskquota, --with-gp-stats-collector +# Not enabled here: --with-gp-stats-collector. It is wired up, but +# src/hook_wrappers.h declares test_uds_receive() as returning int64_t while +# the definition returns PG's int64. Those are the same type on 64-bit Linux +# and differ on macOS, so it could not be verified locally; enable it once +# someone has confirmed it builds. # # Deliberately dropped: --with-pythonsrc-ext downloads psutil / PyYAML / # PyGreSQL from PyPI during `make install`, which has no honest meson @@ -138,6 +144,10 @@ jobs: -Dorafce=enabled \ -Dic_proxy=enabled \ -Dgpfdist=enabled \ + -Dgpcloud=enabled \ + -Dmapreduce=enabled \ + -Ddiskquota=enabled \ + -Dpax=enabled \ -Dtap_tests=enabled \ -Dgssapi=enabled \ -Dldap=enabled \ diff --git a/contrib/meson.build b/contrib/meson.build index 255e6094413..b5a43dccdfa 100644 --- a/contrib/meson.build +++ b/contrib/meson.build @@ -54,6 +54,10 @@ subdir('pg_walinspect') subdir('postgres_fdw') subdir('seg') subdir('sepgsql') +# --enable-pax; requires protobuf >= 3.5, zstd >= 1.4 and the shared backend +if get_option('pax').enabled() + subdir('pax_storage') +endif subdir('interconnect') subdir('spi') subdir('sslinfo') diff --git a/contrib/pax_storage/meson.build b/contrib/pax_storage/meson.build new file mode 100644 index 00000000000..1b9981e56fe --- /dev/null +++ b/contrib/pax_storage/meson.build @@ -0,0 +1,165 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# +# PAX ships a standalone CMake project driven from its Makefile. The source +# lists here mirror the groups in src/cpp/cmake/pax.cmake for the default +# configuration (USE_PAX_CATALOG=ON, USE_MANIFEST_API=OFF, VEC_BUILD off). + +subdir('src/cpp/storage/proto') + +# --- generated extension SQL --------------------------------------------- +# cmake/pax.cmake builds tools/gen_sql.c and pipes its stdout into +# pax-cdbinit--1.0.sql, writing into the source tree; capture it instead. +pax_gen_sql = executable('pax_gen_sql', + files('tools/gen_sql.c'), + include_directories: include_directories('src/cpp'), + dependencies: [backend_code], + build_by_default: false, + install: false, +) + +pax_cdbinit_sql = custom_target('pax-cdbinit--1.0.sql', + output: 'pax-cdbinit--1.0.sql', + command: [pax_gen_sql], + capture: true, + build_by_default: true, + install: true, + install_dir: dir_data / 'cdb_init.d', +) + +# --- the module ----------------------------------------------------------- +pax_sources = files( + 'src/cpp/access/pax_access_handle.cc', + 'src/cpp/access/pax_access_method_internal.cc', + 'src/cpp/access/pax_deleter.cc', + 'src/cpp/access/pax_dml_state.cc', + 'src/cpp/access/pax_inserter.cc', + 'src/cpp/access/pax_scanner.cc', + 'src/cpp/access/pax_table_cluster.cc', + 'src/cpp/access/pax_updater.cc', + 'src/cpp/access/pax_visimap.cc', + 'src/cpp/access/paxc_rel_options.cc', + 'src/cpp/catalog/pax_aux_table.cc', + 'src/cpp/catalog/pax_fastsequence.cc', + 'src/cpp/catalog/pax_manifest.cc', + 'src/cpp/catalog/pg_pax_tables.cc', + 'src/cpp/clustering/clustering.cc', + 'src/cpp/clustering/index_clustering.cc', + 'src/cpp/clustering/lexical_clustering.cc', + 'src/cpp/clustering/pax_clustering_reader.cc', + 'src/cpp/clustering/pax_clustering_writer.cc', + 'src/cpp/clustering/sorter_index.cc', + 'src/cpp/clustering/sorter_tuple.cc', + 'src/cpp/clustering/zorder_clustering.cc', + 'src/cpp/clustering/zorder_utils.cc', + 'src/cpp/comm/bitmap.cc', + 'src/cpp/comm/bloomfilter.cc', + 'src/cpp/comm/byte_buffer.cc', + 'src/cpp/comm/cbdb_wrappers.cc', + 'src/cpp/comm/fast_io.cc', + 'src/cpp/comm/guc.cc', + 'src/cpp/comm/pax_memory.cc', + 'src/cpp/comm/pax_resource.cc', + 'src/cpp/comm/paxc_wrappers.cc', + 'src/cpp/comm/vec_numeric.cc', + 'src/cpp/exceptions/CException.cc', + 'src/cpp/storage/columns/pax_column.cc', + 'src/cpp/storage/columns/pax_column_traits.cc', + 'src/cpp/storage/columns/pax_columns.cc', + 'src/cpp/storage/columns/pax_compress.cc', + 'src/cpp/storage/columns/pax_decoding.cc', + 'src/cpp/storage/columns/pax_delta_encoding.cc', + 'src/cpp/storage/columns/pax_dict_encoding.cc', + 'src/cpp/storage/columns/pax_encoding.cc', + 'src/cpp/storage/columns/pax_encoding_column.cc', + 'src/cpp/storage/columns/pax_encoding_non_fixed_column.cc', + 'src/cpp/storage/columns/pax_encoding_utils.cc', + 'src/cpp/storage/columns/pax_rlev2_decoding.cc', + 'src/cpp/storage/columns/pax_rlev2_encoding.cc', + 'src/cpp/storage/columns/pax_vec_bitpacked_column.cc', + 'src/cpp/storage/columns/pax_vec_bpchar_column.cc', + 'src/cpp/storage/columns/pax_vec_column.cc', + 'src/cpp/storage/columns/pax_vec_encoding_column.cc', + 'src/cpp/storage/columns/pax_vec_numeric_column.cc', + 'src/cpp/storage/file_system.cc', + 'src/cpp/storage/filter/pax_filter.cc', + 'src/cpp/storage/filter/pax_row_filter.cc', + 'src/cpp/storage/filter/pax_sparse_filter.cc', + 'src/cpp/storage/filter/pax_sparse_pg_path.cc', + 'src/cpp/storage/filter/pax_sparse_vec_path.cc', + 'src/cpp/storage/local_file_system.cc', + 'src/cpp/storage/micro_partition.cc', + 'src/cpp/storage/micro_partition_file_factory.cc', + 'src/cpp/storage/micro_partition_iterator.cc', + 'src/cpp/storage/micro_partition_metadata.cc', + 'src/cpp/storage/micro_partition_row_filter_reader.cc', + 'src/cpp/storage/micro_partition_stats.cc', + 'src/cpp/storage/micro_partition_stats_updater.cc', + 'src/cpp/storage/micro_partition_udf.cc', + 'src/cpp/storage/oper/pax_oper.cc', + 'src/cpp/storage/oper/pax_oper_udf.cc', + 'src/cpp/storage/oper/pax_stats.cc', + 'src/cpp/storage/orc/orc_dump_reader.cpp', + 'src/cpp/storage/orc/orc_format_reader.cc', + 'src/cpp/storage/orc/orc_group.cc', + 'src/cpp/storage/orc/orc_reader.cc', + 'src/cpp/storage/orc/orc_type.cc', + 'src/cpp/storage/orc/orc_vec_group.cc', + 'src/cpp/storage/orc/orc_writer.cc', + 'src/cpp/storage/pax.cc', + 'src/cpp/storage/pax_buffer.cc', + 'src/cpp/storage/pax_itemptr.cc', + 'src/cpp/storage/paxc_smgr.cc', + 'src/cpp/storage/proto/protobuf_stream.cc', + 'src/cpp/storage/strategy.cc', + 'src/cpp/storage/toast/pax_toast.cc', + 'src/cpp/storage/vec/arrow_wrapper.cc', + 'src/cpp/storage/vec/pax_porc_adpater.cc', + 'src/cpp/storage/vec/pax_porc_vec_adpater.cc', + 'src/cpp/storage/vec/pax_vec_adapter.cc', + 'src/cpp/storage/vec/pax_vec_comm.cc', + 'src/cpp/storage/vec/pax_vec_reader.cc', + 'src/cpp/storage/wal/pax_wal.cc', + 'src/cpp/storage/wal/paxc_desc.c', + 'src/cpp/storage/wal/paxc_wal.cc', + +) + +pax_deps = [zstd, zlib, protobuf] +if get_option('lz4').enabled() + pax_deps += lz4 +endif +if host_machine.system() == 'linux' + # cmake/pax.cmake: list(APPEND pax_target_link_libs uring) + pax_deps += dependency('liburing', required: true) +endif + +pax_inc = include_directories( + 'src/cpp', + 'src/cpp/contrib/tabulate/include', +) + +pax = shared_module('pax', + pax_sources, + pax_proto_sources, + include_directories: pax_inc, + override_options: ['cpp_std=c++17'], + kwargs: contrib_mod_args + { + 'dependencies': contrib_mod_args['dependencies'] + pax_deps, + }, +) +contrib_targets += pax diff --git a/contrib/pax_storage/src/cpp/storage/proto/meson.build b/contrib/pax_storage/src/cpp/storage/proto/meson.build new file mode 100644 index 00000000000..7693d58eccb --- /dev/null +++ b/contrib/pax_storage/src/cpp/storage/proto/meson.build @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +# The sources include these as "storage/proto/xxx.pb.h", so the generated +# headers must sit in a storage/proto directory inside the build tree. +# Generating from this subdirectory puts them exactly there; the parent adds +# src/cpp to the include path, which covers the build tree as well. +# +# The CMake build instead runs protoc during configure and writes the results +# back into the source tree (PROTO_OUTPUT_DIR is the source directory). +pax_proto_sources = [] + +foreach base : ['micro_partition_stats', 'pax', 'orc_proto'] + pax_proto_sources += custom_target('pax_' + base + '_pb', + input: base + '.proto', + output: [base + '.pb.cc', base + '.pb.h'], + # protoc needs -I to be an exact textual prefix of the file argument. + command: [protoc, + '-I', meson.current_source_dir(), + '--cpp_out=@OUTDIR@', + meson.current_source_dir() / (base + '.proto')], + ) +endforeach diff --git a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh index 2b221122eea..571f84a0688 100755 --- a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh +++ b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh @@ -36,7 +36,8 @@ fail() { echo "::error::$*" >&2; exit 1; } # 1. Installed artifacts # -------------------------------------------------------------------- echo "== checking installed binaries ==" -for b in postgres initdb pg_ctl psql pg_dump pg_upgrade gpfdist; do +for b in postgres initdb pg_ctl psql pg_dump pg_upgrade gpfdist gpfts \ + gpmapreduce gpcheckcloud pg_alterckey; do [ -x "${PREFIX}/bin/${b}" ] || fail "missing bin/${b}" echo " ok bin/${b}" done @@ -47,6 +48,11 @@ for e in interconnect gp_exttable_fdw gp_toolkit gp_distribution_policy pxf_fdw; echo " ok ${e}" done +echo "== checking PAX ==" +[ -f "${PREFIX}/share/postgresql/cdb_init.d/pax-cdbinit--1.0.sql" ] \ + || fail "missing generated pax-cdbinit--1.0.sql" +echo " ok pax-cdbinit--1.0.sql" + echo "== checking generated catalog data ==" for f in system_views_gp.sql cdb_init.d/cdb_schema.sql postgres.bki; do [ -f "${PREFIX}/share/postgresql/${f}" ] || fail "missing share/postgresql/${f}" diff --git a/src/bin/pg_waldump/meson.build b/src/bin/pg_waldump/meson.build index ae674d17c38..be911027ef2 100644 --- a/src/bin/pg_waldump/meson.build +++ b/src/bin/pg_waldump/meson.build @@ -6,6 +6,18 @@ pg_waldump_sources = files( 'rmgrdesc.c', ) +# rmgrdesc.c includes "paxc_desc.h" under USE_PAX_STORAGE. The Makefile +# symlinks paxc_desc.[ch] in from contrib/pax_storage and adds paxc_desc.o to +# OBJS; meson references them where they live. +pg_waldump_inc = [postgres_inc] +if get_option('pax').enabled() + pg_waldump_sources += files( + '../../../contrib/pax_storage/src/cpp/storage/wal/paxc_desc.c') + pg_waldump_inc += include_directories( + '../../../contrib/pax_storage/src/cpp/storage/wal') +endif + + pg_waldump_sources += rmgr_desc_sources pg_waldump_sources += xlogreader_sources pg_waldump_sources += files('../../backend/access/transam/xlogstats.c') @@ -18,6 +30,7 @@ endif pg_waldump = executable('pg_waldump', pg_waldump_sources, + include_directories: pg_waldump_inc, dependencies: [frontend_code, lz4, zstd], c_args: ['-DFRONTEND'], # needed for xlogreader et al kwargs: default_bin_args, From 54dad806087568aaf653f873beb1f920988aea62 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Mon, 31 Aug 2026 14:00:12 +0800 Subject: [PATCH 08/13] meson: match the autoconf build's NLS and warning settings Two places where the meson build did more than configure.ac asks for. NLS: upstream's meson exposes an nls option; Cloudberry's configure.ac has had --enable-nls deliberately removed since 2015, and the translation catalogues have gone stale in the years since. The option now defaults to disabled and errors if turned on, rather than offering a build nobody maintains. Warnings: configure.ac keeps -Wdeclaration-after-statement commented out, because "GPDB code is full of declarations after statement", and adds -Wno-unused-but-set-variable. meson had neither, which is the whole difference between 2263 warnings and 10 on the same tree. The meson floor moves to 0.61 here, for install_symlink. That turns out to be the wrong trade and is settled later in the series; see "meson: fixes from installing and running the result". Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 2 +- meson.build | 47 +++++++++++++++----- meson_options.txt | 7 ++- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml index 7fb15ecf626..70c3a456289 100644 --- a/.github/workflows/build-meson-cloudberry.yml +++ b/.github/workflows/build-meson-cloudberry.yml @@ -113,7 +113,7 @@ jobs: run: | set -euox pipefail # The build image ships autoconf/make but not meson. - python3 -m pip install --disable-pip-version-check 'meson>=0.54' ninja + python3 -m pip install --disable-pip-version-check 'meson>=0.61' ninja meson --version ninja --version diff --git a/meson.build b/meson.build index aee78b5689c..2e2a0ceeca8 100644 --- a/meson.build +++ b/meson.build @@ -11,10 +11,11 @@ project('postgresql', version: '16.9', license: 'PostgreSQL', - # We want < 0.56 for python 3.5 compatibility on old platforms. EPEL for - # RHEL 7 has 0.55. < 0.54 would require replacing some uses of the fs - # module, < 0.53 all uses of fs. So far there's no need to go to >=0.56. - meson_version: '>=0.54', + # Upstream targets >=0.54 to stay usable on old platforms. Cloudberry needs + # install_symlink (0.61) for three symlinks its Makefiles create: + # $bindir/stream/stream, $bindir/lib/gpcheckcat and gps3ext.so. All platforms + # Cloudberry builds on ship a newer meson, or install it from pip. + meson_version: '>=0.61', default_options: [ 'warning_level=1', #-Wall equivalent 'b_pch=false', @@ -2021,13 +2022,16 @@ if llvm.found() cxxflags_warn += cpp.get_supported_arguments(common_warning_flags) endif -# A few places with imported code get a pass on -Wdeclaration-after-statement, remember -# the result for them +# Upstream enables -Wdeclaration-after-statement here. Cloudberry does not: +# configure.ac keeps that check commented out because, in its own words, "GPDB +# code is full of declarations after statement". Enabling it produces a couple +# of thousand warnings and no signal. +# +# Because the positive flag is never added, configure.ac also leaves +# PERMIT_DECLARATION_AFTER_STATEMENT empty, so the places that would opt out +# of the warning (src/common's ryu code) need nothing either. Keep the variable +# defined so those call sites stay unchanged. cflags_no_decl_after_statement = [] -if cc.has_argument('-Wdeclaration-after-statement') - cflags_warn += '-Wdeclaration-after-statement' - cflags_no_decl_after_statement += '-Wno-declaration-after-statement' -endif # The following tests want to suppress various unhelpful warnings by adding @@ -2050,6 +2054,11 @@ negative_warning_flags = [ # Suppress clang 16's strict warnings about function casts 'cast-function-type-strict', + # Variables that are set but otherwise unused. configure.ac disables this + # too: the warnings were all fixed upstream, but Cloudberry-added code still + # emits them. Its TODO to fix that code and drop this applies here as well. + 'unused-but-set-variable', + # To make warning_level=2 / -Wextra work, we'd need at least the following # 'clobbered', # 'missing-field-initializers', @@ -2745,6 +2754,24 @@ cdata.set('ENABLE_THREAD_SAFETY', 1) ############################################################### nlsopt = get_option('nls') + +# Cloudberry does not support NLS, and has not since Greenplum removed it in +# 2015 (commit 7afc98bca0c, "Remove support for NLS."): there are no +# translations for Greenplum- or Cloudberry-specific strings, and all .po +# files were deleted at the time. configure.ac keeps the whole NLS block +# commented out, so --enable-nls is not even an option there. +# +# The PG16 merge reintroduced some upstream .po files and the po/LINGUAS files +# that PG16 added, but the two do not agree: LINGUAS came in whole from +# upstream while the .po set did not, so several LINGUAS entries name catalogs +# that are not in the tree. Building with NLS would fail on those, and would +# in any case produce catalogs covering only upstream messages. +# +# Fail loudly rather than half-translate; see configure.ac for the conditions +# under which NLS could be supported properly. +if nlsopt.enabled() + error('NLS is not supported by Cloudberry; see the NLS comment in configure.ac') +endif libintl = not_found_dep if not nlsopt.disabled() diff --git a/meson_options.txt b/meson_options.txt index cbfa9da6438..efec0e486e7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -115,8 +115,11 @@ option('llvm', type: 'feature', value: 'disabled', option('lz4', type: 'feature', value: 'auto', description: 'LZ4 support') -option('nls', type: 'feature', value: 'auto', - description: 'Native language support') +# Cloudberry does not support NLS. See the comment in configure.ac and the +# error raised in meson.build; upstream's default here is 'auto', which would +# silently enable NLS whenever gettext happens to be installed. +option('nls', type: 'feature', value: 'disabled', + description: 'Native language support (not supported by Cloudberry)') option('pam', type: 'feature', value: 'auto', description: 'PAM support') From 7c469aa2b0d63e83b3a3c489b0e75473c4c55ba2 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Mon, 31 Aug 2026 16:54:33 +0800 Subject: [PATCH 09/13] ci: build a matrix of meson configurations and test a real demo cluster Mirrors build-cloudberry.yml's shape -- check-skip, build, test, report -- so that test jobs can be added alongside cluster-test later. The build matrix is the part that earns its keep today. Most of the bugs found while porting were in option combinations rather than in any single configuration: C++ being enabled only for ORCA, PAX requiring the shared backend, extensions gated on flags never exercised together. Three configurations cover that surface: full every component this branch supports minimal everything optional off, which catches conditional guards that only work when enabled no-shared-backend -Dshared_postgres_backend=false, a path nothing else covers; PAX comes off with it since PAX links against libpostgres.so cluster-test goes past what the smoke test can reach. meson-smoke-test.sh only runs single-user mode, so it never starts a segment. The new script brings up a real multi-segment cluster with gpinitsystem and then checks that data actually distributes (1000 rows across segments, not just 1000 rows), that a plan contains a Motion node, that ORCA plans a distributed join, and that ao_row and pax tables work distributed. That also makes it the first test of two things the build alone cannot prove: the gpMgmt install is complete enough to run gpinitsystem, and dropping --with-pythonsrc-ext is workable -- psutil, PyGreSQL and PyYAML are installed from python-dependencies.txt instead of being vendored. Two checks are new in the build job: meson_version feature warnings are fatal, since they are cheap to fix and easy to let accumulate, and the compiler warning count is reported to the step summary, because a jump there usually means the meson flags have drifted from configure.ac. Regression suites are still not run. src/test/regress and friends are make-driven and include src/Makefile.global from the source tree, which only a configure run produces, so they cannot execute against a meson-only tree. meson also now installs $prefix/cloudberry-env.sh, which gpMgmt/Makefile generates and which demo_cluster.sh sources; without it the cluster test could not run, and an install was not usable the way an autoconf one is. Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 311 +++++++++++++++--- .../cloudberry/scripts/meson-cluster-test.sh | 147 +++++++++ gpMgmt/meson.build | 16 + 3 files changed, 430 insertions(+), 44 deletions(-) create mode 100755 devops/build/automation/cloudberry/scripts/meson-cluster-test.sh diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml index 70c3a456289..b0838c8d965 100644 --- a/.github/workflows/build-meson-cloudberry.yml +++ b/.github/workflows/build-meson-cloudberry.yml @@ -19,15 +19,37 @@ # Apache Cloudberry Meson Build # # PostgreSQL 16 introduced meson as a second build system alongside -# autoconf/make. This workflow builds Cloudberry with meson and runs a smoke -# test, so that the meson path keeps working while it is brought up to parity -# with the autoconf path. +# autoconf/make. This workflow builds Cloudberry with meson, brings up a real +# demo cluster on the result, and exercises the MPP paths against it. # # This does NOT replace the autoconf build. Until the two are proven -# equivalent, `build-cloudberry.yml` remains the authoritative build; this +# equivalent, build-cloudberry.yml remains the authoritative build; this # workflow exists to stop the meson files from rotting and to surface # divergence early. # +# Shape, mirroring build-cloudberry.yml: +# +# check-skip -> build (matrix) -> cluster-test -> report +# +# The build matrix is the part that earns its keep today. Most of the bugs +# found while porting were in option combinations rather than in any single +# configuration: C++ being enabled only for ORCA, PAX requiring the shared +# backend, extensions gated on flags that were never exercised together. Three +# configurations cover that surface: +# +# full every component this branch supports +# minimal everything optional switched off, which catches +# conditional guards that only work when enabled +# no-shared-backend -Dshared_postgres_backend=false, a path nothing else +# covers (PAX has to come off with it, since PAX links +# against libpostgres.so) +# +# Regression suites are NOT run here yet. src/test/regress and friends are +# make-driven and include src/Makefile.global from the source tree, which only +# a configure run produces, so they cannot execute against a meson-only tree. +# Porting them is separate work; this workflow is structured so those jobs can +# be added alongside cluster-test once that lands. +# # Option mapping, against the reference configure line in coverity.yml: # # --disable-external-fts -> -Dexternal_fts=false @@ -62,7 +84,8 @@ # # Deliberately dropped: --with-pythonsrc-ext downloads psutil / PyYAML / # PyGreSQL from PyPI during `make install`, which has no honest meson -# equivalent. Those are external runtime dependencies for the meson build. +# equivalent. They are external runtime dependencies instead, which is why +# cluster-test installs them before calling gpinitsystem. # -------------------------------------------------------------------- name: Apache Cloudberry Meson Build @@ -80,10 +103,93 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + BUILD_IMAGE: apache/incubator-cloudberry:cbdb-build-rocky9-latest + INSTALL_PREFIX: /usr/local/cloudberry-db + MESON_VERSION: '>=0.61' + jobs: - meson-build: - name: Meson build and smoke test + # ------------------------------------------------------------------ + check-skip: + name: Check skip + runs-on: ubuntu-22.04 + outputs: + should_skip: ${{ steps.skip-check.outputs.should_skip }} + steps: + - id: skip-check + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + PR_TITLE: ${{ github.event.pull_request.title || '' }} + PR_BODY: ${{ github.event.pull_request.body || '' }} + run: | + echo "should_skip=false" >> "$GITHUB_OUTPUT" + if [[ "$EVENT_NAME" == "pull_request" ]]; then + MESSAGE="${PR_TITLE} ${PR_BODY}" + if printf '%s' "$MESSAGE" | grep -qEi '\[skip[ -]ci\]|\[ci[ -]skip\]'; then + echo "Skip requested by PR title/body" + echo "should_skip=true" >> "$GITHUB_OUTPUT" + fi + fi + + # ------------------------------------------------------------------ + build: + name: Build (${{ matrix.name }}) runs-on: ubuntu-22.04 + needs: [check-skip] + if: needs.check-skip.outputs.should_skip != 'true' + + strategy: + fail-fast: false + matrix: + include: + - name: full + upload: true + options: >- + -Dexternal_fts=false + -Dorca=enabled + -Dpxf=enabled + -Dorafce=enabled + -Dic_proxy=enabled + -Dgpfdist=enabled + -Dgpcloud=enabled + -Dmapreduce=enabled + -Ddiskquota=enabled + -Dpax=enabled + -Dtap_tests=enabled + -Dgssapi=enabled + -Dldap=enabled + -Dlibxml=enabled + -Dlz4=enabled + -Dzstd=enabled + -Dpam=enabled + -Dplperl=enabled + -Dplpython=enabled + -Dssl=openssl + -Duuid=e2fs + -Dpgport=5432 + - name: minimal + upload: false + options: >- + -Dorca=disabled + -Dpxf=disabled + -Dorafce=disabled + -Dic_proxy=disabled + -Dgpfdist=disabled + -Dgpcloud=disabled + -Dmapreduce=disabled + -Ddiskquota=disabled + -Dpax=disabled + -Ddebug_extensions=false + -Dtap_tests=disabled + - name: no-shared-backend + upload: false + options: >- + -Dshared_postgres_backend=false + -Dpax=disabled + -Dorca=enabled + -Dgpfdist=enabled + -Dpxf=enabled container: image: apache/incubator-cloudberry:cbdb-build-rocky9-latest @@ -91,10 +197,6 @@ jobs: --user root -h cdw - env: - BUILD_DIR: build-meson - INSTALL_PREFIX: /usr/local/cloudberry-db - steps: - name: Checkout Apache Cloudberry uses: actions/checkout@v7 @@ -102,7 +204,7 @@ jobs: fetch-depth: 0 submodules: true - - name: Environment Initialization + - name: Environment initialization run: | if ! su - gpadmin -c "/tmp/init_system.sh"; then echo "::error::Container initialization failed" @@ -113,7 +215,7 @@ jobs: run: | set -euox pipefail # The build image ships autoconf/make but not meson. - python3 -m pip install --disable-pip-version-check 'meson>=0.61' ninja + python3 -m pip install --disable-pip-version-check "meson${MESON_VERSION}" ninja meson --version ninja --version @@ -132,58 +234,179 @@ jobs: - name: meson setup run: | set -euox pipefail - # Run the build as gpadmin, like the autoconf workflows do. - # No single quotes inside, so the whole command can be double quoted - # and the environment variables expand in this shell. - su gpadmin -c "cd ${GITHUB_WORKSPACE} && meson setup ${BUILD_DIR} . \ + # Run the build as gpadmin, like the autoconf workflows do. No single + # quotes inside, so the whole command can be double quoted and the + # environment variables expand in this shell. + su gpadmin -c "cd ${GITHUB_WORKSPACE} && meson setup build-meson . \ --prefix=${INSTALL_PREFIX} \ --buildtype=release \ - -Dexternal_fts=false \ - -Dorca=enabled \ - -Dpxf=enabled \ - -Dorafce=enabled \ - -Dic_proxy=enabled \ - -Dgpfdist=enabled \ - -Dgpcloud=enabled \ - -Dmapreduce=enabled \ - -Ddiskquota=enabled \ - -Dpax=enabled \ - -Dtap_tests=enabled \ - -Dgssapi=enabled \ - -Dldap=enabled \ - -Dlibxml=enabled \ - -Dlz4=enabled \ - -Dzstd=enabled \ - -Dpam=enabled \ - -Dplperl=enabled \ - -Dplpython=enabled \ - -Dssl=openssl \ - -Duuid=e2fs \ - -Dpgport=5432 \ + ${{ matrix.options }} \ -Dextra_include_dirs=/usr/local/xerces-c/include \ -Dextra_lib_dirs=${INSTALL_PREFIX}/lib" + - name: Fail on meson warnings + run: | + set -euo pipefail + # meson_version warnings mean a feature is used that the declared floor + # does not cover. They are cheap to fix and easy to miss, so treat them + # as errors here rather than letting them accumulate. + if grep -q "uses feature introduced in" build-meson/meson-logs/meson-log.txt; then + echo "::error::meson reported meson_version feature warnings" + grep "uses feature introduced in" build-meson/meson-logs/meson-log.txt + exit 1 + fi + echo "No meson_version feature warnings" + - name: ninja build run: | set -euox pipefail - su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C ${BUILD_DIR} -j$(nproc)" + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson -j$(nproc)" \ + 2>&1 | tee build-meson-build.log + + - name: Report compiler warnings + run: | + set -euo pipefail + # Not fatal, but surfaced: the autoconf build is warning-quiet for the + # flags Cloudberry selects, so a jump here usually means the meson + # flags have drifted from configure.ac. + COUNT=$(grep -c "warning:" build-meson-build.log || true) + echo "Compiler warnings: ${COUNT}" + if [ "${COUNT}" -gt 0 ]; then + grep -oE "\[-W[a-z0-9-]+\]" build-meson-build.log \ + | sort | uniq -c | sort -rn | head -20 + fi + { + echo "### Build \`${{ matrix.name }}\`" + echo + echo "Compiler warnings: **${COUNT}**" + } >> "$GITHUB_STEP_SUMMARY" - name: ninja install run: | set -euox pipefail - su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C ${BUILD_DIR} install" + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson install" - - name: Verify install and run smoke test + - name: Smoke test run: | set -euox pipefail su gpadmin -c "${GITHUB_WORKSPACE}/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh ${INSTALL_PREFIX}" + - name: Package install tree + if: matrix.upload + run: | + set -euox pipefail + tar -C "$(dirname ${INSTALL_PREFIX})" -czf \ + "${GITHUB_WORKSPACE}/cloudberry-meson-install.tar.gz" \ + "$(basename ${INSTALL_PREFIX})" + ls -la "${GITHUB_WORKSPACE}/cloudberry-meson-install.tar.gz" + + - name: Upload install tree + if: matrix.upload + uses: actions/upload-artifact@v4 + with: + name: meson-install + path: cloudberry-meson-install.tar.gz + retention-days: 3 + if-no-files-found: error + - name: Upload meson logs on failure if: failure() uses: actions/upload-artifact@v4 with: - name: meson-logs + name: meson-logs-${{ matrix.name }} path: | - ${{ env.BUILD_DIR }}/meson-logs/ + build-meson/meson-logs/ + build-meson-build.log retention-days: 7 if-no-files-found: ignore + + # ------------------------------------------------------------------ + cluster-test: + name: Demo cluster test + runs-on: ubuntu-22.04 + needs: [check-skip, build] + if: needs.check-skip.outputs.should_skip != 'true' + + container: + image: apache/incubator-cloudberry:cbdb-build-rocky9-latest + options: >- + --user root + -h cdw + + steps: + - name: Checkout Apache Cloudberry + uses: actions/checkout@v7 + with: + fetch-depth: 1 + submodules: false + + - name: Environment initialization + run: | + if ! su - gpadmin -c "/tmp/init_system.sh"; then + echo "::error::Container initialization failed" + exit 1 + fi + + - name: Download install tree + uses: actions/download-artifact@v4 + with: + name: meson-install + + - name: Unpack install tree + run: | + set -euox pipefail + tar -C "$(dirname ${INSTALL_PREFIX})" -xzf cloudberry-meson-install.tar.gz + chown -R gpadmin:gpadmin "${INSTALL_PREFIX}" + chown -R gpadmin:gpadmin "${GITHUB_WORKSPACE}" + test -x "${INSTALL_PREFIX}/bin/postgres" + test -f "${INSTALL_PREFIX}/cloudberry-env.sh" + + - name: Install gpMgmt Python dependencies + run: | + set -euox pipefail + # The meson build does not vendor these (see the header comment); they + # are runtime dependencies of the management utilities. + python3 -m pip install --disable-pip-version-check -r python-dependencies.txt + su gpadmin -c "python3 -c 'import psutil, pg, yaml; print(\"deps ok\")'" + + - name: Create demo cluster and run MPP checks + run: | + set -euox pipefail + su gpadmin -c "${GITHUB_WORKSPACE}/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh ${INSTALL_PREFIX} ${GITHUB_WORKSPACE}" + + - name: Upload cluster logs on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: meson-cluster-logs + path: | + gpAux/gpdemo/datadirs/*/pg_log/ + gpAux/gpdemo/*.log + /home/gpadmin/gpAdminLogs/ + retention-days: 7 + if-no-files-found: ignore + + # ------------------------------------------------------------------ + report: + name: Report + runs-on: ubuntu-22.04 + needs: [check-skip, build, cluster-test] + if: always() && needs.check-skip.outputs.should_skip != 'true' + steps: + - name: Summarise + run: | + BUILD="${{ needs.build.result }}" + CLUSTER="${{ needs.cluster-test.result }}" + { + echo "## Meson build" + echo + echo "| Job | Result |" + echo "| --- | --- |" + echo "| build (all configurations) | ${BUILD} |" + echo "| cluster-test | ${CLUSTER} |" + } >> "$GITHUB_STEP_SUMMARY" + if [ "${BUILD}" != "success" ] || [ "${CLUSTER}" != "success" ]; then + echo "::error::meson workflow failed (build=${BUILD} cluster-test=${CLUSTER})" + exit 1 + fi + echo "All meson jobs passed" diff --git a/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh new file mode 100755 index 00000000000..f3ef3e940f9 --- /dev/null +++ b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +# -------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# -------------------------------------------------------------------- +# +# Bring up a real multi-segment demo cluster on a meson-built Apache +# Cloudberry installation and exercise the MPP paths against it. +# +# meson-smoke-test.sh only runs single-user mode, which proves the catalogs and +# storage layers work but never starts a segment. This goes further: it uses +# gpinitsystem from the installed gpMgmt tree, so it also proves that the +# management utilities, the generated cloudberry-env.sh and the Python +# dependencies are all in place -- the parts a single-node smoke test cannot +# reach. +# +# Usage: meson-cluster-test.sh +# -------------------------------------------------------------------- +set -euo pipefail + +PREFIX="${1:?usage: $0 }" +SRCDIR="${2:?usage: $0 }" + +fail() { echo "::error::$*" >&2; exit 1; } +section() { echo; echo "== $* =="; } + +# -------------------------------------------------------------------- +# Environment +# -------------------------------------------------------------------- +section "sourcing cloudberry-env.sh" +# gpMgmt/Makefile generates this into the install prefix; the meson build does +# the same. demo_cluster.sh and every gpMgmt utility depend on it. +[ -f "${PREFIX}/cloudberry-env.sh" ] || fail "missing ${PREFIX}/cloudberry-env.sh" +# shellcheck disable=SC1090,SC1091 +source "${PREFIX}/cloudberry-env.sh" +echo " GPHOME=${GPHOME:-unset}" +[ -n "${GPHOME:-}" ] || fail "cloudberry-env.sh did not set GPHOME" + +section "checking the Python dependencies gpMgmt needs" +# The meson build deliberately does not vendor these: --with-pythonsrc-ext +# downloads them from PyPI during install, which has no meson equivalent, so +# they are external runtime dependencies. gpinitsystem fails without them. +for m in psutil pygresql yaml; do + mod="${m}" + [ "${m}" = "pygresql" ] && mod="pg" + python3 -c "import ${mod}" 2>/dev/null && echo " ok ${m}" \ + || fail "python module ${m} is missing; install python-dependencies.txt" +done + +section "verifying ssh to localhost" +# gpinitsystem drives segments over ssh even for a single-host demo cluster. +ssh -o BatchMode=yes -o StrictHostKeyChecking=no "$(hostname)" 'true' \ + || fail "passwordless ssh to $(hostname) does not work" +echo " ok ssh $(hostname)" + +# -------------------------------------------------------------------- +# Cluster +# -------------------------------------------------------------------- +section "creating the demo cluster" +# gpAux/gpdemo/Makefile uses `-include src/Makefile.global`, so this target +# works on a tree that was never configured with autoconf. +make -C "${SRCDIR}/gpAux/gpdemo" create-demo-cluster \ + || fail "demo cluster creation failed" + +# shellcheck disable=SC1090,SC1091 +source "${SRCDIR}/gpAux/gpdemo/gpdemo-env.sh" \ + || fail "could not source gpdemo-env.sh" +echo " ok cluster created, PGPORT=${PGPORT:-unset}" + +cleanup() { + echo + echo "== tearing down the demo cluster ==" + make -C "${SRCDIR}/gpAux/gpdemo" destroy-demo-cluster >/dev/null 2>&1 || true +} +trap cleanup EXIT + +section "restarting the cluster" +gpstop -a || fail "gpstop failed" +gpstart -a || fail "gpstart failed" +gpstate || fail "gpstate failed" + +# -------------------------------------------------------------------- +# MPP checks +# -------------------------------------------------------------------- +q() { psql -d postgres -tAc "$1"; } + +section "segment configuration" +q "select role, count(*) from gp_segment_configuration group by role order by role;" \ + | sed 's/^/ /' +NPRIM=$(q "select count(*) from gp_segment_configuration where role='p' and content >= 0;") +[ "${NPRIM}" -ge 1 ] || fail "no primary segments registered" +echo " ok ${NPRIM} primary segment(s)" + +section "data really distributes across segments" +q "create table t_dist(a int, b text) distributed by (a);" >/dev/null +q "insert into t_dist select i, 'v'||i from generate_series(1,1000) i;" >/dev/null +NSEG=$(q "select count(distinct gp_segment_id) from t_dist;") +TOTAL=$(q "select count(*) from t_dist;") +[ "${TOTAL}" = "1000" ] || fail "expected 1000 rows, got ${TOTAL}" +[ "${NSEG}" -ge 2 ] || fail "table did not distribute: rows on ${NSEG} segment(s)" +echo " ok 1000 rows spread over ${NSEG} segments" + +section "a plan uses Motion" +q "explain select count(*) from t_dist;" | grep -qi motion \ + || fail "no Motion node in a distributed aggregate plan" +echo " ok Motion present" + +section "ORCA plans a distributed query" +q "select gp_opt_version();" | sed 's/^/ /' +q "set optimizer=on; select count(*) from t_dist a join t_dist b using (a);" \ + | tail -1 | grep -q '^1000$' || fail "ORCA-planned join returned unexpected rows" +echo " ok ORCA join returned 1000 rows" + +section "append-only storage, distributed" +q "create table t_ao(a int) using ao_row distributed by (a);" >/dev/null +q "insert into t_ao select generate_series(1,500);" >/dev/null +[ "$(q 'select count(*) from t_ao;')" = "500" ] || fail "AO table wrong row count" +echo " ok ao_row returned 500 rows" + +section "PAX storage, distributed" +if q "select count(*) from pg_am where amname='pax';" | grep -q '^1$'; then + q "create table t_pax(a int, b text) using pax distributed by (a);" >/dev/null + q "insert into t_pax select i, 'p'||i from generate_series(1,500) i;" >/dev/null + [ "$(q 'select count(*) from t_pax;')" = "500" ] || fail "PAX table wrong row count" + echo " ok pax returned 500 rows" +else + echo " skip pax access method not present in this build" +fi + +section "resource groups are queryable" +q "select count(*) from gp_toolkit.gp_resgroup_config;" | sed 's/^/ rows: /' + +echo +echo "Cluster test passed." diff --git a/gpMgmt/meson.build b/gpMgmt/meson.build index d741705b5b5..eaf49cf3945 100644 --- a/gpMgmt/meson.build +++ b/gpMgmt/meson.build @@ -20,6 +20,22 @@ gpmgmt_subst_version = files('bin/subst_version.py') +# gpMgmt/Makefile generates $prefix/cloudberry-env.sh by running +# bin/generate-cloudberry-env.sh and redirecting its stdout. The generator uses +# a quoted heredoc, so its output is entirely static and derives GPHOME at +# runtime -- nothing from the build environment leaks in. +# +# gpAux/gpdemo/demo_cluster.sh sources this file, and it is how users set up +# their environment, so an install without it is not usable. +cloudberry_env_sh = custom_target('cloudberry-env.sh', + output: 'cloudberry-env.sh', + command: [bash, files('bin/generate-cloudberry-env.sh')], + capture: true, + build_by_default: true, + install: true, + install_dir: dir_prefix, +) + subdir('sbin') subdir('bin') subdir('doc') From a6dc9b1e2653b324a9828663d729be962a0521ee Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 1 Sep 2026 09:57:58 +0800 Subject: [PATCH 10/13] meson: fixes from installing and running the result None of these were visible from a build. Every one came out of installing the tree and starting a real cluster on it, and each would have shipped a build that compiles and links and then does not work. libdir. meson derives it from the platform, which is lib64 on RHEL. cloudberry-env.sh hardcodes PYTHONPATH=$GPHOME/lib/python and LD_LIBRARY_PATH=$GPHOME/lib, so gppylib and libpostgres.so landed where nothing looks for them. Every file present, install unusable. PG_VERSION_STR. gpMgmt parses select version() and insists on "(Apache Cloudberry build )". With upstream's string, gpstop dies on a healthy cluster with "too many tokens in version". gpMgmt files. Ten the autoconf build installs and this port did not, nine of them Python modules, so nothing failed to build: gppylib/commands/base.py, all of gppylib/util, gppylib/programs/gppkg.py, gppylib/system/ComputeCatalogUpdate.py, gppylib/gpMgmttest, lib's crashreport.gdb, and the foreign-key JSON gpcheckcat reads, which is generated from the same headers as postgres.bki. gpMgmt Python modules. --with-pythonsrc-ext downloads psutil, PyGreSQL and PyYAML mid-build, which has no honest meson equivalent, so it was dropped. What should not have gone with it is the install: the Makefile's half of that option only copies what is already in gpMgmt/bin/ext, and without the same conditional copy there is no supported way to get the modules into an install at all. meson floor. Raising it to 0.61 for install_symlink turned roughly thirty-five deprecations in upstream's own meson files into warnings on every configure -- meson only reports a deprecated API once the project claims a version that has it deprecated. Three symlinks are not worth that, nor worth diverging from upstream on the one line every future merge touches. The floor goes back to upstream's value and the symlinks are made by an install script. Per-directory warning flags. Five directories relax a warning in their own Makefile. Two need more than an extra c_args: meson compiles the whole backend as one target, so src/backend/task moves into a static library that carries the flag, and plpgsql, where the Makefile scopes -Wno-array-bounds to pl_exec.o alone, gets a library for that one file. Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 66 ++++++++---- .../cloudberry/scripts/meson-cluster-test.sh | 9 +- .../cloudberry/scripts/meson-smoke-test.sh | 35 ++++++ gpMgmt/bin/gppylib/commands/meson.build | 10 ++ gpMgmt/bin/gppylib/data/meson.build | 19 ++++ gpMgmt/bin/gppylib/gpMgmttest/meson.build | 8 ++ gpMgmt/bin/gppylib/programs/meson.build | 9 ++ gpMgmt/bin/gppylib/system/meson.build | 7 ++ gpMgmt/bin/gppylib/util/meson.build | 7 ++ gpMgmt/bin/lib/meson.build | 7 ++ gpMgmt/bin/meson.build | 6 +- gpMgmt/bin/stream/meson.build | 6 +- gpMgmt/install_python_modules.py | 101 ++++++++++++++++++ gpMgmt/meson.build | 7 ++ gpcontrib/gpcloud/meson.build | 6 +- gpcontrib/gpmapreduce/meson.build | 4 +- meson.build | 55 +++++++--- src/backend/task/meson.build | 14 ++- src/bin/pg_dump/meson.build | 8 ++ src/include/catalog/meson.build | 5 + src/pl/plpgsql/src/meson.build | 12 ++- src/pl/plpython/meson.build | 2 + src/tools/install_symlink.py | 72 +++++++++++++ 23 files changed, 429 insertions(+), 46 deletions(-) create mode 100755 gpMgmt/install_python_modules.py create mode 100755 src/tools/install_symlink.py diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml index b0838c8d965..9ef6b74b266 100644 --- a/.github/workflows/build-meson-cloudberry.yml +++ b/.github/workflows/build-meson-cloudberry.yml @@ -84,8 +84,11 @@ # # Deliberately dropped: --with-pythonsrc-ext downloads psutil / PyYAML / # PyGreSQL from PyPI during `make install`, which has no honest meson -# equivalent. They are external runtime dependencies instead, which is why -# cluster-test installs them before calling gpinitsystem. +# equivalent -- a build should not reach the network. The meson build still +# installs those modules, but only if they have already been staged in +# gpMgmt/bin/ext; see gpMgmt/install_python_modules.py. The build job stages +# them the same way the autoconf build does, so the install tree +# cluster-test unpacks is self-contained. # -------------------------------------------------------------------- name: Apache Cloudberry Meson Build @@ -106,7 +109,10 @@ concurrency: env: BUILD_IMAGE: apache/incubator-cloudberry:cbdb-build-rocky9-latest INSTALL_PREFIX: /usr/local/cloudberry-db - MESON_VERSION: '>=0.61' + # Matches meson.build's floor. Pinned rather than left to pip's latest so + # that CI fails the same way a supported-but-old meson would, instead of + # silently depending on features newer than the project claims to need. + MESON_VERSION: '>=0.54' jobs: # ------------------------------------------------------------------ @@ -247,15 +253,30 @@ jobs: - name: Fail on meson warnings run: | set -euo pipefail - # meson_version warnings mean a feature is used that the declared floor - # does not cover. They are cheap to fix and easy to miss, so treat them - # as errors here rather than letting them accumulate. - if grep -q "uses feature introduced in" build-meson/meson-logs/meson-log.txt; then - echo "::error::meson reported meson_version feature warnings" - grep "uses feature introduced in" build-meson/meson-logs/meson-log.txt + LOG=build-meson/meson-logs/meson-log.txt + # Three kinds of warning are about the declared meson floor, and all + # three are actionable and platform-independent: + # + # uses feature introduced in the floor is too low for the code + # uses feature deprecated the floor is high enough that meson + # now objects to upstream's own APIs + # always evaluates to true the floor made an upstream version + # guard dead + # + # A configure that reports none of them is the evidence that the floor + # in meson.build is the right one, so treat any as a failure. Other + # warnings can be environment-specific, so those are only reported. + if grep -qE "uses feature introduced in|uses feature deprecated|always evaluates to true" "${LOG}"; then + echo "::error::meson reported version-floor warnings" + grep -E "uses feature introduced in|uses feature deprecated|always evaluates to true" "${LOG}" exit 1 fi - echo "No meson_version feature warnings" + echo "No meson version-floor warnings" + OTHER=$(grep -c "WARNING" "${LOG}" || true) + echo "Other meson warnings: ${OTHER}" + if [ "${OTHER}" -gt 0 ]; then + grep "WARNING" "${LOG}" | head -20 + fi - name: ninja build run: | @@ -286,6 +307,23 @@ jobs: set -euox pipefail su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson install" + - name: Stage gpMgmt Python modules + if: matrix.upload + run: | + set -euox pipefail + # psutil, PyGreSQL and PyYAML are runtime dependencies of the + # management utilities, not build inputs. The meson build installs them + # if they have been staged in gpMgmt/bin/ext but never downloads them, + # so stage them with gpMgmt/bin's own targets -- the same ones + # --with-pythonsrc-ext drives -- and install a second time to pick them + # up. PyGreSQL needs pg_config, hence the order. + su gpadmin -c "cd ${GITHUB_WORKSPACE} && PATH=${INSTALL_PREFIX}/bin:\$PATH \ + make -C gpMgmt/bin TAR=tar psutil pygresql pyyaml" + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson install" + test -d "${INSTALL_PREFIX}/lib/python/psutil" + test -f "${INSTALL_PREFIX}/lib/python/pg.py" + test -d "${INSTALL_PREFIX}/lib/python/yaml" + - name: Smoke test run: | set -euox pipefail @@ -361,14 +399,6 @@ jobs: test -x "${INSTALL_PREFIX}/bin/postgres" test -f "${INSTALL_PREFIX}/cloudberry-env.sh" - - name: Install gpMgmt Python dependencies - run: | - set -euox pipefail - # The meson build does not vendor these (see the header comment); they - # are runtime dependencies of the management utilities. - python3 -m pip install --disable-pip-version-check -r python-dependencies.txt - su gpadmin -c "python3 -c 'import psutil, pg, yaml; print(\"deps ok\")'" - - name: Create demo cluster and run MPP checks run: | set -euox pipefail diff --git a/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh index f3ef3e940f9..2d138d4130f 100755 --- a/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh +++ b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh @@ -50,14 +50,15 @@ echo " GPHOME=${GPHOME:-unset}" [ -n "${GPHOME:-}" ] || fail "cloudberry-env.sh did not set GPHOME" section "checking the Python dependencies gpMgmt needs" -# The meson build deliberately does not vendor these: --with-pythonsrc-ext -# downloads them from PyPI during install, which has no meson equivalent, so -# they are external runtime dependencies. gpinitsystem fails without them. +# gpinitsystem fails without these. The meson build never downloads them, but +# it does install whatever has been staged in gpMgmt/bin/ext, so finding them +# here also proves cloudberry-env.sh puts $GPHOME/lib/python on PYTHONPATH and +# that gpMgmt/install_python_modules.py put them there. for m in psutil pygresql yaml; do mod="${m}" [ "${m}" = "pygresql" ] && mod="pg" python3 -c "import ${mod}" 2>/dev/null && echo " ok ${m}" \ - || fail "python module ${m} is missing; install python-dependencies.txt" + || fail "python module ${m} is missing from ${PREFIX}/lib/python; stage it with 'make -C gpMgmt/bin TAR=tar psutil pygresql pyyaml' and install again" done section "verifying ssh to localhost" diff --git a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh index 571f84a0688..c2a3f037aa3 100755 --- a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh +++ b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh @@ -53,6 +53,29 @@ echo "== checking PAX ==" || fail "missing generated pax-cdbinit--1.0.sql" echo " ok pax-cdbinit--1.0.sql" +echo "== checking library layout ==" +# These paths are not interchangeable: cloudberry-env.sh hardcodes +# PYTHONPATH=$GPHOME/lib/python and LD_LIBRARY_PATH=$GPHOME/lib, so an install +# that lands them in lib64 (meson's default on RHEL) is broken even though +# every binary is present. Check the paths, not just the files. +[ -d "${PREFIX}/lib/postgresql" ] || fail "no lib/postgresql -- is libdir set to lib?" +echo " ok lib/postgresql" +[ -f "${PREFIX}/lib/python/gppylib/gpversion.py" ] \ + || fail "gppylib is not under lib/python -- is libdir set to lib?" +echo " ok lib/python/gppylib" +[ -d "${PREFIX}/lib64" ] && fail "install split across lib and lib64" +echo " ok nothing in lib64" + +echo "== checking gpMgmt ==" +[ -f "${PREFIX}/cloudberry-env.sh" ] || fail "missing cloudberry-env.sh" +echo " ok cloudberry-env.sh" +for b in gpinitsystem gpstart gpstop gpstate; do + [ -x "${PREFIX}/bin/${b}" ] || fail "missing bin/${b}" + echo " ok bin/${b}" +done +[ -f "${PREFIX}/bin/lib/gpdemo/demo_cluster.sh" ] || fail "missing gpdemo scripts" +echo " ok bin/lib/gpdemo" + echo "== checking generated catalog data ==" for f in system_views_gp.sql cdb_init.d/cdb_schema.sql postgres.bki; do [ -f "${PREFIX}/share/postgresql/${f}" ] || fail "missing share/postgresql/${f}" @@ -103,6 +126,18 @@ grep -qE 'n = "[1-9][0-9]*"' "${WORKDIR}/views.out" || { } echo " ok $(sed -n 's/.*n = "\([0-9]*\)".*/\1/p' "${WORKDIR}/views.out" | head -1) gp_* views" +echo "== checking the version string ==" +# gpMgmt parses select version() with gpversion.py, which insists on +# "(Apache Cloudberry build )". Upstream's PG_VERSION_STR has +# no such part, so a build that inherits it starts and serves queries but makes +# every management utility fail; check the string, not just that it exists. +run_sql "select version();" >"${WORKDIR}/version.out" +grep -q "(Apache Cloudberry " "${WORKDIR}/version.out" || { + cat "${WORKDIR}/version.out" >&2 + fail "version() does not identify Cloudberry -- is PG_VERSION_STR upstream's?" +} +echo " ok $(sed -n 's/.*(\(Apache Cloudberry [^)]*\)).*/\1/p' "${WORKDIR}/version.out" | head -1)" + echo "== checking ORCA ==" run_sql "select gp_opt_version();" >"${WORKDIR}/orca.out" grep -q "GPOPT version" "${WORKDIR}/orca.out" || { diff --git a/gpMgmt/bin/gppylib/commands/meson.build b/gpMgmt/bin/gppylib/commands/meson.build index fbacd2cb87d..13625c4293e 100644 --- a/gpMgmt/bin/gppylib/commands/meson.build +++ b/gpMgmt/bin/gppylib/commands/meson.build @@ -22,3 +22,13 @@ install_data( 'unix.py', install_dir: gppylib_dir / 'commands', ) + +# The Makefile installs this one with INSTALL_SCRIPT rather than INSTALL_DATA. +# It is imported, not executed, so the mode is of no consequence -- but it is +# what the autoconf install produces, and the two trees should be comparable +# file for file. +install_data( + 'base.py', + install_dir: gppylib_dir / 'commands', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/gppylib/data/meson.build b/gpMgmt/bin/gppylib/data/meson.build index 37d57148321..45d2404f918 100644 --- a/gpMgmt/bin/gppylib/data/meson.build +++ b/gpMgmt/bin/gppylib/data/meson.build @@ -13,3 +13,22 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. + +# gpcheckcat reads the foreign-key relationships of the catalog out of this +# file rather than deriving them at runtime, so an install without it can load +# but not check a catalog. +# +# The Makefile pipes the catalog headers into process_foreign_keys.pl with cat; +# the script reads them with Perl's <>, which takes filenames from ARGV just as +# happily as it takes stdin, so the file list can be passed directly. Output is +# keyed and sorted by catalog name, so argument order does not matter. +gppylib_catalog_json = custom_target(gp_majorversion + '.json', + output: gp_majorversion + '.json', + input: postgres_bki_srcs + files('../../../../src/include/catalog/catversion.h'), + command: [perl, files('../../../../src/backend/catalog/process_foreign_keys.pl'), + '@INPUT@'], + capture: true, + build_by_default: true, + install: true, + install_dir: gppylib_dir / 'data', +) diff --git a/gpMgmt/bin/gppylib/gpMgmttest/meson.build b/gpMgmt/bin/gppylib/gpMgmttest/meson.build index 37d57148321..8b052035714 100644 --- a/gpMgmt/bin/gppylib/gpMgmttest/meson.build +++ b/gpMgmt/bin/gppylib/gpMgmttest/meson.build @@ -13,3 +13,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. + +# Only the package marker is installed. The tests themselves are not shipped, +# but gpMgmttest has to remain importable: gppylib/Makefile recurses into it +# for exactly this one file. +install_data( + '__init__.py', + install_dir: gppylib_dir / 'gpMgmttest', +) diff --git a/gpMgmt/bin/gppylib/programs/meson.build b/gpMgmt/bin/gppylib/programs/meson.build index 0da6d208d5d..e7f0a711b49 100644 --- a/gpMgmt/bin/gppylib/programs/meson.build +++ b/gpMgmt/bin/gppylib/programs/meson.build @@ -33,3 +33,12 @@ foreach f : [ install_dir: gppylib_dir / 'programs', ) endforeach + +# gppkg.py gets both treatments the Makefile gives it: installed executable, +# and run through putversion like the cls* modules above. +install_data( + configure_file(input: 'gppkg.py', output: 'gppkg.py', + command: [python, gpmgmt_subst_version, '@INPUT@', '@OUTPUT@', gp_version_long]), + install_dir: gppylib_dir / 'programs', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/gppylib/system/meson.build b/gpMgmt/bin/gppylib/system/meson.build index ab7ed9bb8b8..d0b10c95235 100644 --- a/gpMgmt/bin/gppylib/system/meson.build +++ b/gpMgmt/bin/gppylib/system/meson.build @@ -29,3 +29,10 @@ install_data( 'osInterface.py', install_dir: gppylib_dir / 'system', ) + +# Installed executable by the Makefile, unlike its neighbours above. +install_data( + 'ComputeCatalogUpdate.py', + install_dir: gppylib_dir / 'system', + install_mode: 'rwxr-xr-x', +) diff --git a/gpMgmt/bin/gppylib/util/meson.build b/gpMgmt/bin/gppylib/util/meson.build index 37d57148321..bafe4185949 100644 --- a/gpMgmt/bin/gppylib/util/meson.build +++ b/gpMgmt/bin/gppylib/util/meson.build @@ -13,3 +13,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. + +install_data( + '__init__.py', + 'gp_utils.py', + 'ssh_utils.py', + install_dir: gppylib_dir / 'util', +) diff --git a/gpMgmt/bin/lib/meson.build b/gpMgmt/bin/lib/meson.build index 4f52cf367af..8a85b05e89d 100644 --- a/gpMgmt/bin/lib/meson.build +++ b/gpMgmt/bin/lib/meson.build @@ -41,3 +41,10 @@ install_data( install_dir: dir_bin / 'lib', install_mode: 'rwxr-xr-x', ) + +# Not a program: gpmemreport feeds this to gdb as a batch script. The Makefile +# installs it with INSTALL_DATA for that reason. +install_data( + 'crashreport.gdb', + install_dir: dir_bin / 'lib', +) diff --git a/gpMgmt/bin/meson.build b/gpMgmt/bin/meson.build index f3d26d229c0..063c3b36974 100644 --- a/gpMgmt/bin/meson.build +++ b/gpMgmt/bin/meson.build @@ -82,7 +82,7 @@ install_data( ) # if [ ! -L $(bindir)/lib/gpcheckcat ]; then ln -s ../gpcheckcat gpcheckcat -install_symlink('gpcheckcat', - install_dir: dir_bin / 'lib', - pointing_to: '..' / 'gpcheckcat', +meson.add_install_script(gp_install_symlink, + dir_bin / 'lib' / 'gpcheckcat', + '..' / 'gpcheckcat', ) diff --git a/gpMgmt/bin/stream/meson.build b/gpMgmt/bin/stream/meson.build index f5794642e22..0058fd63b28 100644 --- a/gpMgmt/bin/stream/meson.build +++ b/gpMgmt/bin/stream/meson.build @@ -20,7 +20,7 @@ stream_bin = executable('stream', ) # Symlink kept for backward compatibility: $bindir/stream/stream -> ../lib/stream -install_symlink('stream', - install_dir: dir_bin / 'stream', - pointing_to: '..' / 'lib' / 'stream', +meson.add_install_script(gp_install_symlink, + dir_bin / 'stream' / 'stream', + '..' / 'lib' / 'stream', ) diff --git a/gpMgmt/install_python_modules.py b/gpMgmt/install_python_modules.py new file mode 100755 index 00000000000..b520245ccff --- /dev/null +++ b/gpMgmt/install_python_modules.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +"""Install the Python modules gpMgmt needs into $prefix/lib/python. + +The gpMgmt utilities import psutil, pg (PyGreSQL) and yaml at runtime, and +cloudberry-env.sh puts $GPHOME/lib/python on PYTHONPATH for exactly that +reason. gpMgmt/Makefile copies them out of gpMgmt/bin/ext during `make +install`, if that directory happens to exist. + +This is the meson equivalent, and it is deliberately the same conditional +copy rather than a build step. autoconf grows the directory from +--with-pythonsrc-ext, which downloads three tarballs from PyPI in the middle +of the build; meson has no honest way to express that, and a build that +reaches the network is not one we want. So the modules stay an external +dependency: stage them yourself, then install. The supported way to do that +is the target the autoconf build already uses, which needs pg_config from a +finished install: + + ninja -C build install + PATH=$prefix/bin:$PATH make -C gpMgmt/bin TAR=tar psutil pygresql pyyaml + ninja -C build install + +Anything else that leaves importable modules in gpMgmt/bin/ext works too -- +a virtualenv's site-packages copied in, or distribution packages. An +install with nothing staged is still a valid install; it just cannot run the +management utilities until the three modules are on PYTHONPATH some other +way. Hence: no staged modules, no output, no error. +""" + +import os +import shutil +import sys +from glob import glob +from pathlib import Path + + +def main() -> int: + source_root = Path(os.environ['MESON_SOURCE_ROOT']) + # DESTDIR-prefixed, so `meson install --destdir` stages correctly. + prefix = Path(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + # meson sets this to 0 rather than unsetting it for a non-quiet install. + quiet = os.environ.get('MESON_INSTALL_QUIET', '') not in ('', '0', 'false') + + ext = source_root / 'gpMgmt' / 'bin' / 'ext' + + # cloudberry-env.sh hardcodes PYTHONPATH=$GPHOME/lib/python, so this is a + # literal path and not libdir -- an install that honoured a libdir of + # lib64 here would put the modules somewhere nothing looks. + dest = prefix / 'lib' / 'python' + + # Mirrors the gpMgmt/Makefile install target. Each group is independent: + # staging only psutil is a legitimate thing to do. + groups = [ + ['__init__.py'], + ['psutil'], + ['pgdb.py', 'pg.py', '_pg*.so'], + ['yaml'], + ] + + installed = [] + for group in groups: + matches = [Path(m) for pattern in group for m in sorted(glob(str(ext / pattern)))] + # A group is all-or-nothing: pg.py without _pg*.so is not importable, + # and half-installing it would fail at runtime instead of at install + # time. Skipping the whole group leaves the same clean "not staged" + # state as staging nothing at all. + if len(matches) < len(group): + continue + dest.mkdir(parents=True, exist_ok=True) + for src in matches: + target = dest / src.name + if src.is_dir(): + shutil.copytree(src, target, dirs_exist_ok=True) + else: + shutil.copy2(src, target) + installed.append(src.name) + + if installed and not quiet: + print('Installing gpMgmt Python modules to {}: {}'.format( + dest, ', '.join(installed))) + + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/gpMgmt/meson.build b/gpMgmt/meson.build index eaf49cf3945..29ecd788468 100644 --- a/gpMgmt/meson.build +++ b/gpMgmt/meson.build @@ -39,3 +39,10 @@ cloudberry_env_sh = custom_target('cloudberry-env.sh', subdir('sbin') subdir('bin') subdir('doc') + +# psutil, PyGreSQL and PyYAML land in $prefix/lib/python if they have been +# staged in gpMgmt/bin/ext, the same conditional copy gpMgmt/Makefile does. +# It has to be an install script rather than an install_subdir: whether the +# modules are there is decided after configure, by a separate build step that +# itself needs a finished install to find pg_config. See the script's header. +meson.add_install_script('install_python_modules.py') diff --git a/gpcontrib/gpcloud/meson.build b/gpcontrib/gpcloud/meson.build index 61cc2ab298f..e6c0f284f23 100644 --- a/gpcontrib/gpcloud/meson.build +++ b/gpcontrib/gpcloud/meson.build @@ -60,9 +60,9 @@ contrib_targets += gpcloud # The Makefile overrides contrib-global.mk's install target purely to add this # symlink: ln -sf gpcloud.so $(pkglibdir)/gps3ext.so -install_symlink('gps3ext' + dlsuffix, - install_dir: dir_lib_pkg, - pointing_to: 'gpcloud' + dlsuffix, +meson.add_install_script(gp_install_symlink, + dir_lib_pkg / 'gps3ext' + dlsuffix, + 'gpcloud' + dlsuffix, ) subdir('bin/gpcheckcloud') diff --git a/gpcontrib/gpmapreduce/meson.build b/gpcontrib/gpmapreduce/meson.build index d7bcbc19412..35147e00dd4 100644 --- a/gpcontrib/gpmapreduce/meson.build +++ b/gpcontrib/gpmapreduce/meson.build @@ -45,7 +45,9 @@ gpmapreduce = executable('gpmapreduce', files('src/main.c', 'src/mapred.c', 'src/parse.c'), gpmapreduce_yaml_parse, gpmapreduce_yaml_scan, - c_args: ['-DFRONTEND'], + # The Makefile disables -Wimplicit-fallthrough for this module: "it is hard + # to change some macros using switch-case". + c_args: ['-DFRONTEND', '-Wno-implicit-fallthrough'], # '.' picks up this directory in the *build* tree too, where bison puts # yaml_parse.h -- the generated scanner includes it. include_directories: include_directories('.', 'src', 'include'), diff --git a/meson.build b/meson.build index 2e2a0ceeca8..87d6c225649 100644 --- a/meson.build +++ b/meson.build @@ -11,11 +11,10 @@ project('postgresql', version: '16.9', license: 'PostgreSQL', - # Upstream targets >=0.54 to stay usable on old platforms. Cloudberry needs - # install_symlink (0.61) for three symlinks its Makefiles create: - # $bindir/stream/stream, $bindir/lib/gpcheckcat and gps3ext.so. All platforms - # Cloudberry builds on ship a newer meson, or install it from pip. - meson_version: '>=0.61', + # We want < 0.56 for python 3.5 compatibility on old platforms. EPEL for + # RHEL 7 has 0.55. < 0.54 would require replacing some uses of the fs + # module, < 0.53 all uses of fs. So far there's no need to go to >=0.56. + meson_version: '>=0.54', default_options: [ 'warning_level=1', #-Wall equivalent 'b_pch=false', @@ -24,6 +23,13 @@ project('postgresql', # works even on windows, where it's a drive-relative path (i.e. when on # d:/somepath it'll install to d:/usr/local/pgsql) 'prefix=/usr/local/pgsql', + + # meson derives libdir from the platform, which is lib64 on RHEL and its + # derivatives. autoconf uses plain lib, and Cloudberry depends on that: + # cloudberry-env.sh hardcodes PYTHONPATH=$GPHOME/lib/python and + # LD_LIBRARY_PATH=$GPHOME/lib, so gppylib and libpostgres.so have to land + # in lib. Pin it for the same compatibility reason as the prefix above. + 'libdir=lib', ] ) @@ -2729,13 +2735,9 @@ cdata.set('MEMSET_LOOP_LIMIT', memset_loop_limit) cdata.set_quoted('DLSUFFIX', dlsuffix) -# built later than the rest of the version metadata, we need SIZEOF_VOID_P -cdata.set_quoted('PG_VERSION_STR', - 'PostgreSQL @0@ on @1@-@2@, compiled by @3@-@4@, @5@-bit'.format( - pg_version, host_machine.cpu_family(), host_system, - cc.get_id(), cc.version(), cdata.get('SIZEOF_VOID_P') * 8, - ) -) +# PG_VERSION_STR is set further down, in the Cloudberry configuration section: +# it needs SIZEOF_VOID_P, which is why upstream builds it here, but it also +# needs the Cloudberry version, which is computed later still. @@ -3022,6 +3024,16 @@ generated_sources_ac = {} # its own directory, so it is safe to invoke from any working directory. bash = find_program('bash', native: true) +# Three of Cloudberry's Makefiles install a symlink. meson.add_install_script +# with this helper is the 0.54-compatible way to do that; see its header for +# why the alternative -- install_symlink, and the floor it needs -- costs more +# than it saves. +# +# A plain path, not files(): add_install_script only learned to take a File in +# 0.55. meson.source_root() is how upstream spells this at the same floor -- +# project_source_root() would itself be too new. +gp_install_symlink = meson.source_root() / 'src' / 'tools' / 'install_symlink.py' + gp_version_long = run_command('bash', meson.current_source_dir() / 'getversion', check: true).stdout().strip() gp_version_short = run_command('bash', meson.current_source_dir() / 'getversion', @@ -3046,6 +3058,25 @@ cdata.set_quoted('GP_VERSION', gp_version_long) cdata.set_quoted('GP_MAJORVERSION', gp_majorversion) cdata.set('GP_VERSION_NUM', gp_version_num) +# This is what `select version()` returns, and gpMgmt parses it: gpversion.py +# looks for "(Apache Cloudberry build )" and refuses to run +# against anything else, so dropping the parenthesised part -- as the upstream +# string does -- makes gpstart, gpstop and gpstate fail on a cluster that is +# otherwise perfectly healthy. Keep it byte-compatible with configure.ac: +# +# PostgreSQL $PG_VERSION (Apache Cloudberry $GP_VERSION) on $host, \ +# compiled by $cc_string, N-bit +# +# The host and compiler spellings still differ from autoconf's, because meson +# has no config.guess triplet and reports the compiler as id-version. Nothing +# parses those. +cdata.set_quoted('PG_VERSION_STR', + 'PostgreSQL @0@ (Apache Cloudberry @1@) on @2@-@3@, compiled by @4@-@5@, @6@-bit'.format( + pg_version, gp_version_long, host_machine.cpu_family(), host_system, + cc.get_id(), cc.version(), cdata.get('SIZEOF_VOID_P') * 8, + ) +) + # ORCA optimizer (orcaopt / xerces are resolved near the top of this file, # because enabling C++ has to happen before any C++ target is defined) if xerces.found() diff --git a/src/backend/task/meson.build b/src/backend/task/meson.build index b3157e03bc0..02f38f67bab 100644 --- a/src/backend/task/meson.build +++ b/src/backend/task/meson.build @@ -14,10 +14,22 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. -backend_sources += files( +# This directory's Makefile adds -Wno-implicit-fallthrough to CPPFLAGS. meson +# compiles the whole backend as one target, so the sources are split into their +# own static library to carry the flag, the same way src/backend/nodes does for +# its include path. +task_sources = files( 'entry.c', 'job_metadata.c', 'misc.c', 'pg_cron.c', 'task_states.c', ) + +task_lib = static_library('task', + task_sources, + c_args: ['-Wno-implicit-fallthrough'], + dependencies: [backend_code], + kwargs: internal_lib_args, +) +backend_link_with += task_lib diff --git a/src/bin/pg_dump/meson.build b/src/bin/pg_dump/meson.build index 79cdfd86192..f98fdf23d63 100644 --- a/src/bin/pg_dump/meson.build +++ b/src/bin/pg_dump/meson.build @@ -1,5 +1,9 @@ # Copyright (c) 2022-2023, PostgreSQL Global Development Group +# override CPPFLAGS := -Wno-deprecated-declarations ... in this directory's +# Makefile, applied to everything built here. +pg_dump_c_args = ['-Wno-deprecated-declarations'] + pg_dump_common_sources = files( 'compress_gzip.c', 'compress_io.c', @@ -21,6 +25,7 @@ pg_dump_common_sources = files( pg_dump_common = static_library('libpgdump_common', pg_dump_common_sources, c_pch: pch_postgres_fe_h, + c_args: pg_dump_c_args, dependencies: [frontend_code, libpq, lz4, zlib, zstd], kwargs: internal_lib_args, ) @@ -41,6 +46,7 @@ endif pg_dump = executable('pg_dump', pg_dump_sources, link_with: [pg_dump_common], + c_args: pg_dump_c_args, dependencies: [frontend_code, libpq, zlib], kwargs: default_bin_args, ) @@ -60,6 +66,7 @@ endif pg_dumpall = executable('pg_dumpall', pg_dumpall_sources, link_with: [pg_dump_common], + c_args: pg_dump_c_args, dependencies: [frontend_code, libpq, zlib], kwargs: default_bin_args, ) @@ -79,6 +86,7 @@ endif pg_restore = executable('pg_restore', pg_restore_sources, link_with: [pg_dump_common], + c_args: pg_dump_c_args, dependencies: [frontend_code, libpq, zlib], kwargs: default_bin_args, ) diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build index f8aaf2d863e..525b3a1b10b 100644 --- a/src/include/catalog/meson.build +++ b/src/include/catalog/meson.build @@ -180,6 +180,11 @@ if not get_option('external_fts') input += files('gp_segment_configuration_indexing.h') endif +# gppylib's foreign-key JSON is built from this same set of headers, which is +# why the Makefiles keep it in one variable. Export it rather than let +# gpMgmt/bin/gppylib/data grow a second copy of the list that can drift. +postgres_bki_srcs = input + generated_catalog_headers = custom_target('generated_catalog_headers', output: output_files, install_dir: output_install, diff --git a/src/pl/plpgsql/src/meson.build b/src/pl/plpgsql/src/meson.build index bc63e35612d..6b65bd82378 100644 --- a/src/pl/plpgsql/src/meson.build +++ b/src/pl/plpgsql/src/meson.build @@ -2,12 +2,21 @@ plpgsql_sources = files( 'pl_comp.c', - 'pl_exec.c', 'pl_funcs.c', 'pl_handler.c', 'pl_scanner.c', ) +# This directory's Makefile scopes -Wno-array-bounds to pl_exec.o alone. meson +# has no per-file flags, so pl_exec.c gets its own static library rather than +# relaxing the warning for the whole module. +plpgsql_pl_exec = static_library('plpgsql_pl_exec', + files('pl_exec.c'), + c_args: ['-Wno-array-bounds'], + dependencies: [backend_code], + kwargs: internal_lib_args, +) + pl_gram = custom_target('gram', input: 'pl_gram.y', kwargs: bison_kw, @@ -51,6 +60,7 @@ endif plpgsql = shared_module('plpgsql', plpgsql_sources, + link_whole: plpgsql_pl_exec, c_pch: pch_postgres_h, include_directories: include_directories('.'), kwargs: pg_mod_args, diff --git a/src/pl/plpython/meson.build b/src/pl/plpython/meson.build index 98b7d7c7af7..2cabc5a95e0 100644 --- a/src/pl/plpython/meson.build +++ b/src/pl/plpython/meson.build @@ -42,6 +42,8 @@ plpython = shared_module('plpython3', include_directories: [plpython_inc, postgres_inc], kwargs: pg_mod_args + { 'dependencies': [python3_dep, pg_mod_args['dependencies']], + # override CPPFLAGS := -Wno-error ... in this directory's Makefile + 'c_args': pg_mod_args.get('c_args', []) + ['-Wno-error'], }, ) pl_targets += plpython diff --git a/src/tools/install_symlink.py b/src/tools/install_symlink.py new file mode 100755 index 00000000000..800159fa472 --- /dev/null +++ b/src/tools/install_symlink.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +"""Create a symlink in the install tree. + +Usage: install_symlink.py + + link where the symlink goes, relative to the install prefix + target what it points to, verbatim -- relative links stay relative + +Cloudberry's Makefiles create three symlinks that the upstream PostgreSQL +build has no equivalent for: + + $bindir/stream/stream -> ../lib/stream + $bindir/lib/gpcheckcat -> ../gpcheckcat + $pkglibdir/gps3ext.so -> gpcloud.so + +meson grew install_symlink() in 0.61, but PostgreSQL declares a floor of +0.54 and means it -- and raising the floor here turns roughly thirty +deprecations in upstream's own meson files into warnings on every configure, +because meson only reports a deprecated API once the project claims a version +that has it deprecated. Three symlinks are not worth that, nor worth +diverging from upstream on the one line every future merge touches. +""" + +import os +import sys +from pathlib import Path + + +def main(argv) -> int: + if len(argv) != 3: + print(__doc__.strip(), file=sys.stderr) + return 2 + + link_rel, target = argv[1], argv[2] + + # DESTDIR-prefixed, so `meson install --destdir` stages correctly. + prefix = Path(os.environ['MESON_INSTALL_DESTDIR_PREFIX']) + quiet = os.environ.get('MESON_INSTALL_QUIET', '') not in ('', '0', 'false') + + link = prefix / link_rel + link.parent.mkdir(parents=True, exist_ok=True) + + # Installing twice must not fail, and neither must installing over a real + # file left by an earlier layout. This is what `ln -sf` gives the + # Makefiles. + if link.is_symlink() or link.exists(): + link.unlink() + link.symlink_to(target) + + if not quiet: + print('Installing symlink {} pointing to {}'.format(link, target)) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) From 2f970bd6fe28b75871f1608b6d321a51ef8c49c9 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 1 Sep 2026 10:01:10 +0800 Subject: [PATCH 11/13] ci: harden the meson workflow around what the first runs found The workflow that came with the port built one configuration and ran a fixed smoke test. Everything here is a response to something the first real runs turned up. An install-parity job. The port lists installed files by hand, so a file added to a Makefile and not to the meson.build beside it is silently dropped. Ten such files went unnoticed until gpstop died on a cluster that had come up cleanly; no build catches that, and a test catches only the fraction it exercises. The check is static, finishes in seconds, and reports before the build it would not have been caught by. A configuration-aware smoke test. The old one asserted the full configuration's binaries and GUCs, so every other matrix entry failed for doing what it was told -- missing bin/gpmapreduce, and a FATAL from optimizer=on in a build without ORCA. The expected set now comes from meson-info, so one test serves the whole matrix, which is what makes having a matrix worth anything. gpcheckcat in the cluster test. It is the only thing that reads the foreign-key JSON, so an install missing that file is silent everywhere else. The PyPI downloads move to the front of the job and are cached. They were happening after a forty-minute build, which put the network on the critical path at the worst moment; the Makefile's download target also pip-installs wheel and Cython when absent, and they are absent from the build image, so those go in with meson and ninja instead. Nothing between meson setup and the end of the build reaches the network now, and an offline build only has to stage the three tarballs. Building src/common's frontend library on its own, before the full build. That directory is compiled both ways, and a missing generated-header dependency there fails or not depending on scheduling -- one red matrix entry and one green one on the same commit. Also: the matrix drops to two opposite configurations rather than three, and the workflow triggers on main only, pg16-ci having been a branch in a personal fork. Assisted-by: Claude Code --- .github/workflows/build-meson-cloudberry.yml | 163 ++++++++++++++---- .../cloudberry/scripts/meson-cluster-test.sh | 20 +++ .../scripts/meson-install-parity.py | 147 ++++++++++++++++ .../cloudberry/scripts/meson-smoke-test.sh | 86 +++++++-- gpMgmt/install_python_modules.py | 11 ++ 5 files changed, 378 insertions(+), 49 deletions(-) create mode 100755 devops/build/automation/cloudberry/scripts/meson-install-parity.py diff --git a/.github/workflows/build-meson-cloudberry.yml b/.github/workflows/build-meson-cloudberry.yml index 9ef6b74b266..4f7e5f4d193 100644 --- a/.github/workflows/build-meson-cloudberry.yml +++ b/.github/workflows/build-meson-cloudberry.yml @@ -29,20 +29,29 @@ # # Shape, mirroring build-cloudberry.yml: # -# check-skip -> build (matrix) -> cluster-test -> report +# check-skip -> install-parity -> report +# -> build (matrix) -> cluster-test -> report # -# The build matrix is the part that earns its keep today. Most of the bugs -# found while porting were in option combinations rather than in any single -# configuration: C++ being enabled only for ORCA, PAX requiring the shared -# backend, extensions gated on flags that were never exercised together. Three -# configurations cover that surface: +# install-parity is static and finishes in seconds, so the most common porting +# mistake -- a file added to a Makefile and not to the meson.build beside it -- +# is reported long before the build that would not have caught it anyway. # -# full every component this branch supports -# minimal everything optional switched off, which catches -# conditional guards that only work when enabled -# no-shared-backend -Dshared_postgres_backend=false, a path nothing else -# covers (PAX has to come off with it, since PAX links -# against libpostgres.so) +# The build matrix is two configurations, and they are opposites: +# +# full every component this branch supports, and the reference line in +# coverity.yml. It is what cluster-test runs against. +# minimal every optional component off, shared_postgres_backend included +# +# One build would only ever exercise the enabled side of each `if +# get_option(...)` in the meson files, and the disabled side is where this +# port's bugs were: C++ enabled only for ORCA, PAX requiring the shared +# backend, extensions gated on flags nothing turned off. Between the two, +# every option is compiled in both states. +# +# What that pair does not reach is a cross -- ORCA on with the shared backend +# off, which is the one combination where C++ objects link into a static +# postgres. Add a third configuration if that link ever needs guarding; until +# then it is not worth a third full build of the tree. # # Regression suites are NOT run here yet. src/test/regress and friends are # make-driven and include src/Makefile.global from the source tree, which only @@ -86,17 +95,22 @@ # PyGreSQL from PyPI during `make install`, which has no honest meson # equivalent -- a build should not reach the network. The meson build still # installs those modules, but only if they have already been staged in -# gpMgmt/bin/ext; see gpMgmt/install_python_modules.py. The build job stages -# them the same way the autoconf build does, so the install tree -# cluster-test unpacks is self-contained. +# gpMgmt/bin/ext; see gpMgmt/install_python_modules.py. +# +# The build job splits that in two, so the boundary is real rather than +# rhetorical: the sources are fetched up front, alongside meson and ninja and +# before anything is configured, and are unpacked and compiled after the +# install (PyGreSQL needs pg_config). Nothing between meson setup and the end +# of the build touches the network, an unreachable PyPI fails the job in +# seconds, and the tarballs are cached between runs. # -------------------------------------------------------------------- name: Apache Cloudberry Meson Build on: push: - branches: [ main, pg16-ci ] + branches: [ main ] pull_request: - branches: [ main, pg16-ci ] + branches: [ main ] workflow_dispatch: permissions: @@ -138,6 +152,31 @@ jobs: fi fi + # ------------------------------------------------------------------ + install-parity: + name: Install parity + runs-on: ubuntu-22.04 + needs: [check-skip] + if: needs.check-skip.outputs.should_skip != 'true' + steps: + - name: Checkout Apache Cloudberry + uses: actions/checkout@v7 + with: + # No submodules: this job reads Makefiles and meson.build files and + # compiles nothing. Cloning googletest and friends would cost more + # than the check itself, and the point of the job is fast feedback. + fetch-depth: 1 + submodules: false + + - name: Compare Makefile install lists against meson.build + run: | + set -euo pipefail + # Static, so it runs in seconds and reports before the build finishes. + # It catches the failure mode this port is most exposed to: a file + # added to a Makefile and not to the meson.build beside it, which no + # build failure reveals and only a running cluster notices. + python3 devops/build/automation/cloudberry/scripts/meson-install-parity.py + # ------------------------------------------------------------------ build: name: Build (${{ matrix.name }}) @@ -186,16 +225,9 @@ jobs: -Dmapreduce=disabled -Ddiskquota=disabled -Dpax=disabled + -Dshared_postgres_backend=false -Ddebug_extensions=false -Dtap_tests=disabled - - name: no-shared-backend - upload: false - options: >- - -Dshared_postgres_backend=false - -Dpax=disabled - -Dorca=enabled - -Dgpfdist=enabled - -Dpxf=enabled container: image: apache/incubator-cloudberry:cbdb-build-rocky9-latest @@ -217,13 +249,53 @@ jobs: exit 1 fi - - name: Install meson and ninja + - name: Install Python build tools run: | set -euox pipefail # The build image ships autoconf/make but not meson. python3 -m pip install --disable-pip-version-check "meson${MESON_VERSION}" ninja meson --version ninja --version + # What builds psutil, PyGreSQL and PyYAML later: they are setup.py + # distributions, and PyYAML cythonises its C extension. gpMgmt/bin's + # Makefile pip-installs wheel and Cython itself when they are absent, + # which on this image they are -- as gpadmin, mid-build, over the + # network. Installed here as root they are importable by gpadmin, so + # that check passes and the staging step stays offline. setuptools + # comes along because Python 3.12 dropped distutils and setup.py needs + # its shim; the rocky9 image already has it, images newer than it may + # not. + python3 -m pip install --disable-pip-version-check setuptools wheel "cython<3.0.0" + + - name: Restore cached gpMgmt Python sources + if: matrix.upload + uses: actions/cache@v4 + with: + # Only the tarballs. The unpacked trees and their build output live in + # the same directory and are worthless to cache -- they are rebuilt + # against this job's Python either way. + path: gpMgmt/bin/pythonSrc/ext/*.tar.gz + key: gpmgmt-python-src-${{ hashFiles('gpMgmt/bin/Makefile') }} + + - name: Fetch gpMgmt Python sources + if: matrix.upload + run: | + set -euox pipefail + # psutil, PyGreSQL and PyYAML come from PyPI. Fetching them here, next + # to the other dependency installs and before anything is configured, + # keeps the build itself off the network and turns an unreachable PyPI + # into a failure in seconds rather than after a 40-minute build. They + # cannot be vendored in the repo -- downloading them is what replaced + # that, under the Apache release policy. + # + # This is the target the autoconf build uses, so the versions and URLs + # have one home. It skips any tarball already there, which is what + # makes the cache above work and what an offline build relies on. + # wheel and Cython, which it would otherwise pip-install here, are + # already in from the step above. + make -C gpMgmt/bin download-python-deps + for f in gpMgmt/bin/pythonSrc/ext/*.tar.gz; do gzip -t "${f}"; done + ls -la gpMgmt/bin/pythonSrc/ext/*.tar.gz - name: Prepare install prefix run: | @@ -278,6 +350,21 @@ jobs: grep "WARNING" "${LOG}" | head -20 fi + - name: Build the frontend common library first + run: | + set -euox pipefail + # src/common is compiled twice, once with -DFRONTEND. A backend header + # included there without an #ifndef FRONTEND guard drags in headers + # that only the backend build generates, and ninja is free to compile + # the frontend copy before anything has generated them -- so such a + # mistake fails the build or not depending on scheduling. It cost one + # red matrix entry and one green one on the same commit. + # + # Building this single target from cold, before the full build has + # produced anything, turns that coin flip into a deterministic check + # for the one directory that is compiled both ways. + su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson src/common/libpgcommon_shlib.a" + - name: ninja build run: | set -euox pipefail @@ -315,8 +402,11 @@ jobs: # management utilities, not build inputs. The meson build installs them # if they have been staged in gpMgmt/bin/ext but never downloads them, # so stage them with gpMgmt/bin's own targets -- the same ones - # --with-pythonsrc-ext drives -- and install a second time to pick them - # up. PyGreSQL needs pg_config, hence the order. + # --with-pythonsrc-ext drives. + # + # The sources were fetched before the build; this unpacks and compiles + # them. It cannot move earlier: PyGreSQL builds against pg_config, so + # it needs a finished install, and that is why the install runs twice. su gpadmin -c "cd ${GITHUB_WORKSPACE} && PATH=${INSTALL_PREFIX}/bin:\$PATH \ make -C gpMgmt/bin TAR=tar psutil pygresql pyyaml" su gpadmin -c "cd ${GITHUB_WORKSPACE} && ninja -C build-meson install" @@ -327,7 +417,9 @@ jobs: - name: Smoke test run: | set -euox pipefail - su gpadmin -c "${GITHUB_WORKSPACE}/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh ${INSTALL_PREFIX}" + # The build directory is passed so the smoke test can read which + # optional components this configuration asked for; see its header. + su gpadmin -c "${GITHUB_WORKSPACE}/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh ${INSTALL_PREFIX} ${GITHUB_WORKSPACE}/build-meson" - name: Package install tree if: matrix.upload @@ -375,6 +467,10 @@ jobs: - name: Checkout Apache Cloudberry uses: actions/checkout@v7 with: + # No submodules: this job runs against the install tree built by the + # build job, which does check them out -- PAX compiles against + # src/cpp/contrib/tabulate. Nothing is compiled here; the checkout is + # only for gpAux/gpdemo and the test scripts. fetch-depth: 1 submodules: false @@ -420,11 +516,12 @@ jobs: report: name: Report runs-on: ubuntu-22.04 - needs: [check-skip, build, cluster-test] + needs: [check-skip, install-parity, build, cluster-test] if: always() && needs.check-skip.outputs.should_skip != 'true' steps: - name: Summarise run: | + PARITY="${{ needs.install-parity.result }}" BUILD="${{ needs.build.result }}" CLUSTER="${{ needs.cluster-test.result }}" { @@ -432,11 +529,13 @@ jobs: echo echo "| Job | Result |" echo "| --- | --- |" + echo "| install-parity | ${PARITY} |" echo "| build (all configurations) | ${BUILD} |" echo "| cluster-test | ${CLUSTER} |" } >> "$GITHUB_STEP_SUMMARY" - if [ "${BUILD}" != "success" ] || [ "${CLUSTER}" != "success" ]; then - echo "::error::meson workflow failed (build=${BUILD} cluster-test=${CLUSTER})" + if [ "${PARITY}" != "success" ] || [ "${BUILD}" != "success" ] \ + || [ "${CLUSTER}" != "success" ]; then + echo "::error::meson workflow failed (install-parity=${PARITY} build=${BUILD} cluster-test=${CLUSTER})" exit 1 fi echo "All meson jobs passed" diff --git a/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh index 2d138d4130f..aa84b9a84a7 100755 --- a/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh +++ b/devops/build/automation/cloudberry/scripts/meson-cluster-test.sh @@ -37,6 +37,9 @@ SRCDIR="${2:?usage: $0 }" fail() { echo "::error::$*" >&2; exit 1; } section() { echo; echo "== $* =="; } +OUTDIR="$(mktemp -d)" +trap 'rm -rf "${OUTDIR}"' EXIT + # -------------------------------------------------------------------- # Environment # -------------------------------------------------------------------- @@ -85,6 +88,7 @@ cleanup() { echo echo "== tearing down the demo cluster ==" make -C "${SRCDIR}/gpAux/gpdemo" destroy-demo-cluster >/dev/null 2>&1 || true + rm -rf "${OUTDIR}" } trap cleanup EXIT @@ -93,6 +97,22 @@ gpstop -a || fail "gpstop failed" gpstart -a || fail "gpstart failed" gpstate || fail "gpstate failed" +section "gpcheckcat" +# Runs before any user tables exist, so the catalog is pristine and a failure +# means the installation rather than the workload. Its foreign_key test reads +# gppylib/data/.json, generated at build time from the catalog headers; +# gpcheckcat is the only thing that reads it, so nothing else notices when the +# install does not have it. +gpcheckcat -p "${PGPORT}" postgres >"${OUTDIR}/gpcheckcat.out" 2>&1 || { + tail -30 "${OUTDIR}/gpcheckcat.out" >&2 + fail "gpcheckcat failed" +} +grep -q "Found no catalog issue" "${OUTDIR}/gpcheckcat.out" || { + tail -30 "${OUTDIR}/gpcheckcat.out" >&2 + fail "gpcheckcat did not report a clean catalog" +} +echo " ok $(grep -c "^Performing test" "${OUTDIR}/gpcheckcat.out") catalog tests, no issues" + # -------------------------------------------------------------------- # MPP checks # -------------------------------------------------------------------- diff --git a/devops/build/automation/cloudberry/scripts/meson-install-parity.py b/devops/build/automation/cloudberry/scripts/meson-install-parity.py new file mode 100755 index 00000000000..6b18938d938 --- /dev/null +++ b/devops/build/automation/cloudberry/scripts/meson-install-parity.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed +# with this work for additional information regarding copyright +# ownership. The ASF licenses this file to You under the Apache +# License, Version 2.0 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. + +"""Check that the meson build installs every file the Makefiles install. + +The meson port lists Cloudberry's installed files by hand, so a file added to +a Makefile after the port lands is silently dropped from the meson install. +That failure is invisible until something imports the missing module at +runtime -- which is how gppylib/commands/base.py, gppylib/util/ and the +gpcheckcat catalog JSON were found: not by a build failure, but by gpstop +dying on a cluster that had come up cleanly. + +This is the static check for that class of bug. For every Makefile with an +install target, it reads the filenames the recipe installs and looks for each +one in the meson.build next to it. It is deliberately textual: a name that +appears anywhere in meson.build counts, because the point is to catch +omissions, not to model meson. + +Scope is the Cloudberry-specific trees, where meson.build spells filenames out +literally. Upstream PostgreSQL directories are excluded: they generate install +lists programmatically, so a name-for-name comparison there reports noise +rather than bugs. + +Usage: meson-install-parity.py [source-root] +""" + +import os +import re +import sys + +# Cloudberry's own trees. Everything under them is checked. +ROOTS = ['gpMgmt', 'gpcontrib', 'gpAux', 'contrib/pax_storage'] + +# Directories never walked into: tests are not installed, and pythonSrc/ext +# holds unpacked third-party tarballs. +SKIP_DIRS = {'test', 'tests', '__pycache__', 'ext', 'pythonSrc', 'regress', + 'unit', 'build', 'third-party'} + +# Files a Makefile mentions but neither build system installs. Each needs a +# reason, so that this list cannot quietly become a way to silence real gaps. +EXPECTED_ABSENT = { + # Built only under cmake's BUILD_TOOLS, which defaults to OFF and which + # contrib/pax_storage/Makefile never turns on, so the `if [ -f ... ]` + # around its install never fires in either build. + 'contrib/pax_storage': {'pax_dump'}, +} + + +def makefile_vars(text): + """Resolve the simple `NAME = a b c` assignments a Makefile uses.""" + variables = {} + for m in re.finditer(r'^(\w+)\s*[:+]?=\s*((?:.*\\\n)*.*)$', text, re.M): + variables[m.group(1)] = m.group(2).replace('\\\n', ' ') + return variables + + +def installed_names(makefile_text): + """Filenames the install recipe installs, from $(VAR) loops and literals.""" + body = makefile_text.split('\ninstall:')[1].split('\n\n')[0] + names = set() + variables = makefile_vars(makefile_text) + for var in re.findall(r'\$\((\w+)\)', body): + for token in variables.get(var, '').split(): + # Skip make functions, paths and anything without an extension: + # those are directories or variables, not installed files. + if re.match(r'^[\w.+-]+$', token) and '.' in token: + names.add(token) + for token in re.findall(r'INSTALL_(?:SCRIPT|DATA|PROGRAM|SHLIB)\)?\s+([\w./+-]+)', body): + names.add(os.path.basename(token)) + return names + + +def names_meson(name, meson): + """Is this installed file accounted for in meson.build? + + Usually the filename appears verbatim in an install_data() list. A + compiled module is the exception: the Makefile installs pax.so, while + meson declares shared_module('pax') and derives the suffix, so fall back + to matching the target name for the extensions a build produces. + """ + if name in meson: + return True + stem, ext = os.path.splitext(name) + return ext in ('.so', '.dylib', '.dll', '.a') and "'%s'" % stem in meson + + +def main(argv) -> int: + root = argv[1] if len(argv) > 1 else '.' + gaps = [] + + for tree in ROOTS: + for dirpath, dirnames, filenames in os.walk(os.path.join(root, tree)): + dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS] + if 'Makefile' not in filenames: + continue + + rel = os.path.relpath(dirpath, root) + with open(os.path.join(dirpath, 'Makefile')) as f: + makefile = f.read() + if not re.search(r'^install:', makefile, re.M): + continue + + wanted = installed_names(makefile) - EXPECTED_ABSENT.get(rel, set()) + if not wanted: + continue + + meson_path = os.path.join(dirpath, 'meson.build') + if not os.path.exists(meson_path): + gaps.append((rel, sorted(wanted), 'no meson.build')) + continue + with open(meson_path) as f: + meson = f.read() + missing = sorted(n for n in wanted if not names_meson(n, meson)) + if missing: + gaps.append((rel, missing, 'not named in meson.build')) + + if not gaps: + print('meson install parity: no gaps') + return 0 + + for rel, missing, why in gaps: + print('::error::%s installs %s via make but %s' + % (rel, ' '.join(missing), why)) + print() + print('%d file(s) are installed by the autoconf build and not by meson.' + % sum(len(m) for _, m, _ in gaps)) + print('Add them to the meson.build alongside the Makefile, or, if neither') + print('build should install them, record why in EXPECTED_ABSENT here.') + return 1 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh index c2a3f037aa3..c21472fd15f 100755 --- a/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh +++ b/devops/build/automation/cloudberry/scripts/meson-smoke-test.sh @@ -23,35 +23,78 @@ # catalog generation end to end), and that the MPP-specific pieces are really # there rather than merely linked. # -# Usage: meson-smoke-test.sh +# Usage: meson-smoke-test.sh +# +# The build directory is read, not written: which optional components an +# install should contain depends on how it was configured, so the expected set +# is taken from meson rather than hardcoded. That is what lets one smoke test +# serve every entry in the build matrix instead of only the full one. # -------------------------------------------------------------------- set -euo pipefail -PREFIX="${1:?usage: $0 }" +PREFIX="${1:?usage: $0 }" +BUILDDIR="${2:?usage: $0 }" export LD_LIBRARY_PATH="${PREFIX}/lib:${LD_LIBRARY_PATH:-}" fail() { echo "::error::$*" >&2; exit 1; } +INTRO="${BUILDDIR}/meson-info/intro-buildoptions.json" +[ -f "${INTRO}" ] || fail "no ${INTRO} -- is ${BUILDDIR} a meson build directory?" + +# True when the named option was configured on. Feature options read +# "enabled"; booleans read true. An option meson does not know is a typo here, +# and is reported rather than quietly treated as off. +enabled() { + python3 - "$1" "${INTRO}" <<'PY' +import json, sys +name, intro = sys.argv[1], sys.argv[2] +options = {o["name"]: o["value"] for o in json.load(open(intro))} +if name not in options: + sys.stderr.write("::error::no such meson option: %s\n" % name) + sys.exit(2) +sys.exit(0 if options[name] in (True, "enabled") else 1) +PY +} + # -------------------------------------------------------------------- # 1. Installed artifacts # -------------------------------------------------------------------- +check_bin() { + [ -x "${PREFIX}/bin/$1" ] || fail "missing bin/$1" + echo " ok bin/$1" +} + echo "== checking installed binaries ==" -for b in postgres initdb pg_ctl psql pg_dump pg_upgrade gpfdist gpfts \ - gpmapreduce gpcheckcloud pg_alterckey; do - [ -x "${PREFIX}/bin/${b}" ] || fail "missing bin/${b}" - echo " ok bin/${b}" +for b in postgres initdb pg_ctl psql pg_dump pg_upgrade gpfts pg_alterckey; do + check_bin "${b}" done +# Gated on the option that builds each one, so that a configuration which did +# not ask for a component is not failed for not having it -- and a +# configuration that did ask still has to produce it. +if enabled gpfdist; then check_bin gpfdist; else echo " skip gpfdist (disabled)"; fi +if enabled mapreduce; then check_bin gpmapreduce; else echo " skip gpmapreduce (disabled)"; fi +if enabled gpcloud; then check_bin gpcheckcloud; else echo " skip gpcheckcloud (disabled)"; fi echo "== checking GP extensions ==" -for e in interconnect gp_exttable_fdw gp_toolkit gp_distribution_policy pxf_fdw; do +for e in interconnect gp_exttable_fdw gp_toolkit gp_distribution_policy; do [ -f "${PREFIX}/share/postgresql/extension/${e}.control" ] || fail "missing extension ${e}" echo " ok ${e}" done +if enabled pxf; then + [ -f "${PREFIX}/share/postgresql/extension/pxf_fdw.control" ] || fail "missing extension pxf_fdw" + echo " ok pxf_fdw" +else + echo " skip pxf_fdw (disabled)" +fi echo "== checking PAX ==" -[ -f "${PREFIX}/share/postgresql/cdb_init.d/pax-cdbinit--1.0.sql" ] \ - || fail "missing generated pax-cdbinit--1.0.sql" -echo " ok pax-cdbinit--1.0.sql" +if enabled pax; then + [ -f "${PREFIX}/share/postgresql/cdb_init.d/pax-cdbinit--1.0.sql" ] \ + || fail "missing generated pax-cdbinit--1.0.sql" + echo " ok pax-cdbinit--1.0.sql" +else + echo " skip pax (disabled)" +fi echo "== checking library layout ==" # These paths are not interchangeable: cloudberry-env.sh hardcodes @@ -104,9 +147,14 @@ echo " ok initdb" # A full postmaster needs an MPP identity (-b dbid) and a segment # configuration; single-user mode is enough to prove the catalogs, the # optimizer and the storage layer are functional. +# optimizer=on is fatal in a build without ORCA -- "ORCA is not supported by +# this build" -- so it goes on only when there is an optimizer to ask for. +PG_OPTS=(-c gp_role=utility) +if enabled orca; then PG_OPTS+=(-c optimizer=on); fi + run_sql() { printf '%s\n' "$1" | "${PREFIX}/bin/postgres" --single -D "${DATADIR}" \ - -c gp_role=utility -c optimizer=on postgres 2>&1 + "${PG_OPTS[@]}" postgres 2>&1 } echo "== checking GP catalogs ==" @@ -139,12 +187,16 @@ grep -q "(Apache Cloudberry " "${WORKDIR}/version.out" || { echo " ok $(sed -n 's/.*(\(Apache Cloudberry [^)]*\)).*/\1/p' "${WORKDIR}/version.out" | head -1)" echo "== checking ORCA ==" -run_sql "select gp_opt_version();" >"${WORKDIR}/orca.out" -grep -q "GPOPT version" "${WORKDIR}/orca.out" || { - cat "${WORKDIR}/orca.out" >&2 - fail "ORCA is not available" -} -echo " ok $(sed -n 's/.*gp_opt_version = "\([^"]*\)".*/\1/p' "${WORKDIR}/orca.out" | head -1)" +if enabled orca; then + run_sql "select gp_opt_version();" >"${WORKDIR}/orca.out" + grep -q "GPOPT version" "${WORKDIR}/orca.out" || { + cat "${WORKDIR}/orca.out" >&2 + fail "ORCA is not available" + } + echo " ok $(sed -n 's/.*gp_opt_version = "\([^"]*\)".*/\1/p' "${WORKDIR}/orca.out" | head -1)" +else + echo " skip orca (disabled)" +fi echo "== checking append-only storage ==" run_sql "create table t_ao(a int) with (appendonly=true);" >/dev/null diff --git a/gpMgmt/install_python_modules.py b/gpMgmt/install_python_modules.py index b520245ccff..61fbf3b791b 100755 --- a/gpMgmt/install_python_modules.py +++ b/gpMgmt/install_python_modules.py @@ -35,6 +35,17 @@ PATH=$prefix/bin:$PATH make -C gpMgmt/bin TAR=tar psutil pygresql pyyaml ninja -C build install +That target fetches the three tarballs from PyPI the first time, and skips +any it already finds, so an air-gapped or offline build only has to put them +in gpMgmt/bin/pythonSrc/ext beforehand -- at the exact versions named at the +top of gpMgmt/bin/Makefile: + + psutil-5.7.0.tar.gz PyGreSQL-5.2.tar.gz PyYAML-5.4.1.tar.gz + +Fetching them is then a step you control, and nothing after `meson setup` +reaches the network. (They are not vendored in the repo; downloading them +is what replaced that, under the Apache release policy.) + Anything else that leaves importable modules in gpMgmt/bin/ext works too -- a virtualenv's site-packages copied in, or distribution packages. An install with nothing staged is still a valid install; it just cannot run the From de26a4004c7b8420000444602ed2bb9e3175f6e4 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 1 Sep 2026 11:12:58 +0800 Subject: [PATCH 12/13] Fix gpMgmt Python downloads accepting a failed fetch curl without -f treats an HTTP error as success: it writes the error body to the output file and exits 0. The guard around each download then only asks whether the file exists, so a single 404 or bad gateway leaves a broken tarball that every later run skips over as already downloaded. The build fails much later, in tar, with nothing pointing at the cause. $ curl -sSL .../psutil-99.99.99.tar.gz -o t # 404 $ echo $?; wc -c < t 0 0 Add -f so the request fails, --retry 3 so a transient one does not, and make each guard -s rather than -f so a zero-byte leftover is retried instead of trusted. curl leaves the partial file behind, and --remove-on-error needs a curl newer than rocky8 ships, so the guard is the portable place to fix this. Verified in the build container: a 404 now stops the target with curl's exit status and leaves no file, and with no route to PyPI a zeroed tarball fails the target rather than silently persisting. Assisted-by: Claude Code --- gpMgmt/bin/Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gpMgmt/bin/Makefile b/gpMgmt/bin/Makefile index 7092700b784..a037d5b41f8 100644 --- a/gpMgmt/bin/Makefile +++ b/gpMgmt/bin/Makefile @@ -87,27 +87,30 @@ PYGRESQL_VERSION=5.2 PSUTIL_VERSION=5.7.0 PYYAML_VERSION=5.4.1 +# curl needs -f here: without it an HTTP error is written to the output +# file and reported as success, and the -s guard below then treats that +# file as a finished download on every later run. download-python-deps: @echo "--- Downloading Python dependencies for gpMgmt modules" @mkdir -p $(PYLIB_SRC_EXT) # Download psutil using curl (only if not exists) - @if [ ! -f $(PYLIB_SRC_EXT)/psutil-$(PSUTIL_VERSION).tar.gz ]; then \ + @if [ ! -s $(PYLIB_SRC_EXT)/psutil-$(PSUTIL_VERSION).tar.gz ]; then \ echo "Downloading psutil-$(PSUTIL_VERSION).tar.gz..."; \ - curl -sSL https://files.pythonhosted.org/packages/source/p/psutil/psutil-$(PSUTIL_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/psutil-$(PSUTIL_VERSION).tar.gz; \ + curl -sSLf --retry 3 https://files.pythonhosted.org/packages/source/p/psutil/psutil-$(PSUTIL_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/psutil-$(PSUTIL_VERSION).tar.gz; \ else \ echo "psutil-$(PSUTIL_VERSION).tar.gz already exists, skipping download"; \ fi # Download PyYAML using curl (only if not exists) - @if [ ! -f $(PYLIB_SRC_EXT)/PyYAML-$(PYYAML_VERSION).tar.gz ]; then \ + @if [ ! -s $(PYLIB_SRC_EXT)/PyYAML-$(PYYAML_VERSION).tar.gz ]; then \ echo "Downloading PyYAML-$(PYYAML_VERSION).tar.gz..."; \ - curl -sSL https://files.pythonhosted.org/packages/source/P/PyYAML/PyYAML-$(PYYAML_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/PyYAML-$(PYYAML_VERSION).tar.gz; \ + curl -sSLf --retry 3 https://files.pythonhosted.org/packages/source/P/PyYAML/PyYAML-$(PYYAML_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/PyYAML-$(PYYAML_VERSION).tar.gz; \ else \ echo "PyYAML-$(PYYAML_VERSION).tar.gz already exists, skipping download"; \ fi # Download PyGreSQL using curl (only if not exists) - @if [ ! -f $(PYLIB_SRC_EXT)/PyGreSQL-$(PYGRESQL_VERSION).tar.gz ]; then \ + @if [ ! -s $(PYLIB_SRC_EXT)/PyGreSQL-$(PYGRESQL_VERSION).tar.gz ]; then \ echo "Downloading PyGreSQL-$(PYGRESQL_VERSION).tar.gz..."; \ - curl -sSL https://files.pythonhosted.org/packages/source/P/PyGreSQL/PyGreSQL-$(PYGRESQL_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/PyGreSQL-$(PYGRESQL_VERSION).tar.gz; \ + curl -sSLf --retry 3 https://files.pythonhosted.org/packages/source/P/PyGreSQL/PyGreSQL-$(PYGRESQL_VERSION).tar.gz -o $(PYLIB_SRC_EXT)/PyGreSQL-$(PYGRESQL_VERSION).tar.gz; \ else \ echo "PyGreSQL-$(PYGRESQL_VERSION).tar.gz already exists, skipping download"; \ fi @@ -176,9 +179,9 @@ $(MOCK_BIN): pip3 install mock;\ else\ mkdir -p $(PYLIB_SRC_EXT) && \ - if [ ! -f $(PYLIB_SRC_EXT)/mock-$(MOCK_VERSION).zip ]; then \ + if [ ! -s $(PYLIB_SRC_EXT)/mock-$(MOCK_VERSION).zip ]; then \ echo "Downloading mock-$(MOCK_VERSION).zip..."; \ - curl -sSL https://files.pythonhosted.org/packages/source/m/mock/mock-$(MOCK_VERSION).zip -o $(PYLIB_SRC_EXT)/mock-$(MOCK_VERSION).zip; \ + curl -sSLf --retry 3 https://files.pythonhosted.org/packages/source/m/mock/mock-$(MOCK_VERSION).zip -o $(PYLIB_SRC_EXT)/mock-$(MOCK_VERSION).zip; \ else \ echo "mock-$(MOCK_VERSION).zip already exists, skipping download"; \ fi && \ From ff5685d2c36f56e714147bddf9d536f2854d1454 Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Tue, 1 Sep 2026 11:51:42 +0800 Subject: [PATCH 13/13] Fix the frontend build of src/common needing backend headers src/common is compiled twice, once with -DFRONTEND. percentrepl.c and kmgr_utils.c include utils/builtins.h unguarded, and that pulls in utils/fmgrprotos.h, which is generated for the backend and is not a declared dependency of anything frontend. Nothing orders the two, so ninja is free to compile the frontend copy first: ../src/include/utils/builtins.h:21:10: fatal error: utils/fmgrprotos.h: No such file or directory Which is exactly what happened, and only sometimes: on one commit the full matrix entry went green and the minimal one went red, on the same runner image, differing only in how much else there was to schedule. make never showed it because every Makefile there depends on submake-generated-headers, so the ordering is forced. Everything the offending headers declare -- GpIdentity, terminal_fd, pg_ltoa -- is used only from #ifndef FRONTEND blocks, so the includes belong inside one. kmgr_utils.c also included postgres.h unconditionally, which a FRONTEND translation unit must not do at all; it uses nothing from either header. Verified as a deterministic before/after in a cold build directory, building just the two frontend objects: both fail on the old sources, both compile on the new ones. Assisted-by: Claude Code --- src/common/kmgr_utils.c | 11 +++++++++-- src/common/percentrepl.c | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/common/kmgr_utils.c b/src/common/kmgr_utils.c index ede043d1078..52445b54421 100644 --- a/src/common/kmgr_utils.c +++ b/src/common/kmgr_utils.c @@ -34,12 +34,19 @@ #include "crypto/kmgr.h" #include "lib/stringinfo.h" #include "storage/fd.h" -#include "postgres.h" -#include "utils/builtins.h" #ifndef FRONTEND #include "pgstat.h" #include "storage/fd.h" +/* + * GPDB: backend-only, and unguarded until now. postgres.h must not be reached + * from a FRONTEND translation unit at all, and utils/builtins.h pulls in the + * generated utils/fmgrprotos.h, which nothing builds before src/common in a + * frontend build -- the same latent ordering bug that broke percentrepl.c + * under ninja. Nothing in this file uses either. + */ +#include "postgres.h" +#include "utils/builtins.h" #endif #define KMGR_PROMPT_MSG "Enter authentication needed to generate the cluster key: " diff --git a/src/common/percentrepl.c b/src/common/percentrepl.c index 53b717edda9..d3998655124 100644 --- a/src/common/percentrepl.c +++ b/src/common/percentrepl.c @@ -15,16 +15,25 @@ #ifndef FRONTEND #include "postgres.h" + +/* + * GPDB: everything these declare -- GpIdentity, terminal_fd, pg_ltoa -- is + * used only from #ifndef FRONTEND blocks below, and they are backend headers: + * utils/builtins.h pulls in the generated utils/fmgrprotos.h, which nothing + * builds before src/common in a frontend build. Including them unguarded made + * the frontend copy of this file depend on a backend header being generated + * first, which happened to hold under make's ordering and not under ninja's. + */ +#include "cdb/cdbvars.h" +#include "postmaster/postmaster.h" +#include "utils/builtins.h" #else #include "postgres_fe.h" #include "common/logging.h" #endif -#include "cdb/cdbvars.h" #include "common/percentrepl.h" #include "lib/stringinfo.h" -#include "postmaster/postmaster.h" -#include "utils/builtins.h" /* * replace_percent_placeholders