Skip to content

Commit 0a87822

Browse files
committed
Avoid choosing an invalid index as primary key
Fixing the other functions selecting pg_index (as in Josh original patch) doesn't seem necessary as they are only called with an index oid, and we should only call them with a valid index as argument.
1 parent 9f5c4f5 commit 0a87822

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/pg_reorg.sql.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ CREATE VIEW reorg.primary_keys AS
157157
SELECT indrelid, (reorg.array_accum(indexrelid))[1] AS indexrelid
158158
FROM (SELECT indrelid, indexrelid FROM pg_index
159159
WHERE indisunique
160+
AND indisvalid
160161
AND 0 <> ALL(indkey)
161162
AND NOT EXISTS(
162163
SELECT 1 FROM pg_attribute

0 commit comments

Comments
 (0)