skip to Main Content

I’ve problem with my database running on postgresql 16.2. My application is running fine, it can query data, but I’m not able to create a backup using pg_dump or inspect database via psql.

Running pd_dump ends in following error:

pg_dump: error: query failed: ERROR:  could not find hash function for hash operator 607
pg_dump: detail: Query was: SELECT c.tableoid, c.oid, c.relname, c.relnamespace, c.relkind, c.reltype, c.relowner, c.relchecks, c.relhasindex, c.relhasrules, c.relpages, c.relhastriggers, c.relpersistence, c.reloftype, c.relacl, acldefault(CASE WHEN c.relkind = 'S' THEN 's'::"char" ELSE 'r'::"char" END, c.relowner) AS acldefault, CASE WHEN c.relkind = 'f' THEN (SELECT ftserver FROM pg_catalog.pg_foreign_table WHERE ftrelid = c.oid) ELSE 0 END AS foreignserver, c.relfrozenxid, tc.relfrozenxid AS tfrozenxid, tc.oid AS toid, tc.relpages AS toastpages, tc.reloptions AS toast_reloptions, d.refobjid AS owning_tab, d.refobjsubid AS owning_col, tsp.spcname AS reltablespace, false AS relhasoids, c.relispopulated, c.relreplident, c.relrowsecurity, c.relforcerowsecurity, c.relminmxid, tc.relminmxid AS tminmxid, array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded') AS reloptions, CASE WHEN 'check_option=local' = ANY (c.reloptions) THEN 'LOCAL'::text WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'CASCADED'::text ELSE NULL END AS checkoption, am.amname, (d.deptype = 'i') IS TRUE AS is_identity_sequence, c.relispartition AS ispartition 
FROM pg_class c
LEFT JOIN pg_depend d ON (c.relkind = 'S' AND d.classid = 'pg_class'::regclass AND d.objid = c.oid AND d.objsubid = 0 AND d.refclassid = 'pg_class'::regclass AND d.deptype IN ('a', 'i'))
LEFT JOIN pg_tablespace tsp ON (tsp.oid = c.reltablespace)
LEFT JOIN pg_am am ON (c.relam = am.oid)
LEFT JOIN pg_class tc ON (c.reltoastrelid = tc.oid AND tc.relkind = 't' AND c.relkind <> 'p')
WHERE c.relkind IN ('r', 'S', 'v', 'c', 'm', 'f', 'p')
ORDER BY c.oid

Do you have any idea how to get rid of this error?

I have same error when i try to inspect tables in psql:

# dt
ERROR:  could not find hash function for hash operator 607

2

Answers


  1. You are almost certainly running a different version of pg_dump/psql (e.g. v14 or v15) than the version of server you are using (v16). You can use newer versions of client tools with an older server but not the other way around

    Login or Signup to reply.
  2. You are suffering from data corruption: some system catalog entries are missing. Restore your last good backup if you can.

    As a superuser, you can restore the missing entry:

    INSERT INTO pg_catalog.pg_operator
       (oid, oprname,  oprnamespace, oprowner, oprkind, oprcanmerge, oprcanhash, oprleft, oprright, oprresult, oprcom, oprnegate, oprcode, oprrest, eqsel, oprjoin)
       VALUES
       (607, '=', 11, 10, 'b', TRUE, TRUE, 26, 26, 16, 607, 608,'oideq(oid,oid)'::regprocedure, 'eqsel(internal,oid,internal,integer)'::regprocedure, 'eqjoinsel(internal,oid,internal,smallint,internal)'::regprocedure);
    

    But who knows what else is missing…

    If you get the database to dump, don’t continue working with it. Restore the dump to a new, clean database.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search