From 108d813214b9cf7050bbbb0f8a57d625b5bdc5e6 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sun, 13 Oct 2024 17:40:33 +0200 Subject: [PATCH] Add postgresql 17 --- build/meta/extra-build-tools.p5m | 6 +- build/pg_extension/common.sh | 5 +- build/postgresql/build-17.sh | 190 ++++++++++++++++++ build/postgresql/patches-17/dism.patch | 93 +++++++++ build/postgresql/patches-17/pam-illumos.patch | 30 +++ .../postgresql/patches-17/perl_plpgsql.patch | 19 ++ build/postgresql/patches-17/series | 3 + doc/baseline | 5 + doc/packages.md | 1 + 9 files changed, 345 insertions(+), 7 deletions(-) create mode 100755 build/postgresql/build-17.sh create mode 100644 build/postgresql/patches-17/dism.patch create mode 100644 build/postgresql/patches-17/pam-illumos.patch create mode 100644 build/postgresql/patches-17/perl_plpgsql.patch create mode 100644 build/postgresql/patches-17/series diff --git a/build/meta/extra-build-tools.p5m b/build/meta/extra-build-tools.p5m index d524828f9..17a0ce35a 100644 --- a/build/meta/extra-build-tools.p5m +++ b/build/meta/extra-build-tools.p5m @@ -67,6 +67,8 @@ depend fmri=ooce/library/postgresql-12 type=require depend fmri=ooce/library/postgresql-13 type=require depend fmri=ooce/library/postgresql-14 type=require depend fmri=ooce/library/postgresql-15 type=require +depend fmri=ooce/library/postgresql-16 type=require +depend fmri=ooce/library/postgresql-17 type=require depend fmri=ooce/library/security/libsasl2 type=require depend fmri=ooce/library/serf type=require depend fmri=ooce/library/slang type=require @@ -100,10 +102,6 @@ depend fmri=ooce/x11/library/libxcb type=require depend fmri=ooce/developer/llvm-15 type=conditional \ predicate=release/name@0.5.11-151043 -# Added postgresql 16 from r151044 onwards -depend fmri=ooce/library/postgresql-16 type=conditional \ - predicate=release/name@0.5.11-151044 - # clang 15 is the default clang compiler from r151045 onwards depend fmri=ooce/developer/clang-15 type=conditional \ predicate=release/name@0.5.11-151045 diff --git a/build/pg_extension/common.sh b/build/pg_extension/common.sh index 4f78e6513..799338d85 100644 --- a/build/pg_extension/common.sh +++ b/build/pg_extension/common.sh @@ -10,10 +10,9 @@ # http://www.illumos.org/license/CDDL. # }}} -# Copyright 2023 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2024 OmniOS Community Edition (OmniOSce) Association. -PGVERSIONS="13 14 15" -test_relver '>=' 151044 && PGVERSIONS+=" 16" +PGVERSIONS="13 14 15 16 17" for v in $PGVERSIONS; do BUILD_DEPENDS_IPS+=" ooce/library/postgresql-$v" diff --git a/build/postgresql/build-17.sh b/build/postgresql/build-17.sh new file mode 100755 index 000000000..93bb8f0b4 --- /dev/null +++ b/build/postgresql/build-17.sh @@ -0,0 +1,190 @@ +#!/usr/bin/bash +# +# {{{ CDDL HEADER +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# }}} + +# Copyright 2016 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2024 OmniOS Community Edition (OmniOSce) Association. + +. ../../lib/build.sh + +PROG=postgresql +PKG=ooce/database/postgresql-17 +VER=17.0 +SUMMARY="PostgreSQL 17" +DESC="The World's Most Advanced Open Source Relational Database" + +SKIP_LICENCES=postgresql + +# The icu4c ABI changes frequently. Lock the version +# pulled into each build of postgres. +ICUVER=`pkg_ver icu4c` +ICUVER=${ICUVER%%.*} +BUILD_DEPENDS_IPS="=ooce/library/icu4c@$ICUVER" + +# We want to populate the clang-related environment variables +# and set PATH to point to the correct llvm/clang version for +# the postgres JIT code, but we want to build with gcc. +set_clangver +BASEPATH=$PATH set_gccver $DEFAULT_GCC_VER + +MAJVER=${VER%.*} # M.m +sMAJVER=${MAJVER//./} # Mm +set_patchdir patches-$sMAJVER + +OPREFIX=$PREFIX +PREFIX+=/pgsql-$MAJVER +CONFPATH=/etc$PREFIX +LOGPATH=/var/log$PREFIX +VARPATH=/var$PREFIX +RUNPATH=$VARPATH/run + +reset_configure_opts + +SKIP_RTIME_CHECK=1 +SKIP_SSP_CHECK=1 +NO_SONAME_EXPECTED=1 + +XFORM_ARGS=" + -DPREFIX=${PREFIX#/} + -DOPREFIX=${OPREFIX#/} + -DPROG=$PROG + -DPKGROOT=pgsql-$MAJVER + -DMEDIATOR=$PROG -DMEDIATOR_VERSION=$MAJVER + -DVERSION=$MAJVER + -DsVERSION=$sMAJVER +" + +CFLAGS+=" -O3" +CPPFLAGS+=" -DWAIT_USE_POLL -DOOCEVER=$RELVER" +# postgresql has large enumerations +CTF_FLAGS+=" -s" + +CONFIGURE_OPTS=" + --prefix=$PREFIX + --sysconfdir=$CONFPATH + --localstatedir=$VARPATH + --enable-thread-safety + --with-pam + --with-ssl=openssl + --with-lz4 + --with-zstd + --with-libxml + --with-libxslt + --with-readline + --without-systemd + --with-system-tzdata=/usr/share/lib/zoneinfo +" + +CONFIGURE_OPTS[amd64_WS]+=" + --bindir=$PREFIX/bin + --with-llvm LLVM_CONFIG=\"$CLANGPATH/bin/llvm-config --link-static\" + --enable-dtrace DTRACEFLAGS=-64 +" +CONFIGURE_OPTS[aarch64]+=" + --disable-dtrace +" + +# need to build world +MAKE_TARGET=world-bin +MAKE_INSTALL_TARGET=install-world-bin + +pre_configure() { + typeset arch=$1 + + LDFLAGS[$arch]+=" -Wl,-R$OPREFIX/${LIBDIRS[$arch]}" +} + +install_man() { + logmsg "Fetching and installing pre-built man pages" + + download_source $PROG $PROG $VER-docs $TMPDIR/manpages + + for s in 1 3 5; do + logcmd $MKDIR -p "$DESTDIR/$PREFIX/share/man/man$s" \ + || logerr "mkdir failed" + done + + pushd $TMPDIR/manpages/$PROG-$VER/doc/src/sgml >/dev/null + + logmsg "Renaming man section" + + for s in 1 3; do + for f in man$s/*.$s; do $SED -e '/^\.TH/s/"7"/"5"/' \ + -e 's/\\fR(7)/\\fR(5sql)/g' \ + -e '1s/^\.so man7/.so man5/g;1s/^\(\.so.*\)\.7$/\1.5sql/g' \ + $f >| $DESTDIR/$PREFIX/share/man/man$s/`basename $f` \ + || logerr "failed to rename man section for $f" + done + done + for f in man7/*.7; do $SED -e '/^\.TH/s/"7"/"5"/' \ + -e 's/\\fR(7)/\\fR(5sql)/g' \ + -e '1s/^\.so man7/.so man5/g;1s/^\(\.so.*\)\.7$/\1.5sql/g' \ + $f >| $DESTDIR/$PREFIX/share/man/man5/`basename $f \ + | $SED s/\.7$/.5sql/` || logerr "failed to rename man section for $f" + done + + popd >/dev/null +} + +post_install() { + typeset arch=$1 + + [ $arch = i386 ] && return + + # Make ISA binaries for pg_config, to allow software to find the + # right settings for 32/64-bit when pkg-config is not used. + if [ $arch = amd64 ]; then + pushd $DESTDIR$PREFIX/bin >/dev/null + logcmd mkdir -p amd64 + logcmd mv pg_config amd64/ || logerr "mv pg_config" + make_isaexec_stub_arch amd64 $PREFIX/bin + popd >/dev/null + fi + + install_man + + xform $SRCDIR/files/postgres.xml > $TMPDIR/$PROG-$sMAJVER.xml + install_smf ooce $PROG-$sMAJVER.xml + + manifest_start $TMPDIR/manifest.client + manifest_add_dir $PREFIX/include '.*' + manifest_add_dir $PREFIX/lib/pkgconfig + manifest_add_dir $PREFIX/lib/amd64/pkgconfig + manifest_add_dir $PREFIX/lib/pgxs '.*' + manifest_add_dir $PREFIX/lib/amd64/pgxs '.*' + manifest_add $PREFIX/lib '.*lib(pq\.|ecpg|pgtypes|pgcommon|pgport).*' + manifest_add $PREFIX/bin '.*pg_config' psql ecpg + manifest_add $PREFIX/share/man/man1 pg_config.1 psql.1 ecpg.1 + manifest_add $PREFIX/share psqlrc.sample + manifest_finalise $TMPDIR/manifest.client $OPREFIX + + manifest_uniq $TMPDIR/manifest.{server,client} + manifest_finalise $TMPDIR/manifest.server $OPREFIX etc +} + +init +download_source $PROG $PROG $VER +patch_source +prep_build +build +#run_testsuite check-world-bin +PKG=${PKG/database/library} SUMMARY+=" client and libraries" \ + make_package -seed $TMPDIR/manifest.client +[ "$FLAVOR" != libsandheaders ] \ + && RUN_DEPENDS_IPS="ooce/database/postgresql-common \ + =ooce/library/icu4c@$ICUVER" \ + make_package -seed $TMPDIR/manifest.server server.mog +clean_up + +# Vim hints +# vim:ts=4:sw=4:et:fdm=marker diff --git a/build/postgresql/patches-17/dism.patch b/build/postgresql/patches-17/dism.patch new file mode 100644 index 000000000..9e7eefaa4 --- /dev/null +++ b/build/postgresql/patches-17/dism.patch @@ -0,0 +1,93 @@ +On Solaris we want to use DISM or ISM e.g. Dynamic Intimate Shared Memory or Intimate Shared Memory +which is available via sysv SHM only. This patch changes the default shared memory system to be sysv +on Solaris based systems e.g. which have SHM_SHARE_MMU (which translates to ISM) and when SHM_PAGEABLE +is defined in sys/shm.h we set the default PG_SHMAT_FLAGS to SHM_PAGEABLE which will lead to DISM being +used. The patch to the postgresql.conf.sample is to show that sysv is the default for Solaris and the +ordering is changed as by default it used to be mmap and posix for the defaults and you could always +override things using the sysv setting. +-- +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/backend/utils/misc/postgresql.conf.sample a/src/backend/utils/misc/postgresql.conf.sample +--- a~/src/backend/utils/misc/postgresql.conf.sample 1970-01-01 00:00:00 ++++ a/src/backend/utils/misc/postgresql.conf.sample 1970-01-01 00:00:00 +@@ -143,16 +143,15 @@ + #autovacuum_work_mem = -1 # min 64kB, or -1 to use maintenance_work_mem + #logical_decoding_work_mem = 64MB # min 64kB + #max_stack_depth = 2MB # min 100kB +-#shared_memory_type = mmap # the default is the first option ++#shared_memory_type = sysv # the default is the first option + # supported by the operating system: +- # mmap + # sysv + # windows + # (change requires restart) +-#dynamic_shared_memory_type = posix # the default is usually the first option ++#dynamic_shared_memory_type = sysv # the default is usually the first option + # supported by the operating system: +- # posix + # sysv ++ # posix + # windows + # mmap + # (change requires restart) +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/include/portability/mem.h a/src/include/portability/mem.h +--- a~/src/include/portability/mem.h 1970-01-01 00:00:00 ++++ a/src/include/portability/mem.h 1970-01-01 00:00:00 +@@ -14,11 +14,15 @@ + + #define IPCProtection (0600) /* access/modify by user only */ + ++#ifdef SHM_PAGEABLE /* use dynamic intimate shared memory on Solaris */ ++#define PG_SHMAT_FLAGS SHM_PAGEABLE ++#else + #ifdef SHM_SHARE_MMU /* use intimate shared memory on Solaris */ + #define PG_SHMAT_FLAGS SHM_SHARE_MMU + #else + #define PG_SHMAT_FLAGS 0 + #endif ++#endif + + /* Linux prefers MAP_ANONYMOUS, but the flag is called MAP_ANON on other systems. */ + #ifndef MAP_ANONYMOUS +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/include/storage/dsm_impl.h a/src/include/storage/dsm_impl.h +--- a~/src/include/storage/dsm_impl.h 1970-01-01 00:00:00 ++++ a/src/include/storage/dsm_impl.h 1970-01-01 00:00:00 +@@ -19,6 +19,13 @@ + #define DSM_IMPL_WINDOWS 3 + #define DSM_IMPL_MMAP 4 + ++#ifdef HAVE_SYS_SHM_H ++/* ++ * For SHM_SHARE_MMU. ++ */ ++#include ++#endif ++ + /* + * Determine which dynamic shared memory implementations will be supported + * on this platform, and which one will be the default. +@@ -34,6 +41,11 @@ + #define USE_DSM_SYSV + #ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE + #define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV ++#else ++#ifdef SHM_SHARE_MMU ++#undef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE ++#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV ++#endif + #endif + #define USE_DSM_MMAP + #endif +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/include/storage/pg_shmem.h a/src/include/storage/pg_shmem.h +--- a~/src/include/storage/pg_shmem.h 1970-01-01 00:00:00 ++++ a/src/include/storage/pg_shmem.h 1970-01-01 00:00:00 +@@ -71,7 +71,9 @@ extern PGDLLIMPORT void *ShmemProtective + #endif + extern PGDLLIMPORT void *UsedShmemSegAddr; + +-#if !defined(WIN32) && !defined(EXEC_BACKEND) ++#if defined(SHM_SHARE_MMU) ++#define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_SYSV ++#elif !defined(WIN32) && !defined(EXEC_BACKEND) + #define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_MMAP + #elif !defined(WIN32) + #define DEFAULT_SHARED_MEMORY_TYPE SHMEM_TYPE_SYSV diff --git a/build/postgresql/patches-17/pam-illumos.patch b/build/postgresql/patches-17/pam-illumos.patch new file mode 100644 index 000000000..e6dda63ea --- /dev/null +++ b/build/postgresql/patches-17/pam-illumos.patch @@ -0,0 +1,30 @@ +see: https://www.illumos.org/issues/15657 +struct pam_message in struct pam_conv is not const in illumos before r151051 + +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/backend/libpq/auth.c a/src/backend/libpq/auth.c +--- a~/src/backend/libpq/auth.c 1970-01-01 00:00:00 ++++ a/src/backend/libpq/auth.c 1970-01-01 00:00:00 +@@ -96,7 +96,11 @@ static int auth_peer(hbaPort *port); + #define PGSQL_PAM_SERVICE "postgresql" /* Service name passed to PAM */ + + static int CheckPAMAuth(Port *port, const char *user, const char *password); ++#if OOCEVER >= 151051 + static int pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, ++#else ++static int pam_passwd_conv_proc(int num_msg, struct pam_message **msg, ++#endif + struct pam_response **resp, void *appdata_ptr); + + static struct pam_conv pam_passw_conv = { +@@ -1910,7 +1914,11 @@ auth_peer(hbaPort *port) + */ + + static int ++#if OOCEVER >= 151051 + pam_passwd_conv_proc(int num_msg, const struct pam_message **msg, ++#else ++pam_passwd_conv_proc(int num_msg, struct pam_message **msg, ++#endif + struct pam_response **resp, void *appdata_ptr) + { + const char *passwd; diff --git a/build/postgresql/patches-17/perl_plpgsql.patch b/build/postgresql/patches-17/perl_plpgsql.patch new file mode 100644 index 000000000..12c76f58d --- /dev/null +++ b/build/postgresql/patches-17/perl_plpgsql.patch @@ -0,0 +1,19 @@ +diff -wpruN --no-dereference '--exclude=*.orig' a~/src/pl/plpgsql/src/pl_exec.c a/src/pl/plpgsql/src/pl_exec.c +--- a~/src/pl/plpgsql/src/pl_exec.c 1970-01-01 00:00:00 ++++ a/src/pl/plpgsql/src/pl_exec.c 1970-01-01 00:00:00 +@@ -8381,6 +8381,15 @@ exec_set_found(PLpgSQL_execstate *estate + PLpgSQL_var *var; + + var = (PLpgSQL_var *) (estate->datums[estate->found_varno]); ++ ++ /* ++ * Prevent spurious warning due to compiler not realizing ++ * VARATT_IS_EXTERNAL_NON_EXPANDED() branch in assign_simple_var() isn't ++ * reachable due to "found" being byvalue. ++ */ ++ if (var->datatype->typlen != 1) ++ pg_unreachable(); ++ + assign_simple_var(estate, var, BoolGetDatum(state), false, false); + } + diff --git a/build/postgresql/patches-17/series b/build/postgresql/patches-17/series new file mode 100644 index 000000000..f6696c45f --- /dev/null +++ b/build/postgresql/patches-17/series @@ -0,0 +1,3 @@ +dism.patch +pam-illumos.patch +perl_plpgsql.patch diff --git a/doc/baseline b/doc/baseline index a5b51975c..46074e4e4 100644 --- a/doc/baseline +++ b/doc/baseline @@ -61,6 +61,10 @@ extra.omnios ooce/database/postgresql-16 extra.omnios ooce/database/postgresql-16/citus extra.omnios ooce/database/postgresql-16/mysql_fdw extra.omnios ooce/database/postgresql-16/pg_repack +extra.omnios ooce/database/postgresql-17 +extra.omnios ooce/database/postgresql-17/citus +extra.omnios ooce/database/postgresql-17/mysql_fdw +extra.omnios ooce/database/postgresql-17/pg_repack extra.omnios ooce/database/postgresql-common extra.omnios ooce/database/rrdtool extra.omnios ooce/developer/aarch64-gcc10 @@ -176,6 +180,7 @@ extra.omnios ooce/library/postgresql-13 extra.omnios ooce/library/postgresql-14 extra.omnios ooce/library/postgresql-15 extra.omnios ooce/library/postgresql-16 +extra.omnios ooce/library/postgresql-17 extra.omnios ooce/library/security/libsasl2 extra.omnios ooce/library/serf extra.omnios ooce/library/slang diff --git a/doc/packages.md b/doc/packages.md index e4e9050a7..634fc6e62 100644 --- a/doc/packages.md +++ b/doc/packages.md @@ -43,6 +43,7 @@ | ooce/database/postgresql-14 | 14.13 | https://www.postgresql.org/ftp/source/ | [omniosorg](https://github.com/omniosorg) | ooce/database/postgresql-15 | 15.8 | https://www.postgresql.org/ftp/source/ | [omniosorg](https://github.com/omniosorg) | ooce/database/postgresql-16 | 16.4 | https://www.postgresql.org/ftp/source/ | [omniosorg](https://github.com/omniosorg) +| ooce/database/postgresql-17 | 17.0 | https://www.postgresql.org/ftp/source/ | [omniosorg](https://github.com/omniosorg) | ooce/database/postgresql-XX/citus | 12.1.0 | https://github.com/citusdata/citus/releases | [omniosorg](https://github.com/omniosorg) | ooce/database/postgresql-XX/mysql_fdw | 2.9.1 | https://github.com/EnterpriseDB/mysql_fdw/releases | [omniosorg](https://github.com/omniosorg) | ooce/database/postgresql-XX/pg_repack | 1.5.0 | https://github.com/reorg/pg_repack/tags | [omniosorg](https://github.com/omniosorg)