@@ -968,75 +968,6 @@ getIdentitySequence(Oid relid, AttrNumber attnum, bool missing_ok)
968968 return linitial_oid (seqlist );
969969}
970970
971- /*
972- * get_constraint_index
973- * Given the OID of a unique, primary-key, or exclusion constraint,
974- * return the OID of the underlying index.
975- *
976- * Return InvalidOid if the index couldn't be found; this suggests the
977- * given OID is bogus, but we leave it to caller to decide what to do.
978- */
979- Oid
980- get_constraint_index (Oid constraintId )
981- {
982- Oid indexId = InvalidOid ;
983- Relation depRel ;
984- ScanKeyData key [3 ];
985- SysScanDesc scan ;
986- HeapTuple tup ;
987-
988- /* Search the dependency table for the dependent index */
989- depRel = table_open (DependRelationId , AccessShareLock );
990-
991- ScanKeyInit (& key [0 ],
992- Anum_pg_depend_refclassid ,
993- BTEqualStrategyNumber , F_OIDEQ ,
994- ObjectIdGetDatum (ConstraintRelationId ));
995- ScanKeyInit (& key [1 ],
996- Anum_pg_depend_refobjid ,
997- BTEqualStrategyNumber , F_OIDEQ ,
998- ObjectIdGetDatum (constraintId ));
999- ScanKeyInit (& key [2 ],
1000- Anum_pg_depend_refobjsubid ,
1001- BTEqualStrategyNumber , F_INT4EQ ,
1002- Int32GetDatum (0 ));
1003-
1004- scan = systable_beginscan (depRel , DependReferenceIndexId , true,
1005- NULL , 3 , key );
1006-
1007- while (HeapTupleIsValid (tup = systable_getnext (scan )))
1008- {
1009- Form_pg_depend deprec = (Form_pg_depend ) GETSTRUCT (tup );
1010-
1011- /*
1012- * We assume any internal dependency of an index on the constraint
1013- * must be what we are looking for.
1014- */
1015- if (deprec -> classid == RelationRelationId &&
1016- deprec -> objsubid == 0 &&
1017- deprec -> deptype == DEPENDENCY_INTERNAL )
1018- {
1019- char relkind = get_rel_relkind (deprec -> objid );
1020-
1021- /*
1022- * This is pure paranoia; there shouldn't be any other relkinds
1023- * dependent on a constraint.
1024- */
1025- if (relkind != RELKIND_INDEX &&
1026- relkind != RELKIND_PARTITIONED_INDEX )
1027- continue ;
1028-
1029- indexId = deprec -> objid ;
1030- break ;
1031- }
1032- }
1033-
1034- systable_endscan (scan );
1035- table_close (depRel , AccessShareLock );
1036-
1037- return indexId ;
1038- }
1039-
1040971/*
1041972 * get_index_constraint
1042973 * Given the OID of an index, return the OID of the owning unique,
0 commit comments