Restore relhaspkey in PostgreSQL Version 11 Beta - Mailing list pgsql-general

From Melvin Davidson
Subject Restore relhaspkey in PostgreSQL Version 11 Beta
Date
Msg-id CANu8Fiy2RZL+uVnnrzaCTJxMgcKBDOnAR7bDx3n0P=KycbSNhA@mail.gmail.com
Whole thread Raw
Responses Re: Restore relhaspkey in PostgreSQL Version 11 Beta
List pgsql-general

In the release notes for Version 11 Beta, under changes, I see these scary
remarks:

Remove relhaspkey column from system table pg_class (Peter Eisentraut)

Applications needing to check for a primary key should consult pg_index.

That absolutely breaks my code (and I'm guessing others), as I have a cron
job that checks for tables that were created with no pkey.
IE: SELECT n.nspname,
       c.relname as table,
       c.reltuples::bigint
  FROM pg_class c
  JOIN pg_namespace n ON (n.oid =c.relnamespace )
 WHERE relkind = 'r' AND
       relname NOT LIKE 'pg_%' AND
       relname NOT LIKE 'sql_%' AND
       relhaspkey = FALSE
ORDER BY n.nspname, c.relname;

relhaspkey has been in pg_class since the earliest version of PostgreSQL. AFAIK
there is NO NEED to remove it! In fact, the system catalogs should only be changed when there is an absolute requirement, not at someone's whim. Adding a column is fine, but dropping columns that breaks code is ridiculous.

Please restore that column before the final release!

--
Melvin Davidson
Maj. Database & Exploration Specialist

Universe Exploration Command – UXC

Employment by invitation only!

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: ALTER ROLE SET search_path produced by pg_dumpall gives : ERROR: syntax error at or near "$" .
Next
From: Tom Lane
Date:
Subject: Re: Restore relhaspkey in PostgreSQL Version 11 Beta