mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-14 11:40:38 +00:00
for loop
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
ARG PG_VERSION
|
||||
ARG REPOSITORY=neondatabase
|
||||
ARG IMAGE=build-tools
|
||||
ARG TAG=pinned
|
||||
@@ -22,59 +21,59 @@ RUN apt update && \
|
||||
#
|
||||
#########################################################################################
|
||||
FROM build-deps AS pg-build
|
||||
# ARG PG_VERSION
|
||||
# COPY vendor/postgres-${PG_VERSION} postgres
|
||||
RUN for version in v14 v15 v16; do \
|
||||
cp -r "vendor/postgres-${version}" "postgres-$version" ;\
|
||||
echo $version \
|
||||
COPY "vendor/postgres-v14" /postgres-v14
|
||||
COPY "vendor/postgres-v15" /postgres-v15
|
||||
COPY "vendor/postgres-v16" /postgres-v16
|
||||
RUN for pg_version in v14 v15 v16; do \
|
||||
install_dir="/postgres-$pg_version" ; \
|
||||
cd "$install_dir"; \
|
||||
export CONFIGURE_CMD="./configure CFLAGS='-O2 -g3' --enable-debug --with-openssl --with-uuid=ossp \
|
||||
--with-icu --with-libxml --with-libxslt --with-lz4" && \
|
||||
if [ "${pg_version}" != "v14" ]; then \
|
||||
# zstd is available only from PG15
|
||||
export CONFIGURE_CMD="${CONFIGURE_CMD} --with-zstd"; \
|
||||
fi && \
|
||||
eval $CONFIGURE_CMD && \
|
||||
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s install && \
|
||||
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C contrib/ install && \
|
||||
# Install headers
|
||||
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/include install && \
|
||||
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/interfaces/libpq install && \
|
||||
# Enable some of contrib extensions
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/autoinc.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/bloom.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/earthdistance.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/insert_username.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/intagg.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/moddatetime.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_stat_statements.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgrowlocks.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgstattuple.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/refint.control && \
|
||||
echo 'trusted = true' >> /usr/local/pgsql/share/extension/xml2.control && \
|
||||
# We need to grant EXECUTE on pg_stat_statements_reset() to neon_superuser.
|
||||
# In vanilla postgres this function is limited to Postgres role superuser.
|
||||
# In neon we have neon_superuser role that is not a superuser but replaces superuser in some cases.
|
||||
# We could add the additional grant statements to the postgres repository but it would be hard to maintain,
|
||||
# whenever we need to pick up a new postgres version and we want to limit the changes in our postgres fork,
|
||||
# so we do it here.
|
||||
old_list="pg_stat_statements--1.0--1.1.sql pg_stat_statements--1.1--1.2.sql pg_stat_statements--1.2--1.3.sql pg_stat_statements--1.3--1.4.sql pg_stat_statements--1.4--1.5.sql pg_stat_statements--1.4.sql pg_stat_statements--1.5--1.6.sql"; \
|
||||
# the first loop is for pg_stat_statement extension version <= 1.6
|
||||
for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
||||
filename=$(basename "$file"); \
|
||||
if echo "$old_list" | grep -q -F "$filename"; then \
|
||||
echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset() TO neon_superuser;' >> $file; \
|
||||
fi; \
|
||||
done; \
|
||||
# the second loop is for pg_stat_statement extension versions >= 1.7,
|
||||
# where pg_stat_statement_reset() got 3 additional arguments
|
||||
for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
||||
filename=$(basename "$file"); \
|
||||
if ! echo "$old_list" | grep -q -F "$filename"; then \
|
||||
echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset(Oid, Oid, bigint) TO neon_superuser;' >> $file; \
|
||||
fi; \
|
||||
done; \
|
||||
done
|
||||
# RUN cd postgres && \
|
||||
# export CONFIGURE_CMD="./configure CFLAGS='-O2 -g3' --enable-debug --with-openssl --with-uuid=ossp \
|
||||
# --with-icu --with-libxml --with-libxslt --with-lz4" && \
|
||||
# if [ "${PG_VERSION}" != "v14" ]; then \
|
||||
# # zstd is available only from PG15
|
||||
# export CONFIGURE_CMD="${CONFIGURE_CMD} --with-zstd"; \
|
||||
# fi && \
|
||||
# eval $CONFIGURE_CMD && \
|
||||
# make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s install && \
|
||||
# make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C contrib/ install && \
|
||||
# # Install headers
|
||||
# make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/include install && \
|
||||
# make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/interfaces/libpq install && \
|
||||
# # Enable some of contrib extensions
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/autoinc.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/bloom.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/earthdistance.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/insert_username.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/intagg.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/moddatetime.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/pg_stat_statements.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgrowlocks.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgstattuple.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/refint.control && \
|
||||
# echo 'trusted = true' >> /usr/local/pgsql/share/extension/xml2.control && \
|
||||
# # We need to grant EXECUTE on pg_stat_statements_reset() to neon_superuser.
|
||||
# # In vanilla postgres this function is limited to Postgres role superuser.
|
||||
# # In neon we have neon_superuser role that is not a superuser but replaces superuser in some cases.
|
||||
# # We could add the additional grant statements to the postgres repository but it would be hard to maintain,
|
||||
# # whenever we need to pick up a new postgres version and we want to limit the changes in our postgres fork,
|
||||
# # so we do it here.
|
||||
# old_list="pg_stat_statements--1.0--1.1.sql pg_stat_statements--1.1--1.2.sql pg_stat_statements--1.2--1.3.sql pg_stat_statements--1.3--1.4.sql pg_stat_statements--1.4--1.5.sql pg_stat_statements--1.4.sql pg_stat_statements--1.5--1.6.sql"; \
|
||||
# # the first loop is for pg_stat_statement extension version <= 1.6
|
||||
# for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
||||
# filename=$(basename "$file"); \
|
||||
# if echo "$old_list" | grep -q -F "$filename"; then \
|
||||
# echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset() TO neon_superuser;' >> $file; \
|
||||
# fi; \
|
||||
# done; \
|
||||
# # the second loop is for pg_stat_statement extension versions >= 1.7,
|
||||
# # where pg_stat_statement_reset() got 3 additional arguments
|
||||
# for file in /usr/local/pgsql/share/extension/pg_stat_statements--*.sql; do \
|
||||
# filename=$(basename "$file"); \
|
||||
# if ! echo "$old_list" | grep -q -F "$filename"; then \
|
||||
# echo 'GRANT EXECUTE ON FUNCTION pg_stat_statements_reset(Oid, Oid, bigint) TO neon_superuser;' >> $file; \
|
||||
# fi; \
|
||||
# done
|
||||
|
||||
# #########################################################################################
|
||||
# #
|
||||
|
||||
Reference in New Issue
Block a user