pg_config - how to change postgres versions

自闭症网瘾萝莉.ら 提交于 2021-01-28 00:15:15

问题


By default I had postgres 10 versions on my two ubuntu 14 machines, but I installed postgres 9.6 on the two of them.

But on one of them pg_config give me:

VERSION = PostgreSQL 9.6.6

And the other:

VERSION = PostgreSQL 10.1

They have the same libpq-dev packages in:

dpkg -l | grep libpq-dev

libpq-dev  10.1-1.pgdg14.04+1  amd64 header files for libpq5 (PostgreSQL library)

So I was wondering is there a way for me to change the version installed that it gives me postgres 9.6 instead of postgres 10.01? Maybe using the pg_config file?

Tnx, Tom

update: on the instance that still shows postgres 10, this is the result(which shows that it is not installed):

ii  pgdg-keyring                         2017.3                                     all          keyring for apt.postgresql.org
ii  postgresql-9.6                       9.6.6-1.pgdg14.04+1                        amd64        object-relational SQL database, version 9.6 server
ii  postgresql-client-9.6                9.6.6-1.pgdg14.04+1                        amd64        front-end programs for PostgreSQL 9.6
ii  postgresql-client-common             189.pgdg14.04+1                            all          manager for multiple PostgreSQL client versions
ii  postgresql-common                    189.pgdg14.04+1                            all          PostgreSQL database-cluster manager
ii  postgresql-contrib-9.6               9.6.6-1.pgdg14.04+1                        amd64        additional facilities for PostgreSQL

回答1:


duplicated: pg_config shows 9.4 instead of 9.3

On: Debian, Ubuntu

the bash /usr/bin/pg_config is setup to look and get the latest /usr/lib/postgresql/*/pg_config --version available

A fast solution, NOT elegant and weak, could be to update it as follow.
Then update env as, e.g.:

export FORCE_PGCONFIG=/usr/lib/postgresql/12/pg_config

/usr/bin/pg_config (updated) :

PGBINROOT="/usr/lib/postgresql/"
#redhat# PGBINROOT="/usr/pgsql-"
# user edit :
if [ -n "$FORCE_PGCONFIG" ]; then
    # up to you to set it properly...
    LATEST_SERVER_DEV="$FORCE_PGCONFIG";
else
    LATEST_SERVER_DEV=`ls -v $PGBINROOT*/bin/pg_config 2>/dev/null|tail -n1`;
fi
# end user edit ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if [ -n "$LATEST_SERVER_DEV" ]; then
    exec "$LATEST_SERVER_DEV" "$@"
else
    if [ -x /usr/bin/pg_config.libpq-dev ]; then
    exec /usr/bin/pg_config.libpq-dev "$@"
    else
    echo "You need to install postgresql-server-dev-NN for building a server-side extension or libpq-dev for building a client-side application." >&2
    exit 1
    fi
fi


来源:https://stackoverflow.com/questions/48562616/pg-config-how-to-change-postgres-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!