iterating over relation's attributes

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: iterating over relation's attributes
Date: 2007-05-05 17:09:31
Message-ID: 463CBA4B.9010206@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


What is the approved way to iterate over a relation's attributes? I see
that lsyscache.c::get_relnatts() is marked NOT_USED and has been for
nearly seven years. Maybe it's time to remove that code ;-)

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: iterating over relation's attributes
Date: 2007-05-05 18:45:56
Message-ID: 25875.1178390756@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> What is the approved way to iterate over a relation's attributes?

Most places scan through the relation's tuple descriptor, rather
than expending multiple catalog lookups in pg_attribute.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: iterating over relation's attributes
Date: 2007-05-05 20:00:05
Message-ID: 463CE245.7010700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>
>> What is the approved way to iterate over a relation's attributes?
>>
>
> Most places scan through the relation's tuple descriptor, rather
> than expending multiple catalog lookups in pg_attribute.
>
>
>

Doesn't that require me to open the relation? Is that a good thing if I
wouldn't otherwise be doing that?

This is in the context of making CheckAttributeType recurse into
composite types.

cheers

andrew


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: iterating over relation's attributes
Date: 2007-05-06 00:13:35
Message-ID: 29387.1178410415@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> Tom Lane wrote:
>> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>> What is the approved way to iterate over a relation's attributes?
>>
>> Most places scan through the relation's tuple descriptor, rather
>> than expending multiple catalog lookups in pg_attribute.

> Doesn't that require me to open the relation? Is that a good thing if I
> wouldn't otherwise be doing that?

Sure, because whatever work gets done is likely to be amortized across
multiple uses of the relcache entry anyway.

regards, tom lane