Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/build-cloudberry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ jobs:
"gpcontrib/gp_sparse_vector:installcheck",
"gpcontrib/gp_toolkit:installcheck"]
},
{"test":"ic-diskquota",
"make_configs":["gpcontrib/diskquota:installcheck"],
"shared_preload_libraries":"diskquota-2.3"
},
{"test":"ic-fixme",
"make_configs":["src/test/regress:installcheck-fixme"],
"enable_core_check":false
Expand Down Expand Up @@ -1265,7 +1269,15 @@ jobs:

{
chmod +x "${SRC_DIR}"/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh
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

# Build BLDWRAP_POSTGRES_CONF_ADDONS for shared_preload_libraries if specified
EXTRA_CONF=""
if [[ -n "${{ matrix.shared_preload_libraries }}" ]]; then
EXTRA_CONF="shared_preload_libraries='${{ matrix.shared_preload_libraries }}'"
echo "Adding shared_preload_libraries: ${{ matrix.shared_preload_libraries }}"
fi

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
echo "::error::Demo cluster creation failed"
exit 1
fi
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/build-deb-cloudberry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,15 @@ jobs:

{
chmod +x "${SRC_DIR}"/devops/build/automation/cloudberry/scripts/create-cloudberry-demo-cluster.sh
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

# Build BLDWRAP_POSTGRES_CONF_ADDONS for shared_preload_libraries if specified
EXTRA_CONF=""
if [[ -n "${{ matrix.shared_preload_libraries }}" ]]; then
EXTRA_CONF="shared_preload_libraries='${{ matrix.shared_preload_libraries }}'"
echo "Adding shared_preload_libraries: ${{ matrix.shared_preload_libraries }}"
fi

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
echo "::error::Demo cluster creation failed"
exit 1
fi
Expand Down
8 changes: 7 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,18 @@ The Greenplum Database software includes:
gpcontrib/orafce/*
see licenses/LICENSE-orafce.txt

----------------------------
----------------------------
BSD 3 Clause License

gpcontrib/gpcloud/test/googletest
see licenses/LICENSE-googletest.txt

----------------------------
PostgreSQL License

gpcontrib/diskquota/*
see licenses/LICENSE-diskquota.txt

================================================================================
Apache Cloudberry includes codes from

Expand Down
7 changes: 5 additions & 2 deletions gpcontrib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ ifeq "$(enable_debug_extensions)" "yes"
gp_legacy_string_agg \
gp_replica_check \
gp_toolkit \
pg_hint_plan
pg_hint_plan \
diskquota
else
recurse_targets = gp_sparse_vector \
gp_distribution_policy \
gp_internal_tools \
gp_legacy_string_agg \
gp_exttable_fdw \
gp_toolkit \
pg_hint_plan
pg_hint_plan \
diskquota
endif

ifeq "$(with_zstd)" "yes"
Expand Down Expand Up @@ -97,3 +99,4 @@ installcheck:
$(MAKE) -C gp_sparse_vector installcheck
$(MAKE) -C gp_toolkit installcheck
$(MAKE) -C gp_exttable_fdw installcheck
$(MAKE) -C diskquota installcheck
13 changes: 13 additions & 0 deletions gpcontrib/diskquota/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build directory
build*/

# The tests results
results/

# For IDE/Editors
.vscode
.idea
tags
cscope*
.ccls-cache/
compile_commands.json
178 changes: 178 additions & 0 deletions gpcontrib/diskquota/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
cmake_minimum_required(VERSION 3.20)
# cmake_path requires 3.20

project(diskquota)

if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Choose the type of build." FORCE)
endif()

# generate 'compile_commands.json'
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Retrieve repository information
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Git.cmake)
GitHash_Get(DISKQUOTA_GIT_HASH)

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Gpdb.cmake)


# set include directories for all sub-projects
include_directories(${PG_INCLUDE_DIR_SERVER})
include_directories(${PG_INCLUDE_DIR}) # for libpq
# For in-tree builds, libpq headers are in a separate directory
if(PG_INCLUDE_DIR_LIBPQ)
include_directories(${PG_INCLUDE_DIR_LIBPQ})
endif()
# Overwrite the default build type flags set by cmake.
# We don't want the '-O3 -DNDEBUG' from cmake. Instead, those will be set by the CFLAGS from pg_config.
# And, the good news is, GPDB release always have '-g'.
set(CMAKE_C_FLAGS_RELEASE "" CACHE
STRING "Flags for RELEASE build" FORCE)
set(CMAKE_C_FLAGS_DEBUG "-DDISKQUOTA_DEBUG"
CACHE STRING "Flags for DEBUG build" FORCE)
# set link flags for all sub-projects
set(CMAKE_MODULE_LINKER_FLAGS "${PG_LD_FLAGS}")
if (APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -bundle_loader ${PG_BIN_DIR}/postgres")
endif()
# set c and ld flags for all projects
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PG_C_FLAGS}")

# generate version
if(NOT DEFINED DISKQUOTA_VERSION)
file(STRINGS VERSION DISKQUOTA_VERSION)
endif()

string(REGEX REPLACE "^([0-9]+).[0-9]+.[0-9]+$" "\\1" DISKQUOTA_MAJOR_VERSION
${DISKQUOTA_VERSION})
string(REGEX REPLACE "^[0-9]+.([0-9]+).[0-9]+$" "\\1" DISKQUOTA_MINOR_VERSION
${DISKQUOTA_VERSION})
string(REGEX REPLACE "^[0-9]+.[0-9]+.([0-9]+)$" "\\1" DISKQUOTA_PATCH_VERSION
${DISKQUOTA_VERSION})

if("${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION}" STREQUAL "1.0")
# in special, version 1.0.x do not has suffix
set(DISKQUOTA_BINARY_NAME "diskquota")
else()
set(DISKQUOTA_BINARY_NAME
"diskquota-${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION}")
endif()

add_compile_definitions(
DISKQUOTA_VERSION="${DISKQUOTA_VERSION}"
DISKQUOTA_MAJOR_VERSION=${DISKQUOTA_MAJOR_VERSION}
DISKQUOTA_MINOR_VERSION=${DISKQUOTA_MINOR_VERSION}
DISKQUOTA_PATCH_VERSION=${DISKQUOTA_PATCH_VERSION}
DISKQUOTA_BINARY_NAME="${DISKQUOTA_BINARY_NAME}")

set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
file(GLOB diskquota_SRC "${SRC_DIR}/*.c")

set(DISKQUOTA_DDL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/control/ddl")
file(GLOB diskquota_DDL "${DISKQUOTA_DDL_DIR}/*")

add_library(diskquota MODULE ${diskquota_SRC})

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"${PG_HOME}"
CACHE PATH "default install prefix" FORCE)
endif()

set_target_properties(
diskquota
PROPERTIES OUTPUT_NAME ${DISKQUOTA_BINARY_NAME}
PREFIX ""
C_STANDARD 99
LINKER_LANGUAGE "C")

TARGET_LINK_LIBRARIES(diskquota ${PG_LIB_DIR}/libpq.so)

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

if(DEFINED DISKQUOTA_LAST_RELEASE_PATH)
message(STATUS "Copy pervious installer from ${DISKQUOTA_LAST_RELEASE_PATH}")
file(ARCHIVE_EXTRACT INPUT ${DISKQUOTA_LAST_RELEASE_PATH} PATTERNS "*.so")
file(GLOB so_files_list
"${CMAKE_BINARY_DIR}/lib/postgresql/*.so")

foreach(so_path IN LISTS so_files_list)
get_filename_component(so_name ${so_path} NAME_WLE)
# Replace 'diskquota-x.y' with 'x.y'. 'diskquota' won't be replaced, which belongs to 1.x release.
string(REPLACE "diskquota-" "" so_ver ${so_name})
# Install the previous so files. Those so files have versions less than current version.
# diskqutoa.so doesn't have version string in the file name. It belongs to 1.x release.
if((${so_ver} STREQUAL "diskquota") OR
${so_ver} VERSION_LESS ${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION})
list(APPEND DISKQUOTA_PREVIOUS_LIBRARY ${so_path})
endif()
endforeach()

install(PROGRAMS ${DISKQUOTA_PREVIOUS_LIBRARY} DESTINATION "lib/postgresql/")

get_filename_component(
DISKQUOTA_LAST_RELEASE_FILENAME ${DISKQUOTA_LAST_RELEASE_PATH} NAME CACHE
"last release installer name")
string(
REGEX
REPLACE "^diskquota-([0-9]+).[0-9]+.[0-9]+-.*$" "\\1"
DISKQUOTA_LAST_MAJOR_VERSION ${DISKQUOTA_LAST_RELEASE_FILENAME})
string(
REGEX
REPLACE "^diskquota-[0-9]+.([0-9]+).[0-9]+-.*$" "\\1"
DISKQUOTA_LAST_MINOR_VERSION ${DISKQUOTA_LAST_RELEASE_FILENAME})
string(
REGEX
REPLACE "^diskquota-[0-9]+.[0-9]+.([0-9]+)-.*$" "\\1"
DISKQUOTA_LAST_PATCH_VERSION ${DISKQUOTA_LAST_RELEASE_FILENAME})

set(DISKQUOTA_LAST_VERSION
"${DISKQUOTA_LAST_MAJOR_VERSION}.${DISKQUOTA_LAST_MINOR_VERSION}.${DISKQUOTA_LAST_PATCH_VERSION}"
)
endif()

set(tgz_NAME
"diskquota-${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION}.${DISKQUOTA_PATCH_VERSION}-${DISTRO_NAME}_x86_64"
)
set(CPACK_GENERATOR "TGZ")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_PACKAGE_FILE_NAME ${tgz_NAME})
include(CPack)
# create_artifact target is used to tar the package with version into a version-less tarball to be
# used on concourse gcs resource. It will be uploaded to a gcs version file (no diskquota version
# string in the file name), and be retrieved in the release step. Then we don't have to firgure out
# a way to add the version string back to the release file name, just untar it.
set(artifact_NAME "diskquota.tar.gz")
add_custom_target(create_artifact
COMMAND
${CMAKE_COMMAND} --build . --target package
COMMAND
${CMAKE_COMMAND} -E tar czvf ${artifact_NAME} "${tgz_NAME}.tar.gz")
# packing end

# Create build-info
# The diskquota-build-info shouldn't be copied to GPDB release by install_gpdb_component
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/BuildInfo.cmake)
set(build_info_PATH ${CMAKE_CURRENT_BINARY_DIR}/diskquota-build-info)
BuildInfo_Create(${build_info_PATH}
VARS
DISKQUOTA_GIT_HASH
DISKQUOTA_VERSION
GP_MAJOR_VERSION
GP_VERSION
CMAKE_BUILD_TYPE)
# Create build-info end

# Add installcheck targets
add_subdirectory(tests)
add_subdirectory(upgrade_test)

# NOTE: keep install part at the end of file, to overwrite previous binary
install(PROGRAMS "cmake/install_gpdb_component" DESTINATION ".")
install(FILES ${diskquota_DDL} DESTINATION "share/postgresql/extension/")
install(TARGETS diskquota DESTINATION "lib/postgresql/")
install(FILES ${build_info_PATH} DESTINATION ".")
31 changes: 31 additions & 0 deletions gpcontrib/diskquota/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Copyright (c) 2004-2020 Pivotal Software, Inc.
Copyright (c) 2020-Present VMware, Inc. or its affiliates

diskquota is licensed under the PostgreSQL license, the same license
as PostgreSQL. It contains parts of PostgreSQL source code. A copy of
the license is below:

--------------
PostgreSQL Database Management System
(formerly known as Postgres, then as Postgres95)

Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group

Portions Copyright (c) 1994, The Regents of the University of California

Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this
paragraph and the following two paragraphs appear in all copies.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
76 changes: 76 additions & 0 deletions gpcontrib/diskquota/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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.
#
# Makefile for diskquota extension
#
# This Makefile wraps the CMake build system for integration with
# the Cloudberry build process.
#
# Usage:
# make # build the extension
# make install # install the extension
# make installcheck # run regression tests
# make clean # clean build artifacts

ifdef USE_PGXS
# Standalone build: pg_config must be in PATH
PG_CONFIG_ABS := $(shell which pg_config)
PG_PREFIX := $(shell $(PG_CONFIG_ABS) --prefix)
CMAKE_OPTS := -DPG_CONFIG=$(PG_CONFIG_ABS)
else
# In-tree build
subdir = gpcontrib/diskquota
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
# Get absolute source directory path
PG_SRC_DIR_ABS := $(shell cd $(top_builddir) && pwd)
PG_CONFIG_ABS := $(PG_SRC_DIR_ABS)/src/bin/pg_config/pg_config
PG_PREFIX := $(prefix)
# Pass PG_SRC_DIR to CMake so it doesn't try to derive it from pg_config
CMAKE_OPTS := -DPG_CONFIG=$(PG_CONFIG_ABS) -DPG_SRC_DIR=$(PG_SRC_DIR_ABS)
endif

.PHONY: all
all: build

.PHONY: build
build:
@echo "Building diskquota with CMake..."
@if [ ! -f build/Makefile ]; then \
mkdir -p build && \
cd build && \
cmake $(CMAKE_OPTS) -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(PG_PREFIX) .. ; \
fi
cd build && $(MAKE)

.PHONY: install
install: build
cd build && $(MAKE) install

.PHONY: installcheck
installcheck:
@echo "Running diskquota regression tests..."
@if [ ! -f build/Makefile ]; then \
mkdir -p build && \
cd build && \
cmake $(CMAKE_OPTS) -DCMAKE_INSTALL_PREFIX=$(DESTDIR)$(PG_PREFIX) .. ; \
fi
cd build && $(MAKE) installcheck

.PHONY: clean
clean:
rm -rf build
Loading
Loading