File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -65,3 +65,19 @@ SELECT relname, relhasindex
65
65
tenk2 | t
66
66
(53 rows)
67
67
68
+ --
69
+ -- another sanity check: every system catalog that has OIDs should have
70
+ -- a unique index on OID. This ensures that the OIDs will be unique,
71
+ -- even after the OID counter wraps around.
72
+ -- We exclude non-system tables from the check by looking at nspname.
73
+ --
74
+ SELECT relname, nspname
75
+ FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
76
+ WHERE relhasoids
77
+ AND ((nspname ~ '^pg_') IS NOT FALSE)
78
+ AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
79
+ AND indkey[0] = -2 AND indkey[1] = 0 AND indisunique);
80
+ relname | nspname
81
+ ---------+---------
82
+ (0 rows)
83
+
Original file line number Diff line number Diff line change 1
-
2
1
VACUUM;
2
+
3
3
--
4
4
-- sanity check, if we don't have indices the test will take years to
5
5
-- complete. But skip TOAST relations since they will have varying
@@ -10,3 +10,15 @@ SELECT relname, relhasindex
10
10
WHERE relhasindex AND relkind != ' t'
11
11
ORDER BY relname;
12
12
13
+ --
14
+ -- another sanity check: every system catalog that has OIDs should have
15
+ -- a unique index on OID. This ensures that the OIDs will be unique,
16
+ -- even after the OID counter wraps around.
17
+ -- We exclude non-system tables from the check by looking at nspname.
18
+ --
19
+ SELECT relname, nspname
20
+ FROM pg_class c LEFT JOIN pg_namespace n ON n .oid = relnamespace
21
+ WHERE relhasoids
22
+ AND ((nspname ~ ' ^pg_' ) IS NOT FALSE)
23
+ AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c .oid
24
+ AND indkey[0 ] = - 2 AND indkey[1 ] = 0 AND indisunique);
You can’t perform that action at this time.
0 commit comments