Skip to content

Commit

Permalink
Initialize Cargo / timescaledb only if available
Browse files Browse the repository at this point in the history
Previously, we depended on the value of PG_VERSIONS or TSDB_PG_VERSIONS.
This doesn't always work correctly, however, we can switch to
determining the versions at runtime, that should prevent errors like:

     528.1 + for pg in '$PG_VERSIONS'
     528.1 + init_flags=' --pg12 /usr/pgsql-12/bin/pg_config --pg13 /usr/pgsql-13/bin/pg_config --pg14 /usr/pgsql-14/bin/pg_config --pg15 /usr/pgsql-15/bin/pg_config --pg16 /usr/pgsql-16/bin/pg_config'
     528.1 + cargo pgrx init --pg12 /usr/pgsql-12/bin/pg_config --pg13 /usr/pgsql-13/bin/pg_config --pg14 /usr/pgsql-14/bin/pg_config --pg15 /usr/pgsql-15/bin/pg_config --pg16 /usr/pgsql-16/bin/pg_config
     528.1      Creating PGRX_HOME at `/home/postgres/.pgrx`
     528.1 The application panicked (crashed).
     528.1 Message:  no major version:
     528.1    0: The specified pg_config binary, `/usr/pgsql-16/bin/pg_config`, does not exist
     528.1    1: No such file or directory (os error 2)
  • Loading branch information
feikesteenbergen committed Nov 27, 2023
1 parent 0953c2b commit c6442d4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions docker/ci/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,19 @@ cargo install cargo-pgrx --version =$PGRX_VERSION

# Configure pgrx
## `cargo pgrx init` is not additive; must specify all versions in one command.
for pg in $PG_VERSIONS; do
init_flags="$init_flags --pg$pg $PG_BASE$pg/bin/pg_config"
done
for pg_config in $(find /usr -name 'pg_config' -type f | grep "${PG_BASE}"); do
pg="$(${pg_config} --version | awk -F '[ .]' '{print $2'})"
init_flags="$init_flags --pg$pg ${pg_config}"
cargo pgrx init $init_flags
## Initialize pgrx-managed databases so we can add the timescaledb load.
for pg in $TSDB_PG_VERSIONS; do
echo "shared_preload_libraries = 'timescaledb'" >> ~/.pgrx/data-$pg/postgresql.conf

## Initialize pgrx-managed databases so we can add the timescaledb load, but only
## for those PostgreSQL versions that have the timescaledb.so library available.
for pg_config in $(find /usr -name 'pg_config' -type f | grep "${PG_BASE}"); do
pg="$(${pg_config} --version | awk -F '[ .]' '{print $2'})"
lib="$(find "${PGBASE}${pg}" -type f -name 'timescaledb.so')"
if [ "${lib}" != "" ]; then
echo "shared_preload_libraries = 'timescaledb'" >> ~/.pgrx/data-$pg/postgresql.conf
fi
done

# Clone and fetch dependencies so we builds have less work to do.
Expand Down

0 comments on commit c6442d4

Please sign in to comment.