Re: logical column position

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rod Taylor <pg(at)rbt(dot)ca>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Neil Conway <neilc(at)samurai(dot)com>, Jon Jensen <jon(at)endpoint(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: logical column position
Date: 2003-11-21 16:46:55
Message-ID: 3FBE417F.10109@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:

>Andreas Pflug <pgadmin(at)pse-consulting(dot)de> writes:
>
>
>>Maybe my proposal wasn't clear enough:
>>Just as an index references a pg_class entry by it's OID, not some value
>>identifying it's physical storage, all objects might continue
>>referencing columns by attnum.
>>
>>
>
>That's exactly the same thing I am saying. Your mistake is to assume
>that this function can be combined with identification of a (changeable)
>logical column position. It can't. Changeability and immutability are
>just not compatible requirements.
>
>
In the mind of a programmer, a ALTER COLUMN doesn't create a new column,
but merely changes some attributes of an existing column. In this sense,
changeability and immutability are not controversal.

Digging deeper:

TupDesc contains an array of physical attr descriptions, and to access a
column description attnum is taken as index into that array (taken from
fastgetattr).

return fetchatt(tupleDesc->attrs[attnum-1], ...)

The physical location can easily reordered if there's an additional
array, to translate attnum into the array index.

return fetchatt(tupleDesc->attrs[tupleDesc->attrpos[attnum-1]] ...

For sure, reordering (i.e. changing the attrpos array) may only be
performed as long as the column isn't referenced.

Regards,
Andreas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2003-11-21 17:09:00 Re: [HACKERS] More detail on settings for pgavd?
Previous Message Tom Lane 2003-11-21 16:40:10 Anyone working on pg_dump dependency ordering?