Skip site navigation (1) Skip section navigation (2)

Re: change natural column order

From: Daniel Martini <dmartini(at)uni-hohenheim(dot)de>
To: Joolz <joolz(at)arbodienst-limburg(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org,Tino Wildenhain <tino(at)wildenhain(dot)de>
Subject: Re: change natural column order
Date: 2004-11-30 14:11:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general

Joolz, you already got quite a few answers, that the frontend is probably
not properly designed, if it relies on a certain column ordering. I agree
completely with that. However your question got me curious, and I've digged
around a bit in the system tables. You might be interested in my findings.
See below.

Citing Joolz <joolz(at)arbodienst-limburg(dot)nl>:
> I agree. Only I think this wouldn't require new functionality, I
> have a gut feeling that this is possible as it is. Now only find out
> how :)
> I'll have a look at the system tables (that's where the answer must
> be) but maybe someone who has done this can save me the time...

If you do:
set search_path=information_schema;
\d columns
and look at the Columns defined, you'll find a column called ordinal_position,
which incidentally corresponds to the position of the columns on output. If
you dig a bit further and look at the definition of the columns view, you'll
find, that this column comes from a column attnum in pg_attribute. As
database superuser, you can actually change the values of attnum, however
doing so results in:
ERROR:  invalid memory alloc request size 4294967295
on queries on the tables for which you changed attnum. So:
1.) obviously PostgreSQL does not like it at all (at least on my platform,
    which is OpenBSD 3.6)
2.) I wouldn't risk messing with a system table, which I can only write to
    if I'm superuser if I don't completely understand what's happening
    behind the scenes (at least not for production use).
3.) changing that behaviour is probably a lot more work than changing the 


In response to


pgsql-general by date

Next:From: MageDate: 2004-11-30 14:50:45
Subject: Re: change natural column order
Previous:From: Richard HuxtonDate: 2004-11-30 13:16:39
Subject: Re: starting the database server

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group