From: | Justin Tocci <jtocci(at)tocci(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Primary key column numbers... |
Date: | 2005-05-31 16:49:34 |
Message-ID: | 1E819014-574D-4D91-837D-56B71A274486@tocci.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
What I'm trying to do is
IF the relation given is a TABLE, give the primary key column numbers.
IF the relation is a VIEW, just give an array with a '1' in it.
ELSE NULL.
Later I'll put in some hocus-pocus to be more intelligent about VIEWs
but right now this would do me fine.
I've read the docs on arrays and such, I just can't seem to put
together nor cast an array that's compatible with int2vector. There
was some notice to look at contrib/array but that has been removed in
version 8, which is what I'm using.
This is what I have so far.
SELECT indkey
FROM (SELECT relname, indkey
FROM pg_catalog.pg_index join pg_catalog.pg_class
ON pg_index.indrelid = pg_class.oid
WHERE indisprimary=true
UNION
SELECT viewname, ('{1}')::int2vector[] as indkey
FROM pg_catalog.pg_views ) t
WHERE relname = '????'
Result: ERROR: UNION/INTERSECT/EXCEPT could not convert type
int2vector[] to int2vector
Any help here would be appreciated.
justin tocci
fort worth, tx
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Hayward | 2005-05-31 17:03:04 | prevent user change password? |
Previous Message | Scott Marlowe | 2005-05-31 16:37:02 | Re: For Tom Lane |