duplicate_oids 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/perl
  2. #----------------------------------------------------------------------
  3. #
  4. # duplicate_oids
  5. # Identifies any manually-assigned OIDs that are used multiple times
  6. # in the Postgres catalog data.
  7. #
  8. # While duplicate OIDs would only cause a failure if they appear in
  9. # the same catalog, our project policy is that manually assigned OIDs
  10. # should be globally unique, to avoid confusion.
  11. #
  12. # Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  13. # Portions Copyright (c) 1994, Regents of the University of California
  14. #
  15. # src/include/catalog/duplicate_oids
  16. #
  17. #----------------------------------------------------------------------
  18. use strict;
  19. use warnings;
  20. # Must run in src/include/catalog
  21. use FindBin;
  22. chdir $FindBin::RealBin or die "could not cd to $FindBin::RealBin: $!\n";
  23. use lib "$FindBin::RealBin/../../backend/catalog/";
  24. use Catalog;
  25. my @input_files = glob("pg_*.h");
  26. my $oids = Catalog::FindAllOidsFromHeaders(@input_files);
  27. my %oidcounts;
  28. foreach my $oid (@{$oids})
  29. {
  30. $oidcounts{$oid}++;
  31. }
  32. my $found = 0;
  33. foreach my $oid (sort { $a <=> $b } keys %oidcounts)
  34. {
  35. next unless $oidcounts{$oid} > 1;
  36. $found = 1;
  37. print "$oid\n";
  38. }
  39. exit $found;