0

I want to describe a table schema in postgresql 14. However when I use the older \d+, the error is thrown:

pgsql=# \d+ <table_name>
ERROR:  column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

Thanks in advance!

3 Answers3

2

If you use an older psql version to connect to a newer server version, some commands may fail, as psql informs you when the connection is established. This is exactly what you see at work there.

Call the psql from your v14 installation, and things will work fine. If you don't know how to do that, uninstall all older versions of PostgreSQL.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
1

\d+ is working on Postgres14 well. Maybe you are use older version of psql. There is not forward compatibility. If you want to use PostgreSQL14, you should to use psql for Postgres14 and higher. You can check it by --option:

[pavel.stehule@pgsql ~]$ psql --version
psql (PostgreSQL) 9.6.23
Pavel Stehule
  • 42,331
  • 5
  • 91
  • 94
1

Like both the earlier answers, you have two versions of psql in your host and the default is the older one which is not compatible with the current database version which is 14.

Temporary fix:

  • verify the current version & location
bash-4.2$ psql --version
psql (PostgreSQL) 9.2.24
bash-4.2$ which psql
/usr/bin/psql
  • Find the location of the version of psql for the current DB. Usually, its under /usr/psql??/bin , like:
bash-4.2$ cd /usr/pgsql-13/bin
bash-4.2$ ls -ltr|grep psql
-rwxr-xr-x 1 root root  644264 May 13  2021 psql
  • Navigate to that location or invoke that psql binary by providing the path, like
bash-4.2$ /usr/pgsql-13/bin/psql --version
psql (PostgreSQL) 13.3

bash-4.2$ /usr/pgsql-13/bin/psql
Pager usage is off.
psql (13.3)
Type "help" for help.

postgres=#

Permanent Fix

If you want the psql of the existing database which is the new version to be default , you can use 'update-alternatives' utility. Like mentioned here: How do I correct the mismatch of psql version and postgresql version?

This is how I did.

    
    [root@ip-10-211-209-252 bin]# pwd
/usr/bin
    [root@ip-xxxx bin]# mv psql psql9
    [root@ip-xxxx bin]# update-alternatives --install /usr/bin/psql psql /usr/bin/psql9  1
    
    [root@ip-xxxx bin]# cd /usr/pgsql-13/bin
    [root@ip-xxxx bin]# ls -ltr|grep psql
    -rwxr-xr-x 1 root root  644264 May 13  2021 psql
    [root@ip-xxxx bin]# update-alternatives --install /usr/bin/psql psql /usr/pgsql-13/bin/psql 2
    [root@ip-xxxx bin]# update-alternatives --config psql
    
    There are 3 programs which provide 'psql'.
    
      Selection    Command
    -----------------------------------------------
    *+ 1           /usr/pgsql-13/bin/psql
       2           /usr/bin/psql
       3           /usr/bin/psql9
    
    Enter to keep the current selection[+], or type selection number: 1
    [root@ip-xxxx bin]#

rajorshi
  • 697
  • 4
  • 9