Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
273ae970
Commit
273ae970
authored
22 years ago
by
Tom Lane
Browse files
Options
Downloads
Patches
Plain Diff
Add a sanity check to make sure that all system catalogs that have OIDs
also have a unique index on OID.
parent
039cb479
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/regress/expected/sanity_check.out
+16
-0
16 additions, 0 deletions
src/test/regress/expected/sanity_check.out
src/test/regress/sql/sanity_check.sql
+13
-1
13 additions, 1 deletion
src/test/regress/sql/sanity_check.sql
with
29 additions
and
1 deletion
src/test/regress/expected/sanity_check.out
+
16
−
0
View file @
273ae970
...
@@ -65,3 +65,19 @@ SELECT relname, relhasindex
...
@@ -65,3 +65,19 @@ SELECT relname, relhasindex
tenk2 | t
tenk2 | t
(53 rows)
(53 rows)
--
-- another sanity check: every system catalog that has OIDs should have
-- a unique index on OID. This ensures that the OIDs will be unique,
-- even after the OID counter wraps around.
-- We exclude non-system tables from the check by looking at nspname.
--
SELECT relname, nspname
FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
WHERE relhasoids
AND ((nspname ~ '^pg_') IS NOT FALSE)
AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
AND indkey[0] = -2 AND indkey[1] = 0 AND indisunique);
relname | nspname
---------+---------
(0 rows)
This diff is collapsed.
Click to expand it.
src/test/regress/sql/sanity_check.sql
+
13
−
1
View file @
273ae970
VACUUM
;
VACUUM
;
--
--
-- sanity check, if we don't have indices the test will take years to
-- sanity check, if we don't have indices the test will take years to
-- complete. But skip TOAST relations since they will have varying
-- complete. But skip TOAST relations since they will have varying
...
@@ -10,3 +10,15 @@ SELECT relname, relhasindex
...
@@ -10,3 +10,15 @@ SELECT relname, relhasindex
WHERE
relhasindex
AND
relkind
!=
't'
WHERE
relhasindex
AND
relkind
!=
't'
ORDER
BY
relname
;
ORDER
BY
relname
;
--
-- another sanity check: every system catalog that has OIDs should have
-- a unique index on OID. This ensures that the OIDs will be unique,
-- even after the OID counter wraps around.
-- We exclude non-system tables from the check by looking at nspname.
--
SELECT
relname
,
nspname
FROM
pg_class
c
LEFT
JOIN
pg_namespace
n
ON
n
.
oid
=
relnamespace
WHERE
relhasoids
AND
((
nspname
~
'^pg_'
)
IS
NOT
FALSE
)
AND
NOT
EXISTS
(
SELECT
1
FROM
pg_index
i
WHERE
indrelid
=
c
.
oid
AND
indkey
[
0
]
=
-
2
AND
indkey
[
1
]
=
0
AND
indisunique
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment