get_constraint_index() and conindid

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-12-07T10:09:16Z
Lists: pgsql-hackers

Attachments

get_constraint_index() does its work by going through pg_depend.  It was 
added before pg_constraint.conindid was added, and some callers are 
still not changed.  Are there reasons for that?  Probably not.  The 
attached patch changes get_constraint_index() to an lsyscache-style 
lookup instead.

The nearby get_index_constraint() should probably also be changed to 
scan pg_constraint instead of pg_depend, but that doesn't have a 
syscache to use, so it would be a different approach, so I figured I'd 
ask about get_constraint_index() first.


Commits

  1. Change get_constraint_index() to use pg_constraint.conindid