Обсуждение: Retrieving a column comment

Поиск
Список
Период
Сортировка

Retrieving a column comment

От
Oliver Kohll
Дата:
Hi,

I can't seem to retrieve a comment on a table column. The following copy from
psql should I think return a comment:

====================
mydatabase=> COMMENT ON COLUMN car.manufacturer IS 'manufacturer name';
COMMENT
mydatabase=> SELECT relnamespace FROM pg_class WHERE relname='car';
 relnamespace
--------------
         2200
(1 row)

mydatabase=> SELECT col_description(2200,1);
 col_description
-----------------

(1 row)

====================
i.e. it just returns a blank row.

The col_description is described at
http://www.postgresql.org/docs/7.3/static/functions-misc.html
The field number supplied above '1' is right if the first col in a table is
'0', in fact no number I've tried returns anything.

I can't seem to find any examples at all on the web about retrieving column
COMMENTs. Has anyone done this? Postgres version is 7.3

Regards,

Oliver Kohll
GT webMarque
--


Re: Retrieving a column comment

От
Alvaro Herrera
Дата:
On Sun, Oct 26, 2003 at 10:02:22PM +0000, Oliver Kohll wrote:

> I can't seem to retrieve a comment on a table column. The following copy from
> psql should I think return a comment:
>
> mydatabase=> SELECT relnamespace FROM pg_class WHERE relname='car';
>  relnamespace
> --------------
>          2200
> (1 row)

Try using relfilenode instead of relnamespace.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Hay que recordar que la existencia en el cosmos, y particularmente la
elaboración de civilizaciones dentre de él no son, por desgracia,
nada idílicas" (Ijon Tichy)

Re: Retrieving a column comment

От
Oliver Kohll
Дата:
On Sunday 26 October 2003 23:03, Alvaro Herrera wrote:
> On Sun, Oct 26, 2003 at 10:02:22PM +0000, Oliver Kohll wrote:
> > I can't seem to retrieve a comment on a table column. The following copy
> > from psql should I think return a comment:
> >
> > mydatabase=> SELECT relnamespace FROM pg_class WHERE relname='car';
> >  relnamespace
> > --------------
> >          2200
> > (1 row)
>
> Try using relfilenode instead of relnamespace.

Great, thanks Alvaro. The webpage I found the original code in must have been
wrong but that's it.

Oliver


Re: Retrieving a column comment

От
Tom Lane
Дата:
Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
> On Sun, Oct 26, 2003 at 10:02:22PM +0000, Oliver Kohll wrote:
>> I can't seem to retrieve a comment on a table column. The following copy from
>> psql should I think return a comment:
>>
>> mydatabase=> SELECT relnamespace FROM pg_class WHERE relname='car';
>> relnamespace
>> --------------
>> 2200
>> (1 row)

> Try using relfilenode instead of relnamespace.

Actually what he wants is the oid.  relfilenode is not relevant to
anything except the table's disk file name.

            regards, tom lane