Correctly populates the "position_in_unique_constraint" column in the
information_schema.key_column_usage view.

--
Greg Sabino Mullane [EMAIL PROTECTED]
End Point Corporation
PGP Key: 0x14964AC8 200608182231
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

Index: information_schema.sql
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/catalog/information_schema.sql,v
retrieving revision 1.33
diff -u -c -r1.33 information_schema.sql
*** information_schema.sql	2 Apr 2006 17:38:13 -0000	1.33
--- information_schema.sql	19 Aug 2006 02:28:51 -0000
***************
*** 921,931 ****
             CAST(relname AS sql_identifier) AS table_name,
             CAST(a.attname AS sql_identifier) AS column_name,
             CAST((ss.x).n AS cardinal_number) AS ordinal_position,
!            CAST(null AS cardinal_number) AS position_in_unique_constraint  -- FIXME
      FROM pg_attribute a,
!          (SELECT r.oid, nc.nspname AS nc_nspname, c.conname,
                   nr.nspname AS nr_nspname, r.relname,
!                 _pg_expandarray(c.conkey) AS x
            FROM pg_namespace nr, pg_class r, pg_namespace nc,
                 pg_constraint c
            WHERE nr.oid = r.relnamespace
--- 921,937 ----
             CAST(relname AS sql_identifier) AS table_name,
             CAST(a.attname AS sql_identifier) AS column_name,
             CAST((ss.x).n AS cardinal_number) AS ordinal_position,
!            (
!              SELECT CAST(a AS cardinal_number)
!              FROM pg_constraint,
!                (SELECT a FROM generate_series(1,(SELECT array_upper(ss.confkey,1))) f(a)) AS foo
!              WHERE conrelid = ss.confrelid
!              AND conkey[foo.a] = ss.confkey[(ss.x).n]
!            ) AS position_in_unique_constraint
      FROM pg_attribute a,
!          (SELECT r.oid, nc.nspname AS nc_nspname, c.conname, c.confkey,
                   nr.nspname AS nr_nspname, r.relname,
!                  _pg_expandarray(c.conkey) AS x
            FROM pg_namespace nr, pg_class r, pg_namespace nc,
                 pg_constraint c
            WHERE nr.oid = r.relnamespace

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to