Ошибка столбец c relhasoids не существует символ 245

I’m trying to CREATE TABLE command in Postgresql.
After creating a table, if I punch in TABLE table name, it works.

But I punch in d table name, I keep getting an error below.

ERROR: column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

I attempted DROP DATABASE table name recreated a database and recreated a table again several times. But it didn’t work.

Any suggestions would be appreciated! Thank you.

asked Oct 19, 2019 at 6:39

Nao's user avatar

NaoNao

1,3432 gold badges7 silver badges8 bronze badges

4

I am able to reproduce your error if I am using Postgres v.12 and an older client (v.11 or earlier):

[root@def /]# psql -h 172.17.0.3
psql (11.5, server 12.0)
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=# create table mytable (id int, name text);
CREATE TABLE
postgres=# table mytable;
 id | name 
----+------
(0 rows)

postgres=# d mytable;
ERROR:  column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...
                                                             ^
postgres=# 

This is because in v. 12, table OIDs are no longer treated as special columns, and hence the relhasoids column is no longer necessary. Please make sure you’re using a v. 12 psql binary so you don’t encounter this error.

You may not necessarily be using psql, so the more general answer here is to make sure you’re using a compatible client.

answered Oct 19, 2019 at 7:19

richyen's user avatar

richyenrichyen

7,9663 gold badges13 silver badges28 bronze badges

2

For anyone running Postgres as a Docker container:

Instead of running psql from the host, run it from inside the container e.g.

docker exec -it postgres_container_name psql your_connection_string

The Postgres image always ships with the corresponding—and thus always updated—version of psql so you don’t have to worry about having the correct version installed on the host machine.

answered Nov 7, 2019 at 11:52

joakim's user avatar

joakimjoakim

3,3932 gold badges23 silver badges28 bronze badges

6

If you’re using DataGrip, there’s an easy fix:

Try using «Introspect using JDBC metadata». This fixed it for me when (I think) I had a version mismatch between postgresql server and DataGrip client.

Under your connection settings -> Options tab -> check Introspect using JDBC metadata

According to https://www.jetbrains.com/help/datagrip/data-sources-and-drivers-dialog.html#optionsTab :

Switch to the JDBC-based introspector.

To retrieve information about database objects (DB metadata), DataGrip
uses the following introspectors:

  1. A native introspector (might be unavailable for certain DBMS). The
    native introspector uses DBMS-specific tables and views as a source of
    metadata. It can retrieve DBMS-specific details and produce a more
    precise picture of database objects.

  2. A JDBC-based introspector (available for all the DBMS). The JDBC-based
    introspector uses the metadata provided by the JDBC driver. It can
    retrieve only standard information about database objects and their
    properties.

Consider using the JDBC-based intorspector when the native
introspector fails or is not available.

The native introspector can fail, when your database server version is
older than the minimum version supported by DataGrip.

You can try to switch to the JDBC-based introspector to fix problems
with retrieving the database structure information from your database.
For example, when the schemas that exist in your database or database
objects below the schema level are not shown in the Database tool
window.

answered Nov 20, 2020 at 16:25

David Hempy's user avatar

David HempyDavid Hempy

5,2552 gold badges40 silver badges66 bronze badges

2

The issue is the client (psql) is a different version from the postgres server. I have seen this issue with psql version 11 talking to postgres version 12. To solve this issue upgrade the psql version to 12.

If you are running a docker postgres, you can exec into the container then use the psql client installed there.

# get the container id with this
docker ps
# Then exec into the container, please note the host will now be 120.0.0.1
docker exec -it c12e8c6b8eb5 /bin/bash

answered Jul 16, 2020 at 16:08

Eutychus's user avatar

EutychusEutychus

4328 silver badges12 bronze badges

I had this issue because my psql was 9.2 and the server version was 12.7.
So … clearly the psql client needs to be updated. But how?

Before you go downloading/installing anything though you may already have the right version. In my case I did.

I executed which psql which showed my version was coming from /usr/bin/psql.
I then checked /usr/pgsql-12/bin and found there was a psql in there.
So all I needed to do was ensure psql was picked up from there.
There are a number of places that could be controlling this; in my case I just added this line to my .pgsql_profile (in the postgres user’s home directory):

export PATH="/usr/pgsql-12/bin:$PATH"

Logging out and back in as postgres and executing which psql showed the change had been successful:

 which psql
/usr/pgsql-12/bin/psql

answered Jul 30, 2021 at 11:51

JL_SO's user avatar

JL_SOJL_SO

1,7121 gold badge24 silver badges38 bronze badges

This answer is specific to pgcli

If you are using pgcli you may be encountering this issue. It’s solved by updating the python package pgspecial.

If you installed pgcli using pip, you can simply do, depending on your python version:

pip install -U pgspecial

or

pip3 install -U pgspecial

If you are using Ubuntu and intalled pgcli using apt, you can either switch it to pip with:

sudo apt remove --purge pgcli
pip3 install pgcli

or update the distribution package python-pgspecial or python3-pgspecial from the Ubuntu packages web site. In that case you may need to update its dependencies as well.

answered Oct 25, 2020 at 10:28

Jocelyn's user avatar

JocelynJocelyn

1,31112 silver badges20 bronze badges

I had this issue today, was unable to continue work due to this, strangely the application code is working fine.

Later, found this issue is only occurring if I use OmniDb client I use to connect to DB.

I have switched client to default pgAdmin 4 that comes with postgres installation & issue is not occurring anymore pgAdmin 4. Link: https://www.pgadmin.org/download/pgadmin-4-windows/

Its possible that OmniDb client might be older, but no time to troubleshoot it, using pgAdmin 4 for now.

Hope that helps.

answered Oct 19, 2019 at 9:32

Manohar Reddy Poreddy's user avatar

1

Just update DataGrip solved this issue, Datagrip updated to version DataGrip 2019.3.3, Build #DB-193.6494.42, built on February 12, 2020, Now working :)

Just for DataGrip users!

answered Oct 2, 2020 at 17:10

DariusV's user avatar

DariusVDariusV

2,62715 silver badges21 bronze badges

1

I had the same issue today too. In my case, the problem was solved when I deleted the version 12 and installed the version 11. Seems that v12 has some features that must be create along the others columns.

answered Oct 20, 2019 at 0:23

Danilo Silva's user avatar

1

To fix this, edit Postgres.php file and comment the lines from hasObjectID function as shown below.

function hasObjectID($table) {
    $c_schema = $this->_schema;
    $this->clean($c_schema);
    $this->clean($table);

    /*
    $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}'
        AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')";

    $rs = $this->selectSet($sql);
    if ($rs->recordCount() != 1) return null;
    else {
        $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']);
        return $rs->fields['relhasoids'];
    }
    */
}

answered Jun 20, 2020 at 6:15

Pankaj Shinde's user avatar

Pankaj ShindePankaj Shinde

3,3312 gold badges35 silver badges44 bronze badges

I had the same issue when using PgAdmin to query the database.

Once I installed the newest version of PgAdmin the error disappeared!

answered Sep 13, 2020 at 17:19

sanwall's user avatar

You might also try restarting pgadmin.

After upgrading from postgres96 to postgres12 I had the same issue. My pgadmin was running psql v12.0 so that wasn’t the issue. I restarted pgadmin for a separate issue and the relhasoids issue went away.

If anyone could explain to me why this worked that would be appreciated.

answered Dec 16, 2021 at 18:43

Okianakin's user avatar

answered Jul 16, 2020 at 4:01

Oscar's user avatar

OscarOscar

471 silver badge7 bronze badges

I also got same issue with my postgresql tables. I have fixed this issue by below query.

ALTER Table MyDataBase.table_name add column column_name data_type default 0 not null;
commit;

Suraj Rao's user avatar

Suraj Rao

29.4k11 gold badges94 silver badges103 bronze badges

answered Nov 25, 2020 at 7:20

Naresh Ayanavilli's user avatar

I’m updating a Linux server with a new version of PostgreSql and I have an Error Message in phpPgAdmin when I browse a table.

The Ubuntu 18.04.3 LTS server running Apache 2.4.41, PHP 7.3.11 and when I update to PostgreSQL 12.0 and phpPgAdmin 7.12.0 the error occurs. With PostgreSQL 11.5 and phpPgAdmin 5.6 I didn’t have this problem.

I expect to visualize the data stored in the table using phpPgAdmin, but the actual output is:

    SQL error:
ERROR:  column «relhasoids» does not exist
LINE 1: SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='pr...

    In statement:
SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='product'
            AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='public')

richyen's user avatar

richyen

7,9663 gold badges13 silver badges28 bronze badges

asked Nov 7, 2019 at 23:33

Luis Cedeño's user avatar

1

Editing the file /usr/share/phppgadmin/classes/database/Postgres.php and comment line 1045 to line 1054 the error disappears:

function hasObjectID($table) {
    $c_schema = $this->_schema;
    $this->clean($c_schema);
    $this->clean($table);
/*
    $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}'
        AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')";

    $rs = $this->selectSet($sql);
    if ($rs->recordCount() != 1) return null;
    else {
        $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']);
        return $rs->fields['relhasoids'];
    } */
}

answered Nov 7, 2019 at 23:44

Luis Cedeño's user avatar

Luis CedeñoLuis Cedeño

2111 gold badge2 silver badges10 bronze badges

2

This column does not exist anymore, since you cannot create tables with OID any longer.

From the documentation:

WITH ( storage_parameter [= value] [, … ] )

This clause specifies optional storage parameters for a table or index; see Storage Parameters for more information. For backward-compatibility the WITH clause for a table can also include OIDS=FALSE to specify that rows of the new table should not contain OIDs (object identifiers), OIDS=TRUE is not supported anymore.

WITHOUT OIDS

This is backward-compatible syntax for declaring a table WITHOUT OIDS, creating a table WITH OIDS is not supported anymore.

answered Nov 7, 2019 at 23:41

Islingre's user avatar

IslingreIslingre

1,9926 silver badges18 bronze badges

I’m trying to CREATE TABLE command in Postgresql.
After creating a table, if I punch in TABLE table name, it works.

But I punch in d table name, I keep getting an error below.

ERROR: column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

I attempted DROP DATABASE table name recreated a database and recreated a table again several times. But it didn’t work.

Any suggestions would be appreciated! Thank you.

asked Oct 19, 2019 at 6:39

Nao's user avatar

NaoNao

1,2732 gold badges6 silver badges8 bronze badges

4

I am able to reproduce your error if I am using Postgres v.12 and an older client (v.11 or earlier):

[root@def /]# psql -h 172.17.0.3
psql (11.5, server 12.0)
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=# create table mytable (id int, name text);
CREATE TABLE
postgres=# table mytable;
 id | name 
----+------
(0 rows)

postgres=# d mytable;
ERROR:  column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...
                                                             ^
postgres=# 

This is because in v. 12, table OIDs are no longer treated as special columns, and hence the relhasoids column is no longer necessary. Please make sure you’re using a v. 12 psql binary so you don’t encounter this error.

You may not necessarily be using psql, so the more general answer here is to make sure you’re using a compatible client.

answered Oct 19, 2019 at 7:19

richyen's user avatar

richyenrichyen

7,5263 gold badges12 silver badges28 bronze badges

2

For anyone running Postgres as a Docker container:

Instead of running psql from the host, run it from inside the container e.g.

docker exec -it postgres_container_name psql your_connection_string

The Postgres image always ships with the corresponding—and thus always updated—version of psql so you don’t have to worry about having the correct version installed on the host machine.

answered Nov 7, 2019 at 11:52

joakim's user avatar

joakimjoakim

3,1332 gold badges23 silver badges25 bronze badges

6

If you’re using DataGrip, there’s an easy fix:

Try using «Introspect using JDBC metadata». This fixed it for me when (I think) I had a version mismatch between postgresql server and DataGrip client.

Under your connection settings -> Options tab -> check Introspect using JDBC metadata

According to https://www.jetbrains.com/help/datagrip/data-sources-and-drivers-dialog.html#optionsTab :

Switch to the JDBC-based introspector.

To retrieve information about database objects (DB metadata), DataGrip
uses the following introspectors:

  1. A native introspector (might be unavailable for certain DBMS). The
    native introspector uses DBMS-specific tables and views as a source of
    metadata. It can retrieve DBMS-specific details and produce a more
    precise picture of database objects.

  2. A JDBC-based introspector (available for all the DBMS). The JDBC-based
    introspector uses the metadata provided by the JDBC driver. It can
    retrieve only standard information about database objects and their
    properties.

Consider using the JDBC-based intorspector when the native
introspector fails or is not available.

The native introspector can fail, when your database server version is
older than the minimum version supported by DataGrip.

You can try to switch to the JDBC-based introspector to fix problems
with retrieving the database structure information from your database.
For example, when the schemas that exist in your database or database
objects below the schema level are not shown in the Database tool
window.

answered Nov 20, 2020 at 16:25

David Hempy's user avatar

David HempyDavid Hempy

4,8712 gold badges42 silver badges63 bronze badges

2

The issue is the client (psql) is a different version from the postgres server. I have seen this issue with psql version 11 talking to postgres version 12. To solve this issue upgrade the psql version to 12.

If you are running a docker postgres, you can exec into the container then use the psql client installed there.

# get the container id with this
docker ps
# Then exec into the container, please note the host will now be 120.0.0.1
docker exec -it c12e8c6b8eb5 /bin/bash

answered Jul 16, 2020 at 16:08

Eutychus's user avatar

EutychusEutychus

3938 silver badges10 bronze badges

I had this issue because my psql was 9.2 and the server version was 12.7.
So … clearly the psql client needs to be updated. But how?

Before you go downloading/installing anything though you may already have the right version. In my case I did.

I executed which psql which showed my version was coming from /usr/bin/psql.
I then checked /usr/pgsql-12/bin and found there was a psql in there.
So all I needed to do was ensure psql was picked up from there.
There are a number of places that could be controlling this; in my case I just added this line to my .pgsql_profile (in the postgres user’s home directory):

export PATH="/usr/pgsql-12/bin:$PATH"

Logging out and back in as postgres and executing which psql showed the change had been successful:

 which psql
/usr/pgsql-12/bin/psql

answered Jul 30, 2021 at 11:51

JL_SO's user avatar

JL_SOJL_SO

1,6221 gold badge23 silver badges34 bronze badges

This answer is specific to pgcli

If you are using pgcli you may be encountering this issue. It’s solved by updating the python package pgspecial.

If you installed pgcli using pip, you can simply do, depending on your python version:

pip install -U pgspecial

or

pip3 install -U pgspecial

If you are using Ubuntu and intalled pgcli using apt, you can either switch it to pip with:

sudo apt remove --purge pgcli
pip3 install pgcli

or update the distribution package python-pgspecial or python3-pgspecial from the Ubuntu packages web site. In that case you may need to update its dependencies as well.

answered Oct 25, 2020 at 10:28

Jocelyn's user avatar

JocelynJocelyn

1,31211 silver badges20 bronze badges

I had this issue today, was unable to continue work due to this, strangely the application code is working fine.

Later, found this issue is only occurring if I use OmniDb client I use to connect to DB.

I have switched client to default pgAdmin 4 that comes with postgres installation & issue is not occurring anymore pgAdmin 4. Link: https://www.pgadmin.org/download/pgadmin-4-windows/

Its possible that OmniDb client might be older, but no time to troubleshoot it, using pgAdmin 4 for now.

Hope that helps.

answered Oct 19, 2019 at 9:32

Manohar Reddy Poreddy's user avatar

1

Just update DataGrip solved this issue, Datagrip updated to version DataGrip 2019.3.3, Build #DB-193.6494.42, built on February 12, 2020, Now working :)

Just for DataGrip users!

answered Oct 2, 2020 at 17:10

DariusV's user avatar

DariusVDariusV

2,53314 silver badges21 bronze badges

1

I had the same issue today too. In my case, the problem was solved when I deleted the version 12 and installed the version 11. Seems that v12 has some features that must be create along the others columns.

answered Oct 20, 2019 at 0:23

Danilo Silva's user avatar

1

To fix this, edit Postgres.php file and comment the lines from hasObjectID function as shown below.

function hasObjectID($table) {
    $c_schema = $this->_schema;
    $this->clean($c_schema);
    $this->clean($table);

    /*
    $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}'
        AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')";

    $rs = $this->selectSet($sql);
    if ($rs->recordCount() != 1) return null;
    else {
        $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']);
        return $rs->fields['relhasoids'];
    }
    */
}

answered Jun 20, 2020 at 6:15

Pankaj Shinde's user avatar

Pankaj ShindePankaj Shinde

3,1732 gold badges35 silver badges43 bronze badges

I had the same issue when using PgAdmin to query the database.

Once I installed the newest version of PgAdmin the error disappeared!

answered Sep 13, 2020 at 17:19

sanwall's user avatar

You might also try restarting pgadmin.

After upgrading from postgres96 to postgres12 I had the same issue. My pgadmin was running psql v12.0 so that wasn’t the issue. I restarted pgadmin for a separate issue and the relhasoids issue went away.

If anyone could explain to me why this worked that would be appreciated.

answered Dec 16, 2021 at 18:43

Okianakin's user avatar

answered Jul 16, 2020 at 4:01

Oscar's user avatar

OscarOscar

471 silver badge7 bronze badges

I also got same issue with my postgresql tables. I have fixed this issue by below query.

ALTER Table MyDataBase.table_name add column column_name data_type default 0 not null;
commit;

Suraj Rao's user avatar

Suraj Rao

29.3k11 gold badges96 silver badges103 bronze badges

answered Nov 25, 2020 at 7:20

Naresh Ayanavilli's user avatar

I facing the below error many times in the log file for PostgreSQL server v12.5 even the client version is the same version and I haven’t any other versions now. I just was having 10 and 12.5 and I removed both of them then I reinstalled v 12.5 only. any suggestions please ?

[23939] ERROR: column c.relhasoids does not exist at character 245
2021-02-20 20:03:02.274 EET [23939] STATEMENT: select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when ‘d’ then t.typbasetype else 0 end, t.typtypmod, c.relhasoids, attidentity, c.relhassubclass from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and c.oid = 350213) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum

I facing the below error many times in the log file for PostgreSQL server v12.5 even the client version is the same version and I haven’t any other versions now. I just was having 10 and 12.5 and I removed both of them then I reinstalled v 12.5 only. any suggestions please ?

[23939] ERROR: column c.relhasoids does not exist at character 245
2021-02-20 20:03:02.274 EET [23939] STATEMENT: select n.nspname, c.relname, a.attname, a.atttypid, t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), case t.typtype when ‘d’ then t.typbasetype else 0 end, t.typtypmod, c.relhasoids, attidentity, c.relhassubclass from (((pg_catalog.pg_class c inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace and c.oid = 350213) inner join pg_catalog.pg_attribute a on (not a.attisdropped) and a.attnum > 0 and a.attrelid = c.oid) inner join pg_catalog.pg_type t on t.oid = a.atttypid) left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum order by n.nspname, c.relname, attnum

Google Translate

SEARCH

Calendar

March 2021

M T W T F S S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31  

Archives

Archives

Blog Stats

  • 1,151,001 hits

Categories

Meta

I get the following error when trying to select rows from a table:

ERROR:  column rel.relhasoids does not exist
LINE 1: SELECT rel.relhasoids AS has_oids

Configuration is:

  • Linux RHL8
  • NAME=»Red Hat Enterprise Linux»
  • VERSION=»8.2 (Ootpa)»
  • postgresql12-server-12.3
  • psql (12.3)
  • PgAdmin 4.3 en 4,5

Laurenz Albe's user avatar

Laurenz Albe

38.5k4 gold badges34 silver badges58 bronze badges

asked Jul 14, 2020 at 13:20

Lilian Nunez's user avatar

The column relhasoids has been dropped from the system catalog pg_class in PostgreSQL v12, because the long deprecated WITH OIDS clause has been removed from CREATE TABLE.

Obviously you are using an old version of pgAdmin 4 that has not got the message yet.

Upgrade to a newer version of pgAdmin, and the error should vanish.

answered Jul 14, 2020 at 15:24

Laurenz Albe's user avatar

Laurenz AlbeLaurenz Albe

38.5k4 gold badges34 silver badges58 bronze badges

Я пытаюсь выполнить команду СОЗДАТЬ ТАБЛИЦУ в Postgresql. После создания таблицы, если я введу ТАБЛИЦА имя таблицы , все заработает.

Но я набираю d имя таблицы , я получаю сообщение об ошибке ниже.

ERROR: column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...

Я попытался DROP DATABASE имя таблицы воссоздать базу данных и повторно создать таблицу несколько раз. Но это не сработало.

Мы ценим любые предложения! Спасибо.

15 ответов

Для всех, кто запускает Postgres как контейнер Docker :

Вместо запуска psql с хоста запустите его изнутри контейнера, например.

docker exec -it postgres_container_name psql your_connection_string

Образ Postgres всегда поставляется с соответствующей — и, следовательно, всегда обновляемой — версией psql < / em>, поэтому вам не нужно беспокоиться о том, чтобы на хост-машине была установлена ​​правильная версия.


44

joakim
7 Ноя 2019 в 14:52

Я могу воспроизвести вашу ошибку, если я использую Postgres v.12 и более старый клиент (v.11 или более ранний):

[root@def /]# psql -h 172.17.0.3
psql (11.5, server 12.0)
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=# create table mytable (id int, name text);
CREATE TABLE
postgres=# table mytable;
 id | name 
----+------
(0 rows)

postgres=# d mytable;
ERROR:  column c.relhasoids does not exist
LINE 1: ...riggers, c.relrowsecurity, c.relforcerowsecurity, c.relhasoi...
                                                             ^
postgres=# 

Это связано с тем, что в версии 12 идентификаторы OID таблиц больше не рассматриваются как специальные столбцы, поэтому столбец relhasoids больше не нужен. Убедитесь, что вы используете двоичный файл версии 12 psql, чтобы избежать этой ошибки.

Возможно, вы не обязательно используете psql, поэтому более общий ответ здесь — убедиться, что вы используете совместимый клиент.


103

richyen
19 Окт 2019 в 19:31

У меня была такая же проблема сегодня. В моем случае проблема была решена, когда я удалил версию 12 и установил версию 11. Похоже, что в v12 есть некоторые функции, которые необходимо создать в других столбцах.


2

Danilo Silva
20 Окт 2019 в 03:23

Проблема в том, что версия клиента (psql) отличается от версии сервера postgres. Я видел эту проблему, когда psql версии 11 разговаривал с postgres версии 12. Чтобы решить эту проблему, обновите версию psql до 12.

Если вы запускаете docker postgres, вы можете выполнить команду exec в контейнере, а затем использовать установленный там клиент psql.

# get the container id with this
docker ps
# Then exec into the container, please note the host will now be 120.0.0.1
docker exec -it c12e8c6b8eb5 /bin/bash


15

Eutychus
16 Июл 2020 в 19:08

Этот ответ относится к pgcli

Если вы используете pgcli, вы можете столкнуться с этой проблемой. Решается обновлением пакета python pgspecial.

Если вы установили pgcli с помощью pip, вы можете просто сделать, в зависимости от вашей версии Python:

pip install -U pgspecial

Или

pip3 install -U pgspecial

Если вы используете Ubuntu и установили pgcli с помощью apt, вы можете переключить его на pip с помощью:

sudo apt remove --purge pgcli
pip3 install pgcli

Или обновите пакет распространения python-pgspecial или python3-pgspecial из пакетов Ubuntu веб-сайт. В этом случае вам может потребоваться также обновить его зависимости.


4

Jocelyn
25 Окт 2020 в 13:28

У меня была эта проблема сегодня, из-за этого я не мог продолжить работу, как ни странно, код приложения работает нормально.

Позже выяснилось, что эта проблема возникает только в том случае, если я использую клиент OmniDb, который я использую для подключения к БД.

Я переключил клиент на pgAdmin 4 по умолчанию, который поставляется с установкой postgres, и проблема больше не возникает pgAdmin 4. Ссылка: https://www.pgadmin.org/download/pgadmin-4-windows/

Возможно, что клиент OmniDb старше, но сейчас нет времени устранять неполадки, используя pgAdmin 4.

Надеюсь, это поможет.


3

Manohar Reddy Poreddy
19 Окт 2019 в 12:32

Чтобы исправить это, отредактируйте файл Postgres.php и прокомментируйте строки из функции hasObjectID, как показано ниже.

function hasObjectID($table) {
    $c_schema = $this->_schema;
    $this->clean($c_schema);
    $this->clean($table);

    /*
    $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}'
        AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$c_schema}')";

    $rs = $this->selectSet($sql);
    if ($rs->recordCount() != 1) return null;
    else {
        $rs->fields['relhasoids'] = $this->phpBool($rs->fields['relhasoids']);
        return $rs->fields['relhasoids'];
    }
    */
}


0

Pankaj Shinde
20 Июн 2020 в 09:15

Просто обновите DataGrip, решив эту проблему, Datagrip обновился до версии DataGrip 2019.3.3, Build # DB-193.6494.42, построен 12 февраля 2020 г., теперь работает :)

Только для пользователей DataGrip!


3

DariusV
2 Окт 2020 в 20:10

У меня была эта проблема, потому что мой psql был 9.2, а версия сервера — 12.7. Итак … очевидно, что клиент psql нуждается в обновлении. Но как?

Прежде чем вы загрузите / установите что-либо, возможно, у вас уже есть нужная версия. В моем случае я это сделал.

Я выполнил which psql, который показал, что моя версия исходит от /usr/bin/psql. Затем я проверил /usr/pgsql-12/bin и обнаружил, что там есть psql. Так что все, что мне нужно было сделать, это убедиться, что psql был взят оттуда. Есть несколько мест, которые могут это контролировать; в моем случае я просто добавил эту строку в свой .pgsql_profile (в домашнем каталоге пользователя postgres):

export PATH="/usr/pgsql-12/bin:$PATH"

Выход и повторный вход в качестве postgres и выполнение which psql показали, что изменение было успешным:

 which psql
/usr/pgsql-12/bin/psql


4

JL_SO
30 Июл 2021 в 14:51

У меня была такая же проблема при использовании PgAdmin для запроса базы данных.

Как только я установил последнюю версию PgAdmin, ошибка исчезла!


0

sanwall
13 Сен 2020 в 20:19

У меня также была такая же проблема с моими таблицами postgresql. Я исправил эту проблему с помощью запроса ниже.

ALTER Table MyDataBase.table_name add column column_name data_type default 0 not null;
commit;


-3

Suraj Rao
25 Ноя 2020 в 10:30

Если вы используете DataGrip, есть простое решение:

Попробуйте использовать «Introspect с использованием метаданных JDBC». Это исправило это для меня, когда (я думаю) у меня было несоответствие версий между сервером postgresql и клиентом DataGrip.

В настройках вашего подключения -> вкладка Параметры -> установите флажок Introspect с использованием метаданных JDBC.

Согласно https://www.jetbrains.com /help/datagrip/data-sources-and-drivers-dialog.html#optionsTab:

Переключитесь на интроспектор на основе JDBC.

Для получения информации об объектах базы данных (метаданных БД) DataGrip использует следующие интроспекторы:

  1. Собственный интроспектор (может быть недоступен для некоторых СУБД). В собственный интроспектор использует специфичные для СУБД таблицы и представления в качестве источника метаданные. Он может извлекать специфичные для СУБД детали и производить более точное изображение объектов базы данных.

  2. Интроспектор на основе JDBC (доступен для всех СУБД). Основанный на JDBC интроспектор использует метаданные, предоставленные драйвером JDBC. Может получать только стандартную информацию об объектах базы данных и их свойства.

Рассмотрите возможность использования интроспектора на основе JDBC, когда собственный интроспектор не работает или недоступен.

Собственный интроспектор может дать сбой, если версия вашего сервера базы данных старше минимальной версии, поддерживаемой DataGrip.

Вы можете попробовать переключиться на интроспектор на основе JDBC, чтобы исправить проблемы с получением информации о структуре базы данных из вашей базы данных. Например, когда схемы, существующие в вашей базе данных, или объекты базы данных ниже уровня схемы не отображаются в окне инструмента базы данных.


27

David Hempy
20 Ноя 2020 в 19:25

Вы также можете попробовать перезапустить pgadmin.

После обновления с postgres96 до postgres12 у меня возникла та же проблема. Мой pgadmin запускал psql v12.0, так что это не проблема. Я перезапустил pgadmin для отдельной проблемы, и проблема с relhasoids исчезла.

Если бы кто-нибудь мог объяснить мне, почему это сработало, я был бы признателен.


0

Okianakin
16 Дек 2021 в 21:43

Hi !

Thanks for this great extension. I am using it as a dependency to an extension I am building here:

https://gitlab.com/dalibo/postgresql_anonymizer/

We’re currently testing our extension with PostgreSQL 12 which will be release in a few weeks and there’s an error when loading ddlx with Postgres 12

For instance :

$ docker run -it --entrypoint=bash postgres:12
# apt update && apt install pgxnclient postgresql-server-dev-12 && pgxn install ddlx
# psql -U postgres -c "create extension ddlx;"

generates the following error :

WITH 
	  rel_kind(k,v) AS (
	         VALUES ('r','TABLE'),
	                ('p','TABLE'),
	                ('v','VIEW'),
	                ('i','INDEX'),
	                ('I','INDEX'),
	                ('S','SEQUENCE'),
	                ('s','SPECIAL'),
	                ('m','MATERIALIZED VIEW'),
	                ('c','TYPE'),
	                ('t','TOAST'),
	                ('f','FOREIGN TABLE')
	  ),
	  typ_type(k,v,v2) AS (
	         VALUES ('b','BASE','TYPE'),
	                ('c','COMPOSITE','TYPE'),
	                ('d','DOMAIN','DOMAIN'),
	                ('e','ENUM','TYPE'),
	                ('p','PSEUDO','TYPE'),
	                ('r','RANGE','TYPE')
	  )
	  SELECT c.oid,
	         'pg_class'::regclass,
	         c.relname AS name,
	         n.nspname AS namespace,
	         pg_get_userbyid(c.relowner) AS owner,
	         coalesce(cc.v,c.relkind::text) AS sql_kind,
	         cast(1::regclass AS text) AS sql_identifier,
	         relacl as acl
	    FROM pg_class c JOIN pg_namespace n ON n.oid=c.relnamespace
	    LEFT JOIN rel_kind AS cc on cc.k = c.relkind
	   WHERE c.oid = 1
	   UNION 
	  SELECT p.oid,
	         'pg_proc'::regclass,
	         p.proname AS name,
	         n.nspname AS namespace,
	         pg_get_userbyid(p.proowner) AS owner,
	         case
	           when p.proisagg then 'AGGREGATE'
	           else 'FUNCTION' 
	         end 
	         AS sql_kind,
	         cast(1::regprocedure AS text) AS sql_identifier,
	         proacl as acl
	    FROM pg_proc p JOIN pg_namespace n ON n.oid=p.pronamespace
	   WHERE p.oid = 1
	   UNION 
	  SELECT t.oid,
	         'pg_type'::regclass,
	         t.typname AS name,
	         n.nspname AS namespace,
	         pg_get_userbyid(t.typowner) AS owner,
	         coalesce(cc.v,tt.v2,t.typtype::text) AS sql_kind,
	         format_type(1,null) AS sql_identifier,
	         null as acl
	    FROM pg_type t JOIN pg_namespace n ON n.oid=t.typnamespace
	    LEFT JOIN typ_type AS tt ON tt.k = t.typtype
	    LEFT JOIN pg_class AS c ON c.oid = t.typrelid
	    LEFT JOIN rel_kind AS cc ON cc.k = c.relkind
	   WHERE t.oid = 1
	   UNION
	  SELECT r.oid,
	         'pg_roles'::regclass,
	         r.rolname as name,
	         null as namespace,
	         null as owner,
	         'ROLE' as sql_kind,
	         quote_ident(r.rolname) as sql_identifier,
	         null as acl
	    FROM pg_roles r
	   WHERE r.oid = 1
	   UNION
	  SELECT r.oid,
	         'pg_rewrite'::regclass,
	         r.rulename as name,
	         null as namespace,
	         null as owner,
	         'RULE' as sql_kind,
	         quote_ident(r.rulename)||' ON '|| 
	           cast(c.oid::regclass as text) sql_identifier,
	         null as acl
	    FROM pg_rewrite r JOIN pg_class c on (c.oid = r.ev_class)
	   WHERE r.oid = 1
	   UNION
	  SELECT n.oid,
	         'pg_namespace'::regclass,
	         n.nspname as name,
	         current_database() as namespace,
	         pg_get_userbyid(n.nspowner) AS owner,
	         'SCHEMA' as sql_kind,
	         quote_ident(n.nspname) as sql_identifier,
	         nspacl as acl
	    FROM pg_namespace n join pg_roles r on r.oid = n.nspowner
	   WHERE n.oid = 1
	   UNION
	  SELECT con.oid,
	         'pg_constraint'::regclass,
	         con.conname as name,
	         c.relname as namespace,
	         null as owner,
	         'CONSTRAINT' as sql_kind,
	         quote_ident(con.conname)
	         ||coalesce(' ON '||cast(c.oid::regclass as text),'') as sql_identifier,
	         null as acl
	    FROM pg_constraint con 
	    left JOIN pg_class c ON (con.conrelid=c.oid)
	    LEFT join (
	         values ('f','FOREIGN KEY'),
	                ('c','CHECK'),
	                ('x','EXCLUDE'),
	                ('u','UNIQUE'),
	                ('p','PRIMARY KEY'),
	                ('t','TRIGGER')
	         ) as tt on tt.column1 = con.contype
	   WHERE con.oid = 1
	   UNION
	  SELECT t.oid,
	         'pg_trigger'::regclass,
	         t.tgname as name,
	         c.relname as namespace,
	         null as owner,
	         'TRIGGER' as sql_kind,
	         format('%I ON %s',t.tgname,cast(c.oid::regclass as text)) as sql_identifier,
	         null as acl
	    FROM pg_trigger t join pg_class c on (t.tgrelid=c.oid)
	   WHERE t.oid = 1
	   UNION
	  SELECT ad.oid,
	         'pg_attrdef'::regclass,
	         a.attname as name,
	         c.relname as namespace,
	         null as owner,
	         'DEFAULT' as sql_kind,
	         format('%s.%I',cast(c.oid::regclass as text),a.attname) as sql_identifier,
	         null as acl
	    FROM pg_attrdef ad 
	    JOIN pg_class c ON (ad.adrelid=c.oid)
	    JOIN pg_attribute a ON (c.oid = a.attrelid and a.attnum=ad.adnum)
	   WHERE ad.oid = 1
	   UNION
	  SELECT op.oid,
	         'pg_operator'::regclass,
	         op.oprname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(op.oprowner) as owner,
	         'OPERATOR' as sql_kind,
	         cast(op.oid::regoperator as text) as sql_identifier,
	         null as acl
	    FROM pg_operator op JOIN pg_namespace n ON n.oid=op.oprnamespace
	   WHERE op.oid = 1
	   UNION
	  SELECT cfg.oid,
	         'pg_ts_config'::regclass,
	         cfg.cfgname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(cfg.cfgowner) as owner,
	         'TEXT SEARCH CONFIGURATION' as sql_kind,
	         cast(cfg.oid::regconfig as text) as sql_identifier,
	         null as acl
	    FROM pg_ts_config cfg JOIN pg_namespace n ON n.oid=cfg.cfgnamespace
	   WHERE cfg.oid = 1
	   UNION
	  SELECT dict.oid,
	         'pg_ts_dict'::regclass,
	         dict.dictname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(dict.dictowner) as owner,
	         'TEXT SEARCH DICTIONARY' as sql_kind,
	         cast(dict.oid::regdictionary as text) as sql_identifier,
	         null as acl
	    FROM pg_ts_dict dict JOIN pg_namespace n ON n.oid=dict.dictnamespace
	   WHERE dict.oid = 1
	   UNION
	  SELECT prs.oid,
	         'pg_ts_parser'::regclass,
	         prs.prsname as name,
	         n.nspname as namespace,
	         null as owner,
	         'TEXT SEARCH PARSER' as sql_kind,
	         format('%s%I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',prs.prsname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_ts_parser prs JOIN pg_namespace n ON n.oid=prs.prsnamespace
	   WHERE prs.oid = 1
	   UNION
	  SELECT tmpl.oid,
	         'pg_ts_template'::regclass,
	         tmpl.tmplname as name,
	         n.nspname as namespace,
	         null as owner,
	         'TEXT SEARCH TEMPLATE' as sql_kind,
	         format('%s%I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',tmpl.tmplname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_ts_template tmpl JOIN pg_namespace n ON n.oid=tmpl.tmplnamespace
	   WHERE tmpl.oid = 1
	   UNION
	  SELECT fdw.oid,
	         'pg_foreign_data_wrapper'::regclass,
	         fdw.fdwname as name,
	         null as namespace,
	         pg_get_userbyid(fdw.fdwowner) as owner,
	         'FOREIGN DATA WRAPPER' as sql_kind,
	         quote_ident(fdw.fdwname) as sql_identifier,
	         fdwacl as acl
	    FROM pg_foreign_data_wrapper fdw
	   WHERE fdw.oid = 1
	   UNION
	  SELECT srv.oid,
	         'pg_foreign_server'::regclass,
	         srv.srvname as name,
	         null as namespace,
	         pg_get_userbyid(srv.srvowner) as owner,
	         'SERVER' as sql_kind,
	         quote_ident(srv.srvname) as sql_identifier,
	         srvacl as acl
	    FROM pg_foreign_server srv
	   WHERE srv.oid = 1
	   UNION
	  SELECT ums.umid,
	         'pg_user_mapping'::regclass,
	         null as name,
	         null as namespace,
	         null as owner,
	         'USER MAPPING' as sql_kind,
	         'FOR '||quote_ident(ums.usename)||
	         ' SERVER '||quote_ident(ums.srvname) as sql_identifier,
	         null as acl
	    FROM pg_user_mappings ums
	   WHERE ums.umid = 1
	   UNION
	  SELECT ca.oid,
	         'pg_cast'::regclass,
	         null as name,
	         null as namespace,
	         null as owner,
	         'CAST' as sql_kind,
	         format('(%s AS %s)',
	           format_type(ca.castsource,null),format_type(ca.casttarget,null))
	           as sql_identifier,
	         null as acl
	    FROM pg_cast ca
	   WHERE ca.oid = 1
	   UNION
	  SELECT co.oid,
	         'pg_collation'::regclass,
	         co.collname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(co.collowner) as owner,
	         'COLLATION' as sql_kind,
	         format('%s%I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',co.collname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_collation co JOIN pg_namespace n ON n.oid=co.collnamespace
	   WHERE co.oid = 1
	   UNION
	  SELECT co.oid,
	         'pg_conversion'::regclass,
	         co.conname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(co.conowner) as owner,
	         'CONVERSION' as sql_kind,
	         format('%s%I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',co.conname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_conversion co JOIN pg_namespace n ON n.oid=co.connamespace
	   WHERE co.oid = 1
	   UNION
	  SELECT lan.oid,
	         'pg_language'::regclass,
	         lan.lanname as name,
	         null as namespace,
	         pg_get_userbyid(lan.lanowner) as owner,
	         'LANGUAGE' as sql_kind,
	         quote_ident(lan.lanname) as sql_identifier,
	         lan.lanacl as acl
	    FROM pg_language lan
	   WHERE lan.oid = 1
	   UNION
	  SELECT opf.oid,
	         'pg_opfamily'::regclass,
	         opf.opfname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(opf.opfowner) as owner,
	         'OPERATOR FAMILY' as sql_kind,
	         format('%s%I USING %I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',
	           opf.opfname,
	           am.amname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_opfamily opf JOIN pg_namespace n ON n.oid=opf.opfnamespace
	    JOIN pg_am am on (am.oid=opf.opfmethod)
	   WHERE opf.oid = 1
	   UNION
	  SELECT dat.oid,
	         'pg_database'::regclass,
	         dat.datname as name,
	         null as namespace,
	         pg_get_userbyid(dat.datdba) as owner,
	         'DATABASE' as sql_kind,
	         quote_ident(dat.datname) as sql_identifier,
	         dat.datacl as acl
	    FROM pg_database dat
	   WHERE dat.oid = 1
	   UNION
	  SELECT spc.oid,
	         'pg_tablespace'::regclass,
	         spc.spcname as name,
	         null as namespace,
	         pg_get_userbyid(spc.spcowner) as owner,
	         'TABLESPACE' as sql_kind,
	         quote_ident(spc.spcname) as sql_identifier,
	         spc.spcacl as acl
	    FROM pg_tablespace spc
	   WHERE spc.oid = 1
	   UNION
	  SELECT opc.oid,
	         'pg_opclass'::regclass,
	         opcname as name,
	         n.nspname as namespace,
	         pg_get_userbyid(opc.opcowner) as owner,
	         'OPERATOR CLASS' as sql_kind,
	         format('%s%I USING %I',
	           quote_ident(nullif(n.nspname,current_schema()))||'.',
	           opc.opcname,
	           am.amname) 
	           as sql_identifier,
	         null as acl
	    FROM pg_opclass opc JOIN pg_namespace n ON n.oid=opc.opcnamespace
	    JOIN pg_am am ON am.oid=opc.opcmethod
	   WHERE opc.oid = 1

ERROR:  column p.proisagg does not exist
LINE 41:             when p.proisagg then 'AGGREGATE'
                          ^
HINT:  Perhaps you meant to reference the column "p.prolang".

  • Ошибка стоила очень дорого
  • Ошибка студенчество отмечали начало каникул является
  • Ошибка стирания команда scsi отменена
  • Ошибка структуры данных карты тахографа атол
  • Ошибка стиральной машины электролюкс е04