Skip to content

Commit 2f048ec

Browse files
committed
Add diskquota support for Apache Cloudberry
Integrate diskquota extension into Apache Cloudberry build system and adapt the codebase for Cloudberry 2.0+ (PostgreSQL 14 based). Main changes: Build system integration: * Add new Makefile for building with Cloudberry source tree ``` make make install make installcheck make clean ``` * Update gpcontrib/Makefile to include diskquota in build and installcheck * Simplify CMakeLists.txt by removing GP6 version conditionals * Add PG_SRC_DIR availability check for isolation2 tests Code modernization (remove GP6 compatibility code): * Remove GP_VERSION_NUM < 70000 conditionals throughout codebase * Replace deprecated APIs: heap_open -> table_open, heap_beginscan_catalog -> table_beginscan_catalog, heap_endscan -> table_endscan, etc. * Replace init_ps_display() with set_ps_display() for process status * Replace StrNCpy() with snprintf() for safer string handling * Remove WaitForBackgroundWorkerShutdown() polyfill (now in core) * Remove MemoryAccounting_Reset() calls (removed in GP7+) * Update tuple descriptor attribute access from pointer to direct access Documentation: * Rewrite README.md for Apache Cloudberry with updated build instructions Other improvements: * Update extension comment to be more descriptive * Ensure postgres.h is included first in all source files CI: * add ic-diskquota to `build-cloudberry.yml` workflow * For `build-deb-cloudberry.yml`, the installation and configure prefix are not consisent, which results in the test error. Will add ic-diskquota test back once updating the deb workflow. See: https://lists.apache.org/thread/1zd80r1hvpwwh5fjd5yqgcc7sr4f27qr
1 parent 598c885 commit 2f048ec

159 files changed

Lines changed: 831 additions & 7515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-cloudberry.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ jobs:
314314
"gpcontrib/gp_toolkit:installcheck",
315315
"gpcontrib/gp_exttable_fdw:installcheck"]
316316
},
317+
{"test":"ic-diskquota",
318+
"make_configs":["gpcontrib/diskquota:installcheck"],
319+
"shared_preload_libraries":"diskquota-2.3"
320+
},
317321
{"test":"ic-fixme",
318322
"make_configs":["src/test/regress:installcheck-fixme"],
319323
"enable_core_check":false
@@ -1379,7 +1383,15 @@ jobs:
13791383
13801384
{
13811385
chmod +x "${SRC_DIR}"/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh
1382-
if ! time su - gpadmin -c "cd ${SRC_DIR} && NUM_PRIMARY_MIRROR_PAIRS='${{ matrix.num_primary_mirror_pairs }}' SRC_DIR=${SRC_DIR} ${SRC_DIR}/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh"; then
1386+
1387+
# Build BLDWRAP_POSTGRES_CONF_ADDONS for shared_preload_libraries if specified
1388+
EXTRA_CONF=""
1389+
if [[ -n "${{ matrix.shared_preload_libraries }}" ]]; then
1390+
EXTRA_CONF="shared_preload_libraries='${{ matrix.shared_preload_libraries }}'"
1391+
echo "Adding shared_preload_libraries: ${{ matrix.shared_preload_libraries }}"
1392+
fi
1393+
1394+
if ! time su - gpadmin -c "cd ${SRC_DIR} && NUM_PRIMARY_MIRROR_PAIRS='${{ matrix.num_primary_mirror_pairs }}' BLDWRAP_POSTGRES_CONF_ADDONS=\"${EXTRA_CONF}\" SRC_DIR=${SRC_DIR} ${SRC_DIR}/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh"; then
13831395
echo "::error::Demo cluster creation failed"
13841396
exit 1
13851397
fi

.github/workflows/build-deb-cloudberry.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,15 @@ jobs:
13221322
13231323
{
13241324
chmod +x "${SRC_DIR}"/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh
1325-
if ! time su - gpadmin -c "cd ${SRC_DIR} && NUM_PRIMARY_MIRROR_PAIRS='${{ matrix.num_primary_mirror_pairs }}' SRC_DIR=${SRC_DIR} ${SRC_DIR}/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh"; then
1325+
1326+
# Build BLDWRAP_POSTGRES_CONF_ADDONS for shared_preload_libraries if specified
1327+
EXTRA_CONF=""
1328+
if [[ -n "${{ matrix.shared_preload_libraries }}" ]]; then
1329+
EXTRA_CONF="shared_preload_libraries='${{ matrix.shared_preload_libraries }}'"
1330+
echo "Adding shared_preload_libraries: ${{ matrix.shared_preload_libraries }}"
1331+
fi
1332+
1333+
if ! time su - gpadmin -c "cd ${SRC_DIR} && NUM_PRIMARY_MIRROR_PAIRS='${{ matrix.num_primary_mirror_pairs }}' BLDWRAP_POSTGRES_CONF_ADDONS=\"${EXTRA_CONF}\" SRC_DIR=${SRC_DIR} ${SRC_DIR}/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh"; then
13261334
echo "::error::Demo cluster creation failed"
13271335
exit 1
13281336
fi

gpcontrib/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ ifeq "$(enable_debug_extensions)" "yes"
2222
gp_legacy_string_agg \
2323
gp_replica_check \
2424
gp_toolkit \
25-
pg_hint_plan
25+
pg_hint_plan \
26+
diskquota
2627
else
2728
recurse_targets = gp_sparse_vector \
2829
gp_distribution_policy \
2930
gp_internal_tools \
3031
gp_legacy_string_agg \
3132
gp_exttable_fdw \
3233
gp_toolkit \
33-
pg_hint_plan
34+
pg_hint_plan \
35+
diskquota
3436
endif
3537

3638
ifeq "$(with_zstd)" "yes"
@@ -97,3 +99,4 @@ installcheck:
9799
$(MAKE) -C gp_sparse_vector installcheck
98100
$(MAKE) -C gp_toolkit installcheck
99101
$(MAKE) -C gp_exttable_fdw installcheck
102+
$(MAKE) -C diskquota installcheck

gpcontrib/diskquota/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Gpdb.cmake)
2222
# set include directories for all sub-projects
2323
include_directories(${PG_INCLUDE_DIR_SERVER})
2424
include_directories(${PG_INCLUDE_DIR}) # for libpq
25+
# For in-tree builds, libpq headers are in a separate directory
26+
if(PG_INCLUDE_DIR_LIBPQ)
27+
include_directories(${PG_INCLUDE_DIR_LIBPQ})
28+
endif()
2529
# Overwrite the default build type flags set by cmake.
2630
# We don't want the '-O3 -DNDEBUG' from cmake. Instead, those will be set by the CFLAGS from pg_config.
2731
# And, the good news is, GPDB release always have '-g'.
@@ -85,9 +89,7 @@ set_target_properties(
8589
C_STANDARD 99
8690
LINKER_LANGUAGE "C")
8791

88-
if (${GP_MAJOR_VERSION} STRGREATER_EQUAL "7")
89-
TARGET_LINK_LIBRARIES(diskquota ${PG_LIB_DIR}/libpq.so)
90-
endif()
92+
TARGET_LINK_LIBRARIES(diskquota ${PG_LIB_DIR}/libpq.so)
9193

9294
# packing part, move to a separate file if this part is too large
9395
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Distro.cmake)

gpcontrib/diskquota/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# Makefile for diskquota extension
19+
#
20+
# This Makefile wraps the CMake build system for integration with
21+
# the Cloudberry build process.
22+
#
23+
# Usage:
24+
# make # build the extension
25+
# make install # install the extension
26+
# make installcheck # run regression tests
27+
# make clean # clean build artifacts
28+
29+
ifdef USE_PGXS
30+
# Standalone build: pg_config must be in PATH
31+
PG_CONFIG_ABS := $(shell which pg_config)
32+
PG_PREFIX := $(shell $(PG_CONFIG_ABS) --prefix)
33+
CMAKE_OPTS := -DPG_CONFIG=$(PG_CONFIG_ABS)
34+
else
35+
# In-tree build
36+
subdir = gpcontrib/diskquota
37+
top_builddir = ../..
38+
include $(top_builddir)/src/Makefile.global
39+
# Get absolute source directory path
40+
PG_SRC_DIR_ABS := $(shell cd $(top_builddir) && pwd)
41+
PG_CONFIG_ABS := $(PG_SRC_DIR_ABS)/src/bin/pg_config/pg_config
42+
PG_PREFIX := $(prefix)
43+
# Pass PG_SRC_DIR to CMake so it doesn't try to derive it from pg_config
44+
CMAKE_OPTS := -DPG_CONFIG=$(PG_CONFIG_ABS) -DPG_SRC_DIR=$(PG_SRC_DIR_ABS)
45+
endif
46+
47+
.PHONY: all
48+
all: build
49+
50+
.PHONY: build
51+
build:
52+
@echo "Building diskquota with CMake..."
53+
@if [ ! -f build/Makefile ]; then \
54+
mkdir -p build && \
55+
cd build && \
56+
cmake $(CMAKE_OPTS) -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(PG_PREFIX) .. ; \
57+
fi
58+
cd build && $(MAKE)
59+
60+
.PHONY: install
61+
install: build
62+
cd build && $(MAKE) install
63+
64+
.PHONY: installcheck
65+
installcheck:
66+
@echo "Running diskquota regression tests..."
67+
@if [ ! -f build/Makefile ]; then \
68+
mkdir -p build && \
69+
cd build && \
70+
cmake $(CMAKE_OPTS) -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(PG_PREFIX) .. ; \
71+
fi
72+
cd build && $(MAKE) installcheck
73+
74+
.PHONY: clean
75+
clean:
76+
rm -rf build

0 commit comments

Comments
 (0)