Re: datatype.sgml misleading regclass example

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: datatype.sgml misleading regclass example
Date: 2004-10-09 17:01:15
Message-ID: 28531.1097341275@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Michael Fuhr <mike(at)fuhr(dot)org> writes:
> for example, one may write 'mytable'::regclass to get the OID
> of table mytable, rather than SELECT oid FROM pg_class WHERE
> relname = 'mytable'.
> To get the OID, don't we then need to cast to the oid type?

If you want to see it as a numeric value, yeah, but you can for example
compare it to an OID column without doing that.

SELECT attname FROM pg_attribute WHERE attrelid = 'mytable'::regclass;

Most of the time when I'm using a regxxx cast, it's because I *don't*
want to be bothered with the numeric value.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-10-09 23:51:41 Re: 8.0.0beta3 plpython link troubles
Previous Message Michael Fuhr 2004-10-09 16:21:03 datatype.sgml misleading regclass example