Fix constraint_column_usage for foreign keys.
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 16 Dec 2003 14:56:34 +0000 (14:56 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 16 Dec 2003 14:56:34 +0000 (14:56 +0000)
src/backend/catalog/information_schema.sql

index aeb4e7101eace732c0249a7c3a045ff5852bffbe..9764097044076c8d8256a72f0388306bddc68e60 100644 (file)
@@ -445,10 +445,9 @@ CREATE VIEW constraint_column_usage AS
                pg_constraint c, _pg_keypositions() AS pos(n)
           WHERE nr.oid = r.relnamespace
             AND r.oid = a.attrelid
-            AND r.oid = c.conrelid
             AND nc.oid = c.connamespace
-            AND (CASE WHEN c.contype = 'f' THEN c.confkey[pos.n] = a.attnum
-                      ELSE c.conkey[pos.n] = a.attnum END)
+            AND (CASE WHEN c.contype = 'f' THEN r.oid = c.confrelid AND c.confkey[pos.n] = a.attnum
+                      ELSE r.oid = c.conrelid AND c.conkey[pos.n] = a.attnum END)
             AND a.attnum > 0
             AND NOT a.attisdropped
             AND c.contype IN ('p', 'u', 'f')