I am contributing to Apache AGE, an extension of PostgreSQL, and would like to maintain PostgreSQL 11, 12, and 13 installed to easily switch between them to test/debug the extension's functionality.
I have PostgreSQL 12 installed from the source code, and as it is not in my interest to keep multiple databases running at the same time, I followed the steps below to install PostgreSQL 13:
- Accessed PostgreSQL 12 source code directory.
- I switched from the
origin/REL_12_STABLE
branch to theorigin/REL_13_STABLE
branch. - Then, I ran the following commands:
make distclean
./configure --prefix=/usr/local/pgsql-13
make -j4
However, I am not able to change the version. This is the output of the pg_config
command. Only the version is still 12.14, even though I am pointing to the correct directory:
BINDIR = /usr/local/pgsql-13/bin
DOCDIR = /usr/local/pgsql-13/share/doc
HTMLDIR = /usr/local/pgsql-13/share/doc
INCLUDEDIR = /usr/local/pgsql-13/include
PKGINCLUDEDIR = /usr/local/pgsql-13/include
INCLUDEDIR-SERVER = /usr/local/pgsql-13/include/server
LIBDIR = /usr/local/pgsql-13/lib
PKGLIBDIR = /usr/local/pgsql-13/lib
LOCALEDIR = /usr/local/pgsql-13/share/locale
MANDIR = /usr/local/pgsql-13/share/man
SHAREDIR = /usr/local/pgsql-13/share
SYSCONFDIR = /usr/local/pgsql-13/etc
PGXS = /usr/local/pgsql-13/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--prefix=/usr/local/pgsql-13'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql-13/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lz -lreadline -lcrypt -lm
VERSION = PostgreSQL 12.14
I tried:
- Manually changing the version in the
postgresql.conf
file of the database and the/usr/local/pgsql-13/bin/data
directory. - Installing
postgresql-server-dev-13
. - Updating the
FORCE_PGCONFIG
variable withexport FORCE_PGCONFIG=/usr/local/pgsql-13/bin/pg_config
. - Updating the
FORCE_PGCONFIG
variable with the file from the package manager installation:export FORCE_PGCONFIG=/usr/local/pgsql-13/bin/pg_config
.
But none of these options worked. The option 4 causes errors when initializing the database with pg_ctl
, even no other database is running. It also not suitable for debugging the code:
2023-04-09 13:16:54.163 -03 [7819] LOG: could not bind IPv4 address "127.0.0.1": Address already in use
2023-04-09 13:16:54.163 -03 [7819] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-04-09 13:16:54.163 -03 [7819] WARNING: could not create listen socket for "localhost"
2023-04-09 13:16:54.163 -03 [7819] FATAL: could not create any TCP/IP sockets
2023-04-09 13:16:54.164 -03 [7819] LOG: database system is shut down
Also, I saw that it is possible to change the port number and use two servers simultaneously, but since I will only be using one version at a time, I don't see the point in doing that.
I'm using Ubuntu 22.04 LTS. Is there any way to keep all versions from the source code installation?