Subject: Issue with installing postgres extension

From: bhavani dba <[email-masked]>
Date: Wed, 26 Jun 2024 19:22:57 -0400

I am having issues with postgres extensions and I have already installed
the contrib package.

thank you for the help!!

postgres=# CREATE EXTENSION pg_stat_statements;
ERROR:  could not load library
"/home/postgres/bin/pgsql/15/lib/pg_stat_statements.so":
/home/postgres/bin/pgsql/15/lib/pg_stat_statements.so: undefined symbol:
InitMaterializedSRF
postgres=#
postgres=# exit
[postgres@postgres ~]$ rpm -q postgresql15-contrib
postgresql15-contrib-15.7-3PGDG.rhel8.x86_64
[postgres@postgres ~]$ pg_config
BINDIR = /home/postgres/bin/pgsql/15/bin
DOCDIR = /home/postgres/bin/pgsql/15/share/doc
HTMLDIR = /home/postgres/bin/pgsql/15/share/doc
INCLUDEDIR = /home/postgres/bin/pgsql/15/include
PKGINCLUDEDIR = /home/postgres/bin/pgsql/15/include
INCLUDEDIR-SERVER = /home/postgres/bin/pgsql/15/include/server
LIBDIR = /home/postgres/bin/pgsql/15/lib
PKGLIBDIR = /home/postgres/bin/pgsql/15/lib
LOCALEDIR = /home/postgres/bin/pgsql/15/share/locale
MANDIR = /home/postgres/bin/pgsql/15/share/man
SHAREDIR = /home/postgres/bin/pgsql/15/share
SYSCONFDIR = /home/postgres/bin/pgsql/15/etc
PGXS = /home/postgres/bin/pgsql/15/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE =  '--prefix=/home/postgres/bin/pgsql/15'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type
-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,'/home/postgres/bin/pgsql/15/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lz -lreadline -lpthread -lrt -ldl -lm
VERSION = PostgreSQL 15.0
[postgres@postgres ~]$ cd /home/postgres/bin/pgsql/15/lib
[postgres@postgres lib]$ ls
cyrillic_and_mic.so    libecpg.a               libpgcommon_shlib.a
 libpq.so                    plpgsql.so            utf8_and_gb18030.so
dict_snowball.so       libecpg_compat.a        libpgfeutils.a
libpq.so.5                  repmgr.so             utf8_and_gbk.so
euc2004_sjis2004.so    libecpg_compat.so       libpgport.a
 libpq.so.5.15               utf8_and_big5.so      utf8_and_iso8859_1.so
euc_cn_and_mic.so      libecpg_compat.so.3     libpgport_shlib.a
 libpqwalreceiver.so         utf8_and_cyrillic.so  utf8_and_iso8859.so
euc_jp_and_sjis.so     libecpg_compat.so.3.15  libpgtypes.a
pgoutput.so                 utf8_and_euc2004.so   utf8_and_johab.so
euc_kr_and_mic.so      libecpg.so              libpgtypes.so
 pg_stat_statements.control  utf8_and_euc_cn.so    utf8_and_sjis2004.so
euc_tw_and_big5.so     libecpg.so.6            libpgtypes.so.3
 pg_stat_statements.so       utf8_and_euc_jp.so    utf8_and_sjis.so
latin2_and_win1250.so  libecpg.so.6.15         libpgtypes.so.3.15   pgxs
                     utf8_and_euc_kr.so    utf8_and_uhc.so
latin_and_mic.so       libpgcommon.a           libpq.a
 pkgconfig                   utf8_and_euc_tw.so    utf8_and_win.so
[postgres@postgres lib]$ psqll
bash: psqll: command not found...
Similar command is: 'psql'
[postgres@postgres lib]$ psql
psql (15.7, server 15.0)
Type "help" for help.

postgres=#

-- 
Thanks & Regards,

BHAVANI DHULIPALLA
(973)-615-0290

---

From: Tom Lane <[email-masked]>
Date: Wed, 26 Jun 2024 19:43:04 -0400

> /home/postgres/bin/pgsql/15/lib/pg_stat_statements.so: undefined symbol:

This certainly looks like you are trying to load a v15 extension
into a pre-v15 server (since the InitMaterializedSRF function
didn't exist in prior versions).

I'm going to go out on a limb and guess that you just installed
v15 and forgot to restart the server, so that what's running is
still v14 or before.  If so, you probably also forgot the
pg_upgrade step --- you can't simply start a new major version
in an old one's data directory.

			regards, tom lane

---

From: bhavani dba <[email-masked]>
Date: Wed, 26 Jun 2024 21:08:23 -0400

thank you for tom for your response. i dont remember installing postgres 14
version on the server and it seems like I have postgres 15 running.

Please see below.

[postgres@postgres ~]$ psql
psql (15.7, server 15.0)
Type "help" for help.

postgres=#

postgres=# CREATE EXTENSION pg_stat_statements;
ERROR:  could not load library
"/home/postgres/bin/pgsql/15/lib/pg_stat_statements.so":
/home/postgres/bin/pgsql/15/lib/pg_stat_statements.so: undefined symbol:
InitMaterializedSRF
postgres=#
postgres=# SELECT version();
                                                  version
------------------------------------------------------------------------------------------------------------
 PostgreSQL 15.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1
20191121 (Red Hat 8.3.1-5.0.1), 64-bit
(1 row)

-- 
Thanks & Regards,

BHAVANI DHULIPALLA
(973)-615-0290

---

From: Tom Lane <[email-masked]>
Date: Wed, 26 Jun 2024 22:25:36 -0400

> [postgres@postgres ~]$ psql

Hmm ... after poking around a bit, it appears you are trying to load
extension code compiled against 15.1 or later into a 15.0 server.
Possibly we should have thought a bit harder about the compatibility
implications of commit f2f7e509e.  Nonetheless, what are you doing
running a 15.0 server?  That was many minor releases and bug fixes
ago.

			regards, tom lane