Skip to content

Commit

Permalink
Postgresql 14 (#644)
Browse files Browse the repository at this point in the history
- removed PostgreSQL v9.5
- removed a couple of extensions installed from pgxn (they fail to compile on 11+ anyway)
  • Loading branch information
CyberDem0n authored Oct 4, 2021
1 parent e3ce570 commit f2b1876
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 66 deletions.
2 changes: 1 addition & 1 deletion delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline:
env: &ENV
BASE_IMAGE: registry.opensource.zalan.do/library/ubuntu-18.04
IMAGE: registry-write.opensource.zalan.do/acid/spilo
PGVERSION: 13
PGVERSION: 14
type: script
commands:
- desc: Build spilo docker image
Expand Down
55 changes: 29 additions & 26 deletions postgres-appliance/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG BASE_IMAGE=ubuntu:18.04
ARG PGVERSION=13
ARG TIMESCALEDB="1.7.5 2.3.1 2.4.1"
ARG PGVERSION=14
ARG TIMESCALEDB="1.7.5 2.3.1 2.4.2"
ARG DEMO=false
ARG COMPRESS=false

Expand Down Expand Up @@ -66,25 +66,26 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& find /var/log -type f -exec truncate --size 0 {} \;

COPY cron_unprivileged.c dependencies/debs dependencies/src /builddeps/
COPY patches/*.patch /builddeps/

ARG PGVERSION
ARG TIMESCALEDB
ARG TIMESCALEDB_APACHE_ONLY=true
ARG DEMO
ARG COMPRESS
ARG PGOLDVERSIONS="9.5 9.6 10 11 12"
ARG PGOLDVERSIONS="9.6 10 11 12 13"
ARG WITH_PERL=false

ARG DEB_PG_SUPPORTED_VERSIONS="$PGOLDVERSIONS $PGVERSION"

# Install PostgreSQL, extensions and contribs
ENV POSTGIS_VERSION=3.1 \
POSTGIS_LEGACY=3.0 \
POSTGIS_LEGACY=3.1 \
BG_MON_COMMIT=1f3461dda893c14778c02b5968d4c83a5d4d8e7d \
PG_AUTH_MON_COMMIT=437435b4e2de32a820e86973f6934ec849a768e0 \
PG_MON_COMMIT=54fbdcc3cfe7e2a626bd96dda644d9a0c6866b58 \
DECODERBUFS=v.1.3.1.Final \
SET_USER=REL2_0_1 \
SET_USER=REL3_0_0 \
PLPROFILER=REL4_1 \
PAM_OAUTH2=v1.0.1 \
PLANTUNER_COMMIT=800d81bc85da64ff3ef66e12aed1d4e1e54fc006 \
Expand All @@ -103,7 +104,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& rm -f *.deb \
&& apt-get install -y $BUILD_PACKAGES; \
else \
BUILD_PACKAGES="$BUILD_PACKAGES pgxnclient zlib1g-dev libprotobuf-c-dev libpam0g-dev libcurl4-openssl-dev libicu-dev python libc-ares-dev pandoc pkg-config" \
BUILD_PACKAGES="$BUILD_PACKAGES zlib1g-dev libprotobuf-c-dev libpam0g-dev libcurl4-openssl-dev libicu-dev python libc-ares-dev pandoc pkg-config" \
# debezium-decoderbufs: libprotobuf-c-dev
&& apt-get install -y $BUILD_PACKAGES libprotobuf-c1 libcurl4 \
\
Expand Down Expand Up @@ -152,17 +153,20 @@ RUN export DEBIAN_FRONTEND=noninteractive \
postgresql-${version}-hypopg \
postgresql-${version}-pgaudit \
postgresql-${version}-pg-checksums \
postgresql-${version}-pgl-ddl-deploy \
postgresql-${version}-pglogical \
postgresql-${version}-pglogical-ticker \
postgresql-${version}-pldebugger \
postgresql-${version}-pllua \
postgresql-${version}-plpgsql-check \
postgresql-${version}-plproxy \
postgresql-${version}-postgis-${POSTGIS_VERSION%.*} \
postgresql-${version}-postgis-${POSTGIS_VERSION%.*}-scripts \
postgresql-${version}-repack \
postgresql-${version}-wal2json" \
&& if [ $version != "14" ]; then \
EXTRAS="$EXTRAS \
postgresql-${version}-pgl-ddl-deploy \
postgresql-${version}-pglogical \
postgresql-${version}-pglogical-ticker \
postgresql-${version}-pldebugger \
postgresql-${version}-repack"; \
fi \
&& if [ "$WITH_PERL" = "true" ]; then \
EXTRAS="$EXTRAS postgresql-plperl-${version}"; \
fi \
Expand Down Expand Up @@ -194,14 +198,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& cd .. \
\
&& if [ "$DEMO" != "true" ]; then \
if [ ${version%.*} -lt 11 ]; then \
for extension in quantile trimmed_aggregates; do \
pgxn install $extension \
&& strip /usr/lib/postgresql/$version/lib/$extension.so; \
done; \
fi \
\
&& EXTRA_EXTENSIONS="plantuner-${PLANTUNER_COMMIT} plprofiler postgres-decoderbufs" \
EXTRA_EXTENSIONS="plantuner-${PLANTUNER_COMMIT} plprofiler postgres-decoderbufs" \
&& if [ ${version%.*} -ge 10 ]; then \
EXTRA_EXTENSIONS="$EXTRA_EXTENSIONS pg_mon-${PG_MON_COMMIT}"; \
fi; \
Expand All @@ -218,7 +215,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
\
&& sed -i "s/ main.*$/ main/g" /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y postgresql postgresql-server-dev-all libpq-dev \
&& apt-get install -y postgresql postgresql-server-dev-all postgresql-all libpq-dev \
&& for version in $DEB_PG_SUPPORTED_VERSIONS; do \
apt-get install -y postgresql-server-dev-${version}; \
done \
Expand All @@ -230,21 +227,27 @@ RUN export DEBIAN_FRONTEND=noninteractive \
# create postgis symlinks to make it possible to perform update
&& ln -s postgis-${POSTGIS_VERSION%.*}.so \
/usr/lib/postgresql/${version}/lib/postgis-2.5.so; \
done; \
done \
&& PACKAGES="repack"; \
fi \
\
# build and install missing packages
&& for pkg in pgextwlist; do \
apt-get source postgresql-$PGVERSION-${pkg} \
&& for pkg in pgextwlist $PACKAGES; do \
apt-get source postgresql-13-${pkg} \
&& cd $(ls -d *${pkg%?}*-*/) \
&& if [ -f ../$pkg.patch ]; then patch -p1 < ../$pkg.patch; fi \
&& if [ "$pkg" = "pgextwlist" ]; then \
sed -i '/postgresql-all/d' debian/control.in \
# make it possible to use it from shared_preload_libraries
&& perl -ne 'print unless /PG_TRY/ .. /PG_CATCH/' pgextwlist.c > pgextwlist.c.f \
&& egrep -v '(PG_END_TRY|EmitWarningsOnPlaceholders)' pgextwlist.c.f > pgextwlist.c; \
fi \
&& pg_buildext updatecontrol \
&& DEB_BUILD_OPTIONS=nocheck debuild -b -uc -us \
&& if [ "$pkg" = "pgextwlist" ]; then \
DEB_BUILD_OPTIONS=nocheck debuild -b -uc -us; \
else \
DEB_BUILD_OPTIONS=nocheck DEB_PG_SUPPORTED_VERSIONS=$PGVERSION debuild -b -uc -us; \
fi \
&& cd .. \
&& for version in $DEB_PG_SUPPORTED_VERSIONS; do \
for deb in postgresql-${version}-${pkg}_*.deb; do \
Expand All @@ -257,7 +260,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& gcc -s -shared -fPIC -o /usr/local/lib/cron_unprivileged.so cron_unprivileged.c \
\
# Remove unnecessary packages
&& apt-get purge -y ${BUILD_PACKAGES} postgresql postgresql-server-dev-* libpq-dev=* libmagic1 bsdmainutils \
&& apt-get purge -y ${BUILD_PACKAGES} postgresql postgresql-all postgresql-server-dev-* libpq-dev=* libmagic1 bsdmainutils \
&& apt-get autoremove -y \
&& apt-get clean \
&& dpkg -l | grep '^rc' | awk '{print $2}' | xargs apt-get purge -y \
Expand Down Expand Up @@ -307,7 +310,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
&& d2="$d1" \
&& d1="../../${v1##*/}/$d1" \
&& if [ "${d2%-*}" = "contrib/postgis" ]; then \
if [ "${v2##*/}" = "9.5" ]; then d2="${d2%-*}-$POSTGIS_LEGACY"; fi \
if [ "${v2##*/}" = "9.6" ]; then d2="${d2%-*}-$POSTGIS_LEGACY"; fi \
&& d1="../$d1"; \
fi \
&& d2="$v2/$d2" \
Expand Down
44 changes: 44 additions & 0 deletions postgres-appliance/patches/pgextwlist.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff -urN pgextwlist-1.11.orig/pgextwlist.c pgextwlist-1.11/pgextwlist.c
--- pgextwlist-1.11.orig/pgextwlist.c 2020-05-24 21:10:12.000000000 +0200
+++ pgextwlist-1.11/pgextwlist.c 2021-06-25 13:16:13.568885524 +0200
@@ -101,7 +101,7 @@

#define PROCESS_UTILITY_ARGS pstmt, queryString, context, \
params, queryEnv, dest, completionTag
-#else
+#elif PG_MAJOR_VERSION < 1400
#define PROCESS_UTILITY_PROTO_ARGS PlannedStmt *pstmt, \
const char *queryString, \
ProcessUtilityContext context, \
@@ -112,6 +112,18 @@

#define PROCESS_UTILITY_ARGS pstmt, queryString, context, \
params, queryEnv, dest, qc
+#else
+#define PROCESS_UTILITY_PROTO_ARGS PlannedStmt *pstmt, \
+ const char *queryString, \
+ bool readOnlyTree, \
+ ProcessUtilityContext context, \
+ ParamListInfo params, \
+ QueryEnvironment *queryEnv, \
+ DestReceiver *dest, \
+ QueryCompletion *qc
+#define PROCESS_UTILITY_ARGS pstmt, queryString, readOnlyTree, context, \
+ params, queryEnv, dest, qc
+
#endif /* PG_MAJOR_VERSION */

#define EREPORT_EXTENSION_IS_NOT_WHITELISTED(op) \
diff -urN pgextwlist-1.11.orig/utils.c pgextwlist-1.11/utils.c
--- pgextwlist-1.11.orig/utils.c 2020-05-24 21:10:12.000000000 +0200
+++ pgextwlist-1.11/utils.c 2021-06-25 13:16:20.133002157 +0200
@@ -470,6 +470,9 @@
{
ProcessUtility(stmt,
sql,
+#if PG_MAJOR_VERSION >= 1400
+ false,
+#endif
#if PG_MAJOR_VERSION >= 903
PROCESS_UTILITY_QUERY,
#endif
Loading

0 comments on commit f2b1876

Please sign in to comment.